@solidjs/signals 0.13.13 → 2.0.0-beta.11

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 (110) hide show
  1. package/README.md +8 -7
  2. package/dist/dev.js +1230 -598
  3. package/dist/node.cjs +2064 -1555
  4. package/dist/prod.js +1783 -1251
  5. package/dist/types/boundaries.d.ts +126 -5
  6. package/dist/types/core/action.d.ts +34 -0
  7. package/dist/types/core/constants.d.ts +26 -0
  8. package/dist/types/core/context.d.ts +10 -2
  9. package/dist/types/core/core.d.ts +129 -9
  10. package/dist/types/core/dev.d.ts +1 -1
  11. package/dist/types/core/effect.d.ts +4 -2
  12. package/dist/types/core/error.d.ts +24 -0
  13. package/dist/types/core/external.d.ts +19 -0
  14. package/dist/types/core/graph.d.ts +2 -0
  15. package/dist/types/core/index.d.ts +1 -1
  16. package/dist/types/core/owner.d.ts +93 -3
  17. package/dist/types/core/scheduler.d.ts +43 -2
  18. package/dist/types/core/types.d.ts +5 -6
  19. package/dist/types/index.d.ts +3 -3
  20. package/dist/types/map.d.ts +32 -3
  21. package/dist/types/signals.d.ts +362 -42
  22. package/dist/types/src/boundaries.d.ts +173 -0
  23. package/dist/types/src/core/action.d.ts +35 -0
  24. package/dist/types/src/core/async.d.ts +6 -0
  25. package/dist/types/src/core/constants.d.ts +51 -0
  26. package/dist/types/src/core/context.d.ts +36 -0
  27. package/dist/types/src/core/core.d.ts +174 -0
  28. package/dist/types/src/core/dev.d.ts +49 -0
  29. package/dist/types/src/core/effect.d.ts +32 -0
  30. package/dist/types/src/core/error.d.ts +38 -0
  31. package/dist/types/src/core/external.d.ts +45 -0
  32. package/dist/types/src/core/graph.d.ts +5 -0
  33. package/dist/types/src/core/heap.d.ts +14 -0
  34. package/dist/types/src/core/index.d.ts +12 -0
  35. package/dist/types/src/core/lanes.d.ts +54 -0
  36. package/dist/types/src/core/owner.d.ts +116 -0
  37. package/dist/types/src/core/scheduler.d.ts +122 -0
  38. package/dist/types/src/core/types.d.ts +85 -0
  39. package/dist/types/src/index.d.ts +9 -0
  40. package/dist/types/src/map.d.ts +53 -0
  41. package/dist/types/src/signals.d.ts +512 -0
  42. package/dist/types/src/store/index.d.ts +9 -0
  43. package/dist/types/src/store/optimistic.d.ts +45 -0
  44. package/dist/types/src/store/projection.d.ts +66 -0
  45. package/dist/types/src/store/reconcile.d.ts +23 -0
  46. package/dist/types/src/store/store.d.ts +125 -0
  47. package/dist/types/src/store/storePath.d.ts +58 -0
  48. package/dist/types/src/store/utils.d.ts +114 -0
  49. package/dist/types/store/optimistic.d.ts +38 -12
  50. package/dist/types/store/projection.d.ts +55 -15
  51. package/dist/types/store/reconcile.d.ts +22 -0
  52. package/dist/types/store/store.d.ts +72 -15
  53. package/dist/types/store/storePath.d.ts +28 -0
  54. package/dist/types/store/utils.d.ts +78 -7
  55. package/dist/types-cjs/boundaries.d.cts +173 -0
  56. package/dist/types-cjs/core/action.d.cts +35 -0
  57. package/dist/types-cjs/core/async.d.cts +6 -0
  58. package/dist/types-cjs/core/constants.d.cts +51 -0
  59. package/dist/types-cjs/core/context.d.cts +36 -0
  60. package/dist/types-cjs/core/core.d.cts +174 -0
  61. package/dist/types-cjs/core/dev.d.cts +49 -0
  62. package/dist/types-cjs/core/effect.d.cts +32 -0
  63. package/dist/types-cjs/core/error.d.cts +38 -0
  64. package/dist/types-cjs/core/external.d.cts +45 -0
  65. package/dist/types-cjs/core/graph.d.cts +5 -0
  66. package/dist/types-cjs/core/heap.d.cts +14 -0
  67. package/dist/types-cjs/core/index.d.cts +12 -0
  68. package/dist/types-cjs/core/lanes.d.cts +54 -0
  69. package/dist/types-cjs/core/owner.d.cts +116 -0
  70. package/dist/types-cjs/core/scheduler.d.cts +122 -0
  71. package/dist/types-cjs/core/types.d.cts +85 -0
  72. package/dist/types-cjs/index.d.cts +9 -0
  73. package/dist/types-cjs/map.d.cts +53 -0
  74. package/dist/types-cjs/package.json +3 -0
  75. package/dist/types-cjs/signals.d.cts +512 -0
  76. package/dist/types-cjs/src/boundaries.d.cts +173 -0
  77. package/dist/types-cjs/src/core/action.d.cts +35 -0
  78. package/dist/types-cjs/src/core/async.d.cts +6 -0
  79. package/dist/types-cjs/src/core/constants.d.cts +51 -0
  80. package/dist/types-cjs/src/core/context.d.cts +36 -0
  81. package/dist/types-cjs/src/core/core.d.cts +174 -0
  82. package/dist/types-cjs/src/core/dev.d.cts +49 -0
  83. package/dist/types-cjs/src/core/effect.d.cts +32 -0
  84. package/dist/types-cjs/src/core/error.d.cts +38 -0
  85. package/dist/types-cjs/src/core/external.d.cts +45 -0
  86. package/dist/types-cjs/src/core/graph.d.cts +5 -0
  87. package/dist/types-cjs/src/core/heap.d.cts +14 -0
  88. package/dist/types-cjs/src/core/index.d.cts +12 -0
  89. package/dist/types-cjs/src/core/lanes.d.cts +54 -0
  90. package/dist/types-cjs/src/core/owner.d.cts +116 -0
  91. package/dist/types-cjs/src/core/scheduler.d.cts +122 -0
  92. package/dist/types-cjs/src/core/types.d.cts +85 -0
  93. package/dist/types-cjs/src/index.d.cts +9 -0
  94. package/dist/types-cjs/src/map.d.cts +53 -0
  95. package/dist/types-cjs/src/signals.d.cts +512 -0
  96. package/dist/types-cjs/src/store/index.d.cts +9 -0
  97. package/dist/types-cjs/src/store/optimistic.d.cts +45 -0
  98. package/dist/types-cjs/src/store/projection.d.cts +66 -0
  99. package/dist/types-cjs/src/store/reconcile.d.cts +23 -0
  100. package/dist/types-cjs/src/store/store.d.cts +125 -0
  101. package/dist/types-cjs/src/store/storePath.d.cts +58 -0
  102. package/dist/types-cjs/src/store/utils.d.cts +114 -0
  103. package/dist/types-cjs/store/index.d.cts +9 -0
  104. package/dist/types-cjs/store/optimistic.d.cts +45 -0
  105. package/dist/types-cjs/store/projection.d.cts +66 -0
  106. package/dist/types-cjs/store/reconcile.d.cts +23 -0
  107. package/dist/types-cjs/store/store.d.cts +125 -0
  108. package/dist/types-cjs/store/storePath.d.cts +58 -0
  109. package/dist/types-cjs/store/utils.d.cts +114 -0
  110. package/package.json +35 -27
@@ -9,7 +9,16 @@ export declare let clock: number;
9
9
  export declare let activeTransition: Transition | null;
10
10
  export declare let projectionWriteActive: boolean;
11
11
  export declare let _hitUnhandledAsync: boolean;
12
+ export declare function registerTransientStoreNode(node: Signal<any>): void;
12
13
  export declare function resetUnhandledAsync(): void;
14
+ /**
15
+ * Toggles the dev-mode "must be inside a `<Loading>` boundary" enforcement
16
+ * window. Only `render()` calls this — wrapping the initial mount so that a
17
+ * top-level uncaught async read surfaces the diagnostic. Not part of the
18
+ * user-facing API.
19
+ *
20
+ * @internal
21
+ */
13
22
  export declare function enforceLoadingBoundary(enabled: boolean): void;
14
23
  export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
15
24
  export declare function setProjectionWriteActive(value: boolean): void;
@@ -29,6 +38,7 @@ export interface Transition {
29
38
  _actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
30
39
  _queueStash: QueueStub;
31
40
  _done: boolean | Transition;
41
+ _gatedSubs: Set<Computed<any>>;
32
42
  }
33
43
  export declare function schedule(): void;
34
44
  export interface IQueue {
@@ -57,25 +67,56 @@ export declare class Queue implements IQueue {
57
67
  }
58
68
  export declare class GlobalQueue extends Queue {
59
69
  _running: boolean;
70
+ _pendingNode: Signal<any> | null;
60
71
  _pendingNodes: Signal<any>[];
61
72
  _optimisticNodes: OptimisticNode[];
62
73
  _optimisticStores: Set<any>;
63
74
  static _update: (el: Computed<unknown>) => void;
64
75
  static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
76
+ static _runEffect: (el: Computed<unknown>) => void;
65
77
  static _clearOptimisticStore: ((store: any) => void) | null;
66
78
  flush(): void;
67
79
  notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
68
80
  initTransition(transition?: Transition | null): void;
69
81
  }
82
+ export declare function queuePendingNode(node: Signal<any>): void;
70
83
  export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
71
84
  export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
72
85
  export declare function trackOptimisticStore(store: any): void;
73
86
  export declare const globalQueue: GlobalQueue;
74
87
  /**
75
- * By default, changes are batched on the microtask queue which is an async process. You can flush
76
- * the queue synchronously to get the latest updates by calling `flush()`.
88
+ * Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
89
+ * flush scope before draining the queue.
90
+ *
91
+ * Reactive updates are normally batched onto the microtask queue, so multiple
92
+ * writes in a row collapse into a single update pass. Call `flush()` when you
93
+ * need to *observe* the result of those writes synchronously — most commonly
94
+ * in tests, but also at the boundary of imperative integration code. Pass a
95
+ * callback when the writes themselves should bypass microtask scheduling and
96
+ * drain synchronously when the callback returns.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const [count, setCount] = createSignal(0);
101
+ * const doubled = createMemo(() => count() * 2);
102
+ *
103
+ * setCount(5);
104
+ * flush();
105
+ * expect(doubled()).toBe(10);
106
+ *
107
+ * flush(() => setCount(6));
108
+ * expect(doubled()).toBe(12);
109
+ *
110
+ * // Nested flushes drain at each level:
111
+ * flush(() => {
112
+ * setCount(7);
113
+ * flush(() => setCount(8)); // inner drain — effects fire here
114
+ * // outer continues with up-to-date state
115
+ * });
116
+ * ```
77
117
  */
78
118
  export declare function flush(): void;
119
+ export declare function flush<T>(fn: () => T): T;
79
120
  export declare function currentTransition(transition: Transition): Transition;
80
121
  export declare function setActiveTransition(transition: Transition | null): void;
81
122
  export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
@@ -16,11 +16,12 @@ export interface NodeOptions<T> {
16
16
  name?: string;
17
17
  transparent?: boolean;
18
18
  equals?: ((prev: T, next: T) => boolean) | false;
19
- pureWrite?: boolean;
19
+ ownedWrite?: boolean;
20
20
  /** Exclude this signal from snapshot capture (internal — not part of public API) */
21
21
  _noSnapshot?: boolean;
22
22
  unobserved?: () => void;
23
23
  lazy?: boolean;
24
+ sync?: boolean;
24
25
  }
25
26
  export interface RawSignal<T> {
26
27
  _subs: Link | null;
@@ -29,8 +30,7 @@ export interface RawSignal<T> {
29
30
  _snapshotValue?: any;
30
31
  _name?: string;
31
32
  _equals: false | ((a: T, b: T) => boolean);
32
- _pureWrite?: boolean;
33
- _noSnapshot?: boolean;
33
+ _config: number;
34
34
  _unobserved?: () => void;
35
35
  _time: number;
36
36
  _transition: Transition | null;
@@ -48,8 +48,7 @@ export interface FirewallSignal<T> extends RawSignal<T> {
48
48
  export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
49
49
  export interface Owner {
50
50
  id?: string;
51
- _transparent?: boolean;
52
- _childrenForbidden?: boolean;
51
+ _config: number;
53
52
  _snapshotScope?: boolean;
54
53
  _disposal: Disposable | Disposable[] | null;
55
54
  _parent: Owner | null;
@@ -58,6 +57,7 @@ export interface Owner {
58
57
  _queue: IQueue;
59
58
  _firstChild: Owner | null;
60
59
  _nextSibling: Owner | null;
60
+ _prevSibling: Owner | null;
61
61
  _pendingDisposal: Disposable | Disposable[] | null;
62
62
  _pendingFirstChild: Owner | null;
63
63
  }
@@ -65,7 +65,6 @@ export interface Computed<T> extends RawSignal<T>, Owner {
65
65
  _deps: Link | null;
66
66
  _depsTail: Link | null;
67
67
  _flags: number;
68
- _inSnapshotScope?: boolean;
69
68
  _blocked?: boolean;
70
69
  _pendingSource?: Computed<any>;
71
70
  _pendingSources?: Set<Computed<any>>;
@@ -1,9 +1,9 @@
1
1
  export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest, isRefreshing, refresh, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, enforceLoadingBoundary, enableExternalSource } from "./core/index.js";
2
2
  import { type Dev } from "./core/index.js";
3
3
  export declare const DEV: Dev | undefined;
4
- export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.js";
4
+ export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Refreshable, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.js";
5
5
  export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled, onCleanup } from "./signals.js";
6
- export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
6
+ export type { Accessor, SourceAccessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
7
7
  export { mapArray, repeat, type Maybe } from "./map.js";
8
8
  export * from "./store/index.js";
9
- export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten } from "./boundaries.js";
9
+ export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.js";
@@ -1,9 +1,28 @@
1
1
  import { type Accessor } from "./signals.js";
2
2
  export type Maybe<T> = T | void | null | undefined | false;
3
3
  /**
4
- * Reactively transforms an array with a callback function - underlying helper for the `<For>` control flow
4
+ * Reactively maps an array, reusing the previously-mapped value for unchanged
5
+ * items. The callback receives `(value, index)` as accessors so individual
6
+ * items and indexes can be subscribed to without re-running the mapper.
5
7
  *
6
- * similar to `Array.prototype.map`, but gets the value and index as accessors, transforms only values that changed and returns an accessor and reactively tracks changes to the list.
8
+ * This is the underlying helper that powers `<For>`. App code should use
9
+ * `<For>` directly; reach for `mapArray` when implementing custom list
10
+ * components.
11
+ *
12
+ * - `options.keyed` — `true` (default for primitives) compares by identity;
13
+ * `false` falls back to index-only mapping; pass a function `(item) => key`
14
+ * for stable identity by extracted key.
15
+ * - `options.fallback` — accessor returning a value to show when the input is
16
+ * empty.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const view = mapArray(
21
+ * items,
22
+ * (item, index) => `${index()}: ${item().label}`,
23
+ * { fallback: () => "no items" }
24
+ * );
25
+ * ```
7
26
  *
8
27
  * @description https://docs.solidjs.com/reference/reactive-utilities/map-array
9
28
  */
@@ -13,7 +32,17 @@ export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly
13
32
  name?: string;
14
33
  }): Accessor<MappedItem[]>;
15
34
  /**
16
- * Reactively repeats a callback function the count provided - underlying helper for the `<Repeat>` control flow
35
+ * Reactively renders a callback `count` times, reusing previously-rendered
36
+ * entries when only the count changes. Underlying helper for `<Repeat>`.
37
+ *
38
+ * - `options.from` — start index (default `0`); useful for offset/windowed
39
+ * rendering.
40
+ * - `options.fallback` — accessor returning a value to show when count is `0`.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const view = repeat(count, i => `Item ${i}`, { fallback: () => "empty" });
45
+ * ```
17
46
  *
18
47
  * @description https://docs.solidjs.com/reference/reactive-utilities/repeat
19
48
  */