text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>use const_serialize::SerializeConst; use crate::{AssetOptions, AssetOptionsBuilder, AssetVariant}; /// Options for a javascript asset #[derive( Debug, Eq, PartialEq, PartialOrd, Clone, Copy, Hash, SerializeConst, serde::Serialize, serde::Deserialize, )] pub struct...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>mod folder; pub use folder::*; mod images; pub use images::*; mod options; pub use options::*; mod css; pub use css::*; mod js; pub use js::*; mod asset; pub <|fim_suffix|>parser; pub use css_module_parser::*; mod ffi; pub use ffi::*; <|fim_middle|>use asset::*; mod css_module; pub use css_module::...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>elf) -> AssetOptions { AssetOptions { add_hash: self.add_hash, variant: AssetVariant::Unknown, } } } impl<T> AssetOptionsBuilder<T> { /// Create a new asset options builder with the given variant pub const fn variant(variant: T) -> Self { Self {...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{AssetParseError, linker::generate_link_section, resolve_path}; use macro_string::MacroString; use proc_macro2::TokenStream as TokenStream2; use quote::{ToTokens, quote}; use std::{ hash::{DefaultHasher, Hash, Hasher}, path::{Path, PathBuf}, }; use syn::{ Token, parse::{Parse, P...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{asset::AssetParser, resolve_path}; use macro_string::MacroString; use manganis_core::{create_module_hash, get_class_mappings}; use proc_macro2::{Span, TokenStream}; use quote::{ToTokens, TokenStreamExt, format_ident, quote}; use syn::{ Ident, ItemStruct, parse::{Parse, ParseStream}, ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> for (i, c) in s.chars().enumerate() { if c == '_' { capitalize_next = true; } else if capitalize_next { result.push(c.to_ascii_uppercase()); capitalize_next = false; } else if i == 0 { result.push(c.to_ascii_lowercase()); ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>nalyzer_env || looks_like_rust_analyzer_exe } <|fim_prefix|>#![doc = include_str!("../README.md")] #![deny(missing_docs)] use std::path::PathBuf; use proc_macro::TokenStream; use proc_macro2::Span; use quote::{ToTokens, quote}; use syn::{ ItemStruct, parse::{Parse, ParseStream}, parse_macro_...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> }; } } <|fim_prefix|>use proc_macro2::TokenStream as TokenStream2; use quote::ToTokens; use quote::quote; /// Generate a linker section for embedding arbitrary data in the binary /// /// This is a generic version that allows customizing the serialization function, /// buffer type, and copy bytes f...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>const OPTIONAL: Option<Asset> = option_asset!("/assets/does_not_exist.txt"); assert!(OPTIONAL.is_none()); } <|fim_prefix|>use manganis::{Asset, asset, option_asset}; #[test] fn resolves_existing_asset() { const REQUIRED: Asset = asset!("/assets/asset.txt"); const OPTIONAL: Option<Asset> = op...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> handler); } else { #[cfg(feature = "tracing")] tracing::warn!("net feature not enabled, cannot fetch {request:#?}"); } } } <|fim_prefix|>use blitz_shell::BlitzShellProxy; use std::sync::Arc; use blitz_traits::net::{NetHandler, NetProvider, Request}; pub struc...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use blitz_dom::FontContext; use dioxus_core::LaunchConfig; use winit::window::WindowAttributes; /// Launch-time configuration for a dioxus-native application. pub struct Config { pub(crate) window_attributes: WindowAttributes, pub(crate) font_ctx: Option<FontContext>, } impl LaunchConfig for Con...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use blitz_shell::{BlitzShellEvent, BlitzShellProxy}; use dioxus_document::{Document, NoOpDocument}; use winit::window::WindowId; use crate::DioxusNativeEvent; pub struct DioxusNativeDocument { pub(crate) proxy: BlitzShellProxy, pub(crate) window: WindowId, } impl DioxusNativeDocument { pub(...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use blitz_shell::{BlitzApplication, BlitzShellProxy, View}; use dioxus_core::{ScopeId, provide_context}; use dioxus_history::{History, MemoryHistory}; use std::rc::Rc; use std::sync::Arc; use winit::application::ApplicationHandler; use winit::event::{StartCause, WindowEvent}; use winit::ev<|fim_suffix|>ut...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>:WindowHandle>, width: u32, height: u32, on_ready: F, ) { self.inner .borrow_mut() .resume(window, width, height, on_ready) } fn complete_resume(&mut self) -> bool { self.inner.borrow_mut().complete_resume() } fn suspend...
fim
DioxusLabs/dioxus
rust
#![cfg_attr(docsrs, feature(doc_cfg))] //! A native renderer for Dioxus. //! //! ## Feature flags //! - `default`: Enables the features listed below. //! - `accessibility`: Enables [`accesskit`](https://docs.rs/accesskit/latest/accesskit/) accessibility support. //! - `hot-reload`: Enables hot-reloading of Dioxus R...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use blitz_traits::{ navigation::{NavigationOptions, NavigationProvider}, net::Method, }; pub(crate) struct DioxusNativeNavigationProvider; impl NavigationProvider for DioxusNativeNavigationProvider { fn navigate_to(&self, options: NavigationOptions) { <|fim_suffix|>tions.url.scheme(), "htt...
fim
DioxusLabs/dioxus
rust
// RSX and component definition pub use dioxus_core; pub use dioxus_core::{ AnyhowContext, Attribute, Callback, Component, Element, ErrorBoundary, ErrorContext, Event, EventHandler, Fragment, HasAttributes, IntoDynNode, RenderError, ScopeId, SuspenseBoundary, SuspenseContext, VNode, VirtualDom, consume_cont...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Integration between Dioxus and Blitz use crate::NodeId; use crate::events::{ BlitzKeyboardData, NativeConverter, NativeFocusData, NativeFormData, NativePointerData, NativeScrollData, NativeWheelData, NodeHandle, }; use crate::mutation_writer::{DioxusState, MutationWriter}; use crate::qual_name...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use blitz_dom::{BaseDocument, Node}; use blitz_traits::events::{ BlitzKeyEvent, BlitzPointerEvent, BlitzPointerId, BlitzScrollEvent, BlitzWheelDelta, BlitzWheelEvent, MouseEventButton, }; use dioxus_html::{ AnimationData, BeforeInputData, CancelData, ClipboardData, CompositionData, DragData, ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> ($pattern:literal) => {{ #[cfg(feature = "tracing")] tracing::debug!($pattern); }}; ($pattern:literal, $item1:expr) => {{ #[cfg(feature = "tracing")] tracing::debug!($pattern, $item1); }}; ($pattern:literal, $item1:expr, $item2:expr) => {{ #[cfg...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>//! Integration between Dioxus and Blitz use crate::{NodeId, qual_name, trace, write_once_attr::WriteOnceAttr}; use blitz_dom::{BaseDocument, Document as _, DocumentMutator, PlainDocument, Widget}; use blitz_traits::events::DomEventKind; use dioxus_core::{ AttributeValue, ElementId, Template, Template...
fim
DioxusLabs/dioxus
rust
use std::{cell::RefCell, rc::Rc, sync::atomic::AtomicUsize}; use blitz_dom::{BaseDocument, PlainDocument, Widget}; use dioxus_core::{AttributeValue, IntoAttributeValue}; #[derive(Clone, PartialEq)] pub struct SubDocumentAttr(WriteOnceAttr<Box<PlainDocument>>); impl SubDocumentAttr { pub fn new(doc: BaseDocument)...
fim
DioxusLabs/dioxus
rust
use dioxus::prelude::*; const FAVICON: Asset = asset!("/assets/favicon.ico"); const MAIN_CSS: Asset = asset!("/assets/main.css"); const HEADER_SVG: Asset = asset!("/assets/header.svg"); fn main() { dioxus::launch(App); } #[component] fn App() -> Element { rsx! { document::Link { rel: "icon", href: FA...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> script tag were a classic <script>. export const value = "ok-auto"; window.__esm_auto_value = value; window.__esm_auto_meta = typeof import.meta.url; <|fim_prefix|>// No `with_module(true)` is set on the asset — the CLI must detect this file // as ESM from its source (top-level `export`) and emit `<scrip...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>export const <|fim_suffix|>; <|fim_middle|>importedValue = "ok-esm-import"<|endoftext|>
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>portedValue; export const entryValue = importedValue; <|fim_prefix|>import { impo<|fim_middle|>rtedValue } from "./esm_import_dep.js"; window.__esm_import_value = im<|endoftext|>
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// No top-level import/export — auto-detection alone would classify this as a // classic script. `with_module(true)` on the asset overrides that and forces // the CLI to emit `<script type="module">` and run esbuild with the ESM // pipeline. The playwright spec asserts both that the global is set and that...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>(function () { window.__iife_classic_value = "<|fim_suffix|>})(); <|fim_middle|>ok-classic"; <|endoftext|>
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>(function () { var value = "ok-minify"; <|fim_suffix|>y_value = value; })(); <|fim_middle|>window.__iife_minif<|endoftext|>
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|> import.meta.url === "string" ? "ok-mjs" : "bad-mjs"; <|fim_prefix|><|fim_middle|>window.__mjs_auto_value = typeof<|endoftext|>
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>/*! * sweetalert2 v11.22.2 * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Sweetalert2=t()}(this,function(){"use strict";functio...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>nction" && define.amd) { define(function () { root.__umd_minify_value = factory().value; return factory(); }); } else { root.__umd_minify_value = factory().value; } })(this, function () { return { value: "ok-umd" }; }); <|fim_prefix|>(function (r...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>fn main() { // use std::path::PathBuf; // // If the monaco editor folder doesn't exist, download it // let monaco_path = PathBuf::from("monac<|fim_suffix|>r::new(bytes.as_ref())); // let monaco_path_partial = PathBuf::from("partial-monaco-editor"); // archive.unpack(&monaco_path_parti...
fim
DioxusLabs/dioxus
rust
// This test checks the CLI optimizes assets correctly without breaking them use dioxus::prelude::*; const SOME_IMAGE: Asset = asset!("/images/toasts.png", AssetOptions::image().with_avif()); const SOME_IMAGE_WITH_THE_SAME_URL: Asset = asset!("/images/toasts.png", AssetOptions::image().with_jpg()); #[used] static...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>_test::main() } <|fim_prefix|>fn main() { dioxus_cli_op<|fim_middle|>timization<|endoftext|>
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> dioxus_cli_optimization_test::main() } <|fim_prefix|>fn main()<|fim_middle|> { <|endoftext|>
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>//localhost:{port}/assets/toasts.png is found even though it is not used in the page const response = await page.request.get( `http://localhost:${port}/assets/toasts.png` ); // Expect the response to be ok expect(response.status()).toBe(200); // make sure the response is an image...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// This test asserts that the client feature is disable on the server build by the cli // even if it is set as a default feature #![allow(non_snake_case)] use dioxus::p<|fim_suffix|> features } #[server] async fn get_server_features() -> ServerFnResult<Vec<String>> { Ok(current_platform_features()) ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ontainText('server features: ["server"]'); await expect(main).toContainText('client features: ["web"]'); }); <|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/t<|fim_middle|>est"); test("loads with correct features", async ({ page }) => { await page.goto("http://localhost:8002"...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>body {{ font-family: 'Roboto'; }}" } } } /// Make sure assets in the assets folder are served correctly and hashed assets are cached forever #[component] fn Assets() -> Element { #[used] static _ASSET: Asset = asset!("/assets/image.png"); #[used] static _STATIC_NO_HASH: Asset = asset...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>Error` and /// set the status code accordingly. Note that you can commit any status code you want with `commit_http_status`. /// /// The router will automatically set the HTTP status code when doing SSR. #[component] fn ErrorLayout() -> Element { rsx! { ErrorBoundary { handle_error...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>row new Error("Failed to navigate to http://localhost:8124/blog/3"); } expect(blogPanicRes.status()).toBe(500); // Go to /blog/4 which should be a 404 const blogNotFoundRes = await page.goto("http://localhost:8124/blog/4"); if (!blogNotFoundRes) { throw new Error("Failed to navigate to http...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// This test is used by playwright configured in the root of the repo // Tests: // - Errors that originate in the initial render #![allow(non_snake_case)] use dioxus::prelude::*; fn main() { dioxus::launch(app); } fn app() -> Element { rsx! { Errors {} } } #[server] async fn server...
fim
DioxusLabs/dioxus
rust
// @ts-check const { test, expect } = require("@playwright/test"); test("errors", async ({ page }) => { await page.goto("http://localhost:3232"); // give the page time to finish loading resources await page.waitForLoadState("networkidle"); await page.waitForTimeout(2000); // Make sure the error that was th...
fim
DioxusLabs/dioxus
javascript
// Adjacent server components that both use server functions shouldn't cause // hydration issues // https://github.com/DioxusLabs/dioxus/issues/4595 use dioxus::prelude::*; fn main() { dioxus::launch(|| rsx! { Home {} }); } #[component] pub fn Home() -> Element { let mut count = use_signal(|| 0); rsx! { ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); test("hydration", async ({ page }) => { await page.goto("http://localhost:7979"); // give time for the page to load a<|fim_suffix|>icking the button should increase the count await button.click(); await expect(button).toContainTe...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// Regression test for https://github.com/DioxusLabs/dioxus/pull/3480 use dioxus::prelude::*; fn main() { dioxu<|fim_suffix|>alse); rsx! { div { onmounted: move |_| { mounted.set(true); }, if mounted() { "The mounted ev...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test, expect } = re<|fim_suffix|><|fim_middle|>quire("@playwright/test"); test("hydration", async ({ page }) => { await page.goto("http://localhost:7777"); // Expect the page to contain the pending text. const main = page.locator("#main"); await expect(main).toContainText("T...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|> count += 1; }, "{count}" }, } else { div { Link { class: "app-button-circle item-navbar", to: Route::Home, ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); // Wait for the build to finish async function waitForBuild(request) { for (let i = 0; i < 10; i++) { const build = await request.get("http://localhost:8888"); let text = await build.text(); if (!text.includes("Backend conne...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>#[component] fn Comp(#[props(extends = GlobalAttributes)] attributes: Vec<Attribute>) -> Element { rsx! { div { width: 100, div { ..attributes, } } } } <|fim_prefix|>//! Regression test for <https://github.com/DioxusLabs/dioxus/is...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); test("spread attributes hydr<|fim_suffix|>er).toHaveText("Count: 0"); // Clicking on the button should increment the count await counter.click(); await expect(counter).toHaveText("Count: 1"); }); <|fim_middle|>ate", async ({ page }...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>ipt-head"); await script.waitFor({ state: "attached" }); await expect(script).toHaveAttribute("async", "true"); const style = page.locator("style#style-head"); await style.waitFor({ state: "attached" }); const main = page.locator("#main"); await expect(main).toHaveCSS("font-family", "Roboto")...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// This test is used by playwright configured in the root of the repo use axum::{Router, extract::ws::WebSocketUpgrade, response::Html, routing::get}; use dioxus::{logger::tracing::Level, prelude::*}; fn app() -> Element { let mut num = use_signal(|| 0); rsx! { div { "hello ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>iv = page.locator("div.style-div"); await expect(div).toHaveText("colored text"); await expect(div).toHaveCSS("color", "rgb(255, 0, 0)"); }); test("onmounted", async ({ page }) => { await page.goto("http://127.0.0.1:3030"); // Expect the onmounted event to be called exactly once. const mounted...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// This test is used by playwright configured in the root of the repo // Tests: // - SEO without JS // - Streaming hydration // - Suspense // - Server functions // // Without Javascript, content may not load into the right location, but it should still be somewhere in the html even if it is invisible use...
fim
DioxusLabs/dioxus
rust
#![allow(non_snake_case)] use dioxus::prelude::*; use nested_suspense::app; fn main() { LaunchBuilder::new() .with_cfg(server_only! { ServeConfig::builder() .enable_out_of_order_streaming() }) .launch(app); } <|endoftext|>
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> .enable_out_of_order_streaming() }) .launch(app); } #[server(endpoint = "static_routes")] async fn static_routes() -> ServerFnResult<Vec<String>> { Ok(vec!["/".to_string()]) } <|fim_prefix|>#![allow(non_snake_case)] use dioxus::prelude::*; use nested_suspense::app; f...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>ght order/location, but SEO should still work await page.waitForLoadState("load"); const body = page.locator("body"); const textExpected = [ "The robot becomes sentient and says hello world", "The world says hello back", "In a stunning turn of events, the world collectively unites and s...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// @ts-check con<|fim_suffix|>; const nestedMessageTitle2 = page.locator("#title-2"); await expect(nestedMessageTitle2).toContainText("Goodbye Robot"); const nestedMessageBody2 = page.locator("#body-2"); await expect(nestedMessageBody2).toContainText("The robot says goodbye"); const nestedMessa...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); const { timeout } = require("./playwright.config"); test("nested suspense resolves", async ({ page }) => { // Wait for the dev server to reload await page.goto("http://localhost:5050"); // Then wait for the page to start loading a...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>mization", command: `${dx} run --addr 127.0.0.1 --port 8989` }, { specs: ["wasm-split.spec.js"], port: 8001, cwd: "wasm-split-harness", command: `${dx} run --bin wasm-split-harness --web --addr 127.0.0.1 --port 8001 --wasm-split --profile wasm-split-release` }, { specs: ["default-features-disabled.spe...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// This test is used by playwright configured in the root of the repo // Tests: // - Streaming hydration // - Suspense // - Server futures #![allow(non_snake_case, unused)] use dioxus::{fullstack::commit_initial_chunk, prelude::*}; use serde::{Deserialize, Serialize}; fn app() -> Element { // Start ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); test("suspense resolves on server", async ({ page }) => { // Wait for the dev server to reload await page.goto("http://localhost:4040"); // Then wait for the page to start loading await page.goto("http://localhost:4040", { waitUnt...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>//! This file is a fuzz-test for the wasm-split engine to ensure that it works as expected. //! The docsite is a better target for this, but we try to boil down the complexity into this small //! test file. #![allow(non_snake_case)] use dioxus::prelude::*; use futures::AsyncReadExt; use js_sys::Date; us...
fim
DioxusLabs/dioxus
rust
// Handle caching of github stars // This file is part of the fuzz test to prove we can handle linked js files // Two days const STAR_EXPIRE_TIME = 172800000; export function get_stars(name) { let item = localStorage.getItem(name); let data = JSON.parse(item); if (!data) { return null; } if (data.expi...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>t"); await addBodyTextButton.click(); await expect(counterGlobal).toContainText("Global Counter: 2"); const outputBox = page.locator("#output-box"); await expect(outputBox).toContainText("Rendered!"); // The other wasm module const addBodyElementButton = page.locator("#add-body-element"); a...
fim
DioxusLabs/dioxus
javascript
// This test is used by playwright configured in the root of the repo use dioxus::prelude::*; use wasm_bindgen::prelude::*; fn app() -> Element { let mut num = use_signal(|| 0); let mut eval_result = use_signal(String::new); rsx! { div { "hello axum! {num}" document::Title...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>tFound {segments:?}" } } } <|fim_prefix|>use std::rc::Rc; use dioxus::{prelude::*, web::HashHistory}; fn main() { dioxus::LaunchBuilder::new() .with_cfg(dioxus::web::Config::new().history(Rc::new(HashHistory::new(false)))) .launch(|| { rsx! { R...
fim
DioxusLabs/dioxus
rust
// @ts-check const { test, expect } = require("@playwright/test"); test("redirect", async ({ page }) => { // Going to the root url should redirect to /other. await page.goto("http://localhost:2021"); // Expect the page to the text Other const main = page.locator("#other"); await expect(main).toContainText("...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>use dioxus::prelude::*; const CSS: Asset = asset!("/assets/style.css"); const IMAGE: Asset = asset!("/assets/toasts.png"); fn app() -> Element { let mut num = use_signal(|| 0); // make sure to emit funky closure code in this module to test wasm-bindgen handling let _closures = wasm_bindgen:...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use dioxus::prelude::*; const CSS: Asset = asset!("/assets/style.css"); const IMAGE: Asset = asset!("/assets/toasts.png"); fn app() -> Element { let mut num = use_signal(|| 0); rsx! { document::Link { href: CSS, rel: "stylesheet", } img { ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); const hotPatchTimeout = { timeout: 1000 * 60 * 2, // 2 minute }; test("button click", async ({ page }) => { const fs = require("fs"); const mainPath = "web-hot-patch-fullstack-temp/src/main.rs"; var mainContent = fs.r<|fim_suffix...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>ge is still loaded. // expect the attribute src to start with /assets/toasts- await expect(headerImage).toHaveAttribute("src", /\/assets\/toasts-/); // ** Then add a new asset to the page ** // Switch from style to alternative-style const updatedContentWithAlternativeStyle = updatedContentWithT...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|> rsx! { div { id: "other", "Other" } Link { id: "other-id-link", to: Route::OtherId { id: "123".to_string() }, "go to OtherId" } } } #[component] fn OtherId(id: String) -> Element { rsx! { div {...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>("NotFound"); }); <|fim_prefix|>// @ts-check const { test, expect } = require("@playwright/test"); test("redirect", async ({ page }) => { // Going to the root url should redirect to /other. await page.goto("http://localhost:2020"); // Expect the page to the text Other const main = page.l<|fim_m...
fim
DioxusLabs/dioxus
javascript
<|fim_prefix|>// @ts-check const { test, expect, defineConfig } = require("@playwright/test"); test("button click", async ({ page }) => { await page.goto("http://localhost:9990"); // Expect the page to contain the counter text. const main = page.locator("#main"); await expect(main).toContainText("hello axum! ...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>n", onclick: move |_| count += 1, "Up high!" } } } <|fim_prefix|>use dioxus::LaunchBuilder; use dioxus::prelude::*; fn main() { LaunchBuilder::new() .with_cfg( dioxus::desktop::Config::new() .with_windows_b<|fim_middle|>rowser_args("--remote...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>::Config::new().with_windows_browser_args("--remote-debugging-port=8788"), ); builder.launch(app); } <|fim_prefix|>use dioxus::prelude::*; con<|fim_middle|>st CSS: Asset = asset!("/assets/style.css"); fn app() -> Element { let mut num = use_signal(|| 0); rsx! { document::Link {...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>// @ts-check const { test: base, expect } = require("@playwright/test"); const fs = require("fs"); const test = base.extend({ browser: async ({ playwright }, use) => { const browser = await playwright.chromium.connectOverCDP("http://127.0.0.1:8788"); await use(browser); await browser.close(...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>); }, page: async ({ context }, use) => { const page = context.pages()[0]; await use(page); }, }); test("button click", async ({ page }) => { // Expect the page to contain the counter text. const main = page.locator("#main"); await expect(main).toContainText("High-five counter: 0"); ...
fim
DioxusLabs/dioxus
javascript
<|fim_suffix|>props.format_route_as_root_route, parse_route_from_root_route: props.parse_route_from_root_route, }); provide_context(OutletContext::<R>::new()); }); rsx! { Outlet::<R> {} } } <|fim_prefix|>/// Components that allow the macro to add child routers. This component provid...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>k here to go back" } } } <|fim_prefix|>use dioxus_core::Element; use dioxus_core_macro::rsx; use dioxus_html as dioxus_elements; #[allow(deprecated)] use<|fim_middle|> crate::hooks::use_router; /// The default component to render when an external navigation fails. #[allow(non_snake_case)] pub fn Fai...
fim
DioxusLabs/dioxus
rust
use dioxus_core::{Element, VNode}; use dioxus_core_macro::{Props, rsx}; use dioxus_html as dioxus_elements; use tracing::error; use crate::utils::use_router_internal::use_router_internal; /// The properties for a [`GoBackButton`] or a [`GoForwardButton`]. #[derive(Debug, Props, Clone, PartialEq)] pub struct HistoryB...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use dioxus_core::{Callback, Element, use_hook}; use dioxus_core_macro::{Props, component}; use dioxus_history::{History, provide_history_context}; use std::rc::Rc; /// A component that provides a <|fim_suffix|> /// The history to provide to child components. history: Callback<(), Rc<dyn History>...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>new_tab: true, /// rel: "link_rel", /// to: Route::Index {}, /// /// "A fully configured link" /// } /// } /// } /// # /// # let mut vdom = VirtualDom::new(App); /// # vdom.rebuild_in_place(); /// # assert_eq!( /// # dioxus_ssr::render(&vdom), /// # ...
fim
DioxusLabs/dioxus
rust
use crate::{outlet::OutletContext, *}; use dioxus_core::Element; /// An outlet for the current content. /// /// Only works as descendant of a [`Link`] component, otherwise it will be inactive. /// /// The [`Outlet`] is aware of how many [`Outlet`]s it is nested within. It will render the content /// of the active rout...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>-> Element { use crate::{RouterContext, outlet::OutletContext}; use_hook(|| { provide_router_context(RouterContext::new(props.config.call(()))); }); #[cfg(feature = "streaming")] dioxus_hooks::use_after_suspense_resolved(|| { dioxus_fullstack_core::commit_initial_chun...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{ExternalNavigationFailure, NavigationTarget, RouterContext}; /// Acquire the navigator without subscribing to updates. /// /// Can be called anywhere in the application provided a Router has been initialized. /// /// ## Panics /// /// Panics if there is no router present. pub fn navigator() -...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>u<|fim_suffix|> # Returns /// /// Returns an [`OutletContext<R>`] containing the current nesting level information. /// /// # Examples /// /// ```rust, no_run /// # use dioxus::prelude::*; /// # use dioxus_router::use_outlet_context; /// /// # #[derive(Routable,Clone,PartialEq)] /// # enum MyRouter { /// ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>e router is running in a liveview context /// We do some slightly weird things for liveview because of the network boundary pub(crate) fn include_prevent_default(&self) -> bool { history().include_prevent_default() } /// Check whether there is a previous page to navigate back to. ...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use dioxus_core::{try_consume_context, use_hook}; use crate::{Navigator, RouterContext}; /// A hook that provides access to the navigator to change the router history. /// /// <|fim_suffix|>ent] /// fn App() -> Element { /// rsx! { /// Router::<Route> {} /// } /// } /// /// #[component] ...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>// h2 { "Current Path" } /// p { "{path}" } /// } /// } /// # /// # let mut vdom = VirtualDom::new(App); /// # vdom.rebuild_in_place(); /// # assert_eq!(dioxus_ssr::render(&vdom), "<h1>App</h1><h2>Current Path</h2><p>/</p>") /// ``` #[doc(alias = "use_url")] #[must_use] pub fn use_rout...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{RouterContext, utils::use_router_internal::use_router_internal}; #[deprecated = "prefer the `router()` function or `use_route` functions"] #[must_use] /// A hook that provides access to information about the router. pub fn<|fim_suffix|>xus_core::try_consume_context() } <|fim_middle|> use_rout...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|> .add(b'>'); /// The ASCII set that must be escaped in path segments. pub const PATH_ASCII_SET: &AsciiSet = &QUERY_ASCII_SET .add(b'?') .add(b'^') .add(b'`') .add(b'{') .add(b'}'); /// The ASCII set that must be escaped in hash fragments. pub con...
fim
DioxusLabs/dioxus
rust
<|fim_suffix|>::Internal(value.to_string()), false => NavigationTarget::External(value.to_string()), }, None => NavigationTarget::External(value.to_string()), } } } impl From<String> for NavigationTarget { fn from(value: String) -> Self { match try_router...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>#![allow(non_snake_case)] //! # Routable use dioxus_core::Element; use std::iter::FlatMap; use std::slice::Iter; use std::{fmt::Display, str::FromStr}; /// An error that occurs when parsing a route. #[derive(Debug, PartialEq)] pub struct RouteParseError<E: Display> { /// The attempted routes that fa...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::{GenericRouterContext, NavigationTarget, Routable, RoutingCallback}; use dioxus_core::Element; use std::sync::Arc; /// Global configuration options for the router. /// /// This i<|fim_suffix|>ting is updated. /// /// The callback is invoked after the routing is updated, but before comp...
fim
DioxusLabs/dioxus
rust
<|fim_prefix|>use crate::RouterContext; use dioxus_core::{try_consume_context, use_hook}; /// A private hook to subscribe to the router. /// /// Used to reduce redundancy within other components/hooks. Safe to call multiple times for a /// single component, but not recommended. Multiple subscriptions wil<|fim_suffix|>...
fim
DioxusLabs/dioxus
rust
#![allow(unused)] use std::rc::Rc; use dioxus::prelude::*; #[derive(Routable, Clone, PartialEq, Debug)] #[rustfmt::skip] enum Route { #[route("/")] RootIndex {}, #[nest("/fixed")] #[layout(Fixed)] #[route("/")] FixedIndex {}, #[route("/fixed")] Fixe...
fim
DioxusLabs/dioxus
rust