Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(draft) Leptos 0.7 #2607

Merged
merged 619 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
619 commits
Select commit Hold shift + click to select a range
2c48b07
update todo app csr
gbj Jun 16, 2024
e69f62b
fix CSS file names
gbj Jun 16, 2024
e28e5ce
catch resource reads inside Signal during Suspense
gbj Jun 16, 2024
df6a462
don't require spawn_local for actios
gbj Jun 17, 2024
1ff1d48
chore: clippy
gbj Jun 17, 2024
f191bb8
fix: correctly escape style and class attributes
gbj Jun 17, 2024
4a80c8b
fix: can't memoize JS properties, because they can be set between sig…
gbj Jun 17, 2024
9e4c0b8
whenever we create a new root Owner, set it as the current owner, whi…
gbj Jun 18, 2024
602ac60
feat: synchronous serialized values with SharedValue
gbj Jun 19, 2024
bd1601e
default to SerdeJson encoding for resources, use new_str() for Str en…
gbj Jun 19, 2024
e4d2560
add trait impls and encodings for SharedValue
gbj Jun 19, 2024
10230d6
remove most remaining marker/placeholder elements
gbj Jun 19, 2024
ce832ce
rename from new_serde to new
gbj Jun 19, 2024
3c9c5aa
chore: clippy
gbj Jun 19, 2024
7034375
chore(ci): only run semver checks if not labeled 'breaking'
gbj Jun 21, 2024
f7ee0c4
chore(ci): add Makefiles for smaller packages
gbj Jun 21, 2024
a32c715
feat: 0.7 query signals
gbj Jun 21, 2024
c9e32b6
chore(ci): remove warnings in tests
gbj Jun 21, 2024
63f8da2
feat: Attr exposes PhantomData field (#2641)
luoxiaozero Jun 21, 2024
2a236e0
type-erase RenderEffeect functions for binary size improvements
gbj Jun 21, 2024
309a3d5
fix: correctly rebuild reactive attributes to avoid stale signals
gbj Jun 21, 2024
81c0947
fix reactive styles
gbj Jun 21, 2024
4323e30
fix tests
gbj Jun 21, 2024
76506c0
0.7 Provider component
gbj Jun 21, 2024
ba8bd2b
expose Owner::shared_context()
gbj Jun 21, 2024
35f489a
allow conversion directly from Arc signal types to MaybeSignal
gbj Jun 22, 2024
27feaf4
enable reactive-graph hydration when hydration is enabled
gbj Jun 22, 2024
3fb2d49
chore(ci): fix examples
gbj Jun 22, 2024
417d345
examples: errors_axum
gbj Jun 22, 2024
92552de
make ErrorBoundary fallback run lazily
gbj Jun 22, 2024
772a837
make Routes fallback run lazily
gbj Jun 22, 2024
c74a791
fix: signals mark subscribers dirty, but don't say they're always dir…
gbj Jun 22, 2024
bdcd4cb
regression test for 7094dee150f4cc8f7d993efb09fd9d66d1a623bf
gbj Jun 22, 2024
1182aff
chore: unused hooks
gbj Jun 22, 2024
7c5b7fc
update islands example
gbj Jun 22, 2024
d7e17a2
remove unnecessary logs
gbj Jun 22, 2024
737949c
fix example tests
gbj Jun 22, 2024
8dc7338
fix ErrorBoundary starting in error state in CSR
gbj Jun 22, 2024
a0b158f
update hackernews_axum to 0.7
gbj Jun 22, 2024
1111914
fix js-framework-benchmark for stable
gbj Jun 22, 2024
a42e371
chore: clippy
gbj Jun 22, 2024
722fd0f
fix: () in templates
gbj Jun 23, 2024
36d16d9
remove unused tests and dependencies
gbj Jun 23, 2024
2a558aa
islands example
gbj Jun 23, 2024
2916873
feat: provide static file handling/fallback directly in integration
gbj Jun 23, 2024
04e09d2
fix: remove extra comment at end of Suspense now that Either no longe…
gbj Jun 23, 2024
7ca810d
fix islands ci setup
gbj Jun 23, 2024
ae14644
update static file serving in Axum examples
gbj Jun 23, 2024
5b7f5e3
hackernews islands example
gbj Jun 23, 2024
c6192ba
fix docs for hydrate_islands
gbj Jun 23, 2024
70655b5
fix: do not accidentally mount things before meta tags in the <head> …
gbj Jun 25, 2024
8b142c7
fix: don't override a text node's 'next sibling after text' position …
gbj Jun 25, 2024
fe7c7c3
omit () entirely if it is the only child of an HTML element
gbj Jun 25, 2024
3ebea79
preliminary work on directives (not useful yet until we have an Eleme…
gbj Jun 25, 2024
095dc78
remove log
gbj Jun 25, 2024
83e0438
fix: do not accidentally mount things before meta tags in the <head> …
brofrain Jun 25, 2024
d2ee093
fix: update HtmlViewState & BodyViewState as well
brofrain Jun 25, 2024
18b33c7
updated directives example
gbj Jun 26, 2024
165a593
cargo fmt
gbj Jun 26, 2024
be92dc5
chore: suppress unnecessary .into() warning
gbj Jun 26, 2024
c187735
chore: missing Debug implementations
gbj Jun 26, 2024
fd121fd
docs: warn on unused RenderEffect
gbj Jun 26, 2024
95756aa
chore: cargo fmt
gbj Jun 26, 2024
f65eaec
feat: add ElementExt to give access to the same view APIs at runtime …
gbj Jun 26, 2024
9de6c5b
feat: add ElementExt to give access to the same view APIs at runtime …
gbj Jun 26, 2024
598c59b
make RemoveEventHandler a concrete type
gbj Jun 26, 2024
081f4ec
chore: cargo fmt
gbj Jun 26, 2024
fc59cda
examples: update directives tests
gbj Jun 26, 2024
c676cf9
Make get_configuration sync (#2647)
benwis Jun 27, 2024
61876df
fix: correct For behavior when mounting with siblings, and when clearing
gbj Jun 27, 2024
38d51b0
feat: support reactive and asynchronous ProtectedRoute conditions
gbj Jun 28, 2024
44eae4c
`0.7.0-alpha`
gbj Jun 28, 2024
a2d8fde
docs: working on memo docs
gbj Jun 28, 2024
64fc6cd
restore fallback for compressed version
gbj Jun 28, 2024
0a5e6fd
chore: unused import
gbj Jun 28, 2024
8502745
chore: update test output
gbj Jun 28, 2024
da045f7
un-break circular dependency
gbj Jun 28, 2024
efa6d60
any_spawner tick version
gbj Jun 28, 2024
61e51cb
support wasm-only
gbj Jun 28, 2024
97dc3cc
support wasm-only
gbj Jun 28, 2024
7e3781b
support wasm-only
gbj Jun 28, 2024
514c51c
fix: rebuilding AnyView
gbj Jun 29, 2024
c76208a
fix: nonexistent feature
gbj Jun 29, 2024
ce4fe63
Destructuring `let` (0.7) (#2655)
Jinxit Jun 29, 2024
88af893
fix: `<option>` struct generation
gbj Jun 29, 2024
055701e
fix: `<option>` struct generation
gbj Jun 29, 2024
2ccf5e9
Revert "lazy Future construction for AsyncDerived"
gbj Jun 30, 2024
3ed1ad7
impl `From<T>` for `(Arc)Signal<T>`
gbj Jun 30, 2024
381ff8a
fix: trait import
gbj Jun 30, 2024
180511e
fix: update imports and methods
gbj Jun 30, 2024
ddc7abf
fix: impl `Copy` for `Callback` (#2658)
brofrain Jun 30, 2024
6885777
support MaybeSignal in view
gbj Jun 30, 2024
059c8ab
chore: clippy
gbj Jun 30, 2024
8f46288
fix: ensure correct ownership chain when passing views through Outlet
gbj Jul 1, 2024
4eea1f0
remove log
gbj Jul 1, 2024
33a3708
fix: prevent panicking if conditionally rendering Outlet
gbj Jul 1, 2024
989f298
allow Outlet to be called multiple times
gbj Jul 1, 2024
f8283f4
Add missing 'form' attribute for <mo> (#2660)
lnay Jul 1, 2024
52a3f84
router alpha 2
gbj Jul 1, 2024
fd48a61
macro alpha 2
gbj Jul 1, 2024
d7ca969
blocking resources
gbj Jul 2, 2024
a68653b
feat: automatically replace Suspense blocks if they are still waiting…
gbj Jul 2, 2024
2f58191
Implement Default trait for signals with a parameter that also implem…
agraboso Jul 2, 2024
1dae77d
fix: don't break Routes SSR now that it uses Suspend
gbj Jul 2, 2024
2006eca
Form component in 0.7
gbj Jul 3, 2024
dc80e38
router alpha 3
gbj Jul 3, 2024
8b9bcff
reexport SVG and MathML element types
gbj Jul 3, 2024
746bf8e
fix: MaybeProp None case
gbj Jul 4, 2024
87f9fa2
chore: `cfg` warnings
gbj Jul 4, 2024
0cf3113
feat: local resources with .await
gbj Jul 4, 2024
4a0f173
feat: support Suspend in attributes
gbj Jul 6, 2024
208ab97
feat: move to a channel-based implementation for meta
gbj Jul 6, 2024
e9c7b50
feat: attributes on body and html
gbj Jul 6, 2024
f7b16b7
feat: correct HTML rendering for spread attributes on <Body/> and <Ht…
gbj Jul 6, 2024
504c958
docs: update syntax for Html/Body
gbj Jul 6, 2024
ccf6703
chore: clippy and clean up unused functions
gbj Jul 6, 2024
fa731d5
feat: top-level Suspend without Suspense
gbj Jul 6, 2024
67fe4cc
fix: rebuilding NodeRef
gbj Jul 8, 2024
4b539b5
fix: was disposing of Suspense Owner too early
gbj Jul 8, 2024
5d3a175
chore: remove unused dependencies
gbj Jul 8, 2024
9536480
feat: use codee for shared ser-de codexes with leptos-use (and more p…
gbj Jul 9, 2024
e1f3be6
chore: cargo fmt (#2672)
sabify Jul 9, 2024
e2721d5
fix: invalid p/ul relationship causing hydration issue
gbj Jul 10, 2024
8ac1564
fix: properly handle errors in streaming body responses
gbj Jul 10, 2024
37db7b5
chore: leptosfmt
gbj Jul 10, 2024
6ca3639
fix: improved API for unsync actions that doesn't require SendWrapper…
gbj Jul 10, 2024
db8f5e4
feat: initial work on reactive stores
gbj Jul 11, 2024
6590749
docs: initial work on porting docs from 0.6 to 0.7
gbj Jul 11, 2024
e5c159f
feat: add arena-allocated/Copy Store
gbj Jul 11, 2024
3515469
feat: iteration over reactive store list
gbj Jul 11, 2024
12a9e06
feat: additional ARIA attributes (#2677)
luoxiaozero Jul 11, 2024
2c4f11b
remove FromRef implementation from LeptosRoutes axum impl (#2670)
b4-io Jul 12, 2024
c771ab7
examples: revert changes to counter
gbj Jul 12, 2024
c72c2f4
fix: allow creating resources inside Suspense
gbj Jul 12, 2024
0a89f15
feat: type-erased store Field structs
gbj Jul 12, 2024
6290c42
fix: proper building of paths for nested fields
gbj Jul 12, 2024
efd060c
feat: Suspend on style: and class:
gbj Jul 12, 2024
04c67cb
chore: clear warnings
gbj Jul 12, 2024
62cb361
chore: clippy
gbj Jul 12, 2024
3b09312
chore: clippy
gbj Jul 12, 2024
66d6038
add allow too_many_arguments (#2684)
b4-io Jul 12, 2024
05d0114
chore: remove unused AsyncState
gbj Jul 12, 2024
8f0a8e0
docs: porting docs from 0.6 to 0.7
gbj Jul 12, 2024
dac4589
docs: finish reactive graph docs for 0.7
gbj Jul 12, 2024
ddb596f
chore: start with a default sandbox, to avoid panics in tests
gbj Jul 12, 2024
64bc258
docs: add tachys docs
gbj Jul 13, 2024
7752ab7
fix: custom elements SSR
gbj Jul 13, 2024
bf8d2e0
fix: custom elements should support any attribute names
gbj Jul 14, 2024
b24ae7a
fix: explicitly untrack the children of `<Show/>`
gbj Jul 16, 2024
93e6456
fix: require `Suspend::new()` to ensure the `Future` is properly scop…
gbj Jul 16, 2024
efb699a
docs: improved warning location
gbj Jul 16, 2024
4107203
examples: update to `Suspend::new()`
gbj Jul 16, 2024
51f368c
fix: Suspend::new() in router
gbj Jul 17, 2024
d24f97b
fix: remove unnecessary untrack in Show
gbj Jul 17, 2024
a2385e4
fix: set `None` observer properly in `ScopedFuture`
gbj Jul 17, 2024
873aec5
feat: allow using enums for `StaticSegment` by implementing `AsPath` …
mahmoud-eltahawy Jul 18, 2024
f4f129c
feat: add `path!` macro in router to parse string paths into tuples (…
boyswan Jul 19, 2024
75336bc
fix: add HTML global `on___` attributes
gbj Jul 19, 2024
28fcfe4
example: use `path!` macro in router example
gbj Jul 19, 2024
e6c2f8c
fix: allow one-element tuples for route matching
gbj Jul 19, 2024
e3482b4
feat: reintroduce `queue_microtask` (#2703)
CorvusPrudens Jul 20, 2024
8635887
feat: optional branch-marking in HTML to support initial work on clie…
gbj Jul 21, 2024
6be0900
chore: fmt
gbj Jul 21, 2024
e7a8067
fix: only create Future once initially, and poll it twice, rather tha…
gbj Jul 21, 2024
a1ca854
chore: fmt
gbj Jul 21, 2024
4fe7fe7
chore: remove `pub` field in `Suspend` so that `Suspend::new()` must …
gbj Jul 21, 2024
d4ec5e1
fix: rename nightly feature for const generic `&'static str` (https:/…
gbj Jul 22, 2024
1f2b13a
feat: allow `!Send` signals
gbj Jul 23, 2024
efe832e
fix: `hackernews_js_fetch` example for `leptos_0.7` (#2678)
sabify Jul 23, 2024
634ac1c
chore: clippy and fmt
gbj Jul 23, 2024
200047a
chore: remove unnecessary default generics
gbj Jul 24, 2024
eb29d84
docs: fix cfg for docsrs
gbj Jul 24, 2024
f7abe72
fix: add missing imports
gbj Jul 24, 2024
e3f6418
chore: clippy
gbj Jul 24, 2024
a4ce797
fix: improve type inference for the default threadsafe signal case
gbj Jul 24, 2024
be83b5f
chore: remove unused imports
gbj Jul 24, 2024
55053da
chore: clippy
gbj Jul 24, 2024
4c4d3dc
feat: mark branches in AnyView
gbj Jul 24, 2024
43421c5
example: use a local signal for the input
gbj Jul 24, 2024
6a705e2
chore: clippy
gbj Jul 24, 2024
54401c6
beta version
gbj Jul 24, 2024
4fb00e2
chore: remove unused imports
gbj Jul 25, 2024
89bbdc5
feat: patch reactive stores in place, only notifying on changed fields
gbj Jul 25, 2024
25bfc27
fix: set `<Title/>` text and formatter in context during client-side …
gbj Jul 25, 2024
d9b590b
fix: unique IDs and correct hydration for `<ErrorBoundary/>` (closes …
gbj Jul 25, 2024
8b9685e
fix: `throw_error` version
gbj Jul 25, 2024
1534dd5
fix: CSR `<ErrorBoundary/>`
gbj Jul 25, 2024
1c05389
fix: prevent LocalResource from spawning a local task on the server, …
gbj Jul 26, 2024
30cf116
fix: correct re-exports for islands with props (closes #2723)
gbj Jul 26, 2024
b92bfa4
docs: suppress warning about wrong client-side mode after initial cal…
gbj Jul 27, 2024
1aa2752
fix: if island is not entry point, update hydration cursor correctly …
gbj Jul 27, 2024
0f50ace
fix: tracking/notifications for AsyncDerived if they start with initi…
gbj Jul 27, 2024
260c624
fix: serializing island props (closes #2730)
gbj Jul 28, 2024
a6a65ba
fix: release borrow on shared context when hydrating island (closes #…
gbj Jul 28, 2024
29b0dca
fix: allow Suspense to remount before rebuilding (closes #2721)
gbj Jul 28, 2024
5fb80aa
fix: cancel action when original owner, not current owner, is cleaned…
gbj Jul 28, 2024
f2d6375
fix: never resolve LocalResource synchronously (closes #2736)
gbj Jul 28, 2024
8c37553
fix: `leptos_router_macro::path` into public api (#2737)
chrisp60 Jul 28, 2024
6cc0604
fix: no longer necessary to 'seal' ErrorBoundary (closes #2738)
gbj Jul 29, 2024
dcc43e5
fix: correctly handle Action abort if it has already completed (close…
gbj Jul 29, 2024
a51faea
fix: abort when leaving *this* owner, but don't force it if already c…
gbj Jul 29, 2024
11011c2
fix: correct async resolution for islands (closes #2734)
gbj Jul 29, 2024
c22f20a
feat: add `Effect::watch` (#2732)
maccesch Jul 29, 2024
6c749f5
fix: provide a hydration context during route generation
gbj Jul 29, 2024
24775fb
fix: properly handle islands used in the body of other islands (close…
gbj Jul 29, 2024
4fa72a9
feat: allow reusing the same endpoint for server functions with diffe…
gbj Jul 30, 2024
93c893f
fix: use correct Request type in Actix extractor
gbj Jul 30, 2024
632ce0f
fix merge issues
gbj Jul 30, 2024
3e05b5b
feat: support `class = ` in view macro
gbj Jul 30, 2024
ab3e94d
chore: clippy
gbj Jul 30, 2024
213365e
chore: clippy
gbj Jul 31, 2024
a2d3d94
feat: support memos with `!Send` values
gbj Jul 31, 2024
c88409a
fix: update reactive views for new requirements
gbj Jul 31, 2024
04f5207
fix: be ready to complete navigation immediately
gbj Jul 31, 2024
9330cf2
fix: set default storage type for SignalTypes
gbj Jul 31, 2024
27f2e60
chore: clean up unused imports in tests
gbj Jul 31, 2024
c953432
chore: fmt
gbj Aug 1, 2024
f2f35cd
chore: fix imports in tests
gbj Aug 1, 2024
3a4ad07
chore: remove unused dependencies
gbj Aug 1, 2024
0e979a0
chore: remove dead code from `leptos_dom` (now found in `tachys`)
gbj Aug 1, 2024
d1d6126
chore: add makefile for CI
gbj Aug 1, 2024
dbb4c79
chore: remove unused features
gbj Aug 1, 2024
0599906
feat: add `create_slice` functions
gbj Aug 1, 2024
8beb988
chore: update tests and doctests
gbj Aug 1, 2024
84ac642
chore: update tests and doctests
gbj Aug 1, 2024
05cd1bc
chore: proper feature gating for imports
gbj Aug 1, 2024
bb63a15
chore: update tests and doctests
gbj Aug 1, 2024
805be42
chore: fix doctest
gbj Aug 1, 2024
5ad17d6
fix: correct thread-local behavior for Effects (closes #2754)
gbj Aug 1, 2024
c43b71d
chore: update examples and doctests
gbj Aug 2, 2024
35b457a
chore: update examples and doctests
gbj Aug 2, 2024
114df87
chore: clippy
gbj Aug 2, 2024
ac751dd
chore(ci): update nightly
gbj Aug 2, 2024
71ca02a
chore: clippy
gbj Aug 2, 2024
605e4b1
chore: update examples and doctests
gbj Aug 2, 2024
34382c0
chore: fix ssr tests
gbj Aug 2, 2024
82ea4eb
chore: fix ssr tests
gbj Aug 2, 2024
00fb8f2
fix: do not pass SendWrappers through Suspense (closes #2756)
gbj Aug 2, 2024
25f0186
chore: update tests
gbj Aug 2, 2024
54e4205
chore: update tests
gbj Aug 2, 2024
4845459
chore: update tests
gbj Aug 3, 2024
a0ad927
fix: generated tests should not use old APIs
gbj Aug 3, 2024
982bfd8
feat: allow aborting dispatched actions (closes #2746)
gbj Aug 3, 2024
1d97494
fix: update syntax now that dispatch returns something
gbj Aug 3, 2024
9ba8947
chore: fmt
gbj Aug 3, 2024
42a8e49
feat: provide deprecated `watch` function (#2761)
CorvusPrudens Aug 4, 2024
dcdad73
chore: fmt
gbj Aug 4, 2024
c700092
fix: allow svg elements to use inner_html (#2764)
luoxiaozero Aug 4, 2024
026152d
fix: correctly rebuild reactive attributes to avoid stale signals (#2…
luoxiaozero Aug 4, 2024
3dbedfc
feat: reintroduce custom events (#2762)
CorvusPrudens Aug 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/ci-semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:

test:
needs: [get-leptos-changed]
if: needs.get-leptos-changed.outputs.leptos_changed == 'true'
name: Run semver check (nightly-2024-07-21)
if: needs.get-leptos-changed.outputs.leptos_changed == 'true' && github.event.pull_request.labels[0].name != 'breaking'
name: Run semver check (nightly-2024-08-01)
runs-on: ubuntu-latest

steps:
Expand All @@ -25,4 +25,4 @@ jobs:
- name: Semver Checks
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
rust-toolchain: nightly-2024-07-21
rust-toolchain: nightly-2024-08-01
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
matrix:
directory:
[
any_error,
any_spawner,
const_str_slice_concat,
either_of,
hydration_context,
integrations/actix,
integrations/axum,
integrations/utils,
Expand All @@ -28,10 +33,14 @@ jobs:
leptos_dom,
leptos_hot_reload,
leptos_macro,
leptos_reactive,
leptos_server,
meta,
next_tuple,
oco,
or_poisoned,
reactive_graph,
router,
router_macro,
server_fn,
server_fn/server_fn_macro_default,
server_fn_macro,
Expand All @@ -40,4 +49,4 @@ jobs:
with:
directory: ${{ matrix.directory }}
cargo_make_task: "ci"
toolchain: nightly-2024-07-21
toolchain: nightly-2024-08-01
16 changes: 14 additions & 2 deletions .github/workflows/get-leptos-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,29 @@ jobs:
uses: tj-actions/changed-files@v43
with:
files: |
integrations/**
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_reactive/**
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
Expand Down
55 changes: 39 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ resolver = "2"
members = [
# utilities
"oco",
"any_spawner",
"const_str_slice_concat",
"either_of",
"next_tuple",
"oco",
"or_poisoned",

# core
"hydration_context",
"leptos",
"leptos_dom",
"leptos_config",
"leptos_hot_reload",
"leptos_macro",
"leptos_reactive",
"leptos_server",
"reactive_graph",
"reactive_stores",
"reactive_stores_macro",
"server_fn",
"server_fn_macro",
"server_fn/server_fn_macro_default",
"tachys",

# integrations
"integrations/actix",
Expand All @@ -24,28 +34,41 @@ members = [
# libraries
"meta",
"router",
"router_macro",
"any_error",
]
exclude = ["benchmarks", "examples"]

[workspace.package]
version = "0.6.13"
version = "0.7.0-beta"
rust-version = "1.75"

[workspace.dependencies]
oco_ref = { path = "./oco", version = "0.1.0" }
leptos = { path = "./leptos", version = "0.6.13" }
leptos_dom = { path = "./leptos_dom", version = "0.6.13" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.6.13" }
leptos_macro = { path = "./leptos_macro", version = "0.6.13" }
leptos_reactive = { path = "./leptos_reactive", version = "0.6.13" }
leptos_server = { path = "./leptos_server", version = "0.6.13" }
server_fn = { path = "./server_fn", version = "0.6.13" }
server_fn_macro = { path = "./server_fn_macro", version = "0.6.13" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.6" }
leptos_config = { path = "./leptos_config", version = "0.6.13" }
leptos_router = { path = "./router", version = "0.6.13" }
leptos_meta = { path = "./meta", version = "0.6.13" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.6.13" }
throw_error = { path = "./any_error/", version = "0.2.0-beta" }
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-beta" }
leptos = { path = "./leptos", version = "0.7.0-beta" }
leptos_config = { path = "./leptos_config", version = "0.7.0-beta" }
leptos_dom = { path = "./leptos_dom", version = "0.7.0-beta" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-beta" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-beta" }
leptos_macro = { path = "./leptos_macro", version = "0.7.0-beta" }
leptos_router = { path = "./router", version = "0.7.0-beta" }
leptos_router_macro = { path = "./router_macro", version = "0.7.0-beta" }
leptos_server = { path = "./leptos_server", version = "0.7.0-beta" }
leptos_meta = { path = "./meta", version = "0.7.0-beta" }
next_tuple = { path = "./next_tuple", version = "0.1.0-beta" }
oco_ref = { path = "./oco", version = "0.2" }
or_poisoned = { path = "./or_poisoned", version = "0.1" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0-beta" }
reactive_stores = { path = "./reactive_stores", version = "0.1.0-beta" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0-beta" }
server_fn = { path = "./server_fn", version = "0.7.0-beta" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-beta" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-beta" }
tachys = { path = "./tachys", version = "0.1.0-beta" }

[profile.release]
codegen-units = 1
Expand Down
40 changes: 40 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- core examples
- [x] counter
- [x] counters
- [x] fetch
- [x] todomvc
- [x] error_boundary
- [x] parent\_child
- [x] on: on components
- [ ] router
- [ ] slots
- [ ] hackernews
- [ ] counter\_isomorphic
- [ ] todo\_app\_sqlite
- other ssr examples
- [ ] error boundary SSR
- reactivity
- Signal wrappers
- SignalDispose implementations on all Copy types
- untracked access warnings
- ErrorBoundary
- [ ] RenderHtml implementation
- [ ] Separate component?
- Suspense/Transition components?
- callbacks
- unsync StoredValue
- SSR
- escaping HTML correctly (attributes + text nodes)
- router
- nested routes
- trailing slashes
- \_meta package (and use in hackernews)
- integrations
- update tests
- hackernews example
- TODOs
- Suspense/Transition/Await components
- nicer routing components
- async routing (waiting for data to load before navigation)
- `<A>` component
- figure out rebuilding issues: list (needs new signal IDs) vs. regular rebuild
13 changes: 13 additions & 0 deletions any_error/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "throw_error"
edition = "2021"
version = "0.2.0-beta"
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

[dependencies]
pin-project-lite = "0.2"
File renamed without changes.
2 changes: 2 additions & 0 deletions any_error/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A utility library for wrapping arbitrary errors, and for “throwing” errors in a way
that can be caught by user-defined error hooks.
165 changes: 165 additions & 0 deletions any_error/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#![forbid(unsafe_code)]
#![deny(missing_docs)]

//! A utility library for wrapping arbitrary errors, and for “throwing” errors in a way
//! that can be caught by user-defined error hooks.

use std::{
cell::RefCell,
error,
fmt::{self, Display},
future::Future,
mem, ops,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};

/* Wrapper Types */

/// This is a result type into which any error can be converted.
///
/// Results are stored as [`Error`].
pub type Result<T, E = Error> = core::result::Result<T, E>;

/// A generic wrapper for any error.
#[derive(Debug, Clone)]
#[repr(transparent)]
pub struct Error(Arc<dyn error::Error + Send + Sync>);

impl Error {
/// Converts the wrapper into the inner reference-counted error.
pub fn into_inner(self) -> Arc<dyn error::Error + Send + Sync> {
Arc::clone(&self.0)
}
}

impl ops::Deref for Error {
type Target = Arc<dyn error::Error + Send + Sync>;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}

impl<T> From<T> for Error
where
T: error::Error + Send + Sync + 'static,
{
fn from(value: T) -> Self {
Error(Arc::new(value))
}
}

/// Implements behavior that allows for global or scoped error handling.
///
/// This allows for both "throwing" errors to register them, and "clearing" errors when they are no
/// longer valid. This is useful for something like a user interface, in which an error can be
/// "thrown" on some invalid user input, and later "cleared" if the user corrects the input.
/// Keeping a unique identifier for each error allows the UI to be updated accordingly.
pub trait ErrorHook: Send + Sync {
/// Handles the given error, returning a unique identifier.
fn throw(&self, error: Error) -> ErrorId;

/// Clears the error associated with the given identifier.
fn clear(&self, id: &ErrorId);
}

/// A unique identifier for an error. This is returned when you call [`throw`], which calls a
/// global error handler.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Default)]
pub struct ErrorId(usize);

impl Display for ErrorId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt(&self.0, f)
}
}

impl From<usize> for ErrorId {
fn from(value: usize) -> Self {
Self(value)
}
}

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))),
)
}

/// Invokes the error hook set by [`set_error_hook`] with the given error.
pub fn throw(error: impl Into<Error>) -> ErrorId {
ERROR_HOOK
.with_borrow(|hook| hook.as_ref().map(|hook| hook.throw(error.into())))
.unwrap_or_default()
}

/// Clears the given error from the current error hook.
pub fn clear(id: &ErrorId) {
ERROR_HOOK
.with_borrow(|hook| hook.as_ref().map(|hook| hook.clear(id)))
.unwrap_or_default()
}

pin_project_lite::pin_project! {
/// A [`Future`] that reads the error hook that is set when it is created, and sets this as the
/// current error hook whenever it is polled.
pub struct ErrorHookFuture<Fut> {
hook: Option<Arc<dyn ErrorHook>>,
#[pin]
inner: Fut
}
}

impl<Fut> ErrorHookFuture<Fut> {
/// Reads the current hook and wraps the given [`Future`], returning a new `Future` that will
/// set the error hook whenever it is polled.
pub fn new(inner: Fut) -> Self {
Self {
hook: ERROR_HOOK.with_borrow(Clone::clone),
inner,
}
}
}

impl<Fut> Future for ErrorHookFuture<Fut>
where
Fut: Future,
{
type Output = Fut::Output;

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)));
this.inner.poll(cx)
}
}
Loading