@fluixi/reactive 1.0.0-alpha.103 → 1.0.0-alpha.104
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 +43 -4
- package/dist/cdn/reactive.global.js +2 -2
- package/dist/cdn/reactive.mjs +43 -4
- package/dist/cdn/signal.cjs +1 -1
- package/dist/cdn/signal.global.js +2 -2
- package/dist/cdn/signal.mjs +1 -1
- package/dist/index.cjs +43 -4
- package/dist/index.mjs +43 -4
- package/dist/lib/index.cjs +44 -5
- package/dist/lib/index.mjs +44 -5
- package/dist/lib/observable/index.cjs +1 -1
- package/dist/lib/observable/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +1 -1
- package/dist/lib/signal/api.mjs +1 -1
- package/dist/lib/signal/cached-resource.cjs +2 -2
- package/dist/lib/signal/cached-resource.mjs +2 -2
- package/dist/lib/signal/graph/children.cjs +1 -1
- package/dist/lib/signal/graph/children.mjs +1 -1
- package/dist/lib/signal/graph/compat.cjs +2 -2
- package/dist/lib/signal/graph/compat.mjs +2 -2
- package/dist/lib/signal/graph/context-children.cjs +201 -0
- package/dist/lib/signal/graph/context-children.d.ts +15 -0
- package/dist/lib/signal/graph/context-children.d.ts.map +1 -0
- package/dist/lib/signal/graph/context-children.js +53 -0
- package/dist/lib/signal/graph/context-children.mjs +178 -0
- package/dist/lib/signal/graph/core.cjs +2 -2
- package/dist/lib/signal/graph/core.mjs +2 -2
- package/dist/lib/signal/graph/debounced.cjs +1 -1
- package/dist/lib/signal/graph/debounced.mjs +1 -1
- package/dist/lib/signal/graph/derived.cjs +1 -1
- package/dist/lib/signal/graph/derived.mjs +1 -1
- package/dist/lib/signal/graph/error-boundary.cjs +1 -1
- package/dist/lib/signal/graph/error-boundary.mjs +1 -1
- package/dist/lib/signal/graph/index.cjs +2 -2
- package/dist/lib/signal/graph/index.mjs +2 -2
- package/dist/lib/signal/graph/observe.cjs +1 -1
- package/dist/lib/signal/graph/observe.mjs +1 -1
- package/dist/lib/signal/graph/resource.cjs +1 -1
- package/dist/lib/signal/graph/resource.mjs +1 -1
- package/dist/lib/signal/graph/runtime.cjs +1 -1
- package/dist/lib/signal/graph/runtime.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.cjs +44 -5
- package/dist/lib/signal/graph/signal-next.d.ts +2 -1
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.js +2 -1
- package/dist/lib/signal/graph/signal-next.mjs +44 -5
- package/dist/lib/signal/graph/state.cjs +1 -1
- package/dist/lib/signal/graph/state.mjs +1 -1
- package/dist/lib/signal/graph/suspense.cjs +1 -1
- package/dist/lib/signal/graph/suspense.mjs +1 -1
- package/dist/lib/signal/index-legacy.cjs +2 -2
- package/dist/lib/signal/index-legacy.mjs +2 -2
- package/dist/lib/signal/index.cjs +44 -5
- package/dist/lib/signal/index.mjs +44 -5
- package/dist/lib/signal/list.cjs +1 -1
- package/dist/lib/signal/list.mjs +1 -1
- package/dist/lib/signal/resource-api.cjs +1 -1
- package/dist/lib/signal/resource-api.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/lib/signal/utilities.cjs +2 -2
- package/dist/lib/signal/utilities.mjs +2 -2
- package/dist/lib/store/api.cjs +1 -1
- package/dist/lib/store/api.mjs +1 -1
- package/dist/lib/store/index.cjs +2 -2
- package/dist/lib/store/index.mjs +2 -2
- package/dist/lib/store/store.cjs +1 -1
- package/dist/lib/store/store.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +2 -2
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +2 -2
- package/package.json +2 -2
package/dist/lib/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// src/version.generated.ts
|
|
4
|
-
var VERSION = "1.0.0-alpha.
|
|
4
|
+
var VERSION = "1.0.0-alpha.104";
|
|
5
5
|
|
|
6
6
|
// src/lib/predicates.ts
|
|
7
7
|
function isFunction(value) {
|
|
@@ -1336,8 +1336,8 @@ function setResourceCacheScope(fn) {
|
|
|
1336
1336
|
}
|
|
1337
1337
|
var _pageCache;
|
|
1338
1338
|
function currentResourceCache() {
|
|
1339
|
-
const
|
|
1340
|
-
if (
|
|
1339
|
+
const scoped2 = _cacheScope?.();
|
|
1340
|
+
if (scoped2) return scoped2;
|
|
1341
1341
|
if (typeof window === "undefined") return createResourceCache();
|
|
1342
1342
|
return _pageCache ??= createResourceCache();
|
|
1343
1343
|
}
|
|
@@ -1594,6 +1594,45 @@ function readChildren(fn) {
|
|
|
1594
1594
|
return __DEV__ ? createMemo(() => resolveChildrenValue(children()), void 0, { name: "children" }) : createMemo(() => resolveChildrenValue(children()));
|
|
1595
1595
|
}
|
|
1596
1596
|
|
|
1597
|
+
// src/lib/signal/graph/context-children.ts
|
|
1598
|
+
function scoped(child, provider) {
|
|
1599
|
+
return () => {
|
|
1600
|
+
const scope = createChildOwner(provider);
|
|
1601
|
+
onCleanup(() => {
|
|
1602
|
+
disposeScope(scope);
|
|
1603
|
+
const owned = provider.owned;
|
|
1604
|
+
const at = owned ? owned.indexOf(scope) : -1;
|
|
1605
|
+
if (at >= 0) owned.splice(at, 1);
|
|
1606
|
+
});
|
|
1607
|
+
return runWithOwner(scope, child);
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
function bindChildren(children, provider) {
|
|
1611
|
+
if (typeof children === "function") {
|
|
1612
|
+
return isSignal(children) || children.length ? children : scoped(children, provider);
|
|
1613
|
+
}
|
|
1614
|
+
return Array.isArray(children) ? children.map((child) => bindChildren(child, provider)) : children;
|
|
1615
|
+
}
|
|
1616
|
+
function createContext2(defaultValue, name) {
|
|
1617
|
+
const context2 = createContext(defaultValue, name);
|
|
1618
|
+
const provide2 = context2.Provider;
|
|
1619
|
+
const Provider = (props) => provide2({
|
|
1620
|
+
get value() {
|
|
1621
|
+
return props.value;
|
|
1622
|
+
},
|
|
1623
|
+
get debug() {
|
|
1624
|
+
return props.debug;
|
|
1625
|
+
},
|
|
1626
|
+
// Read by the runtime Provider with its own scope current.
|
|
1627
|
+
get children() {
|
|
1628
|
+
const provider = getOwner();
|
|
1629
|
+
const children = props.children;
|
|
1630
|
+
return provider ? bindChildren(children, provider) : children;
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
return { ...context2, Provider };
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1597
1636
|
// src/lib/signal/graph/suspense.ts
|
|
1598
1637
|
var SuspenseContext = createContext();
|
|
1599
1638
|
setSuspendHandler((promise, owner) => {
|
|
@@ -2684,7 +2723,7 @@ export {
|
|
|
2684
2723
|
createChildOwner,
|
|
2685
2724
|
createComputed,
|
|
2686
2725
|
createComputedStore,
|
|
2687
|
-
createContext,
|
|
2726
|
+
createContext2 as createContext,
|
|
2688
2727
|
createDebounce,
|
|
2689
2728
|
createDebouncedResource,
|
|
2690
2729
|
createDebouncedSignal,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/lib/signal/api.cjs
CHANGED
package/dist/lib/signal/api.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -28,7 +28,7 @@ __export(cached_resource_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(cached_resource_exports);
|
|
29
29
|
|
|
30
30
|
// src/version.generated.ts
|
|
31
|
-
var VERSION = "1.0.0-alpha.
|
|
31
|
+
var VERSION = "1.0.0-alpha.104";
|
|
32
32
|
|
|
33
33
|
// src/lib/signal/graph/state.ts
|
|
34
34
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// src/version.generated.ts
|
|
4
|
-
var VERSION = "1.0.0-alpha.
|
|
4
|
+
var VERSION = "1.0.0-alpha.104";
|
|
5
5
|
|
|
6
6
|
// src/lib/signal/graph/state.ts
|
|
7
7
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -25,7 +25,7 @@ __export(children_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(children_exports);
|
|
26
26
|
|
|
27
27
|
// src/version.generated.ts
|
|
28
|
-
var VERSION = "1.0.0-alpha.
|
|
28
|
+
var VERSION = "1.0.0-alpha.104";
|
|
29
29
|
|
|
30
30
|
// src/lib/signal/graph/state.ts
|
|
31
31
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -42,7 +42,7 @@ __export(compat_exports, {
|
|
|
42
42
|
module.exports = __toCommonJS(compat_exports);
|
|
43
43
|
|
|
44
44
|
// src/version.generated.ts
|
|
45
|
-
var VERSION = "1.0.0-alpha.
|
|
45
|
+
var VERSION = "1.0.0-alpha.104";
|
|
46
46
|
|
|
47
47
|
// src/lib/signal/graph/state.ts
|
|
48
48
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// src/version.generated.ts
|
|
4
|
-
var VERSION = "1.0.0-alpha.
|
|
4
|
+
var VERSION = "1.0.0-alpha.104";
|
|
5
5
|
|
|
6
6
|
// src/lib/signal/graph/state.ts
|
|
7
7
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -0,0 +1,201 @@
|
|
|
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/context-children.ts
|
|
21
|
+
var context_children_exports = {};
|
|
22
|
+
__export(context_children_exports, {
|
|
23
|
+
createContext: () => createContext2
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(context_children_exports);
|
|
26
|
+
|
|
27
|
+
// src/version.generated.ts
|
|
28
|
+
var VERSION = "1.0.0-alpha.104";
|
|
29
|
+
|
|
30
|
+
// src/lib/signal/graph/state.ts
|
|
31
|
+
var MAJOR = VERSION.split(".")[0];
|
|
32
|
+
var KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
33
|
+
var VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
34
|
+
var defaultSchedule = (run) => {
|
|
35
|
+
if (typeof queueMicrotask === "function") queueMicrotask(run);
|
|
36
|
+
else void Promise.resolve().then(run);
|
|
37
|
+
};
|
|
38
|
+
function defaults() {
|
|
39
|
+
return {
|
|
40
|
+
consumer: null,
|
|
41
|
+
untracked: false,
|
|
42
|
+
owner: null,
|
|
43
|
+
queue: [],
|
|
44
|
+
scheduled: false,
|
|
45
|
+
flushing: false,
|
|
46
|
+
batchDepth: 0,
|
|
47
|
+
hostSchedule: defaultSchedule,
|
|
48
|
+
onSuspend: null,
|
|
49
|
+
onError: null,
|
|
50
|
+
observer: null
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var realm = globalThis;
|
|
54
|
+
function backfillState(existing) {
|
|
55
|
+
const fresh = defaults();
|
|
56
|
+
const target = existing;
|
|
57
|
+
for (const field of Object.keys(fresh)) {
|
|
58
|
+
if (!(field in existing)) target[field] = fresh[field];
|
|
59
|
+
}
|
|
60
|
+
return existing;
|
|
61
|
+
}
|
|
62
|
+
function claim() {
|
|
63
|
+
const existing = realm[KEY];
|
|
64
|
+
return existing ? backfillState(existing) : realm[KEY] = defaults();
|
|
65
|
+
}
|
|
66
|
+
var G = claim();
|
|
67
|
+
(realm[VERSIONS_KEY] ??= []).push(VERSION);
|
|
68
|
+
|
|
69
|
+
// src/lib/signal/graph/observe.ts
|
|
70
|
+
function observeReactiveNodes(next) {
|
|
71
|
+
G.observer = next;
|
|
72
|
+
return () => {
|
|
73
|
+
if (G.observer === next) G.observer = null;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var running = [];
|
|
77
|
+
function reportReactiveContextCreated(id) {
|
|
78
|
+
G.observer?.contextCreated?.(id);
|
|
79
|
+
}
|
|
80
|
+
function reportReactiveContext(id, kind, value) {
|
|
81
|
+
const observer = G.observer;
|
|
82
|
+
if (!observer?.context || !running.length) return;
|
|
83
|
+
observer.context(running[running.length - 1], id, kind, value);
|
|
84
|
+
}
|
|
85
|
+
var HOOK = "__FLUIXI_DEVTOOLS_HOOK__";
|
|
86
|
+
var hook = globalThis[HOOK];
|
|
87
|
+
if (typeof hook?.inject === "function") {
|
|
88
|
+
try {
|
|
89
|
+
hook.inject({ observeReactiveNodes, version: VERSION });
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/lib/signal/graph/runtime.ts
|
|
95
|
+
function createChildOwner(parent) {
|
|
96
|
+
const owner = makeOwner(parent);
|
|
97
|
+
if (parent) (parent.owned ??= []).push(owner);
|
|
98
|
+
return owner;
|
|
99
|
+
}
|
|
100
|
+
function disposeScope(owner, final = true) {
|
|
101
|
+
disposeOwner(owner, final);
|
|
102
|
+
}
|
|
103
|
+
function makeOwner(parent) {
|
|
104
|
+
return { cleanups: null, owned: null, parent, contexts: null };
|
|
105
|
+
}
|
|
106
|
+
function createContext(defaultValue, name) {
|
|
107
|
+
const id = Symbol(name ?? "context");
|
|
108
|
+
reportReactiveContextCreated(id);
|
|
109
|
+
const Provider = (props) => {
|
|
110
|
+
reportReactiveContext(id, "provide", props.value);
|
|
111
|
+
const parent = G.owner;
|
|
112
|
+
const owner = makeOwner(parent);
|
|
113
|
+
(owner.contexts = /* @__PURE__ */ new Map()).set(id, props.value);
|
|
114
|
+
if (parent) (parent.owned ??= []).push(owner);
|
|
115
|
+
G.owner = owner;
|
|
116
|
+
try {
|
|
117
|
+
return props.children;
|
|
118
|
+
} finally {
|
|
119
|
+
G.owner = parent;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return { id, defaultValue, Provider };
|
|
123
|
+
}
|
|
124
|
+
function getOwner() {
|
|
125
|
+
return G.owner;
|
|
126
|
+
}
|
|
127
|
+
function runWithOwner(owner, fn) {
|
|
128
|
+
const prev = G.owner;
|
|
129
|
+
G.owner = owner;
|
|
130
|
+
try {
|
|
131
|
+
return fn();
|
|
132
|
+
} finally {
|
|
133
|
+
G.owner = prev;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function onCleanup(fn) {
|
|
137
|
+
if (!G.owner) return;
|
|
138
|
+
if (G.owner.disposed) {
|
|
139
|
+
fn();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
(G.owner.cleanups ??= []).push(fn);
|
|
143
|
+
}
|
|
144
|
+
function disposeOwner(owner, final = true) {
|
|
145
|
+
if (owner.disposed) return;
|
|
146
|
+
if (owner.owned) {
|
|
147
|
+
for (let i = owner.owned.length - 1; i >= 0; i--) disposeOwner(owner.owned[i]);
|
|
148
|
+
owner.owned = null;
|
|
149
|
+
}
|
|
150
|
+
if (owner.cleanups) {
|
|
151
|
+
for (let i = owner.cleanups.length - 1; i >= 0; i--) owner.cleanups[i]();
|
|
152
|
+
owner.cleanups = null;
|
|
153
|
+
}
|
|
154
|
+
if (final) owner.disposed = true;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/lib/signal/graph/detect.ts
|
|
158
|
+
var __BROWSER_PROD__ = typeof window === "undefined" ? false : window.__FLUIXI_PROD__ === true;
|
|
159
|
+
var $SIGNAL = /* @__PURE__ */ Symbol.for("signal");
|
|
160
|
+
function isSignal(value) {
|
|
161
|
+
return typeof value === "function" && value[$SIGNAL] === true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/lib/signal/graph/context-children.ts
|
|
165
|
+
function scoped(child, provider) {
|
|
166
|
+
return () => {
|
|
167
|
+
const scope = createChildOwner(provider);
|
|
168
|
+
onCleanup(() => {
|
|
169
|
+
disposeScope(scope);
|
|
170
|
+
const owned = provider.owned;
|
|
171
|
+
const at = owned ? owned.indexOf(scope) : -1;
|
|
172
|
+
if (at >= 0) owned.splice(at, 1);
|
|
173
|
+
});
|
|
174
|
+
return runWithOwner(scope, child);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function bindChildren(children, provider) {
|
|
178
|
+
if (typeof children === "function") {
|
|
179
|
+
return isSignal(children) || children.length ? children : scoped(children, provider);
|
|
180
|
+
}
|
|
181
|
+
return Array.isArray(children) ? children.map((child) => bindChildren(child, provider)) : children;
|
|
182
|
+
}
|
|
183
|
+
function createContext2(defaultValue, name) {
|
|
184
|
+
const context = createContext(defaultValue, name);
|
|
185
|
+
const provide = context.Provider;
|
|
186
|
+
const Provider = (props) => provide({
|
|
187
|
+
get value() {
|
|
188
|
+
return props.value;
|
|
189
|
+
},
|
|
190
|
+
get debug() {
|
|
191
|
+
return props.debug;
|
|
192
|
+
},
|
|
193
|
+
// Read by the runtime Provider with its own scope current.
|
|
194
|
+
get children() {
|
|
195
|
+
const provider = getOwner();
|
|
196
|
+
const children = props.children;
|
|
197
|
+
return provider ? bindChildren(children, provider) : children;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return { ...context, Provider };
|
|
201
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public `createContext`: the runtime's, with a Provider that keeps plain function
|
|
3
|
+
* children in its scope. The runtime Provider reads `children` under its own owner and
|
|
4
|
+
* hands them back as they are. A child that is a memo (`<Show>`, `<For>`) captured that
|
|
5
|
+
* owner, but a plain function child (`{() => (open() ? <Panel /> : null)}`) is run later by
|
|
6
|
+
* whoever inserts it, outside the scope, and its components read the default.
|
|
7
|
+
*
|
|
8
|
+
* Each such child is handed back still a plain function, so it is inserted when and where
|
|
9
|
+
* it was before (hydration adopts nodes in that order), but every run happens in a fresh
|
|
10
|
+
* scope under the Provider, disposed before the next run as the inserting effect's own
|
|
11
|
+
* children would be.
|
|
12
|
+
*/
|
|
13
|
+
import { type Context } from './runtime.js';
|
|
14
|
+
export declare function createContext<T>(defaultValue?: T, name?: string): Context<T>;
|
|
15
|
+
//# sourceMappingURL=context-children.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-children.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/context-children.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAOL,KAAK,OAAO,EAEb,MAAM,cAAc,CAAC;AAwBtB,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAmB5E"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public `createContext`: the runtime's, with a Provider that keeps plain function
|
|
3
|
+
* children in its scope. The runtime Provider reads `children` under its own owner and
|
|
4
|
+
* hands them back as they are. A child that is a memo (`<Show>`, `<For>`) captured that
|
|
5
|
+
* owner, but a plain function child (`{() => (open() ? <Panel /> : null)}`) is run later by
|
|
6
|
+
* whoever inserts it, outside the scope, and its components read the default.
|
|
7
|
+
*
|
|
8
|
+
* Each such child is handed back still a plain function, so it is inserted when and where
|
|
9
|
+
* it was before (hydration adopts nodes in that order), but every run happens in a fresh
|
|
10
|
+
* scope under the Provider, disposed before the next run as the inserting effect's own
|
|
11
|
+
* children would be.
|
|
12
|
+
*/
|
|
13
|
+
import { createContext as createRuntimeContext, createChildOwner, disposeScope, getOwner, onCleanup, runWithOwner, } from './runtime.js';
|
|
14
|
+
import { isSignal } from './detect.js';
|
|
15
|
+
function scoped(child, provider) {
|
|
16
|
+
return () => {
|
|
17
|
+
const scope = createChildOwner(provider);
|
|
18
|
+
onCleanup(() => {
|
|
19
|
+
disposeScope(scope);
|
|
20
|
+
const owned = provider.owned;
|
|
21
|
+
const at = owned ? owned.indexOf(scope) : -1;
|
|
22
|
+
if (at >= 0)
|
|
23
|
+
owned.splice(at, 1);
|
|
24
|
+
});
|
|
25
|
+
return runWithOwner(scope, child);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function bindChildren(children, provider) {
|
|
29
|
+
// A memo or signal keeps its own owner; a render prop (with arguments) is called by its parent.
|
|
30
|
+
if (typeof children === 'function') {
|
|
31
|
+
return isSignal(children) || children.length ? children : scoped(children, provider);
|
|
32
|
+
}
|
|
33
|
+
return Array.isArray(children) ? children.map((child) => bindChildren(child, provider)) : children;
|
|
34
|
+
}
|
|
35
|
+
export function createContext(defaultValue, name) {
|
|
36
|
+
const context = createRuntimeContext(defaultValue, name);
|
|
37
|
+
const provide = context.Provider;
|
|
38
|
+
const Provider = (props) => provide({
|
|
39
|
+
get value() {
|
|
40
|
+
return props.value;
|
|
41
|
+
},
|
|
42
|
+
get debug() {
|
|
43
|
+
return props.debug;
|
|
44
|
+
},
|
|
45
|
+
// Read by the runtime Provider with its own scope current.
|
|
46
|
+
get children() {
|
|
47
|
+
const provider = getOwner();
|
|
48
|
+
const children = props.children;
|
|
49
|
+
return provider ? bindChildren(children, provider) : children;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return { ...context, Provider };
|
|
53
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// src/version.generated.ts
|
|
2
|
+
var VERSION = "1.0.0-alpha.104";
|
|
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
|
+
function reportReactiveContextCreated(id) {
|
|
52
|
+
G.observer?.contextCreated?.(id);
|
|
53
|
+
}
|
|
54
|
+
function reportReactiveContext(id, kind, value) {
|
|
55
|
+
const observer = G.observer;
|
|
56
|
+
if (!observer?.context || !running.length) return;
|
|
57
|
+
observer.context(running[running.length - 1], id, kind, value);
|
|
58
|
+
}
|
|
59
|
+
var HOOK = "__FLUIXI_DEVTOOLS_HOOK__";
|
|
60
|
+
var hook = globalThis[HOOK];
|
|
61
|
+
if (typeof hook?.inject === "function") {
|
|
62
|
+
try {
|
|
63
|
+
hook.inject({ observeReactiveNodes, version: VERSION });
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/lib/signal/graph/runtime.ts
|
|
69
|
+
function createChildOwner(parent) {
|
|
70
|
+
const owner = makeOwner(parent);
|
|
71
|
+
if (parent) (parent.owned ??= []).push(owner);
|
|
72
|
+
return owner;
|
|
73
|
+
}
|
|
74
|
+
function disposeScope(owner, final = true) {
|
|
75
|
+
disposeOwner(owner, final);
|
|
76
|
+
}
|
|
77
|
+
function makeOwner(parent) {
|
|
78
|
+
return { cleanups: null, owned: null, parent, contexts: null };
|
|
79
|
+
}
|
|
80
|
+
function createContext(defaultValue, name) {
|
|
81
|
+
const id = Symbol(name ?? "context");
|
|
82
|
+
reportReactiveContextCreated(id);
|
|
83
|
+
const Provider = (props) => {
|
|
84
|
+
reportReactiveContext(id, "provide", props.value);
|
|
85
|
+
const parent = G.owner;
|
|
86
|
+
const owner = makeOwner(parent);
|
|
87
|
+
(owner.contexts = /* @__PURE__ */ new Map()).set(id, props.value);
|
|
88
|
+
if (parent) (parent.owned ??= []).push(owner);
|
|
89
|
+
G.owner = owner;
|
|
90
|
+
try {
|
|
91
|
+
return props.children;
|
|
92
|
+
} finally {
|
|
93
|
+
G.owner = parent;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return { id, defaultValue, Provider };
|
|
97
|
+
}
|
|
98
|
+
function getOwner() {
|
|
99
|
+
return G.owner;
|
|
100
|
+
}
|
|
101
|
+
function runWithOwner(owner, fn) {
|
|
102
|
+
const prev = G.owner;
|
|
103
|
+
G.owner = owner;
|
|
104
|
+
try {
|
|
105
|
+
return fn();
|
|
106
|
+
} finally {
|
|
107
|
+
G.owner = prev;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function onCleanup(fn) {
|
|
111
|
+
if (!G.owner) return;
|
|
112
|
+
if (G.owner.disposed) {
|
|
113
|
+
fn();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
(G.owner.cleanups ??= []).push(fn);
|
|
117
|
+
}
|
|
118
|
+
function disposeOwner(owner, final = true) {
|
|
119
|
+
if (owner.disposed) return;
|
|
120
|
+
if (owner.owned) {
|
|
121
|
+
for (let i = owner.owned.length - 1; i >= 0; i--) disposeOwner(owner.owned[i]);
|
|
122
|
+
owner.owned = null;
|
|
123
|
+
}
|
|
124
|
+
if (owner.cleanups) {
|
|
125
|
+
for (let i = owner.cleanups.length - 1; i >= 0; i--) owner.cleanups[i]();
|
|
126
|
+
owner.cleanups = null;
|
|
127
|
+
}
|
|
128
|
+
if (final) owner.disposed = true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/lib/signal/graph/detect.ts
|
|
132
|
+
var __BROWSER_PROD__ = typeof window === "undefined" ? false : window.__FLUIXI_PROD__ === true;
|
|
133
|
+
var $SIGNAL = /* @__PURE__ */ Symbol.for("signal");
|
|
134
|
+
function isSignal(value) {
|
|
135
|
+
return typeof value === "function" && value[$SIGNAL] === true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/lib/signal/graph/context-children.ts
|
|
139
|
+
function scoped(child, provider) {
|
|
140
|
+
return () => {
|
|
141
|
+
const scope = createChildOwner(provider);
|
|
142
|
+
onCleanup(() => {
|
|
143
|
+
disposeScope(scope);
|
|
144
|
+
const owned = provider.owned;
|
|
145
|
+
const at = owned ? owned.indexOf(scope) : -1;
|
|
146
|
+
if (at >= 0) owned.splice(at, 1);
|
|
147
|
+
});
|
|
148
|
+
return runWithOwner(scope, child);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function bindChildren(children, provider) {
|
|
152
|
+
if (typeof children === "function") {
|
|
153
|
+
return isSignal(children) || children.length ? children : scoped(children, provider);
|
|
154
|
+
}
|
|
155
|
+
return Array.isArray(children) ? children.map((child) => bindChildren(child, provider)) : children;
|
|
156
|
+
}
|
|
157
|
+
function createContext2(defaultValue, name) {
|
|
158
|
+
const context = createContext(defaultValue, name);
|
|
159
|
+
const provide = context.Provider;
|
|
160
|
+
const Provider = (props) => provide({
|
|
161
|
+
get value() {
|
|
162
|
+
return props.value;
|
|
163
|
+
},
|
|
164
|
+
get debug() {
|
|
165
|
+
return props.debug;
|
|
166
|
+
},
|
|
167
|
+
// Read by the runtime Provider with its own scope current.
|
|
168
|
+
get children() {
|
|
169
|
+
const provider = getOwner();
|
|
170
|
+
const children = props.children;
|
|
171
|
+
return provider ? bindChildren(children, provider) : children;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return { ...context, Provider };
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
createContext2 as createContext
|
|
178
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,7 +31,7 @@ __export(core_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(core_exports);
|
|
32
32
|
|
|
33
33
|
// src/version.generated.ts
|
|
34
|
-
var VERSION = "1.0.0-alpha.
|
|
34
|
+
var VERSION = "1.0.0-alpha.104";
|
|
35
35
|
|
|
36
36
|
// src/lib/signal/graph/state.ts
|
|
37
37
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.104 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// src/version.generated.ts
|
|
4
|
-
var VERSION = "1.0.0-alpha.
|
|
4
|
+
var VERSION = "1.0.0-alpha.104";
|
|
5
5
|
|
|
6
6
|
// src/lib/signal/graph/state.ts
|
|
7
7
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -26,7 +26,7 @@ __export(debounced_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(debounced_exports);
|
|
27
27
|
|
|
28
28
|
// src/version.generated.ts
|
|
29
|
-
var VERSION = "1.0.0-alpha.
|
|
29
|
+
var VERSION = "1.0.0-alpha.104";
|
|
30
30
|
|
|
31
31
|
// src/lib/signal/graph/state.ts
|
|
32
32
|
var MAJOR = VERSION.split(".")[0];
|