Skip to content

Releases

effect-atom-svelte@0.5.1

Choose a tag to compare

@github-actions github-actions released this 30 Nov 00:53
6c75a7c

Patch Changes

  • 00a334e: A HydrationBoundary no longer runs a hydrated atom's effect again during the server render. An effect or stream atom whose Success or Failure a load function dehydrated now renders that result on the server without repeating the request, as it did before Effect 4.1, with or without skipInitialRun. A promise-encoded Initial (Hydration.dehydrate(registry, { encodeInitialAs: "promise" })) is still waited for during the render, and so is a stream's Success that is still waiting when read with useAtomResult or useAtomSuspense and suspendOnWaiting: 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 its Atom.serializable sets skipInitialRun: 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"; useAtomSet says how concurrent Atom.fn calls settle, and that Atom.Interrupt and Atom.Reset don't stop them; useAtomResult and useAtomSuspense say when a hydrated atom runs again in the browser, and that they must be called before a component's first await; HydrationBoundary says an effect or stream atom it hydrates runs again once read unless it sets skipInitialRun; 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 names useAtomResult.
  • 68f2584: On the server, useAtomSuspense with suspendOnWaiting renders a still-waiting value from useAtomInitialValues as is, as useAtomResult already 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

Choose a tag to compare

@github-actions github-actions released this 30 Nov 00:53
6c75a7c

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"; useAtomSet says how concurrent Atom.fn calls settle, and that Atom.Interrupt and Atom.Reset don't stop them; useAtomResult and useAtomSuspense say when a hydrated atom runs again in the browser, and that they must be called before a component's first await; HydrationBoundary says an effect or stream atom it hydrates runs again once read unless it sets skipInitialRun; 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 names useAtomResult.
  • Updated dependencies [00a334e]
  • Updated dependencies [5c9f007]
  • Updated dependencies [68f2584]
    • effect-atom-svelte@0.5.1

effect-atom-svelte@0.5.0

Choose a tag to compare

@github-actions github-actions released this 29 Nov 15:05
83be069

Minor Changes

  • a659d81: Move to Effect 4.1: the effect peer range is now ~4.1.0, so upgrade effect to 4.1 alongside this release. The devtools need effect-atom-svelte 0.5.

    useAtomInitialValues takes the entries Effect 4.1's Atom.initialValue makes, options included, as RegistryProvider's initialValues already does. Give an effect or stream atom Atom.initialValue(atom, value, { skipInitialRun: true }) to keep the value in the browser instead of running the atom again on mount, as for data a load function already fetched. It runs once it is refreshed.

    With Effect 4.1, an effect or stream atom a HydrationBoundary hydrates runs again in the browser once something reads it, as Effect's Hydration.hydrate now does, and shows the server's result until the browser's arrives. On 4.0 only atoms wrapped by Atom.withReactivity and similar did. To keep the server's result, give the atom Atom.serializable({ key, schema, skipInitialRun: true }). The hooks (useAtomResult, useAtomSuspense) still run nothing again unless you set revalidateOnHydrate.

  • 15d04f9: Add remoteQueryAtom to effect-atom-svelte/sveltekit (unstable): it turns a SvelteKit 3 remote query or query.live into an atom that follows every change SvelteKit makes to it — a refresh, a .set(), a command's single-flight update, an optimistic withOverride and live pushes — and starts in the browser from the result the server render sent. In development, reading one with useAtomValue on the server warns that the server renders Initial.

Patch Changes

  • 2ea38eb: A form field's dirty in 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 (by append or replace) has no initial value, so its fields read dirty. revertToLastSubmit brings 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 RegistryProvider holding 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() resolves false there too. A payload, mapError or Atom.fn that throws ends the submit as a defect in submitResult, rather than leaving submitting true for good. And useAtomSet's promiseExit mode resolves with Exit.die when the Atom.fn throws before returning its Effect, instead of rejecting.
  • 0740552: useAtomResult and useAtomSuspense now send the server's result for an AtomRpc or AtomHttpApi query with both a serializationKey and a staleTime, and for any serializable atom wrapped in Atom.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, and staleTime decides 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: useAtomSubscribe no 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. With immediate, 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, useAtomSet waiting for Atom.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

Choose a tag to compare

@github-actions github-actions released this 29 Nov 15:05
83be069

Minor Changes

  • a659d81: Move to Effect 4.1: the effect peer range is now ~4.1.0, so upgrade effect to 4.1 alongside this release. The devtools need effect-atom-svelte 0.5.

    useAtomInitialValues takes the entries Effect 4.1's Atom.initialValue makes, options included, as RegistryProvider's initialValues already does. Give an effect or stream atom Atom.initialValue(atom, value, { skipInitialRun: true }) to keep the value in the browser instead of running the atom again on mount, as for data a load function already fetched. It runs once it is refreshed.

    With Effect 4.1, an effect or stream atom a HydrationBoundary hydrates runs again in the browser once something reads it, as Effect's Hydration.hydrate now does, and shows the server's result until the browser's arrives. On 4.0 only atoms wrapped by Atom.withReactivity and similar did. To keep the server's result, give the atom Atom.serializable({ key, schema, skipInitialRun: true }). The hooks (useAtomResult, useAtomSuspense) still run nothing again unless you set revalidateOnHydrate.

Patch Changes

effect-atom-svelte@0.4.1

Choose a tag to compare

@github-actions github-actions released this 16 Oct 00:57
2157adb

Patch Changes

  • 27d4a1b: Form: leafHook now names a value outside a union, such as a select whose value isn't one of its Schema.Literals. It used to get Effect's own Expected "a" | "b" whatever the hook returned. The hook receives it as an InvalidType whose ast is the union, as it already did for a single Schema.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

Choose a tag to compare

@github-actions github-actions released this 15 Oct 23:15
6a8c15b

Minor Changes

  • 85d302a: Add forms built from one Effect Schema (#60). Form.make defines a form, useForm creates an instance in a component and Form.instance creates 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 with mapError, and leaves the rest in submitResult. field.issue gives the latest check's message before the timing shows it, for a live checklist. An instance's atoms are labelled with the form's name (SignUp.values, SignUp.state, SignUp.check). Array fields keep each item's errors and touched state with it when items move, and form.at hands part of a form to a component.

    effect-atom-svelte/sveltekit adds useUnsavedChangesGuard, 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 its handleError hooks 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

Choose a tag to compare

@github-actions github-actions released this 15 Oct 23:16
6a8c15b

Minor Changes

  • 85d302a: The Vite plugin names a form from Form.make after the variable it's declared as (#60), so a form instance's atoms show in the panel and the docs graph as SignUp.values, SignUp.state and SignUp.check rather than by number.

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.
  • Updated dependencies [85d302a]
  • Updated dependencies [b5033af]
    • effect-atom-svelte@0.4.0

effect-atom-svelte@0.3.0

Choose a tag to compare

@github-actions github-actions released this 11 Oct 19:05
db2dae5

Minor Changes

  • 4208ce3: Re-export Effect's Reactivity module beside Atom, AtomRegistry and the other effect/reactivity modules, so the reactivity keys mutations refresh can be used from effect-atom-svelte too.
  • 4f0d922: useAtomRef and useAtomRefPropValue return a current you can assign for a writable AtomRef, which sets the ref or the property, so bind:value={name.current} works as it does with useAtom. A read-only ref, such as one from map, still returns a read-only current.

Patch Changes

  • 72bc355: Fix several edge cases in server rendering and hydration:

    • On the server, useAtomResult and useAtomSuspense render a value from useAtomInitialValues without running the atom, as useAtomValue already 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 without suspendOnWaiting rendered first.
    • On the server, HydrationBoundary ignores 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 HydrationBoundary keeps the values another boundary given the same state queued, as a layout and its page might be.
    • A seeded useAtomSuspense read in the script, outside any reaction, lets go of its atom once the getter moves on.
    • A hook after a top-level await no longer warns in development about a missed seed for an atom whose result the server didn't send, such as a defect.
  • 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 with Atom.withLabel. The panel follows a shortcut prop 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 Refreshed when 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 useAtomInitialValues being 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.

    provideRegistry now 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. handleClientError uses SvelteKit 2's message for an error whose own message is empty, such as a Data.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 ScopedAtom provider under {#key} with its input in the serialization key, no longer throws Two 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 HydrationBoundary now matches the server's markup when the atom already exists, as with a value from RegistryProvider's initialValues or 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's experimental.async; without it they are updated after the first render, as before. Each server-rendered page with a HydrationBoundary carries one more small hydratable entry for this.
    • In the browser, a value dehydrated as a promise that lands after its HydrationBoundary is 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.
  • c64799e: Fix useAtomSuspense with includeFailure resolving, after it waited, with a copy of the atom's result rather than the result itself. The copy lost a Failure's previousSuccess, so AsyncResult.getOrElse and AsyncResult.value no 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 ScopeChanged follow 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 as Atom.debounce, makeRefreshOnSignal or refreshOnWindowFocus, and not for an Atom.runtime released while its layer builds, which carries on.
    • idleTTL gives undefined for an atom with an idle TTL of 0, which is removed as soon as nothing reads it.
  • f6f0c9c: Fix several things effect-atom-svelte/inspector reported 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.reset reports 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 as Refreshed, as it always was.

    Fix the devtools labelling a component with a generics attribute holding > wrongly, and taking a <script> inside <svelte:head> for the component's script: an inline head script got an import that 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 as Arrowup. The graph puts both sides of a diamond to the right of its source whichever atom a scope lists first.

  • 456cf7c: Fix pending useAtomSet calls and initial values in edge cases:

    • A "promise" or "promiseExit" call no longer hangs when the RegistryProvider that 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 writes Atom.Reset settles as interrupted, instead of hanging, or resolving with the initialValue of an Atom.fn that has one. Atom.Interrupt remains the way to cancel a call.
    • useAtomInitialValues lets 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 (or provideRegistry without a registry) 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 $derived on the page running again on every read until reload.
  • 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 when id switched to an atom not built yet, returning a new object for an unchanged value; an $effect that first read an atom ran twice; and code after awaiting useAtomSuspense of an atom that resolves at once, in an $effect, ran twice.

  • 67d468b: Fix the first refresh of an atom with a value from `initialValue...

Read more

effect-atom-svelte-devtools@0.2.2

Choose a tag to compare

@github-actions github-actions released this 11 Oct 19:05
db2dae5

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 with Atom.withLabel. The panel follows a shortcut prop 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 Refreshed when 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 write NaN, Infinity and undefined fields as they are instead of showing null or dropping the field. A map whose keys are objects, or whose keys read the same as strings (1 and "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/inspector reported 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.reset reports 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 as Refreshed, as it always was.

    Fix the devtools labelling a component with a generics attribute holding > wrongly, and taking a <script> inside <svelte:head> for the component's script: an inline head script got an import that 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 as Arrowup. The graph puts both sides of a diamond to the right of its source whichever atom a scope lists first.

  • 073fbdf: Fix atomLabels treating 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 (a SyntaxError when the page loads), or have its calls wrapped in the label helper (a ReferenceError).
    • A comment in <script module> that mentions <svelte:head> no longer stops the instance script's atoms being labelled.
  • 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

Choose a tag to compare

@github-actions github-actions released this 08 Oct 07:32
df3794d

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() and watchRegistries list 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.