Compare commits

..

550 Commits

Author SHA1 Message Date
Greg Johnston
2abb56a9fc chore: clippy 2024-07-24 09:22:20 -04:00
Greg Johnston
ca0c2a6280 example: use a local signal for the input 2024-07-24 09:20:09 -04:00
Greg Johnston
50026be1ae feat: mark branches in AnyView 2024-07-24 09:15:54 -04:00
Greg Johnston
d6e7f44a6a chore: clippy 2024-07-24 09:09:03 -04:00
Greg Johnston
b77559af51 chore: remove unused imports 2024-07-24 09:07:43 -04:00
Greg Johnston
8ce42747fd fix: improve type inference for the default threadsafe signal case 2024-07-24 09:06:27 -04:00
Greg Johnston
8245324989 chore: clippy 2024-07-24 08:15:32 -04:00
Greg Johnston
8f75eca6a6 fix: add missing imports 2024-07-24 08:14:31 -04:00
Greg Johnston
8a22e33d3c docs: fix cfg for docsrs 2024-07-24 07:56:57 -04:00
Greg Johnston
98f849e28e chore: remove unnecessary default generics 2024-07-24 07:56:57 -04:00
Greg Johnston
cf765549fb chore: clippy and fmt 2024-07-24 07:56:57 -04:00
Saber Haj Rabiee
48ded323a8 fix: hackernews_js_fetch example for leptos_0.7 (#2678) 2024-07-24 07:56:57 -04:00
Greg Johnston
acbd96059b feat: allow !Send signals 2024-07-24 07:56:57 -04:00
Greg Johnston
01755bbd82 fix: rename nightly feature for const generic &'static str (d0c11bf6e3\#diff-7b65e42e2b87910c94950caf7f0687fda2f9f98f311099404f5c4afb4a36e50c) 2024-07-24 07:56:57 -04:00
Greg Johnston
75e681a977 chore: remove pub field in Suspend so that Suspend::new() must be used 2024-07-24 07:56:57 -04:00
Greg Johnston
835d4a3e64 chore: fmt 2024-07-24 07:56:57 -04:00
Greg Johnston
90ea25aee1 fix: only create Future once initially, and poll it twice, rather than creating it twice 2024-07-24 07:56:57 -04:00
Greg Johnston
505f192e6a chore: fmt 2024-07-24 07:56:57 -04:00
Greg Johnston
8b0943be06 feat: optional branch-marking in HTML to support initial work on client-side islands routing 2024-07-24 07:56:57 -04:00
Corvus
845447e0ce feat: reintroduce queue_microtask (#2703) 2024-07-24 07:56:57 -04:00
Greg Johnston
78601d69ae fix: allow one-element tuples for route matching 2024-07-24 07:56:57 -04:00
Greg Johnston
a40c591039 example: use path! macro in router example 2024-07-24 07:56:57 -04:00
Greg Johnston
decec8c580 fix: add HTML global on___ attributes 2024-07-24 07:56:57 -04:00
boyswan
e4749dc1a9 feat: add path! macro in router to parse string paths into tuples (#2694) 2024-07-24 07:56:57 -04:00
mahmoud-eltahawy
74112f0690 feat: allow using enums for StaticSegment by implementing AsPath (#2685) 2024-07-24 07:56:57 -04:00
Greg Johnston
0e5a3a4317 fix: set None observer properly in ScopedFuture 2024-07-24 07:56:57 -04:00
Greg Johnston
e0640f92dd fix: remove unnecessary untrack in Show 2024-07-24 07:56:57 -04:00
Greg Johnston
c6a209c0d5 fix: Suspend::new() in router 2024-07-24 07:56:57 -04:00
Greg Johnston
eda56e2758 examples: update to Suspend::new() 2024-07-24 07:56:57 -04:00
Greg Johnston
35a88ee9e4 docs: improved warning location 2024-07-24 07:56:56 -04:00
Greg Johnston
adb7adacd7 fix: require Suspend::new() to ensure the Future is properly scoped at creation time, not at render time 2024-07-24 07:56:56 -04:00
Greg Johnston
22762ecf85 fix: explicitly untrack the children of <Show/> 2024-07-24 07:56:56 -04:00
Greg Johnston
093723ce2e fix: custom elements should support any attribute names 2024-07-24 07:56:56 -04:00
Greg Johnston
71c94d53bf fix: custom elements SSR 2024-07-24 07:56:56 -04:00
Greg Johnston
b88e4637e9 docs: add tachys docs 2024-07-24 07:56:56 -04:00
Greg Johnston
a4fca5bef1 chore: start with a default sandbox, to avoid panics in tests 2024-07-24 07:56:56 -04:00
Greg Johnston
0b87451ab2 docs: finish reactive graph docs for 0.7 2024-07-24 07:56:56 -04:00
Greg Johnston
523786cd4d docs: porting docs from 0.6 to 0.7 2024-07-24 07:56:56 -04:00
Greg Johnston
3e2f69e6a8 chore: remove unused AsyncState 2024-07-24 07:56:56 -04:00
Bruno De Simone
afbc5be655 add allow too_many_arguments (#2684) 2024-07-24 07:56:56 -04:00
Greg Johnston
d937739f26 chore: clippy 2024-07-24 07:56:56 -04:00
Greg Johnston
7bdba127c0 chore: clippy 2024-07-24 07:56:56 -04:00
Greg Johnston
b1724cc336 chore: clear warnings 2024-07-24 07:56:56 -04:00
Greg Johnston
7ca9b485e5 feat: Suspend on style: and class: 2024-07-24 07:56:56 -04:00
Greg Johnston
a25994612f fix: proper building of paths for nested fields 2024-07-24 07:56:56 -04:00
Greg Johnston
6a1732def4 feat: type-erased store Field structs 2024-07-24 07:56:56 -04:00
Greg Johnston
d07579f278 fix: allow creating resources inside Suspense 2024-07-24 07:56:56 -04:00
Greg Johnston
9a58c639ca examples: revert changes to counter 2024-07-24 07:56:56 -04:00
Bruno De Simone
da9b26fd90 remove FromRef implementation from LeptosRoutes axum impl (#2670) 2024-07-24 07:56:56 -04:00
luoxiaozero
7d5f7d3d05 feat: additional ARIA attributes (#2677) 2024-07-24 07:56:56 -04:00
Greg Johnston
d1a71ef1df feat: iteration over reactive store list 2024-07-24 07:56:56 -04:00
Greg Johnston
f517276b2e feat: add arena-allocated/Copy Store 2024-07-24 07:56:56 -04:00
Greg Johnston
44b4268e6a docs: initial work on porting docs from 0.6 to 0.7 2024-07-24 07:56:56 -04:00
Greg Johnston
6923f52d12 feat: initial work on reactive stores 2024-07-24 07:56:56 -04:00
Greg Johnston
59a3c5538e fix: improved API for unsync actions that doesn't require SendWrapper on input 2024-07-24 07:56:56 -04:00
Greg Johnston
3f4a897e60 chore: leptosfmt 2024-07-24 07:56:56 -04:00
Greg Johnston
6355126fd7 fix: properly handle errors in streaming body responses 2024-07-24 07:56:56 -04:00
Greg Johnston
596cd72303 fix: invalid p/ul relationship causing hydration issue 2024-07-24 07:56:56 -04:00
Saber Haj Rabiee
2cac35b910 chore: cargo fmt (#2672) 2024-07-24 07:56:56 -04:00
Greg Johnston
f92520ce98 feat: use codee for shared ser-de codexes with leptos-use (and more possibilities in future) 2024-07-24 07:56:56 -04:00
Greg Johnston
ecc4e588eb chore: remove unused dependencies 2024-07-24 07:56:56 -04:00
Greg Johnston
4289470059 fix: was disposing of Suspense Owner too early 2024-07-24 07:56:56 -04:00
Greg Johnston
60eb68a856 fix: rebuilding NodeRef 2024-07-24 07:56:56 -04:00
Greg Johnston
a0f5ea2189 feat: top-level Suspend without Suspense 2024-07-24 07:56:56 -04:00
Greg Johnston
67bebf385f chore: clippy and clean up unused functions 2024-07-24 07:56:56 -04:00
Greg Johnston
56af98c19f docs: update syntax for Html/Body 2024-07-24 07:56:56 -04:00
Greg Johnston
21101ce44d feat: correct HTML rendering for spread attributes on <Body/> and <Html/> 2024-07-24 07:56:56 -04:00
Greg Johnston
f11163f904 feat: attributes on body and html 2024-07-24 07:56:56 -04:00
Greg Johnston
a36467c117 feat: move to a channel-based implementation for meta 2024-07-24 07:56:56 -04:00
Greg Johnston
2d39922156 feat: support Suspend in attributes 2024-07-24 07:56:56 -04:00
Greg Johnston
ee2d1fb4d3 feat: local resources with .await 2024-07-24 07:56:56 -04:00
Greg Johnston
105b2d088f chore: cfg warnings 2024-07-24 07:56:56 -04:00
Greg Johnston
48c83890a8 fix: MaybeProp None case 2024-07-24 07:56:56 -04:00
Greg Johnston
2699ec2120 reexport SVG and MathML element types 2024-07-24 07:56:56 -04:00
Greg Johnston
390e917ca4 router alpha 3 2024-07-24 07:56:56 -04:00
Greg Johnston
114c1c1cba Form component in 0.7 2024-07-24 07:56:56 -04:00
Greg Johnston
d8c5e67866 fix: don't break Routes SSR now that it uses Suspend 2024-07-24 07:56:56 -04:00
Alicia Garcia-Raboso
fc368f6767 Implement Default trait for signals with a parameter that also implements Default (#2662)
Co-authored-by: alicia.garcia.raboso <alicia.garcia.raboso@bbva.com>
2024-07-24 07:56:56 -04:00
Greg Johnston
63860a1b26 feat: automatically replace Suspense blocks if they are still waiting to be flushed, without JS (replaces PartiallyBlocked) 2024-07-24 07:56:56 -04:00
Greg Johnston
c7f9eb8be2 blocking resources 2024-07-24 07:56:56 -04:00
Greg Johnston
367852a8dc macro alpha 2 2024-07-24 07:56:56 -04:00
Greg Johnston
1792836113 router alpha 2 2024-07-24 07:56:56 -04:00
Luke Naylor
dbd38f1004 Add missing 'form' attribute for <mo> (#2660)
This attribute seems to be missing in the attribute
table on Mozilla Docs, however does appear in the
compatibility table lower down.
This attribute is also frequently used by temml,
a common generator for mathml content.
2024-07-24 07:56:56 -04:00
Greg Johnston
a402a260a9 allow Outlet to be called multiple times 2024-07-24 07:56:56 -04:00
Greg Johnston
b3ba7cf12f fix: prevent panicking if conditionally rendering Outlet 2024-07-24 07:56:56 -04:00
Greg Johnston
0d60051845 remove log 2024-07-24 07:56:56 -04:00
Greg Johnston
df8ca27875 fix: ensure correct ownership chain when passing views through Outlet 2024-07-24 07:56:56 -04:00
Greg Johnston
637bf25317 chore: clippy 2024-07-24 07:56:56 -04:00
Greg Johnston
7cced5d011 support MaybeSignal in view 2024-07-24 07:56:56 -04:00
Kajetan Welc
154f43f3d6 fix: impl Copy for Callback (#2658) 2024-07-24 07:56:56 -04:00
Greg Johnston
e632c8981a fix: update imports and methods 2024-07-24 07:56:56 -04:00
Greg Johnston
1c9428dd2c fix: trait import 2024-07-24 07:56:56 -04:00
Greg Johnston
90dd481e94 impl From<T> for (Arc)Signal<T> 2024-07-24 07:56:56 -04:00
Greg Johnston
9c717ab035 Revert "lazy Future construction for AsyncDerived"
This reverts commit 9e84e1f57c.
2024-07-24 07:56:56 -04:00
Greg Johnston
08f933bcd8 fix: <option> struct generation 2024-07-24 07:56:56 -04:00
Greg Johnston
ffcd0cd27e fix: <option> struct generation 2024-07-24 07:56:56 -04:00
Lucas Åström
d4a0110871 Destructuring let (0.7) (#2655)
* Use `let()` syntax for bindings

This lets users use destructuring when binding more complex values, and we also get better IDE support.

* Update rstml
2024-07-24 07:56:56 -04:00
Greg Johnston
503271e833 fix: nonexistent feature 2024-07-24 07:56:56 -04:00
Greg Johnston
cdb43831b9 fix: rebuilding AnyView 2024-07-24 07:56:56 -04:00
Greg Johnston
e1e7703ec1 support wasm-only 2024-07-24 07:56:56 -04:00
Greg Johnston
d89b64b317 support wasm-only 2024-07-24 07:56:56 -04:00
Greg Johnston
e22f1a721f support wasm-only 2024-07-24 07:56:56 -04:00
Greg Johnston
61c177e7d5 any_spawner tick version 2024-07-24 07:56:56 -04:00
Greg Johnston
2c8454ac60 un-break circular dependency 2024-07-24 07:56:56 -04:00
Greg Johnston
dba780680a chore: update test output 2024-07-24 07:56:56 -04:00
Greg Johnston
5e9218b495 chore: unused import 2024-07-24 07:56:56 -04:00
Greg Johnston
fa679a08a1 restore fallback for compressed version 2024-07-24 07:56:56 -04:00
Greg Johnston
8e68aea7f5 docs: working on memo docs 2024-07-24 07:56:56 -04:00
Greg Johnston
8727642f00 0.7.0-alpha 2024-07-24 07:56:56 -04:00
Greg Johnston
c56b0160ca feat: support reactive and asynchronous ProtectedRoute conditions 2024-07-24 07:56:56 -04:00
Greg Johnston
b6285f6427 fix: correct For behavior when mounting with siblings, and when clearing 2024-07-24 07:56:56 -04:00
Ben Wishovich
868d34f746 Make get_configuration sync (#2647)
* Made get_configuraiton sync

* Update examples
2024-07-24 07:56:56 -04:00
Greg Johnston
da9985bdcd examples: update directives tests 2024-07-24 07:56:55 -04:00
Greg Johnston
250bae1e5a chore: cargo fmt 2024-07-24 07:56:55 -04:00
Greg Johnston
9f9f445031 make RemoveEventHandler a concrete type 2024-07-24 07:56:55 -04:00
Greg Johnston
f9bcaff77e feat: add ElementExt to give access to the same view APIs at runtime that we do at compile time 2024-07-24 07:56:55 -04:00
Greg Johnston
3ca0154e8d feat: add ElementExt to give access to the same view APIs at runtime that we do at compile time 2024-07-24 07:56:55 -04:00
Greg Johnston
4d72ca05b6 chore: cargo fmt 2024-07-24 07:56:55 -04:00
Greg Johnston
879a075129 chore: cargo fmt 2024-07-24 07:56:55 -04:00
Greg Johnston
6be5583633 docs: warn on unused RenderEffect 2024-07-24 07:56:55 -04:00
Greg Johnston
c2381ce983 chore: missing Debug implementations 2024-07-24 07:56:55 -04:00
Greg Johnston
d8ac849cef chore: suppress unnecessary .into() warning 2024-07-24 07:56:55 -04:00
Greg Johnston
8c12d6ec30 cargo fmt 2024-07-24 07:56:55 -04:00
Greg Johnston
dbefaed343 updated directives example 2024-07-24 07:56:55 -04:00
brofrain
a69ec96e75 fix: update HtmlViewState & BodyViewState as well 2024-07-24 07:56:55 -04:00
Kajetan Welc
6f349cf630 fix: do not accidentally mount things before meta tags in the <head> when updating the DOM v2 2024-07-24 07:56:55 -04:00
Greg Johnston
6d0f027d45 remove log 2024-07-24 07:56:55 -04:00
Greg Johnston
ca29be7f08 preliminary work on directives (not useful yet until we have an ElementExt that allows you to do things declaratively from an Element 2024-07-24 07:56:55 -04:00
Greg Johnston
0d7f2c8c2c omit () entirely if it is the only child of an HTML element 2024-07-24 07:56:55 -04:00
Greg Johnston
8067b269bf fix: don't override a text node's 'next sibling after text' position if it's in Either, now that they don't have separate marker nodes 2024-07-24 07:56:55 -04:00
Greg Johnston
cc0198244f fix: do not accidentally mount things before meta tags in the <head> when updating the DOM 2024-07-24 07:56:55 -04:00
Greg Johnston
fbc2461c2c fix docs for hydrate_islands 2024-07-24 07:56:55 -04:00
Greg Johnston
dc03ba0a28 hackernews islands example 2024-07-24 07:56:55 -04:00
Greg Johnston
5787e0c91f update static file serving in Axum examples 2024-07-24 07:56:55 -04:00
Greg Johnston
1e7cf132cb fix islands ci setup 2024-07-24 07:56:55 -04:00
Greg Johnston
6cf69fe08c fix: remove extra comment at end of Suspense now that Either no longer requires it 2024-07-24 07:56:55 -04:00
Greg Johnston
a512fb8be3 feat: provide static file handling/fallback directly in integration 2024-07-24 07:56:55 -04:00
Greg Johnston
91c6c340aa islands example 2024-07-24 07:56:55 -04:00
Greg Johnston
32605f4e96 remove unused tests and dependencies 2024-07-24 07:56:55 -04:00
Greg Johnston
5c956026a0 fix: () in templates 2024-07-24 07:56:55 -04:00
Greg Johnston
d34718ad31 chore: clippy 2024-07-24 07:56:55 -04:00
Greg Johnston
092822d318 fix js-framework-benchmark for stable 2024-07-24 07:56:55 -04:00
Greg Johnston
9ed1acd906 update hackernews_axum to 0.7 2024-07-24 07:56:55 -04:00
Greg Johnston
cab828da6f fix ErrorBoundary starting in error state in CSR 2024-07-24 07:56:55 -04:00
Greg Johnston
3ae26d4aef fix example tests 2024-07-24 07:56:55 -04:00
Greg Johnston
d737ab62c6 remove unnecessary logs 2024-07-24 07:56:55 -04:00
Greg Johnston
b77e640f58 update islands example 2024-07-24 07:56:55 -04:00
Greg Johnston
242ef36f87 chore: unused hooks 2024-07-24 07:56:55 -04:00
Greg Johnston
37e78df9e9 regression test for 7094dee150 2024-07-24 07:56:55 -04:00
Greg Johnston
03330336aa fix: signals mark subscribers dirty, but don't say they're always dirty if they haven't changed 2024-07-24 07:56:55 -04:00
Greg Johnston
8c0a5107f7 make Routes fallback run lazily 2024-07-24 07:56:55 -04:00
Greg Johnston
e7cc1b7f49 make ErrorBoundary fallback run lazily 2024-07-24 07:56:55 -04:00
Greg Johnston
0beb620aba examples: errors_axum 2024-07-24 07:56:55 -04:00
Greg Johnston
2cd576ebd3 chore(ci): fix examples 2024-07-24 07:56:55 -04:00
Greg Johnston
58ac7cdf77 enable reactive-graph hydration when hydration is enabled 2024-07-24 07:56:55 -04:00
Greg Johnston
fcb5d63e47 allow conversion directly from Arc signal types to MaybeSignal 2024-07-24 07:56:55 -04:00
Greg Johnston
c306a40d3b expose Owner::shared_context() 2024-07-24 07:56:55 -04:00
Greg Johnston
c32b21329a 0.7 Provider component 2024-07-24 07:56:55 -04:00
Greg Johnston
bca905e617 fix tests 2024-07-24 07:56:55 -04:00
Greg Johnston
27ee65a7e8 fix reactive styles 2024-07-24 07:56:55 -04:00
Greg Johnston
8640b36b8e fix: correctly rebuild reactive attributes to avoid stale signals 2024-07-24 07:56:55 -04:00
Greg Johnston
77b6255f3c type-erase RenderEffeect functions for binary size improvements 2024-07-24 07:56:55 -04:00
luoxiaozero
f00b8e02c6 feat: Attr exposes PhantomData field (#2641) 2024-07-24 07:56:55 -04:00
Greg Johnston
20ce0f543e chore(ci): remove warnings in tests 2024-07-24 07:56:55 -04:00
Greg Johnston
d40e8ac297 feat: 0.7 query signals 2024-07-24 07:56:55 -04:00
Greg Johnston
f6e83698de chore(ci): add Makefiles for smaller packages 2024-07-24 07:56:55 -04:00
Greg Johnston
a93212c533 chore(ci): only run semver checks if not labeled 'breaking' 2024-07-24 07:56:55 -04:00
Greg Johnston
8e107b042e chore: clippy 2024-07-24 07:56:55 -04:00
Greg Johnston
05dded3f48 rename from new_serde to new 2024-07-24 07:56:55 -04:00
Greg Johnston
153f9af497 remove most remaining marker/placeholder elements 2024-07-24 07:56:55 -04:00
Greg Johnston
1c3c161a1b add trait impls and encodings for SharedValue 2024-07-24 07:56:55 -04:00
Greg Johnston
a91eab4f5b default to SerdeJson encoding for resources, use new_str() for Str encoding 2024-07-24 07:56:55 -04:00
Greg Johnston
255fa85925 feat: synchronous serialized values with SharedValue 2024-07-24 07:56:55 -04:00
Greg Johnston
da77d0fb36 whenever we create a new root Owner, set it as the current owner, which will make it the default owner (e.g., during SSR) instead of None 2024-07-24 07:56:55 -04:00
Greg Johnston
0e360b7e00 fix: can't memoize JS properties, because they can be set between signal updates by user input 2024-07-24 07:56:55 -04:00
Greg Johnston
404de33fb3 fix: correctly escape style and class attributes 2024-07-24 07:56:55 -04:00
Greg Johnston
6712656738 chore: clippy 2024-07-24 07:56:55 -04:00
Greg Johnston
38bb187735 don't require spawn_local for actios 2024-07-24 07:56:55 -04:00
Greg Johnston
f57f0831b8 catch resource reads inside Signal during Suspense 2024-07-24 07:56:55 -04:00
Greg Johnston
1c2b201e1f fix CSS file names 2024-07-24 07:56:55 -04:00
Greg Johnston
2058cee348 update todo app csr 2024-07-24 07:56:55 -04:00
Greg Johnston
140996db6e fix: correctly escape text nodes, except in script/style tags 2024-07-24 07:56:55 -04:00
Greg Johnston
4c9adc7d50 chore: clean up examples for CI 2024-07-24 07:56:55 -04:00
Greg Johnston
196d845b86 fix: provide matched route via context when rebuilding (so <A> works) 2024-07-24 07:56:55 -04:00
Greg Johnston
3dec67a51e unused 2024-07-24 07:56:55 -04:00
Greg Johnston
abe4b39a01 refactor insert_before_this to find parent lazily, and use it for rebuilding reactive components by replacing their whole contents 2024-07-24 07:56:55 -04:00
Greg Johnston
99d8541c83 make sure SendWrapper supports Futures 2024-07-24 07:56:55 -04:00
Greg Johnston
37e5e89c78 move several complex examples into projects 2024-07-24 07:56:55 -04:00
Greg Johnston
5e11ea1753 update js-framework-benchmark example 2024-07-24 07:56:55 -04:00
Greg Johnston
8c54f7b8cf fix test text 2024-07-24 07:56:55 -04:00
Greg Johnston
f6b265ce7f fix: custom Stream implementation for streaming resource data that supports nested data/multiple polled values, rather than taking it all at once at the beginning 2024-07-24 07:56:55 -04:00
Greg Johnston
8b0b24ad72 suspense_tests: actually wait for other resource in nested case 2024-07-24 07:56:55 -04:00
Greg Johnston
69ac71ab04 can save a lookup here 2024-07-24 07:56:55 -04:00
Greg Johnston
7c9ff835e4 remove unused workspace member 2024-07-24 07:56:54 -04:00
Greg Johnston
261856e6f3 update workflows 2024-07-24 07:56:54 -04:00
Greg Johnston
32976b2de4 remove unused leptos_reactive integration 2024-07-24 07:56:54 -04:00
Greg Johnston
508e38d48d remove old router files 2024-07-24 07:56:54 -04:00
Greg Johnston
48d125222a fix Cargo.toml after merge 2024-07-24 07:56:54 -04:00
Greg Johnston
49fb0f681c re-enable all routes 2024-07-24 07:56:54 -04:00
Greg Johnston
7737376672 chore: clean up warnings and logging 2024-07-24 07:56:54 -04:00
Greg Johnston
c9091ffcdc reverted Fn()/FnMut() change 2024-07-24 07:56:54 -04:00
Greg Johnston
2e3a976288 Revert "fix: constrain reactive rendering to Fn(), because using dry_resolve() for Suspense requires idempotent render functions so that they can be called once (to register resources) and called a second time to resolve"
This reverts commit 7ec5c77ba3e8f45bae04a7661a56741f95125adb.
2024-07-24 07:56:54 -04:00
Greg Johnston
e044ab3070 progress on updating suspense tests 2024-07-24 07:56:54 -04:00
Greg Johnston
0a5764868f add server redirects 2024-07-24 07:56:54 -04:00
Greg Johnston
bee7a2c13a fix: relative path resolution 2024-07-24 07:56:54 -04:00
Greg Johnston
b3b1f11b1c simplifying todo examples 2024-07-24 07:56:54 -04:00
Greg Johnston
78d0c75ef4 initial work updating suspense tests 2024-07-24 07:56:54 -04:00
Greg Johnston
a53a30dbed clarify hydrate/csr warning 2024-07-24 07:56:54 -04:00
Greg Johnston
10d5bd704e export actions in prelude 2024-07-24 07:56:54 -04:00
Greg Johnston
69da1f2198 remove Into<_> by default for setting signals, because it interferes with type inference 2024-07-24 07:56:54 -04:00
Greg Johnston
5e32da1690 add support for unsync actions 2024-07-24 07:56:54 -04:00
Greg Johnston
a6ad908cae simplifying and updating server fns example 2024-07-24 07:56:54 -04:00
Greg Johnston
d8bf76963f change name to shell 2024-07-24 07:56:54 -04:00
Greg Johnston
78c1ab6546 update control flow components to new Fn() constraint 2024-07-24 07:56:54 -04:00
Greg Johnston
6abd75463e fix: constrain reactive rendering to Fn(), because using dry_resolve() for Suspense requires idempotent render functions so that they can be called once (to register resources) and called a second time to resolve 2024-07-24 07:56:54 -04:00
Greg Johnston
a395fcdb95 add Debug impl 2024-07-24 07:56:54 -04:00
Greg Johnston
56cfb95df8 fix: actually concatenate nested routes during route generation 2024-07-24 07:56:54 -04:00
Greg Johnston
7d323103c5 reorganize Outlet export 2024-07-24 07:56:54 -04:00
Greg Johnston
0bd39a58ec examples: porting to 0.7 and cleaning up 2024-07-24 07:56:54 -04:00
Greg Johnston
d6ba60a9b0 fix merge 2024-07-24 07:56:54 -04:00
Rakshith Ravi
c9cc2a140f Update import statements in examples (#2625) 2024-07-24 07:56:54 -04:00
Greg Johnston
988aadeef2 examples: use application 404 page 2024-07-24 07:56:54 -04:00
Greg Johnston
e3d1daa87b chore: cargo fmt 2024-07-24 07:56:54 -04:00
Greg Johnston
76d7a5f619 chore: cargo fmt 2024-07-24 07:56:54 -04:00
Greg Johnston
a8be8b2ca9 add warnings if correct features not set for browser 2024-07-24 07:56:54 -04:00
Greg Johnston
6f2467de06 use csr feature so that reactivity runs 2024-07-24 07:56:54 -04:00
Greg Johnston
6bcafb49e4 chore: clippy 2024-07-24 07:56:54 -04:00
Greg Johnston
44fa16dde3 examples: fix input type so tests work, and update text to make the purpose clearer 2024-07-24 07:56:54 -04:00
Greg Johnston
64a4e59266 remove leptos_reactive (moved into reactive_graph and leptos_server) 2024-07-24 07:56:54 -04:00
Greg Johnston
722d77b128 fix: Clone for ArcResource and default to SerdeJson for Resource 2024-07-24 07:56:54 -04:00
Greg Johnston
24b3d9988a chore: clippy 2024-07-24 07:56:54 -04:00
Greg Johnston
aac902c349 fix: don't dispose of parent owners before Suspense children have been rendered 2024-07-24 07:56:54 -04:00
Greg Johnston
644081860f warn if trying to use meta on server side without context 2024-07-24 07:56:54 -04:00
Greg Johnston
0f225daa40 only run RenderEffects when effects are enabled 2024-07-24 07:56:54 -04:00
Greg Johnston
933e015d24 add set_pending to <Transition/> 2024-07-24 07:56:54 -04:00
Greg Johnston
11c2ba553f simplify FlatRoutes logic by using existing OwnedView infrastructure 2024-07-24 07:56:54 -04:00
Greg Johnston
43675b7741 reexport tick() for testing 2024-07-24 07:56:54 -04:00
Greg Johnston
c70c9681e3 fix: ensure that leptos_meta and leptos_router are in SSR mode if using one of the server integrations 2024-07-24 07:56:54 -04:00
Greg Johnston
55725ea11e examples: update hackernews for SSR support 2024-07-24 07:56:54 -04:00
Greg Johnston
41dc042ee7 fix: correctly notify multiple subscribers to same AsyncDerived 2024-07-24 07:56:54 -04:00
Greg Johnston
16f66c5e52 fix: Routes SSR 2024-07-24 07:56:54 -04:00
Greg Johnston
6ff7bca5de fix: correct owner for HTML rendering in FlatRoutes 2024-07-24 07:56:54 -04:00
Greg Johnston
1df939d41e testing: provide tick() that can be called anywhere in tests 2024-07-24 07:56:54 -04:00
Greg Johnston
4845cf989f testing: provide tick() that can be called anywhere in tests 2024-07-24 07:56:54 -04:00
Greg Johnston
ffe09346cd fix portal tests 2024-07-24 07:56:54 -04:00
Greg Johnston
b591140291 fix cleanups in render effects 2024-07-24 07:56:54 -04:00
Greg Johnston
d4f35fb41f chore: clippy 2024-07-24 07:56:54 -04:00
Greg Johnston
d343b373c7 update counters_isomorphic 2024-07-24 07:56:54 -04:00
Greg Johnston
b0c3bb9b10 reexport spawn and spawn_local 2024-07-24 07:56:54 -04:00
Greg Johnston
32a8433d0b ReadSignal from stream 2024-07-24 07:56:54 -04:00
Greg Johnston
1571c907b2 refactor to allow rendering Resource directly in view 2024-07-24 07:56:54 -04:00
Greg Johnston
2baccc8615 removed AnimatedShow example (duplicates the component docs) 2024-07-24 07:56:54 -04:00
Greg Johnston
74fa1da243 properly serialize errors 2024-07-24 07:56:54 -04:00
Greg Johnston
ec617214eb chore: clear warning 2024-07-24 07:56:54 -04:00
Greg Johnston
1b351f5139 pick up on server action error in both server and client 2024-07-24 07:56:54 -04:00
Greg Johnston
1682b6a543 fmt and chores in examples 2024-07-24 07:56:54 -04:00
Greg Johnston
8d634c0d35 fix: serialize an empty string into HTML so it still works as a text node 2024-07-24 07:56:54 -04:00
Greg Johnston
0f820152ca fix: make router fallback lazy 2024-07-24 07:56:54 -04:00
Greg Johnston
a270b7c7c3 add expect_context 2024-07-24 07:56:54 -04:00
Greg Johnston
da824e3e38 fix attr:class when spreading onto a component 2024-07-24 07:56:54 -04:00
Greg Johnston
0255b3991b add ServerAction error handling for any error type (closes #2325) 2024-07-24 07:56:54 -04:00
Greg Johnston
9c44e486f6 remove unused import 2024-07-24 07:56:54 -04:00
Greg Johnston
652c153c6b clean up example 2024-07-24 07:56:54 -04:00
Greg Johnston
b7d9dde973 add CollectView 2024-07-24 07:56:54 -04:00
Greg Johnston
92df0fb145 Actix todo_app_sqlite 2024-07-24 07:56:54 -04:00
Greg Johnston
93bb2e1803 fix: don't drop Owner in FlatRoutes until route has been rendered (thanks @benwis) 2024-07-24 07:56:54 -04:00
Greg Johnston
db25d08ba9 fix: make sure all resource reads are registered 2024-07-24 07:56:54 -04:00
Greg Johnston
48dad26797 chore: clippy and unused dependencies in integrations 2024-07-24 07:56:54 -04:00
Greg Johnston
0b29246972 add some tracing and debug info to HTML elements 2024-07-24 07:56:54 -04:00
Greg Johnston
f63811fbda refactor integrations and add Actix integration 2024-07-24 07:56:54 -04:00
Greg Johnston
a78e649a03 feat: 0.7 nonce support 2024-07-24 07:56:54 -04:00
Greg Johnston
7e23c05f77 ResponseOptions support 2024-07-24 07:56:54 -04:00
Greg Johnston
ad36abed67 fix counters tests 2024-07-24 07:56:54 -04:00
Greg Johnston
7aeade70a6 allow .children() on HTML elements 2024-07-24 07:56:54 -04:00
Greg Johnston
471ab8fbe7 remove async demo 2024-07-24 07:56:54 -04:00
Greg Johnston
7ae5b29f47 fix: writing to lock that has a read 2024-07-24 07:56:54 -04:00
Greg Johnston
f12957a6b2 allow untracking on write guards to support maybe_update 2024-07-24 07:56:54 -04:00
Greg Johnston
b3fd881a8f feat: allow .write() on all writeable signals 2024-07-24 07:56:54 -04:00
Greg Johnston
a70cc73c14 feat: add .by_ref() to create a Future from an AsyncDerived (etc.) that takes a reference, rather than cloning 2024-07-24 07:56:54 -04:00
Greg Johnston
097f3c377a use impl trait in props 2024-07-24 07:56:54 -04:00
Greg Johnston
a711531034 update wasm-bindgen testing approaches 2024-07-24 07:56:54 -04:00
Greg Johnston
b5552fc83e chore: clearing warnings in examples 2024-07-24 07:56:54 -04:00
Greg Johnston
947929b827 additional warnings 2024-07-24 07:56:54 -04:00
Greg Johnston
d5027a6b2d cargo fmt 2024-07-24 07:56:54 -04:00
Greg Johnston
ed061ec6a0 chore: clear up... a few warnings 2024-07-24 07:56:54 -04:00
Greg Johnston
d10cca93f8 update sledgehammer integration 2024-07-24 07:56:53 -04:00
Greg Johnston
1103683e7f remove signal function setter Send-only implementation (dead code) 2024-07-24 07:56:53 -04:00
Greg Johnston
42835815ac remove signal function call Read implementations (dead code) 2024-07-24 07:56:53 -04:00
Greg Johnston
f31dafb398 remove leptos_reactive dependency 2024-07-24 07:56:53 -04:00
Greg Johnston
fa8b58992b oco merge issues 2024-07-24 07:56:53 -04:00
Greg Johnston
db11a387e1 feat: return an async guard from .await rather than cloning the value every time 2024-07-24 07:56:53 -04:00
Greg Johnston
fa92cc21e2 fix return type in async tests 2024-07-24 07:56:53 -04:00
Greg Johnston
e2aa2390fc fix tests that run effects 2024-07-24 07:56:53 -04:00
Greg Johnston
541f734341 feat: return Option from AsyncDerived.get() instead of AsyncState 2024-07-24 07:56:53 -04:00
Greg Johnston
5ed1f29485 example: restore ErrorBoundary 2024-07-24 07:56:53 -04:00
Greg Johnston
aa88a54b74 docs for Owner and context 2024-07-24 07:56:53 -04:00
Greg Johnston
c2d91e78e7 fix tests 2024-07-24 07:56:53 -04:00
Greg Johnston
8d7177ef9c poll AsyncDerived synchronously so that it has the correct value during hydration if it reads from a resource 2024-07-24 07:56:53 -04:00
Greg Johnston
61a6f64b90 correct dirty-checking on AsyncDerived 2024-07-24 07:56:53 -04:00
Greg Johnston
f735ae8d5e fix regular suspense if nothing was read synchronously 2024-07-24 07:56:53 -04:00
Greg Johnston
341840f958 missing dry_resolve on Static 2024-07-24 07:56:53 -04:00
Greg Johnston
3d2e971a93 feat: support *either* .await or reactive reads inside Suspense 2024-07-24 07:56:53 -04:00
Greg Johnston
e245418df8 feat: 0.7 slots 2024-07-24 07:56:53 -04:00
Greg Johnston
d6ab394280 feat: enhanced spreading syntax 2024-07-24 07:56:53 -04:00
Greg Johnston
1f59d98f67 fix external navigations 2024-07-24 07:56:53 -04:00
Greg Johnston
7f4f289fba make WindowListenerHandle Send + Sync so it can be remove via on_cleanup 2024-07-24 07:56:53 -04:00
Greg Johnston
be72416b76 restore ssr/hydration for Routes 2024-07-24 07:56:53 -04:00
Greg Johnston
d878a800ea get nested Routes working again 2024-07-24 07:56:53 -04:00
Greg Johnston
bec7ac8f2e default to Params::get() giving an owned value (which you want in a derived signal), but use reference in the macro 2024-07-24 07:56:53 -04:00
Greg Johnston
5bde17008e add proper dirty checking on AsyncDerived so it can read from memos properly 2024-07-24 07:56:53 -04:00
Greg Johnston
920b340085 make NavigateOptions pub 2024-07-24 07:56:53 -04:00
Greg Johnston
e71e36f70c feat: owning memo 2024-07-24 07:56:53 -04:00
Greg Johnston
a4952b0c78 remove warnings in tests and only run if effects are enabled 2024-07-24 07:56:53 -04:00
Greg Johnston
5fe0e1fa0b fix: prevent memos that have changed from re-triggering the running effect, by setting the Observer during .update_if_necessary() 2024-07-24 07:56:53 -04:00
Greg Johnston
ecb973f74a feat: add Popover API 2024-07-24 07:56:53 -04:00
Greg Johnston
8c1ed5b464 fix Script children 2024-07-24 07:56:53 -04:00
Greg Johnston
0600d7460c fix hydration of Suspend by including the missing placeholder it expects during hydration 2024-07-24 07:56:53 -04:00
Greg Johnston
8fa6fae868 add missing marker comments for Result 2024-07-24 07:56:53 -04:00
Greg Johnston
f98c032aa9 include marker comments in html len 2024-07-24 07:56:53 -04:00
Greg Johnston
281d6841de unused owner 2024-07-24 07:56:53 -04:00
Greg Johnston
fe5943a9f0 impl From/Into for Signal/ArcSignal 2024-07-24 07:56:53 -04:00
Greg Johnston
fbc29586b2 add ArcSignal::derive() 2024-07-24 07:56:53 -04:00
Greg Johnston
e80e9a89ab routing progress indicator 2024-07-24 07:56:53 -04:00
Greg Johnston
66578a94d3 missing min attribute 2024-07-24 07:56:53 -04:00
Greg Johnston
29c6ab1e0b clean up 2024-07-24 07:56:53 -04:00
Greg Johnston
2aa3a1c9d8 remove log 2024-07-24 07:56:53 -04:00
Greg Johnston
94da23184a relax trait bounds on reactive types where possible 2024-07-24 07:56:53 -04:00
Greg Johnston
ed0152d270 add SignalSetter 2024-07-24 07:56:53 -04:00
Greg Johnston
8ea8b0bf47 use transition between navigations 2024-07-24 07:56:53 -04:00
Greg Johnston
b32bcdb0c8 add async transitions that wait for any AsyncDerived created/triggered under them before resolving 2024-07-24 07:56:53 -04:00
Greg Johnston
1a217423dc resolve() on OwnedView 2024-07-24 07:56:53 -04:00
Greg Johnston
0a9a8736ed restore hydration feature for some of its feature-gating benefits for Resource deserialization 2024-07-24 07:56:53 -04:00
Greg Johnston
bd80ea2eb2 cargo fmt 2024-07-24 07:56:53 -04:00
Greg Johnston
c0f6d2fde8 create separate URL/params signals for each route, to prevent updating them and running side effects while navigating away 2024-07-24 07:56:53 -04:00
Greg Johnston
dd3eccae87 fmt 2024-07-24 07:56:53 -04:00
Greg Johnston
7447c0f58e distinguish between dirty and check in effects, so that memos and signals both work correctly 2024-07-24 07:56:53 -04:00
Greg Johnston
2b406e0473 remove unused feature 2024-07-24 07:56:53 -04:00
Greg Johnston
c89ef0de77 updated future impls 2024-07-24 07:56:53 -04:00
Greg Johnston
9f1225b48f check whether ArcAsyncDerived actually needs to run when marked check 2024-07-24 07:56:53 -04:00
Greg Johnston
c0b9d5937b add ancestry debugging for owners 2024-07-24 07:56:53 -04:00
Greg Johnston
682c3cd24c lazy Future construction for AsyncDerived 2024-07-24 07:56:53 -04:00
Greg Johnston
e235b7088d support Resource in CSR for backward-compat 2024-07-24 07:56:53 -04:00
Greg Johnston
a72e1d5c23 allow let: syntax to work 2024-07-24 07:56:53 -04:00
Greg Johnston
6cd82630b7 scope Suspense/Transition correctly within ownership tree 2024-07-24 07:56:53 -04:00
Greg Johnston
056456538e upgrading hackernews example 2024-07-24 07:56:53 -04:00
Greg Johnston
14d664d15b immediately commit URL signal updates 2024-07-24 07:56:53 -04:00
Greg Johnston
fbbbd08e5c reexport A from router::components 2024-07-24 07:56:53 -04:00
Greg Johnston
8bf3f0d8dd add IntoAny to tachys prelude 2024-07-24 07:56:53 -04:00
Greg Johnston
cc0f5096c7 finish support for innerHTML 2024-07-24 07:56:53 -04:00
Greg Johnston
15c11e9a5d feat: iterating over items in children with ChildrenFragment, ChildrenFragmentFn, ChildrenFragmentMut 2024-07-24 07:56:53 -04:00
Greg Johnston
209f8cfc48 only warn about non-reactive accesses if effects are enabled 2024-07-24 07:56:53 -04:00
Greg Johnston
84d6301f71 only run effects on client 2024-07-24 07:56:53 -04:00
Greg Johnston
0792319ae1 resolve() implementation for AnyView 2024-07-24 07:56:53 -04:00
Greg Johnston
4c08d99095 fix deadlock on nested Signals 2024-07-24 07:56:53 -04:00
Greg Johnston
1320470d14 fix FlatRouter SSR/hydration after lazy routes 2024-07-24 07:56:53 -04:00
Greg Johnston
433cf151bb feat: nested islands with context for 0.7 2024-07-24 07:56:53 -04:00
Greg Johnston
7ed3a0d5e6 fix: correct Send + Sync bounds for children 2024-07-24 07:56:53 -04:00
Greg Johnston
21a95fe574 feat: minimal island support in 0.7 2024-07-24 07:56:53 -04:00
Greg Johnston
6ac31c05e1 docs: full docs and doctests for Action/MultiAction 2024-07-24 07:56:53 -04:00
Greg Johnston
452189b49a remove support for rendering guards directly, as they are !Send and holding onto them in State is also a bad idea 2024-07-24 07:56:53 -04:00
Greg Johnston
4ff89d0baa support nightly static values for style:key="value" 2024-07-24 07:56:53 -04:00
Greg Johnston
13692b84f1 revert to using .get() for function calls 2024-07-24 07:56:53 -04:00
Greg Johnston
80597581d7 fix: only rerun effects if they have dirty ancestors (or it's the first run) 2024-07-24 07:56:53 -04:00
Greg Johnston
f3fdc6c9fe start working on porting over docs and tests and 0.7... 2024-07-24 07:56:53 -04:00
Greg Johnston
bf81e3077c fix meta issue with attributes 2024-07-24 07:56:53 -04:00
Greg Johnston
8fbdea92a3 fix tracing issue 2024-07-24 07:56:53 -04:00
Greg Johnston
b75559de8e chore: get tests in a working state 2024-07-24 07:56:53 -04:00
Greg Johnston
f4e0ec865d fix: make Selector Send/Sync 2024-07-24 07:56:53 -04:00
Greg Johnston
ab9a9d6235 docs: runtime warning if you use .track() outside a tracking context 2024-07-24 07:56:53 -04:00
Greg Johnston
75214f3d65 preliminary tracing for tachys 2024-07-24 07:56:53 -04:00
Greg Johnston
a09ca6c999 chore: warnings 2024-07-24 07:56:53 -04:00
Greg Johnston
b497bae682 examples: router in 0.7 2024-07-24 07:56:53 -04:00
Greg Johnston
daf2a77b73 fix: passing context through router 2024-07-24 07:56:53 -04:00
Greg Johnston
98fe3c707c chore: fix warnings about variable case 2024-07-24 07:56:53 -04:00
Greg Johnston
4e2e94f0b1 examples: timer in 0.7 2024-07-24 07:56:53 -04:00
Greg Johnston
9affa1cdc8 feat: Portals in 0.7 2024-07-24 07:56:53 -04:00
Greg Johnston
e878ffbe7b allow either eager or lazy routes 2024-07-24 07:56:53 -04:00
Greg Johnston
9c5ef51cc3 update StoredValue API in callbacks 2024-07-24 07:56:53 -04:00
Greg Johnston
dd86f9502d chore: clippy warnings 2024-07-24 07:56:53 -04:00
Greg Johnston
33046ca84a smooth out StoredValue APIs 2024-07-24 07:56:53 -04:00
Greg Johnston
cd766f82c9 MaybeSignal and MaybeProp 2024-07-24 07:56:53 -04:00
Marc-Stefan Cassola
6620f85307 added a few old deprecated functions to help users port (#2580) 2024-07-24 07:56:53 -04:00
Greg Johnston
40259990d8 implement With(Untracked) for Signal 2024-07-24 07:56:53 -04:00
Greg Johnston
2dc685a1de don't over-rerender nested router 2024-07-24 07:56:53 -04:00
Greg Johnston
0617c2d803 initial async routing work (to support bundle splitting) 2024-07-24 07:56:53 -04:00
Greg Johnston
462ffae95f noop attribute 'spreading' for routers 2024-07-24 07:56:53 -04:00
Greg Johnston
a98cc28c37 support arbitrary attributes on components in view 2024-07-24 07:56:52 -04:00
Greg Johnston
c365e885cd full attribute spreading 2024-07-24 07:56:52 -04:00
Greg Johnston
945222726b update counter_without_macros imports 2024-07-24 07:56:52 -04:00
Greg Johnston
161c968211 stashing 2024-07-24 07:56:52 -04:00
Greg Johnston
c4aa720766 give a route to upgrade any attribute into a cloneable one 2024-07-24 07:56:52 -04:00
Greg Johnston
8616fab88b work on attribute spreading 2024-07-24 07:56:52 -04:00
Greg Johnston
d8bda86f1c disable AddAnyAttr again now that I remember why it was broken 2024-07-24 07:56:52 -04:00
Greg Johnston
0128e0486d reenable AnyAttr 2024-07-24 07:56:52 -04:00
Greg Johnston
2c24fa9b71 reorganizing exports and updating examples 2024-07-24 07:56:52 -04:00
Greg Johnston
3572652db2 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
5db973ded5 fix reorganized exports 2024-07-24 07:56:52 -04:00
Greg Johnston
6d81602b98 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
487676df97 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
a6f052c0e4 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
8addbdb64d module restructuring for 0.7 2024-07-24 07:56:52 -04:00
Greg Johnston
2059435144 let ErrorBoundary own the fallback 2024-07-24 07:56:52 -04:00
Greg Johnston
8d9783a770 make Suspend a transparent wrapper 2024-07-24 07:56:52 -04:00
Greg Johnston
844bad68b8 provide params properly in FlatRouter 2024-07-24 07:56:52 -04:00
Greg Johnston
59120c310d clear some warnings 2024-07-24 07:56:52 -04:00
Greg Johnston
aaa64f5cab rename TupleBuilder to NextTuple and prep for release 2024-07-24 07:56:52 -04:00
Greg Johnston
5ee2544952 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
53ac129e27 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
a46900f56c prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
bdc0ec25f2 prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
ea50d81178 rename any_error 2024-07-24 07:56:52 -04:00
Greg Johnston
58951e499b prep for preview release 2024-07-24 07:56:52 -04:00
Greg Johnston
3f57dab7f1 remove twiggy file 2024-07-24 07:56:52 -04:00
Greg Johnston
b1edf04abb move router crates 2024-07-24 07:56:52 -04:00
Greg Johnston
87ca774d49 comparison demo 2024-07-24 07:56:52 -04:00
Greg Johnston
ad062c0ea3 SSR optimizations for binary size, and flat router 2024-07-24 07:56:52 -04:00
Greg Johnston
499b965305 work on Axum integration and on error boundaries 2024-07-24 07:56:52 -04:00
Greg Johnston
cdd2e06f28 stash 2024-07-24 07:56:52 -04:00
Greg Johnston
aa841cc8ea feat: add <A> 2024-07-24 07:56:52 -04:00
Greg Johnston
060f89c492 add use_navigate and Redirect 2024-07-24 07:56:52 -04:00
Greg Johnston
6268d902d9 preliminary use_navigate work 2024-07-24 07:56:52 -04:00
Greg Johnston
1740ccd329 fix fallback => match update 2024-07-24 07:56:52 -04:00
Greg Johnston
4b44ab47a1 add more hooks and primitives to router 2024-07-24 07:56:52 -04:00
Greg Johnston
247802ab87 nested route CSR working 2024-07-24 07:56:52 -04:00
Greg Johnston
df4be92936 continuing on nested routes 2024-07-24 07:56:52 -04:00
Greg Johnston
3024c54f74 continuing on nested routes 2024-07-24 07:56:52 -04:00
Greg Johnston
8d4501d006 working on reconfiguring nested routing 2024-07-24 07:56:52 -04:00
Greg Johnston
02f256f602 make placeholder-finding code consistent across container types 2024-07-24 07:56:52 -04:00
Greg Johnston
018b212f70 remove logs 2024-07-24 07:56:52 -04:00
Greg Johnston
762ed8685b fix Transition hydration 2024-07-24 07:56:52 -04:00
Greg Johnston
ee2c192b99 remove TryCatch/fallible rendering in favor of better ErrorBoundary model 2024-07-24 07:56:52 -04:00
Greg Johnston
c4e5ba3a61 finish todo_app_sqlite_axum 2024-07-24 07:56:52 -04:00
Greg Johnston
b326f0f4e0 fix Vec hydration 2024-07-24 07:56:52 -04:00
Greg Johnston
5ce5ec3cac add MultiActionForm 2024-07-24 07:56:52 -04:00
Greg Johnston
eda794a1ff add MultiAction/ServerMultiAction 2024-07-24 07:56:52 -04:00
Greg Johnston
fe646d7f6a stash 2024-07-24 07:56:52 -04:00
Greg Johnston
26ec393537 ErrorBoundary SSR and serialization of errors to support hydration 2024-07-24 07:56:52 -04:00
Greg Johnston
e9ab1c0b03 get types working with nested ErrorBoundary/Suspense 2024-07-24 07:56:52 -04:00
Greg Johnston
126a1ebbe9 probably as far as I can go with the current SuspenseBoundary approach 2024-07-24 07:56:52 -04:00
Greg Johnston
9024cec3eb fix static types 2024-07-24 07:56:52 -04:00
Greg Johnston
28bce5d2a6 fix cancellation logic for server fn requests 2024-07-24 07:56:52 -04:00
Greg Johnston
7b7a82a8f1 only subscribe to memo manually if already loaded 2024-07-24 07:56:52 -04:00
Greg Johnston
8d3b737303 Suspense SSR 2024-07-24 07:56:52 -04:00
Greg Johnston
7a5e56df15 updates toward todo_app_sqlite 2024-07-24 07:56:52 -04:00
Greg Johnston
7d3715b480 fix stable examples 2024-07-24 07:56:52 -04:00
Greg Johnston
14b9e76e57 implement rendering traits for signals directly on stable 2024-07-24 07:56:52 -04:00
Greg Johnston
309f373601 suspend!() macro 2024-07-24 07:56:52 -04:00
Greg Johnston
d22f347bbb add Transition 2024-07-24 07:56:52 -04:00
Greg Johnston
fc23614d99 loosen requirements for Show 2024-07-24 07:56:52 -04:00
Greg Johnston
f2f43c1237 working on examples 2024-07-24 07:56:52 -04:00
Greg Johnston
6f71e9d6d6 finish TodoMVC example 2024-07-24 07:56:52 -04:00
Greg Johnston
8317e7edaa simplify Suspense: this should still work with hydration 2024-07-24 07:56:52 -04:00
Greg Johnston
5eae11d1ca working model for Suspense with new version 2024-07-24 07:56:52 -04:00
Greg Johnston
5a0954a61a probably as far as I can go with the current SuspenseBoundary approach 2024-07-24 07:56:52 -04:00
Greg Johnston
d94b29cd05 fix ErrorBoundary/Suspense 2024-07-24 07:56:52 -04:00
Greg Johnston
b79a5422aa feat: ErrorBoundary and Suspense 2024-07-24 07:56:52 -04:00
Greg Johnston
6923eed5fd feat: ErrorBoundary 2024-07-24 07:56:52 -04:00
Greg Johnston
21e21e4f35 fix Cargo.toml merge issues 2024-07-24 07:56:52 -04:00
Greg Johnston
e6973deded working on examples 2024-07-24 07:56:52 -04:00
Greg Johnston
6f63cf7a52 styling with CSS 2024-07-24 07:56:52 -04:00
Greg Johnston
f2c16314be example with isomorphic GTK/web design system 2024-07-24 07:56:52 -04:00
Greg Johnston
e9c649477e gtk example 2024-07-24 07:56:52 -04:00
Greg Johnston
2bb30ef6ed ErrorBoundary component 2024-07-24 07:56:52 -04:00
Greg Johnston
537764d82e Suspense/Transition components 2024-07-24 07:56:52 -04:00
Greg Johnston
c64affe458 GTK example for 0.7 2024-07-24 07:56:51 -04:00
Greg Johnston
488b87bcbf add serde-wasm-bindgen encoding for resources 2024-07-24 07:56:51 -04:00
Greg Johnston
555438c747 add typed children 2024-07-24 07:56:51 -04:00
Greg Johnston
cc04773d5f scope Arena to each request 2024-07-24 07:56:51 -04:00
Greg Johnston
f55f634f95 correctly omit HTML-generating code from AnyView 2024-07-24 07:56:51 -04:00
Greg Johnston
58cd2f92d7 experimental sledgehammer Renderer backend 2024-07-24 07:56:51 -04:00
Greg Johnston
67217aa693 fix async context issues, add flat routing 2024-07-24 07:56:51 -04:00
Greg Johnston
c015695462 test more dynamic string length work 2024-07-24 07:56:51 -04:00
Greg Johnston
1eaa6b6b0b attribute value escaping 2024-07-24 07:56:51 -04:00
Greg Johnston
92f76e9177 work related to 0.7 blog port 2024-07-24 07:56:51 -04:00
Greg Johnston
2a4eb9b484 work related to 0.7 blog port 2024-07-24 07:56:51 -04:00
Greg Johnston
0d5f60c7f2 completing work on meta 2024-07-24 07:56:51 -04:00
Greg Johnston
3be3d72f25 completing work on meta 2024-07-24 07:56:51 -04:00
Greg Johnston
b824f59176 initial work on meta 2024-07-24 07:56:51 -04:00
Greg Johnston
b3a799c6dd initial work on meta 2024-07-24 07:56:51 -04:00
Greg Johnston
2dc462bc8b stash 2024-07-24 07:56:51 -04:00
Greg Johnston
971c57c963 fix nested route rebuilding 2024-07-24 07:56:51 -04:00
Greg Johnston
1f2c9780c2 navigation between nested routes 2024-07-24 07:56:51 -04:00
Greg Johnston
346556082d initial stage for working nested route rendering 2024-07-24 07:56:51 -04:00
Greg Johnston
6a249bd29f stash 2024-07-24 07:56:51 -04:00
Greg Johnston
48c1bca429 stash 2024-07-24 07:56:51 -04:00
Greg Johnston
ee5c5d6f4c get basic routing working 2024-07-24 07:56:51 -04:00
Greg Johnston
2a2f129e40 stash 2024-07-24 07:56:51 -04:00
Greg Johnston
ea09fb253a reorganize 2024-07-24 07:56:51 -04:00
Greg Johnston
ade6f1b7bc working on nesting routing 2024-07-24 07:56:51 -04:00
Greg Johnston
2be7f8d06c reorganize 2024-07-24 07:56:51 -04:00
Greg Johnston
cdfb98adf6 stash 2024-07-24 07:56:51 -04:00
Greg Johnston
b9d37a4571 abstract interface to walk nested routes and to access views 2024-07-24 07:56:51 -04:00
Greg Johnston
0e5dce6d0f reorganize and clean up 2024-07-24 07:56:51 -04:00
Greg Johnston
2ff4e1ea8f nested route matching 2024-07-24 07:56:51 -04:00
Greg Johnston
beff818216 stash 2024-07-24 07:56:51 -04:00
Greg Johnston
ba15a96fe7 stash 2024-07-24 07:56:51 -04:00
Greg Johnston
4c67fb854c work on routing utils 2024-07-24 07:56:51 -04:00
Greg Johnston
1416385fc0 nested route matching working 2024-07-24 07:56:51 -04:00
Greg Johnston
643d2c443b stash 2024-07-24 07:56:51 -04:00
Greg Johnston
1c0aabddd0 use either_of crate 2024-07-24 07:56:51 -04:00
Greg Johnston
a8aaa57e7c nested routes take 1 2024-07-24 07:56:51 -04:00
Greg Johnston
c37f67f858 split EitherOfX into its own crate 2024-07-24 07:56:51 -04:00
Greg Johnston
22f6d9b733 work on routing 2024-07-24 07:56:51 -04:00
Greg Johnston
320848895f work on routing 2024-07-24 07:56:51 -04:00
Greg Johnston
a061102ee4 set up routing 2024-07-24 07:56:51 -04:00
Greg Johnston
10b04c7bae clear warning 2024-07-24 07:56:51 -04:00
Greg Johnston
afbc5de1ad chore: clear warnings 2024-07-24 07:56:51 -04:00
Greg Johnston
7542ca3905 pass on: to components (and lay basis for passing all other attributes) 2024-07-24 07:56:51 -04:00
Greg Johnston
eac71a2c1a working on AddAttr 2024-07-24 07:56:51 -04:00
Greg Johnston
26d7c131a0 remove boilerplate: require that Node, Element, etc. types always be Clone + 'static 2024-07-24 07:56:51 -04:00
Greg Johnston
21e981ab58 parent_child example 2024-07-24 07:56:51 -04:00
Greg Johnston
63de8b321f use AnyError for all try_ rendering errors, so that they can compose 2024-07-24 07:56:51 -04:00
Greg Johnston
71beb92d0e support for guards with class: syntax 2024-07-24 07:56:51 -04:00
Greg Johnston
0ceb6d539a add Borrow implementation to make it easier to abstract over T and Guard<T> 2024-07-24 07:56:51 -04:00
Greg Johnston
343f9299d2 finish error boundary (fix last state transition issue) 2024-07-24 07:56:51 -04:00
Greg Johnston
ce6d751368 progress on error boundary that works with nested reactivity 2024-07-24 07:56:51 -04:00
Greg Johnston
cdcd860608 progress on error boundary that works with nested reactivity 2024-07-24 07:56:51 -04:00
Greg Johnston
7b47457209 error example 2024-07-24 07:56:51 -04:00
Greg Johnston
886411a7b0 enable event delegation 2024-07-24 07:56:51 -04:00
Greg Johnston
8773d57ef0 fix release build 2024-07-24 07:56:51 -04:00
Greg Johnston
8c06c2b62b update TODO.md 2024-07-24 07:56:51 -04:00
Greg Johnston
cf4b0747dc store effects in reactive system 2024-07-24 07:56:51 -04:00
Greg Johnston
80d1ef0e58 todomvc example 2024-07-24 07:56:51 -04:00
Greg Johnston
c69e97bfaf work on async demo 2024-07-24 07:56:51 -04:00
Greg Johnston
a891a7a09e clone values for Futures 2024-07-24 07:56:51 -04:00
Greg Johnston
093e41fc3d make guard types more nestable/flexible so that we can implement render traits on any of them 2024-07-24 07:56:51 -04:00
Greg Johnston
0e8bc744b2 work on async demo 2024-07-24 07:56:51 -04:00
Greg Johnston
557b99426f work on async demo 2024-07-24 07:56:51 -04:00
Greg Johnston
9b0b5138d5 feat: create generic any_spawner crate to share between reactive system and renderer 2024-07-24 07:56:51 -04:00
Greg Johnston
97e4be6f85 add other methods on Stored 2024-07-24 07:56:51 -04:00
Greg Johnston
fb700feffb work on async demo 2024-07-24 07:56:51 -04:00
Greg Johnston
b8f7960f6a stash: working on jsfb 2024-07-24 07:56:51 -04:00
Greg Johnston
d71d39f8ed chore: remove unnecessary log 2024-07-24 07:56:51 -04:00
Greg Johnston
88e1ea9b6b fix: correct owner for rows of For, correct cleanup of arenas 2024-07-24 07:56:51 -04:00
Greg Johnston
5587c5e8b8 fix: close memory leak in tasks waiting on channels 2024-07-24 07:56:51 -04:00
Greg Johnston
be725cb27e feat: typed event targets 2024-07-24 07:56:51 -04:00
Greg Johnston
167474ee55 working on examples 2024-07-24 07:56:51 -04:00
Greg Johnston
ba88bdd082 begin migrating to leptos and leptos_dom packages 2024-07-24 07:56:51 -04:00
Greg Johnston
eee18f8b43 stash 2024-07-24 07:56:51 -04:00
Greg Johnston
ccc01e590f stash 2024-07-24 07:56:18 -04:00
Greg Johnston
a8ea282271 chore: remove leptos_reactive and add reactive_graph 2024-07-24 07:56:18 -04:00
Greg Johnston
5c2f0df4b7 feat: improved ergonomics of read guards 2024-07-24 07:56:18 -04:00
Greg Johnston
46151c4b9f feat: add Readable implementation for all types 2024-07-24 07:56:18 -04:00
Greg Johnston
0fc1692337 feat: add no_std support in appropriate crates 2024-07-24 07:56:18 -04:00
Greg Johnston
511db7ec16 feat: tachys 2024-07-24 07:56:18 -04:00
Greg Johnston
28404e7ee4 feat: add Fn traits 2024-07-24 07:56:18 -04:00
Greg Johnston
e1bb490fa0 docs: note re: execution order (see #2261 and #2262) 2024-07-24 07:56:18 -04:00
Greg Johnston
f6b41535cf feat: modular SharedContext for hydration 2024-07-24 07:56:18 -04:00
Greg Johnston
611ee4c74c chore: split OrPoisoned trait into its own crate for reuse 2024-07-24 07:56:18 -04:00
Greg Johnston
a22242cf53 feat: modular, trait-based, Send/Sync reactive system 2024-07-24 07:56:18 -04:00
413 changed files with 20503 additions and 22444 deletions

View File

@@ -1,13 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directories:
- "/"
- "/examples/*"
- "/benchmarks"
schedule:
interval: "daily"

View File

@@ -1,21 +1,23 @@
name: CI Changed Examples
on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main
- leptos_0.6
jobs:
get-example-changed:
uses: ./.github/workflows/get-example-changed.yml
get-matrix:
needs: [get-example-changed]
uses: ./.github/workflows/get-changed-examples-matrix.yml
with:
example_changed: ${{ fromJSON(needs.get-example-changed.outputs.example_changed) }}
test:
name: CI
needs: [get-example-changed, get-matrix]

View File

@@ -1,13 +1,13 @@
name: CI Examples
on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main
- leptos_0.6
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml

View File

@@ -1,25 +1,28 @@
name: CI semver
on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main
- leptos_0.6
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml
test:
needs: [get-leptos-changed]
if: github.event.pull_request.labels[0].name == 'semver' # needs.get-leptos-changed.outputs.leptos_changed == 'true' && github.event.pull_request.labels[0].name != 'breaking'
name: Run semver check (nightly-2024-08-01)
if: needs.get-leptos-changed.outputs.leptos_changed == 'true' && github.event.pull_request.labels[0].name != 'breaking'
name: Run semver check (nightly-2024-04-14)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Semver Checks
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
rust-toolchain: nightly-2024-08-01
rust-toolchain: nightly-2024-04-14

View File

@@ -1,27 +1,52 @@
name: CI
on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main
- leptos_0.6
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml
get-leptos-matrix:
uses: ./.github/workflows/get-leptos-matrix.yml
test:
name: CI
needs: [get-leptos-changed, get-leptos-matrix]
needs: [get-leptos-changed]
if: needs.get-leptos-changed.outputs.leptos_changed == 'true'
strategy:
matrix: ${{ fromJSON(needs.get-leptos-matrix.outputs.matrix) }}
fail-fast: false
matrix:
directory:
[
any_error,
any_spawner,
const_str_slice_concat,
either_of,
hydration_context,
integrations/actix,
integrations/axum,
integrations/utils,
leptos,
leptos_config,
leptos_dom,
leptos_hot_reload,
leptos_macro,
leptos_server,
meta,
next_tuple,
oco,
or_poisoned,
reactive_graph,
router,
router_macro,
server_fn,
server_fn/server_fn_macro_default,
server_fn_macro,
]
uses: ./.github/workflows/run-cargo-make-task.yml
with:
directory: ${{ matrix.directory }}
cargo_make_task: "ci"
toolchain: nightly-2024-08-01
toolchain: nightly-2024-04-14

View File

@@ -26,7 +26,7 @@ jobs:
- name: Get example project directories that changed
id: changed-dirs
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v41
with:
dir_names: true
dir_names_max_depth: "2"

View File

@@ -1,10 +1,12 @@
name: Examples Changed Call
on:
workflow_call:
outputs:
example_changed:
description: "Example Changed"
value: ${{ jobs.get-example-changed.outputs.example_changed }}
jobs:
get-example-changed:
name: Get Example Changed
@@ -16,17 +18,21 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get example files that changed
id: changed-files
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v43
with:
files: |
examples/**
!examples/cargo-make/**
!examples/gtk/**
!examples/Makefile.toml
!examples/*.md
- name: List example files that changed
run: echo '${{ steps.changed-files.outputs.all_changed_files }}'
- name: Set example_changed
id: set-example-changed
run: |

View File

@@ -1,34 +1,38 @@
name: Get Examples Matrix Call
on:
workflow_call:
outputs:
matrix:
description: "Matrix"
value: ${{ jobs.create.outputs.matrix }}
jobs:
create:
name: Create Examples Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env:
# separate examples using "|" (vertical bar) char like "a|b|c".
# cargo-make should be excluded by default.
EXCLUDED_EXAMPLES: cargo-make
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install jq
- name: Set Matrix
id: set-matrix
run: |
examples=$(ls -1d examples/*/ |
grep -vE "($EXCLUDED_EXAMPLES)" |
sed 's/\/$//' |
examples=$(ls examples |
awk '{print "examples/" $0}' |
grep -v .md |
grep -v examples/Makefile.toml |
grep -v examples/cargo-make |
grep -v examples/gtk |
jq -R -s -c 'split("\n")[:-1]')
echo "Example Directories: $examples"
echo "matrix={\"directory\":$examples}" >> "$GITHUB_OUTPUT"
- name: Print Location Info
run: |
echo "Workspace: ${{ github.workspace }}"

View File

@@ -1,10 +1,12 @@
name: Get Leptos Changed Call
on:
workflow_call:
outputs:
leptos_changed:
description: "Leptos Changed"
value: ${{ jobs.create.outputs.leptos_changed }}
jobs:
create:
name: Detect Source Change
@@ -16,19 +18,40 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get source files that changed
id: changed-source
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v43
with:
files_ignore: |
.*/**/*
cargo-make/**/*
examples/**/*
projects/**/*
benchmarks/**/*
docs/**/*
files: |
any_error/**
any_spawner/**
const_str_slice_concat/**
either_of/**
hydration_context/**
integrations/actix/**
integrations/axum/**
integrations/utils/**
leptos/**
leptos_config/**
leptos_dom/**
leptos_hot_reload/**
leptos_macro/**
leptos_server/**
meta/**
next_tuple/**
oco/**
or_poisoned/**
reactive_graph/**
router/**
router_macro/**
server_fn/**
server_fn/server_fn_macro_default/**
server_fn_macro/**
- name: List source files that changed
run: echo '${{ steps.changed-source.outputs.all_changed_files }}'
- name: Set leptos_changed
id: set-source-changed
run: |

View File

@@ -1,32 +0,0 @@
name: Get Leptos Matrix Call
on:
workflow_call:
outputs:
matrix:
description: "Matrix"
value: ${{ jobs.create.outputs.matrix }}
jobs:
create:
name: Create Leptos Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install jq
- name: Set Matrix
id: set-matrix
run: |
crates=$(cargo metadata --no-deps --quiet --format-version 1 |
jq -r '.packages[] | select(.name != "workspace") | .manifest_path| rtrimstr("/Cargo.toml")' |
sed "s|$(pwd)/||" |
jq -R -s -c 'split("\n")[:-1]')
echo "Leptos Directories: $crates"
echo "matrix={\"directory\":$crates}" >> "$GITHUB_OUTPUT"
- name: Print Location Info
run: |
echo "Workspace: ${{ github.workspace }}"
pwd
ls | sort -u

View File

@@ -1,4 +1,5 @@
name: Run Task
on:
workflow_call:
inputs:
@@ -11,53 +12,70 @@ on:
toolchain:
required: true
type: string
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
test:
name: Run ${{ inputs.cargo_make_task }} (${{ inputs.toolchain }})
runs-on: ubuntu-latest
steps:
# Setup environment
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
- name: Add wasm32-unknown-unknown
run: rustup target add wasm32-unknown-unknown
- name: Setup cargo-make
uses: davidB/rust-cargo-make@v1
- name: Cargo generate-lockfile
run: cargo generate-lockfile
- uses: Swatinem/rust-cache@v2
- name: Install binstall
uses: cargo-bins/cargo-binstall@main
- name: Install wasm-bindgen
run: cargo binstall wasm-bindgen-cli --no-confirm
- name: Install cargo-leptos
run: cargo binstall cargo-leptos --no-confirm
- name: Install Trunk
uses: jetli/trunk-action@v0.5.0
with:
version: "latest"
- name: Print Trunk Version
run: trunk --version
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
@@ -65,6 +83,7 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Maybe install chromedriver
run: |
project_makefile=${{inputs.directory}}/Makefile.toml
@@ -80,6 +99,7 @@ jobs:
else
echo chromedriver is not required
fi
- name: Maybe install playwright browser dependencies
run: |
for pw_path in $(find ${{inputs.directory}} -name playwright.config.ts)
@@ -93,16 +113,12 @@ jobs:
echo Playwright is not required
fi
done
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Maybe install gtk-rs dependencies
run: |
if [ ! -z $(echo ${{inputs.directory}} | grep gtk) ]; then
sudo apt-get update
sudo apt-get install -y libglib2.0-dev libgio2.0-cil-dev libgraphene-1.0-dev libcairo2-dev libpango1.0-dev libgtk-4-dev
fi
# Run Cargo Make Task
- name: ${{ inputs.cargo_make_task }}
run: |

View File

@@ -37,39 +37,37 @@ members = [
"router_macro",
"any_error",
]
exclude = ["benchmarks", "examples", "projects"]
exclude = ["benchmarks", "examples"]
[workspace.package]
version = "0.7.0-gamma"
edition = "2021"
rust-version = "1.76"
version = "0.7.0-alpha"
rust-version = "1.75"
[workspace.dependencies]
throw_error = { path = "./any_error/", version = "0.2.0-gamma" }
any_spawner = { path = "./any_spawner/", version = "0.1.0" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1.0" }
either_of = { path = "./either_of/", version = "0.1.0" }
hydration_context = { path = "./hydration_context", version = "0.2.0-gamma" }
leptos = { path = "./leptos", version = "0.7.0-gamma" }
leptos_config = { path = "./leptos_config", version = "0.7.0-gamma" }
leptos_dom = { path = "./leptos_dom", version = "0.7.0-gamma" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-gamma" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-gamma" }
leptos_macro = { path = "./leptos_macro", version = "0.7.0-gamma" }
leptos_router = { path = "./router", version = "0.7.0-gamma" }
leptos_router_macro = { path = "./router_macro", version = "0.7.0-gamma" }
leptos_server = { path = "./leptos_server", version = "0.7.0-gamma" }
leptos_meta = { path = "./meta", version = "0.7.0-gamma" }
next_tuple = { path = "./next_tuple", version = "0.1.0-gamma" }
oco_ref = { path = "./oco", version = "0.2.0" }
or_poisoned = { path = "./or_poisoned", version = "0.1.0" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0-gamma" }
reactive_stores = { path = "./reactive_stores", version = "0.1.0-gamma" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0-gamma" }
server_fn = { path = "./server_fn", version = "0.7.0-gamma" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-gamma" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-gamma" }
tachys = { path = "./tachys", version = "0.1.0-gamma" }
throw_error = { path = "./any_error/", version = "0.1" }
any_spawner = { path = "./any_spawner/", version = "0.1" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
either_of = { path = "./either_of/", version = "0.1" }
hydration_context = { path = "./hydration_context", version = "0.2.0-alpha" }
leptos = { path = "./leptos", version = "0.7.0-alpha" }
leptos_config = { path = "./leptos_config", version = "0.7.0-alpha" }
leptos_dom = { path = "./leptos_dom", version = "0.7.0-alpha" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-alpha" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-alpha" }
leptos_macro = { path = "./leptos_macro", version = "0.7.0-alpha" }
leptos_router = { path = "./router", version = "0.7.0-alpha" }
leptos_server = { path = "./leptos_server", version = "0.7.0-alpha" }
leptos_meta = { path = "./meta", version = "0.7.0-alpha" }
next_tuple = { path = "./next_tuple", version = "0.1.0-alpha" }
oco_ref = { path = "./oco", version = "0.2" }
or_poisoned = { path = "./or_poisoned", version = "0.1" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0-alpha" }
reactive_stores = { path = "./reactive_stores", version = "0.1.0-alpha" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0-alpha" }
server_fn = { path = "./server_fn", version = "0.7.0-alpha" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-alpha" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-alpha" }
tachys = { path = "./tachys", version = "0.1.0-alpha" }
[profile.release]
codegen-units = 1

View File

@@ -12,8 +12,6 @@
You can find a list of useful libraries and example projects at [`awesome-leptos`](https://github.com/leptos-rs/awesome-leptos).
# The `main` branch is currently undergoing major changes in preparation for the [0.7](https://github.com/leptos-rs/leptos/milestone/4) release. For a stable version, please use the [v0.6.13 tag](https://github.com/leptos-rs/leptos/tree/v0.6.13)
# Leptos
```rust

View File

@@ -1,13 +1,13 @@
[package]
name = "throw_error"
version = "0.2.0-gamma"
edition = "2021"
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Utilities for wrapping, throwing, and catching errors."
rust-version.workspace = true
edition.workspace = true
[dependencies]
pin-project-lite = "0.2.14"
pin-project-lite = "0.2"

View File

@@ -9,7 +9,7 @@ use std::{
error,
fmt::{self, Display},
future::Future,
mem, ops,
ops,
pin::Pin,
sync::Arc,
task::{Context, Poll},
@@ -92,25 +92,9 @@ thread_local! {
static ERROR_HOOK: RefCell<Option<Arc<dyn ErrorHook>>> = RefCell::new(None);
}
/// Resets the error hook to its previous state when dropped.
pub struct ResetErrorHookOnDrop(Option<Arc<dyn ErrorHook>>);
impl Drop for ResetErrorHookOnDrop {
fn drop(&mut self) {
ERROR_HOOK.with_borrow_mut(|this| *this = self.0.take())
}
}
/// Returns the current error hook.
pub fn get_error_hook() -> Option<Arc<dyn ErrorHook>> {
ERROR_HOOK.with_borrow(Clone::clone)
}
/// Sets the current thread-local error hook, which will be invoked when [`throw`] is called.
pub fn set_error_hook(hook: Arc<dyn ErrorHook>) -> ResetErrorHookOnDrop {
ResetErrorHookOnDrop(
ERROR_HOOK.with_borrow_mut(|this| mem::replace(this, Some(hook))),
)
pub fn set_error_hook(hook: Arc<dyn ErrorHook>) {
ERROR_HOOK.with_borrow_mut(|this| *this = Some(hook))
}
/// Invokes the error hook set by [`set_error_hook`] with the given error.
@@ -156,10 +140,9 @@ where
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
let _hook = this
.hook
.as_ref()
.map(|hook| set_error_hook(Arc::clone(hook)));
if let Some(hook) = &this.hook {
set_error_hook(Arc::clone(hook))
}
this.inner.poll(cx)
}
}

View File

@@ -1,22 +1,22 @@
[package]
name = "any_spawner"
edition = "2021"
version = "0.1.1"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Spawn asynchronous tasks in an executor-independent way."
edition.workspace = true
[dependencies]
futures = "0.3.30"
glib = { version = "0.20.0", optional = true }
thiserror = "1.0"
tokio = { version = "1.39", optional = true, default-features = false, features = [
"rt",
futures = "0.3"
glib = { version = "0.19", optional = true }
thiserror = "1"
tokio = { version = "1", optional = true, default-features = false, features = [
"rt",
] }
tracing = { version = "0.1.40", optional = true }
wasm-bindgen-futures = { version = "0.4.42", optional = true }
tracing = { version = "0.1", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
[features]
tracing = ["dep:tracing"]
@@ -28,6 +28,3 @@ futures-executor = ["futures/thread-pool", "futures/executor"]
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-all-features]
denylist = ["tracing"]

View File

@@ -2,36 +2,35 @@
name = "benchmarks"
version = "0.1.0"
edition = "2021"
# std::sync::LazyLock is stabilized in Rust version 1.80.0
rust-version = "1.80.0"
rust-version.workspace = true
[dependencies]
l0410 = { package = "leptos", version = "0.4.10", features = [
"nightly",
"ssr",
"nightly",
"ssr",
] }
leptos = { path = "../leptos", features = ["ssr", "nightly"] }
leptos_reactive = { path = "../leptos_reactive", features = ["ssr", "nightly"] }
tachydom = { git = "https://github.com/gbj/tachys", features = [
"nightly",
"leptos",
"nightly",
"leptos",
] }
tachy_maccy = { git = "https://github.com/gbj/tachys", features = ["nightly"] }
sycamore = { version = "0.8.0", features = ["ssr"] }
yew = { version = "0.20.0", features = ["ssr"] }
tokio-test = "0.4.0"
miniserde = "0.1.0"
gloo = "0.8.0"
uuid = { version = "1.0", features = ["serde", "v4", "wasm-bindgen"] }
wasm-bindgen = "0.2.0"
lazy_static = "1.0"
log = "0.4.0"
strum = "0.24.0"
strum_macros = "0.24.0"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
tera = "1.0"
sycamore = { version = "0.8", features = ["ssr"] }
yew = { version = "0.20", features = ["ssr"] }
tokio-test = "0.4"
miniserde = "0.1"
gloo = "0.8"
uuid = { version = "1", features = ["serde", "v4", "wasm-bindgen"] }
wasm-bindgen = "0.2"
lazy_static = "1"
log = "0.4"
strum = "0.24"
strum_macros = "0.24"
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
tera = "1"
[dependencies.web-sys]
version = "0.3.0"
version = "0.3"
features = ["Window", "Document", "HtmlElement", "HtmlInputElement"]

View File

@@ -18,7 +18,7 @@ fn leptos_ssr_bench(b: &mut Bencher) {
}
}
let rendered = view! {
let rendered = view! {
<main>
<h1>"Welcome to our benchmark page."</h1>
<p>"Here's some introductory text."</p>
@@ -58,7 +58,7 @@ fn tachys_ssr_bench(b: &mut Bencher) {
}
}
let rendered = view! {
let rendered = view! {
<main>
<h1>"Welcome to our benchmark page."</h1>
<p>"Here's some introductory text."</p>
@@ -92,13 +92,13 @@ fn tera_ssr_bench(b: &mut Bencher) {
{% endfor %}
</main>"#;
static LazyCell<TERA>: Tera = LazyLock::new(|| {
let mut tera = Tera::default();
tera.add_raw_templates(vec![("template.html", TEMPLATE)]).unwrap();
tera
});
lazy_static::lazy_static! {
static ref TERA: Tera = {
let mut tera = Tera::default();
tera.add_raw_templates(vec![("template.html", TEMPLATE)]).unwrap();
tera
};
}
#[derive(Serialize, Deserialize)]
struct Counter {

View File

@@ -55,7 +55,7 @@ static TEMPLATE: &str = r#"<main>
{% else %}
<li><a href="/">All</a></li>
{% endif %}
{% if mode_active %}
<li><a href="/active" class="selected">Active</a></li>
{% else %}
@@ -91,13 +91,13 @@ fn tera_todomvc_ssr(b: &mut Bencher) {
use serde::{Deserialize, Serialize};
use tera::*;
static LazyLock<TERA>: Tera = LazyLock( || {
lazy_static::lazy_static! {
static ref TERA: Tera = {
let mut tera = Tera::default();
tera.add_raw_templates(vec![("template.html", TEMPLATE)]).unwrap();
tera
});
};
}
#[derive(Serialize, Deserialize)]
struct Todo {
@@ -131,13 +131,13 @@ fn tera_todomvc_ssr_1000(b: &mut Bencher) {
use serde::{Deserialize, Serialize};
use tera::*;
static TERA: LazyLock<Tera> = LazyLock::new(|| {
let mut tera = Tera::default();
tera.add_raw_templates(vec![("template.html", TEMPLATE)]).unwrap();
tera
});
lazy_static::lazy_static! {
static ref TERA: Tera = {
let mut tera = Tera::default();
tera.add_raw_templates(vec![("template.html", TEMPLATE)]).unwrap();
tera
};
}
#[derive(Serialize, Deserialize)]
struct Todo {

View File

@@ -1,5 +1,6 @@
[package]
name = "const_str_slice_concat"
edition = "2021"
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
@@ -7,6 +8,5 @@ readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Utilities for const concatenation of string slices."
rust-version.workspace = true
edition.workspace = true
[dependencies]

View File

@@ -1,5 +1,6 @@
[package]
name = "either_of"
edition = "2021"
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
@@ -7,7 +8,6 @@ readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Utilities for working with enumerated types that contain one of 2..n other types."
rust-version.workspace = true
edition.workspace = true
[dependencies]
pin-project-lite = "0.2.14"
pin-project-lite = "0.2"

View File

@@ -133,104 +133,3 @@ tuples!(EitherOf13 + EitherOf13Future + EitherOf13FutureProj => A, B, C, D, E, F
tuples!(EitherOf14 + EitherOf14Future + EitherOf14FutureProj => A, B, C, D, E, F, G, H, I, J, K, L, M, N);
tuples!(EitherOf15 + EitherOf15Future + EitherOf15FutureProj => A, B, C, D, E, F, G, H, I, J, K, L, M, N, O);
tuples!(EitherOf16 + EitherOf16Future + EitherOf16FutureProj => A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P);
/// Matches over the first expression and returns an either ([`Either`], [`EitherOf3`], ... [`EitherOf6`])
/// composed of the values returned by the match arms.
///
/// The pattern syntax is exactly the same as found in a match arm.
///
/// # Examples
///
/// ```
/// # use either_of::*;
/// let either2 = either!(Some("hello"),
/// Some(s) => s.len(),
/// None => 0.0,
/// );
/// assert!(matches!(either2, Either::<usize, f64>::Left(5)));
///
/// let either3 = either!(Some("admin"),
/// Some("admin") => "hello admin",
/// Some(_) => 'x',
/// _ => 0,
/// );
/// assert!(matches!(either3, EitherOf3::<&str, char, i32>::A("hello admin")));
/// ```
#[macro_export]
macro_rules! either {
($match:expr, $left_pattern:pat => $left_expression:expr, $right_pattern:pat => $right_expression:expr,) => {
match $match {
$left_pattern => $crate::Either::Left($left_expression),
$right_pattern => $crate::Either::Right($right_expression),
}
};
($match:expr, $a_pattern:pat => $a_expression:expr, $b_pattern:pat => $b_expression:expr, $c_pattern:pat => $c_expression:expr,) => {
match $match {
$a_pattern => $crate::EitherOf3::A($a_expression),
$b_pattern => $crate::EitherOf3::B($b_expression),
$c_pattern => $crate::EitherOf3::C($c_expression),
}
};
($match:expr, $a_pattern:pat => $a_expression:expr, $b_pattern:pat => $b_expression:expr, $c_pattern:pat => $c_expression:expr, $d_pattern:pat => $d_expression:expr,) => {
match $match {
$a_pattern => $crate::EitherOf4::A($a_expression),
$b_pattern => $crate::EitherOf4::B($b_expression),
$c_pattern => $crate::EitherOf4::C($c_expression),
$d_pattern => $crate::EitherOf4::D($d_expression),
}
};
($match:expr, $a_pattern:pat => $a_expression:expr, $b_pattern:pat => $b_expression:expr, $c_pattern:pat => $c_expression:expr, $d_pattern:pat => $d_expression:expr, $e_pattern:pat => $e_expression:expr,) => {
match $match {
$a_pattern => $crate::EitherOf5::A($a_expression),
$b_pattern => $crate::EitherOf5::B($b_expression),
$c_pattern => $crate::EitherOf5::C($c_expression),
$d_pattern => $crate::EitherOf5::D($d_expression),
$e_pattern => $crate::EitherOf5::E($e_expression),
}
};
($match:expr, $a_pattern:pat => $a_expression:expr, $b_pattern:pat => $b_expression:expr, $c_pattern:pat => $c_expression:expr, $d_pattern:pat => $d_expression:expr, $e_pattern:pat => $e_expression:expr, $f_pattern:pat => $f_expression:expr,) => {
match $match {
$a_pattern => $crate::EitherOf6::A($a_expression),
$b_pattern => $crate::EitherOf6::B($b_expression),
$c_pattern => $crate::EitherOf6::C($c_expression),
$d_pattern => $crate::EitherOf6::D($d_expression),
$e_pattern => $crate::EitherOf6::E($e_expression),
$f_pattern => $crate::EitherOf6::F($f_expression),
}
}; // if you need more eithers feel free to open a PR ;-)
}
// compile time test
#[test]
fn either_macro() {
let _: Either<&str, f64> = either!(12,
12 => "12",
_ => 0.0,
);
let _: EitherOf3<&str, f64, i32> = either!(12,
12 => "12",
13 => 0.0,
_ => 12,
);
let _: EitherOf4<&str, f64, char, i32> = either!(12,
12 => "12",
13 => 0.0,
14 => ' ',
_ => 12,
);
let _: EitherOf5<&str, f64, char, f32, i32> = either!(12,
12 => "12",
13 => 0.0,
14 => ' ',
15 => 0.0f32,
_ => 12,
);
let _: EitherOf6<&str, f64, char, f32, u8, i32> = either!(12,
12 => "12",
13 => 0.0,
14 => ' ',
15 => 0.0f32,
16 => 24u8,
_ => 12,
);
}

View File

@@ -7,18 +7,19 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[dependencies]
actix-files = { version = "0.6.6", optional = true }
actix-web = { version = "4.8", optional = true, features = ["macros"] }
console_error_panic_hook = "0.1.7"
cfg-if = "1.0"
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4", optional = true, features = ["macros"] }
console_error_panic_hook = "0.1"
cfg-if = "1"
leptos = { path = "../../leptos" }
leptos_meta = { path = "../../meta" }
leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router" }
wasm-bindgen = "0.2.93"
serde = { version = "1.0", features = ["derive"] }
wasm-bindgen = "0.2"
serde = { version = "1", features = ["derive"] }
[features]
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:actix-files",

View File

@@ -1,9 +1,68 @@
# Action Form Error Handling Example
<picture>
<source srcset="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_Solid_White.svg" media="(prefers-color-scheme: dark)">
<img src="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_RGB.svg" alt="Leptos Logo">
</picture>
## Getting Started
# Leptos Starter Template
See the [Examples README](../README.md) for setup and run instructions.
This is a template for use with the [Leptos](https://github.com/leptos-rs/leptos) web framework and the [cargo-leptos](https://github.com/akesson/cargo-leptos) tool.
## Quick Start
## Creating your template repo
Execute `cargo leptos watch` to run this example.
If you don't have `cargo-leptos` installed you can install it with
`cargo install cargo-leptos`
Then run
`cargo leptos new --git leptos-rs/start`
to generate a new project template (you will be prompted to enter a project name).
`cd {projectname}`
to go to your newly created project.
Of course, you should explore around the project structure, but the best place to start with your application code is in `src/app.rs`.
## Running your project
`cargo leptos watch`
By default, you can access your local project at `http://localhost:3000`
## Installing Additional Tools
By default, `cargo-leptos` uses `nightly` Rust, `cargo-generate`, and `sass`. If you run into any trouble, you may need to install one or more of these tools.
1. `rustup toolchain install nightly --allow-downgrade` - make sure you have Rust nightly
2. `rustup target add wasm32-unknown-unknown` - add the ability to compile Rust to WebAssembly
3. `cargo install cargo-generate` - install `cargo-generate` binary (should be installed automatically in future)
4. `npm install -g sass` - install `dart-sass` (should be optional in future)
## Executing a Server on a Remote Machine Without the Toolchain
After running a `cargo leptos build --release` the minimum files needed are:
1. The server binary located in `target/server/release`
2. The `site` directory and all files within located in `target/site`
Copy these files to your remote server. The directory structure should be:
```text
leptos_start
site/
```
Set the following environment variables (updating for your project as needed):
```sh
export LEPTOS_OUTPUT_NAME="leptos_start"
export LEPTOS_SITE_ROOT="site"
export LEPTOS_SITE_PKG_DIR="pkg"
export LEPTOS_SITE_ADDR="127.0.0.1:3000"
export LEPTOS_RELOAD_PORT="3001"
```
Finally, run the server binary.
## Notes about CSR and Trunk:
Although it is not recommended, you can also run your project without server integration using the feature `csr` and `trunk serve`:
`trunk serve --open --features csr`
This may be useful for integrating external tools which require a static site, e.g. `tauri`.

View File

@@ -52,10 +52,23 @@ async fn main() -> std::io::Result<()> {
.await
}
#[cfg(not(feature = "ssr"))]
#[cfg(not(any(feature = "ssr", feature = "csr")))]
pub fn main() {
// no client-side main function
// unless we want this to work with e.g., Trunk for pure client-side testing
// see lib.rs for hydration function instead
// see optional feature `csr` instead
}
#[cfg(all(not(feature = "ssr"), feature = "csr"))]
pub fn main() {
// a client-side main function is required for using `trunk serve`
// prefer using `cargo leptos serve` instead
// to run: `trunk serve --open --features csr`
use action_form_error_handling::app::*;
use leptos::prelude::*;
console_error_panic_hook::set_once();
mount_to_body(App);
}

View File

@@ -1,111 +0,0 @@
[package]
name = "axum_js_ssr"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7.5", optional = true }
console_error_panic_hook = "0.1.7"
console_log = "1.0"
gloo-utils = "0.2.0"
html-escape = "0.2.13"
http-body-util = { version = "0.1.0", optional = true }
js-sys = { version = "0.3.69", optional = true }
leptos = { path = "../../leptos", features = ["tracing"] }
leptos_meta = { path = "../../meta" }
leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_router = { path = "../../router" }
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
tokio = { version = "1.39", features = [ "rt-multi-thread", "macros", "time" ], optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
wasm-bindgen = "0.2.92"
web-sys = { version = "0.3.69", features = [ "AddEventListenerOptions", "Document", "Element", "Event", "EventListener", "EventTarget", "Performance", "Window" ], optional = true }
[features]
hydrate = [
"leptos/hydrate",
"dep:js-sys",
"dep:web-sys",
]
ssr = [
"dep:axum",
"dep:http-body-util",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"leptos_meta/ssr",
"dep:leptos_axum",
"leptos_router/ssr",
]
[profile.release]
panic = "abort"
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"
[package.metadata.cargo-all-features]
denylist = ["axum", "tower", "tower-http", "tokio", "sqlx", "leptos_axum"]
skip_feature_sets = [["ssr", "hydrate"]]
[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "axum_js_ssr"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
site-pkg-dir = "pkg"
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/main.scss"
# Assets source dir. All files found here will be copied and synchronized to site-root.
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
#
# Optional. Env: LEPTOS_ASSETS_DIR.
assets-dir = "assets"
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"
# The port to use for automatic reload monitoring
reload-port = 3001
# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
# [Windows] for non-WSL use "npx.cmd playwright test"
# This binary name can be checked in Powershell with Get-Command npx
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"
# The browserlist query used for optimizing the CSS.
browserquery = "defaults"
# Set by cargo-leptos watch when building with that tool. Controls whether autoreload JS will be included in the head
watch = false
# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"
# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]
# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false
# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = ["hydrate"]
# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false
lib-profile-release = "wasm-release"

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 Tommy Yu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,8 +0,0 @@
extend = [
{ path = "../cargo-make/main.toml" },
{ path = "../cargo-make/cargo-leptos.toml" },
]
[env]
CLIENT_PROCESS_NAME = "axum_js_ssr"

View File

@@ -1,10 +0,0 @@
# Leptos Axum JS SSR Example
This example shows the various ways that JavaScript may be included into
a Leptos application. The intent is to demonstrate how this may be done
and how it may cause the application to fail in an unexpected manner if
done incorrectly.
## Quick Start
Run `cargo leptos watch` to run this example.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2006, Ivan Sagalaev.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,47 +0,0 @@
# Highlight.js CDN Assets
**Note: this contains only a subset of files from the full package from NPM.**
[![install size](https://packagephobia.now.sh/badge?p=highlight.js)](https://packagephobia.now.sh/result?p=highlight.js)
**This package contains only the CDN build assets of highlight.js.**
This may be what you want if you'd like to install the pre-built distributable highlight.js client-side assets via NPM. If you're wanting to use highlight.js mainly on the server-side you likely want the [highlight.js][1] package instead.
To access these files via CDN:<br>
https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/
**If you just want a single .js file with the common languages built-in:
<https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/highlight.min.js>**
---
## Highlight.js
Highlight.js is a syntax highlighter written in JavaScript. It works in
the browser as well as on the server. It works with pretty much any
markup, doesnt depend on any framework, and has automatic language
detection.
If you'd like to read the full README:<br>
<https://github.com/highlightjs/highlight.js/blob/main/README.md>
## License
Highlight.js is released under the BSD License. See [LICENSE][7] file
for details.
## Links
The official site for the library is at <https://highlightjs.org/>.
The Github project may be found at: <https://github.com/highlightjs/highlight.js>
Further in-depth documentation for the API and other topics is at
<http://highlightjs.readthedocs.io/>.
A list of the Core Team and contributors can be found in the [CONTRIBUTORS.md][8] file.
[1]: https://www.npmjs.com/package/highlight.js
[7]: https://github.com/highlightjs/highlight.js/blob/main/LICENSE
[8]: https://github.com/highlightjs/highlight.js/blob/main/CONTRIBUTORS.md

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,93 +0,0 @@
{
"name": "@highlightjs/cdn-assets",
"description": "Syntax highlighting with language autodetection. (pre-compiled CDN assets)",
"keywords": [
"highlight",
"syntax"
],
"homepage": "https://highlightjs.org/",
"version": "11.10.0",
"author": "Josh Goebel <hello@joshgoebel.com>",
"contributors": [
"Josh Goebel <hello@joshgoebel.com>",
"Egor Rogov <e.rogov@postgrespro.ru>",
"Vladimir Jimenez <me@allejo.io>",
"Ivan Sagalaev <maniac@softwaremaniacs.org>",
"Jeremy Hull <sourdrums@gmail.com>",
"Oleg Efimov <efimovov@gmail.com>",
"Gidi Meir Morris <gidi@gidi.io>",
"Jan T. Sott <git@idleberg.com>",
"Li Xuanji <xuanji@gmail.com>",
"Marcos Cáceres <marcos@marcosc.com>",
"Sang Dang <sang.dang@polku.io>"
],
"bugs": {
"url": "https://github.com/highlightjs/highlight.js/issues"
},
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "git://github.com/highlightjs/highlight.js.git"
},
"sideEffects": [
"./es/common.js",
"./lib/common.js",
"*.css",
"*.scss"
],
"scripts": {
"mocha": "mocha",
"lint": "eslint src/*.js src/lib/*.js demo/*.js tools/**/*.js --ignore-pattern vendor",
"lint-languages": "eslint --no-eslintrc -c .eslintrc.lang.js src/languages/**/*.js",
"build_and_test": "npm run build && npm run test",
"build_and_test_browser": "npm run build-browser && npm run test-browser",
"build": "node ./tools/build.js -t node",
"build-cdn": "node ./tools/build.js -t cdn",
"build-browser": "node ./tools/build.js -t browser :common",
"devtool": "npx http-server",
"test": "mocha test",
"test-markup": "mocha test/markup",
"test-detect": "mocha test/detect",
"test-browser": "mocha test/browser",
"test-parser": "mocha test/parser"
},
"engines": {
"node": ">=12.0.0"
},
"devDependencies": {
"@colors/colors": "^1.6.0",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/mocha": "^10.0.2",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"clean-css": "^5.3.2",
"cli-table": "^0.3.1",
"commander": "^12.1.0",
"css": "^3.0.0",
"css-color-names": "^1.0.1",
"deep-freeze-es6": "^3.0.2",
"del": "^7.1.0",
"dependency-resolver": "^2.0.1",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"glob": "^8.1.0",
"glob-promise": "^6.0.5",
"handlebars": "^4.7.8",
"http-server": "^14.1.1",
"jsdom": "^24.1.0",
"lodash": "^4.17.20",
"mocha": "^10.2.0",
"refa": "^0.4.1",
"rollup": "^4.0.2",
"should": "^13.2.3",
"terser": "^5.21.0",
"tiny-worker": "^2.3.0",
"typescript": "^5.2.2",
"wcag-contrast": "^3.0.0"
}
}

View File

@@ -1,10 +0,0 @@
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
Theme: GitHub Dark
Description: Dark theme as seen on github.com
Author: github.com
Maintainer: @Hirse
Updated: 2021-05-15
Outdated base version: https://github.com/primer/github-syntax-dark
Current colors taken from GitHub's CSS
*/.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}

View File

@@ -1,10 +0,0 @@
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
Theme: GitHub
Description: Light theme as seen on github.com
Author: github.com
Maintainer: @Hirse
Updated: 2021-05-15
Outdated base version: https://github.com/primer/github-syntax-light
Current colors taken from GitHub's CSS
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}

View File

@@ -1,6 +0,0 @@
{
"name": "axum_js_ssr",
"dependencies": {
"@highlightjs/cdn-assets": "^11.10.0"
}
}

View File

@@ -1,2 +0,0 @@
[toolchain]
channel = "stable" # test change

View File

@@ -1,8 +0,0 @@
use leptos::{prelude::ServerFnError, server};
#[server]
pub async fn fetch_code() -> Result<String, ServerFnError> {
// emulate loading of code from a database/version control/etc
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
Ok(crate::consts::CH05_02A.to_string())
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,39 +0,0 @@
// Example programs from the Rust Programming Language Book
pub const CH03_05A: &str = r#"fn main() {
let number = 3;
if number < 5 {
println!("condition was true");
} else {
println!("condition was false");
}
}
"#;
// For some reason, swapping the code examples "fixes" example 6. It
// might have something to do with the lower complexity of highlighting
// a shorter example. Anyway, including extra newlines for the shorter
// example to match with the longer in order to avoid reflowing the
// table during the async resource loading for CSR.
pub const CH05_02A: &str = r#"fn main() {
let width1 = 30;
let height1 = 50;
println!(
"The area of the rectangle is {} square pixels.",
area(width1, height1)
);
}
fn area(width: u32, height: u32) -> u32 {
width * height
}
"#;
pub const LEPTOS_HYDRATED: &str = "_leptos_hydrated";

View File

@@ -1,59 +0,0 @@
#[cfg(not(feature = "ssr"))]
mod csr {
use gloo_utils::format::JsValueSerdeExt;
use js_sys::{
Object,
Reflect::{get, set},
};
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};
#[wasm_bindgen(
module = "/node_modules/@highlightjs/cdn-assets/es/highlight.min.js"
)]
extern "C" {
type HighlightOptions;
#[wasm_bindgen(catch, js_namespace = default, js_name = highlight)]
fn highlight_lang(
code: String,
options: Object,
) -> Result<Object, JsValue>;
#[wasm_bindgen(js_namespace = default, js_name = highlightAll)]
pub fn highlight_all();
}
// Keeping the `ignoreIllegals` argument out of the default case, and since there is no optional arguments
// in Rust, this will have to be provided in a separate function (e.g. `highlight_ignore_illegals`), much
// like how `web_sys` does it for the browser APIs. For simplicity, only the highlighted HTML code is
// returned on success, and None on error.
pub fn highlight(code: String, lang: String) -> Option<String> {
let options = js_sys::Object::new();
set(&options, &"language".into(), &lang.into())
.expect("failed to assign lang to options");
highlight_lang(code, options)
.map(|result| {
let value = get(&result, &"value".into())
.expect("HighlightResult failed to contain the value key");
value.into_serde().expect("Value should have been a string")
})
.ok()
}
}
#[cfg(feature = "ssr")]
mod ssr {
// noop under ssr
pub fn highlight_all() {}
// TODO see if there is a Rust-based solution that will enable isomorphic rendering for this feature.
// the current (disabled) implementation simply calls html_escape.
// pub fn highlight(code: String, _lang: String) -> Option<String> {
// Some(html_escape::encode_text(&code).into_owned())
// }
}
#[cfg(not(feature = "ssr"))]
pub use csr::*;
#[cfg(feature = "ssr")]
pub use ssr::*;

View File

@@ -1,51 +0,0 @@
pub mod api;
pub mod app;
pub mod consts;
pub mod hljs;
#[cfg(feature = "hydrate")]
#[wasm_bindgen::prelude::wasm_bindgen]
pub fn hydrate() {
use app::*;
use consts::LEPTOS_HYDRATED;
use std::panic;
panic::set_hook(Box::new(|info| {
// this custom hook will call out to show the usual error log at
// the console while also attempt to update the UI to indicate
// a restart of the application is required to continue.
console_error_panic_hook::hook(info);
let window = leptos::prelude::window();
if !matches!(
js_sys::Reflect::get(&window, &wasm_bindgen::JsValue::from_str(LEPTOS_HYDRATED)),
Ok(t) if t == true
) {
let document = leptos::prelude::document();
let _ = document.query_selector("#reset").map(|el| {
el.map(|el| {
el.set_class_name("panicked");
})
});
let _ = document.query_selector("#notice").map(|el| {
el.map(|el| {
el.set_class_name("panicked");
})
});
}
}));
leptos::mount::hydrate_body(App);
let window = leptos::prelude::window();
js_sys::Reflect::set(
&window,
&wasm_bindgen::JsValue::from_str(LEPTOS_HYDRATED),
&wasm_bindgen::JsValue::TRUE,
)
.expect("error setting hydrated status");
let event = web_sys::Event::new(LEPTOS_HYDRATED)
.expect("error creating hydrated event");
let document = leptos::prelude::document();
document
.dispatch_event(&event)
.expect("error dispatching hydrated event");
leptos::logging::log!("dispatched hydrated event");
}

View File

@@ -1,152 +0,0 @@
#[cfg(feature = "ssr")]
mod latency {
use std::sync::{Mutex, OnceLock};
pub static LATENCY: OnceLock<
Mutex<std::iter::Cycle<std::slice::Iter<'_, u64>>>,
> = OnceLock::new();
pub static ES_LATENCY: OnceLock<
Mutex<std::iter::Cycle<std::slice::Iter<'_, u64>>>,
> = OnceLock::new();
}
#[cfg(feature = "ssr")]
#[tokio::main]
async fn main() {
use axum::{
body::Body,
extract::Request,
http::{
header::{self, HeaderValue},
StatusCode,
},
middleware::{self, Next},
response::{IntoResponse, Response},
routing::get,
Router,
};
use axum_js_ssr::app::*;
use http_body_util::BodyExt;
use leptos::prelude::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
latency::LATENCY.get_or_init(|| [0, 4, 40, 400].iter().cycle().into());
latency::ES_LATENCY.get_or_init(|| [0].iter().cycle().into());
// Having the ES_LATENCY (a cycle of latency for the loading of the es
// module) in an identical cycle as LATENCY (for the standard version)
// adversely influences the intended demo, as this ultimately delays
// hydration when set too high which can cause panic under every case.
// If you want to test the effects of the delay just modify the list of
// values for the desired cycle of delays.
let conf = get_configuration(None).unwrap();
let addr = conf.leptos_options.site_addr;
let leptos_options = conf.leptos_options;
// Generate the list of routes in your Leptos App
let routes = generate_route_list(App);
async fn highlight_js() -> impl IntoResponse {
(
[(header::CONTENT_TYPE, "text/javascript")],
include_str!(
"../node_modules/@highlightjs/cdn-assets/highlight.min.js"
),
)
}
async fn latency_for_highlight_js(
req: Request,
next: Next,
) -> Result<impl IntoResponse, (StatusCode, String)> {
let uri_parts = &mut req.uri().path().rsplit('/');
let is_highlightjs = uri_parts.next() == Some("highlight.min.js");
let es = uri_parts.next() == Some("es");
let module_type = if es { "es module " } else { "standard " };
let res = next.run(req).await;
if is_highlightjs {
// additional processing if the filename is the test subject
let (mut parts, body) = res.into_parts();
let bytes = body
.collect()
.await
.map_err(|err| {
(
StatusCode::BAD_REQUEST,
format!("error reading body: {err}"),
)
})?
.to_bytes();
let latency = if es {
&latency::ES_LATENCY
} else {
&latency::LATENCY
};
let delay = match latency
.get()
.expect("latency cycle wasn't set up")
.try_lock()
{
Ok(ref mut mutex) => {
*mutex.next().expect("cycle always has next")
}
Err(_) => 0,
};
// inject the logging of the delay used into the target script
log!(
"loading {module_type}highlight.min.js with latency of \
{delay} ms"
);
let js_log = format!(
"\nconsole.log('loaded {module_type}highlight.js with a \
minimum latency of {delay} ms');"
);
tokio::time::sleep(std::time::Duration::from_millis(delay)).await;
let bytes = [bytes, js_log.into()].concat();
let length = bytes.len();
let body = Body::from(bytes);
// Provide the bare minimum set of headers to avoid browser cache.
parts.headers = header::HeaderMap::from_iter(
[
(
header::CONTENT_TYPE,
HeaderValue::from_static("text/javascript"),
),
(header::CONTENT_LENGTH, HeaderValue::from(length)),
]
.into_iter(),
);
Ok(Response::from_parts(parts, body))
} else {
Ok(res)
}
}
let app = Router::new()
.route("/highlight.min.js", get(highlight_js))
.leptos_routes(&leptos_options, routes, {
let leptos_options = leptos_options.clone();
move || shell(leptos_options.clone())
})
.fallback(leptos_axum::file_and_error_handler(shell))
.layer(middleware::from_fn(latency_for_highlight_js))
.with_state(leptos_options);
// run our app with hyper
// `axum::Server` is a re-export of `hyper::Server`
log!("listening on http://{}", &addr);
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
#[cfg(not(feature = "ssr"))]
pub fn main() {
// no client-side main function
// unless we want this to work with e.g., Trunk for pure client-side testing
// see lib.rs for hydration function instead
}

View File

@@ -1,171 +0,0 @@
html, body {
margin: 0;
padding: 0;
font-family: sans-serif;
height: 100vh;
overflow: hidden;
}
body {
display: flex;
flex-flow: row nowrap;
}
nav {
min-width: 17em;
height: 100vh;
counter-reset: example-counter 0;
list-style-type: none;
list-style-position: outside;
overflow: auto;
}
nav a {
display: block;
padding: 0.5em 2em;
text-decoration: none;
}
nav a small {
display: block;
}
nav a.example::before {
counter-reset: subexample-counter 0;
counter-increment: example-counter 1;
content: counter(example-counter) ". ";
}
nav a.subexample::before {
counter-increment: subexample-counter 1;
content: counter(example-counter) "." counter(subexample-counter) " ";
}
div#notice {
display: none;
}
main div#notice.panicked {
position: sticky;
top: 0;
padding: 0.5em 2em;
display: block;
}
main {
width: 100%;
overflow: auto;
}
main article {
max-width: 60em;
margin: 0 1em;
padding: 0 1em;
}
main p, main li {
line-height: 1.3em;
}
main li pre code, main div pre code {
display: block;
line-height: normal;
}
main ol, main ul {
padding-left: 2em;
}
h2>code, p>code, li>code {
border-radius: 3px;
padding: 2px;
}
li pre code, div pre code {
margin: 0 !important;
padding: 0 !important;
}
#code-demo {
overflow-x: auto;
}
#code-demo table {
width: 50em;
margin: auto;
}
#code-demo table td {
vertical-align: top;
}
#code-demo table code {
display: block;
padding: 1em;
}
@media (prefers-color-scheme: light) {
nav {
background: #f7f7f7;
}
nav a {
color: #000;
}
nav a[aria-current="page"] {
background-color: #e0e0e0;
}
nav a:hover, h2>code, p>code, li>code {
background-color: #e7e7e7;
}
nav a.panicked, main div#notice.panicked {
background: #fdd;
}
main div#notice.panicked a {
color: #000;
}
nav a.section {
border-bottom: 1px solid #777;
}
}
@media (prefers-color-scheme: dark) {
nav {
background: #080808;
}
nav a {
color: #fff;
}
nav a[aria-current="page"] {
background-color: #3f3f3f;
}
nav a:hover, h2>code, p>code, li>code {
background-color: #383838;
}
nav a.panicked, main div#notice.panicked {
background: #733;
}
main div#notice.panicked a {
color: #fff;
}
nav a.section {
border-bottom: 1px solid #888;
}
}
// Just include the raw style as-is because I can't find a quick and easy way to import them just for the
// appropriate media type...
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}
@media (prefers-color-scheme: light){.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}}
@media (prefers-color-scheme: dark){.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}}

View File

@@ -10,12 +10,12 @@ lto = true
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
console_log = "1.0"
log = "0.4.22"
console_log = "1"
log = "0.4"
console_error_panic_hook = "0.1.7"
gloo-timers = { version = "0.3.0", features = ["futures"] }
[dev-dependencies]
wasm-bindgen = "0.2.93"
wasm-bindgen-test = "0.3.42"
web-sys = "0.3.70"
wasm-bindgen = "0.2"
wasm-bindgen-test = "0.3.0"
web-sys = "0.3"

View File

@@ -2,8 +2,6 @@
name = "counter_isomorphic"
version = "0.1.0"
edition = "2021"
# std::sync::LazyLock is stabilized in Rust version 1.80.0
rust-version = "1.80.0"
[lib]
crate-type = ["cdylib", "rlib"]
@@ -13,33 +11,34 @@ codegen-units = 1
lto = true
[dependencies]
actix-files = { version = "0.6.6", optional = true }
actix-web = { version = "4.8", optional = true, features = ["macros"] }
broadcaster = "1.0"
console_log = "1.0"
console_error_panic_hook = "0.1.7"
futures = "0.3.30"
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4", optional = true, features = ["macros"] }
broadcaster = "1"
console_log = "1"
console_error_panic_hook = "0.1"
futures = "0.3"
lazy_static = "1"
leptos = { path = "../../leptos" }
leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router" }
log = "0.4.22"
once_cell = "1.19"
gloo-net = { version = "0.6.0" }
wasm-bindgen = "0.2.93"
serde = { version = "1.0", features = ["derive"] }
simple_logger = "5.0"
tracing = { version = "0.1.40", optional = true }
log = "0.4"
once_cell = "1.18"
gloo-net = { git = "https://github.com/rustwasm/gloo" }
wasm-bindgen = "0.2"
serde = { version = "1", features = ["derive"] }
simple_logger = "4.3"
tracing = { version = "0.1", optional = true }
send_wrapper = "0.6.0"
[features]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:actix-files",
"dep:actix-web",
"dep:tracing",
"leptos/ssr",
"leptos_actix",
"leptos_router/ssr",
"dep:actix-files",
"dep:actix-web",
"dep:tracing",
"leptos/ssr",
"leptos_actix",
"leptos_router/ssr",
]
[package.metadata.cargo-all-features]
@@ -47,13 +46,13 @@ denylist = ["actix-files", "actix-web", "leptos_actix"]
skip_feature_sets = [["ssr", "hydrate"]]
[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "counter_isomorphic"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
# When NOT using cargo-leptos this must be updated to "." or the counters will not work. The above warning still applies if you do switch to cargo-leptos later.
site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
# Defaults to pkg
site-pkg-dir = "pkg"
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
# style-file = "src/styles/tailwind.css"

View File

@@ -10,12 +10,12 @@ use tracing::instrument;
pub mod ssr_imports {
pub use broadcaster::BroadcastChannel;
pub use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::LazyLock;
pub static COUNT: AtomicI32 = AtomicI32::new(0);
pub static COUNT_CHANNEL: LazyLock<BroadcastChannel<i32>> =
LazyLock::new(BroadcastChannel::<i32>::new);
lazy_static::lazy_static! {
pub static ref COUNT_CHANNEL: BroadcastChannel<i32> = BroadcastChannel::new();
}
}
#[server]
@@ -113,10 +113,10 @@ pub fn Counter() -> impl IntoView {
</p>
<ErrorBoundary fallback=|errors| move || format!("Error: {:#?}", errors.get())>
<div>
<button on:click=move |_| { clear.dispatch(()); }>"Clear"</button>
<button on:click=move |_| { dec.dispatch(()); }>"-1"</button>
<button on:click=move |_| clear.dispatch(())>"Clear"</button>
<button on:click=move |_| dec.dispatch(())>"-1"</button>
<span>"Value: " <Suspense>{counter} "!"</Suspense></span>
<button on:click=move |_| { inc.dispatch(()); }>"+1"</button>
<button on:click=move |_| inc.dispatch(())>"+1"</button>
</div>
</ErrorBoundary>
</div>
@@ -224,12 +224,12 @@ pub fn MultiuserCounter() -> impl IntoView {
"This one uses server-sent events (SSE) to live-update when other users make changes."
</p>
<div>
<button on:click=move |_| { clear.dispatch(()); }>"Clear"</button>
<button on:click=move |_| { dec.dispatch(()); }>"-1"</button>
<button on:click=move |_| clear.dispatch(())>"Clear"</button>
<button on:click=move |_| dec.dispatch(())>"-1"</button>
<span>
"Multiplayer Value: " {move || multiplayer_value.get().unwrap_or_default()}
</span>
<button on:click=move |_| { inc.dispatch(()); }>"+1"</button>
<button on:click=move |_| inc.dispatch(())>"+1"</button>
</div>
</div>
}

View File

@@ -13,6 +13,6 @@ leptos_router = { path = "../../router", features = [] }
console_error_panic_hook = "0.1.7"
[dev-dependencies]
wasm-bindgen = "0.2.93"
wasm-bindgen-test = "0.3.42"
web-sys = "0.3.70"
wasm-bindgen = "0.2"
wasm-bindgen-test = "0.3.0"
web-sys = "0.3"

View File

@@ -14,10 +14,10 @@ console_error_panic_hook = "0.1.7"
[dev-dependencies]
wasm-bindgen = "0.2"
wasm-bindgen-test = "0.3.42"
pretty_assertions = "1.4"
rstest = "0.22.0"
wasm-bindgen-test = "0.3.34"
pretty_assertions = "1.3.0"
rstest = "0.17.0"
[dev-dependencies.web-sys]
features = ["HtmlElement", "XPathResult"]
version = "0.3.70"
version = "0.3.61"

View File

@@ -1,6 +0,0 @@
# Support playwright testing
node_modules/
test-results/
end2end/playwright-report/
playwright/.cache/
pnpm-lock.yaml

View File

@@ -4,10 +4,10 @@ version = "0.1.0"
edition = "2021"
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
leptos = { path = "../../leptos", features = ["csr"] }
console_error_panic_hook = "0.1.7"
[dev-dependencies]
wasm-bindgen-test = "0.3.42"
wasm-bindgen = "0.2.93"
web-sys = "0.3.70"
wasm-bindgen-test = "0.3.0"
wasm-bindgen = "0.2"
web-sys = "0.3"

View File

@@ -2,5 +2,4 @@ extend = [
{ path = "../cargo-make/main.toml" },
{ path = "../cargo-make/wasm-test.toml" },
{ path = "../cargo-make/trunk_server.toml" },
{ path = "../cargo-make/playwright-trunk-test.toml" },
]

View File

@@ -1,4 +0,0 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/

View File

@@ -1,83 +0,0 @@
{
"name": "grip",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "grip",
"devDependencies": {
"@playwright/test": "^1.35.1"
}
},
"node_modules/.pnpm/@playwright+test@1.33.0": {
"extraneous": true
},
"node_modules/.pnpm/@types+node@20.2.1/node_modules/@types/node": {
"version": "20.2.1",
"extraneous": true,
"license": "MIT"
},
"node_modules/.pnpm/playwright-core@1.33.0/node_modules/playwright-core": {
"version": "1.33.0",
"extraneous": true,
"license": "Apache-2.0",
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@playwright/test": {
"version": "1.35.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.35.1.tgz",
"integrity": "sha512-b5YoFe6J9exsMYg0pQAobNDR85T1nLumUYgUTtKm4d21iX2L7WqKq9dW8NGJ+2vX0etZd+Y7UeuqsxDXm9+5ZA==",
"dev": true,
"dependencies": {
"@types/node": "*",
"playwright-core": "1.35.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=16"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/@types/node": {
"version": "20.3.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.1.tgz",
"integrity": "sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==",
"dev": true
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/playwright-core": {
"version": "1.35.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.35.1.tgz",
"integrity": "sha512-pNXb6CQ7OqmGDRspEjlxE49w+4YtR6a3X6mT1hZXeJHWmsEz7SunmvZeiG/+y1yyMZdHnnn73WKYdtV1er0Xyg==",
"dev": true,
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=16"
}
}
}
}

View File

@@ -1,10 +0,0 @@
{
"private": "true",
"scripts": {},
"devDependencies": {
"@playwright/test": "^1.46.1"
},
"dependencies": {
"pnpm": "^9.7.1"
}
}

View File

@@ -1,77 +0,0 @@
import { defineConfig, devices } from "@playwright/test";
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !process.env.DEV,
/* Retry on CI only */
retries: process.env.DEV ? 0 : 10,
/* Opt out of parallel tests on CI. */
workers: process.env.DEV ? 1 : 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [["html", { open: "never" }], ["list"]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://127.0.0.1:8080",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},
/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
// {
// name: "firefox",
// use: { ...devices["Desktop Firefox"] },
// },
// {
// name: "webkit",
// use: { ...devices["Desktop Safari"] },
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ..devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: "cd ../ && trunk serve",
// url: "http://127.0.0.1:8080",
// reuseExistingServer: false, //!process.env.CI,
// },
});

View File

@@ -1,19 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Add 1000 Counters", () => {
test("should increase the number of counters", async ({ page }) => {
const ui = new CountersPage(page);
await Promise.all([
await ui.goto(),
await ui.addOneThousandCountersButton.waitFor(),
]);
await ui.addOneThousandCounters();
await ui.addOneThousandCounters();
await ui.addOneThousandCounters();
await expect(ui.counters).toHaveText("3000");
});
});

View File

@@ -1,15 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Add Counter", () => {
test("should increase the number of counters", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.addCounter();
await ui.addCounter();
await expect(ui.counters).toHaveText("3");
});
});

View File

@@ -1,18 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Clear Counters", () => {
test("should reset the counts", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.addCounter();
await ui.addCounter();
await ui.clearCounters();
await expect(ui.total).toHaveText("0");
await expect(ui.counters).toHaveText("0");
});
});

View File

@@ -1,16 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Decrement Count", () => {
test("should decrease the total count", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.decrementCount();
await ui.decrementCount();
await ui.decrementCount();
await expect(ui.total).toHaveText("-3");
});
});

View File

@@ -1,30 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Enter Count", () => {
test("should increase the total count", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.enterCount("5");
await expect(ui.total).toHaveText("5");
await expect(ui.counters).toHaveText("1");
});
test("should decrease the total count", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.addCounter();
await ui.addCounter();
await ui.enterCount("100");
await ui.enterCount("100", 1);
await ui.enterCount("100", 2);
await ui.enterCount("50", 1);
await expect(ui.total).toHaveText("250");
});
});

View File

@@ -1,98 +0,0 @@
import { expect, Locator, Page } from "@playwright/test";
export class CountersPage {
readonly page: Page;
readonly addCounterButton: Locator;
readonly addOneThousandCountersButton: Locator;
readonly clearCountersButton: Locator;
readonly incrementCountButton: Locator;
readonly counterInput: Locator;
readonly decrementCountButton: Locator;
readonly removeCountButton: Locator;
readonly total: Locator;
readonly counters: Locator;
constructor(page: Page) {
this.page = page;
this.addCounterButton = page.locator("button", { hasText: "Add Counter" });
this.addOneThousandCountersButton = page.locator("button", {
hasText: "Add 1000 Counters",
});
this.clearCountersButton = page.locator("button", {
hasText: "Clear Counters",
});
this.decrementCountButton = page.locator("button", {
hasText: "-1",
});
this.incrementCountButton = page.locator("button", {
hasText: "+1",
});
this.removeCountButton = page.locator("button", {
hasText: "x",
});
this.total = page.getByTestId("total");
this.counters = page.getByTestId("counters");
this.counterInput = page.getByRole("textbox");
}
async goto() {
await this.page.goto("/");
}
async addCounter() {
await Promise.all([
this.addCounterButton.waitFor(),
this.addCounterButton.click(),
]);
}
async addOneThousandCounters() {
this.addOneThousandCountersButton.click();
}
async decrementCount(index: number = 0) {
await Promise.all([
this.decrementCountButton.nth(index).waitFor(),
this.decrementCountButton.nth(index).click(),
]);
}
async incrementCount(index: number = 0) {
await Promise.all([
this.incrementCountButton.nth(index).waitFor(),
this.incrementCountButton.nth(index).click(),
]);
}
async clearCounters() {
await Promise.all([
this.clearCountersButton.waitFor(),
this.clearCountersButton.click(),
]);
}
async enterCount(count: string, index: number = 0) {
await Promise.all([
this.counterInput.nth(index).waitFor(),
this.counterInput.nth(index).fill(count),
]);
}
async removeCounter(index: number = 0) {
await Promise.all([
this.removeCountButton.nth(index).waitFor(),
this.removeCountButton.nth(index).click(),
]);
}
}

View File

@@ -1,16 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Increment Count", () => {
test("should increase the total count", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.incrementCount();
await ui.incrementCount();
await ui.incrementCount();
await expect(ui.total).toHaveText("3");
});
});

View File

@@ -1,17 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("Remove Counter", () => {
test("should decrement the number of counters", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await ui.addCounter();
await ui.addCounter();
await ui.addCounter();
await ui.removeCounter(1);
await expect(ui.counters).toHaveText("2");
});
});

View File

@@ -1,19 +0,0 @@
import { test, expect } from "@playwright/test";
import { CountersPage } from "./fixtures/counters_page";
test.describe("View Counters", () => {
test("should see the title", async ({ page }) => {
const ui = new CountersPage(page);
await ui.goto();
await expect(page).toHaveTitle("Counters");
});
test("should see the initial counts", async ({ page }) => {
const counters = new CountersPage(page);
await counters.goto();
await expect(counters.total).toHaveText("0");
await expect(counters.counters).toHaveText("0");
});
});

View File

@@ -2,7 +2,6 @@
<html>
<head>
<link data-trunk rel="rust" data-wasm-opt="z" data-weak-refs/>
<title>Counters</title>
</head>
<body></body>
</html>
</html>

View File

@@ -1,4 +1,4 @@
use leptos::prelude::*;
use leptos::prelude::{signal::*, *};
const MANY_COUNTERS: usize = 1000;
@@ -44,13 +44,12 @@ pub fn Counters() -> impl IntoView {
<button on:click=clear_counters>"Clear Counters"</button>
<p>
"Total: "
<span data-testid="total">
<span>
{move || {
counters.get().iter().map(|(_, count)| count.get()).sum::<i32>().to_string()
}}
</span> " from "
<span data-testid="counters">{move || counters.get().len().to_string()}</span>
</span> " from " <span>{move || counters.get().len().to_string()}</span>
" counters."
</p>
<ul>

View File

@@ -23,7 +23,7 @@ async fn inc() {
div.inner_html(),
"<button>Add Counter</button><button>Add 1000 \
Counters</button><button>Clear Counters</button><p>Total: \
<span data-testid=\"total\">0</span> from <span data-testid=\"counters\">0</span> counters.</p><ul><!----></ul>"
<span>0</span> from <span>0</span> counters.</p><ul><!----></ul>"
);
// add 3 counters
@@ -38,7 +38,7 @@ async fn inc() {
div.inner_html(),
"<button>Add Counter</button><button>Add 1000 \
Counters</button><button>Clear Counters</button><p>Total: \
<span data-testid=\"total\">0</span> from <span data-testid=\"counters\">3</span> \
<span>0</span> from <span>3</span> \
counters.</p><ul><li><button>-1</button><input \
type=\"text\"><span>0</span><button>+1</button><button>x</button></\
li><li><button>-1</button><input \
@@ -80,7 +80,7 @@ async fn inc() {
div.inner_html(),
"<button>Add Counter</button><button>Add 1000 \
Counters</button><button>Clear Counters</button><p>Total: \
<span data-testid=\"total\">6</span> from <span data-testid=\"counters\">3</span> \
<span>6</span> from <span>3</span> \
counters.</p><ul><li><button>-1</button><input \
type=\"text\"><span>1</span><button>+1</button><button>x</button></\
li><li><button>-1</button><input \
@@ -105,7 +105,7 @@ async fn inc() {
div.inner_html(),
"<button>Add Counter</button><button>Add 1000 \
Counters</button><button>Clear Counters</button><p>Total: \
<span data-testid=\"total\">5</span> from <span data-testid=\"counters\">2</span> \
<span>5</span> from <span>2</span> \
counters.</p><ul><li><button>-1</button><input \
type=\"text\"><span>2</span><button>+1</button><button>x</button></\
li><li><button>-1</button><input \

View File

@@ -5,12 +5,12 @@ edition = "2021"
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
log = "0.4.22"
console_log = "1.0"
log = "0.4"
console_log = "1"
console_error_panic_hook = "0.1.7"
web-sys = { version = "0.3.70", features = ["Clipboard", "Navigator"] }
web-sys = { version = "0.3", features = ["Clipboard", "Navigator"] }
[dev-dependencies]
wasm-bindgen-test = "0.3.42"
wasm-bindgen = "0.2.93"
web-sys = { version = "0.3.70", features = ["NodeList"] }
wasm-bindgen-test = "0.3.0"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["NodeList"] }

View File

@@ -24,7 +24,11 @@ pub fn copy_to_clipboard(el: Element, content: &str) {
evt.prevent_default();
evt.stop_propagation();
let _ = window().navigator().clipboard().write_text(&content);
let _ = window()
.navigator()
.clipboard()
.expect("navigator.clipboard to be available")
.write_text(&content);
el.set_inner_html(&format!("Copied \"{}\"", &content));
});
@@ -49,6 +53,7 @@ impl From<()> for Amount {
}
}
// .into() will automatically be called on the parameter
pub fn add_dot(el: Element, amount: Amount) {
use leptos::wasm_bindgen::JsCast;
let el = el.unchecked_into::<web_sys::HtmlElement>();
@@ -77,17 +82,12 @@ pub fn App() -> impl IntoView {
let data = "Hello World!";
view! {
<a href="#" use:copy_to_clipboard=data>
"Copy \""
{data}
"\" to clipboard"
</a>
<a href="#" use:copy_to_clipboard=data>"Copy \"" {data} "\" to clipboard"</a>
// automatically applies the directive to every root element in `SomeComponent`
<SomeComponent use:highlight/>
<SomeComponent use:highlight />
// no value will default to `().into()`
<button use:add_dot>"Add a dot"</button>
// can manually call `.into()` to convert to the correct type
// (automatically calling `.into()` prevents using generics in directive functions)
<button use:add_dot=5.into()>"Add 5 dots"</button>
// `5.into()` automatically called
<button use:add_dot=5>"Add 5 dots"</button>
}
}

View File

@@ -9,6 +9,6 @@ lto = true
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
console_log = "1.0"
log = "0.4.22"
console_log = "1"
log = "0.4"
console_error_panic_hook = "0.1.7"

View File

@@ -7,19 +7,19 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1.7"
console_error_panic_hook = "0.1"
leptos = { path = "../../leptos" }
leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_meta = { path = "../../meta" }
leptos_router = { path = "../../router" }
serde = { version = "1.0", features = ["derive"] }
axum = { version = "0.7.5", optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true }
http = { version = "1.1" }
serde = { version = "1", features = ["derive"] }
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
http = { version = "1.0" }
thiserror = "1.0"
wasm-bindgen = "0.2.93"
wasm-bindgen = "0.2"
[features]
hydrate = ["leptos/hydrate"]

View File

@@ -9,16 +9,16 @@ lto = true
[dependencies]
leptos = { path = "../../leptos", features = ["csr", "tracing"] }
reqwasm = "0.5.0"
gloo-timers = { version = "0.3.0", features = ["futures"] }
serde = { version = "1.0", features = ["derive"] }
log = "0.4.22"
console_log = "1.0"
console_error_panic_hook = "0.1.7"
thiserror = "1.0"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-subscriber-wasm = "0.1.0"
reqwasm = "0.5"
gloo-timers = { version = "0.3", features = ["futures"] }
serde = { version = "1", features = ["derive"] }
log = "0.4"
console_log = "1"
console_error_panic_hook = "0.1"
thiserror = "1"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-subscriber-wasm = "0.1"
[dev-dependencies]
wasm-bindgen-test = "0.3.42"
wasm-bindgen-test = "0.3"

18
examples/gtk/Cargo.toml Normal file
View File

@@ -0,0 +1,18 @@
[package]
name = "gtk"
version = "0.1.0"
edition = "2021"
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
throw_error = { path = "../../any_error/" }
any_spawner = { path = "../../any_spawner/" }
next_tuple = { path = "../../next_tuple/" }
gtk = { version = "0.8.0", package = "gtk4", optional = true }
paste = "1.0.14"
console_error_panic_hook = { version = "0.1", optional = true }
[features]
gtk = ["dep:gtk", "any_spawner/glib"]
wasm = ["any_spawner/wasm-bindgen", "dep:console_error_panic_hook"]

8
examples/gtk/index.html Normal file
View File

@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta name="color-scheme" content="dark">
<link rel="css" href="style.css" data-trunk>
</head>
<body></body>
</html>

View File

@@ -0,0 +1,633 @@
use self::properties::Connect;
use gtk::{
ffi::GtkWidget,
glib::{
object::{IsA, IsClass, ObjectExt},
Object, Value,
},
prelude::{Cast, WidgetExt},
Label, Orientation, Widget,
};
use leptos::{
reactive_graph::effect::RenderEffect,
tachys::{
renderer::{CastFrom, Renderer},
view::{Mountable, Render},
},
};
use next_tuple::NextTuple;
use std::{borrow::Cow, marker::PhantomData};
#[derive(Debug)]
pub struct LeptosGtk;
#[derive(Debug, Clone)]
pub struct Element(pub Widget);
impl Element {
pub fn remove(&self) {
self.0.unparent();
}
}
#[derive(Debug, Clone)]
pub struct Text(pub Element);
impl<T> From<T> for Element
where
T: Into<Widget>,
{
fn from(value: T) -> Self {
Element(value.into())
}
}
impl Mountable<LeptosGtk> for Element {
fn unmount(&mut self) {
self.remove()
}
fn mount(
&mut self,
parent: &<LeptosGtk as Renderer>::Element,
marker: Option<&<LeptosGtk as Renderer>::Node>,
) {
self.0
.insert_before(&parent.0, marker.as_ref().map(|m| &m.0));
}
fn insert_before_this(&self,
child: &mut dyn Mountable<LeptosGtk>,
) -> bool {
child.mount(parent, Some(self.as_ref()));
true
}
}
impl Mountable<LeptosGtk> for Text {
fn unmount(&mut self) {
self.0.remove()
}
fn mount(
&mut self,
parent: &<LeptosGtk as Renderer>::Element,
marker: Option<&<LeptosGtk as Renderer>::Node>,
) {
self.0
.0
.insert_before(&parent.0, marker.as_ref().map(|m| &m.0));
}
fn insert_before_this(&self,
child: &mut dyn Mountable<LeptosGtk>,
) -> bool {
child.mount(parent, Some(self.as_ref()));
true
}
}
impl CastFrom<Element> for Element {
fn cast_from(source: Element) -> Option<Self> {
Some(source)
}
}
impl CastFrom<Element> for Text {
fn cast_from(source: Element) -> Option<Self> {
source
.0
.downcast::<Label>()
.ok()
.map(|n| Text(Element::from(n)))
}
}
impl AsRef<Element> for Element {
fn as_ref(&self) -> &Element {
self
}
}
impl AsRef<Element> for Text {
fn as_ref(&self) -> &Element {
&self.0
}
}
impl Renderer for LeptosGtk {
type Node = Element;
type Element = Element;
type Text = Text;
type Placeholder = Element;
fn intern(text: &str) -> &str {
text
}
fn create_text_node(text: &str) -> Self::Text {
Text(Element::from(Label::new(Some(text))))
}
fn create_placeholder() -> Self::Placeholder {
let label = Label::new(None);
label.set_visible(false);
Element::from(label)
}
fn set_text(node: &Self::Text, text: &str) {
let node_as_text = node.0 .0.downcast_ref::<Label>().unwrap();
node_as_text.set_label(text);
}
fn set_attribute(node: &Self::Element, name: &str, value: &str) {
node.0.set_property(name, value);
}
fn remove_attribute(node: &Self::Element, name: &str) {
node.0.set_property(name, None::<&str>);
}
fn insert_node(
parent: &Self::Element,
new_child: &Self::Node,
marker: Option<&Self::Node>,
) {
new_child
.0
.insert_before(&parent.0, marker.as_ref().map(|n| &n.0));
}
fn remove_node(
parent: &Self::Element,
child: &Self::Node,
) -> Option<Self::Node> {
todo!()
}
fn remove(node: &Self::Node) {
todo!()
}
fn get_parent(node: &Self::Node) -> Option<Self::Node> {
node.0.parent().map(Element::from)
}
fn first_child(node: &Self::Node) -> Option<Self::Node> {
todo!()
}
fn next_sibling(node: &Self::Node) -> Option<Self::Node> {
todo!()
}
fn log_node(node: &Self::Node) {
todo!()
}
fn clear_children(parent: &Self::Element) {
todo!()
}
}
pub fn root<Chil>(children: Chil) -> (Widget, impl Mountable<LeptosGtk>)
where
Chil: Render<LeptosGtk>,
{
let state = r#box()
.orientation(Orientation::Vertical)
.spacing(12)
.child(children)
.build();
(state.as_widget().clone(), state)
}
pub trait WidgetClass {
type Widget: Into<Widget> + IsA<Object> + IsClass;
}
pub struct LGtkWidget<Widg, Props, Chil> {
widget: PhantomData<Widg>,
properties: Props,
children: Chil,
}
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Chil: NextTuple,
{
pub fn child<T>(
self,
child: T,
) -> LGtkWidget<Widg, Props, Chil::Output<T>> {
let LGtkWidget {
widget,
properties,
children,
} = self;
LGtkWidget {
widget,
properties,
children: children.next_tuple(child),
}
}
}
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: NextTuple,
Chil: Render<LeptosGtk>,
{
pub fn connect<F>(
self,
signal_name: &'static str,
callback: F,
) -> LGtkWidget<Widg, Props::Output<Connect<F>>, Chil>
where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
{
let LGtkWidget {
widget,
properties,
children,
} = self;
LGtkWidget {
widget,
properties: properties.next_tuple(Connect {
signal_name,
callback,
}),
children,
}
}
}
pub struct LGtkWidgetState<Widg, Props, Chil>
where
Chil: Render<LeptosGtk>,
Props: Property,
Widg: WidgetClass,
{
ty: PhantomData<Widg>,
widget: Element,
properties: Props::State,
children: Chil::State,
}
impl<Widg, Props, Chil> LGtkWidgetState<Widg, Props, Chil>
where
Chil: Render<LeptosGtk>,
Props: Property,
Widg: WidgetClass,
{
pub fn as_widget(&self) -> &Widget {
&self.widget.0
}
}
impl<Widg, Props, Chil> Render<LeptosGtk> for LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: Property,
Chil: Render<LeptosGtk>,
{
type State = LGtkWidgetState<Widg, Props, Chil>;
fn build(self) -> Self::State {
let widget = Object::new::<Widg::Widget>();
let widget = Element::from(widget);
let properties = self.properties.build(&widget);
let mut children = self.children.build();
children.mount(&widget, None);
LGtkWidgetState {
ty: PhantomData,
widget,
properties,
children,
}
}
fn rebuild(self, state: &mut Self::State) {
self.properties
.rebuild(&state.widget, &mut state.properties);
self.children.rebuild(&mut state.children);
}
}
impl<Widg, Props, Chil> Mountable<LeptosGtk>
for LGtkWidgetState<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: Property,
Chil: Render<LeptosGtk>,
{
fn unmount(&mut self) {
self.children.unmount();
self.widget.remove();
}
fn mount(
&mut self,
parent: &<LeptosGtk as Renderer>::Element,
marker: Option<&<LeptosGtk as Renderer>::Node>,
) {
println!("mounting {}", std::any::type_name::<Widg>());
self.children.mount(&self.widget, None);
LeptosGtk::insert_node(parent, &self.widget, marker);
}
fn insert_before_this(&self,
child: &mut dyn Mountable<LeptosGtk>,
) -> bool {
child.mount(parent, Some(self.widget.as_ref()));
true
}
}
pub trait Property {
type State;
fn build(self, element: &Element) -> Self::State;
fn rebuild(self, element: &Element, state: &mut Self::State);
}
impl<T, F> Property for F
where
T: Property,
T::State: 'static,
F: Fn() -> T + 'static,
{
type State = RenderEffect<T::State>;
fn build(self, widget: &Element) -> Self::State {
let widget = widget.clone();
RenderEffect::new(move |prev| {
let value = self();
if let Some(mut prev) = prev {
value.rebuild(&widget, &mut prev);
prev
} else {
value.build(&widget)
}
})
}
fn rebuild(self, widget: &Element, state: &mut Self::State) {}
}
pub fn button() -> LGtkWidget<gtk::Button, (), ()> {
LGtkWidget {
widget: PhantomData,
properties: (),
children: (),
}
}
pub fn r#box() -> LGtkWidget<gtk::Box, (), ()> {
LGtkWidget {
widget: PhantomData,
properties: (),
children: (),
}
}
mod widgets {
use super::WidgetClass;
impl WidgetClass for gtk::Button {
type Widget = Self;
}
impl WidgetClass for gtk::Box {
type Widget = Self;
}
}
pub mod properties {
use super::{
Element, LGtkWidget, LGtkWidgetState, LeptosGtk, Property, WidgetClass,
};
use gtk::glib::{object::ObjectExt, Value};
use leptos::tachys::{renderer::Renderer, view::Render};
use next_tuple::NextTuple;
pub struct Connect<F>
where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
{
pub signal_name: &'static str,
pub callback: F,
}
impl<F> Property for Connect<F>
where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
{
type State = ();
fn build(self, element: &Element) -> Self::State {
element.0.connect(self.signal_name, false, self.callback);
}
fn rebuild(self, element: &Element, state: &mut Self::State) {}
}
/* examples for macro */
pub struct Orientation {
value: gtk::Orientation,
}
pub struct OrientationState {
value: gtk::Orientation,
}
impl Property for Orientation {
type State = OrientationState;
fn build(self, element: &Element) -> Self::State {
element.0.set_property("orientation", self.value);
OrientationState { value: self.value }
}
fn rebuild(self, element: &Element, state: &mut Self::State) {
if self.value != state.value {
element.0.set_property("orientation", self.value);
state.value = self.value;
}
}
}
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: NextTuple,
Chil: Render<LeptosGtk>,
{
pub fn orientation(
self,
value: impl Into<gtk::Orientation>,
) -> LGtkWidget<Widg, Props::Output<Orientation>, Chil> {
let LGtkWidget {
widget,
properties,
children,
} = self;
LGtkWidget {
widget,
properties: properties.next_tuple(Orientation {
value: value.into(),
}),
children,
}
}
}
pub struct Spacing {
value: i32,
}
pub struct SpacingState {
value: i32,
}
impl Property for Spacing {
type State = SpacingState;
fn build(self, element: &Element) -> Self::State {
element.0.set_property("spacing", self.value);
SpacingState { value: self.value }
}
fn rebuild(self, element: &Element, state: &mut Self::State) {
if self.value != state.value {
element.0.set_property("spacing", self.value);
state.value = self.value;
}
}
}
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: NextTuple,
Chil: Render<LeptosGtk>,
{
pub fn spacing(
self,
value: impl Into<i32>,
) -> LGtkWidget<Widg, Props::Output<Spacing>, Chil> {
let LGtkWidget {
widget,
properties,
children,
} = self;
LGtkWidget {
widget,
properties: properties.next_tuple(Spacing {
value: value.into(),
}),
children,
}
}
}
/* end examples for properties macro */
pub struct Label {
value: String,
}
impl Label {
pub fn new(value: impl Into<String>) -> Self {
Self {
value: value.into(),
}
}
}
pub struct LabelState {
value: String,
}
impl Property for Label {
type State = LabelState;
fn build(self, element: &Element) -> Self::State {
LeptosGtk::set_attribute(element, "label", &self.value);
LabelState { value: self.value }
}
fn rebuild(self, element: &Element, state: &mut Self::State) {
todo!()
}
}
impl Property for () {
type State = ();
fn build(self, _element: &Element) -> Self::State {}
fn rebuild(self, _element: &Element, _state: &mut Self::State) {}
}
macro_rules! tuples {
($($ty:ident),* $(,)?) => {
impl<$($ty,)*> Property for ($($ty,)*)
where $($ty: Property,)*
{
type State = ($($ty::State,)*);
fn build(self, element: &Element) -> Self::State {
#[allow(non_snake_case)]
let ($($ty,)*) = self;
($($ty.build(element),)*)
}
fn rebuild(self, element: &Element, state: &mut Self::State) {
paste::paste! {
#[allow(non_snake_case)]
let ($($ty,)*) = self;
#[allow(non_snake_case)]
let ($([<state_ $ty:lower>],)*) = state;
$($ty.rebuild(element, [<state_ $ty:lower>]));*
}
}
}
}
}
tuples!(A);
tuples!(A, B);
tuples!(A, B, C);
tuples!(A, B, C, D);
tuples!(A, B, C, D, E);
tuples!(A, B, C, D, E, F);
tuples!(A, B, C, D, E, F, G);
tuples!(A, B, C, D, E, F, G, H);
tuples!(A, B, C, D, E, F, G, H, I);
tuples!(A, B, C, D, E, F, G, H, I, J);
tuples!(A, B, C, D, E, F, G, H, I, J, K);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U);
tuples!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V);
tuples!(
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W
);
tuples!(
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X
);
tuples!(
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X,
Y
);
}

175
examples/gtk/src/main.rs Normal file
View File

@@ -0,0 +1,175 @@
#[cfg(feature = "gtk")]
use gtk::{
glib::Value, prelude::*, Application, ApplicationWindow, Orientation,
Widget,
};
#[cfg(feature = "wasm")]
use leptos::tachys::{dom::body, html::element, html::event as ev};
use leptos::{
logging,
prelude::*,
reactive_graph::{effect::Effect, owner::Owner, signal::RwSignal},
Executor, For, ForProps,
};
#[cfg(feature = "gtk")]
use leptos_gtk::{Element, LGtkWidget, LeptosGtk};
use std::{mem, thread, time::Duration};
#[cfg(feature = "gtk")]
mod leptos_gtk;
const APP_ID: &str = "dev.leptos.Counter";
// Basic GTK app setup from https://gtk-rs.org/gtk4-rs/stable/latest/book/hello_world.html
fn main() {
// use the glib event loop to power the reactive system
#[cfg(feature = "gtk")]
{
_ = Executor::init_glib();
let app = Application::builder().application_id(APP_ID).build();
app.connect_startup(|_| load_css());
app.connect_activate(|app| {
// Connect to "activate" signal of `app`
let owner = Owner::new();
let view = owner.with(ui);
let (root, state) = leptos_gtk::root(view);
let window = ApplicationWindow::builder()
.application(app)
.title("TachyGTK")
.child(&root)
.build();
// Present window
window.present();
mem::forget((owner, state));
});
app.run();
}
#[cfg(all(feature = "wasm", not(feature = "gtk")))]
{
console_error_panic_hook::set_once();
_ = Executor::init_wasm_bindgen();
let owner = Owner::new();
let view = owner.with(ui);
let mut state = view.build();
state.mount(&body().into(), None);
mem::forget((owner, state));
}
}
#[cfg(feature = "gtk")]
type Rndr = LeptosGtk;
#[cfg(all(feature = "wasm", not(feature = "gtk")))]
type Rndr = Dom;
fn ui() -> impl Render<Rndr> {
let value = RwSignal::new(0);
let rows = RwSignal::new(vec![1, 2, 3, 4, 5]);
Effect::new(move |_| {
logging::log!("value = {}", value.get());
});
// just an example of multithreaded reactivity
#[cfg(feature = "gtk")]
thread::spawn(move || loop {
thread::sleep(Duration::from_millis(250));
value.update(|n| *n += 1);
});
vstack((
hstack((
button("-1", move || value.update(|n| *n -= 1)),
move || value.get().to_string(),
button("+1", move || value.update(|n| *n += 1)),
)),
button("Swap", move || {
rows.update(|items| {
items.swap(1, 3);
})
}),
hstack(For(ForProps::builder()
.each(move || rows.get())
.key(|k| *k)
.children(|v| v)
.build())),
))
}
fn button(
label: impl Render<Rndr>,
callback: impl Fn() + Send + Sync + 'static,
) -> impl Render<Rndr> {
#[cfg(feature = "gtk")]
{
leptos_gtk::button()
.child(label)
.connect("clicked", move |_| {
callback();
None
})
}
#[cfg(all(feature = "wasm", not(feature = "gtk")))]
{
element::button()
.on(ev::click, move |_| callback())
.child(label)
}
}
fn vstack(children: impl Render<Rndr>) -> impl Render<Rndr> {
#[cfg(feature = "gtk")]
{
leptos_gtk::r#box()
.orientation(Orientation::Vertical)
.spacing(12)
.child(children)
}
#[cfg(all(feature = "wasm", not(feature = "gtk")))]
{
element::div()
.style(("display", "flex"))
.style(("flex-direction", "column"))
.style(("align-items", "center"))
.style(("justify-content", "center"))
.style(("margin", "1rem"))
.child(children)
}
}
fn hstack(children: impl Render<Rndr>) -> impl Render<Rndr> {
#[cfg(feature = "gtk")]
{
leptos_gtk::r#box()
.orientation(Orientation::Horizontal)
.spacing(12)
.child(children)
}
#[cfg(all(feature = "wasm", not(feature = "gtk")))]
{
element::div()
.style(("display", "flex"))
.style(("align-items", "center"))
.style(("justify-content", "center"))
.style(("margin", "1rem"))
.child(children)
}
}
#[cfg(feature = "gtk")]
fn load_css() {
use gtk::{gdk::Display, CssProvider};
let provider = CssProvider::new();
provider.load_from_path("style.css");
// Add the provider to the default screen
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}

0
examples/gtk/style.css Normal file
View File

View File

@@ -13,27 +13,31 @@ panic = "abort"
lto = true
[dependencies]
actix-files = { version = "0.6.6", optional = true }
actix-web = { version = "4.8", optional = true, features = ["macros"] }
console_log = "1.0"
console_error_panic_hook = "0.1.7"
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4", optional = true, features = ["macros"] }
console_log = "1"
console_error_panic_hook = "0.1"
leptos = { path = "../../leptos" }
leptos_meta = { path = "../../meta" }
leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router" }
log = "0.4.22"
serde = { version = "1.0", features = ["derive"] }
gloo-net = { version = "0.6.0", features = ["http"] }
reqwest = { version = "0.12.5", features = ["json"] }
wasm-bindgen = "0.2.93"
web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] }
log = "0.4"
serde = { version = "1", features = ["derive"] }
gloo-net = { version = "0.2", features = ["http"] }
reqwest = { version = "0.11", features = ["json"] }
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["AbortController", "AbortSignal"] }
send_wrapper = "0.6.0"
[features]
default = ["csr"]
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate"]
ssr = ["dep:actix-files", "dep:actix-web", "dep:leptos_actix", "leptos/ssr"]
ssr = [
"dep:actix-files",
"dep:actix-web",
"dep:leptos_actix",
"leptos/ssr",
]
[profile.wasm-release]
inherits = "release"

View File

@@ -11,22 +11,22 @@ codegen-units = 1
lto = true
[dependencies]
console_error_panic_hook = "0.1.7"
console_error_panic_hook = "0.1"
leptos = { path = "../../leptos" }
leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_meta = { path = "../../meta" }
leptos_router = { path = "../../router" }
serde = { version = "1.0", features = ["derive"] }
tracing = "0.1.40"
gloo-net = { version = "0.6.0", features = ["http"] }
reqwest = { version = "0.12.5", features = ["json"] }
axum = { version = "0.7.5", optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true }
http = { version = "1.1", optional = true }
web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] }
wasm-bindgen = "0.2.93"
tracing = "0.1"
gloo-net = { version = "0.4", features = ["http"] }
reqwest = { version = "0.11", features = ["json"] }
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
http = { version = "1.0", optional = true }
web-sys = { version = "0.3", features = ["AbortController", "AbortSignal"] }
wasm-bindgen = "0.2"
send_wrapper = { version = "0.6.0", features = ["futures"] }
[features]

View File

@@ -11,34 +11,34 @@ codegen-units = 1
lto = true
[dependencies]
console_error_panic_hook = "0.1.7"
leptos = { path = "../../leptos", features = ["experimental-islands"] }
console_error_panic_hook = "0.1"
leptos = { path = "../../leptos", features = [
"experimental-islands",
] }
leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_meta = { path = "../../meta" }
leptos_router = { path = "../../router" }
leptos_router = { path = "../../router"}
serde = { version = "1.0", features = ["derive"] }
tracing = "0.1.40"
gloo-net = { version = "0.6.0", features = ["http"] }
reqwest = { version = "0.12.5", features = ["json"] }
axum = { version = "0.7.5", optional = true, features = ["http2"] }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = [
tracing = "0.1"
gloo-net = { version = "0.4", features = ["http"] }
reqwest = { version = "0.11", features = ["json"] }
axum = { version = "0.7", optional = true, features = ["http2"] }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = [
"fs",
"compression-gzip",
"compression-br",
], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true }
http = { version = "1.1", optional = true }
web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] }
wasm-bindgen = "0.2.93"
rust-embed = { version = "8.5", features = [
"axum",
"mime_guess",
"tokio",
], optional = true }
mime_guess = { version = "2.0", optional = true }
tokio = { version = "1", features = ["full"], optional = true }
http = { version = "1.0", optional = true }
web-sys = { version = "0.3", features = ["AbortController", "AbortSignal"] }
wasm-bindgen = "0.2"
lazy_static = "1.4.0"
rust-embed = { version = "8", features = ["axum", "mime_guess", "tokio"], optional = true }
mime_guess = { version = "2.0.4", optional = true }
[features]
default = []
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate"]
ssr = [

View File

@@ -11,30 +11,30 @@ codegen-units = 1
lto = true
[dependencies]
console_error_panic_hook = "0.1.7"
console_error_panic_hook = "0.1"
console_log = "1.0"
log = "0.4.22"
log = "0.4"
leptos = { path = "../../leptos" }
leptos_axum = { path = "../../integrations/axum", default-features = false, optional = true }
leptos_meta = { path = "../../meta" }
leptos_router = { path = "../../router" }
leptos_server = { path = "../../leptos_server", optional = true }
serde = { version = "1.0", features = ["derive"] }
tracing = "0.1.40"
gloo-net = { version = "0.6.0", features = ["http"] }
reqwest = { version = "0.12.5", features = ["json"] }
axum = { version = "0.7.5", default-features = false, optional = true }
tower = { version = "0.4.13", optional = true }
http = { version = "1.1", optional = true }
web-sys = { version = "0.3.70", features = [
tracing = "0.1"
gloo-net = { version = "0.5", features = ["http"] }
reqwest = { version = "0.12", features = ["json"] }
axum = { version = "0.7", default-features = false, optional = true }
tower = { version = "0.4", optional = true }
http = { version = "1.0", optional = true }
web-sys = { version = "0.3", features = [
"AbortController",
"AbortSignal",
"Request",
"Response",
] }
getrandom = { version = "0.2.15", features = ["js"] }
wasm-bindgen = "0.2.93"
wasm-bindgen-futures = { version = "0.4.42", features = [
getrandom = { version = "0.2.7", features = ["js"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = { version = "0.4.37", features = [
"futures-core-03-stream",
], optional = true }
axum-js-fetch = { git = "https://github.com/seanaye/axum-js-fetch", optional = true }

View File

@@ -7,32 +7,32 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1.7"
futures = "0.3.30"
http = "1.1"
console_error_panic_hook = "0.1"
futures = "0.3"
http = "1.0"
leptos = { path = "../../leptos", features = [
"tracing",
"experimental-islands",
"tracing",
"experimental-islands",
] }
server_fn = { path = "../../server_fn", features = ["serde-lite"] }
leptos_axum = { path = "../../integrations/axum", optional = true }
log = "0.4.22"
serde = { version = "1.0", features = ["derive"] }
axum = { version = "0.7.5", optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true }
wasm-bindgen = "0.2.93"
log = "0.4"
serde = { version = "1", features = ["derive"] }
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
wasm-bindgen = "0.2"
[features]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"dep:leptos_axum",
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"dep:leptos_axum",
]
[profile.wasm-release]

View File

@@ -7,35 +7,33 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1.7"
futures = "0.3.30"
http = "1.1"
console_error_panic_hook = "0.1"
futures = "0.3"
http = "1.0"
leptos = { path = "../../leptos", features = [
"tracing",
"experimental-islands",
"tracing",
"experimental-islands",
] }
leptos_router = { path = "../../router" }
server_fn = { path = "../../server_fn", features = ["serde-lite"] }
leptos_axum = { path = "../../integrations/axum", features = [
"islands-router",
], optional = true }
log = "0.4.22"
serde = { version = "1.0", features = ["derive"] }
axum = { version = "0.7.5", optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true }
wasm-bindgen = "0.2.93"
leptos_axum = { path = "../../integrations/axum", features = ["islands-router"], optional = true }
log = "0.4"
serde = { version = "1", features = ["derive"] }
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
wasm-bindgen = "0.2"
[features]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"dep:leptos_axum",
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"dep:leptos_axum",
]
[profile.wasm-release]

View File

@@ -8,13 +8,13 @@ codegen-units = 1
lto = true
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] } # for actual benchmarking, add `nightly` and `delegation` features
leptos = { path = "../../leptos", features = ["csr"] } # for actual benchmarking, add `nightly` and `event-delegation` features
# used in rand, but we need to enable js feature
getrandom = { version = "0.2.15", features = ["js"] }
getrandom = { version = "0.2.7", features = ["js"] }
rand = { version = "0.8.5", features = ["small_rng"] }
console_error_panic_hook = "0.1.7"
[dev-dependencies]
wasm-bindgen = "0.2"
wasm-bindgen-test = "0.3.42"
wasm-bindgen-test = "0.3.0"
web-sys = "0.3"

View File

@@ -162,24 +162,22 @@ pub fn App() -> impl IntoView {
<table class="table table-hover table-striped test-data">
<tbody>
<For
each=move || data.get()
key=|row| row.id
each={move || data.get()}
key={|row| row.id}
children=move |row: RowData| {
let row_id = row.id;
let label = row.label;
let is_selected = is_selected.clone();
template! {
< tr class : danger = { move || is_selected.selected(Some(row_id)) }
> < td class = "col-md-1" > { row_id.to_string() } </ td > < td
class = "col-md-4" >< a on : click = move | _ | set_selected
.set(Some(row_id)) > { move || label.get() } </ a ></ td > < td
class = "col-md-1" >< a on : click = move | _ | remove(row_id) ><
span class = "glyphicon glyphicon-remove" aria - hidden = "true" ></
span ></ a ></ td > < td class = "col-md-6" /> </ tr >
}
ViewTemplate::new(view! {
<tr class:danger={move || is_selected.selected(Some(row_id))}>
<td class="col-md-1">{row_id.to_string()}</td>
<td class="col-md-4"><a on:click=move |_| set_selected.set(Some(row_id))>{move || label.get()}</a></td>
<td class="col-md-1"><a on:click=move |_| remove(row_id)><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
<td class="col-md-6"/>
</tr>
})
}
/>
</tbody>
</table>
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>

View File

@@ -9,7 +9,7 @@ lto = true
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
console_log = "1.0"
log = "0.4.22"
console_log = "1"
log = "0.4"
console_error_panic_hook = "0.1.7"
web-sys = "0.3.70"
web-sys = "0.3"

View File

@@ -5,12 +5,12 @@ edition = "2021"
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
log = "0.4.22"
console_log = "1.0"
log = "0.4"
console_log = "1"
console_error_panic_hook = "0.1.7"
wasm-bindgen = "0.2.93"
wasm-bindgen = "0.2"
[dev-dependencies]
wasm-bindgen-test = "0.3.42"
wasm-bindgen = "0.2.93"
web-sys = "0.3.70"
wasm-bindgen-test = "0.3.0"
wasm-bindgen = "0.2"
web-sys = "0.3"

View File

@@ -10,16 +10,16 @@ codegen-units = 1
panic = "abort"
[dependencies]
console_log = "1.0"
console_log = "1"
leptos = { path = "../../leptos", features = ["csr", "tracing"] }
leptos_router = { path = "../../router" } #, features = ["tracing"] }
leptos_router = { path = "../../router" } #, features = ["tracing"] }
leptos_router_macro = { path = "../../router_macro" }
serde = { version = "1.0", features = ["derive"] }
futures = "0.3.30"
serde = { version = "1", features = ["derive"] }
futures = "0.3"
console_error_panic_hook = "0.1.7"
tracing-subscriber = "0.3.18"
tracing-subscriber-wasm = "0.1.0"
tracing = "0.1.40"
[dev-dependencies]
wasm-bindgen-test = "0.3.42"
wasm-bindgen-test = "0.3.0"

View File

@@ -65,14 +65,13 @@ pub fn RouterExample() -> impl IntoView {
// You can define other routes in their own component.
// Routes implement the MatchNestedRoutes
#[component]
pub fn ContactRoutes() -> impl MatchNestedRoutes + Clone {
pub fn ContactRoutes() -> impl MatchNestedRoutes<Dom> + Clone {
view! {
<ParentRoute path=path!("") view=ContactList>
<Route path=path!("/") view=|| "Select a contact."/>
<Route path=path!("/:id") view=Contact/>
</ParentRoute>
}
.into_inner()
}
#[component]

View File

@@ -7,53 +7,44 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1.7"
futures = "0.3.30"
http = "1.1"
console_error_panic_hook = "0.1"
futures = "0.3"
http = "1.0"
leptos = { path = "../../leptos" }
leptos_axum = { path = "../../integrations/axum", optional = true }
server_fn = { path = "../../server_fn", features = [
"serde-lite",
"rkyv",
"multipart",
"postcard",
] }
log = "0.4.22"
simple_logger = "5.0"
serde = { version = "1.0", features = ["derive"] }
axum = { version = "0.7.5", optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = [
"fs",
"tracing",
"trace",
], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true }
server_fn = { path = "../../server_fn", features = ["serde-lite", "rkyv", "multipart"] }
log = "0.4"
simple_logger = "4.0"
serde = { version = "1", features = ["derive"] }
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs", "tracing", "trace"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
thiserror = "1.0"
wasm-bindgen = "0.2.93"
wasm-bindgen = "0.2"
serde_toml = "0.0.1"
toml = "0.8.19"
web-sys = { version = "0.3.70", features = ["FileList", "File"] }
strum = { version = "0.26.3", features = ["strum_macros", "derive"] }
notify = { version = "6.1", optional = true }
pin-project-lite = "0.2.14"
dashmap = { version = "6.0", optional = true }
once_cell = { version = "1.19", optional = true }
async-broadcast = { version = "0.7.1", optional = true }
toml = "0.8.8"
web-sys = { version = "0.3.67", features = ["FileList", "File"] }
strum = { version = "0.25.0", features = ["strum_macros", "derive"] }
notify = { version = "6.1.1", optional = true }
pin-project-lite = "0.2.13"
dashmap = { version = "5.5.3", optional = true }
once_cell = { version = "1.19.0", optional = true }
async-broadcast = { version = "0.6.0", optional = true }
[features]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"dep:leptos_axum",
"dep:notify",
"dep:dashmap",
"dep:once_cell",
"dep:async-broadcast",
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"dep:leptos_axum",
"dep:notify",
"dep:dashmap",
"dep:once_cell",
"dep:async-broadcast",
]
[package.metadata.cargo-all-features]

View File

@@ -6,8 +6,7 @@ use server_fn::{
client::{browser::BrowserClient, Client},
codec::{
Encoding, FromReq, FromRes, GetUrl, IntoReq, IntoRes, MultipartData,
MultipartFormData, Postcard, Rkyv, SerdeLite, StreamingText,
TextStream,
MultipartFormData, Rkyv, SerdeLite, StreamingText, TextStream,
},
request::{browser::BrowserRequest, ClientReq, Req},
response::{browser::BrowserResponse, ClientRes, Res},
@@ -66,7 +65,6 @@ pub fn HomePage() -> impl IntoView {
<h2>"Alternative Encodings"</h2>
<ServerFnArgumentExample/>
<RkyvExample/>
<PostcardExample/>
<FileUpload/>
<FileUploadWithProgress/>
<FileWatcher/>
@@ -882,67 +880,3 @@ pub fn CustomClientExample() -> impl IntoView {
})>Click me</button>
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct PostcardData {
name: String,
age: u32,
hobbies: Vec<String>,
}
/// This server function uses Postcard for both input and output encoding.
/// Postcard provides efficient binary serialization, almost as fast as rkyv, while also being
/// serde compatible
#[server(input = Postcard, output = Postcard)]
pub async fn postcard_example(
data: PostcardData,
) -> Result<PostcardData, ServerFnError> {
// Simulate some processing time
tokio::time::sleep(std::time::Duration::from_millis(250)).await;
// Modify the data to demonstrate server-side changes
let mut modified_data = data.clone();
modified_data.age += 1;
modified_data.hobbies.push("Rust programming".to_string());
Ok(modified_data)
}
/// This component demonstrates the usage of Postcard encoding with server functions.
/// It allows incrementing the age of a person and shows how the data is
/// serialized, sent to the server, processed, and returned.
#[component]
pub fn PostcardExample() -> impl IntoView {
// Initialize the input data
let (input, set_input) = signal(PostcardData {
name: "Alice".to_string(),
age: 30,
hobbies: vec!["reading".to_string(), "hiking".to_string()],
});
// Create a resource that will call the server function whenever the input changes
let postcard_result = Resource::new(
move || input.get(),
|data| async move { postcard_example(data).await },
);
view! {
<h3>Using <code>postcard</code> encoding</h3>
<p>"This example demonstrates using Postcard for efficient binary serialization."</p>
<button on:click=move |_| {
// Update the input data when the button is clicked
set_input.update(|data| {
data.age += 1;
});
}>
"Increment Age"
</button>
// Display the current input data
<p>"Input: " {move || format!("{:?}", input.get())}</p>
<Transition>
// Display the result from the server, which will update automatically
// when the input changes due to the resource
<p>"Result: " {move || postcard_result.get().map(|r| format!("{:?}", r))}</p>
</Transition>
}
}

View File

@@ -9,6 +9,6 @@ lto = true
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
console_log = "1.0"
log = "0.4.22"
console_log = "1"
log = "0.4"
console_error_panic_hook = "0.1.7"

View File

@@ -2,26 +2,25 @@
name = "ssr_modes"
version = "0.1.0"
edition = "2021"
# std::sync::LazyLock is stabilized in Rust version 1.80.0
rust-version = "1.80.0"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
actix-files = { version = "0.6.6", optional = true }
actix-web = { version = "4.8", optional = true, features = ["macros"] }
console_error_panic_hook = "0.1.7"
console_log = "1.0"
leptos = { path = "../../leptos" }
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4", optional = true, features = ["macros"] }
console_error_panic_hook = "0.1"
console_log = "1"
lazy_static = "1"
leptos = { path = "../../leptos"}
leptos_meta = { path = "../../meta" }
leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router" }
log = "0.4.22"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
tokio = { version = "1.39", features = ["time"] }
wasm-bindgen = "0.2.93"
log = "0.4"
serde = { version = "1", features = ["derive"] }
thiserror = "1"
tokio = { version = "1", features = ["time"] }
wasm-bindgen = "0.2"
[features]
hydrate = ["leptos/hydrate"]
@@ -39,12 +38,12 @@ denylist = ["actix-files", "actix-web", "leptos_actix"]
skip_feature_sets = [["ssr", "hydrate"]]
[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "ssr_modes"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
# Defaults to pkg
site-pkg-dir = "pkg"
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/main.scss"

View File

@@ -1,5 +1,4 @@
use std::sync::LazyLock;
use lazy_static::lazy_static;
use leptos::prelude::*;
use leptos_meta::*;
use leptos_router::{
@@ -147,9 +146,8 @@ fn Post() -> impl IntoView {
}
// Dummy API
static POSTS: LazyLock<[Post; 3]> = LazyLock::new(|| {
[
lazy_static! {
static ref POSTS: Vec<Post> = vec![
Post {
id: 0,
title: "My first post".to_string(),
@@ -165,8 +163,8 @@ static POSTS: LazyLock<[Post; 3]> = LazyLock::new(|| {
title: "My third post".to_string(),
content: "This is my third post".to_string(),
},
]
});
];
}
#[derive(Error, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PostError {

View File

@@ -2,45 +2,42 @@
name = "ssr_modes_axum"
version = "0.1.0"
edition = "2021"
# std::sync::LazyLock is stabilized in Rust version 1.80.0
rust-version = "1.80.0"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1.7"
console_log = "1.0"
leptos = { path = "../../leptos", features = [
"hydration",
] } #"nightly", "hydration"] }
console_error_panic_hook = "0.1"
console_log = "1"
lazy_static = "1"
leptos = { path = "../../leptos", features = ["hydration" ] } #"nightly", "hydration"] }
leptos_meta = { path = "../../meta" }
leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_router = { path = "../../router" }
log = "0.4.22"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
axum = { version = "0.7.5", optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = [
"rt-multi-thread",
"macros",
"time",
log = "0.4"
serde = { version = "1", features = ["derive"] }
thiserror = "1"
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
tokio = { version = "1", features = [
"rt-multi-thread",
"macros",
"time",
], optional = true }
wasm-bindgen = "0.2.93"
wasm-bindgen = "0.2"
[features]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"leptos_meta/ssr",
"dep:leptos_axum",
"leptos_router/ssr",
"dep:axum",
"dep:tower",
"dep:tower-http",
"dep:tokio",
"leptos/ssr",
"leptos_meta/ssr",
"dep:leptos_axum",
"leptos_router/ssr",
]
[profile.release]

View File

@@ -1,5 +1,4 @@
use std::sync::LazyLock;
use lazy_static::lazy_static;
use leptos::prelude::*;
use leptos_meta::MetaTags;
use leptos_meta::*;
@@ -21,7 +20,7 @@ pub fn shell(options: LeptosOptions) -> impl IntoView {
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<AutoReload options=options.clone()/>
<AutoReload options=options.clone() />
<HydrationScripts options/>
<MetaTags/>
</head>
@@ -65,24 +64,15 @@ pub fn App() -> impl IntoView {
<a href="/admin">"Admin"</a>
<Transition>
<ActionForm action=toggle_admin>
<input
type="hidden"
name="is_admin"
value=move || {
(!is_admin.get().and_then(|n| n.ok()).unwrap_or_default())
.to_string()
}
<input type="hidden" name="is_admin"
value=move || (!is_admin.get().and_then(|n| n.ok()).unwrap_or_default()).to_string()
/>
<button>
{move || {
if is_admin.get().and_then(Result::ok).unwrap_or_default() {
"Log Out"
} else {
"Log In"
}
{move || if is_admin.get().and_then(Result::ok).unwrap_or_default() {
"Log Out"
} else {
"Log In"
}}
</button>
</ActionForm>
</Transition>
@@ -149,15 +139,9 @@ fn HomePage() -> impl IntoView {
<li>
<a href=format!("/post/{}", post.id)>{post.title.clone()}</a>
"|"
<a href=format!(
"/post_in_order/{}",
post.id,
)>{post.title.clone()} "(in order)"</a>
<a href=format!("/post_in_order/{}", post.id)>{post.title.clone()} "(in order)"</a>
"|"
<a href=format!(
"/post_partially_blocked/{}",
post.id,
)>{post.title} "(partially blocked)"</a>
<a href=format!("/post_partially_blocked/{}", post.id)>{post.title} "(partially blocked)"</a>
</li>
</For>
</ul>
@@ -220,11 +204,12 @@ fn Post() -> impl IntoView {
Ok(comments) => Ok(view! {
<h1>"Comments"</h1>
<ul>
{comments
.into_iter()
.map(|comment| view! { <li>{comment}</li> })
.collect_view()}
{comments.into_iter()
.map(|comment| view! {
<li>{comment}</li>
})
.collect_view()
}
</ul>
}),
_ => Err(PostError::ServerError),
@@ -252,19 +237,22 @@ fn Post() -> impl IntoView {
}
}>{post_view}</ErrorBoundary>
</Suspense>
<Suspense fallback=move || view! { <p>"Loading comments..."</p> }>{comments_view}</Suspense>
<Suspense fallback=move || view! { <p>"Loading comments..."</p> }>
{comments_view}
</Suspense>
}
}
#[component]
pub fn Admin() -> impl IntoView {
view! { <p>"You can only see this page if you're logged in."</p> }
view! {
<p>"You can only see this page if you're logged in."</p>
}
}
// Dummy API
static POSTS: LazyLock<[Post; 3]> = LazyLock::new(|| {
[
lazy_static! {
static ref POSTS: Vec<Post> = vec![
Post {
id: 0,
title: "My first post".to_string(),
@@ -280,8 +268,8 @@ static POSTS: LazyLock<[Post; 3]> = LazyLock::new(|| {
title: "My third post".to_string(),
content: "This is my third post".to_string(),
},
]
});
];
}
#[derive(Error, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PostError {

View File

@@ -1,13 +0,0 @@
# Generated by Cargo
# will have compiled files and executables
/target/
pkg
# These are backup files generated by rustfmt
**/*.rs.bk
# node e2e test tools and outputs
node_modules/
test-results/
end2end/playwright-report/
playwright/.cache/

Some files were not shown because too many files have changed in this diff Show More