text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>//! To render custom error pages, you can create a layout component that captures errors from routes //! with an `ErrorBoundary` and display different content based on the error type. //! //! While capturing the error, we set the appropriate HTTP status code using `FullstackContext::commit_error_status`. ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>#![allow(non_snake_case)] use dioxus::prelude::*; fn main() { // Make sure to set the url of the server where server functions are hosted - they aren't always at localhost #[cfg(not(feature = "server"))] dioxus::fullstack::set_server_url("http://127.0.0.1:8080"); dioxus::launch(app); } ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example showcases a fullstack variant of the "dog app" demo, but with the loader and actions //! self-hosted instead of using the Dog API. use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { // Fetch the list of breeds from the Dog API, using the `?` syntax...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example shows how to get access to the full axum request in a handler. //! //! <|fim_suffix|>intln!("No API key found"); } Ok(()) } <|fim_middle|>The extra arguments in the `post` macro are passed to the handler function, but not exposed //! to the client. This means we can still call th...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>says: "} pre { "{message:?}"} button { onclick: move |_| message.call("world".into(), 30), "Click me!" } } }); } #[get("/api/:name/?age")] async fn get_message(name: String, age: i32) -> Result<String> { Ok(format!("Hello {}, you are {} years old!", name, age)) } <...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! An example of handling errors from server functions. //! //! This example showcases a few important error handling patterns when using Dioxus Fullstack. //! //! Run with: //! //! ```sh //! dx serve --web //! ``` //! //! What this example shows: //! - You can return `anyhow::Result<T>` (i.e. `Result<T>...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>#[get("/api/example", headers: dioxus::fullstack::HeaderMap)] async fn get_headers() -> Result<String> { Ok(format!("{:#?}", headers)) } <|fim_prefix|>//! This example shows how you can extract a HeaderMap from requests to read custom headers. //! //! The extra arguments in the `#[get(...)]` macro are...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>tring> { Ok(format!( "Hello from the server, {}! You are {} years old. 🚀", name, age )) } <|fim_prefix|>//! A simple hello world <|fim_middle|>example for Dioxus fullstack //! //! Run with: //! //! ```sh //! dx serve --web //! ``` //! //! This example demonstrates a simple Dioxus ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example demonstrates how to use types like `Form`, `SetHeader`, and `TypedHeader` //! to create a simple login form that sets a cookie in the browser and uses it for authentication //! on a protected endpoint. //! //! For more information on handling forms in general, see the multipart_form examp...
fim
DioxusLabs/dioxus
rust
//! This example shows how to use middleware in a fullstack Dioxus app. //! //! Dioxus supports two ways of middleware: //! - Applying layers to the top-level axum router //! - Apply `#[middleware]` attributes to individual handlers use dioxus::prelude::*; #[cfg(feature = "server")] use {std::time::Duration, tower_ht...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>mit your resume" } } } } } /// Upload a form as multipart form data. /// /// MultipartFormData is typed over the form data structure, allowing us to extract /// both files and other form fields in a type-safe manner. /// /// On the server, we have access to axum's `Multipart` extr...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! An example showcasing query parameters in Dioxus Fullstack server functions. //! //! The query parameter syntax mostly follows axum, but with a few extra conveniences. //! - can rename parameters in the function signature with `?age=age_in_years` where `age_in_years` is Rust variable name //! - can ab...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>{ "Welcome home" } form { method: "post", action: "/api/old-blog", button { "Go to blog" } } } } #[component] fn Blog() -> Element { rsx! { h1 { "Welcome to the blog!" } } } #[post("/api/old-blog")] async fn redirect_to_blog() -> Re...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Run with: //! //! ```sh //! dx serve --platform web //! ``` use dioxus::prelude::*; fn main() { dioxus::LaunchBuilder::new() .with_cfg(server_only!( ServeConfig::builder().incremental( dioxus::server::IncrementalRendererConfig::default() .i...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example is a simple showcase of Dioxus Server Functions. //! //! The other examples in this folder showcase advanced features of server functions like custom //! data types, error handling, websockets, and more. //! //! This example is meant to just be a simple starting point to show how server f...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>nt { Yay { message: String }, Nay { error: String }, } /// Our SSE endpoint, when called, will return the ServerEvents handle which streams events to the client. /// On the client, we can interact with this stream object to get new events as they arrive. #[get("/api/sse")] async fn listen_for_cha...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example shows how to use global state to maintain state between server functions. use std::rc::Rc; use axum_core::extract::{FromRef, FromRequest}; use dioxus::{ fullstack::{FullstackContext, extract::State}, prelude::*, }; use reqwest::header::HeaderMap; #[cfg(feature = "server")] use ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>endering until the future resolves. let post_data = use_loader(move || get_post(id()))?; rsx! { h1 { "Post {id}" } p { "{post_data}" } } } #[get("/api/post/{id}")] async fn get_post(id: u32) -> Result<String, HttpError> { match id { 1 => Ok("first post".to_string(...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example shows how to use the `Streaming<T, E>` type to send streaming responses from the //! server to the client (and the client to the server!). //! //! The `Streaming<T, E>` type automatically coordinates sending and receiving streaming data over HTTP. //! The `T` type parameter is the type of...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>le if there was an error during upload. if errored { _ = file.sync_data().await; let _ = tokio::fs::remove_file(&upload_file).await; HttpError::internal_server_error("Failed to upload file")?; } Ok(uploaded as u32) } /// Upload a file as a raw byte stream. This requir...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example demonstrates that dioxus server functions can be called directly as a Rust //! function or via an HTTP request using reqwest. //! //! Dioxus server functions generated a REST endpoint that can be called using any HTTP client. //! By default, they also support different serialization forma...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>nc move { loop { // Wait for the socket to connect _ = socket.connect().await; // Loop poll with recv. Throws an error when the connection closes, making it possible // to run code before the socket re-connects when the name input changes ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Managing focus //! //! This example shows how to manage focus in a Dioxus application. We implement a "roulette" that focuses on each <|fim_suffix|>:rc::Rc; use async_std::task::sleep; use dioxus::prelude::*; const STYLE: Asset = asset!("/examples/assets/roulette.css"); fn main() { dioxus::laun...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>h, initial-scale=1.0" /> <style>body { background-color: olive; }</style> </head> <body> <h1>External HTML</h1> <div id="main"></div> </body> </html> "# .into(), ), ) .launch(app); } fn app() -> Element { rsx! { h1 { "Custo...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>Item::select_all(None), &MenuItem::with_id("switch-text", "Switch text", true, None), ]) .unwrap(); menu.append(&edit_menu).unwrap(); // Create a desktop config that overrides the default menu with the custom menu let config = dioxus::desktop::Config::new().with_m...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>oninput: move |e| { items.write()[index].contents = e.value(); } } } } } } } } } fn initial_kanban_data() -> Vec<Item> { ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>n Rust and JS. let mut eval = document::eval( r#" dioxus.send("Hi from JS!"); let msg = await dioxus.recv(); console.log(msg); return "hi from JS!"; "#, ); // Send a message to the JS code. ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example shows how to use the `file` methods on FormEvent and DragEvent to handle file uploads and drops. //! //! Dioxus intercepts these events and provides a Rusty interface to the file data. Since we want this interface to //! be crossplatform, use dioxus::html::HasFileData; use dioxus::prelud...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ndler, it might navigate the page depending on the webview. // We suggest always attaching a submit handler to the form. onsubmit: move |ev| { println!("Submit event: {:#?}", ev); submitted_values.set(ev.values()); ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Dioxus ships out-of-the-box with tracing hooks that integrate with the Dioxus-CLI. //! //! The built-in tracing-subscriber automatically sets up a wasm panic hook and wires up output //! to be consumed in a machine-readable format when running under `dx`. //! //! You can disable the built-in tracing-s...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>::launch(app); } fn app() -> Element { let onclick = move |_| { dioxus::desktop::window().new_window(VirtualDom::new(popup), Default::default()); }; rsx! { button { onclick, "New Window" } } } fn popup() -> Element { let mut count = use_signal(|| 0); rsx! { ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> app() -> Element { use_hook(|| { // Set the close behavior for the main window // This will hide the window instead of closing it when the user clicks the close button window().set_close_behavior(WindowCloseBehaviour::WindowHides); // Initialize the tray icon with a d...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>t { href: asset!("/examples/assets/read_size.css") } div { width: "50%", height: "50%", background_color: "red", onresize: move |evt| dimensions.set(evt.data().get_content_box_size().unwrap()), "This element is {dimensions():?}" }...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> } h2 { class: animated_classes().join(" "), onvisible: move |evt| { let data = evt.data(); if let Ok(is_intersecting) = data.is_intersecting() { animated_classes.write()[1] = if is_intersecti...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> background_color: "black", onmousedown: move |_| dioxus::desktop::window().drag(), } "This is an overlay!" } } } } fn make_config() -> dioxus::desktop::Config { dioxus::desktop::Config::default().with_window(m...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Read the size of elements using the MountedData struct. //! //! Whenever an Element is finally mounted to the Dom, its data is available to be read. //! These fields can typically only be read asynchronously, since various renderers need to release the main thread to //! perform layout and painting. ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>0.0, 20.0 * value), ScrollBehavior::Smooth) .await .unwrap(); } } }, } } } } } <|fim_prefix|>//! Scroll elements using the...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> onmounted: move |cx| header_element.set(Some(cx.data())), "Scroll to top example" } for i in 0..100 { div { "Item {i}" } } button { onclick: move |_| async move { if let Som...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Add global shortcuts to your app while a component is active //! //! This demo shows how to add a global shortcut to your app that toggles a signal. You could use this to implement //! a raycast-type app, or to add a global shortcut to your app that toggles a component on and off. //! //! These are *g...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>vdom)); // We can render to a buf directly too let mut file = String::new(); let mut renderer = dioxus_ssr::Renderer::default(); renderer.render_to(&mut file, &vdom).unwrap(); println!("{file}"); } fn app() -> Element { rsx!( div { h1 { "Title" } p...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> div { // You can set the title of the page with the Title component // In web applications, this sets the title in the head. // On desktop, it sets the window title Title { "My Application (Count {count})" } button { onclick: move |_| count ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ry_sep = format!("\r\n--{boundary}\r\n"); let boundary_closer = format!("\r\n--{boundary}\r\n"); resp = resp.header( CONTENT_TYPE, format!("multipart/byteranges; boundary={boundary}"), ); for (end, start) in ranges { ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>gpu::MultisampleState::default(), multiview_mask: None, cache: None, }); let config = wgpu::SurfaceConfiguration { usage: wgpu::TextureUsages::RENDER_ATTACHMENT, format: swapchain_format, width: size.width, height: si...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example demonstrates how to handle window events and change window properties. //! //! We're able to do things like: //! - implement window dragging //! - toggle fullscreen //! - toggle always on top //! - toggle window decorations //! - change the window title //! //! The entire featuresuite of ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Listen for window focus events using a wry event handler //! //! This example shows how to use the use_wry_event_handler hook to listen for window focus events. //! We can intercept any Wry event, but in this case we're only interested in the WindowEvent::Focused event. //! //! This lets you do things...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>t { let mut user_input = use_signal(String::new); let window = dioxus::desktop::use_window(); let close_window = move |_| { println!("Attempting to close Window B"); window.close(); }; rsx! { div { h1 { "Compose a new email" } button { ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Adjust the zoom of a desktop app //! //! This example shows how to adjust the zoom of a desktop app using <|fim_suffix|> input { r#type: "number", value: "{level}", oninput: move |e| { if let Ok(new_zoom) = e.value().parse::<f64>() { ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>move |event: Event<SelectionData>| log_event(Rc::new(event.data().selection())), onselectstart: move |event: Event<SelectionData>| log_event(Rc::new(event.data().selection())), onselectionchange: move |event: Event<SelectionData>| log_event(Rc::new(event.dat...
fim
DioxusLabs/dioxus
rust
//! This example demonstrates how to create a generic component in Dioxus. //! //! Generic components can be useful when you want to create a component that renders differently depending on the type //! of data it receives. In this particular example, we're just using a type that implements `Display` and `PartialEq`, ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Optional props //! //! This example demonstrates how to use optional props in your components. The `Button` component has several props, //! and we use a variety of attributes to set them. use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { rsx! { // We ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ent { rsx! { p { "{text}" } } } // no_case_check disables PascalCase checking if you *really* want a snake_case component. // This will likely be deprecated/removed in a future update that will introduce a more polished linting system, // something like Clippy. #[component(no_case_check)]...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>{ "{b}" } div { "{c}" } div { {children} } div { onclick } } } <|fim_prefix|>//! Dioxus supports shorthand syntax for creating elements and components. use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { let a = 123; let b = 456; ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! A few ways of mapping elements into rsx! syntax //! //! Rsx allows anything that's an iterator where the output type implements Into<Element>, so you can use any of the following: use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { rsx!( div { ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! This example demonstrates how to use the spread operator to pass attributes to child components. //! //! This lets components like the `Link` allow the user to extend the attributes of the underlying `a` tag. //! These attributes are bundled into a `Vec<Attribute>` which can be spread into the child c...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Dioxus allows webcomponents to be created with a simple syntax. //! //! Read more about webcomponents [here](https://developer.mozilla.org/en-US/docs/Web/Web_Components) //! //! We typically suggest wrapping webcomponents in a strongly typed interface using a component. use dioxus::prelude::*; fn ma...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ype: "text", oninput: move |e| contents.set(e.value()), } } } } <|fim_prefix|>//! XSS Safety //! //! This example proves that Dioxus is safe from XSS attacks. use dioxus::prelude::*; fn main() { dioxus::launch<|fim_middle|>(app); } fn app() -> Element { l...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! A "sketch" of how to integrate a Dioxus Native app to into a wider application //! by rendering the UI to a texture and driving it with your own event loop //! //! (this example is not really intended to be run as-is, and requires you to fill //! in the missing pieces) use anyrender_vello::VelloSceneP...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>sWith(version); }) .map(function (key) { /* Return a promise that's fulfilled when each outdated cache is deleted. */ return caches.delete(key); }) ); }) .then(function () { //console...
fim
DioxusLabs/dioxus
javascript
use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { rsx! ( div { style: "text-align: center;", h1 { "🌗 Dioxus 🚀" } h3 { "Frontend that scales." } p { "Build web, desktop, and mobile apps with Dioxus" } } ) } <|endoftext|>
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { let grey_background = true; rsx! { Stylesheet { href: asset!("/assets/tailwind.css") } div { header { class: "text-gray-400 body-font", // you can use...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>: f32 = start_time.elapsed().as_millis() as f32 / 500.; let [light_red, light_green, light_blue] = light; let immediates = Immediates { light_color_and_time: [light_red, light_green, light_blue, elapsed], }; let mut encoder = self .device ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>olor>) -> Element { let (sender, demo_widget_attr) = use_hook(|| { let demo_widget = DemoWidget::new(); let sender = demo_widget.sender(); let attr = CustomWidgetAttr::new(demo_widget); (sender, attr) }); use_effect(move || { sender.send(DemoMessage::Se...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use std::path::PathBuf; struct Example { name: String, path: PathBuf, } fn main() { let dir = PathBuf::from("/Users/jonathankelley/Development/dioxus/examples"); let out_file = PathBuf::from("/Users/jonathankelley/Development/dioxus/target/decl.toml"); let mut <|fim_suffix|>le_stem(...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>#![warn(missing_docs)] //! The asset resolver for the Dioxus bundle format. Each platform has its own way of resolving assets. This crate handles //! resolving assets in a cross-platform way. //! //!<|fim_suffix|>; /// # } /// ``` #[allow(unused)] pub fn asset_path(asset: impl ToString) -> Result<PathBuf,...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Native specific utilities for resolving assets in a bundle. This module is intended for use in renderers that //! need to resolve asset bundles for resources like images, and fonts. use http::{Response, status::StatusCode}; use std::path::{Path, PathBuf}; use crate::{AssetPathError, NativeAssetResol...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>cted a js_sys::Error, got: {:?}", value) } } } pub(crate) async fn resolve_web_asset(path: &str) -> Result<Vec<u8>, WebAssetResolveError> { let url = if path.starts_with("/") { path.to_string() } else { format!("/{path}") }; let request = Request::new_with_str...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>esult { self.buf.push_str(s); Ok(()) } } <|fim_prefix|>//! The output buffer that supports some helpful methods //! These are separate from the input so we can lend references between the two use std::fmt::{Result, Write}; use dioxus_rsx::IfmtInput; use crate::indent::IndentOptions;...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> let parsed = syn::parse_file(contents).expect("parse file okay"); let macros = collect_from_file(&parsed); assert_eq!(macros.len(), 3); } /// Ensure that we only collect non-skipped macros #[test] fn dont_collect_skipped_macros() { let contents = include_str!("../tests/samples/skip.rsx"); ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>: &str) -> usize { line.chars() .map(|ch| if ch == '\t' { self.width } else { 1 }) .sum() } /// Estimates how many times the line has been indented. pub fn count_indents(&self, mut line: &str) -> usize { let mut indent = 0; while !line.is_empty(...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>e file so an accompanying IDE tool can map these changes /// back to the file precisely. /// /// Nested blocks of RSX will be handled automatically /// /// This returns an error if the rsx itself is invalid. /// /// Will early return if any of the expressions are not complete. Even though we *could* retur...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use dioxus_rsx::CallBody; use syn::{Expr, File, Item, MacroDelimiter, parse::Parser, visit_mut::VisitMut}; use crate::{IndentOptions, Writer}; impl Writer<'_> { pub fn unparse_expr(&mut self, expr: &Expr) -> String { unparse_expr(expr, self.raw_src, &self.out.indent) } pub fn unpars...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{IndentOptions, buffer::Buffer}; use dioxus_rsx::*; use proc_macro2::{LineColumn, Span}; use quote::ToTokens; use regex::Regex; use std::{ borrow::Cow, collections::{HashMap, HashSet, VecDeque}, fmt::{Result, Write}, }; use syn::{Expr, spanned::Spanned, token::Brace}; #[derive(Debu...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>#[test] fn no_parse() { let src = include_str!("./partials/no_parse.rsx"); assert!(syn::parse_file(src).is_err()); } #[test] fn parses_but_fmt_fails() { let src = include_str!("./partials/wrong.rsx"); let file = syn::parse_file(src).unwrap(); let formatted = dioxus_autofmt<|fim_suffix...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>default())); let twice = dioxus_autofmt::apply_formats(&once, dioxus_autofmt::fmt_file(&once, Default::default())); let thrice = dioxus_autofmt::apply_formats(&twice, dioxus_autofmt::fmt_file(&twice, Default::default())); pretty_assertions::assert_eq!(&once, &twice, "pass 1 vs ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use dioxus_rsx::CallBody; use syn::parse_quote; macro_rules! test_case { ( $path:literal ) => { works(include!($path), include_str!($path)) }; } /// Ensure we can write RSX blocks without a source file /// /// Useful in code generation use c<|fim_suffix|> src.trim().lines(...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>s_autofmt::try_fmt_file(src_wrong, &parsed, $indent).unwrap_or_default(); let out = dioxus_autofmt::apply_formats(src_wrong, formatted); // normalize line endings let out = out.replace("\r", ""); let src_right = src_right.replace("\r", ""); pre...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use std::env; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; fn main() { println!("cargo:rerun-if-env-changed=DIOXUS_CLI_GIT_SHA"); println!("cargo:rerun-if-env-changed=DIOXUS_CLI_GIT_SHA_SHORT"); let manifest_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unw...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> tracing::info!("Creating iOS IPA at {}", output_path.display()); let staging_dir = tempfile::tempdir().context("Failed to create temp dir for IPA staging")?; let payload_dir = staging_dir.path().join("Payload"); std::fs::create_dir_all(&payload_dir)?; let...
fim
DioxusLabs/dioxus
rust
use crate::{ PackageType, bundler::{AppCategory, BundleContext}, }; use anyhow::{Context, Result, bail}; use handlebars::Handlebars; use image::{GenericImageView, ImageFormat}; use std::{ fs::{self, File}, io::{BufReader, Cursor, Write}, path::{Path, PathBuf}, }; use tokio::process::Command; const ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::bundler::{AppCategory, Bundle, BundleContext, copy_dir_recursive}; use crate::{MacOsSettings, PackageType}; use anyhow::{Context, Result, bail}; use image::{DynamicImage, ImageReader}; use std::fs::{self, File}; use std::io::BufWriter; use std::path::{Path, PathBuf}; use std::process::{Command ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>mod ios; mod linux; mod macos; mod tools; mod updater; mod windows; use crate::PackageType; use crate::{BuildRequest, DebianSettings, MacOsSettings, WindowsSettings}; use anyhow::Context; use anyhow::Result; use std::collections::HashMap; use std::path::{Path, PathBuf}; use tools::ResolvedTools; /// A c...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Tool downloading and caching for external bundling tools. //! //! All downloads happen upfront via `resolve_tools()` before any bundling starts. //! This keeps tool downloads out of the bundle format modules. use super::Arch; use crate::{PackageType, WebviewInstallMode, WindowsSettings}; use anyhow::...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> PackageType::AppImage | PackageType::Deb => { // Create .tar.gz of the artifact for artifact_path in &bundle.bundle_paths { let tar_path = output_dir.join(format!( "{}.tar.gz", arti...
fim
DioxusLabs/dioxus
rust
use crate::bundler::BundleContext; use crate::{NSISInstallerMode, WebviewInstallMode, WindowsSettings}; use anyhow::{Context, Result, bail}; use handlebars::Handlebars; use serde_json::Value as JsonValue; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use tokio::process::Command; use uuid::Uuid; impl ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>bug; } if target.split_debuginfo.is_none() { target.split_debuginfo = new.split_debuginfo; } if target.rpath.is_none() { target.rpath = new.rpath; } if target.lto.is_none() { target.lto = new.lto; } if target.debug_assertions.is_none() { targ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> 1 )?; let max_line_num_len = hook_span.end.line.to_string().len(); writeln!(f, "{:>max_line_num_len$} {}", "", pipe_char)?; for (i, line) in self.file_content.lines().enumerate() { let line_num = i + 1; if line_num >= hook_sp...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>olumn { line: start.line, column: start.column + first_line.len(), }; for line in lines { end.line += 1; end.column = line.len(); } Self { source_text: Some(source_text.to_string()), start, ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> } Node::Async(async_info) => { let issue = Issue::HookInsideAsync(hook_info.clone(), async_info.clone()); self.issues.push(issue); } ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use super::{check::collect_rs_files, *}; use crate::Workspace; use anyhow::{Context, bail}; use dioxus_autofmt::{IndentOptions, IndentType}; use rayon::prelude::*; use std::{borrow::Cow, fs, path::Path}; // For reference, the rustfmt main.rs file // https://github.com/rust-lang/rustfmt/blob/master/src/bi...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ame, // but since we don't have the BuildRequest here, we look for the entry with link_args // (only the tip crate has link_args attached) or fall back to any entry. let (rustc_args, rustc_envs, rustc_cwd) = self .workspace_rustc .rustc_args .ite...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use std::{fs::create_dir_all, path::PathBuf}; use crate::opt::process_file_to; use crate::{Result, StructuredOutput}; use clap::Parser; use tracing::debug; #[derive(Clone, Debug, Parser)] pub struct BuildAssets { /// The s<|fim_suffix|>estination_path.display(), asset ); ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>e a list of bundles that we might need to copy. // Package-type based bundling is handled by the bundler module. match client.bundle { // Desktop and Android platforms use package-type dispatch in the bundler module. BundleFormat::MacOS | BundleFormat::I...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> } } } <|fim_prefix|>//! Run linting against the user's codebase. //! //! For reference, the rustfmt main.rs file //! <https://github.com/rust-lang/rustfmt/blob/master/src/bin/main.rs> use super::*; use crate::BuildRequest; use anyhow::{Context, anyhow}; use futures_util::{StreamExt, stream::Futur...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use std::{ collections::{HashMap, HashSet}, ops::Deref, path::{Path, PathBuf}, }; use crate::{DioxusConfig, Result, StructuredOutput, Workspace, verbosity_or_default}; use anyhow::{Context, bail}; use clap::Parser; use dioxus_component_manifest::{ CargoDependency, Component, ComponentDepe...
fim
DioxusLabs/dioxus
rust
use super::*; use crate::{CliSettings, TraceSrc, Workspace, settings::SupportedEditor}; /// Dioxus config file controls #[derive(Clone, Debug, Deserialize, Subcommand)] pub(crate) enum Config { /// Init `Dioxus.toml` for project/folder. Init { /// Init project name name: String, /// Co...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>/// Post-creation actions for newly setup crates. pub(crate) fn post_create(path: &Path, vcs: &Vcs) -> Result<()> { let metadata = if let Some(parent_dir) = path.parent() { match cargo_metadata::MetadataCommand::new() .current_dir(parent_dir) .exec() { ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use super::*; use crate::{AndroidTools, Result, Workspace}; use anyhow::{Context, bail}; use itertools::Itertools; /// Perform a system analysis to verify the system install is working correctly. #[derive(Clone, Debug, Parser)] pub(crate) struct Doctor {} impl Doctor { pub async fn doctor(self) -> R...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{ AppBuilder, BuildArgs, BuildId, BuildMode, HotpatchModuleCache, Result, StructuredOutput, WorkspaceRustcArgs, platform_override::CommandWithPlatformOverrides, }; use anyhow::Context; use clap::Parser; use dioxus_dx_wire_format::StructuredBuildArtifacts; use std::io::Read; use std::syn...
fim
DioxusLabs/dioxus
rust
use super::*; use cargo_generate::{GenerateArgs, TemplatePath, Vcs}; #[derive(Clone, Debug, Default, Deserialize, Parser)] #[clap(name = "init")] pub struct Init { /// Create a new Dioxus project at PATH #[arg(default_value = ".")] pub path: PathBuf, /// Project name. Defaults to directory name #[...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::Result; use anyhow::{Context, bail}; use serde::{Deserialize, Serialize}; use std::{borrow::Cow, ffi::OsString, path::PathBuf, process::ExitCode}; use target_lexicon::Triple; /// `dx` can act as a linker in a few scenarios. Note that we don't *actually* implement the linker logic, /// instead ...
fim
DioxusLabs/dioxus
rust