@fictjs/runtime 0.5.0 → 0.5.2
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/advanced.cjs +9 -9
- package/dist/advanced.js +4 -4
- package/dist/{chunk-5AA7HP4S.js → chunk-4NUHM77Z.js} +3 -3
- package/dist/{chunk-BQG7VEBY.js → chunk-D2IWOO4X.js} +2 -2
- package/dist/{chunk-KYLNC4CD.cjs → chunk-KNGHYGK4.cjs} +17 -17
- package/dist/{chunk-KYLNC4CD.cjs.map → chunk-KNGHYGK4.cjs.map} +1 -1
- package/dist/{chunk-FKDMDAUR.js → chunk-LRFMCJY3.js} +119 -19
- package/dist/chunk-LRFMCJY3.js.map +1 -0
- package/dist/{chunk-GHUV2FLD.cjs → chunk-QB2UD62G.cjs} +8 -8
- package/dist/{chunk-GHUV2FLD.cjs.map → chunk-QB2UD62G.cjs.map} +1 -1
- package/dist/{chunk-KKKYW54Z.js → chunk-SLFAEVKJ.js} +3 -3
- package/dist/{chunk-TKWN42TA.cjs → chunk-Z6M3HKLG.cjs} +156 -156
- package/dist/{chunk-TKWN42TA.cjs.map → chunk-Z6M3HKLG.cjs.map} +1 -1
- package/dist/{chunk-6SOPF5LZ.cjs → chunk-ZR435MDC.cjs} +120 -20
- package/dist/chunk-ZR435MDC.cjs.map +1 -0
- package/dist/index.cjs +95 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.js +120 -25
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +60 -10
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +64 -42
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +12 -3
- package/dist/internal.d.ts +12 -3
- package/dist/internal.js +25 -3
- package/dist/internal.js.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +671 -0
- package/dist/jsx-dev-runtime.d.ts +671 -0
- package/dist/loader.cjs +60 -8
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.d.cts +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +53 -1
- package/dist/loader.js.map +1 -1
- package/dist/{resume-Dx8_l72o.d.ts → resume-CqeQ3v_q.d.ts} +5 -1
- package/dist/{resume-BrAkmSTY.d.cts → resume-i-A3EFox.d.cts} +5 -1
- package/package.json +1 -1
- package/src/cycle-guard.ts +1 -1
- package/src/internal.ts +4 -0
- package/src/list-helpers.ts +19 -4
- package/src/loader.ts +58 -0
- package/src/resume.ts +55 -0
- package/src/signal.ts +47 -22
- package/src/ssr-stream.ts +38 -0
- package/src/suspense.ts +62 -7
- package/dist/chunk-6SOPF5LZ.cjs.map +0 -1
- package/dist/chunk-FKDMDAUR.js.map +0 -1
- /package/dist/{chunk-5AA7HP4S.js.map → chunk-4NUHM77Z.js.map} +0 -0
- /package/dist/{chunk-BQG7VEBY.js.map → chunk-D2IWOO4X.js.map} +0 -0
- /package/dist/{chunk-KKKYW54Z.js.map → chunk-SLFAEVKJ.js.map} +0 -0
package/dist/advanced.cjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkKNGHYGK4cjs = require('./chunk-KNGHYGK4.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkQB2UD62Gcjs = require('./chunk-QB2UD62G.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ var _chunkGHUV2FLDcjs = require('./chunk-GHUV2FLD.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkZ6M3HKLGcjs = require('./chunk-Z6M3HKLG.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -26,13 +26,13 @@ var _chunkTKWN42TAcjs = require('./chunk-TKWN42TA.cjs');
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkZR435MDCcjs = require('./chunk-ZR435MDC.cjs');
|
|
30
30
|
|
|
31
31
|
// src/versioned-signal.ts
|
|
32
32
|
function createVersionedSignal(initialValue, options) {
|
|
33
33
|
const equals = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.equals]), () => ( Object.is));
|
|
34
|
-
const value =
|
|
35
|
-
const version =
|
|
34
|
+
const value = _chunkZR435MDCcjs.signal.call(void 0, initialValue);
|
|
35
|
+
const version = _chunkZR435MDCcjs.signal.call(void 0, 0);
|
|
36
36
|
const bumpVersion = () => {
|
|
37
37
|
const next = version() + 1;
|
|
38
38
|
version(next);
|
|
@@ -53,8 +53,8 @@ function createVersionedSignal(initialValue, options) {
|
|
|
53
53
|
force: () => {
|
|
54
54
|
bumpVersion();
|
|
55
55
|
},
|
|
56
|
-
peekVersion: () =>
|
|
57
|
-
peekValue: () =>
|
|
56
|
+
peekVersion: () => _chunkZR435MDCcjs.untrack.call(void 0, () => version()),
|
|
57
|
+
peekValue: () => _chunkZR435MDCcjs.untrack.call(void 0, () => value())
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -79,5 +79,5 @@ function createVersionedSignal(initialValue, options) {
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
exports.createAttributeBinding =
|
|
82
|
+
exports.createAttributeBinding = _chunkZ6M3HKLGcjs.createAttributeBinding; exports.createChildBinding = _chunkZ6M3HKLGcjs.createChildBinding; exports.createClassBinding = _chunkZ6M3HKLGcjs.createClassBinding; exports.createContext = _chunkKNGHYGK4cjs.createContext; exports.createRenderEffect = _chunkZR435MDCcjs.createRenderEffect; exports.createScope = _chunkQB2UD62Gcjs.createScope; exports.createSelector = _chunkZR435MDCcjs.createSelector; exports.createShow = _chunkZ6M3HKLGcjs.createShow; exports.createSignal = _chunkZR435MDCcjs.signal; exports.createStyleBinding = _chunkZ6M3HKLGcjs.createStyleBinding; exports.createTextBinding = _chunkZ6M3HKLGcjs.createTextBinding; exports.createVersionedSignal = createVersionedSignal; exports.effectScope = _chunkZR435MDCcjs.effectScope; exports.getDevtoolsHook = _chunkZR435MDCcjs.getDevtoolsHook; exports.hasContext = _chunkKNGHYGK4cjs.hasContext; exports.isReactive = _chunkZ6M3HKLGcjs.isReactive; exports.registerErrorHandler = _chunkZR435MDCcjs.registerErrorHandler; exports.runInScope = _chunkQB2UD62Gcjs.runInScope; exports.setCycleProtectionOptions = _chunkZR435MDCcjs.setCycleProtectionOptions; exports.unwrap = _chunkZ6M3HKLGcjs.unwrap; exports.useContext = _chunkKNGHYGK4cjs.useContext;
|
|
83
83
|
//# sourceMappingURL=advanced.cjs.map
|
package/dist/advanced.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
createContext,
|
|
3
3
|
hasContext,
|
|
4
4
|
useContext
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SLFAEVKJ.js";
|
|
6
6
|
import {
|
|
7
7
|
createScope,
|
|
8
8
|
runInScope
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4NUHM77Z.js";
|
|
10
10
|
import {
|
|
11
11
|
createAttributeBinding,
|
|
12
12
|
createChildBinding,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
createTextBinding,
|
|
17
17
|
isReactive,
|
|
18
18
|
unwrap
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-D2IWOO4X.js";
|
|
20
20
|
import {
|
|
21
21
|
createRenderEffect,
|
|
22
22
|
createSelector,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
setCycleProtectionOptions,
|
|
27
27
|
signal,
|
|
28
28
|
untrack
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-LRFMCJY3.js";
|
|
30
30
|
|
|
31
31
|
// src/versioned-signal.ts
|
|
32
32
|
function createVersionedSignal(initialValue, options) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isReactive
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D2IWOO4X.js";
|
|
4
4
|
import {
|
|
5
5
|
createEffect,
|
|
6
6
|
createRoot,
|
|
7
7
|
onCleanup,
|
|
8
8
|
registerRootCleanup
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LRFMCJY3.js";
|
|
10
10
|
|
|
11
11
|
// src/scope.ts
|
|
12
12
|
function createScope() {
|
|
@@ -44,4 +44,4 @@ export {
|
|
|
44
44
|
createScope,
|
|
45
45
|
runInScope
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-4NUHM77Z.js.map
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
setTransitionContext,
|
|
41
41
|
signal,
|
|
42
42
|
untrack
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-LRFMCJY3.js";
|
|
44
44
|
|
|
45
45
|
// src/jsx.ts
|
|
46
46
|
var Fragment = Symbol("Fragment");
|
|
@@ -2256,4 +2256,4 @@ export {
|
|
|
2256
2256
|
createElement,
|
|
2257
2257
|
template
|
|
2258
2258
|
};
|
|
2259
|
-
//# sourceMappingURL=chunk-
|
|
2259
|
+
//# sourceMappingURL=chunk-D2IWOO4X.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZ6M3HKLGcjs = require('./chunk-Z6M3HKLG.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ var _chunkTKWN42TAcjs = require('./chunk-TKWN42TA.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkZR435MDCcjs = require('./chunk-ZR435MDC.cjs');
|
|
16
16
|
|
|
17
17
|
// src/context.ts
|
|
18
18
|
var contextStorage = /* @__PURE__ */ new WeakMap();
|
|
@@ -32,8 +32,8 @@ function createContext(defaultValue) {
|
|
|
32
32
|
Provider: null
|
|
33
33
|
};
|
|
34
34
|
context.Provider = function Provider(props) {
|
|
35
|
-
const hostRoot =
|
|
36
|
-
const providerRoot =
|
|
35
|
+
const hostRoot = _chunkZR435MDCcjs.getCurrentRoot.call(void 0, );
|
|
36
|
+
const providerRoot = _chunkZR435MDCcjs.createRootContext.call(void 0, hostRoot);
|
|
37
37
|
const contextMap = getContextMap(providerRoot);
|
|
38
38
|
contextMap.set(id, props.value);
|
|
39
39
|
const fragment = document.createDocumentFragment();
|
|
@@ -47,32 +47,32 @@ function createContext(defaultValue) {
|
|
|
47
47
|
cleanup = void 0;
|
|
48
48
|
}
|
|
49
49
|
if (activeNodes.length) {
|
|
50
|
-
|
|
50
|
+
_chunkZ6M3HKLGcjs.removeNodes.call(void 0, activeNodes);
|
|
51
51
|
activeNodes = [];
|
|
52
52
|
}
|
|
53
53
|
if (children == null || children === false) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
const prev =
|
|
56
|
+
const prev = _chunkZR435MDCcjs.pushRoot.call(void 0, providerRoot);
|
|
57
57
|
let nodes = [];
|
|
58
58
|
try {
|
|
59
|
-
const output =
|
|
60
|
-
nodes =
|
|
59
|
+
const output = _chunkZ6M3HKLGcjs.createElement.call(void 0, children);
|
|
60
|
+
nodes = _chunkZ6M3HKLGcjs.toNodeArray.call(void 0, output);
|
|
61
61
|
const parentNode = marker.parentNode;
|
|
62
62
|
if (parentNode) {
|
|
63
|
-
|
|
63
|
+
_chunkZ6M3HKLGcjs.insertNodesBefore.call(void 0, parentNode, nodes, marker);
|
|
64
64
|
}
|
|
65
65
|
} finally {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
_chunkZR435MDCcjs.popRoot.call(void 0, prev);
|
|
67
|
+
_chunkZR435MDCcjs.flushOnMount.call(void 0, providerRoot);
|
|
68
68
|
}
|
|
69
69
|
cleanup = () => {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
_chunkZR435MDCcjs.destroyRoot.call(void 0, providerRoot);
|
|
71
|
+
_chunkZ6M3HKLGcjs.removeNodes.call(void 0, nodes);
|
|
72
72
|
};
|
|
73
73
|
activeNodes = nodes;
|
|
74
74
|
};
|
|
75
|
-
|
|
75
|
+
_chunkZR435MDCcjs.createRenderEffect.call(void 0, () => {
|
|
76
76
|
contextMap.set(id, props.value);
|
|
77
77
|
renderChildren(props.children);
|
|
78
78
|
});
|
|
@@ -81,7 +81,7 @@ function createContext(defaultValue) {
|
|
|
81
81
|
return context;
|
|
82
82
|
}
|
|
83
83
|
function useContext(context) {
|
|
84
|
-
let root =
|
|
84
|
+
let root = _chunkZR435MDCcjs.getCurrentRoot.call(void 0, );
|
|
85
85
|
while (root) {
|
|
86
86
|
const contextMap = contextStorage.get(root);
|
|
87
87
|
if (contextMap && contextMap.has(context.id)) {
|
|
@@ -92,7 +92,7 @@ function useContext(context) {
|
|
|
92
92
|
return context.defaultValue;
|
|
93
93
|
}
|
|
94
94
|
function hasContext(context) {
|
|
95
|
-
let root =
|
|
95
|
+
let root = _chunkZR435MDCcjs.getCurrentRoot.call(void 0, );
|
|
96
96
|
while (root) {
|
|
97
97
|
const contextMap = contextStorage.get(root);
|
|
98
98
|
if (contextMap && contextMap.has(context.id)) {
|
|
@@ -108,4 +108,4 @@ function hasContext(context) {
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
exports.createContext = createContext; exports.useContext = useContext; exports.hasContext = hasContext;
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-KNGHYGK4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/fict/fict/packages/runtime/dist/chunk-KYLNC4CD.cjs","../src/context.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;A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IAAI,KAAA,EAAO,8CAAA,CAAe;AAG1B,EAAA,MAAA,CAAO,IAAA,EAAM;AACX,IAAA,MAAM,WAAA,EAAa,cAAA,CAAe,GAAA,CAAI,IAAI,CAAA;AAC1C,IAAA,GAAA,CAAI,WAAA,GAAc,UAAA,CAAW,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AAC5C,MAAA,OAAO,UAAA,CAAW,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA;AAAA,IAClC;AACA,IAAA,KAAA,EAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAGA,EAAA,OAAO,OAAA,CAAQ,YAAA;AACjB;AAqBO,SAAS,UAAA,CAAc,OAAA,EAA8B;AAC1D,EAAA,IAAI,KAAA,EAAO,8CAAA,CAAe;AAE1B,EAAA,MAAA,CAAO,IAAA,EAAM;AACX,IAAA,MAAM,WAAA,EAAa,cAAA,CAAe,GAAA,CAAI,IAAI,CAAA;AAC1C,IAAA,GAAA,CAAI,WAAA,GAAc,UAAA,CAAW,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AAC5C,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,KAAA,EAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAEA,EAAA,OAAO,KAAA;AACT;ADnMA;AACA;AACE;AACA;AACA;AACF,wGAAC","file":"/home/runner/work/fict/fict/packages/runtime/dist/chunk-KYLNC4CD.cjs","sourcesContent":[null,"/**\n * @fileoverview Context API for Fict\n *\n * Provides a way to pass data through the component tree without having to pass\n * props down manually at every level. Context is designed for:\n *\n * - SSR isolation (different request = different context values)\n * - Multi-instance support (multiple app roots with different values)\n * - Subtree scoping (override values in specific parts of the tree)\n *\n * ## Design Principles\n *\n * 1. **Reuses existing RootContext hierarchy** - Uses parent chain for value lookup,\n * consistent with handleError/handleSuspend mechanisms.\n *\n * 2. **Zero extra root creation overhead** - Provider doesn't create new root,\n * only mounts value on current root.\n *\n * 3. **Auto-aligned with insert/suspense boundaries** - Because they create child\n * roots that inherit parent, context values propagate correctly.\n *\n * ## Usage\n *\n * ```tsx\n * // Create context with default value\n * const ThemeContext = createContext<'light' | 'dark'>('light')\n *\n * // Provide value to subtree\n * function App() {\n * return (\n * <ThemeContext.Provider value=\"dark\">\n * <ThemedComponent />\n * </ThemeContext.Provider>\n * )\n * }\n *\n * // Consume value\n * function ThemedComponent() {\n * const theme = useContext(ThemeContext)\n * return <div class={theme}>...</div>\n * }\n * ```\n *\n * @module\n */\n\nimport { createElement } from './dom'\nimport { createRenderEffect } from './effect'\nimport {\n createRootContext,\n destroyRoot,\n flushOnMount,\n getCurrentRoot,\n popRoot,\n pushRoot,\n type RootContext,\n} from './lifecycle'\nimport { insertNodesBefore, removeNodes, toNodeArray } from './node-ops'\nimport type { BaseProps, FictNode } from './types'\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Context object created by createContext.\n * Contains the Provider component and serves as a key for context lookup.\n */\nexport interface Context<T> {\n /** Unique identifier for this context */\n readonly id: symbol\n /** Default value when no provider is found */\n readonly defaultValue: T\n /** Provider component for supplying context values */\n Provider: ContextProvider<T>\n /** Display name for debugging */\n displayName?: string\n}\n\n/**\n * Props for the Context Provider component\n */\nexport interface ProviderProps<T> extends BaseProps {\n /** The value to provide to the subtree */\n value: T\n}\n\n/**\n * Provider component type\n */\nexport type ContextProvider<T> = (props: ProviderProps<T>) => FictNode\n\n// ============================================================================\n// Internal Context Storage\n// ============================================================================\n\n/**\n * WeakMap to store context values per RootContext.\n * Using WeakMap ensures proper garbage collection when roots are destroyed.\n */\nconst contextStorage = new WeakMap<RootContext, Map<symbol, unknown>>()\n\n/**\n * Get the context map for a root, creating it if needed\n */\nfunction getContextMap(root: RootContext): Map<symbol, unknown> {\n let map = contextStorage.get(root)\n if (!map) {\n map = new Map()\n contextStorage.set(root, map)\n }\n return map\n}\n\n// ============================================================================\n// Context API\n// ============================================================================\n\n/**\n * Creates a new context with the given default value.\n *\n * Context provides a way to pass values through the component tree without\n * explicit props drilling. It's especially useful for:\n *\n * - Theme data\n * - Locale/i18n settings\n * - Authentication state\n * - Feature flags\n * - Any data that many components at different nesting levels need\n *\n * @param defaultValue - The value to use when no Provider is found above in the tree\n * @returns A context object with a Provider component\n *\n * @example\n * ```tsx\n * // Create a theme context\n * const ThemeContext = createContext<'light' | 'dark'>('light')\n *\n * // Use the provider\n * function App() {\n * return (\n * <ThemeContext.Provider value=\"dark\">\n * <Content />\n * </ThemeContext.Provider>\n * )\n * }\n *\n * // Consume the context\n * function Content() {\n * const theme = useContext(ThemeContext)\n * return <div class={`theme-${theme}`}>Hello</div>\n * }\n * ```\n */\nexport function createContext<T>(defaultValue: T): Context<T> {\n const id = Symbol('fict.context')\n\n const context: Context<T> = {\n id,\n defaultValue,\n Provider: null as unknown as ContextProvider<T>,\n }\n\n // Create the Provider component\n context.Provider = function Provider(props: ProviderProps<T>): FictNode {\n const hostRoot = getCurrentRoot()\n\n // Create a child root for the provider's subtree\n // This establishes the provider boundary - children will look up from here\n const providerRoot = createRootContext(hostRoot)\n\n // Store the context value on this root\n const contextMap = getContextMap(providerRoot)\n contextMap.set(id, props.value)\n\n // Create DOM structure\n const fragment = document.createDocumentFragment()\n const marker = document.createComment('fict:ctx')\n fragment.appendChild(marker)\n\n let cleanup: (() => void) | undefined\n let activeNodes: Node[] = []\n\n const renderChildren = (children: FictNode) => {\n // Cleanup previous render\n if (cleanup) {\n cleanup()\n cleanup = undefined\n }\n if (activeNodes.length) {\n removeNodes(activeNodes)\n activeNodes = []\n }\n\n if (children == null || children === false) {\n return\n }\n\n const prev = pushRoot(providerRoot)\n let nodes: Node[] = []\n try {\n const output = createElement(children)\n nodes = toNodeArray(output)\n const parentNode = marker.parentNode as (ParentNode & Node) | null\n if (parentNode) {\n insertNodesBefore(parentNode, nodes, marker)\n }\n } finally {\n popRoot(prev)\n flushOnMount(providerRoot)\n }\n\n cleanup = () => {\n destroyRoot(providerRoot)\n removeNodes(nodes)\n }\n activeNodes = nodes\n }\n\n // Initial render\n createRenderEffect(() => {\n // Update context value on re-render (if value prop changes reactively)\n contextMap.set(id, props.value)\n renderChildren(props.children)\n })\n\n return fragment\n }\n\n return context\n}\n\n/**\n * Reads the current value of a context.\n *\n * useContext looks up through the RootContext parent chain to find the\n * nearest Provider for this context. If no Provider is found, returns\n * the context's default value.\n *\n * @param context - The context object created by createContext\n * @returns The current context value\n *\n * @example\n * ```tsx\n * const ThemeContext = createContext('light')\n *\n * function ThemedButton() {\n * const theme = useContext(ThemeContext)\n * return <button class={theme === 'dark' ? 'btn-dark' : 'btn-light'}>Click</button>\n * }\n * ```\n */\nexport function useContext<T>(context: Context<T>): T {\n let root = getCurrentRoot()\n\n // Walk up the parent chain looking for the context value\n while (root) {\n const contextMap = contextStorage.get(root)\n if (contextMap && contextMap.has(context.id)) {\n return contextMap.get(context.id) as T\n }\n root = root.parent\n }\n\n // No provider found, return default value\n return context.defaultValue\n}\n\n/**\n * Checks if a context value is currently provided in the tree.\n *\n * Useful for conditional behavior when a provider may or may not exist.\n *\n * @param context - The context object to check\n * @returns true if a Provider exists above in the tree\n *\n * @example\n * ```tsx\n * function OptionalTheme() {\n * if (hasContext(ThemeContext)) {\n * const theme = useContext(ThemeContext)\n * return <div class={theme}>Themed content</div>\n * }\n * return <div>Default content</div>\n * }\n * ```\n */\nexport function hasContext<T>(context: Context<T>): boolean {\n let root = getCurrentRoot()\n\n while (root) {\n const contextMap = contextStorage.get(root)\n if (contextMap && contextMap.has(context.id)) {\n return true\n }\n root = root.parent\n }\n\n return false\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/fict/fict/packages/runtime/dist/chunk-KNGHYGK4.cjs","../src/context.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACoFA,IAAM,eAAA,kBAAiB,IAAI,OAAA,CAA2C,CAAA;AAKtE,SAAS,aAA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AAA,CAAe,GAAA,CAAI,IAAI,CAAA;AAC1C,IAAA,GAAA,CAAI,WAAA,GAAc,UAAA,CAAW,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AAC5C,MAAA,OAAO,UAAA,CAAW,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA;AAAA,IAClC;AACA,IAAA,KAAA,EAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAGA,EAAA,OAAO,OAAA,CAAQ,YAAA;AACjB;AAqBO,SAAS,UAAA,CAAc,OAAA,EAA8B;AAC1D,EAAA,IAAI,KAAA,EAAO,8CAAA,CAAe;AAE1B,EAAA,MAAA,CAAO,IAAA,EAAM;AACX,IAAA,MAAM,WAAA,EAAa,cAAA,CAAe,GAAA,CAAI,IAAI,CAAA;AAC1C,IAAA,GAAA,CAAI,WAAA,GAAc,UAAA,CAAW,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AAC5C,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,KAAA,EAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAEA,EAAA,OAAO,KAAA;AACT;ADnMA;AACA;AACE;AACA;AACA;AACF,wGAAC","file":"/home/runner/work/fict/fict/packages/runtime/dist/chunk-KNGHYGK4.cjs","sourcesContent":[null,"/**\n * @fileoverview Context API for Fict\n *\n * Provides a way to pass data through the component tree without having to pass\n * props down manually at every level. Context is designed for:\n *\n * - SSR isolation (different request = different context values)\n * - Multi-instance support (multiple app roots with different values)\n * - Subtree scoping (override values in specific parts of the tree)\n *\n * ## Design Principles\n *\n * 1. **Reuses existing RootContext hierarchy** - Uses parent chain for value lookup,\n * consistent with handleError/handleSuspend mechanisms.\n *\n * 2. **Zero extra root creation overhead** - Provider doesn't create new root,\n * only mounts value on current root.\n *\n * 3. **Auto-aligned with insert/suspense boundaries** - Because they create child\n * roots that inherit parent, context values propagate correctly.\n *\n * ## Usage\n *\n * ```tsx\n * // Create context with default value\n * const ThemeContext = createContext<'light' | 'dark'>('light')\n *\n * // Provide value to subtree\n * function App() {\n * return (\n * <ThemeContext.Provider value=\"dark\">\n * <ThemedComponent />\n * </ThemeContext.Provider>\n * )\n * }\n *\n * // Consume value\n * function ThemedComponent() {\n * const theme = useContext(ThemeContext)\n * return <div class={theme}>...</div>\n * }\n * ```\n *\n * @module\n */\n\nimport { createElement } from './dom'\nimport { createRenderEffect } from './effect'\nimport {\n createRootContext,\n destroyRoot,\n flushOnMount,\n getCurrentRoot,\n popRoot,\n pushRoot,\n type RootContext,\n} from './lifecycle'\nimport { insertNodesBefore, removeNodes, toNodeArray } from './node-ops'\nimport type { BaseProps, FictNode } from './types'\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Context object created by createContext.\n * Contains the Provider component and serves as a key for context lookup.\n */\nexport interface Context<T> {\n /** Unique identifier for this context */\n readonly id: symbol\n /** Default value when no provider is found */\n readonly defaultValue: T\n /** Provider component for supplying context values */\n Provider: ContextProvider<T>\n /** Display name for debugging */\n displayName?: string\n}\n\n/**\n * Props for the Context Provider component\n */\nexport interface ProviderProps<T> extends BaseProps {\n /** The value to provide to the subtree */\n value: T\n}\n\n/**\n * Provider component type\n */\nexport type ContextProvider<T> = (props: ProviderProps<T>) => FictNode\n\n// ============================================================================\n// Internal Context Storage\n// ============================================================================\n\n/**\n * WeakMap to store context values per RootContext.\n * Using WeakMap ensures proper garbage collection when roots are destroyed.\n */\nconst contextStorage = new WeakMap<RootContext, Map<symbol, unknown>>()\n\n/**\n * Get the context map for a root, creating it if needed\n */\nfunction getContextMap(root: RootContext): Map<symbol, unknown> {\n let map = contextStorage.get(root)\n if (!map) {\n map = new Map()\n contextStorage.set(root, map)\n }\n return map\n}\n\n// ============================================================================\n// Context API\n// ============================================================================\n\n/**\n * Creates a new context with the given default value.\n *\n * Context provides a way to pass values through the component tree without\n * explicit props drilling. It's especially useful for:\n *\n * - Theme data\n * - Locale/i18n settings\n * - Authentication state\n * - Feature flags\n * - Any data that many components at different nesting levels need\n *\n * @param defaultValue - The value to use when no Provider is found above in the tree\n * @returns A context object with a Provider component\n *\n * @example\n * ```tsx\n * // Create a theme context\n * const ThemeContext = createContext<'light' | 'dark'>('light')\n *\n * // Use the provider\n * function App() {\n * return (\n * <ThemeContext.Provider value=\"dark\">\n * <Content />\n * </ThemeContext.Provider>\n * )\n * }\n *\n * // Consume the context\n * function Content() {\n * const theme = useContext(ThemeContext)\n * return <div class={`theme-${theme}`}>Hello</div>\n * }\n * ```\n */\nexport function createContext<T>(defaultValue: T): Context<T> {\n const id = Symbol('fict.context')\n\n const context: Context<T> = {\n id,\n defaultValue,\n Provider: null as unknown as ContextProvider<T>,\n }\n\n // Create the Provider component\n context.Provider = function Provider(props: ProviderProps<T>): FictNode {\n const hostRoot = getCurrentRoot()\n\n // Create a child root for the provider's subtree\n // This establishes the provider boundary - children will look up from here\n const providerRoot = createRootContext(hostRoot)\n\n // Store the context value on this root\n const contextMap = getContextMap(providerRoot)\n contextMap.set(id, props.value)\n\n // Create DOM structure\n const fragment = document.createDocumentFragment()\n const marker = document.createComment('fict:ctx')\n fragment.appendChild(marker)\n\n let cleanup: (() => void) | undefined\n let activeNodes: Node[] = []\n\n const renderChildren = (children: FictNode) => {\n // Cleanup previous render\n if (cleanup) {\n cleanup()\n cleanup = undefined\n }\n if (activeNodes.length) {\n removeNodes(activeNodes)\n activeNodes = []\n }\n\n if (children == null || children === false) {\n return\n }\n\n const prev = pushRoot(providerRoot)\n let nodes: Node[] = []\n try {\n const output = createElement(children)\n nodes = toNodeArray(output)\n const parentNode = marker.parentNode as (ParentNode & Node) | null\n if (parentNode) {\n insertNodesBefore(parentNode, nodes, marker)\n }\n } finally {\n popRoot(prev)\n flushOnMount(providerRoot)\n }\n\n cleanup = () => {\n destroyRoot(providerRoot)\n removeNodes(nodes)\n }\n activeNodes = nodes\n }\n\n // Initial render\n createRenderEffect(() => {\n // Update context value on re-render (if value prop changes reactively)\n contextMap.set(id, props.value)\n renderChildren(props.children)\n })\n\n return fragment\n }\n\n return context\n}\n\n/**\n * Reads the current value of a context.\n *\n * useContext looks up through the RootContext parent chain to find the\n * nearest Provider for this context. If no Provider is found, returns\n * the context's default value.\n *\n * @param context - The context object created by createContext\n * @returns The current context value\n *\n * @example\n * ```tsx\n * const ThemeContext = createContext('light')\n *\n * function ThemedButton() {\n * const theme = useContext(ThemeContext)\n * return <button class={theme === 'dark' ? 'btn-dark' : 'btn-light'}>Click</button>\n * }\n * ```\n */\nexport function useContext<T>(context: Context<T>): T {\n let root = getCurrentRoot()\n\n // Walk up the parent chain looking for the context value\n while (root) {\n const contextMap = contextStorage.get(root)\n if (contextMap && contextMap.has(context.id)) {\n return contextMap.get(context.id) as T\n }\n root = root.parent\n }\n\n // No provider found, return default value\n return context.defaultValue\n}\n\n/**\n * Checks if a context value is currently provided in the tree.\n *\n * Useful for conditional behavior when a provider may or may not exist.\n *\n * @param context - The context object to check\n * @returns true if a Provider exists above in the tree\n *\n * @example\n * ```tsx\n * function OptionalTheme() {\n * if (hasContext(ThemeContext)) {\n * const theme = useContext(ThemeContext)\n * return <div class={theme}>Themed content</div>\n * }\n * return <div>Default content</div>\n * }\n * ```\n */\nexport function hasContext<T>(context: Context<T>): boolean {\n let root = getCurrentRoot()\n\n while (root) {\n const contextMap = contextStorage.get(root)\n if (contextMap && contextMap.has(context.id)) {\n return true\n }\n root = root.parent\n }\n\n return false\n}\n"]}
|
|
@@ -401,7 +401,7 @@ var enterRootGuard = () => true;
|
|
|
401
401
|
var exitRootGuard = () => {
|
|
402
402
|
};
|
|
403
403
|
var defaultOptions = {
|
|
404
|
-
enabled:
|
|
404
|
+
enabled: isDev2,
|
|
405
405
|
maxFlushCyclesPerMicrotask: 1e4,
|
|
406
406
|
maxEffectRunsPerFlush: 2e4,
|
|
407
407
|
windowSize: 5,
|
|
@@ -978,6 +978,8 @@ var cycle = 0;
|
|
|
978
978
|
var batchDepth = 0;
|
|
979
979
|
var activeSub;
|
|
980
980
|
var flushScheduled = false;
|
|
981
|
+
var currentFlushId = 0;
|
|
982
|
+
var activeCleanupFlushId = 0;
|
|
981
983
|
var highPriorityQueue = [];
|
|
982
984
|
var lowPriorityQueue = [];
|
|
983
985
|
var isInTransition = false;
|
|
@@ -1223,6 +1225,8 @@ function updateSignal(s) {
|
|
|
1223
1225
|
const current = s.currentValue;
|
|
1224
1226
|
const pending = s.pendingValue;
|
|
1225
1227
|
if (valuesDiffer(s, current, pending)) {
|
|
1228
|
+
s.prevValue = current;
|
|
1229
|
+
s.prevFlushId = currentFlushId;
|
|
1226
1230
|
s.currentValue = pending;
|
|
1227
1231
|
return true;
|
|
1228
1232
|
}
|
|
@@ -1241,6 +1245,8 @@ function updateComputed(c) {
|
|
|
1241
1245
|
c.flags &= ~Running;
|
|
1242
1246
|
purgeDeps(c);
|
|
1243
1247
|
if (valuesDiffer(c, oldValue, newValue)) {
|
|
1248
|
+
c.prevValue = oldValue;
|
|
1249
|
+
c.prevFlushId = currentFlushId;
|
|
1244
1250
|
c.value = newValue;
|
|
1245
1251
|
if (isDev5) updateComputedDevtools(c, newValue);
|
|
1246
1252
|
return true;
|
|
@@ -1254,15 +1260,19 @@ function updateComputed(c) {
|
|
|
1254
1260
|
}
|
|
1255
1261
|
function runEffect(e) {
|
|
1256
1262
|
const flags = e.flags;
|
|
1257
|
-
|
|
1258
|
-
if (e.runCleanup)
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1263
|
+
const runCleanup = () => {
|
|
1264
|
+
if (!e.runCleanup) return;
|
|
1265
|
+
inCleanup = true;
|
|
1266
|
+
activeCleanupFlushId = currentFlushId;
|
|
1267
|
+
try {
|
|
1268
|
+
e.runCleanup();
|
|
1269
|
+
} finally {
|
|
1270
|
+
activeCleanupFlushId = 0;
|
|
1271
|
+
inCleanup = false;
|
|
1265
1272
|
}
|
|
1273
|
+
};
|
|
1274
|
+
if (flags & Dirty) {
|
|
1275
|
+
runCleanup();
|
|
1266
1276
|
++cycle;
|
|
1267
1277
|
if (isDev5) effectRunDevtools(e);
|
|
1268
1278
|
e.depsTail = void 0;
|
|
@@ -1280,14 +1290,6 @@ function runEffect(e) {
|
|
|
1280
1290
|
throw err;
|
|
1281
1291
|
}
|
|
1282
1292
|
} else if (flags & Pending && e.deps) {
|
|
1283
|
-
if (e.runCleanup) {
|
|
1284
|
-
inCleanup = true;
|
|
1285
|
-
try {
|
|
1286
|
-
e.runCleanup();
|
|
1287
|
-
} finally {
|
|
1288
|
-
inCleanup = false;
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
1293
|
let isDirty = false;
|
|
1292
1294
|
try {
|
|
1293
1295
|
isDirty = checkDirty(e.deps, e);
|
|
@@ -1307,6 +1309,7 @@ function runEffect(e) {
|
|
|
1307
1309
|
throw err;
|
|
1308
1310
|
}
|
|
1309
1311
|
if (isDirty) {
|
|
1312
|
+
runCleanup();
|
|
1310
1313
|
++cycle;
|
|
1311
1314
|
if (isDev5) effectRunDevtools(e);
|
|
1312
1315
|
e.depsTail = void 0;
|
|
@@ -1352,6 +1355,7 @@ function flush() {
|
|
|
1352
1355
|
endFlushGuard();
|
|
1353
1356
|
return;
|
|
1354
1357
|
}
|
|
1358
|
+
currentFlushId++;
|
|
1355
1359
|
flushScheduled = false;
|
|
1356
1360
|
let highIndex = 0;
|
|
1357
1361
|
while (highIndex < highPriorityQueue.length) {
|
|
@@ -1456,6 +1460,12 @@ function signalOper(value) {
|
|
|
1456
1460
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1457
1461
|
}
|
|
1458
1462
|
}
|
|
1463
|
+
if (inCleanup) {
|
|
1464
|
+
if (this.prevFlushId === activeCleanupFlushId) {
|
|
1465
|
+
return this.prevValue;
|
|
1466
|
+
}
|
|
1467
|
+
return this.currentValue;
|
|
1468
|
+
}
|
|
1459
1469
|
let sub = activeSub;
|
|
1460
1470
|
while (sub !== void 0) {
|
|
1461
1471
|
if (sub.flags & 3) {
|
|
@@ -1489,7 +1499,12 @@ function computed(getter, options2) {
|
|
|
1489
1499
|
return bound;
|
|
1490
1500
|
}
|
|
1491
1501
|
function computedOper() {
|
|
1492
|
-
if (inCleanup)
|
|
1502
|
+
if (inCleanup) {
|
|
1503
|
+
if (this.prevFlushId === activeCleanupFlushId) {
|
|
1504
|
+
return this.prevValue;
|
|
1505
|
+
}
|
|
1506
|
+
return this.value;
|
|
1507
|
+
}
|
|
1493
1508
|
const flags = this.flags;
|
|
1494
1509
|
if (flags & Dirty) {
|
|
1495
1510
|
if (updateComputed(this)) {
|
|
@@ -1637,6 +1652,8 @@ function __resetReactiveState() {
|
|
|
1637
1652
|
isInTransition = false;
|
|
1638
1653
|
inCleanup = false;
|
|
1639
1654
|
cycle = 0;
|
|
1655
|
+
currentFlushId = 0;
|
|
1656
|
+
activeCleanupFlushId = 0;
|
|
1640
1657
|
}
|
|
1641
1658
|
function untrack(fn) {
|
|
1642
1659
|
const prev = activeSub;
|
|
@@ -1780,6 +1797,34 @@ function createMemo(fn, options2) {
|
|
|
1780
1797
|
return computed(fn, options2);
|
|
1781
1798
|
}
|
|
1782
1799
|
|
|
1800
|
+
// src/ssr-stream.ts
|
|
1801
|
+
var ssrStreamHooks = null;
|
|
1802
|
+
var boundaryStack = [];
|
|
1803
|
+
function __fictSetSSRStreamHooks(hooks) {
|
|
1804
|
+
ssrStreamHooks = hooks;
|
|
1805
|
+
if (!hooks) {
|
|
1806
|
+
boundaryStack.length = 0;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
function __fictGetSSRStreamHooks() {
|
|
1810
|
+
return ssrStreamHooks;
|
|
1811
|
+
}
|
|
1812
|
+
function __fictPushSSRBoundary(id) {
|
|
1813
|
+
boundaryStack.push(id);
|
|
1814
|
+
}
|
|
1815
|
+
function __fictPopSSRBoundary(expected) {
|
|
1816
|
+
if (boundaryStack.length === 0) return;
|
|
1817
|
+
const top = boundaryStack[boundaryStack.length - 1];
|
|
1818
|
+
if (expected && top !== expected) {
|
|
1819
|
+
boundaryStack.pop();
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
boundaryStack.pop();
|
|
1823
|
+
}
|
|
1824
|
+
function __fictGetCurrentSSRBoundary() {
|
|
1825
|
+
return boundaryStack.length > 0 ? boundaryStack[boundaryStack.length - 1] : null;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1783
1828
|
// src/store.ts
|
|
1784
1829
|
var PROXY = Symbol("fict:store-proxy");
|
|
1785
1830
|
var TARGET = Symbol("fict:store-target");
|
|
@@ -1948,17 +1993,20 @@ var resumableEnabled = false;
|
|
|
1948
1993
|
var hydrating = false;
|
|
1949
1994
|
var scopeCounter = 0;
|
|
1950
1995
|
var scopeRegistry = /* @__PURE__ */ new Map();
|
|
1996
|
+
var boundaryScopes = /* @__PURE__ */ new Map();
|
|
1951
1997
|
var snapshotState = null;
|
|
1952
1998
|
var resumedScopes = /* @__PURE__ */ new Map();
|
|
1953
1999
|
function __fictEnableSSR() {
|
|
1954
2000
|
ssrEnabled = true;
|
|
1955
2001
|
scopeCounter = 0;
|
|
1956
2002
|
scopeRegistry = /* @__PURE__ */ new Map();
|
|
2003
|
+
boundaryScopes = /* @__PURE__ */ new Map();
|
|
1957
2004
|
resumedScopes.clear();
|
|
1958
2005
|
snapshotState = null;
|
|
1959
2006
|
}
|
|
1960
2007
|
function __fictDisableSSR() {
|
|
1961
2008
|
ssrEnabled = false;
|
|
2009
|
+
boundaryScopes = /* @__PURE__ */ new Map();
|
|
1962
2010
|
}
|
|
1963
2011
|
function __fictEnableResumable() {
|
|
1964
2012
|
resumableEnabled = true;
|
|
@@ -2000,12 +2048,27 @@ function __fictRegisterScope(ctx, host, type, props) {
|
|
|
2000
2048
|
if (props !== void 0) {
|
|
2001
2049
|
record.props = props;
|
|
2002
2050
|
}
|
|
2051
|
+
const boundaryId = __fictGetCurrentSSRBoundary();
|
|
2052
|
+
if (boundaryId) {
|
|
2053
|
+
record.boundaryId = boundaryId;
|
|
2054
|
+
let scopes = boundaryScopes.get(boundaryId);
|
|
2055
|
+
if (!scopes) {
|
|
2056
|
+
scopes = /* @__PURE__ */ new Set();
|
|
2057
|
+
boundaryScopes.set(boundaryId, scopes);
|
|
2058
|
+
}
|
|
2059
|
+
scopes.add(id);
|
|
2060
|
+
}
|
|
2003
2061
|
scopeRegistry.set(id, record);
|
|
2004
2062
|
return id;
|
|
2005
2063
|
}
|
|
2006
2064
|
function __fictGetScopeRegistry() {
|
|
2007
2065
|
return scopeRegistry;
|
|
2008
2066
|
}
|
|
2067
|
+
function __fictGetScopesForBoundary(boundaryId) {
|
|
2068
|
+
const scopes = boundaryScopes.get(boundaryId);
|
|
2069
|
+
if (!scopes) return [];
|
|
2070
|
+
return Array.from(scopes);
|
|
2071
|
+
}
|
|
2009
2072
|
function __fictSerializeSSRState() {
|
|
2010
2073
|
const scopes = {};
|
|
2011
2074
|
for (const [id, record] of scopeRegistry.entries()) {
|
|
@@ -2026,12 +2089,42 @@ function __fictSerializeSSRState() {
|
|
|
2026
2089
|
}
|
|
2027
2090
|
return { scopes };
|
|
2028
2091
|
}
|
|
2092
|
+
function __fictSerializeSSRStateForScopes(scopeIds) {
|
|
2093
|
+
const scopes = {};
|
|
2094
|
+
for (const id of scopeIds) {
|
|
2095
|
+
const record = scopeRegistry.get(id);
|
|
2096
|
+
if (!record) continue;
|
|
2097
|
+
const snapshot = {
|
|
2098
|
+
id,
|
|
2099
|
+
slots: serializeSlots(record.ctx)
|
|
2100
|
+
};
|
|
2101
|
+
if (record.type !== void 0) {
|
|
2102
|
+
snapshot.t = record.type;
|
|
2103
|
+
}
|
|
2104
|
+
if (record.props !== void 0) {
|
|
2105
|
+
snapshot.props = record.props;
|
|
2106
|
+
}
|
|
2107
|
+
if (record.ctx.slotMap !== void 0) {
|
|
2108
|
+
snapshot.vars = record.ctx.slotMap;
|
|
2109
|
+
}
|
|
2110
|
+
scopes[id] = snapshot;
|
|
2111
|
+
}
|
|
2112
|
+
return { scopes };
|
|
2113
|
+
}
|
|
2029
2114
|
function __fictSetSSRState(state) {
|
|
2030
2115
|
snapshotState = state;
|
|
2031
2116
|
if (!state) {
|
|
2032
2117
|
resumedScopes.clear();
|
|
2033
2118
|
}
|
|
2034
2119
|
}
|
|
2120
|
+
function __fictMergeSSRState(state) {
|
|
2121
|
+
if (!state) return;
|
|
2122
|
+
if (!snapshotState) {
|
|
2123
|
+
snapshotState = { scopes: { ...state.scopes } };
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
Object.assign(snapshotState.scopes, state.scopes);
|
|
2127
|
+
}
|
|
2035
2128
|
function __fictGetSSRScope(id) {
|
|
2036
2129
|
return snapshotState?.scopes[id];
|
|
2037
2130
|
}
|
|
@@ -2334,6 +2427,10 @@ export {
|
|
|
2334
2427
|
createSelector,
|
|
2335
2428
|
createEffect,
|
|
2336
2429
|
createRenderEffect,
|
|
2430
|
+
__fictSetSSRStreamHooks,
|
|
2431
|
+
__fictGetSSRStreamHooks,
|
|
2432
|
+
__fictPushSSRBoundary,
|
|
2433
|
+
__fictPopSSRBoundary,
|
|
2337
2434
|
createStore,
|
|
2338
2435
|
isStoreProxy,
|
|
2339
2436
|
unwrapStore,
|
|
@@ -2348,8 +2445,11 @@ export {
|
|
|
2348
2445
|
__fictIsHydrating,
|
|
2349
2446
|
__fictRegisterScope,
|
|
2350
2447
|
__fictGetScopeRegistry,
|
|
2448
|
+
__fictGetScopesForBoundary,
|
|
2351
2449
|
__fictSerializeSSRState,
|
|
2450
|
+
__fictSerializeSSRStateForScopes,
|
|
2352
2451
|
__fictSetSSRState,
|
|
2452
|
+
__fictMergeSSRState,
|
|
2353
2453
|
__fictGetSSRScope,
|
|
2354
2454
|
__fictEnsureScope,
|
|
2355
2455
|
__fictUseLexicalScope,
|
|
@@ -2360,4 +2460,4 @@ export {
|
|
|
2360
2460
|
serializeValue,
|
|
2361
2461
|
deserializeValue
|
|
2362
2462
|
};
|
|
2363
|
-
//# sourceMappingURL=chunk-
|
|
2463
|
+
//# sourceMappingURL=chunk-LRFMCJY3.js.map
|