@solidjs/signals 2.0.0-rc.4 → 2.0.0-rc.5

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 (53) hide show
  1. package/dist/dev.js +1169 -186
  2. package/dist/node.cjs +2041 -1167
  3. package/dist/prod/boundaries.js +4 -1
  4. package/dist/prod/core/async.js +124 -95
  5. package/dist/prod/core/constants.js +55 -1
  6. package/dist/prod/core/core.js +297 -222
  7. package/dist/prod/core/effect.js +28 -28
  8. package/dist/prod/core/error.js +13 -1
  9. package/dist/prod/core/external.js +2 -2
  10. package/dist/prod/core/graph.js +27 -27
  11. package/dist/prod/core/heap.js +30 -30
  12. package/dist/prod/core/lanes.js +32 -32
  13. package/dist/prod/core/optimistic.js +54 -54
  14. package/dist/prod/core/owner.js +34 -34
  15. package/dist/prod/core/scheduler.js +318 -137
  16. package/dist/prod/core/verdict.js +112 -59
  17. package/dist/prod/index.js +3 -3
  18. package/dist/prod/map.js +106 -106
  19. package/dist/prod/signals.js +253 -25
  20. package/dist/prod/store/next/optimistic.js +262 -123
  21. package/dist/prod/store/next/patch.js +6 -6
  22. package/dist/prod/store/next/projection.js +23 -19
  23. package/dist/prod/store/next/store.js +129 -35
  24. package/dist/prod/store/store.js +2 -2
  25. package/dist/types/core/async.d.ts +2 -0
  26. package/dist/types/core/attribution.d.ts +9 -4
  27. package/dist/types/core/constants.d.ts +54 -0
  28. package/dist/types/core/core.d.ts +19 -20
  29. package/dist/types/core/error.d.ts +9 -0
  30. package/dist/types/core/index.d.ts +2 -2
  31. package/dist/types/core/scheduler.d.ts +34 -0
  32. package/dist/types/core/types.d.ts +12 -0
  33. package/dist/types/index.d.ts +3 -3
  34. package/dist/types/signals.d.ts +108 -0
  35. package/dist/types/store/next/optimistic.d.ts +13 -10
  36. package/dist/types/store/next/projection.d.ts +1 -1
  37. package/dist/types/store/next/store.d.ts +22 -0
  38. package/dist/types/store/next/target.d.ts +15 -0
  39. package/dist/types-cjs/core/async.d.cts +2 -0
  40. package/dist/types-cjs/core/attribution.d.cts +9 -4
  41. package/dist/types-cjs/core/constants.d.cts +54 -0
  42. package/dist/types-cjs/core/core.d.cts +19 -20
  43. package/dist/types-cjs/core/error.d.cts +9 -0
  44. package/dist/types-cjs/core/index.d.cts +2 -2
  45. package/dist/types-cjs/core/scheduler.d.cts +34 -0
  46. package/dist/types-cjs/core/types.d.cts +12 -0
  47. package/dist/types-cjs/index.d.cts +3 -3
  48. package/dist/types-cjs/signals.d.cts +108 -0
  49. package/dist/types-cjs/store/next/optimistic.d.cts +13 -10
  50. package/dist/types-cjs/store/next/projection.d.cts +1 -1
  51. package/dist/types-cjs/store/next/store.d.cts +22 -0
  52. package/dist/types-cjs/store/next/target.d.cts +15 -0
  53. package/package.json +1 -1
@@ -1,20 +1,23 @@
1
+ import { type Transition } from "../../core/scheduler.cjs";
1
2
  import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "../store.cjs";
2
- import type { StoreNextFamily, StoreNextTarget } from "./target.cjs";
3
+ import type { StoreNextTarget } from "./target.cjs";
4
+ /** #3164 fold: a stamped truth is HELD (masked from ordinary readers until
5
+ * the reveal) only while its transition is live AND retaining optimism —
6
+ * overrides are what make partial-coverage composition a tear. A plain
7
+ * async transition carries no overrides, so downstream computes must see
8
+ * staged values to converge (normal speculation). Resolves merges first:
9
+ * merge unions optimistic nodes/stores into the target. */
10
+ export declare function transitionHoldsOptimism(transition: Transition): boolean;
3
11
  export declare function createOptimisticStoreNext<T extends object = {}>(first: T | ((store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>), second?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
4
12
  /** Diff the draft against the current OPTIMISTIC VIEW (committed + active
5
13
  * overrides — the same view the draft was seeded from) and emit engine writes
6
14
  * for exactly the changed keys. Visible-view diffing keeps no-op writes from
7
15
  * entangling lanes (RUL-10 / opt R38). */
8
16
  export declare function notifyOptimisticWrites(t: StoreNextTarget, pb: Record<PropertyKey, any>): void;
9
- /**
10
- * Landing consumption (RUL-2): fresh authoritative data supersedes every
11
- * tentative override in the family. Mirrors legacy clearProjectionOverride —
12
- * drop the override, clear lane/ownership, notify subscribers whose visible
13
- * value changes (reversion effects go to regular queues via the projection
14
- * write posture the caller holds).
15
- */
16
- export declare function consumeOverridesNext(fam: StoreNextFamily): void;
17
17
  /** Optimistic-view composition for snapshot/deep (O1: snapshot is the CURRENT
18
18
  * view, lane values included; a fresh copy per call during pending windows —
19
- * RUL-12). Returns `src` untouched when no override is active on `t`. */
19
+ * RUL-12). Returns `src` untouched when no override is active on `t`.
20
+ * Authoritative-view reads (until()'s predicate) skip composition entirely:
21
+ * the predicate observes authoritative truth, never the caller's tentative
22
+ * overlay. (Write-side emission callers never run under such a compute.) */
20
23
  export declare function optimisticView(t: StoreNextTarget, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
@@ -5,4 +5,4 @@ export declare function createProjectionNext<T extends object = {}>(fn: (draft:
5
5
  * masks the recompute for the tick (core R31 — the manual write wins over a
6
6
  * same-flush dependency change). */
7
7
  export declare function createStoreDerivedNext<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>>, (f: (draft: T) => T | void) => void];
8
- export declare function runProjectionComputedNext<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>;
8
+ export declare function runProjectionComputedNext<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, value: T) => void, aroundDraftWrite?: (op: () => void) => void): Computed<void | T>;
@@ -30,9 +30,16 @@ export declare function materializePB(target: StoreNextTarget): void;
30
30
  * authoritative base (R21/R32).
31
31
  */
32
32
  export declare function adoptPB(target: StoreNextTarget, incoming: Record<PropertyKey, any>, eager?: boolean): void;
33
+ /** Parked truth-staged pending backings (#3164 fold): a tentative draft that
34
+ * opens while a folded landing's backing is live moves the staged container
35
+ * here (see ensurePB); the tentative discard in notifyOptimisticWrites
36
+ * restores it in place of the usual null. */
37
+ export declare const stagedTruthPB: WeakMap<StoreNextTarget, Record<PropertyKey, any>>;
33
38
  /** Same logical slot: both values resolve to one (re-pointed) child target —
34
39
  * adoption preserved identity, so the slot did not change (R9). */
35
40
  export declare function targetsEqual(ov: any, nv: any): boolean;
41
+ export declare function arrayStructureChanged(old: any[], neu: any[]): boolean;
42
+ export declare function membershipChanged(old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): boolean;
36
43
  /**
37
44
  * The fold diff walks SUBSCRIPTION KEYS ONLY (legacy parity: `for key in
38
45
  * nodes`): nodes exist exactly where something tracked, so unobserved data
@@ -62,6 +69,21 @@ export declare function runAuthoritative<T>(fn: () => T): T;
62
69
  /** Active optimistic override on an armed node (armed slot idles at
63
70
  * NOT_PENDING; undefined = unarmed plain node). */
64
71
  export declare function hasActiveOverride(node: Signal<any>): boolean;
72
+ /** The reading computation is until()'s authoritative-view predicate — same
73
+ * source of truth as core read()'s A17 carve-out (`context`, which persists
74
+ * under untrack). optimisticView()'s composition gate consults exactly this:
75
+ * write-side machinery (patch emission, tentative re-application) must keep
76
+ * composing even when it runs inside an authoritative-write bracket. */
77
+ export declare function authoritativeRead(): boolean;
78
+ /** Serve-side authoritative gate: until()'s predicate PLUS truth authors —
79
+ * the projection derive's draft (wrapDraft trap brackets, runAuthoritative;
80
+ * the same posture pair ensurePB classifies drafts by). A source computing
81
+ * the next truth must never read its callers' tentative overlays: a derive
82
+ * continuation's `store.push` computing its index from an action's
83
+ * optimistic row landed truth in the wrong slot and corrupted committed
84
+ * state (#3108). Trap-level overlay serves gate on this so values, length,
85
+ * membership, and keys leave the authoritative view together. */
86
+ export declare function authoritativeServe(): boolean;
65
87
  export type SetStoreNextFunction<T> = (fn: (draft: T) => T | void) => void;
66
88
  /** Low-level setter primitive: opens write mode on a next proxy, runs `fn`,
67
89
  * emits write-time notifications at outermost exit, applies returned
@@ -27,6 +27,17 @@ export interface StoreNextFamily {
27
27
  /** Targets currently carrying active node overrides (landing-consumption
28
28
  * walk, RUL-2: visible landed truth replaces optimism). */
29
29
  overlaid?: Set<any>;
30
+ /** Retaining transactions (#3164 fold ruling): every transaction that made
31
+ * an optimistic setter call on this family and may still be open. While
32
+ * any member is live, truth landings FOLD — they stage into the retaining
33
+ * transaction and reveal atomically at its settle, exactly like a signal
34
+ * landing under an active override. Dead members prune lazily at each
35
+ * landing (retainingTransition). */
36
+ rt?: Set<any>;
37
+ /** Normalized row-key fn (same resolution as the projection channels:
38
+ * `options.key`, "id" default, null = unkeyed). The staged-landing walk
39
+ * reads it: key-matched rows keep their proxy identity across a fold. */
40
+ key?: ((item: any) => any) | null;
30
41
  map: WeakMap<object, StoreNextTarget>;
31
42
  /** The projection computed — assigned after creation (accessor pattern). */
32
43
  node: Computed<any> | null;
@@ -159,6 +170,10 @@ export interface OptStoreHooks {
159
170
  notifyOptimisticWrites(t: any, pb: Record<PropertyKey, any>): void;
160
171
  optimisticView(t: any, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
161
172
  applyTentative(t: any, incoming: any, keyFn: ((item: any) => any) | null): void;
173
+ /** #3164 fold: does this live transaction still retain optimism (armed
174
+ * nodes or tracked stores)? Backs the held-truth masks in next/store.ts so
175
+ * plain-store bundles don't carry the transition-optimism probe. */
176
+ retainsOptimism(t: any): boolean;
162
177
  }
163
178
  export declare let optHooks: OptStoreHooks | null;
164
179
  export declare function setOptHooks(h: OptStoreHooks): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.5",
4
4
  "description": "Solid's reactive primitives: signals, memos, effects, stores, and async-aware computations.",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",