effect-atom-svelte 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Hooks.svelte.d.ts +16 -10
- package/dist/Hooks.svelte.js +443 -143
- package/dist/HydrationBoundary.svelte +130 -12
- package/dist/HydrationBoundary.svelte.d.ts +13 -4
- package/dist/Inspector.d.ts +333 -0
- package/dist/Inspector.js +558 -0
- package/dist/RegistryContext.d.ts +2 -0
- package/dist/RegistryContext.js +22 -6
- package/dist/ScopedAtom.d.ts +5 -4
- package/dist/ScopedAtom.js +5 -4
- package/dist/SvelteKit.d.ts +28 -3
- package/dist/SvelteKit.js +9 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/boundaries.d.ts +9 -0
- package/dist/internal/boundaries.js +8 -0
- package/dist/internal/disposal.d.ts +13 -0
- package/dist/internal/disposal.js +43 -0
- package/dist/internal/hydration.d.ts +11 -2
- package/dist/internal/hydration.js +23 -3
- package/dist/internal/nodeInternals.d.ts +30 -0
- package/dist/internal/nodeInternals.js +107 -0
- package/dist/internal/registries.d.ts +6 -0
- package/dist/internal/registries.js +40 -0
- package/dist/internal/renderEnd.d.ts +13 -0
- package/dist/internal/renderEnd.js +34 -0
- package/dist/internal/scope.svelte.d.ts +29 -0
- package/dist/internal/scope.svelte.js +23 -0
- package/dist/internal/teardown.svelte.d.ts +17 -0
- package/dist/internal/teardown.svelte.js +44 -0
- package/dist/internal/troubleshooting.d.ts +2 -0
- package/dist/internal/troubleshooting.js +3 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This is a community project by Jarred Norris. It is not part of Effect, and the
|
|
|
10
10
|
|
|
11
11
|
- `effect` 4.0.x. The peer range is `~4.0.0`, not `^4.0.0`: the bindings use parts of the atom registry that aren't public API, which a minor release of `effect` can change.
|
|
12
12
|
- Svelte 5.57.2 or later. `experimental.async` is needed for `useAtomSuspense`, `useAtomResult` and server rendering.
|
|
13
|
-
- SvelteKit is optional. The docs site and its tests run on SvelteKit 3. On SvelteKit 2, the error hooks in `effect-atom-svelte/sveltekit` work with less detail.
|
|
13
|
+
- SvelteKit is optional. The docs site and its tests run on SvelteKit 3. On SvelteKit 2, the error hooks in `effect-atom-svelte/sveltekit` work with less detail, and reach `<svelte:boundary>` only with `kit.experimental.handleRenderingErrors` turned on.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
package/dist/Hooks.svelte.d.ts
CHANGED
|
@@ -122,12 +122,14 @@ export declare const useAtomMount: (input: AtomInput<Atom.Atom<unknown>>) => voi
|
|
|
122
122
|
*
|
|
123
123
|
* In `promise` and `promiseExit` modes the setter waits for the atom's next settled result. The
|
|
124
124
|
* wait holds the atom, so a call still in flight keeps it running after the component is
|
|
125
|
-
* destroyed, until it settles
|
|
125
|
+
* destroyed, until it settles, unless the `RegistryProvider` that created the registry is
|
|
126
|
+
* destroyed: that interrupts the call and settles it as interrupted. The call's `signal` cancels only the wait: an `Atom.fn` already
|
|
126
127
|
* running keeps going (send `Atom.Interrupt` to stop it). A signal that is already aborted settles
|
|
127
128
|
* the call as interrupted without writing, as `fetch` does. Calls on one `Atom.fn` share its single
|
|
128
129
|
* result, so a new call supersedes one in flight and every pending call resolves with the latest
|
|
129
130
|
* call's result. `Atom.Reset` has no result to wait for, so these modes leave it out of their
|
|
130
|
-
* types and reject it; reset with a `value` mode setter.
|
|
131
|
+
* types and reject it; reset with a `value` mode setter. A reset written while a promise-mode call
|
|
132
|
+
* is pending settles that promise as interrupted. To cancel a call, send `Atom.Interrupt`.
|
|
131
133
|
*
|
|
132
134
|
* **Example** (Updating an atom from its current value)
|
|
133
135
|
*
|
|
@@ -207,9 +209,10 @@ export declare const useAtomSubscribe: <A>(input: AtomInput<Atom.Atom<A>>, f: (v
|
|
|
207
209
|
* an atom that can only compute in the browser can start from a value on the server.
|
|
208
210
|
*
|
|
209
211
|
* A value applies once while the atom is held, so a component mounted later, or a second
|
|
210
|
-
* component with its own value, does not overwrite a value the atom has moved on from
|
|
211
|
-
*
|
|
212
|
-
*
|
|
212
|
+
* component with its own value, does not overwrite a value the atom has moved on from since the
|
|
213
|
+
* first applied one. An atom that is already in use without one, read by another component, is set
|
|
214
|
+
* to the value, as `@effect/atom-react` does. Once nothing holds the atom and the registry disposes
|
|
215
|
+
* it, the next component to start it applies its value again. On the server a value lasts one render, so each request against a shared registry applies
|
|
213
216
|
* its own; requests rendering at the same time share the registry's atoms, and with them the value
|
|
214
217
|
* the first one applied.
|
|
215
218
|
*
|
|
@@ -232,8 +235,9 @@ export declare const useAtomSubscribe: <A>(input: AtomInput<Atom.Atom<A>>, f: (v
|
|
|
232
235
|
*/
|
|
233
236
|
export declare const useAtomInitialValues: (initialValues: Iterable<readonly [Atom.Atom<unknown>, unknown]>) => void;
|
|
234
237
|
/**
|
|
235
|
-
* Reads an `AtomRef`, following it when the getter returns a different ref. For
|
|
236
|
-
* ref,
|
|
238
|
+
* Reads an `AtomRef`, following it when the getter returns a different ref. For a writable ref,
|
|
239
|
+
* `current` can be assigned too, which sets the ref, so `bind:value={name.current}` works; a
|
|
240
|
+
* read-only ref, as from `map`, can't be. For one property of a ref, use `useAtomRefPropValue`.
|
|
237
241
|
*
|
|
238
242
|
* A ref has no registry. On the server, one created at module level is shared by every request,
|
|
239
243
|
* so don't write a visitor's data to it there: see
|
|
@@ -253,7 +257,8 @@ export declare const useAtomInitialValues: (initialValues: Iterable<readonly [At
|
|
|
253
257
|
* @since 0.1.0
|
|
254
258
|
* @category hooks
|
|
255
259
|
*/
|
|
256
|
-
export declare
|
|
260
|
+
export declare function useAtomRef<A>(input: AtomInput<AtomRef.AtomRef<A>>): AtomState<A>;
|
|
261
|
+
export declare function useAtomRef<A>(input: AtomInput<AtomRef.ReadonlyRef<A>>): AtomValue<A>;
|
|
257
262
|
/**
|
|
258
263
|
* Returns `ref.prop(prop)`, the `AtomRef` for one property of an `AtomRef`. It takes the ref
|
|
259
264
|
* itself, not a getter, and does not follow later changes to `ref` or `prop`; to read a property
|
|
@@ -276,7 +281,8 @@ export declare const useAtomRef: <A>(input: AtomInput<AtomRef.ReadonlyRef<A>>) =
|
|
|
276
281
|
export declare const useAtomRefProp: <A, K extends keyof A>(ref: AtomRef.AtomRef<A>, prop: K) => AtomRef.AtomRef<A[K]>;
|
|
277
282
|
/**
|
|
278
283
|
* Reads one property of an `AtomRef`, following the getter to a different ref. `prop` is taken
|
|
279
|
-
* once, when the component starts, and is not followed.
|
|
284
|
+
* once, when the component starts, and is not followed. Assigning `current` sets the property, so
|
|
285
|
+
* `bind:checked={done.current}` works.
|
|
280
286
|
*
|
|
281
287
|
* **Example** (Reading one property of a ref)
|
|
282
288
|
*
|
|
@@ -292,7 +298,7 @@ export declare const useAtomRefProp: <A, K extends keyof A>(ref: AtomRef.AtomRef
|
|
|
292
298
|
* @since 0.1.0
|
|
293
299
|
* @category hooks
|
|
294
300
|
*/
|
|
295
|
-
export declare const useAtomRefPropValue: <A, K extends keyof A>(input: AtomInput<AtomRef.AtomRef<A>>, prop: K) =>
|
|
301
|
+
export declare const useAtomRefPropValue: <A, K extends keyof A>(input: AtomInput<AtomRef.AtomRef<A>>, prop: K) => AtomState<A[K]>;
|
|
296
302
|
/**
|
|
297
303
|
* Options for `useAtomResult`.
|
|
298
304
|
*
|