@solidjs/signals 2.0.0-beta.9 → 2.0.0-rc.1
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 +14 -10
- package/dist/dev.js +6740 -2011
- package/dist/node.cjs +7927 -3340
- package/dist/prod/affects.js +126 -0
- package/dist/prod/boundaries.js +572 -0
- package/dist/prod/core/action.js +139 -0
- package/dist/prod/core/async.js +607 -0
- package/dist/prod/core/constants.js +92 -0
- package/dist/prod/core/context.js +67 -0
- package/dist/prod/core/core.js +828 -0
- package/dist/prod/core/dev.js +3 -0
- package/dist/prod/core/effect.js +145 -0
- package/dist/prod/core/error.js +68 -0
- package/dist/prod/core/external.js +98 -0
- package/dist/prod/core/graph.js +104 -0
- package/dist/prod/core/heap.js +140 -0
- package/dist/prod/core/invariants.js +42 -0
- package/dist/prod/core/lanes.js +140 -0
- package/dist/prod/core/optimistic.js +262 -0
- package/dist/prod/core/owner.js +302 -0
- package/dist/prod/core/scheduler.js +757 -0
- package/dist/prod/core/verdict.js +369 -0
- package/dist/prod/index.js +45 -0
- package/dist/prod/map.js +319 -0
- package/dist/prod/signals.js +394 -0
- package/dist/prod/store/index.js +36 -0
- package/dist/prod/store/next/optimistic.js +377 -0
- package/dist/prod/store/next/projection.js +172 -0
- package/dist/prod/store/next/reconcile.js +327 -0
- package/dist/prod/store/next/store.js +1232 -0
- package/dist/prod/store/next/target.js +20 -0
- package/dist/prod/store/store.js +325 -0
- package/dist/prod/store/storePath.js +103 -0
- package/dist/prod/store/utils.js +201 -0
- package/dist/types/affects.d.ts +47 -0
- package/dist/types/boundaries.d.ts +60 -13
- package/dist/types/core/action.d.ts +35 -6
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +35 -6
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +66 -63
- package/dist/types/core/dev.d.ts +17 -2
- package/dist/types/core/effect.d.ts +1 -2
- package/dist/types/core/error.d.ts +33 -0
- package/dist/types/core/external.d.ts +0 -11
- package/dist/types/core/graph.d.ts +2 -1
- package/dist/types/core/heap.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/invariants.d.ts +59 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/optimistic.d.ts +6 -0
- package/dist/types/core/owner.d.ts +50 -3
- package/dist/types/core/scheduler.d.ts +85 -11
- package/dist/types/core/types.d.ts +66 -1
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/map.d.ts +21 -5
- package/dist/types/signals.d.ts +183 -12
- package/dist/types/store/index.d.ts +16 -6
- package/dist/types/store/next/optimistic.d.ts +20 -0
- package/dist/types/store/next/projection.d.ts +24 -0
- package/dist/types/store/next/reconcile.d.ts +3 -0
- package/dist/types/store/next/store.d.ts +71 -0
- package/dist/types/store/next/target.d.ts +99 -0
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +10 -6
- package/dist/types/store/reconcile.d.ts +31 -8
- package/dist/types/store/store.d.ts +91 -71
- package/dist/types/store/utils.d.ts +0 -40
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +60 -13
- package/dist/types-cjs/core/action.d.cts +35 -6
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +35 -6
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +66 -63
- package/dist/types-cjs/core/dev.d.cts +17 -2
- package/dist/types-cjs/core/effect.d.cts +1 -2
- package/dist/types-cjs/core/error.d.cts +33 -0
- package/dist/types-cjs/core/external.d.cts +0 -11
- package/dist/types-cjs/core/graph.d.cts +2 -1
- package/dist/types-cjs/core/heap.d.cts +8 -0
- package/dist/types-cjs/core/index.d.cts +3 -2
- package/dist/types-cjs/core/invariants.d.cts +59 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/optimistic.d.cts +6 -0
- package/dist/types-cjs/core/owner.d.cts +50 -3
- package/dist/types-cjs/core/scheduler.d.cts +85 -11
- package/dist/types-cjs/core/types.d.cts +66 -1
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +3 -2
- package/dist/types-cjs/map.d.cts +21 -5
- package/dist/types-cjs/signals.d.cts +183 -12
- package/dist/types-cjs/store/index.d.cts +16 -6
- package/dist/types-cjs/store/next/optimistic.d.cts +20 -0
- package/dist/types-cjs/store/next/projection.d.cts +24 -0
- package/dist/types-cjs/store/next/reconcile.d.cts +3 -0
- package/dist/types-cjs/store/next/store.d.cts +71 -0
- package/dist/types-cjs/store/next/target.d.cts +99 -0
- package/dist/types-cjs/store/optimistic.d.cts +3 -3
- package/dist/types-cjs/store/projection.d.cts +10 -6
- package/dist/types-cjs/store/reconcile.d.cts +31 -8
- package/dist/types-cjs/store/store.d.cts +91 -71
- package/dist/types-cjs/store/utils.d.cts +0 -40
- package/package.json +12 -9
- package/dist/prod.js +0 -3627
|
@@ -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 };
|