@fluixi/reactive 1.0.0-alpha.83 → 1.0.0-alpha.84
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/dist/cdn/reactive.cjs +2673 -1
- package/dist/cdn/reactive.global.js +2 -1
- package/dist/cdn/reactive.mjs +2657 -1
- package/dist/cdn/signal.cjs +299 -1
- package/dist/cdn/signal.d.ts +1 -1
- package/dist/cdn/signal.global.js +2 -1
- package/dist/cdn/signal.js +1 -1
- package/dist/cdn/signal.mjs +276 -1
- package/dist/index.cjs +2673 -1
- package/dist/index.mjs +2657 -1
- package/dist/lib/index.cjs +2674 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.mjs +2659 -1
- package/dist/lib/observable/index.cjs +386 -1
- package/dist/lib/observable/index.mjs +364 -1
- package/dist/lib/observable/observable.cjs +384 -1
- package/dist/lib/observable/observable.d.ts +0 -137
- package/dist/lib/observable/observable.d.ts.map +1 -1
- package/dist/lib/observable/observable.js +0 -71
- package/dist/lib/observable/observable.mjs +361 -1
- package/dist/lib/observable/subscription.cjs +180 -1
- package/dist/lib/observable/subscription.d.ts +0 -12
- package/dist/lib/observable/subscription.d.ts.map +1 -1
- package/dist/lib/observable/subscription.js +0 -12
- package/dist/lib/observable/subscription.mjs +157 -1
- package/dist/lib/observable/types.cjs +18 -1
- package/dist/lib/observable/types.d.ts.map +1 -1
- package/dist/lib/predicates.cjs +44 -1
- package/dist/lib/predicates.d.ts +2 -2
- package/dist/lib/predicates.js +2 -2
- package/dist/lib/predicates.mjs +23 -1
- package/dist/lib/signal/api.cjs +571 -1
- package/dist/lib/signal/api.d.ts +211 -1
- package/dist/lib/signal/api.d.ts.map +1 -1
- package/dist/lib/signal/api.js +207 -12
- package/dist/lib/signal/api.mjs +548 -1
- package/dist/lib/signal/cached-resource.cjs +672 -1
- package/dist/lib/signal/cached-resource.d.ts +28 -16
- package/dist/lib/signal/cached-resource.d.ts.map +1 -1
- package/dist/lib/signal/cached-resource.js +35 -29
- package/dist/lib/signal/cached-resource.mjs +650 -1
- package/dist/lib/signal/graph/children.cjs +325 -1
- package/dist/lib/signal/graph/children.js +1 -1
- package/dist/lib/signal/graph/children.mjs +302 -1
- package/dist/lib/signal/graph/compat.cjs +578 -1
- package/dist/lib/signal/graph/compat.d.ts +13 -13
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +33 -31
- package/dist/lib/signal/graph/compat.mjs +556 -1
- package/dist/lib/signal/graph/core.cjs +295 -1
- package/dist/lib/signal/graph/core.d.ts +28 -24
- package/dist/lib/signal/graph/core.d.ts.map +1 -1
- package/dist/lib/signal/graph/core.js +38 -31
- package/dist/lib/signal/graph/core.mjs +273 -1
- package/dist/lib/signal/graph/debounced.cjs +668 -1
- package/dist/lib/signal/graph/debounced.d.ts +5 -5
- package/dist/lib/signal/graph/debounced.d.ts.map +1 -1
- package/dist/lib/signal/graph/debounced.js +5 -5
- package/dist/lib/signal/graph/debounced.mjs +645 -1
- package/dist/lib/signal/graph/derived.cjs +496 -1
- package/dist/lib/signal/graph/derived.d.ts +1 -1
- package/dist/lib/signal/graph/derived.js +1 -1
- package/dist/lib/signal/graph/derived.mjs +473 -1
- package/dist/lib/signal/graph/detect.cjs +66 -1
- package/dist/lib/signal/graph/detect.mjs +45 -1
- package/dist/lib/signal/graph/error-boundary.cjs +301 -1
- package/dist/lib/signal/graph/error-boundary.js +3 -3
- package/dist/lib/signal/graph/error-boundary.mjs +278 -1
- package/dist/lib/signal/graph/index.cjs +305 -1
- package/dist/lib/signal/graph/index.d.ts +7 -6
- package/dist/lib/signal/graph/index.d.ts.map +1 -1
- package/dist/lib/signal/graph/index.js +7 -6
- package/dist/lib/signal/graph/index.mjs +283 -1
- package/dist/lib/signal/graph/observe.cjs +163 -1
- package/dist/lib/signal/graph/observe.d.ts +8 -8
- package/dist/lib/signal/graph/observe.js +5 -5
- package/dist/lib/signal/graph/observe.mjs +140 -1
- package/dist/lib/signal/graph/resource.cjs +620 -1
- package/dist/lib/signal/graph/resource.d.ts +1 -1
- package/dist/lib/signal/graph/resource.js +7 -8
- package/dist/lib/signal/graph/resource.mjs +597 -1
- package/dist/lib/signal/graph/runtime.cjs +501 -1
- package/dist/lib/signal/graph/runtime.d.ts +7 -7
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +34 -30
- package/dist/lib/signal/graph/runtime.mjs +478 -1
- package/dist/lib/signal/graph/signal-next.cjs +1208 -1
- package/dist/lib/signal/graph/signal-next.d.ts +5 -5
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.js +14 -12
- package/dist/lib/signal/graph/signal-next.mjs +1186 -1
- package/dist/lib/signal/graph/ssr-hooks.cjs +60 -1
- package/dist/lib/signal/graph/ssr-hooks.d.ts +6 -7
- package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -1
- package/dist/lib/signal/graph/ssr-hooks.js +6 -7
- package/dist/lib/signal/graph/ssr-hooks.mjs +39 -1
- package/dist/lib/signal/graph/state.cjs +72 -1
- package/dist/lib/signal/graph/state.d.ts +41 -10
- package/dist/lib/signal/graph/state.d.ts.map +1 -1
- package/dist/lib/signal/graph/state.js +83 -22
- package/dist/lib/signal/graph/state.mjs +49 -1
- package/dist/lib/signal/graph/suspense.cjs +301 -1
- package/dist/lib/signal/graph/suspense.js +4 -4
- package/dist/lib/signal/graph/suspense.mjs +278 -1
- package/dist/lib/signal/index-legacy.cjs +2540 -1
- package/dist/lib/signal/index-legacy.d.ts +1 -1
- package/dist/lib/signal/index-legacy.js +1 -1
- package/dist/lib/signal/index-legacy.mjs +2518 -1
- package/dist/lib/signal/index.cjs +1275 -1
- package/dist/lib/signal/index.d.ts +3 -2
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +7 -4
- package/dist/lib/signal/index.mjs +1253 -1
- package/dist/lib/signal/list.cjs +549 -1
- package/dist/lib/signal/list.d.ts +5 -5
- package/dist/lib/signal/list.js +5 -5
- package/dist/lib/signal/list.mjs +526 -1
- package/dist/lib/signal/resource-api.cjs +626 -1
- package/dist/lib/signal/resource-api.d.ts +5 -5
- package/dist/lib/signal/resource-api.js +5 -5
- package/dist/lib/signal/resource-api.mjs +603 -1
- package/dist/lib/signal/signal.cjs +2023 -1
- package/dist/lib/signal/signal.d.ts +4 -4
- package/dist/lib/signal/signal.d.ts.map +1 -1
- package/dist/lib/signal/signal.js +22 -23
- package/dist/lib/signal/signal.mjs +2000 -1
- package/dist/lib/signal/types.cjs +38 -1
- package/dist/lib/signal/types.d.ts.map +1 -1
- package/dist/lib/signal/types.js +2 -2
- package/dist/lib/signal/types.mjs +17 -1
- package/dist/lib/signal/utilities.cjs +1012 -1
- package/dist/lib/signal/utilities.d.ts +0 -108
- package/dist/lib/signal/utilities.d.ts.map +1 -1
- package/dist/lib/signal/utilities.js +0 -158
- package/dist/lib/signal/utilities.mjs +990 -1
- package/dist/lib/store/api.cjs +612 -1
- package/dist/lib/store/api.d.ts +33 -0
- package/dist/lib/store/api.d.ts.map +1 -1
- package/dist/lib/store/api.js +41 -8
- package/dist/lib/store/api.mjs +596 -1
- package/dist/lib/store/index.cjs +691 -1
- package/dist/lib/store/index.js +1 -1
- package/dist/lib/store/index.mjs +676 -1
- package/dist/lib/store/setter.types.cjs +18 -1
- package/dist/lib/store/setter.types.d.ts +43 -3
- package/dist/lib/store/setter.types.d.ts.map +1 -1
- package/dist/lib/store/store.cjs +658 -1
- package/dist/lib/store/store.d.ts +72 -0
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/store/store.js +148 -5
- package/dist/lib/store/store.mjs +644 -1
- package/dist/lib/store/types.cjs +18 -1
- package/dist/lib/store/types.d.ts +1 -1
- package/dist/lib/store/types.d.ts.map +1 -1
- package/dist/lib/store/utils.cjs +43 -1
- package/dist/lib/store/utils.d.ts +1 -1
- package/dist/lib/store/utils.js +1 -1
- package/dist/lib/store/utils.mjs +22 -1
- package/dist/lib/subject.cjs +450 -1
- package/dist/lib/subject.js +3 -91
- package/dist/lib/subject.mjs +427 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +27 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +7 -1
- package/package.json +5 -4
|
@@ -1 +1,163 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/signal/graph/observe.ts
|
|
21
|
+
var observe_exports = {};
|
|
22
|
+
__export(observe_exports, {
|
|
23
|
+
enterReactiveRun: () => enterReactiveRun,
|
|
24
|
+
exitReactiveRun: () => exitReactiveRun,
|
|
25
|
+
isObserved: () => isObserved,
|
|
26
|
+
observeReactiveNodes: () => observeReactiveNodes,
|
|
27
|
+
reportReactiveBinding: () => reportReactiveBinding,
|
|
28
|
+
reportReactiveContext: () => reportReactiveContext,
|
|
29
|
+
reportReactiveContextCreated: () => reportReactiveContextCreated,
|
|
30
|
+
reportReactiveDirective: () => reportReactiveDirective,
|
|
31
|
+
reportReactiveDispose: () => reportReactiveDispose,
|
|
32
|
+
reportReactiveMove: () => reportReactiveMove,
|
|
33
|
+
reportReactiveNode: () => reportReactiveNode,
|
|
34
|
+
reportReactiveProps: () => reportReactiveProps,
|
|
35
|
+
reportReactiveRun: () => reportReactiveRun,
|
|
36
|
+
reportReactiveWrite: () => reportReactiveWrite,
|
|
37
|
+
withReactiveOrigin: () => withReactiveOrigin
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(observe_exports);
|
|
40
|
+
|
|
41
|
+
// src/version.generated.ts
|
|
42
|
+
var VERSION = "1.0.0-alpha.84";
|
|
43
|
+
|
|
44
|
+
// src/lib/signal/graph/state.ts
|
|
45
|
+
var MAJOR = VERSION.split(".")[0];
|
|
46
|
+
var KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
47
|
+
var VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
48
|
+
var defaultSchedule = (run) => {
|
|
49
|
+
if (typeof queueMicrotask === "function") queueMicrotask(run);
|
|
50
|
+
else void Promise.resolve().then(run);
|
|
51
|
+
};
|
|
52
|
+
function defaults() {
|
|
53
|
+
return {
|
|
54
|
+
consumer: null,
|
|
55
|
+
untracked: false,
|
|
56
|
+
owner: null,
|
|
57
|
+
queue: [],
|
|
58
|
+
scheduled: false,
|
|
59
|
+
flushing: false,
|
|
60
|
+
batchDepth: 0,
|
|
61
|
+
hostSchedule: defaultSchedule,
|
|
62
|
+
onSuspend: null,
|
|
63
|
+
onError: null,
|
|
64
|
+
observer: null
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
var realm = globalThis;
|
|
68
|
+
function backfillState(existing) {
|
|
69
|
+
const fresh = defaults();
|
|
70
|
+
const target = existing;
|
|
71
|
+
for (const field of Object.keys(fresh)) {
|
|
72
|
+
if (!(field in existing)) target[field] = fresh[field];
|
|
73
|
+
}
|
|
74
|
+
return existing;
|
|
75
|
+
}
|
|
76
|
+
function claim() {
|
|
77
|
+
const existing = realm[KEY];
|
|
78
|
+
return existing ? backfillState(existing) : realm[KEY] = defaults();
|
|
79
|
+
}
|
|
80
|
+
var G = claim();
|
|
81
|
+
(realm[VERSIONS_KEY] ??= []).push(VERSION);
|
|
82
|
+
|
|
83
|
+
// src/lib/signal/graph/observe.ts
|
|
84
|
+
function observeReactiveNodes(next) {
|
|
85
|
+
G.observer = next;
|
|
86
|
+
return () => {
|
|
87
|
+
if (G.observer === next) G.observer = null;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
var running = [];
|
|
91
|
+
var origin;
|
|
92
|
+
function withReactiveOrigin(owner, fn) {
|
|
93
|
+
if (!G.observer) return fn();
|
|
94
|
+
const previous = origin;
|
|
95
|
+
origin = owner;
|
|
96
|
+
try {
|
|
97
|
+
return fn();
|
|
98
|
+
} finally {
|
|
99
|
+
origin = previous;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function reportReactiveNode(report) {
|
|
103
|
+
const observer = G.observer;
|
|
104
|
+
if (observer) {
|
|
105
|
+
observer.created(
|
|
106
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function enterReactiveRun(node) {
|
|
111
|
+
if (!G.observer) return false;
|
|
112
|
+
running.push(node);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
function exitReactiveRun() {
|
|
116
|
+
running.pop();
|
|
117
|
+
}
|
|
118
|
+
function reportReactiveRun(node) {
|
|
119
|
+
G.observer?.ran?.(node);
|
|
120
|
+
}
|
|
121
|
+
function reportReactiveWrite(node, by) {
|
|
122
|
+
G.observer?.wrote?.(node, by);
|
|
123
|
+
}
|
|
124
|
+
function reportReactiveBinding(target, kind, name, accessor) {
|
|
125
|
+
const observer = G.observer;
|
|
126
|
+
if (!observer?.bound || !running.length) return;
|
|
127
|
+
observer.bound(running[running.length - 1], target, kind, name, accessor);
|
|
128
|
+
}
|
|
129
|
+
function reportReactiveProps(props) {
|
|
130
|
+
const observer = G.observer;
|
|
131
|
+
if (!observer?.props || !running.length || !props) return;
|
|
132
|
+
observer.props(running[running.length - 1], props);
|
|
133
|
+
}
|
|
134
|
+
function reportReactiveDirective(target, kind, name, accessor) {
|
|
135
|
+
const observer = G.observer;
|
|
136
|
+
if (!observer?.directive || !running.length) return;
|
|
137
|
+
observer.directive(running[running.length - 1], target, kind, name, accessor);
|
|
138
|
+
}
|
|
139
|
+
function reportReactiveContextCreated(id) {
|
|
140
|
+
G.observer?.contextCreated?.(id);
|
|
141
|
+
}
|
|
142
|
+
function reportReactiveContext(id, kind, value) {
|
|
143
|
+
const observer = G.observer;
|
|
144
|
+
if (!observer?.context || !running.length) return;
|
|
145
|
+
observer.context(running[running.length - 1], id, kind, value);
|
|
146
|
+
}
|
|
147
|
+
function reportReactiveMove(node, origin2, name) {
|
|
148
|
+
G.observer?.moved?.(node, origin2, name);
|
|
149
|
+
}
|
|
150
|
+
function reportReactiveDispose(node) {
|
|
151
|
+
G.observer?.disposed?.(node);
|
|
152
|
+
}
|
|
153
|
+
var HOOK = "__FLUIXI_DEVTOOLS_HOOK__";
|
|
154
|
+
var hook = globalThis[HOOK];
|
|
155
|
+
if (typeof hook?.inject === "function") {
|
|
156
|
+
try {
|
|
157
|
+
hook.inject({ observeReactiveNodes, version: VERSION });
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function isObserved() {
|
|
162
|
+
return G.observer != null;
|
|
163
|
+
}
|
|
@@ -9,24 +9,24 @@ export interface ReactiveNodeReport {
|
|
|
9
9
|
name?: string;
|
|
10
10
|
/**
|
|
11
11
|
* How to write it, for a signal. A watcher setting the value through this goes through
|
|
12
|
-
* the same path the application does
|
|
12
|
+
* the same path the application does, writing the node directly marks its readers dirty
|
|
13
13
|
* without ever flushing them, so the page keeps whatever it last rendered.
|
|
14
14
|
*/
|
|
15
15
|
set?: (value: unknown) => void;
|
|
16
16
|
/**
|
|
17
17
|
* The node this one was built for. A store creates a signal per key, lazily, wherever it
|
|
18
|
-
* is first read
|
|
18
|
+
* is first read, the useful location is the store's, not the reader's.
|
|
19
19
|
*/
|
|
20
20
|
origin?: unknown;
|
|
21
21
|
/**
|
|
22
|
-
* The node is the framework's own plumbing
|
|
22
|
+
* The node is the framework's own plumbing, a render effect, one per dom binding. A graph
|
|
23
23
|
* does not show these, but it needs to know they exist: a row added to a list is created
|
|
24
24
|
* inside one, and without it the row has no ancestor it can be attached to.
|
|
25
25
|
*/
|
|
26
26
|
internal?: boolean;
|
|
27
27
|
/**
|
|
28
28
|
* The computations running when this node was made, outermost first. A component's wrapper
|
|
29
|
-
* memo reads nothing itself, so what it created is the only thing tying it to the graph
|
|
29
|
+
* memo reads nothing itself, so what it created is the only thing tying it to the graph
|
|
30
30
|
* and the whole chain is given because the nearest one is often a render effect, which no
|
|
31
31
|
* graph shows.
|
|
32
32
|
*
|
|
@@ -41,15 +41,15 @@ export interface ReactiveObserver {
|
|
|
41
41
|
/** An effect was disposed. Memos and signals go with their owner and are not reported. */
|
|
42
42
|
disposed?(node: unknown): void;
|
|
43
43
|
/**
|
|
44
|
-
* A signal was written, and by which computation
|
|
44
|
+
* A signal was written, and by which computation, nothing, when the write came from an
|
|
45
45
|
* event handler, which is where most of them come from.
|
|
46
46
|
*/
|
|
47
47
|
wrote?(node: unknown, by: unknown): void;
|
|
48
48
|
/**
|
|
49
49
|
* A node now belongs somewhere else, and is called something else.
|
|
50
50
|
*
|
|
51
|
-
* A store write replaces the object that held a value
|
|
52
|
-
* builds a new array
|
|
51
|
+
* A store write replaces the object that held a value: `set({ items: [...items, one] })`
|
|
52
|
+
* builds a new array, and the signals underneath it are the same signals in a new place.
|
|
53
53
|
* Without this they keep pointing at a node that no longer exists.
|
|
54
54
|
*/
|
|
55
55
|
moved?(node: unknown, origin: unknown, name?: string): void;
|
|
@@ -93,7 +93,7 @@ export interface ReactiveObserver {
|
|
|
93
93
|
/**
|
|
94
94
|
* Watch the graph. Returns a function that stops watching.
|
|
95
95
|
*
|
|
96
|
-
* One observer at a time
|
|
96
|
+
* One observer at a time, the last to register wins. Two tools watching one page at once is
|
|
97
97
|
* not a case worth carrying state for.
|
|
98
98
|
*/
|
|
99
99
|
export declare function observeReactiveNodes(next: ReactiveObserver): () => void;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* A place for a tool to watch the reactive graph from outside it.
|
|
3
3
|
*
|
|
4
4
|
* The runtime says a node exists, a computation re-ran, or an effect went away, and hands
|
|
5
|
-
* over the node itself. It does nothing else. Edges are already on the node
|
|
6
|
-
* its `observers`, a consumer keeps its `sources
|
|
5
|
+
* over the node itself. It does nothing else. Edges are already on the node, a source keeps
|
|
6
|
+
* its `observers`, a consumer keeps its `sources`, so a watcher reads the graph rather than
|
|
7
7
|
* reconstructing it, and nothing here wraps or replaces a primitive.
|
|
8
8
|
*
|
|
9
9
|
* Nothing is registered by default: an unwatched runtime pays one null check per node
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
* @fluixi/devtools is the intended caller. Nothing in the framework reads it back.
|
|
13
13
|
*
|
|
14
14
|
* The observer lives on the shared graph state rather than in a module `let`, so a bundle
|
|
15
|
-
* carrying two copies of this module still has one observer
|
|
15
|
+
* carrying two copies of this module still has one observer, the same reason G exists.
|
|
16
16
|
*/
|
|
17
17
|
import { G } from './state.js';
|
|
18
18
|
import { VERSION } from '../../../version.generated.js';
|
|
19
19
|
/**
|
|
20
20
|
* Watch the graph. Returns a function that stops watching.
|
|
21
21
|
*
|
|
22
|
-
* One observer at a time
|
|
22
|
+
* One observer at a time, the last to register wins. Two tools watching one page at once is
|
|
23
23
|
* not a case worth carrying state for.
|
|
24
24
|
*/
|
|
25
25
|
export function observeReactiveNodes(next) {
|
|
@@ -130,7 +130,7 @@ export function reportReactiveDispose(node) {
|
|
|
130
130
|
* have to import a debugger to be debuggable. So a tool sets this global before any of the
|
|
131
131
|
* app loads, and the runtime hands it the door on the way past.
|
|
132
132
|
*
|
|
133
|
-
* Set it too late and nothing happens
|
|
133
|
+
* Set it too late and nothing happens, the runtime only offers once, when this module is
|
|
134
134
|
* first evaluated. A browser agent has to run at document_start for that reason.
|
|
135
135
|
*/
|
|
136
136
|
const HOOK = '__FLUIXI_DEVTOOLS_HOOK__';
|
|
@@ -1 +1,140 @@
|
|
|
1
|
-
|
|
1
|
+
// src/version.generated.ts
|
|
2
|
+
var VERSION = "1.0.0-alpha.84";
|
|
3
|
+
|
|
4
|
+
// src/lib/signal/graph/state.ts
|
|
5
|
+
var MAJOR = VERSION.split(".")[0];
|
|
6
|
+
var KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
7
|
+
var VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
8
|
+
var defaultSchedule = (run) => {
|
|
9
|
+
if (typeof queueMicrotask === "function") queueMicrotask(run);
|
|
10
|
+
else void Promise.resolve().then(run);
|
|
11
|
+
};
|
|
12
|
+
function defaults() {
|
|
13
|
+
return {
|
|
14
|
+
consumer: null,
|
|
15
|
+
untracked: false,
|
|
16
|
+
owner: null,
|
|
17
|
+
queue: [],
|
|
18
|
+
scheduled: false,
|
|
19
|
+
flushing: false,
|
|
20
|
+
batchDepth: 0,
|
|
21
|
+
hostSchedule: defaultSchedule,
|
|
22
|
+
onSuspend: null,
|
|
23
|
+
onError: null,
|
|
24
|
+
observer: null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var realm = globalThis;
|
|
28
|
+
function backfillState(existing) {
|
|
29
|
+
const fresh = defaults();
|
|
30
|
+
const target = existing;
|
|
31
|
+
for (const field of Object.keys(fresh)) {
|
|
32
|
+
if (!(field in existing)) target[field] = fresh[field];
|
|
33
|
+
}
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
function claim() {
|
|
37
|
+
const existing = realm[KEY];
|
|
38
|
+
return existing ? backfillState(existing) : realm[KEY] = defaults();
|
|
39
|
+
}
|
|
40
|
+
var G = claim();
|
|
41
|
+
(realm[VERSIONS_KEY] ??= []).push(VERSION);
|
|
42
|
+
|
|
43
|
+
// src/lib/signal/graph/observe.ts
|
|
44
|
+
function observeReactiveNodes(next) {
|
|
45
|
+
G.observer = next;
|
|
46
|
+
return () => {
|
|
47
|
+
if (G.observer === next) G.observer = null;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
var running = [];
|
|
51
|
+
var origin;
|
|
52
|
+
function withReactiveOrigin(owner, fn) {
|
|
53
|
+
if (!G.observer) return fn();
|
|
54
|
+
const previous = origin;
|
|
55
|
+
origin = owner;
|
|
56
|
+
try {
|
|
57
|
+
return fn();
|
|
58
|
+
} finally {
|
|
59
|
+
origin = previous;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function reportReactiveNode(report) {
|
|
63
|
+
const observer = G.observer;
|
|
64
|
+
if (observer) {
|
|
65
|
+
observer.created(
|
|
66
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function enterReactiveRun(node) {
|
|
71
|
+
if (!G.observer) return false;
|
|
72
|
+
running.push(node);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
function exitReactiveRun() {
|
|
76
|
+
running.pop();
|
|
77
|
+
}
|
|
78
|
+
function reportReactiveRun(node) {
|
|
79
|
+
G.observer?.ran?.(node);
|
|
80
|
+
}
|
|
81
|
+
function reportReactiveWrite(node, by) {
|
|
82
|
+
G.observer?.wrote?.(node, by);
|
|
83
|
+
}
|
|
84
|
+
function reportReactiveBinding(target, kind, name, accessor) {
|
|
85
|
+
const observer = G.observer;
|
|
86
|
+
if (!observer?.bound || !running.length) return;
|
|
87
|
+
observer.bound(running[running.length - 1], target, kind, name, accessor);
|
|
88
|
+
}
|
|
89
|
+
function reportReactiveProps(props) {
|
|
90
|
+
const observer = G.observer;
|
|
91
|
+
if (!observer?.props || !running.length || !props) return;
|
|
92
|
+
observer.props(running[running.length - 1], props);
|
|
93
|
+
}
|
|
94
|
+
function reportReactiveDirective(target, kind, name, accessor) {
|
|
95
|
+
const observer = G.observer;
|
|
96
|
+
if (!observer?.directive || !running.length) return;
|
|
97
|
+
observer.directive(running[running.length - 1], target, kind, name, accessor);
|
|
98
|
+
}
|
|
99
|
+
function reportReactiveContextCreated(id) {
|
|
100
|
+
G.observer?.contextCreated?.(id);
|
|
101
|
+
}
|
|
102
|
+
function reportReactiveContext(id, kind, value) {
|
|
103
|
+
const observer = G.observer;
|
|
104
|
+
if (!observer?.context || !running.length) return;
|
|
105
|
+
observer.context(running[running.length - 1], id, kind, value);
|
|
106
|
+
}
|
|
107
|
+
function reportReactiveMove(node, origin2, name) {
|
|
108
|
+
G.observer?.moved?.(node, origin2, name);
|
|
109
|
+
}
|
|
110
|
+
function reportReactiveDispose(node) {
|
|
111
|
+
G.observer?.disposed?.(node);
|
|
112
|
+
}
|
|
113
|
+
var HOOK = "__FLUIXI_DEVTOOLS_HOOK__";
|
|
114
|
+
var hook = globalThis[HOOK];
|
|
115
|
+
if (typeof hook?.inject === "function") {
|
|
116
|
+
try {
|
|
117
|
+
hook.inject({ observeReactiveNodes, version: VERSION });
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function isObserved() {
|
|
122
|
+
return G.observer != null;
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
enterReactiveRun,
|
|
126
|
+
exitReactiveRun,
|
|
127
|
+
isObserved,
|
|
128
|
+
observeReactiveNodes,
|
|
129
|
+
reportReactiveBinding,
|
|
130
|
+
reportReactiveContext,
|
|
131
|
+
reportReactiveContextCreated,
|
|
132
|
+
reportReactiveDirective,
|
|
133
|
+
reportReactiveDispose,
|
|
134
|
+
reportReactiveMove,
|
|
135
|
+
reportReactiveNode,
|
|
136
|
+
reportReactiveProps,
|
|
137
|
+
reportReactiveRun,
|
|
138
|
+
reportReactiveWrite,
|
|
139
|
+
withReactiveOrigin
|
|
140
|
+
};
|