@solidjs/signals 2.0.0-beta.8 → 2.0.0-rc.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.
Files changed (95) hide show
  1. package/README.md +13 -9
  2. package/dist/dev.js +6078 -1440
  3. package/dist/node.cjs +7684 -3248
  4. package/dist/prod/affects.js +126 -0
  5. package/dist/prod/boundaries.js +572 -0
  6. package/dist/prod/core/action.js +139 -0
  7. package/dist/prod/core/async.js +553 -0
  8. package/dist/prod/core/constants.js +92 -0
  9. package/dist/prod/core/context.js +67 -0
  10. package/dist/prod/core/core.js +817 -0
  11. package/dist/prod/core/dev.js +3 -0
  12. package/dist/prod/core/effect.js +145 -0
  13. package/dist/prod/core/error.js +68 -0
  14. package/dist/prod/core/external.js +98 -0
  15. package/dist/prod/core/graph.js +104 -0
  16. package/dist/prod/core/heap.js +140 -0
  17. package/dist/prod/core/invariants.js +42 -0
  18. package/dist/prod/core/lanes.js +140 -0
  19. package/dist/prod/core/optimistic.js +245 -0
  20. package/dist/prod/core/owner.js +302 -0
  21. package/dist/prod/core/scheduler.js +749 -0
  22. package/dist/prod/core/verdict.js +369 -0
  23. package/dist/prod/index.js +45 -0
  24. package/dist/prod/map.js +317 -0
  25. package/dist/prod/signals.js +375 -0
  26. package/dist/prod/store/optimistic.js +217 -0
  27. package/dist/prod/store/projection.js +231 -0
  28. package/dist/prod/store/reconcile.js +707 -0
  29. package/dist/prod/store/store.js +1081 -0
  30. package/dist/prod/store/storePath.js +103 -0
  31. package/dist/prod/store/utils.js +328 -0
  32. package/dist/types/affects.d.ts +47 -0
  33. package/dist/types/boundaries.d.ts +93 -11
  34. package/dist/types/core/action.d.ts +63 -0
  35. package/dist/types/core/async.d.ts +16 -1
  36. package/dist/types/core/constants.d.ts +46 -0
  37. package/dist/types/core/context.d.ts +10 -2
  38. package/dist/types/core/core.d.ts +111 -17
  39. package/dist/types/core/dev.d.ts +17 -2
  40. package/dist/types/core/effect.d.ts +1 -2
  41. package/dist/types/core/error.d.ts +33 -0
  42. package/dist/types/core/external.d.ts +0 -11
  43. package/dist/types/core/graph.d.ts +2 -1
  44. package/dist/types/core/heap.d.ts +8 -0
  45. package/dist/types/core/index.d.ts +3 -2
  46. package/dist/types/core/invariants.d.ts +59 -0
  47. package/dist/types/core/lanes.d.ts +2 -0
  48. package/dist/types/core/optimistic.d.ts +6 -0
  49. package/dist/types/core/owner.d.ts +101 -3
  50. package/dist/types/core/scheduler.d.ts +97 -9
  51. package/dist/types/core/types.d.ts +68 -6
  52. package/dist/types/core/verdict.d.ts +2 -0
  53. package/dist/types/index.d.ts +4 -3
  54. package/dist/types/map.d.ts +50 -5
  55. package/dist/types/signals.d.ts +424 -19
  56. package/dist/types/store/index.d.ts +1 -1
  57. package/dist/types/store/optimistic.d.ts +39 -13
  58. package/dist/types/store/projection.d.ts +48 -18
  59. package/dist/types/store/reconcile.d.ts +46 -1
  60. package/dist/types/store/store.d.ts +164 -19
  61. package/dist/types/store/storePath.d.ts +28 -0
  62. package/dist/types/store/utils.d.ts +78 -7
  63. package/dist/types-cjs/affects.d.cts +47 -0
  64. package/dist/types-cjs/boundaries.d.cts +93 -11
  65. package/dist/types-cjs/core/action.d.cts +63 -0
  66. package/dist/types-cjs/core/async.d.cts +16 -1
  67. package/dist/types-cjs/core/constants.d.cts +46 -0
  68. package/dist/types-cjs/core/context.d.cts +10 -2
  69. package/dist/types-cjs/core/core.d.cts +111 -17
  70. package/dist/types-cjs/core/dev.d.cts +17 -2
  71. package/dist/types-cjs/core/effect.d.cts +1 -2
  72. package/dist/types-cjs/core/error.d.cts +33 -0
  73. package/dist/types-cjs/core/external.d.cts +0 -11
  74. package/dist/types-cjs/core/graph.d.cts +2 -1
  75. package/dist/types-cjs/core/heap.d.cts +8 -0
  76. package/dist/types-cjs/core/index.d.cts +3 -2
  77. package/dist/types-cjs/core/invariants.d.cts +59 -0
  78. package/dist/types-cjs/core/lanes.d.cts +2 -0
  79. package/dist/types-cjs/core/optimistic.d.cts +6 -0
  80. package/dist/types-cjs/core/owner.d.cts +101 -3
  81. package/dist/types-cjs/core/scheduler.d.cts +97 -9
  82. package/dist/types-cjs/core/types.d.cts +68 -6
  83. package/dist/types-cjs/core/verdict.d.cts +2 -0
  84. package/dist/types-cjs/index.d.cts +4 -3
  85. package/dist/types-cjs/map.d.cts +50 -5
  86. package/dist/types-cjs/signals.d.cts +424 -19
  87. package/dist/types-cjs/store/index.d.cts +1 -1
  88. package/dist/types-cjs/store/optimistic.d.cts +39 -13
  89. package/dist/types-cjs/store/projection.d.cts +48 -18
  90. package/dist/types-cjs/store/reconcile.d.cts +46 -1
  91. package/dist/types-cjs/store/store.d.cts +164 -19
  92. package/dist/types-cjs/store/storePath.d.cts +28 -0
  93. package/dist/types-cjs/store/utils.d.cts +78 -7
  94. package/package.json +14 -11
  95. package/dist/prod.js +0 -3577
@@ -0,0 +1,92 @@
1
+ const REACTIVE_NONE = 0;
2
+
3
+ const REACTIVE_CHECK = 1 << 0;
4
+
5
+ const REACTIVE_DIRTY = 1 << 1;
6
+
7
+ const REACTIVE_RECOMPUTING_DEPS = 1 << 2;
8
+
9
+ const REACTIVE_IN_HEAP = 1 << 3;
10
+
11
+ const REACTIVE_IN_HEAP_HEIGHT = 1 << 4;
12
+
13
+ const REACTIVE_ZOMBIE = 1 << 5;
14
+
15
+ const REACTIVE_DISPOSED = 1 << 6;
16
+
17
+ const REACTIVE_OPTIMISTIC_DIRTY = 1 << 7;
18
+
19
+ const REACTIVE_SNAPSHOT_STALE = 1 << 8;
20
+
21
+ const REACTIVE_LAZY = 1 << 9;
22
+
23
+ const REACTIVE_MANUAL_WRITE = 1 << 10;
24
+
25
+ /**
26
+ * The pending recompute is a re-ask of the same question: `refresh()` dirtied
27
+ * the node while no tracked input changed value. Cleared whenever a real
28
+ * value-change notification arrives (`insertSubs`), and consumed by
29
+ * `recompute` into the node's `_reask` classification — a quiet (re-ask)
30
+ * pending window does not read as pending (question-scoped pending model).
31
+ */ const REACTIVE_REASK = 1 << 11;
32
+
33
+ // Static configuration bits packed into Owner/Computed/Signal _config.
34
+ const CONFIG_OWNED_WRITE = 1 << 0;
35
+
36
+ const CONFIG_NO_SNAPSHOT = 1 << 1;
37
+
38
+ const CONFIG_TRANSPARENT = 1 << 2;
39
+
40
+ const CONFIG_IN_SNAPSHOT_SCOPE = 1 << 3;
41
+
42
+ const CONFIG_CHILDREN_FORBIDDEN = 1 << 4;
43
+
44
+ const CONFIG_AUTO_DISPOSE = 1 << 5;
45
+
46
+ const CONFIG_SYNC = 1 << 6;
47
+
48
+ const STATUS_PENDING = 1 << 0;
49
+
50
+ const STATUS_ERROR = 1 << 1;
51
+
52
+ const STATUS_UNINITIALIZED = 1 << 2;
53
+
54
+ const EFFECT_RENDER = 1;
55
+
56
+ const EFFECT_USER = 2;
57
+
58
+ const EFFECT_TRACKED = 3;
59
+
60
+ const NOT_PENDING = {};
61
+
62
+ const NO_SNAPSHOT = {};
63
+
64
+ /**
65
+ * Stand-in stored in `_overrideValue` for an optimistic write of literal
66
+ * `undefined` (#2898). The slot doubles as the optimistic-node brand
67
+ * (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
68
+ * would erase the node's optimistic identity: the write turns invisible and
69
+ * follow-up writes route off the optimistic path and commit permanently.
70
+ * Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
71
+ * via `visibleOverrideValue`; slot identity tests stay raw.
72
+ */ const OVERRIDE_UNDEFINED = {};
73
+
74
+ /** Unwrap an active override's stored value for surfacing to readers (#2898). */ function unwrapOverride(E) {
75
+ return E === OVERRIDE_UNDEFINED ? undefined : E;
76
+ }
77
+
78
+ const STORE_SNAPSHOT_PROPS = "sp";
79
+
80
+ const SUPPORTS_PROXY = typeof Proxy === "function";
81
+
82
+ const defaultContext = {};
83
+
84
+ /**
85
+ * Brand symbol used by `Refreshable<T>` values (projection stores, async
86
+ * memos) to expose their underlying computation to `refresh()`. Not part of
87
+ * the user-facing API.
88
+ *
89
+ * @internal
90
+ */ const $REFRESH = Symbol("refresh");
91
+
92
+ export { $REFRESH, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, CONFIG_IN_SNAPSHOT_SCOPE, CONFIG_NO_SNAPSHOT, CONFIG_OWNED_WRITE, CONFIG_SYNC, CONFIG_TRANSPARENT, EFFECT_RENDER, EFFECT_TRACKED, EFFECT_USER, NOT_PENDING, NO_SNAPSHOT, OVERRIDE_UNDEFINED, REACTIVE_CHECK, REACTIVE_DIRTY, REACTIVE_DISPOSED, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_LAZY, REACTIVE_MANUAL_WRITE, REACTIVE_NONE, REACTIVE_OPTIMISTIC_DIRTY, REACTIVE_REASK, REACTIVE_RECOMPUTING_DEPS, REACTIVE_SNAPSHOT_STALE, REACTIVE_ZOMBIE, STATUS_ERROR, STATUS_PENDING, STATUS_UNINITIALIZED, STORE_SNAPSHOT_PROPS, SUPPORTS_PROXY, defaultContext, unwrapOverride };
@@ -0,0 +1,67 @@
1
+ import { NoOwnerError, ContextNotFoundError } from "./error.js";
2
+
3
+ import { getOwner } from "./owner.js";
4
+
5
+ /**
6
+ * Context provides a form of dependency injection. It is used to save from needing to pass
7
+ * data as props through intermediate components. This function creates a new context object
8
+ * that can be used with `getContext` and `setContext`.
9
+ *
10
+ * A default value can be provided here which will be used when a specific value is not provided
11
+ * via a `setContext` call.
12
+ */ function createContext(e, t) {
13
+ return {
14
+ id: Symbol(t),
15
+ defaultValue: e
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Low-level owner-targeted context read. The user-facing read API is
21
+ * `useContext` (in `solid-js`), which wraps this primitive. Exposed here for
22
+ * cross-package wiring (e.g. hydration-aware context plumbing).
23
+ *
24
+ * @throws `NoOwnerError` if there's no owner at the time of call.
25
+ * @throws `ContextNotFoundError` if a context value has not been set yet.
26
+ *
27
+ * @internal
28
+ */ function getContext(e, t = getOwner()) {
29
+ if (!t) {
30
+ throw new NoOwnerError;
31
+ }
32
+ const n = hasContext(e, t) ? t.we[e.id] : e.defaultValue;
33
+ if (isUndefined(n)) {
34
+ throw new ContextNotFoundError;
35
+ }
36
+ return n;
37
+ }
38
+
39
+ /**
40
+ * Low-level owner-targeted context write. The user-facing API is
41
+ * `createContext` (in `solid-js`); its provider component wraps this
42
+ * primitive. Exposed here for cross-package wiring.
43
+ *
44
+ * @throws `NoOwnerError` if there's no owner at the time of call.
45
+ *
46
+ * @internal
47
+ */ function setContext(e, t, n = getOwner()) {
48
+ if (!n) {
49
+ throw new NoOwnerError;
50
+ }
51
+ // We're creating a new object to avoid child context values being exposed to parent owners. If
52
+ // we don't do this, everything will be a singleton and all hell will break lose.
53
+ n.we = {
54
+ ...n.we,
55
+ [e.id]: isUndefined(t) ? e.defaultValue : t
56
+ };
57
+ }
58
+
59
+ function hasContext(e, t) {
60
+ return !isUndefined(t?.we[e.id]);
61
+ }
62
+
63
+ function isUndefined(e) {
64
+ return typeof e === "undefined";
65
+ }
66
+
67
+ export { createContext, getContext, setContext };