Repository navigation
Releases
effect-atom-svelte@0.5.1
Patch Changes
- 00a334e: A
HydrationBoundaryno longer runs a hydrated atom's effect again during the server render. An effect or stream atom whoseSuccessorFailurealoadfunction dehydrated now renders that result on the server without repeating the request, as it did before Effect 4.1, with or withoutskipInitialRun. A promise-encodedInitial(Hydration.dehydrate(registry, { encodeInitialAs: "promise" })) is still waited for during the render, and so is a stream'sSuccessthat is still waiting when read withuseAtomResultoruseAtomSuspenseandsuspendOnWaiting: true: the stream runs again, and the settled result is what the server renders and sends. The browser is unchanged: there, the atom runs again once read unless itsAtom.serializablesetsskipInitialRun: true. - 5c9f007: Correct the API docs that ship with the packages, as editors show them on hover, and the package READMEs. The hooks say they hold an atom, instead of "mounted" or "kept alive";
useAtomSetsays how concurrentAtom.fncalls settle, and thatAtom.InterruptandAtom.Resetdon't stop them;useAtomResultanduseAtomSuspensesay when a hydrated atom runs again in the browser, and that they must be called before a component's firstawait;HydrationBoundarysays an effect or stream atom it hydrates runs again once read unless it setsskipInitialRun; and the form docs say which errors clear when. The README says only the async hooks need Svelte's experimental async. The "This atom value is read-only" error also namesuseAtomResult. - 68f2584: On the server,
useAtomSuspensewithsuspendOnWaitingrenders a still-waiting value fromuseAtomInitialValuesas is, asuseAtomResultalready does, instead of running the atom and waiting for it. With a synchronous effect, that wait never ended and the server render hung.
effect-atom-svelte-devtools@0.4.1
Patch Changes
- 5c9f007: Correct the API docs that ship with the packages, as editors show them on hover, and the package READMEs. The hooks say they hold an atom, instead of "mounted" or "kept alive";
useAtomSetsays how concurrentAtom.fncalls settle, and thatAtom.InterruptandAtom.Resetdon't stop them;useAtomResultanduseAtomSuspensesay when a hydrated atom runs again in the browser, and that they must be called before a component's firstawait;HydrationBoundarysays an effect or stream atom it hydrates runs again once read unless it setsskipInitialRun; and the form docs say which errors clear when. The README says only the async hooks need Svelte's experimental async. The "This atom value is read-only" error also namesuseAtomResult. - Updated dependencies [00a334e]
- Updated dependencies [5c9f007]
- Updated dependencies [68f2584]
- effect-atom-svelte@0.5.1
effect-atom-svelte@0.5.0
Minor Changes
-
a659d81: Move to Effect 4.1: the
effectpeer range is now~4.1.0, so upgradeeffectto 4.1 alongside this release. The devtools needeffect-atom-svelte0.5.useAtomInitialValuestakes the entries Effect 4.1'sAtom.initialValuemakes, options included, asRegistryProvider'sinitialValuesalready does. Give an effect or stream atomAtom.initialValue(atom, value, { skipInitialRun: true })to keep the value in the browser instead of running the atom again on mount, as for data aloadfunction already fetched. It runs once it is refreshed.With Effect 4.1, an effect or stream atom a
HydrationBoundaryhydrates runs again in the browser once something reads it, as Effect'sHydration.hydratenow does, and shows the server's result until the browser's arrives. On 4.0 only atoms wrapped byAtom.withReactivityand similar did. To keep the server's result, give the atomAtom.serializable({ key, schema, skipInitialRun: true }). The hooks (useAtomResult,useAtomSuspense) still run nothing again unless you setrevalidateOnHydrate. -
15d04f9: Add
remoteQueryAtomtoeffect-atom-svelte/sveltekit(unstable): it turns a SvelteKit 3 remotequeryorquery.liveinto an atom that follows every change SvelteKit makes to it — a refresh, a.set(), a command's single-flight update, an optimisticwithOverrideand live pushes — and starts in the browser from the result the server render sent. In development, reading one withuseAtomValueon the server warns that the server rendersInitial.
Patch Changes
- 2ea38eb: A form field's
dirtyin an array item now compares with that item's own initial value, wherever the item has moved. Removing or moving items no longer marks the other items' fields dirty. An item added since (byappendorreplace) has no initial value, so its fields read dirty.revertToLastSubmitbrings each item back with its own key, so an item that was there all along keeps its touched state, and every field reads clean again. - 68410a6: A form's submit always settles now. When the
RegistryProviderholding the form is destroyed mid-submit (a dialog with its own provider, closed while it saves),submit()resolves as interrupted instead of rejecting with "registry is disposed", or hanging forever when an async check was still running;validate()resolvesfalsethere too. Apayload,mapErrororAtom.fnthat throws ends the submit as a defect insubmitResult, rather than leavingsubmittingtrue for good. AnduseAtomSet'spromiseExitmode resolves withExit.diewhen theAtom.fnthrows before returning its Effect, instead of rejecting. - 0740552:
useAtomResultanduseAtomSuspensenow send the server's result for anAtomRpcorAtomHttpApiquery with both aserializationKeyand astaleTime, and for any serializable atom wrapped inAtom.swr. The wrapper isn't serializable itself, so before, the browser fetched the query again while hydrating. The hooks now send the result under the wrapped atom's key, andstaleTimedecides in the browser whether it's fresh, counting from when the server fetched it. A plain read on the server of such a query still running now gets the development warning that its result isn't sent, as a serializable atom's does. - 7bd8c74:
useAtomSubscribeno longer breaks its component when the atom's first computation throws, such as a derived atom parsing bad input. The error is left to the atom's readers, as in@effect/atom-react, and the callback hears the atom once it recovers. Withimmediate, the error still reaches the component, since there is no value to call the callback with. - 649cba1: More error messages and development warnings end with a link to their entry on the troubleshooting page: a scoped atom's
use()outside its provider,useAtomSetwaiting forAtom.Reset, an async hook meeting an atom that has not started on the server,RegistryProvider's props changing, and a serializable atom's result that doesn't encode or decode with its schema. The warning for a plain read on the server of a serializable atom still running now links to a new entry there, instead of to the Hydration page.
effect-atom-svelte-devtools@0.4.0
Minor Changes
-
a659d81: Move to Effect 4.1: the
effectpeer range is now~4.1.0, so upgradeeffectto 4.1 alongside this release. The devtools needeffect-atom-svelte0.5.useAtomInitialValuestakes the entries Effect 4.1'sAtom.initialValuemakes, options included, asRegistryProvider'sinitialValuesalready does. Give an effect or stream atomAtom.initialValue(atom, value, { skipInitialRun: true })to keep the value in the browser instead of running the atom again on mount, as for data aloadfunction already fetched. It runs once it is refreshed.With Effect 4.1, an effect or stream atom a
HydrationBoundaryhydrates runs again in the browser once something reads it, as Effect'sHydration.hydratenow does, and shows the server's result until the browser's arrives. On 4.0 only atoms wrapped byAtom.withReactivityand similar did. To keep the server's result, give the atomAtom.serializable({ key, schema, skipInitialRun: true }). The hooks (useAtomResult,useAtomSuspense) still run nothing again unless you setrevalidateOnHydrate.
Patch Changes
effect-atom-svelte@0.4.1
Patch Changes
- 27d4a1b: Form:
leafHooknow names a value outside a union, such as a select whose value isn't one of itsSchema.Literals. It used to get Effect's ownExpected "a" | "b"whatever the hook returned. The hook receives it as anInvalidTypewhoseastis the union, as it already did for a singleSchema.Literal. - d711a99: Fix tuple fields receiving the first element's HTML constraints instead of the constraints for their own position (#60).
- 1d6ab95: Form: a field after a tuple's rest element, as in
Schema.TupleWithRest(Schema.Tuple([A]), [B, C]), now gets its own HTML constraints (C's), not the rest element's. The trailing elements are counted from the array's end, as Effect's parser counts them, so a field's constraints follow the array as it grows (#68).
effect-atom-svelte@0.4.0
Minor Changes
-
85d302a: Add forms built from one Effect Schema (#60).
Form.makedefines a form,useFormcreates an instance in a component andForm.instancecreates one without Svelte. An instance gives each field a bindable value, an error that shows at the right time (validateOn,revalidateOn,debounce), attributes that wire an input to its error, and HTML constraints read from the Schema's checks. Its submit decodes the values and writes them to a mutation, holds it until it settles, maps typed failures onto fields withmapError, and leaves the rest insubmitResult.field.issuegives the latest check's message before the timing shows it, for a live checklist. An instance's atoms are labelled with the form'sname(SignUp.values,SignUp.state,SignUp.check). Array fields keep each item's errors and touched state with it when items move, andform.athands part of a form to a component.effect-atom-svelte/sveltekitaddsuseUnsavedChangesGuard, which asks before leaving a page whose form has unsaved changes. The module now imports$app/navigation, so it loads only inside a SvelteKit app, where itshandleErrorhooks were already used.
Patch Changes
- b5033af: Internal tidy-ups from stricter, type-aware linting: fewer type assertions, and Effect 4.0.5's public registry members in place of private ones. No change to the API or behaviour.
effect-atom-svelte-devtools@0.3.0
effect-atom-svelte@0.3.0
Minor Changes
- 4208ce3: Re-export Effect's
Reactivitymodule besideAtom,AtomRegistryand the othereffect/reactivitymodules, so the reactivity keys mutations refresh can be used fromeffect-atom-sveltetoo. - 4f0d922:
useAtomRefanduseAtomRefPropValuereturn acurrentyou can assign for a writableAtomRef, which sets the ref or the property, sobind:value={name.current}works as it does withuseAtom. A read-only ref, such as one frommap, still returns a read-onlycurrent.
Patch Changes
-
72bc355: Fix several edge cases in server rendering and hydration:
- On the server,
useAtomResultanduseAtomSuspenserender a value fromuseAtomInitialValueswithout running the atom, asuseAtomValuealready did, so a browser-only read or a request the value was there to save no longer runs on the server. - With
suspendOnWaiting, the result sent to the browser is the settled one the server rendered, not one still waiting, which the browser would run again. This holds when another component reading the same atom withoutsuspendOnWaitingrendered first. - On the server,
HydrationBoundaryignores a value dehydrated as a promise that lands after the render, so it can no longer reach a later request through a registry the caller passes in. One that lands during the render is still what the server renders. - Destroying a
HydrationBoundarykeeps the values another boundary given the same state queued, as a layout and its page might be. - A seeded
useAtomSuspenseread in the script, outside any reaction, lets go of its atom once the getter moves on. - A hook after a top-level
awaitno longer warns in development about a missed seed for an atom whose result the server didn't send, such as a defect.
- On the server,
-
73101b0: The devtools no longer carry a mapped atom's value across a hot reload:
Atom.make(1).pipe(Atom.map(...))wrote its mapped value back into its source, so set to 5 it read 10, then 20 after the reload. Only pipes that leave an atom holding what is written to it (keepAlive,autoDispose,setIdleTTL,setLazy,withEquality,withLabel,serializable,withServerValue,withServerValueInitial) keep their value.Atoms declared in a SvelteKit route group, such as
src/routes/(app)/+page.svelte, now show and open their real file, including those labelled withAtom.withLabel. The panel follows ashortcutprop the app changes after it has saved its settings, including settings saved by earlier versions, and keeps a shortcut chosen in the settings even when it is the default. A comment that mentions<svelte:head>before a component's script no longer stops its atoms being labelled.atomLabels()no longer warns that components aren't labelled when it comes after vite-plugin-svelte 7, which labels them.The inspector no longer reports a computation as
Refreshedwhen an earlier refresh changed nothing and a parent changed since. -
85be511: Error messages now end with a link to their entry on the troubleshooting page. "This atom value is read-only" also names the hooks that only read and the ones to write with instead, and "Two different atoms share the serialization key" says why the server can't render it and what to change.
-
7e2bc5c: A server render that fails while a serializable atom's result is still being prepared for the browser no longer reports an unhandled rejection ("registry is disposed"). The provider disposes of its registry when the failed render ends, and the pending result now stops there instead of reading from it.
-
63f9cfb: Fix atoms given a value by
useAtomInitialValuesbeing dropped while another component still held them: when one of two components seeding the same atom unmounted, the atom lost its value, and on the server a request sharing the registry could run the atom's browser-only read. On the server, requests rendering at the same time on a shared registry now keep the value the first one applied until the last of them ends.provideRegistrynow disposes of the registry it created when its component is destroyed while its script is still awaiting. A reader whose getter switched to an atom that threw while subscribing now follows that atom once it recovers.handleClientErroruses SvelteKit 2's message for an error whose own message is empty, such as aData.TaggedError. -
22a7551: Fix three cases where server-rendered state reached the browser wrongly:
- Remounting a component that makes its own serializable atom, such as a
ScopedAtomprovider under{#key}with its input in the serialization key, no longer throwsTwo different atoms share the serialization key. Svelte sets up the new copy before it destroys the old one, so for a moment both hold the key. In the browser, the server's value now belongs to the key, not to the atom that first claimed it, so the new copy shares it, as both already share the registry's value. The server render still throws. - The browser's first render inside a
HydrationBoundarynow matches the server's markup when the atom already exists, as with a value fromRegistryProvider'sinitialValuesor an atom also read above the boundary. While the page hydrates, the boundary updates those atoms before its children render, as the server does. This needs Svelte'sexperimental.async; without it they are updated after the first render, as before. Each server-rendered page with aHydrationBoundarycarries one more smallhydratableentry for this. - In the browser, a value dehydrated as a promise that lands after its
HydrationBoundaryis destroyed, including one destroyed while its children were still loading, is ignored, so it no longer reaches whoever reads the atom later. A reader that already held the atom when the boundary was destroyed, such as a layout's reader above it, still gets the value.
- Remounting a component that makes its own serializable atom, such as a
-
c64799e: Fix
useAtomSuspensewithincludeFailureresolving, after it waited, with a copy of the atom's result rather than the result itself. The copy lost aFailure'spreviousSuccess, soAsyncResult.getOrElseandAsyncResult.valueno longer fell back to the last value. It showed in a promise awaited in the script or an event handler. -
5d0a215: Make the inspector report more accurately, which the devtools show:
- An inspector scope's snapshot and
ScopeChangedfollow an atom in the scope that switches what it reads, also when it mounts, subscribes to or writes another atom while computing, and also while nothing listens to the scope. Interrupted(a cross in the devtools) is reported only for the effect atom whose fiber was interrupted, not also for a wrapper passing its result on, such asAtom.debounce,makeRefreshOnSignalorrefreshOnWindowFocus, and not for anAtom.runtimereleased while its layer builds, which carries on.idleTTLgivesundefinedfor an atom with an idle TTL of 0, which is removed as soon as nothing reads it.
- An inspector scope's snapshot and
-
f6f0c9c: Fix several things
effect-atom-svelte/inspectorreported wrongly. A lazy atom no longer names a parent as the cause of its next computation when that parent changed while the atom was computing, before the atom read it. A node with an initial value (initialValues) that hasn't computed yet reports its first computation as a first read. A node removed after its idle TTL reports its interruption and finalizers before its removal, as other removals do.registry.resetreports the readers it drops. In a scope, a component reading a serializable atom whose node another atom object with the same key made (as after a hot reload) points at that node. The docs now say a refresh signal (refreshOnWindowFocus,makeRefreshOnSignal,swr) is reported asRefreshed, as it always was.Fix the devtools labelling a component with a
genericsattribute holding>wrongly, and taking a<script>inside<svelte:head>for the component's script: an inline head script got animportthat broke the page, and a JSON-LD script stopped the component's atoms being labelled. A shortcut recorded with a key whose code has several words (ArrowUp,PageDown,BracketLeft) now opens the panel once saved, and is shown as such rather than asArrowup. The graph puts both sides of a diamond to the right of its source whichever atom a scope lists first. -
456cf7c: Fix pending
useAtomSetcalls and initial values in edge cases:- A
"promise"or"promiseExit"call no longer hangs when theRegistryProviderthat created its registry is destroyed mid-call: the call is interrupted and the promise settles as interrupted. A registry you pass in yourself is still yours to dispose of. - A
"promise"or"promiseExit"call pending when another setter writesAtom.Resetsettles as interrupted, instead of hanging, or resolving with theinitialValueof anAtom.fnthat has one.Atom.Interruptremains the way to cancel a call. useAtomInitialValueslets go of the entries it applied when a later entry throws, so on the server a registry shared between requests no longer renders the failed request's value in the next one.- A finalizer that throws while a
RegistryProvider(orprovideRegistrywithout aregistry) disposes of its registry in the browser is reported as an uncaught error after teardown, instead of being thrown into Svelte's teardown, where it left every$derivedon the page running again on every read until reload.
- A
-
5c740ad: A reader whose atom is built for the first time by its own read, after the component has mounted, no longer updates a second time with the value it just read.
useAtomValue(() => family(id), transform)ran the transform twice whenidswitched to an atom not built yet, returning a new object for an unchanged value; an$effectthat first read an atom ran twice; and code after awaitinguseAtomSuspenseof an atom that resolves at once, in an$effect, ran twice. -
67d468b: Fix the first refresh of an atom with a value from `initialValue...
effect-atom-svelte-devtools@0.2.2
Patch Changes
-
73101b0: The devtools no longer carry a mapped atom's value across a hot reload:
Atom.make(1).pipe(Atom.map(...))wrote its mapped value back into its source, so set to 5 it read 10, then 20 after the reload. Only pipes that leave an atom holding what is written to it (keepAlive,autoDispose,setIdleTTL,setLazy,withEquality,withLabel,serializable,withServerValue,withServerValueInitial) keep their value.Atoms declared in a SvelteKit route group, such as
src/routes/(app)/+page.svelte, now show and open their real file, including those labelled withAtom.withLabel. The panel follows ashortcutprop the app changes after it has saved its settings, including settings saved by earlier versions, and keeps a shortcut chosen in the settings even when it is the default. A comment that mentions<svelte:head>before a component's script no longer stops its atoms being labelled.atomLabels()no longer warns that components aren't labelled when it comes after vite-plugin-svelte 7, which labels them.The inspector no longer reports a computation as
Refreshedwhen an earlier refresh changed nothing and a parent changed since. -
781e948: A failed atom's sheet now shows what it failed with, fields and all, such as
CityNotFound { city: "Atlantis" }, above the full cause. Sheets writeNaN,Infinityandundefinedfields as they are instead of showingnullor dropping the field. A map whose keys are objects, or whose keys read the same as strings (1and"1"), is shown as[key, value]pairs so no entry is lost, and a map, set or object over 50 entries now says how many more it has, as arrays already did.Clear empties the timeline while it is paused. The timeline's "only this atom" filter is dropped when the panel switches to another registry, instead of picking an unrelated atom there. The graph keeps the selected atom marked when the graph's layout changes.
-
f6f0c9c: Fix several things
effect-atom-svelte/inspectorreported wrongly. A lazy atom no longer names a parent as the cause of its next computation when that parent changed while the atom was computing, before the atom read it. A node with an initial value (initialValues) that hasn't computed yet reports its first computation as a first read. A node removed after its idle TTL reports its interruption and finalizers before its removal, as other removals do.registry.resetreports the readers it drops. In a scope, a component reading a serializable atom whose node another atom object with the same key made (as after a hot reload) points at that node. The docs now say a refresh signal (refreshOnWindowFocus,makeRefreshOnSignal,swr) is reported asRefreshed, as it always was.Fix the devtools labelling a component with a
genericsattribute holding>wrongly, and taking a<script>inside<svelte:head>for the component's script: an inline head script got animportthat broke the page, and a JSON-LD script stopped the component's atoms being labelled. A shortcut recorded with a key whose code has several words (ArrowUp,PageDown,BracketLeft) now opens the panel once saved, and is shown as such rather than asArrowup. The graph puts both sides of a diamond to the right of its source whichever atom a scope lists first. -
073fbdf: Fix
atomLabelstreating some scripts in a component as its own:- A
<script>in the markup (inside an element or a block, such as JSON-LD or an inline analytics snippet) is left alone as page HTML. Before, it could stop the component's atoms being labelled, receive the component-naming import (aSyntaxErrorwhen the page loads), or have its calls wrapped in the label helper (aReferenceError). - A comment in
<script module>that mentions<svelte:head>no longer stops the instance script's atoms being labelled.
- A
-
Updated dependencies [72bc355]
-
Updated dependencies [73101b0]
-
Updated dependencies [85be511]
-
Updated dependencies [7e2bc5c]
-
Updated dependencies [63f9cfb]
-
Updated dependencies [22a7551]
-
Updated dependencies [c64799e]
-
Updated dependencies [5d0a215]
-
Updated dependencies [f6f0c9c]
-
Updated dependencies [456cf7c]
-
Updated dependencies [5c740ad]
-
Updated dependencies [4208ce3]
-
Updated dependencies [67d468b]
-
Updated dependencies [876bdd1]
-
Updated dependencies [dfd7db3]
-
Updated dependencies [473c6e1]
-
Updated dependencies [e0d92a1]
-
Updated dependencies [c64799e]
-
Updated dependencies [c01da28]
-
Updated dependencies [85be511]
-
Updated dependencies [4f0d922]
- effect-atom-svelte@0.3.0
effect-atom-svelte@0.2.0
Minor Changes
- 7dabe68: Add
effect-atom-svelte/inspector, for developer tools.inspect(registry)reports what a registry does to its atoms: each node added and removed, each computation and why it ran (first read, a parent changed, a refresh), each new value and where it came from, readers coming and going, interruptions and finalizers.registries()andwatchRegistrieslist the registries an app's providers hold, in the browser during development.provideInspectorScope()makes a part of the component tree a scope: the hooks below it report the atoms they use, and the scope shows those atoms, everything upstream of them and the hooks, with events for just those atoms; it works in production too, for pages that draw their own atoms.nameComponent(name, file)names a component for the scopes its hooks report to. A registry nobody inspects runs as before, and production builds don't list registries. The API is unstable.