@solidjs/signals 2.0.0-rc.0 → 2.0.0-rc.10

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.
Files changed (149) hide show
  1. package/README.md +1 -1
  2. package/dist/dev-shared.js +7138 -0
  3. package/dist/dev.attribution.js +3307 -0
  4. package/dist/dev.js +8076 -6692
  5. package/dist/observe/affects.js +129 -0
  6. package/dist/observe/attribution.js +7 -0
  7. package/dist/observe/boundaries.js +793 -0
  8. package/dist/observe/core/action.js +177 -0
  9. package/dist/observe/core/async.js +849 -0
  10. package/dist/observe/core/attribution-costs.js +66 -0
  11. package/dist/observe/core/attribution-feedback.js +280 -0
  12. package/dist/observe/core/attribution-hooks.js +83 -0
  13. package/dist/observe/core/attribution-queries.js +43 -0
  14. package/dist/observe/core/attribution.js +2904 -0
  15. package/dist/observe/core/constants.js +283 -0
  16. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  17. package/dist/observe/core/core.js +1999 -0
  18. package/dist/observe/core/dev.js +343 -0
  19. package/dist/observe/core/effect.js +200 -0
  20. package/dist/observe/core/error-hooks.js +71 -0
  21. package/dist/observe/core/error.js +80 -0
  22. package/dist/observe/core/external.js +98 -0
  23. package/dist/observe/core/graph.js +155 -0
  24. package/dist/observe/core/heap.js +147 -0
  25. package/dist/observe/core/invariants.js +45 -0
  26. package/dist/observe/core/lanes.js +205 -0
  27. package/dist/observe/core/optimistic.js +627 -0
  28. package/dist/observe/core/owner.js +353 -0
  29. package/dist/observe/core/scheduler.js +1547 -0
  30. package/dist/observe/core/verdict.js +674 -0
  31. package/dist/observe/index.js +59 -0
  32. package/dist/observe/map.js +484 -0
  33. package/dist/observe/signals.js +731 -0
  34. package/dist/observe/store/index.js +44 -0
  35. package/dist/observe/store/next/optimistic.js +717 -0
  36. package/dist/observe/store/next/projection.js +266 -0
  37. package/dist/observe/store/next/reconcile.js +375 -0
  38. package/dist/observe/store/next/store.js +2480 -0
  39. package/dist/observe/store/next/target.js +51 -0
  40. package/dist/observe/store/store.js +331 -0
  41. package/dist/observe/store/storePath.js +103 -0
  42. package/dist/observe/store/utils.js +1070 -0
  43. package/dist/prod/affects.js +10 -9
  44. package/dist/prod/attribution.js +45 -0
  45. package/dist/prod/boundaries.js +388 -178
  46. package/dist/prod/core/action.js +65 -37
  47. package/dist/prod/core/async.js +477 -208
  48. package/dist/prod/core/attribution-hooks.js +3 -0
  49. package/dist/prod/core/constants.js +186 -1
  50. package/dist/prod/core/context.js +10 -16
  51. package/dist/prod/core/core.js +1556 -415
  52. package/dist/prod/core/dev.js +18 -1
  53. package/dist/prod/core/effect.js +119 -79
  54. package/dist/prod/core/error-hooks.js +71 -0
  55. package/dist/prod/core/error.js +13 -1
  56. package/dist/prod/core/external.js +4 -4
  57. package/dist/prod/core/graph.js +105 -54
  58. package/dist/prod/core/heap.js +72 -65
  59. package/dist/prod/core/invariants.js +3 -2
  60. package/dist/prod/core/lanes.js +117 -52
  61. package/dist/prod/core/optimistic.js +474 -103
  62. package/dist/prod/core/owner.js +131 -84
  63. package/dist/prod/core/scheduler.js +1013 -248
  64. package/dist/prod/core/verdict.js +418 -113
  65. package/dist/prod/index.js +25 -13
  66. package/dist/prod/map.js +314 -151
  67. package/dist/prod/signals.js +382 -32
  68. package/dist/prod/store/index.js +38 -0
  69. package/dist/prod/store/next/optimistic.js +710 -0
  70. package/dist/prod/store/next/projection.js +257 -0
  71. package/dist/prod/store/next/reconcile.js +373 -0
  72. package/dist/prod/store/next/store.js +2356 -0
  73. package/dist/prod/store/next/target.js +51 -0
  74. package/dist/prod/store/store.js +129 -881
  75. package/dist/prod/store/utils.js +982 -242
  76. package/dist/types/attribution.d.ts +19 -0
  77. package/dist/types/attribution.prod.d.ts +22 -0
  78. package/dist/types/boundaries.d.ts +78 -5
  79. package/dist/types/core/action.d.ts +12 -5
  80. package/dist/types/core/async.d.ts +3 -1
  81. package/dist/types/core/attribution-costs.d.ts +35 -0
  82. package/dist/types/core/attribution-feedback.d.ts +133 -0
  83. package/dist/types/core/attribution-hooks.d.ts +304 -0
  84. package/dist/types/core/attribution-queries.d.ts +24 -0
  85. package/dist/types/core/attribution.d.ts +892 -0
  86. package/dist/types/core/constants.d.ts +179 -0
  87. package/dist/types/core/core.d.ts +305 -23
  88. package/dist/types/core/dev.d.ts +421 -8
  89. package/dist/types/core/effect.d.ts +8 -1
  90. package/dist/types/core/error-hooks.d.ts +71 -0
  91. package/dist/types/core/error.d.ts +9 -0
  92. package/dist/types/core/graph.d.ts +23 -0
  93. package/dist/types/core/heap.d.ts +5 -3
  94. package/dist/types/core/index.d.ts +6 -3
  95. package/dist/types/core/invariants.d.ts +5 -1
  96. package/dist/types/core/lanes.d.ts +51 -19
  97. package/dist/types/core/owner.d.ts +15 -3
  98. package/dist/types/core/scheduler.d.ts +252 -3
  99. package/dist/types/core/types.d.ts +124 -41
  100. package/dist/types/index.d.ts +18 -5
  101. package/dist/types/map.d.ts +2 -0
  102. package/dist/types/signals.d.ts +164 -13
  103. package/dist/types/store/index.d.ts +16 -5
  104. package/dist/types/store/next/optimistic.d.ts +25 -0
  105. package/dist/types/store/next/projection.d.ts +27 -0
  106. package/dist/types/store/next/reconcile.d.ts +10 -0
  107. package/dist/types/store/next/store.d.ts +143 -0
  108. package/dist/types/store/next/target.d.ts +196 -0
  109. package/dist/types/store/store.d.ts +46 -112
  110. package/dist/types/store/utils.d.ts +188 -40
  111. package/package.json +32 -26
  112. package/dist/node.cjs +0 -7938
  113. package/dist/prod/store/optimistic.js +0 -217
  114. package/dist/prod/store/projection.js +0 -231
  115. package/dist/prod/store/reconcile.js +0 -707
  116. package/dist/types/store/optimistic.d.ts +0 -45
  117. package/dist/types/store/projection.d.ts +0 -70
  118. package/dist/types/store/reconcile.d.ts +0 -46
  119. package/dist/types-cjs/affects.d.cts +0 -47
  120. package/dist/types-cjs/boundaries.d.cts +0 -175
  121. package/dist/types-cjs/core/action.d.cts +0 -64
  122. package/dist/types-cjs/core/async.d.cts +0 -21
  123. package/dist/types-cjs/core/constants.d.cts +0 -71
  124. package/dist/types-cjs/core/core.d.cts +0 -148
  125. package/dist/types-cjs/core/dev.d.cts +0 -64
  126. package/dist/types-cjs/core/effect.d.cts +0 -30
  127. package/dist/types-cjs/core/error.d.cts +0 -47
  128. package/dist/types-cjs/core/external.d.cts +0 -15
  129. package/dist/types-cjs/core/graph.d.cts +0 -5
  130. package/dist/types-cjs/core/heap.d.cts +0 -22
  131. package/dist/types-cjs/core/index.d.cts +0 -13
  132. package/dist/types-cjs/core/invariants.d.cts +0 -59
  133. package/dist/types-cjs/core/lanes.d.cts +0 -56
  134. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  135. package/dist/types-cjs/core/owner.d.cts +0 -124
  136. package/dist/types-cjs/core/scheduler.d.cts +0 -170
  137. package/dist/types-cjs/core/types.d.cts +0 -148
  138. package/dist/types-cjs/core/verdict.d.cts +0 -2
  139. package/dist/types-cjs/index.d.cts +0 -10
  140. package/dist/types-cjs/map.d.cts +0 -69
  141. package/dist/types-cjs/package.json +0 -3
  142. package/dist/types-cjs/signals.d.cts +0 -605
  143. package/dist/types-cjs/store/index.d.cts +0 -9
  144. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  145. package/dist/types-cjs/store/projection.d.cts +0 -70
  146. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  147. package/dist/types-cjs/store/store.d.cts +0 -213
  148. package/dist/types-cjs/store/storePath.d.cts +0 -58
  149. package/dist/types-cjs/store/utils.d.cts +0 -114
@@ -1,45 +0,0 @@
1
- import { type Refreshable } from "../core/index.js";
2
- import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "./store.js";
3
- /**
4
- * The store equivalent of `createOptimistic`. Writes inside an `action`
5
- * transition are tentative — they show up immediately but auto-revert (or
6
- * reconcile to the action's resolved value) once the transition finishes.
7
- *
8
- * Use this for optimistic UI on collection-shaped data. For single-value
9
- * optimistic state, prefer `createOptimistic`.
10
- *
11
- * - Plain form: `createOptimisticStore(initialValue)`.
12
- * - Derived form: `createOptimisticStore(fn, seed, options?)` — a projection
13
- * store whose authoritative value is recomputed by `fn` and whose
14
- * optimistic overlay reverts after each transition.
15
- *
16
- * `options.key` defaults to `"id"`; specify it only when your data uses a
17
- * different identity field (e.g. `{ key: "uuid" }` or `{ key: t => t.slug }`),
18
- * or `null` to merge positionally. Restating the default just adds noise.
19
- *
20
- * @example
21
- * ```ts
22
- * const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
23
- *
24
- * // Mutation: optimistic add, then in-place reconcile to the saved row.
25
- * const addTodo = action(function* (text: string) {
26
- * const tempId = crypto.randomUUID();
27
- * setTodos(t => { t.push({ id: tempId, text, pending: true }); });
28
- * const saved = yield api.createTodo(text);
29
- * setTodos(t => {
30
- * const i = t.findIndex(x => x.id === tempId);
31
- * if (i >= 0) t[i] = saved;
32
- * });
33
- * });
34
- *
35
- * // Return form: filter is the natural shape for removal.
36
- * const removeTodo = action(function* (id: string) {
37
- * setTodos(t => t.filter(x => x.id !== id));
38
- * yield api.removeTodo(id);
39
- * });
40
- * ```
41
- *
42
- * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
43
- */
44
- export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
45
- export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
@@ -1,70 +0,0 @@
1
- import { type Computed, type Refreshable } from "../core/index.js";
2
- import { type NoFn, type ProjectionOptions, type Store } from "./store.js";
3
- export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): {
4
- store: Refreshable<Store<T>>;
5
- node: Computed<void | T>;
6
- };
7
- /**
8
- * Creates a derived (projected) store. Like `createMemo` but for stores: the
9
- * derive function receives a mutable draft and either mutates it in place
10
- * (canonical) or returns a new value. Either way the result is reconciled
11
- * against the previous draft by `options.key` (default `"id"`), so surviving
12
- * items keep their proxy identity — only added/removed items are
13
- * created/disposed.
14
- *
15
- * If the derive returns a different entity than the one currently held (the
16
- * `/users/1` → `/users/2` shape), the store swaps to it rather than merging,
17
- * and nothing below it is treated as surviving.
18
- *
19
- * Returns the projected store directly (no setter — reads only).
20
- *
21
- * Use this when you want the structural-sharing / per-property tracking
22
- * behaviour of a store on top of a derived computation. For simple read-only
23
- * derivations, `createMemo` is lighter.
24
- *
25
- * @param fn receives the current draft; mutate it in place or return new
26
- * data. Return is convenient for filter/derive shapes where mutation is
27
- * awkward.
28
- * @param seed the backing store value to wrap and reconcile into
29
- * @param options `ProjectionOptions` — `name`, `key`. `key` defaults to
30
- * `"id"`; specify it only when your data uses a different identity field
31
- * (e.g. `{ key: "uuid" }` or `{ key: u => u.slug }`), or `null` to merge
32
- * positionally with no keyed pass.
33
- *
34
- * @example
35
- * ```ts
36
- * // Mutation form — update individual fields on the draft.
37
- * const summary = createProjection<{ total: number; active: number }>(
38
- * draft => {
39
- * draft.total = users().length;
40
- * draft.active = users().filter(u => u.active).length;
41
- * },
42
- * { total: 0, active: 0 }
43
- * );
44
- *
45
- * // Return form — produce a derived collection. Reconciled by `id` so each
46
- * // surviving user keeps the same store identity across recomputes.
47
- * const activeUsers = createProjection<User[]>(
48
- * () => allUsers().filter(u => u.active),
49
- * []
50
- * );
51
- * ```
52
- *
53
- * @see {@link https://github.com/solidjs/x-reactivity#createprojection}
54
- */
55
- export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): Refreshable<Store<T>>;
56
- /**
57
- * Shared projection computed body used by both `createProjection` and the derived
58
- * form of `createOptimisticStore`. Encapsulates the write-trap draft, `storeSetter`
59
- * wrapping, the `handleAsync` subscription with a setter callback, and the commit
60
- * path (which must always go through `storeSetter` so the `writeOnly` guard is
61
- * engaged during `reconcile`'s property reads).
62
- *
63
- * `wrapCommit` is invoked for every commit (sync return and each async yield) and
64
- * lets callers layer extra context around the write — e.g. the optimistic store
65
- * re-enters `setProjectionWriteActive` so reconciles target `STORE_OVERRIDE`
66
- * instead of `STORE_OPTIMISTIC_OVERRIDE` even when an async yield fires outside
67
- * the outer `setProjectionWriteActive` scope.
68
- */
69
- export declare function runProjectionComputed<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any) | null, wrapCommit?: (write: () => void) => void, onDraftWrite?: () => void): Computed<void | T>;
70
- export declare function createWriteTraps(isActive?: () => boolean, onDraftWrite?: () => void): ProxyHandler<any>;
@@ -1,46 +0,0 @@
1
- /**
2
- * Shared body of `reconcile()` and the projection commit. `replace` is the
3
- * only difference: a projection commit is a value swap, not a merge — its root
4
- * proxy is a cell handed out by `createProjection` that can never change
5
- * reference, so a derive returning a different entity is not the slot mistake
6
- * `reconcile()` throws on. Nothing below the root survives that swap, which is
7
- * the rule the keyed diff already applies at a nested slot on a key mismatch.
8
- *
9
- * @internal
10
- */
11
- export declare function reconcileState(value: any, state: any, key: any, replace: boolean): void;
12
- /**
13
- * Returns a draft-mutating function that smart-merges `value` into a store,
14
- * preserving fine-grained reactivity: only changed leaves trigger updates.
15
- *
16
- * With a `key` (default `"id"`), array items whose key matches between old
17
- * and new states keep their identity (updated in place, moves and removals
18
- * update the corresponding signals) — the shape for keyed server payloads.
19
- * Items without the key field fall back to positional matching.
20
- *
21
- * With `key: null`, matching is purely positional: index N of the new array
22
- * merges into index N of the old, and object properties merge recursively —
23
- * the classic pattern for fixed-shape data that churns in place (dashboards,
24
- * monitors), where no keyed diff pass is needed or wanted.
25
- *
26
- * Merging into a slot that holds a *different* entity throws — the caller
27
- * picked the slot, so a key mismatch there is a bug.
28
- *
29
- * @param value the next state to merge in
30
- * @param key property name (string) or extractor function for stable
31
- * identity (default `"id"`); pass `null` for positional merging
32
- *
33
- * @example
34
- * ```ts
35
- * const [todos, setTodos] = createStore<Todo[]>([]);
36
- *
37
- * async function refresh() {
38
- * const fresh = await api.getTodos();
39
- * setTodos(reconcile(fresh)); // diff-merge by `id`
40
- * }
41
- *
42
- * // fixed-shape polling data — positional merge
43
- * setStats(reconcile(nextStats, null));
44
- * ```
45
- */
46
- export declare function reconcile<T extends U, U>(value: T, key?: string | ((item: NonNullable<any>) => any) | null): (state: U) => void;
@@ -1,47 +0,0 @@
1
- import type { Accessor } from "./signals.cjs";
2
- import { type Store } from "./store/store.cjs";
3
- /**
4
- * Declares that in-flight work will change the targeted data: the named
5
- * slot(s) — and everything DERIVED from them — read as pending
6
- * (`isPending` → `true`) from the declaration until the surrounding
7
- * transaction settles or reverts. A mark lives on its own channel — a
8
- * refcount on the marked node plus dep-graph reachability in the verdict
9
- * layer — so the marked values themselves stay readable (a mark is a promise
10
- * of change, not an absence of value), no reader ever suspends on one, and
11
- * completion/settlement accounting never sees one. This is the declaration
12
- * verb of the pending model — additive only. A mark can turn pending ON for
13
- * data the graph can't see changing yet; nothing can turn pending OFF while
14
- * a real change is in flight — a quiet `refresh()` re-ask under a mark still
15
- * reads pending (declaring the reload is what makes it a real question).
16
- *
17
- * Targets:
18
- * - `affects(store)` — a store proxy (any record, root or nested): every
19
- * record reachable from it at declaration time reads pending, including
20
- * through captured child proxies (e.g. `<For>` rows). Siblings are
21
- * untouched; records added after the declaration are not covered.
22
- * - `affects(record, key)` — exactly the named slot of the record. One key
23
- * per call (keys do NOT form a path — target the owning record directly).
24
- * - `affects(accessor)` — a source accessor (signal or memo): the source
25
- * reads pending.
26
- *
27
- * Typically called at the top of an `action` alongside optimistic writes —
28
- * both are up-front declarations about the same mutation. Outside any
29
- * transaction the mark is released at the end of the current flush.
30
- *
31
- * @example
32
- * ```ts
33
- * const send = action(function* (text: string) {
34
- * setState(s => { s.messages.push({ text, status: "sending" }); });
35
- * affects(state.messages.at(-1)!, "status"); // this slot pends until settle
36
- * yield api.send(text);
37
- * });
38
- *
39
- * const reload = action(function* () {
40
- * affects(thing); // the whole store pends…
41
- * refresh(thing); // …over this otherwise-quiet re-ask
42
- * yield api.done();
43
- * });
44
- * ```
45
- */
46
- export declare function affects(target: Accessor<unknown> | Store<object>): void;
47
- export declare function affects<T extends object>(target: Store<T>, key: keyof T): void;
@@ -1,175 +0,0 @@
1
- import { Queue, type Computed, type Effect } from "./core/index.cjs";
2
- import type { Signal } from "./core/index.cjs";
3
- import { type Accessor } from "./signals.cjs";
4
- export interface BoundaryComputed<T> extends Computed<T> {
5
- _propagationMask: number;
6
- }
7
- type RevealSlot = CollectionQueue | RevealController;
8
- type BoolAccessor = () => boolean;
9
- export type RevealOrder = "sequential" | "together" | "natural";
10
- type OrderAccessor = () => RevealOrder;
11
- export declare class RevealController {
12
- _orderAccessor: OrderAccessor;
13
- _collapsedAccessor: BoolAccessor;
14
- _slots: RevealSlot[];
15
- _parentController?: RevealController;
16
- _disabled: Signal<boolean>;
17
- _collapsed: Signal<boolean>;
18
- _ready: boolean;
19
- _minimallyReady: boolean;
20
- _evaluating: boolean;
21
- constructor(order: OrderAccessor, collapsed: BoolAccessor);
22
- _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
23
- _isReady(): boolean;
24
- /**
25
- * "Minimally ready" = this group has something visible to show under its own policy.
26
- * Used by an enclosing `together` group to decide when it can release.
27
- * - `together`: every direct slot is minimally ready.
28
- * - `sequential`: the first owned slot is minimally ready (frontier can advance).
29
- * - `natural`: any owned slot is minimally ready.
30
- */
31
- _isMinimallyReady(): boolean;
32
- _register(slot: RevealSlot): void;
33
- _unregister(slot: RevealSlot): void;
34
- _evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
35
- }
36
- export declare class CollectionQueue extends Queue {
37
- _collectionType: number;
38
- _sources: Set<Computed<any>>;
39
- _tree?: BoundaryComputed<any>;
40
- _pending: boolean;
41
- _disabled: Signal<boolean>;
42
- _error?: Signal<unknown>;
43
- _collapsed: Signal<boolean>;
44
- _revealController?: RevealController;
45
- _initialized: boolean;
46
- _onFn: (() => any) | undefined;
47
- _prevOn: any;
48
- constructor(type: number);
49
- run(type: number): void;
50
- notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
51
- _checkSources(): void;
52
- }
53
- /**
54
- * Lower-level primitive that backs the `<Loading>` flow control. Catches
55
- * pending async reads inside `fn` and renders `fallback` until they settle.
56
- *
57
- * App code should use `<Loading fallback={...}>` instead — reach for this only
58
- * when authoring custom boundary components.
59
- *
60
- * @param fn the tracked subtree
61
- * @param fallback the fallback shown while async reads in `fn` are unresolved
62
- * @param options `on` — accessor whose value scopes the boundary; when set,
63
- * transitions caused by writes to other reactive sources are *not* caught
64
- *
65
- * @example
66
- * ```tsx
67
- * // Custom boundary component built on top of the primitive.
68
- * function MyLoading(props: { fallback: JSX.Element; children: JSX.Element }) {
69
- * return createLoadingBoundary(
70
- * () => props.children,
71
- * () => props.fallback
72
- * ) as unknown as JSX.Element;
73
- * }
74
- * ```
75
- */
76
- export declare function createLoadingBoundary<T, U>(fn: () => T, fallback: () => U, options?: {
77
- on?: () => any;
78
- }): Accessor<T | U>;
79
- /**
80
- * Lower-level primitive that backs the `<Errored>` flow control. Catches
81
- * thrown errors inside `fn` and invokes `fallback(error, reset)` instead.
82
- * `error` is an accessor for the latest captured error; `reset()` recomputes
83
- * the failing sources so the boundary can attempt to recover.
84
- *
85
- * App code should use `<Errored fallback={...}>` instead — reach for this only
86
- * when authoring custom boundary components.
87
- *
88
- * @example
89
- * ```tsx
90
- * // Custom boundary that wraps the primitive and adds telemetry.
91
- * function TracedErrored(props: { fallback: (e: () => unknown) => JSX.Element; children: JSX.Element }) {
92
- * return createErrorBoundary(
93
- * () => props.children,
94
- * (err, reset) => {
95
- * reportError(err());
96
- * return props.fallback(err);
97
- * }
98
- * ) as unknown as JSX.Element;
99
- * }
100
- * ```
101
- */
102
- export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error: Accessor<unknown>, reset: () => void) => U): Accessor<T | U>;
103
- /**
104
- * Coordinate the reveal timing of sibling loading boundaries.
105
- *
106
- * Accepts reactive accessors:
107
- * - `order`: `"sequential"` (default) | `"together"` | `"natural"`.
108
- * - `"sequential"` — classic frontier reveal: siblings reveal in registration order
109
- * as each resolves; later siblings stay hidden until earlier ones complete.
110
- * - `"together"` — every direct slot stays on its fallback until the whole group
111
- * is "minimally ready" (each direct slot has produced its own first visible
112
- * content under its own order), then the whole group releases at once.
113
- * - `"natural"` — children reveal independently (as each resolves). At the top
114
- * level this is a no-op compared to not using `createRevealOrder`; the mode
115
- * exists for nesting, where the group registers as a single composite slot to
116
- * any enclosing `createRevealOrder`.
117
- * - `collapsed`: only meaningful when `order === "sequential"`. When set, tail siblings
118
- * past the frontier suppress their own fallback output. Ignored under `"together"`
119
- * and `"natural"` — those orders have no frontier.
120
- *
121
- * Nested `createRevealOrder` groups compose: the inner controller registers as a
122
- * single slot in the outer controller and is held on its fallbacks until the outer
123
- * releases that slot. Once released, the inner controller runs its own order locally
124
- * over anything still pending. There is no opt-out from an outer hold.
125
- *
126
- * "Minimally ready" is what an order considers its first visible content:
127
- * - `sequential` — frontier-0 is minimally ready (leaf: on resolve; nested: via its
128
- * own minimal signal).
129
- * - `together` — every direct slot is minimally ready.
130
- * - `natural` — any direct slot has visible content (leaves on resolve; nested
131
- * composites via their own minimal signal).
132
- *
133
- * @example
134
- * ```ts
135
- * // Primitive form of `<Reveal>` — coordinate sibling loading boundaries
136
- * // programmatically. App code uses the JSX `<Reveal>` component instead.
137
- * // Both options are accessors so they can react to state changes.
138
- * createRevealOrder(
139
- * () => renderSiblings(),
140
- * { order: () => mode(), collapsed: () => true }
141
- * );
142
- * ```
143
- */
144
- export declare function createRevealOrder<T>(fn: () => T, options?: {
145
- order?: OrderAccessor;
146
- collapsed?: BoolAccessor;
147
- }): T;
148
- /**
149
- * Resolves a children value to its renderable form: unwraps zero-arg functions
150
- * (accessors), recursively flattens arrays, and optionally skips
151
- * non-rendering values (`null`, `undefined`, `true`, `false`, `""`).
152
- *
153
- * Used internally by flow components and by the renderer to walk a children
154
- * tree. App code rarely needs this directly — see `children()` in `solid-js`
155
- * for the user-facing helper that memoizes the result.
156
- *
157
- * @param children value or array of values to flatten
158
- * @param options
159
- * - `skipNonRendered` — drop values that won't render
160
- * - `doNotUnwrap` — leave function children as-is (caller will resolve)
161
- *
162
- * @example
163
- * ```ts
164
- * // Custom renderer walking a children tree manually. Most authors should
165
- * // use `children()` from solid-js, which memoizes the resolved value.
166
- * function renderChildren(value: unknown): unknown {
167
- * return flatten(value, { skipNonRendered: true });
168
- * }
169
- * ```
170
- */
171
- export declare function flatten(children: any, options?: {
172
- skipNonRendered?: boolean;
173
- doNotUnwrap?: boolean;
174
- }): any;
175
- export {};
@@ -1,64 +0,0 @@
1
- /**
2
- * The primitive for mutations: imperative async workflows whose *writes span
3
- * an async gap* — optimistic write, server round-trip, reconciling write —
4
- * where intermediate state must not leak and failure must revert cleanly
5
- * (pair with `createOptimistic` / `createOptimisticStore`).
6
- *
7
- * Navigation-shaped updates do not need an action. A plain setter call is
8
- * enough: reads pull the async, and downstream async computeds hold their
9
- * previous values per-node until the new ones are ready (`isPending` /
10
- * `latest` expose the in-flight state). Reach for `action` only when writes
11
- * happen *after* async work, not merely upstream of it.
12
- *
13
- * Framework-level actions (router form actions, server actions) are
14
- * specializations of this primitive: they are actions in exactly this sense —
15
- * the same transactional semantics — with form binding, serialization, and
16
- * submission tracking layered on top. The shared name is deliberate.
17
- *
18
- * Wraps a generator function so each invocation runs as a single transaction
19
- * (a "transition") that batches every signal/store write between yields. The
20
- * surrounding UI sees one atomic update per yielded step; nothing is committed
21
- * until the action either completes or the next `yield` resolves.
22
- *
23
- * `yield` is the transaction-safe suspension point: the action waits for a
24
- * yielded promise and re-enters the transaction before running the code after
25
- * it. A plain `await` does NOT — the runtime has no hook into an async
26
- * generator's internal await continuations, so writes to fresh signals
27
- * between an `await` and the next `yield` escape the transaction and commit
28
- * immediately. `await` is still the ergonomic choice for typed results; just
29
- * put a bare `yield` before any writes that follow it:
30
- *
31
- * ```ts
32
- * const saved = await api.createTodo(text); // typed result
33
- * yield; // re-enter the transaction before writing
34
- * setTodos(t => { ... });
35
- * ```
36
- *
37
- * (For the same reason, don't call `flush()` inside an action body — it
38
- * drains the transaction mid-step.)
39
- *
40
- * Each call returns a `Promise` that resolves with the generator's return
41
- * value, or rejects if it throws. Pair with `createOptimistic` /
42
- * `createOptimisticStore` to apply tentative writes that auto-revert if the
43
- * action fails.
44
- *
45
- * @example
46
- * ```ts
47
- * const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
48
- *
49
- * const addTodo = action(async function* (text: string) {
50
- * const tempId = crypto.randomUUID();
51
- * setTodos(t => { t.push({ id: tempId, text, pending: true }); }); // optimistic
52
- * const saved = await api.createTodo(text); // network round-trip, typed
53
- * yield; // re-enter the transaction
54
- * setTodos(t => {
55
- * const i = t.findIndex(x => x.id === tempId);
56
- * if (i >= 0) t[i] = saved;
57
- * });
58
- * return saved;
59
- * });
60
- *
61
- * await addTodo("buy milk");
62
- * ```
63
- */
64
- export declare function action<Args extends any[], Y, R>(genFn: (...args: Args) => Generator<Y, R, any> | AsyncGenerator<Y, R, any>): (...args: Args) => Promise<R>;
@@ -1,21 +0,0 @@
1
- import { NotReadyError } from "./error.cjs";
2
- import { type OptimisticLane } from "./lanes.cjs";
3
- import type { Computed, Link } from "./types.cjs";
4
- export declare function addPendingSource(el: Computed<any>, source: Computed<any>): boolean;
5
- /**
6
- * A loading-window node hit an unready source (sync throw in recompute, or a
7
- * NotReadyError-rejected flight): register for the source's settle — the
8
- * settlePendingSource walk runs off `_pendingSources` + `_blocked` alone —
9
- * with NO read-visible pending status, no downstream propagation, no
10
- * transition, no lane registration. Commit #0 keeps serving.
11
- */
12
- export declare function parkLoadingWindow(el: Computed<any>, e: NotReadyError): void;
13
- export declare function setPendingError(el: Computed<any>, source?: Computed<any>, error?: any): void;
14
- export declare function forEachDependent(el: Computed<any>, fn: (node: Computed<any>, link: Link) => void): void;
15
- export declare function releaseSettledDependents(el: Computed<any>): void;
16
- export declare function settleErroredDependents(el: Computed<any>, error: any): void;
17
- export declare function settlePendingSource(el: Computed<any>): void;
18
- export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
19
- export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
20
- export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
21
- export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
@@ -1,71 +0,0 @@
1
- export declare const REACTIVE_NONE = 0;
2
- export declare const REACTIVE_CHECK: number;
3
- export declare const REACTIVE_DIRTY: number;
4
- export declare const REACTIVE_RECOMPUTING_DEPS: number;
5
- export declare const REACTIVE_IN_HEAP: number;
6
- export declare const REACTIVE_IN_HEAP_HEIGHT: number;
7
- export declare const REACTIVE_ZOMBIE: number;
8
- export declare const REACTIVE_DISPOSED: number;
9
- export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
10
- export declare const REACTIVE_SNAPSHOT_STALE: number;
11
- export declare const REACTIVE_LAZY: number;
12
- export declare const REACTIVE_MANUAL_WRITE: number;
13
- /**
14
- * The pending recompute is a re-ask of the same question: `refresh()` dirtied
15
- * the node while no tracked input changed value. Cleared whenever a real
16
- * value-change notification arrives (`insertSubs`), and consumed by
17
- * `recompute` into the node's `_reask` classification — a quiet (re-ask)
18
- * pending window does not read as pending (question-scoped pending model).
19
- */
20
- export declare const REACTIVE_REASK: number;
21
- export declare const CONFIG_OWNED_WRITE: number;
22
- export declare const CONFIG_NO_SNAPSHOT: number;
23
- export declare const CONFIG_TRANSPARENT: number;
24
- export declare const CONFIG_IN_SNAPSHOT_SCOPE: number;
25
- export declare const CONFIG_CHILDREN_FORBIDDEN: number;
26
- export declare const CONFIG_AUTO_DISPOSE: number;
27
- export declare const CONFIG_SYNC: number;
28
- export declare const STATUS_NONE = 0;
29
- export declare const STATUS_PENDING: number;
30
- export declare const STATUS_ERROR: number;
31
- export declare const STATUS_UNINITIALIZED: number;
32
- export declare const EFFECT_PURE = 0;
33
- export declare const EFFECT_RENDER = 1;
34
- export declare const EFFECT_USER = 2;
35
- export declare const EFFECT_TRACKED = 3;
36
- export declare const NOT_PENDING: {};
37
- export declare const NO_SNAPSHOT: {};
38
- /**
39
- * Stand-in stored in `_overrideValue` for an optimistic write of literal
40
- * `undefined` (#2898). The slot doubles as the optimistic-node brand
41
- * (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
42
- * would erase the node's optimistic identity: the write turns invisible and
43
- * follow-up writes route off the optimistic path and commit permanently.
44
- * Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
45
- * via `visibleOverrideValue`; slot identity tests stay raw.
46
- */
47
- export declare const OVERRIDE_UNDEFINED: {};
48
- /** Unwrap an active override's stored value for surfacing to readers (#2898). */
49
- export declare function unwrapOverride<T = any>(v: unknown): T;
50
- export declare const STORE_SNAPSHOT_PROPS = "sp";
51
- export declare const SUPPORTS_PROXY: boolean;
52
- export declare const defaultContext: {};
53
- /**
54
- * Brand symbol used by `Refreshable<T>` values (projection stores, async
55
- * memos) to expose their underlying computation to `refresh()`. Not part of
56
- * the user-facing API.
57
- *
58
- * @internal
59
- */
60
- export declare const $REFRESH: unique symbol;
61
- /**
62
- * Brand applied to values that participate in the `refresh()` re-run protocol.
63
- * Accessors receive this handle internally; projected stores expose it through
64
- * their public return type so user-defined hooks that wrap `createOptimisticStore`
65
- * / `createProjection` / projection-form `createStore` can have their return
66
- * types inferred without leaking the internal `$REFRESH` symbol into public type
67
- * signatures (TS4058).
68
- */
69
- export type Refreshable<T> = T & {
70
- readonly [$REFRESH]: any;
71
- };