Merge branch 'master' into use-server-function
This commit is contained in:
commit
5077199f25
19 files changed
+66
-53
No files matched your search
@@ -29,7 +29,7 @@ jobs:
|
|||||||
# cd fermi && mdbook build -d ../nightly/fermi && cd ..
|
# cd fermi && mdbook build -d ../nightly/fermi && cd ..
|
||||||
|
|
||||||
- name: Deploy 🚀
|
- name: Deploy 🚀
|
||||||
uses: JamesIves/github-pages-deploy-action@v4.4.2
|
uses: JamesIves/github-pages-deploy-action@v4.4.3
|
||||||
with:
|
with:
|
||||||
branch: gh-pages # The branch the action should deploy to.
|
branch: gh-pages # The branch the action should deploy to.
|
||||||
folder: docs/nightly # The folder the action should deploy.
|
folder: docs/nightly # The folder the action should deploy.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ jobs:
|
|||||||
# cd fermi && mdbook build -d ../nightly/fermi && cd ..
|
# cd fermi && mdbook build -d ../nightly/fermi && cd ..
|
||||||
|
|
||||||
- name: Deploy 🚀
|
- name: Deploy 🚀
|
||||||
uses: JamesIves/github-pages-deploy-action@v4.4.2
|
uses: JamesIves/github-pages-deploy-action@v4.4.3
|
||||||
with:
|
with:
|
||||||
branch: gh-pages # The branch the action should deploy to.
|
branch: gh-pages # The branch the action should deploy to.
|
||||||
folder: docs/nightly # The folder the action should deploy.
|
folder: docs/nightly # The folder the action should deploy.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ on:
|
|||||||
- lib.rs
|
- lib.rs
|
||||||
- Cargo.toml
|
- Cargo.toml
|
||||||
- Makefile.toml
|
- Makefile.toml
|
||||||
- playwrite-tests/**
|
- playwright-tests/**
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
/target
|
/target
|
||||||
/playwrite-tests/web/dist
|
/playwright-tests/web/dist
|
||||||
/playwrite-tests/fullstack/dist
|
/playwright-tests/fullstack/dist
|
||||||
/dist
|
/dist
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
+4
-4
@@ -39,10 +39,10 @@ members = [
|
|||||||
# Full project examples
|
# Full project examples
|
||||||
"examples/tailwind",
|
"examples/tailwind",
|
||||||
"examples/PWA-example",
|
"examples/PWA-example",
|
||||||
# Playwrite tests
|
# Playwright tests
|
||||||
"playwrite-tests/liveview",
|
"playwright-tests/liveview",
|
||||||
"playwrite-tests/web",
|
"playwright-tests/web",
|
||||||
"playwrite-tests/fullstack",
|
"playwright-tests/fullstack",
|
||||||
]
|
]
|
||||||
exclude = ["examples/mobile_demo"]
|
exclude = ["examples/mobile_demo"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::HashMap, path::PathBuf};
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct DioxusConfig {
|
pub struct DioxusConfig {
|
||||||
@@ -19,27 +22,36 @@ fn default_plugin() -> toml::Value {
|
|||||||
impl DioxusConfig {
|
impl DioxusConfig {
|
||||||
pub fn load() -> crate::error::Result<Option<DioxusConfig>> {
|
pub fn load() -> crate::error::Result<Option<DioxusConfig>> {
|
||||||
let Ok(crate_dir) = crate::cargo::crate_root() else { return Ok(None); };
|
let Ok(crate_dir) = crate::cargo::crate_root() else { return Ok(None); };
|
||||||
|
let crate_dir = crate_dir.as_path();
|
||||||
|
|
||||||
// we support either `Dioxus.toml` or `Cargo.toml`
|
|
||||||
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
|
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let dioxus_conf_file = dioxus_conf_file.as_path();
|
||||||
toml::from_str::<DioxusConfig>(&std::fs::read_to_string(dioxus_conf_file)?)
|
toml::from_str::<DioxusConfig>(&std::fs::read_to_string(dioxus_conf_file)?)
|
||||||
.map_err(|_| crate::Error::Unique("Dioxus.toml parse failed".into()))
|
.map_err(|err| {
|
||||||
|
let error_location = dioxus_conf_file
|
||||||
|
.strip_prefix(crate_dir)
|
||||||
|
.unwrap_or(dioxus_conf_file)
|
||||||
|
.display();
|
||||||
|
crate::Error::Unique(format!("{error_location} {err}"))
|
||||||
|
})
|
||||||
.map(Some)
|
.map(Some)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn acquire_dioxus_toml(dir: PathBuf) -> Option<PathBuf> {
|
fn acquire_dioxus_toml(dir: &Path) -> Option<PathBuf> {
|
||||||
// prefer uppercase
|
// prefer uppercase
|
||||||
if dir.join("Dioxus.toml").is_file() {
|
let uppercase_conf = dir.join("Dioxus.toml");
|
||||||
return Some(dir.join("Dioxus.toml"));
|
if uppercase_conf.is_file() {
|
||||||
|
return Some(uppercase_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// lowercase is fine too
|
// lowercase is fine too
|
||||||
if dir.join("dioxus.toml").is_file() {
|
let lowercase_conf = dir.join("dioxus.toml");
|
||||||
return Some(dir.join("Dioxus.toml"));
|
if lowercase_conf.is_file() {
|
||||||
|
return Some(lowercase_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
set_up_logging();
|
set_up_logging();
|
||||||
|
|
||||||
let _dioxus_config = DioxusConfig::load()
|
let _dioxus_config = DioxusConfig::load()
|
||||||
.map_err(|e| anyhow!("Failed to load `Dioxus.toml` because: {e}"))?
|
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||||
DioxusConfig::default()
|
DioxusConfig::default()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use std::{
|
|||||||
/// writes through the `write` method. Whenever `write` is called, the component
|
/// writes through the `write` method. Whenever `write` is called, the component
|
||||||
/// that initialized the hook will be marked as "dirty".
|
/// that initialized the hook will be marked as "dirty".
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
||||||
///
|
///
|
||||||
/// // using `write` will give us a `RefMut` to the inner value, which we can call methods on
|
/// // using `write` will give us a `RefMut` to the inner value, which we can call methods on
|
||||||
@@ -26,7 +26,7 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// You can avoid this default behavior with `write_silent`
|
/// You can avoid this default behavior with `write_silent`
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```rust, no_run
|
||||||
/// // with `write_silent`, the component will not be re-rendered
|
/// // with `write_silent`, the component will not be re-rendered
|
||||||
/// val.write_silent().insert(2, "goodbye".to_string());
|
/// val.write_silent().insert(2, "goodbye".to_string());
|
||||||
/// ```
|
/// ```
|
||||||
@@ -35,7 +35,7 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// To read values out of the refcell, you can use the `read` method which will retrun a `Ref`.
|
/// To read values out of the refcell, you can use the `read` method which will retrun a `Ref`.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let map: Ref<_> = val.read();
|
/// let map: Ref<_> = val.read();
|
||||||
///
|
///
|
||||||
/// let item = map.get(&1);
|
/// let item = map.get(&1);
|
||||||
@@ -43,7 +43,7 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// To get an &T out of the RefCell, you need to "reborrow" through the Ref:
|
/// To get an &T out of the RefCell, you need to "reborrow" through the Ref:
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let read = val.read();
|
/// let read = val.read();
|
||||||
/// let map = &*read;
|
/// let map = &*read;
|
||||||
/// ```
|
/// ```
|
||||||
@@ -54,10 +54,10 @@ use std::{
|
|||||||
/// Typically this will be a collection like a HashMap or a Vec. To create new
|
/// Typically this will be a collection like a HashMap or a Vec. To create new
|
||||||
/// elements from the collection, we can use `read()` directly in our rsx!.
|
/// elements from the collection, we can use `read()` directly in our rsx!.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// rsx!{
|
/// rsx!{
|
||||||
/// val.read().iter().map(|(k, v)| {
|
/// val.read().iter().map(|(k, v)| {
|
||||||
/// rsx!{ key: "{k}", value: "{v}" }
|
/// rsx!{ key: "{k}", "{v}" }
|
||||||
/// })
|
/// })
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
@@ -66,9 +66,9 @@ use std::{
|
|||||||
/// "render" inside the iterator. For some cases you might need to collect into
|
/// "render" inside the iterator. For some cases you might need to collect into
|
||||||
/// a temporary Vec.
|
/// a temporary Vec.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let items = val.read().iter().map(|(k, v)| {
|
/// let items = val.read().iter().map(|(k, v)| {
|
||||||
/// cx.render(rsx!{ key: "{k}", value: "{v}" })
|
/// cx.render(rsx!{ key: "{k}", "{v}" })
|
||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// // collect into a Vec
|
/// // collect into a Vec
|
||||||
@@ -80,9 +80,9 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// To access values from a `UseRef` in an async context, you need to detach it
|
/// To access values from a `UseRef` in an async context, you need to detach it
|
||||||
/// from the current scope's lifetime, making it a `'static` value. This is done
|
/// from the current scope's lifetime, making it a `'static` value. This is done
|
||||||
/// by simply calling `ToOnwed` or `Clone`.
|
/// by simply calling `to_owned` or `clone`.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
||||||
///
|
///
|
||||||
/// cx.spawn({
|
/// cx.spawn({
|
||||||
@@ -95,15 +95,15 @@ use std::{
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// If you're working with lots of values like UseState and UseRef, you can use the
|
/// If you're working with lots of values like UseState and UseRef, you can use the
|
||||||
/// `clone!` macro to make it easier to write the above code.
|
/// `to_owned!` macro to make it easier to write the above code.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let val1 = use_ref(|| HashMap::<u32, String>::new());
|
/// let val1 = use_ref(|| HashMap::<u32, String>::new());
|
||||||
/// let val2 = use_ref(|| HashMap::<u32, String>::new());
|
/// let val2 = use_ref(|| HashMap::<u32, String>::new());
|
||||||
/// let val3 = use_ref(|| HashMap::<u32, String>::new());
|
/// let val3 = use_ref(|| HashMap::<u32, String>::new());
|
||||||
///
|
///
|
||||||
/// cx.spawn({
|
/// cx.spawn({
|
||||||
/// clone![val1, val2, val3];
|
/// to_owned![val1, val2, val3];
|
||||||
/// async move {
|
/// async move {
|
||||||
/// some_work().await;
|
/// some_work().await;
|
||||||
/// val.write().insert(1, "hello".to_string());
|
/// val.write().insert(1, "hello".to_string());
|
||||||
@@ -194,7 +194,7 @@ impl<T> UseRef<T> {
|
|||||||
/// Note: You can always "reborrow" the value through the RefCell.
|
/// Note: You can always "reborrow" the value through the RefCell.
|
||||||
/// This method just does it for you automatically.
|
/// This method just does it for you automatically.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@@ -214,7 +214,7 @@ impl<T> UseRef<T> {
|
|||||||
/// Note: You can always "reborrow" the value through the RefCell.
|
/// Note: You can always "reborrow" the value through the RefCell.
|
||||||
/// This method just does it for you automatically.
|
/// This method just does it for you automatically.
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, no_run
|
||||||
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
/// let val = use_ref(|| HashMap::<u32, String>::new());
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dioxus-playwrite-fullstack-test"
|
name = "dioxus-playwright-fullstack-test"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// This test is used by playwrite configured in the root of the repo
|
// This test is used by playwright configured in the root of the repo
|
||||||
// Tests:
|
// Tests:
|
||||||
// - Server functions
|
// - Server functions
|
||||||
// - SSR
|
// - SSR
|
||||||
File renamed without changes.
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dioxus-playwrite-liveview-test"
|
name = "dioxus-playwright-liveview-test"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Playwrite test for Dioxus Liveview"
|
description = "Playwright test for Dioxus Liveview"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// This test is used by playwrite configured in the root of the repo
|
// This test is used by playwright configured in the root of the repo
|
||||||
|
|
||||||
use axum::{extract::ws::WebSocketUpgrade, response::Html, routing::get, Router};
|
use axum::{extract::ws::WebSocketUpgrade, response::Html, routing::get, Router};
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
File renamed without changes.
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dioxus-playwrite-web-test"
|
name = "dioxus-playwright-web-test"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Playwrite test for Dioxus Web"
|
description = "Playwright test for Dioxus Web"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// This test is used by playwrite configured in the root of the repo
|
// This test is used by playwright configured in the root of the repo
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_web::use_eval;
|
use dioxus_web::use_eval;
|
||||||
+13
-12
@@ -1,6 +1,6 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
const { defineConfig, devices } = require('@playwright/test');
|
const { defineConfig, devices } = require("@playwright/test");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read environment variables from file.
|
* Read environment variables from file.
|
||||||
@@ -12,7 +12,7 @@ const path = require('path');
|
|||||||
* @see https://playwright.dev/docs/test-configuration
|
* @see https://playwright.dev/docs/test-configuration
|
||||||
*/
|
*/
|
||||||
module.exports = defineConfig({
|
module.exports = defineConfig({
|
||||||
testDir: './playwrite-tests',
|
testDir: "./playwright-tests",
|
||||||
/* Run tests in files in parallel */
|
/* Run tests in files in parallel */
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
@@ -22,21 +22,21 @@ module.exports = defineConfig({
|
|||||||
/* Opt out of parallel tests on CI. */
|
/* Opt out of parallel tests on CI. */
|
||||||
workers: process.env.CI ? 1 : undefined,
|
workers: process.env.CI ? 1 : undefined,
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: 'html',
|
reporter: "html",
|
||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
// baseURL: 'http://127.0.0.1:3000',
|
// baseURL: 'http://127.0.0.1:3000',
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: "on-first-retry",
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Configure projects for major browsers */
|
/* Configure projects for major browsers */
|
||||||
projects: [
|
projects: [
|
||||||
{
|
{
|
||||||
name: 'chromium',
|
name: "chromium",
|
||||||
use: { ...devices['Desktop Chrome'] },
|
use: { ...devices["Desktop Chrome"] },
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
@@ -73,27 +73,28 @@ module.exports = defineConfig({
|
|||||||
/* Run your local dev server before starting the tests */
|
/* Run your local dev server before starting the tests */
|
||||||
webServer: [
|
webServer: [
|
||||||
{
|
{
|
||||||
command: 'cargo run --package dioxus-playwrite-liveview-test --bin dioxus-playwrite-liveview-test',
|
command:
|
||||||
|
"cargo run --package dioxus-playwright-liveview-test --bin dioxus-playwright-liveview-test",
|
||||||
port: 3030,
|
port: 3030,
|
||||||
timeout: 10 * 60 * 1000,
|
timeout: 10 * 60 * 1000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cwd: path.join(process.cwd(), 'playwrite-tests', 'web'),
|
cwd: path.join(process.cwd(), "playwright-tests", "web"),
|
||||||
command: 'dioxus serve',
|
command: "dioxus serve",
|
||||||
port: 8080,
|
port: 8080,
|
||||||
timeout: 10 * 60 * 1000,
|
timeout: 10 * 60 * 1000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cwd: path.join(process.cwd(), 'playwrite-tests', 'fullstack'),
|
cwd: path.join(process.cwd(), 'playwright-tests', 'fullstack'),
|
||||||
command: 'dioxus build --features web --release\ncargo run --release --features ssr --no-default-features',
|
command: 'dioxus build --features web --release\ncargo run --release --features ssr --no-default-features',
|
||||||
port: 3333,
|
port: 3333,
|
||||||
timeout: 10 * 60 * 1000,
|
timeout: 10 * 60 * 1000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user