@fictjs/runtime 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.cjs +10 -8
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +4 -3
- package/dist/advanced.d.ts +4 -3
- package/dist/advanced.js +10 -8
- package/dist/advanced.js.map +1 -1
- package/dist/{chunk-TWELIZRY.js → chunk-5AA7HP4S.js} +5 -3
- package/dist/{chunk-TWELIZRY.js.map → chunk-5AA7HP4S.js.map} +1 -1
- package/dist/chunk-6SOPF5LZ.cjs +2363 -0
- package/dist/chunk-6SOPF5LZ.cjs.map +1 -0
- package/dist/{chunk-SO6X7G5S.js → chunk-BQG7VEBY.js} +501 -1880
- package/dist/chunk-BQG7VEBY.js.map +1 -0
- package/dist/chunk-FKDMDAUR.js +2363 -0
- package/dist/chunk-FKDMDAUR.js.map +1 -0
- package/dist/{chunk-L4DIV3RC.cjs → chunk-GHUV2FLD.cjs} +9 -7
- package/dist/chunk-GHUV2FLD.cjs.map +1 -0
- package/dist/{chunk-XLIZJMMJ.js → chunk-KKKYW54Z.js} +8 -6
- package/dist/{chunk-XLIZJMMJ.js.map → chunk-KKKYW54Z.js.map} +1 -1
- package/dist/{chunk-M2TSXZ4C.cjs → chunk-KYLNC4CD.cjs} +18 -16
- package/dist/chunk-KYLNC4CD.cjs.map +1 -0
- package/dist/chunk-TKWN42TA.cjs +2259 -0
- package/dist/chunk-TKWN42TA.cjs.map +1 -0
- package/dist/{context-B25xyQrJ.d.cts → context-CTBE00S_.d.cts} +1 -1
- package/dist/{context-CGdP7_Jb.d.ts → context-lkLhbkFJ.d.ts} +1 -1
- package/dist/{effect-D6kaLM2-.d.cts → effect-BpSNEJJz.d.cts} +7 -67
- package/dist/{effect-D6kaLM2-.d.ts → effect-BpSNEJJz.d.ts} +7 -67
- package/dist/index.cjs +40 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.dev.js +92 -4
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +189 -202
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +13 -23
- package/dist/internal.d.ts +13 -23
- package/dist/internal.js +195 -208
- package/dist/internal.js.map +1 -1
- package/dist/loader.cjs +280 -0
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.cts +57 -0
- package/dist/loader.d.ts +57 -0
- package/dist/loader.js +280 -0
- package/dist/loader.js.map +1 -0
- package/dist/{props-BIfromL0.d.cts → props-XTHYD19o.d.cts} +13 -2
- package/dist/{props-BEgIVMRx.d.ts → props-x-HbI-jX.d.ts} +13 -2
- package/dist/resume-BrAkmSTY.d.cts +79 -0
- package/dist/resume-Dx8_l72o.d.ts +79 -0
- package/dist/{scope-CzNkn587.d.ts → scope-CdbGmsFf.d.ts} +1 -1
- package/dist/{scope-Cx_3CjIZ.d.cts → scope-DfcP9I-A.d.cts} +1 -1
- package/dist/signal-C4ISF17w.d.cts +66 -0
- package/dist/signal-C4ISF17w.d.ts +66 -0
- package/package.json +6 -1
- package/src/binding.ts +254 -5
- package/src/dom.ts +103 -5
- package/src/hooks.ts +15 -2
- package/src/hydration.ts +75 -0
- package/src/internal.ts +34 -2
- package/src/list-helpers.ts +113 -12
- package/src/loader.ts +437 -0
- package/src/node-ops.ts +65 -0
- package/src/resume.ts +517 -0
- package/src/store.ts +8 -0
- package/dist/chunk-ID3WBWNO.cjs +0 -3638
- package/dist/chunk-ID3WBWNO.cjs.map +0 -1
- package/dist/chunk-L4DIV3RC.cjs.map +0 -1
- package/dist/chunk-M2TSXZ4C.cjs.map +0 -1
- package/dist/chunk-SO6X7G5S.js.map +0 -1
|
@@ -0,0 +1,2363 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/delegated-events.ts
|
|
2
|
+
var DelegatedEventNames = [
|
|
3
|
+
"beforeinput",
|
|
4
|
+
"click",
|
|
5
|
+
"dblclick",
|
|
6
|
+
"contextmenu",
|
|
7
|
+
"focusin",
|
|
8
|
+
"focusout",
|
|
9
|
+
"input",
|
|
10
|
+
"keydown",
|
|
11
|
+
"keyup",
|
|
12
|
+
"mousedown",
|
|
13
|
+
"mousemove",
|
|
14
|
+
"mouseout",
|
|
15
|
+
"mouseover",
|
|
16
|
+
"mouseup",
|
|
17
|
+
"pointerdown",
|
|
18
|
+
"pointermove",
|
|
19
|
+
"pointerout",
|
|
20
|
+
"pointerover",
|
|
21
|
+
"pointerup",
|
|
22
|
+
"touchend",
|
|
23
|
+
"touchmove",
|
|
24
|
+
"touchstart"
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
// src/constants.ts
|
|
28
|
+
var isDev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _ => _.env, 'optionalAccess', _2 => _2.NODE_ENV]) !== "production";
|
|
29
|
+
var booleans = isDev ? [
|
|
30
|
+
"allowfullscreen",
|
|
31
|
+
"async",
|
|
32
|
+
"alpha",
|
|
33
|
+
// HTMLInputElement
|
|
34
|
+
"autofocus",
|
|
35
|
+
// HTMLElement prop
|
|
36
|
+
"autoplay",
|
|
37
|
+
"checked",
|
|
38
|
+
"controls",
|
|
39
|
+
"default",
|
|
40
|
+
"disabled",
|
|
41
|
+
"formnovalidate",
|
|
42
|
+
"hidden",
|
|
43
|
+
// HTMLElement prop
|
|
44
|
+
"indeterminate",
|
|
45
|
+
"inert",
|
|
46
|
+
// HTMLElement prop
|
|
47
|
+
"ismap",
|
|
48
|
+
"loop",
|
|
49
|
+
"multiple",
|
|
50
|
+
"muted",
|
|
51
|
+
"nomodule",
|
|
52
|
+
"novalidate",
|
|
53
|
+
"open",
|
|
54
|
+
"playsinline",
|
|
55
|
+
"readonly",
|
|
56
|
+
"required",
|
|
57
|
+
"reversed",
|
|
58
|
+
"seamless",
|
|
59
|
+
// HTMLIframeElement - non-standard
|
|
60
|
+
"selected",
|
|
61
|
+
// Experimental attributes
|
|
62
|
+
"adauctionheaders",
|
|
63
|
+
"browsingtopics",
|
|
64
|
+
"credentialless",
|
|
65
|
+
"defaultchecked",
|
|
66
|
+
"defaultmuted",
|
|
67
|
+
"defaultselected",
|
|
68
|
+
"defer",
|
|
69
|
+
"disablepictureinpicture",
|
|
70
|
+
"disableremoteplayback",
|
|
71
|
+
"preservespitch",
|
|
72
|
+
"shadowrootclonable",
|
|
73
|
+
"shadowrootcustomelementregistry",
|
|
74
|
+
"shadowrootdelegatesfocus",
|
|
75
|
+
"shadowrootserializable",
|
|
76
|
+
"sharedstoragewritable"
|
|
77
|
+
] : [];
|
|
78
|
+
var BooleanAttributes = new Set(booleans);
|
|
79
|
+
var properties = isDev ? [
|
|
80
|
+
// Core properties
|
|
81
|
+
"className",
|
|
82
|
+
"value",
|
|
83
|
+
// CamelCase booleans
|
|
84
|
+
"readOnly",
|
|
85
|
+
"noValidate",
|
|
86
|
+
"formNoValidate",
|
|
87
|
+
"isMap",
|
|
88
|
+
"noModule",
|
|
89
|
+
"playsInline",
|
|
90
|
+
// Experimental (camelCase)
|
|
91
|
+
"adAuctionHeaders",
|
|
92
|
+
"allowFullscreen",
|
|
93
|
+
"browsingTopics",
|
|
94
|
+
"defaultChecked",
|
|
95
|
+
"defaultMuted",
|
|
96
|
+
"defaultSelected",
|
|
97
|
+
"disablePictureInPicture",
|
|
98
|
+
"disableRemotePlayback",
|
|
99
|
+
"preservesPitch",
|
|
100
|
+
"shadowRootClonable",
|
|
101
|
+
"shadowRootCustomElementRegistry",
|
|
102
|
+
"shadowRootDelegatesFocus",
|
|
103
|
+
"shadowRootSerializable",
|
|
104
|
+
"sharedStorageWritable",
|
|
105
|
+
// All lowercase booleans
|
|
106
|
+
...booleans
|
|
107
|
+
] : [];
|
|
108
|
+
var Properties = new Set(properties);
|
|
109
|
+
var ChildProperties = /* @__PURE__ */ new Set([
|
|
110
|
+
"innerHTML",
|
|
111
|
+
"textContent",
|
|
112
|
+
"innerText",
|
|
113
|
+
"children"
|
|
114
|
+
]);
|
|
115
|
+
var Aliases = {
|
|
116
|
+
className: "class",
|
|
117
|
+
htmlFor: "for"
|
|
118
|
+
};
|
|
119
|
+
var PropAliases = isDev ? {
|
|
120
|
+
// Direct mapping
|
|
121
|
+
class: "className",
|
|
122
|
+
// Element-specific mappings
|
|
123
|
+
novalidate: {
|
|
124
|
+
$: "noValidate",
|
|
125
|
+
FORM: 1
|
|
126
|
+
},
|
|
127
|
+
formnovalidate: {
|
|
128
|
+
$: "formNoValidate",
|
|
129
|
+
BUTTON: 1,
|
|
130
|
+
INPUT: 1
|
|
131
|
+
},
|
|
132
|
+
ismap: {
|
|
133
|
+
$: "isMap",
|
|
134
|
+
IMG: 1
|
|
135
|
+
},
|
|
136
|
+
nomodule: {
|
|
137
|
+
$: "noModule",
|
|
138
|
+
SCRIPT: 1
|
|
139
|
+
},
|
|
140
|
+
playsinline: {
|
|
141
|
+
$: "playsInline",
|
|
142
|
+
VIDEO: 1
|
|
143
|
+
},
|
|
144
|
+
readonly: {
|
|
145
|
+
$: "readOnly",
|
|
146
|
+
INPUT: 1,
|
|
147
|
+
TEXTAREA: 1
|
|
148
|
+
},
|
|
149
|
+
// Experimental element-specific
|
|
150
|
+
adauctionheaders: {
|
|
151
|
+
$: "adAuctionHeaders",
|
|
152
|
+
IFRAME: 1
|
|
153
|
+
},
|
|
154
|
+
allowfullscreen: {
|
|
155
|
+
$: "allowFullscreen",
|
|
156
|
+
IFRAME: 1
|
|
157
|
+
},
|
|
158
|
+
browsingtopics: {
|
|
159
|
+
$: "browsingTopics",
|
|
160
|
+
IMG: 1
|
|
161
|
+
},
|
|
162
|
+
defaultchecked: {
|
|
163
|
+
$: "defaultChecked",
|
|
164
|
+
INPUT: 1
|
|
165
|
+
},
|
|
166
|
+
defaultmuted: {
|
|
167
|
+
$: "defaultMuted",
|
|
168
|
+
AUDIO: 1,
|
|
169
|
+
VIDEO: 1
|
|
170
|
+
},
|
|
171
|
+
defaultselected: {
|
|
172
|
+
$: "defaultSelected",
|
|
173
|
+
OPTION: 1
|
|
174
|
+
},
|
|
175
|
+
disablepictureinpicture: {
|
|
176
|
+
$: "disablePictureInPicture",
|
|
177
|
+
VIDEO: 1
|
|
178
|
+
},
|
|
179
|
+
disableremoteplayback: {
|
|
180
|
+
$: "disableRemotePlayback",
|
|
181
|
+
AUDIO: 1,
|
|
182
|
+
VIDEO: 1
|
|
183
|
+
},
|
|
184
|
+
preservespitch: {
|
|
185
|
+
$: "preservesPitch",
|
|
186
|
+
AUDIO: 1,
|
|
187
|
+
VIDEO: 1
|
|
188
|
+
},
|
|
189
|
+
shadowrootclonable: {
|
|
190
|
+
$: "shadowRootClonable",
|
|
191
|
+
TEMPLATE: 1
|
|
192
|
+
},
|
|
193
|
+
shadowrootdelegatesfocus: {
|
|
194
|
+
$: "shadowRootDelegatesFocus",
|
|
195
|
+
TEMPLATE: 1
|
|
196
|
+
},
|
|
197
|
+
shadowrootserializable: {
|
|
198
|
+
$: "shadowRootSerializable",
|
|
199
|
+
TEMPLATE: 1
|
|
200
|
+
},
|
|
201
|
+
sharedstoragewritable: {
|
|
202
|
+
$: "sharedStorageWritable",
|
|
203
|
+
IFRAME: 1,
|
|
204
|
+
IMG: 1
|
|
205
|
+
}
|
|
206
|
+
} : {};
|
|
207
|
+
function getPropAlias(prop, tagName) {
|
|
208
|
+
if (!isDev) return void 0;
|
|
209
|
+
const a = PropAliases[prop];
|
|
210
|
+
if (typeof a === "object") {
|
|
211
|
+
return a[tagName] ? a["$"] : void 0;
|
|
212
|
+
}
|
|
213
|
+
return a;
|
|
214
|
+
}
|
|
215
|
+
var $$EVENTS = "_$FICT_DELEGATE";
|
|
216
|
+
var DelegatedEvents = new Set(DelegatedEventNames);
|
|
217
|
+
var svgElements = isDev ? [
|
|
218
|
+
"altGlyph",
|
|
219
|
+
"altGlyphDef",
|
|
220
|
+
"altGlyphItem",
|
|
221
|
+
"animate",
|
|
222
|
+
"animateColor",
|
|
223
|
+
"animateMotion",
|
|
224
|
+
"animateTransform",
|
|
225
|
+
"circle",
|
|
226
|
+
"clipPath",
|
|
227
|
+
"color-profile",
|
|
228
|
+
"cursor",
|
|
229
|
+
"defs",
|
|
230
|
+
"desc",
|
|
231
|
+
"ellipse",
|
|
232
|
+
"feBlend",
|
|
233
|
+
"feColorMatrix",
|
|
234
|
+
"feComponentTransfer",
|
|
235
|
+
"feComposite",
|
|
236
|
+
"feConvolveMatrix",
|
|
237
|
+
"feDiffuseLighting",
|
|
238
|
+
"feDisplacementMap",
|
|
239
|
+
"feDistantLight",
|
|
240
|
+
"feDropShadow",
|
|
241
|
+
"feFlood",
|
|
242
|
+
"feFuncA",
|
|
243
|
+
"feFuncB",
|
|
244
|
+
"feFuncG",
|
|
245
|
+
"feFuncR",
|
|
246
|
+
"feGaussianBlur",
|
|
247
|
+
"feImage",
|
|
248
|
+
"feMerge",
|
|
249
|
+
"feMergeNode",
|
|
250
|
+
"feMorphology",
|
|
251
|
+
"feOffset",
|
|
252
|
+
"fePointLight",
|
|
253
|
+
"feSpecularLighting",
|
|
254
|
+
"feSpotLight",
|
|
255
|
+
"feTile",
|
|
256
|
+
"feTurbulence",
|
|
257
|
+
"filter",
|
|
258
|
+
"font",
|
|
259
|
+
"font-face",
|
|
260
|
+
"font-face-format",
|
|
261
|
+
"font-face-name",
|
|
262
|
+
"font-face-src",
|
|
263
|
+
"font-face-uri",
|
|
264
|
+
"foreignObject",
|
|
265
|
+
"g",
|
|
266
|
+
"glyph",
|
|
267
|
+
"glyphRef",
|
|
268
|
+
"hkern",
|
|
269
|
+
"image",
|
|
270
|
+
"line",
|
|
271
|
+
"linearGradient",
|
|
272
|
+
"marker",
|
|
273
|
+
"mask",
|
|
274
|
+
"metadata",
|
|
275
|
+
"missing-glyph",
|
|
276
|
+
"mpath",
|
|
277
|
+
"path",
|
|
278
|
+
"pattern",
|
|
279
|
+
"polygon",
|
|
280
|
+
"polyline",
|
|
281
|
+
"radialGradient",
|
|
282
|
+
"rect",
|
|
283
|
+
"set",
|
|
284
|
+
"stop",
|
|
285
|
+
"svg",
|
|
286
|
+
"switch",
|
|
287
|
+
"symbol",
|
|
288
|
+
"text",
|
|
289
|
+
"textPath",
|
|
290
|
+
"tref",
|
|
291
|
+
"tspan",
|
|
292
|
+
"use",
|
|
293
|
+
"view",
|
|
294
|
+
"vkern"
|
|
295
|
+
] : [];
|
|
296
|
+
var SVGElements = new Set(svgElements);
|
|
297
|
+
var SVGNamespace = {
|
|
298
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
299
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
300
|
+
};
|
|
301
|
+
var unitlessList = isDev ? [
|
|
302
|
+
"animationIterationCount",
|
|
303
|
+
"animation-iteration-count",
|
|
304
|
+
"borderImageOutset",
|
|
305
|
+
"border-image-outset",
|
|
306
|
+
"borderImageSlice",
|
|
307
|
+
"border-image-slice",
|
|
308
|
+
"borderImageWidth",
|
|
309
|
+
"border-image-width",
|
|
310
|
+
"boxFlex",
|
|
311
|
+
"box-flex",
|
|
312
|
+
"boxFlexGroup",
|
|
313
|
+
"box-flex-group",
|
|
314
|
+
"boxOrdinalGroup",
|
|
315
|
+
"box-ordinal-group",
|
|
316
|
+
"columnCount",
|
|
317
|
+
"column-count",
|
|
318
|
+
"columns",
|
|
319
|
+
"flex",
|
|
320
|
+
"flexGrow",
|
|
321
|
+
"flex-grow",
|
|
322
|
+
"flexPositive",
|
|
323
|
+
"flex-positive",
|
|
324
|
+
"flexShrink",
|
|
325
|
+
"flex-shrink",
|
|
326
|
+
"flexNegative",
|
|
327
|
+
"flex-negative",
|
|
328
|
+
"flexOrder",
|
|
329
|
+
"flex-order",
|
|
330
|
+
"gridRow",
|
|
331
|
+
"grid-row",
|
|
332
|
+
"gridRowEnd",
|
|
333
|
+
"grid-row-end",
|
|
334
|
+
"gridRowSpan",
|
|
335
|
+
"grid-row-span",
|
|
336
|
+
"gridRowStart",
|
|
337
|
+
"grid-row-start",
|
|
338
|
+
"gridColumn",
|
|
339
|
+
"grid-column",
|
|
340
|
+
"gridColumnEnd",
|
|
341
|
+
"grid-column-end",
|
|
342
|
+
"gridColumnSpan",
|
|
343
|
+
"grid-column-span",
|
|
344
|
+
"gridColumnStart",
|
|
345
|
+
"grid-column-start",
|
|
346
|
+
"fontWeight",
|
|
347
|
+
"font-weight",
|
|
348
|
+
"lineClamp",
|
|
349
|
+
"line-clamp",
|
|
350
|
+
"lineHeight",
|
|
351
|
+
"line-height",
|
|
352
|
+
"opacity",
|
|
353
|
+
"order",
|
|
354
|
+
"orphans",
|
|
355
|
+
"tabSize",
|
|
356
|
+
"tab-size",
|
|
357
|
+
"widows",
|
|
358
|
+
"zIndex",
|
|
359
|
+
"z-index",
|
|
360
|
+
"zoom",
|
|
361
|
+
"fillOpacity",
|
|
362
|
+
"fill-opacity",
|
|
363
|
+
"floodOpacity",
|
|
364
|
+
"flood-opacity",
|
|
365
|
+
"stopOpacity",
|
|
366
|
+
"stop-opacity",
|
|
367
|
+
"strokeDasharray",
|
|
368
|
+
"stroke-dasharray",
|
|
369
|
+
"strokeDashoffset",
|
|
370
|
+
"stroke-dashoffset",
|
|
371
|
+
"strokeMiterlimit",
|
|
372
|
+
"stroke-miterlimit",
|
|
373
|
+
"strokeOpacity",
|
|
374
|
+
"stroke-opacity",
|
|
375
|
+
"strokeWidth",
|
|
376
|
+
"stroke-width"
|
|
377
|
+
] : ["opacity", "zIndex"];
|
|
378
|
+
var UnitlessStyles = new Set(unitlessList);
|
|
379
|
+
|
|
380
|
+
// src/devtools.ts
|
|
381
|
+
function getGlobalHook() {
|
|
382
|
+
if (typeof globalThis === "undefined") return void 0;
|
|
383
|
+
return globalThis.__FICT_DEVTOOLS_HOOK__;
|
|
384
|
+
}
|
|
385
|
+
function getDevtoolsHook() {
|
|
386
|
+
return getGlobalHook();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/cycle-guard.ts
|
|
390
|
+
var isDev2 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _3 => _3.env, 'optionalAccess', _4 => _4.NODE_ENV]) !== "production";
|
|
391
|
+
var setCycleProtectionOptions = () => {
|
|
392
|
+
};
|
|
393
|
+
var resetCycleProtectionStateForTests = () => {
|
|
394
|
+
};
|
|
395
|
+
var beginFlushGuard = () => {
|
|
396
|
+
};
|
|
397
|
+
var beforeEffectRunGuard = () => true;
|
|
398
|
+
var endFlushGuard = () => {
|
|
399
|
+
};
|
|
400
|
+
var enterRootGuard = () => true;
|
|
401
|
+
var exitRootGuard = () => {
|
|
402
|
+
};
|
|
403
|
+
var defaultOptions = {
|
|
404
|
+
enabled: true,
|
|
405
|
+
maxFlushCyclesPerMicrotask: 1e4,
|
|
406
|
+
maxEffectRunsPerFlush: 2e4,
|
|
407
|
+
windowSize: 5,
|
|
408
|
+
highUsageRatio: 0.8,
|
|
409
|
+
maxRootReentrantDepth: 10,
|
|
410
|
+
enableWindowWarning: true,
|
|
411
|
+
devMode: isDev2,
|
|
412
|
+
// Backoff warning options
|
|
413
|
+
enableBackoffWarning: isDev2,
|
|
414
|
+
backoffWarningRatio: 0.5
|
|
415
|
+
};
|
|
416
|
+
var enabled = defaultOptions.enabled;
|
|
417
|
+
var options = {
|
|
418
|
+
...defaultOptions
|
|
419
|
+
};
|
|
420
|
+
var effectRunsThisFlush = 0;
|
|
421
|
+
var windowUsage = [];
|
|
422
|
+
var rootDepth = /* @__PURE__ */ new WeakMap();
|
|
423
|
+
var flushWarned = false;
|
|
424
|
+
var rootWarned = false;
|
|
425
|
+
var windowWarned = false;
|
|
426
|
+
var backoffWarned50 = false;
|
|
427
|
+
var backoffWarned75 = false;
|
|
428
|
+
setCycleProtectionOptions = exports.setCycleProtectionOptions = (opts) => {
|
|
429
|
+
if (typeof opts.enabled === "boolean") {
|
|
430
|
+
enabled = opts.enabled;
|
|
431
|
+
}
|
|
432
|
+
options = { ...options, ...opts };
|
|
433
|
+
};
|
|
434
|
+
resetCycleProtectionStateForTests = () => {
|
|
435
|
+
options = { ...defaultOptions };
|
|
436
|
+
enabled = defaultOptions.enabled;
|
|
437
|
+
effectRunsThisFlush = 0;
|
|
438
|
+
windowUsage = [];
|
|
439
|
+
rootDepth = /* @__PURE__ */ new WeakMap();
|
|
440
|
+
flushWarned = false;
|
|
441
|
+
rootWarned = false;
|
|
442
|
+
windowWarned = false;
|
|
443
|
+
backoffWarned50 = false;
|
|
444
|
+
backoffWarned75 = false;
|
|
445
|
+
};
|
|
446
|
+
beginFlushGuard = () => {
|
|
447
|
+
if (!enabled) return;
|
|
448
|
+
effectRunsThisFlush = 0;
|
|
449
|
+
flushWarned = false;
|
|
450
|
+
windowWarned = false;
|
|
451
|
+
backoffWarned50 = false;
|
|
452
|
+
backoffWarned75 = false;
|
|
453
|
+
};
|
|
454
|
+
beforeEffectRunGuard = () => {
|
|
455
|
+
if (!enabled) return true;
|
|
456
|
+
const next = ++effectRunsThisFlush;
|
|
457
|
+
const limit = Math.min(options.maxFlushCyclesPerMicrotask, options.maxEffectRunsPerFlush);
|
|
458
|
+
if (options.enableBackoffWarning && isDev2) {
|
|
459
|
+
const ratio = next / limit;
|
|
460
|
+
const backoffRatio = _nullishCoalesce(options.backoffWarningRatio, () => ( 0.5));
|
|
461
|
+
if (!backoffWarned50 && ratio >= backoffRatio && ratio < backoffRatio + 0.25) {
|
|
462
|
+
backoffWarned50 = true;
|
|
463
|
+
console.warn(
|
|
464
|
+
`[fict] cycle guard: approaching effect limit (${Math.round(ratio * 100)}% of budget used)
|
|
465
|
+
- Current: ${next} effects, Limit: ${limit}
|
|
466
|
+
- Tip: Check for effects that trigger other effects in a loop.
|
|
467
|
+
- Common causes: signal updates inside effects that read and write the same signal.`
|
|
468
|
+
);
|
|
469
|
+
} else if (!backoffWarned75 && ratio >= backoffRatio + 0.25 && ratio < 1) {
|
|
470
|
+
backoffWarned75 = true;
|
|
471
|
+
console.warn(
|
|
472
|
+
`[fict] cycle guard: nearing effect limit (${Math.round(ratio * 100)}% of budget used)
|
|
473
|
+
- Current: ${next} effects, Limit: ${limit}
|
|
474
|
+
- Warning: Consider breaking the reactive dependency cycle.
|
|
475
|
+
- Debug: Use browser devtools to identify the recursive effect chain.`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (next > limit) {
|
|
480
|
+
const message = `[fict] cycle protection triggered: flush-budget-exceeded`;
|
|
481
|
+
if (options.devMode) {
|
|
482
|
+
throw new Error(
|
|
483
|
+
message + `
|
|
484
|
+
- Effect runs: ${next}, Limit: ${limit}
|
|
485
|
+
- This indicates a reactive cycle where effects keep triggering each other.
|
|
486
|
+
- Check for patterns like: createEffect(() => { signal(); signal(newValue); })`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
if (!flushWarned) {
|
|
490
|
+
flushWarned = true;
|
|
491
|
+
console.warn(message, { effectRuns: next, limit });
|
|
492
|
+
}
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
return true;
|
|
496
|
+
};
|
|
497
|
+
endFlushGuard = () => {
|
|
498
|
+
if (!enabled) return;
|
|
499
|
+
recordWindowUsage(effectRunsThisFlush, options.maxFlushCyclesPerMicrotask);
|
|
500
|
+
effectRunsThisFlush = 0;
|
|
501
|
+
};
|
|
502
|
+
enterRootGuard = (root) => {
|
|
503
|
+
if (!enabled) return true;
|
|
504
|
+
const depth = (_nullishCoalesce(rootDepth.get(root), () => ( 0))) + 1;
|
|
505
|
+
if (depth > options.maxRootReentrantDepth) {
|
|
506
|
+
const message = `[fict] cycle protection triggered: root-reentry`;
|
|
507
|
+
if (options.devMode) {
|
|
508
|
+
throw new Error(
|
|
509
|
+
message + `
|
|
510
|
+
- Re-entry depth: ${depth}, Max allowed: ${options.maxRootReentrantDepth}
|
|
511
|
+
- This indicates recursive render() or component initialization.
|
|
512
|
+
- Check for components that trigger re-renders during their own render phase.`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
if (!rootWarned) {
|
|
516
|
+
rootWarned = true;
|
|
517
|
+
console.warn(message, { depth, maxAllowed: options.maxRootReentrantDepth });
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
rootDepth.set(root, depth);
|
|
522
|
+
return true;
|
|
523
|
+
};
|
|
524
|
+
exitRootGuard = (root) => {
|
|
525
|
+
if (!enabled) return;
|
|
526
|
+
const depth = rootDepth.get(root);
|
|
527
|
+
if (depth === void 0) return;
|
|
528
|
+
if (depth <= 1) {
|
|
529
|
+
rootDepth.delete(root);
|
|
530
|
+
} else {
|
|
531
|
+
rootDepth.set(root, depth - 1);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
var recordWindowUsage = (used, budget) => {
|
|
535
|
+
if (!options.enableWindowWarning) return;
|
|
536
|
+
const entry = { used, budget };
|
|
537
|
+
windowUsage.push(entry);
|
|
538
|
+
if (windowUsage.length > options.windowSize) {
|
|
539
|
+
windowUsage.shift();
|
|
540
|
+
}
|
|
541
|
+
if (windowWarned) return;
|
|
542
|
+
if (windowUsage.length >= options.windowSize && windowUsage.every((item) => item.budget > 0 && item.used / item.budget >= options.highUsageRatio)) {
|
|
543
|
+
windowWarned = true;
|
|
544
|
+
reportCycle("high-usage-window", {
|
|
545
|
+
windowSize: options.windowSize,
|
|
546
|
+
ratio: options.highUsageRatio
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
var reportCycle = (reason, detail = void 0) => {
|
|
551
|
+
const hook = getDevtoolsHook();
|
|
552
|
+
_optionalChain([hook, 'optionalAccess', _5 => _5.cycleDetected, 'optionalCall', _6 => _6(detail ? { reason, detail } : { reason })]);
|
|
553
|
+
console.warn(`[fict] cycle protection triggered: ${reason}`, _nullishCoalesce(detail, () => ( "")));
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/lifecycle.ts
|
|
557
|
+
var isDev3 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _7 => _7.env, 'optionalAccess', _8 => _8.NODE_ENV]) !== "production";
|
|
558
|
+
var currentRoot;
|
|
559
|
+
var currentEffectCleanups;
|
|
560
|
+
var globalErrorHandlers = /* @__PURE__ */ new WeakMap();
|
|
561
|
+
var globalSuspenseHandlers = /* @__PURE__ */ new WeakMap();
|
|
562
|
+
function createRootContext(parent) {
|
|
563
|
+
return { parent, cleanups: [], destroyCallbacks: [], suspended: false };
|
|
564
|
+
}
|
|
565
|
+
function pushRoot(root) {
|
|
566
|
+
if (!enterRootGuard(root)) {
|
|
567
|
+
return currentRoot;
|
|
568
|
+
}
|
|
569
|
+
const prev = currentRoot;
|
|
570
|
+
currentRoot = root;
|
|
571
|
+
return prev;
|
|
572
|
+
}
|
|
573
|
+
function getCurrentRoot() {
|
|
574
|
+
return currentRoot;
|
|
575
|
+
}
|
|
576
|
+
function popRoot(prev) {
|
|
577
|
+
if (currentRoot) {
|
|
578
|
+
exitRootGuard(currentRoot);
|
|
579
|
+
}
|
|
580
|
+
currentRoot = prev;
|
|
581
|
+
}
|
|
582
|
+
function onMount(fn) {
|
|
583
|
+
if (currentRoot) {
|
|
584
|
+
;
|
|
585
|
+
(currentRoot.onMountCallbacks || (currentRoot.onMountCallbacks = [])).push(fn);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
runLifecycle(fn);
|
|
589
|
+
}
|
|
590
|
+
function onDestroy(fn) {
|
|
591
|
+
if (currentRoot) {
|
|
592
|
+
currentRoot.destroyCallbacks.push(() => runLifecycle(fn));
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
runLifecycle(fn);
|
|
596
|
+
}
|
|
597
|
+
function onCleanup(fn) {
|
|
598
|
+
registerEffectCleanup(fn);
|
|
599
|
+
}
|
|
600
|
+
function flushOnMount(root) {
|
|
601
|
+
const cbs = root.onMountCallbacks;
|
|
602
|
+
if (!cbs || cbs.length === 0) return;
|
|
603
|
+
const prevRoot = currentRoot;
|
|
604
|
+
currentRoot = root;
|
|
605
|
+
try {
|
|
606
|
+
for (let i = 0; i < cbs.length; i++) {
|
|
607
|
+
const cleanup = cbs[i]();
|
|
608
|
+
if (typeof cleanup === "function") {
|
|
609
|
+
root.cleanups.push(cleanup);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
} finally {
|
|
613
|
+
currentRoot = prevRoot;
|
|
614
|
+
cbs.length = 0;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function registerRootCleanup(fn) {
|
|
618
|
+
if (currentRoot) {
|
|
619
|
+
currentRoot.cleanups.push(fn);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function clearRoot(root) {
|
|
623
|
+
runCleanupList(root.cleanups);
|
|
624
|
+
if (root.onMountCallbacks) {
|
|
625
|
+
root.onMountCallbacks.length = 0;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
function destroyRoot(root) {
|
|
629
|
+
clearRoot(root);
|
|
630
|
+
runCleanupList(root.destroyCallbacks);
|
|
631
|
+
if (root.errorHandlers) {
|
|
632
|
+
root.errorHandlers.length = 0;
|
|
633
|
+
}
|
|
634
|
+
if (globalErrorHandlers.has(root)) {
|
|
635
|
+
globalErrorHandlers.delete(root);
|
|
636
|
+
}
|
|
637
|
+
if (root.suspenseHandlers) {
|
|
638
|
+
root.suspenseHandlers.length = 0;
|
|
639
|
+
}
|
|
640
|
+
if (globalSuspenseHandlers.has(root)) {
|
|
641
|
+
globalSuspenseHandlers.delete(root);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function createRoot(fn, options2) {
|
|
645
|
+
const parent = _optionalChain([options2, 'optionalAccess', _9 => _9.inherit]) ? currentRoot : void 0;
|
|
646
|
+
const root = createRootContext(parent);
|
|
647
|
+
const prev = pushRoot(root);
|
|
648
|
+
let value;
|
|
649
|
+
try {
|
|
650
|
+
value = fn();
|
|
651
|
+
} finally {
|
|
652
|
+
popRoot(prev);
|
|
653
|
+
}
|
|
654
|
+
flushOnMount(root);
|
|
655
|
+
return {
|
|
656
|
+
dispose: () => destroyRoot(root),
|
|
657
|
+
value
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
function withEffectCleanups(bucket, fn) {
|
|
661
|
+
const prev = currentEffectCleanups;
|
|
662
|
+
currentEffectCleanups = bucket;
|
|
663
|
+
try {
|
|
664
|
+
return fn();
|
|
665
|
+
} finally {
|
|
666
|
+
currentEffectCleanups = prev;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function registerEffectCleanup(fn) {
|
|
670
|
+
if (currentEffectCleanups) {
|
|
671
|
+
currentEffectCleanups.push(fn);
|
|
672
|
+
} else {
|
|
673
|
+
registerRootCleanup(fn);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
function runCleanupList(list) {
|
|
677
|
+
let error;
|
|
678
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
679
|
+
try {
|
|
680
|
+
const cleanup = list[i];
|
|
681
|
+
if (cleanup) cleanup();
|
|
682
|
+
} catch (err) {
|
|
683
|
+
if (error === void 0) {
|
|
684
|
+
error = err;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
list.length = 0;
|
|
689
|
+
if (error !== void 0) {
|
|
690
|
+
if (!handleError(error, { source: "cleanup" })) {
|
|
691
|
+
throw error;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function runLifecycle(fn) {
|
|
696
|
+
const cleanup = fn();
|
|
697
|
+
if (typeof cleanup === "function") {
|
|
698
|
+
cleanup();
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function registerErrorHandler(fn) {
|
|
702
|
+
if (!currentRoot) {
|
|
703
|
+
const message = isDev3 ? "registerErrorHandler must be called within a root" : "FICT:E_ROOT_HANDLER";
|
|
704
|
+
throw new Error(message);
|
|
705
|
+
}
|
|
706
|
+
if (!currentRoot.errorHandlers) {
|
|
707
|
+
currentRoot.errorHandlers = [];
|
|
708
|
+
}
|
|
709
|
+
currentRoot.errorHandlers.push(fn);
|
|
710
|
+
const existing = globalErrorHandlers.get(currentRoot);
|
|
711
|
+
if (existing) {
|
|
712
|
+
existing.push(fn);
|
|
713
|
+
} else {
|
|
714
|
+
globalErrorHandlers.set(currentRoot, [fn]);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function registerSuspenseHandler(fn) {
|
|
718
|
+
if (!currentRoot) {
|
|
719
|
+
const message = isDev3 ? "registerSuspenseHandler must be called within a root" : "FICT:E_ROOT_SUSPENSE";
|
|
720
|
+
throw new Error(message);
|
|
721
|
+
}
|
|
722
|
+
if (!currentRoot.suspenseHandlers) {
|
|
723
|
+
currentRoot.suspenseHandlers = [];
|
|
724
|
+
}
|
|
725
|
+
currentRoot.suspenseHandlers.push(fn);
|
|
726
|
+
const existing = globalSuspenseHandlers.get(currentRoot);
|
|
727
|
+
if (existing) {
|
|
728
|
+
existing.push(fn);
|
|
729
|
+
} else {
|
|
730
|
+
globalSuspenseHandlers.set(currentRoot, [fn]);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
function handleError(err, info, startRoot) {
|
|
734
|
+
let root = _nullishCoalesce(startRoot, () => ( currentRoot));
|
|
735
|
+
let error = err;
|
|
736
|
+
while (root) {
|
|
737
|
+
const handlers = root.errorHandlers;
|
|
738
|
+
if (handlers && handlers.length) {
|
|
739
|
+
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
740
|
+
const handler = handlers[i];
|
|
741
|
+
try {
|
|
742
|
+
const handled = handler(error, info);
|
|
743
|
+
if (handled !== false) {
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
} catch (nextErr) {
|
|
747
|
+
error = nextErr;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
root = root.parent;
|
|
752
|
+
}
|
|
753
|
+
const globalForRoot = startRoot ? globalErrorHandlers.get(startRoot) : currentRoot ? globalErrorHandlers.get(currentRoot) : void 0;
|
|
754
|
+
if (globalForRoot && globalForRoot.length) {
|
|
755
|
+
for (let i = globalForRoot.length - 1; i >= 0; i--) {
|
|
756
|
+
const handler = globalForRoot[i];
|
|
757
|
+
try {
|
|
758
|
+
const handled = handler(error, info);
|
|
759
|
+
if (handled !== false) {
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
} catch (nextErr) {
|
|
763
|
+
error = nextErr;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
function handleSuspend(token, startRoot) {
|
|
770
|
+
let root = _nullishCoalesce(startRoot, () => ( currentRoot));
|
|
771
|
+
const originRoot = root;
|
|
772
|
+
while (root) {
|
|
773
|
+
const handlers = root.suspenseHandlers;
|
|
774
|
+
if (handlers && handlers.length) {
|
|
775
|
+
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
776
|
+
const handler = handlers[i];
|
|
777
|
+
const handled = handler(token);
|
|
778
|
+
if (handled !== false) {
|
|
779
|
+
if (originRoot) originRoot.suspended = true;
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
root = root.parent;
|
|
785
|
+
}
|
|
786
|
+
const globalForRoot = startRoot && globalSuspenseHandlers.get(startRoot) ? globalSuspenseHandlers.get(startRoot) : currentRoot ? globalSuspenseHandlers.get(currentRoot) : void 0;
|
|
787
|
+
if (globalForRoot && globalForRoot.length) {
|
|
788
|
+
for (let i = globalForRoot.length - 1; i >= 0; i--) {
|
|
789
|
+
const handler = globalForRoot[i];
|
|
790
|
+
const handled = handler(token);
|
|
791
|
+
if (handled !== false) {
|
|
792
|
+
if (originRoot) originRoot.suspended = true;
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return false;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// src/effect.ts
|
|
801
|
+
function createEffect(fn) {
|
|
802
|
+
let cleanups = [];
|
|
803
|
+
const rootForError = getCurrentRoot();
|
|
804
|
+
const doCleanup = () => {
|
|
805
|
+
runCleanupList(cleanups);
|
|
806
|
+
cleanups = [];
|
|
807
|
+
};
|
|
808
|
+
const run = () => {
|
|
809
|
+
const bucket = [];
|
|
810
|
+
withEffectCleanups(bucket, () => {
|
|
811
|
+
try {
|
|
812
|
+
const maybeCleanup = fn();
|
|
813
|
+
if (typeof maybeCleanup === "function") {
|
|
814
|
+
bucket.push(maybeCleanup);
|
|
815
|
+
}
|
|
816
|
+
} catch (err) {
|
|
817
|
+
if (handleSuspend(err, rootForError)) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
if (handleError(err, { source: "effect" }, rootForError)) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
throw err;
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
cleanups = bucket;
|
|
827
|
+
};
|
|
828
|
+
const disposeEffect = effectWithCleanup(run, doCleanup, rootForError);
|
|
829
|
+
const teardown = () => {
|
|
830
|
+
runCleanupList(cleanups);
|
|
831
|
+
disposeEffect();
|
|
832
|
+
};
|
|
833
|
+
registerRootCleanup(teardown);
|
|
834
|
+
return teardown;
|
|
835
|
+
}
|
|
836
|
+
function createRenderEffect(fn) {
|
|
837
|
+
let cleanup;
|
|
838
|
+
const rootForError = getCurrentRoot();
|
|
839
|
+
const doCleanup = () => {
|
|
840
|
+
if (cleanup) {
|
|
841
|
+
cleanup();
|
|
842
|
+
cleanup = void 0;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
const run = () => {
|
|
846
|
+
try {
|
|
847
|
+
const maybeCleanup = fn();
|
|
848
|
+
if (typeof maybeCleanup === "function") {
|
|
849
|
+
cleanup = maybeCleanup;
|
|
850
|
+
}
|
|
851
|
+
} catch (err) {
|
|
852
|
+
if (handleSuspend(err, rootForError)) {
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const handled = handleError(err, { source: "effect" }, rootForError);
|
|
856
|
+
if (handled) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
throw err;
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
const disposeEffect = effectWithCleanup(run, doCleanup, rootForError);
|
|
863
|
+
const teardown = () => {
|
|
864
|
+
if (cleanup) {
|
|
865
|
+
cleanup();
|
|
866
|
+
cleanup = void 0;
|
|
867
|
+
}
|
|
868
|
+
disposeEffect();
|
|
869
|
+
};
|
|
870
|
+
registerRootCleanup(teardown);
|
|
871
|
+
return teardown;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// src/hooks.ts
|
|
875
|
+
var isDev4 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _10 => _10.env, 'optionalAccess', _11 => _11.NODE_ENV]) !== "production";
|
|
876
|
+
var ctxStack = [];
|
|
877
|
+
var preparedContext = null;
|
|
878
|
+
function assertRenderContext(ctx, hookName) {
|
|
879
|
+
if (!ctx.rendering) {
|
|
880
|
+
const message = isDev4 ? `${hookName} can only be used during render execution` : "FICT:E_HOOK_RENDER";
|
|
881
|
+
throw new Error(message);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
function __fictUseContext() {
|
|
885
|
+
if (ctxStack.length === 0) {
|
|
886
|
+
const message = isDev4 ? "Invalid hook call: hooks can only be used while rendering a component. Make sure you are not calling hooks in event handlers or outside of components." : "FICT:E_HOOK_OUTSIDE_RENDER";
|
|
887
|
+
throw new Error(message);
|
|
888
|
+
}
|
|
889
|
+
const ctx = ctxStack[ctxStack.length - 1];
|
|
890
|
+
if (!ctx.rendering) {
|
|
891
|
+
ctx.cursor = 0;
|
|
892
|
+
ctx.rendering = true;
|
|
893
|
+
}
|
|
894
|
+
return ctx;
|
|
895
|
+
}
|
|
896
|
+
function __fictPushContext() {
|
|
897
|
+
const ctx = _nullishCoalesce(preparedContext, () => ( { slots: [], cursor: 0 }));
|
|
898
|
+
preparedContext = null;
|
|
899
|
+
ctxStack.push(ctx);
|
|
900
|
+
return ctx;
|
|
901
|
+
}
|
|
902
|
+
function __fictPrepareContext(ctx) {
|
|
903
|
+
preparedContext = ctx;
|
|
904
|
+
}
|
|
905
|
+
function __fictGetCurrentComponentId() {
|
|
906
|
+
return _optionalChain([ctxStack, 'access', _12 => _12[ctxStack.length - 1], 'optionalAccess', _13 => _13.componentId]);
|
|
907
|
+
}
|
|
908
|
+
function __fictPopContext() {
|
|
909
|
+
const ctx = ctxStack.pop();
|
|
910
|
+
if (ctx) ctx.rendering = false;
|
|
911
|
+
}
|
|
912
|
+
function __fictResetContext() {
|
|
913
|
+
ctxStack.length = 0;
|
|
914
|
+
}
|
|
915
|
+
function __fictUseSignal(ctx, initial, optionsOrSlot, slot) {
|
|
916
|
+
assertRenderContext(ctx, "__fictUseSignal");
|
|
917
|
+
const options2 = typeof optionsOrSlot === "number" ? void 0 : optionsOrSlot;
|
|
918
|
+
const resolvedSlot = typeof optionsOrSlot === "number" ? optionsOrSlot : slot;
|
|
919
|
+
const index = _nullishCoalesce(resolvedSlot, () => ( ctx.cursor++));
|
|
920
|
+
if (!ctx.slots[index]) {
|
|
921
|
+
ctx.slots[index] = signal(initial, options2);
|
|
922
|
+
}
|
|
923
|
+
if (_optionalChain([options2, 'optionalAccess', _14 => _14.name])) {
|
|
924
|
+
if (!ctx.slotMap) ctx.slotMap = {};
|
|
925
|
+
ctx.slotMap[options2.name] = index;
|
|
926
|
+
}
|
|
927
|
+
return ctx.slots[index];
|
|
928
|
+
}
|
|
929
|
+
function __fictUseMemo(ctx, fn, optionsOrSlot, slot) {
|
|
930
|
+
assertRenderContext(ctx, "__fictUseMemo");
|
|
931
|
+
const options2 = typeof optionsOrSlot === "number" ? void 0 : optionsOrSlot;
|
|
932
|
+
const resolvedSlot = typeof optionsOrSlot === "number" ? optionsOrSlot : slot;
|
|
933
|
+
const index = _nullishCoalesce(resolvedSlot, () => ( ctx.cursor++));
|
|
934
|
+
if (!ctx.slots[index]) {
|
|
935
|
+
ctx.slots[index] = createMemo(fn, options2);
|
|
936
|
+
}
|
|
937
|
+
return ctx.slots[index];
|
|
938
|
+
}
|
|
939
|
+
function __fictUseEffect(ctx, fn, slot) {
|
|
940
|
+
if (slot !== void 0) {
|
|
941
|
+
if (ctx.slots[slot]) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
ctx.slots[slot] = createEffect(fn);
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
assertRenderContext(ctx, "__fictUseEffect");
|
|
948
|
+
const index = ctx.cursor++;
|
|
949
|
+
if (!ctx.slots[index]) {
|
|
950
|
+
ctx.slots[index] = createEffect(fn);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function __fictRender(ctx, fn) {
|
|
954
|
+
ctxStack.push(ctx);
|
|
955
|
+
ctx.cursor = 0;
|
|
956
|
+
ctx.rendering = true;
|
|
957
|
+
try {
|
|
958
|
+
return fn();
|
|
959
|
+
} finally {
|
|
960
|
+
ctx.rendering = false;
|
|
961
|
+
ctxStack.pop();
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// src/signal.ts
|
|
966
|
+
var isDev5 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _15 => _15.env, 'optionalAccess', _16 => _16.NODE_ENV]) !== "production";
|
|
967
|
+
var Mutable = 1;
|
|
968
|
+
var Watching = 2;
|
|
969
|
+
var Running = 4;
|
|
970
|
+
var Recursed = 8;
|
|
971
|
+
var Dirty = 16;
|
|
972
|
+
var Pending = 32;
|
|
973
|
+
var MutableDirty = 17;
|
|
974
|
+
var MutablePending = 33;
|
|
975
|
+
var MutableRunning = 5;
|
|
976
|
+
var WatchingRunning = 6;
|
|
977
|
+
var cycle = 0;
|
|
978
|
+
var batchDepth = 0;
|
|
979
|
+
var activeSub;
|
|
980
|
+
var flushScheduled = false;
|
|
981
|
+
var highPriorityQueue = [];
|
|
982
|
+
var lowPriorityQueue = [];
|
|
983
|
+
var isInTransition = false;
|
|
984
|
+
var enqueueMicrotask = typeof queueMicrotask === "function" ? queueMicrotask : (fn) => {
|
|
985
|
+
Promise.resolve().then(fn);
|
|
986
|
+
};
|
|
987
|
+
var inCleanup = false;
|
|
988
|
+
var SIGNAL_MARKER = Symbol.for("fict:signal");
|
|
989
|
+
var COMPUTED_MARKER = Symbol.for("fict:computed");
|
|
990
|
+
var EFFECT_MARKER = Symbol.for("fict:effect");
|
|
991
|
+
var EFFECT_SCOPE_MARKER = Symbol.for("fict:effectScope");
|
|
992
|
+
function link(dep, sub, version) {
|
|
993
|
+
const prevDep = sub.depsTail;
|
|
994
|
+
if (prevDep !== void 0 && prevDep.dep === dep) return;
|
|
995
|
+
const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
|
|
996
|
+
if (nextDep !== void 0 && nextDep.dep === dep) {
|
|
997
|
+
nextDep.version = version;
|
|
998
|
+
sub.depsTail = nextDep;
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
const prevSub = dep.subsTail;
|
|
1002
|
+
if (prevSub !== void 0 && prevSub.version === version && prevSub.sub === sub) return;
|
|
1003
|
+
const newLink = { version, dep, sub, prevDep, nextDep, prevSub, nextSub: void 0 };
|
|
1004
|
+
sub.depsTail = newLink;
|
|
1005
|
+
dep.subsTail = newLink;
|
|
1006
|
+
if (nextDep !== void 0) nextDep.prevDep = newLink;
|
|
1007
|
+
if (prevDep !== void 0) prevDep.nextDep = newLink;
|
|
1008
|
+
else sub.deps = newLink;
|
|
1009
|
+
if (prevSub !== void 0) prevSub.nextSub = newLink;
|
|
1010
|
+
else dep.subs = newLink;
|
|
1011
|
+
if (isDev5) trackDependencyDevtools(dep, sub);
|
|
1012
|
+
}
|
|
1013
|
+
function unlink(lnk, sub = lnk.sub) {
|
|
1014
|
+
const dep = lnk.dep;
|
|
1015
|
+
const prevDep = lnk.prevDep;
|
|
1016
|
+
const nextDep = lnk.nextDep;
|
|
1017
|
+
const nextSub = lnk.nextSub;
|
|
1018
|
+
const prevSub = lnk.prevSub;
|
|
1019
|
+
if (nextDep !== void 0) nextDep.prevDep = prevDep;
|
|
1020
|
+
else sub.depsTail = prevDep;
|
|
1021
|
+
if (prevDep !== void 0) prevDep.nextDep = nextDep;
|
|
1022
|
+
else sub.deps = nextDep;
|
|
1023
|
+
if (nextSub !== void 0) nextSub.prevSub = prevSub;
|
|
1024
|
+
else dep.subsTail = prevSub;
|
|
1025
|
+
if (prevSub !== void 0) prevSub.nextSub = nextSub;
|
|
1026
|
+
else if ((dep.subs = nextSub) === void 0) unwatched(dep);
|
|
1027
|
+
if (isDev5) untrackDependencyDevtools(dep, sub);
|
|
1028
|
+
return nextDep;
|
|
1029
|
+
}
|
|
1030
|
+
function unwatched(dep) {
|
|
1031
|
+
if (!(dep.flags & Mutable)) {
|
|
1032
|
+
disposeNode(dep);
|
|
1033
|
+
} else if ("getter" in dep && dep.getter !== void 0) {
|
|
1034
|
+
dep.depsTail = void 0;
|
|
1035
|
+
dep.flags = MutableDirty;
|
|
1036
|
+
purgeDeps(dep);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function propagate(firstLink) {
|
|
1040
|
+
let link2 = firstLink;
|
|
1041
|
+
let next = link2.nextSub;
|
|
1042
|
+
let stack;
|
|
1043
|
+
top: for (; ; ) {
|
|
1044
|
+
const sub = link2.sub;
|
|
1045
|
+
let flags = sub.flags;
|
|
1046
|
+
if (!(flags & 60)) {
|
|
1047
|
+
sub.flags = flags | Pending;
|
|
1048
|
+
} else if (!(flags & 12)) {
|
|
1049
|
+
flags = 0;
|
|
1050
|
+
} else if (!(flags & Running)) {
|
|
1051
|
+
sub.flags = flags & ~Recursed | Pending;
|
|
1052
|
+
} else if (!(flags & 48)) {
|
|
1053
|
+
let vlink = sub.depsTail;
|
|
1054
|
+
let valid = false;
|
|
1055
|
+
while (vlink !== void 0) {
|
|
1056
|
+
if (vlink === link2) {
|
|
1057
|
+
valid = true;
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
vlink = vlink.prevDep;
|
|
1061
|
+
}
|
|
1062
|
+
if (valid) {
|
|
1063
|
+
sub.flags = flags | 40;
|
|
1064
|
+
flags &= Mutable;
|
|
1065
|
+
} else {
|
|
1066
|
+
flags = 0;
|
|
1067
|
+
}
|
|
1068
|
+
} else {
|
|
1069
|
+
flags = 0;
|
|
1070
|
+
}
|
|
1071
|
+
if (flags & Watching) notify(sub);
|
|
1072
|
+
if (flags & Mutable) {
|
|
1073
|
+
const subSubs = sub.subs;
|
|
1074
|
+
if (subSubs !== void 0) {
|
|
1075
|
+
const nextSub = subSubs.nextSub;
|
|
1076
|
+
if (nextSub !== void 0) {
|
|
1077
|
+
stack = { value: next, prev: stack };
|
|
1078
|
+
next = nextSub;
|
|
1079
|
+
}
|
|
1080
|
+
link2 = subSubs;
|
|
1081
|
+
continue;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
if (next !== void 0) {
|
|
1085
|
+
link2 = next;
|
|
1086
|
+
next = link2.nextSub;
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
while (stack !== void 0) {
|
|
1090
|
+
link2 = stack.value;
|
|
1091
|
+
stack = stack.prev;
|
|
1092
|
+
if (link2 !== void 0) {
|
|
1093
|
+
next = link2.nextSub;
|
|
1094
|
+
continue top;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
function checkDirty(firstLink, sub) {
|
|
1101
|
+
let link2 = firstLink;
|
|
1102
|
+
let stack;
|
|
1103
|
+
let checkDepth = 0;
|
|
1104
|
+
let dirty = false;
|
|
1105
|
+
top: for (; ; ) {
|
|
1106
|
+
const dep = link2.dep;
|
|
1107
|
+
const depFlags = dep.flags;
|
|
1108
|
+
if (sub.flags & Dirty) {
|
|
1109
|
+
dirty = true;
|
|
1110
|
+
} else if ((depFlags & MutableDirty) === MutableDirty) {
|
|
1111
|
+
if (update(dep)) {
|
|
1112
|
+
const subs = dep.subs;
|
|
1113
|
+
if (subs !== void 0 && subs.nextSub !== void 0) shallowPropagate(subs);
|
|
1114
|
+
dirty = true;
|
|
1115
|
+
}
|
|
1116
|
+
} else if ((depFlags & MutablePending) === MutablePending) {
|
|
1117
|
+
if (!dep.deps) {
|
|
1118
|
+
const nextDep = link2.nextDep;
|
|
1119
|
+
if (nextDep !== void 0) {
|
|
1120
|
+
link2 = nextDep;
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
} else {
|
|
1124
|
+
if (link2.nextSub !== void 0 || link2.prevSub !== void 0) {
|
|
1125
|
+
stack = { value: link2, prev: stack };
|
|
1126
|
+
}
|
|
1127
|
+
link2 = dep.deps;
|
|
1128
|
+
sub = dep;
|
|
1129
|
+
++checkDepth;
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if (!dirty) {
|
|
1134
|
+
const nextDep = link2.nextDep;
|
|
1135
|
+
if (nextDep !== void 0) {
|
|
1136
|
+
link2 = nextDep;
|
|
1137
|
+
continue;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
while (checkDepth-- > 0) {
|
|
1141
|
+
const firstSub = sub.subs;
|
|
1142
|
+
const hasMultipleSubs = firstSub.nextSub !== void 0;
|
|
1143
|
+
if (hasMultipleSubs) {
|
|
1144
|
+
link2 = stack.value;
|
|
1145
|
+
stack = stack.prev;
|
|
1146
|
+
} else {
|
|
1147
|
+
link2 = firstSub;
|
|
1148
|
+
}
|
|
1149
|
+
if (dirty) {
|
|
1150
|
+
if (update(sub)) {
|
|
1151
|
+
if (hasMultipleSubs) shallowPropagate(firstSub);
|
|
1152
|
+
sub = link2.sub;
|
|
1153
|
+
continue;
|
|
1154
|
+
}
|
|
1155
|
+
dirty = false;
|
|
1156
|
+
} else {
|
|
1157
|
+
sub.flags &= ~Pending;
|
|
1158
|
+
}
|
|
1159
|
+
sub = link2.sub;
|
|
1160
|
+
const nextDep = link2.nextDep;
|
|
1161
|
+
if (nextDep !== void 0) {
|
|
1162
|
+
link2 = nextDep;
|
|
1163
|
+
continue top;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return dirty;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function shallowPropagate(firstLink) {
|
|
1170
|
+
let link2 = firstLink;
|
|
1171
|
+
do {
|
|
1172
|
+
const sub = link2.sub;
|
|
1173
|
+
const flags = sub.flags;
|
|
1174
|
+
if ((flags & 48) === Pending) {
|
|
1175
|
+
sub.flags = flags | Dirty;
|
|
1176
|
+
if ((flags & 6) === Watching) notify(sub);
|
|
1177
|
+
}
|
|
1178
|
+
link2 = link2.nextSub;
|
|
1179
|
+
} while (link2 !== void 0);
|
|
1180
|
+
}
|
|
1181
|
+
function update(node) {
|
|
1182
|
+
return "getter" in node && node.getter !== void 0 ? updateComputed(node) : updateSignal(node);
|
|
1183
|
+
}
|
|
1184
|
+
function valuesDiffer(node, prev, next) {
|
|
1185
|
+
if (node.equals === false) return true;
|
|
1186
|
+
if (typeof node.equals === "function") return !node.equals(prev, next);
|
|
1187
|
+
return prev !== next;
|
|
1188
|
+
}
|
|
1189
|
+
function notify(effect2) {
|
|
1190
|
+
effect2.flags &= ~Watching;
|
|
1191
|
+
const effects = [];
|
|
1192
|
+
for (; ; ) {
|
|
1193
|
+
effects.push(effect2);
|
|
1194
|
+
const nextLink = effect2.subs;
|
|
1195
|
+
if (nextLink === void 0) break;
|
|
1196
|
+
effect2 = nextLink.sub;
|
|
1197
|
+
if (effect2 === void 0 || !(effect2.flags & Watching)) break;
|
|
1198
|
+
effect2.flags &= ~Watching;
|
|
1199
|
+
}
|
|
1200
|
+
const targetQueue = isInTransition ? lowPriorityQueue : highPriorityQueue;
|
|
1201
|
+
for (let i = effects.length - 1; i >= 0; i--) {
|
|
1202
|
+
targetQueue.push(effects[i]);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
function purgeDeps(sub) {
|
|
1206
|
+
const depsTail = sub.depsTail;
|
|
1207
|
+
let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
1208
|
+
while (dep !== void 0) dep = unlink(dep, sub);
|
|
1209
|
+
}
|
|
1210
|
+
function disposeNode(node) {
|
|
1211
|
+
node.depsTail = void 0;
|
|
1212
|
+
node.flags = 0;
|
|
1213
|
+
purgeDeps(node);
|
|
1214
|
+
let sub = node.subs;
|
|
1215
|
+
while (sub !== void 0) {
|
|
1216
|
+
const next = sub.nextSub;
|
|
1217
|
+
unlink(sub);
|
|
1218
|
+
sub = next;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function updateSignal(s) {
|
|
1222
|
+
s.flags = Mutable;
|
|
1223
|
+
const current = s.currentValue;
|
|
1224
|
+
const pending = s.pendingValue;
|
|
1225
|
+
if (valuesDiffer(s, current, pending)) {
|
|
1226
|
+
s.currentValue = pending;
|
|
1227
|
+
return true;
|
|
1228
|
+
}
|
|
1229
|
+
return false;
|
|
1230
|
+
}
|
|
1231
|
+
function updateComputed(c) {
|
|
1232
|
+
++cycle;
|
|
1233
|
+
const oldValue = c.value;
|
|
1234
|
+
c.depsTail = void 0;
|
|
1235
|
+
c.flags = MutableRunning;
|
|
1236
|
+
const prevSub = activeSub;
|
|
1237
|
+
activeSub = c;
|
|
1238
|
+
try {
|
|
1239
|
+
const newValue = c.getter(oldValue);
|
|
1240
|
+
activeSub = prevSub;
|
|
1241
|
+
c.flags &= ~Running;
|
|
1242
|
+
purgeDeps(c);
|
|
1243
|
+
if (valuesDiffer(c, oldValue, newValue)) {
|
|
1244
|
+
c.value = newValue;
|
|
1245
|
+
if (isDev5) updateComputedDevtools(c, newValue);
|
|
1246
|
+
return true;
|
|
1247
|
+
}
|
|
1248
|
+
return false;
|
|
1249
|
+
} catch (e) {
|
|
1250
|
+
activeSub = prevSub;
|
|
1251
|
+
c.flags &= ~Running;
|
|
1252
|
+
throw e;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
function runEffect(e) {
|
|
1256
|
+
const flags = e.flags;
|
|
1257
|
+
if (flags & Dirty) {
|
|
1258
|
+
if (e.runCleanup) {
|
|
1259
|
+
inCleanup = true;
|
|
1260
|
+
try {
|
|
1261
|
+
e.runCleanup();
|
|
1262
|
+
} finally {
|
|
1263
|
+
inCleanup = false;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
++cycle;
|
|
1267
|
+
if (isDev5) effectRunDevtools(e);
|
|
1268
|
+
e.depsTail = void 0;
|
|
1269
|
+
e.flags = WatchingRunning;
|
|
1270
|
+
const prevSub = activeSub;
|
|
1271
|
+
activeSub = e;
|
|
1272
|
+
try {
|
|
1273
|
+
e.fn();
|
|
1274
|
+
activeSub = prevSub;
|
|
1275
|
+
e.flags = Watching;
|
|
1276
|
+
purgeDeps(e);
|
|
1277
|
+
} catch (err) {
|
|
1278
|
+
activeSub = prevSub;
|
|
1279
|
+
e.flags = Watching;
|
|
1280
|
+
throw err;
|
|
1281
|
+
}
|
|
1282
|
+
} 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
|
+
let isDirty = false;
|
|
1292
|
+
try {
|
|
1293
|
+
isDirty = checkDirty(e.deps, e);
|
|
1294
|
+
} catch (err) {
|
|
1295
|
+
if (handleSuspend(err, e.root)) {
|
|
1296
|
+
if (e.flags !== 0) {
|
|
1297
|
+
e.flags = Watching;
|
|
1298
|
+
}
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
if (handleError(err, { source: "effect" }, e.root)) {
|
|
1302
|
+
if (e.flags !== 0) {
|
|
1303
|
+
e.flags = Watching;
|
|
1304
|
+
}
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
throw err;
|
|
1308
|
+
}
|
|
1309
|
+
if (isDirty) {
|
|
1310
|
+
++cycle;
|
|
1311
|
+
if (isDev5) effectRunDevtools(e);
|
|
1312
|
+
e.depsTail = void 0;
|
|
1313
|
+
e.flags = WatchingRunning;
|
|
1314
|
+
const prevSub = activeSub;
|
|
1315
|
+
activeSub = e;
|
|
1316
|
+
try {
|
|
1317
|
+
e.fn();
|
|
1318
|
+
activeSub = prevSub;
|
|
1319
|
+
e.flags = Watching;
|
|
1320
|
+
purgeDeps(e);
|
|
1321
|
+
} catch (err) {
|
|
1322
|
+
activeSub = prevSub;
|
|
1323
|
+
e.flags = Watching;
|
|
1324
|
+
throw err;
|
|
1325
|
+
}
|
|
1326
|
+
} else {
|
|
1327
|
+
e.flags = Watching;
|
|
1328
|
+
}
|
|
1329
|
+
} else {
|
|
1330
|
+
e.flags = Watching;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function scheduleFlush() {
|
|
1334
|
+
const hasWork = highPriorityQueue.length > 0 || lowPriorityQueue.length > 0;
|
|
1335
|
+
if (flushScheduled || !hasWork) return;
|
|
1336
|
+
if (batchDepth > 0) return;
|
|
1337
|
+
flushScheduled = true;
|
|
1338
|
+
enqueueMicrotask(() => {
|
|
1339
|
+
flush();
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
function flush() {
|
|
1343
|
+
beginFlushGuard();
|
|
1344
|
+
if (batchDepth > 0) {
|
|
1345
|
+
scheduleFlush();
|
|
1346
|
+
endFlushGuard();
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
const hasWork = highPriorityQueue.length > 0 || lowPriorityQueue.length > 0;
|
|
1350
|
+
if (!hasWork) {
|
|
1351
|
+
flushScheduled = false;
|
|
1352
|
+
endFlushGuard();
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
flushScheduled = false;
|
|
1356
|
+
let highIndex = 0;
|
|
1357
|
+
while (highIndex < highPriorityQueue.length) {
|
|
1358
|
+
const e = highPriorityQueue[highIndex];
|
|
1359
|
+
if (!beforeEffectRunGuard()) {
|
|
1360
|
+
for (let i = 0; i < highPriorityQueue.length; i++) {
|
|
1361
|
+
const queued = highPriorityQueue[i];
|
|
1362
|
+
if (queued && queued.flags !== 0) {
|
|
1363
|
+
queued.flags = Watching;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
for (let i = 0; i < lowPriorityQueue.length; i++) {
|
|
1367
|
+
const queued = lowPriorityQueue[i];
|
|
1368
|
+
if (queued && queued.flags !== 0) {
|
|
1369
|
+
queued.flags = Watching;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
highPriorityQueue.length = 0;
|
|
1373
|
+
lowPriorityQueue.length = 0;
|
|
1374
|
+
flushScheduled = false;
|
|
1375
|
+
endFlushGuard();
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
highIndex++;
|
|
1379
|
+
runEffect(e);
|
|
1380
|
+
}
|
|
1381
|
+
highPriorityQueue.length = 0;
|
|
1382
|
+
let lowIndex = 0;
|
|
1383
|
+
while (lowIndex < lowPriorityQueue.length) {
|
|
1384
|
+
if (highPriorityQueue.length > 0) {
|
|
1385
|
+
if (lowIndex > 0) {
|
|
1386
|
+
lowPriorityQueue.copyWithin(0, lowIndex);
|
|
1387
|
+
lowPriorityQueue.length -= lowIndex;
|
|
1388
|
+
}
|
|
1389
|
+
scheduleFlush();
|
|
1390
|
+
endFlushGuard();
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
const e = lowPriorityQueue[lowIndex];
|
|
1394
|
+
if (!beforeEffectRunGuard()) {
|
|
1395
|
+
for (let i = 0; i < highPriorityQueue.length; i++) {
|
|
1396
|
+
const queued = highPriorityQueue[i];
|
|
1397
|
+
if (queued && queued.flags !== 0) {
|
|
1398
|
+
queued.flags = Watching;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
for (let i = 0; i < lowPriorityQueue.length; i++) {
|
|
1402
|
+
const queued = lowPriorityQueue[i];
|
|
1403
|
+
if (queued && queued.flags !== 0) {
|
|
1404
|
+
queued.flags = Watching;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
highPriorityQueue.length = 0;
|
|
1408
|
+
lowPriorityQueue.length = 0;
|
|
1409
|
+
flushScheduled = false;
|
|
1410
|
+
endFlushGuard();
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
lowIndex++;
|
|
1414
|
+
runEffect(e);
|
|
1415
|
+
}
|
|
1416
|
+
lowPriorityQueue.length = 0;
|
|
1417
|
+
endFlushGuard();
|
|
1418
|
+
}
|
|
1419
|
+
function signal(initialValue, options2) {
|
|
1420
|
+
const s = {
|
|
1421
|
+
currentValue: initialValue,
|
|
1422
|
+
pendingValue: initialValue,
|
|
1423
|
+
subs: void 0,
|
|
1424
|
+
subsTail: void 0,
|
|
1425
|
+
flags: Mutable,
|
|
1426
|
+
__id: void 0,
|
|
1427
|
+
..._optionalChain([options2, 'optionalAccess', _17 => _17.equals]) !== void 0 ? { equals: options2.equals } : {},
|
|
1428
|
+
..._optionalChain([options2, 'optionalAccess', _18 => _18.name]) !== void 0 ? { name: options2.name } : {},
|
|
1429
|
+
..._optionalChain([options2, 'optionalAccess', _19 => _19.devToolsSource]) !== void 0 ? { devToolsSource: options2.devToolsSource } : {}
|
|
1430
|
+
};
|
|
1431
|
+
if (isDev5) registerSignalDevtools(s);
|
|
1432
|
+
const accessor = signalOper.bind(s);
|
|
1433
|
+
accessor[SIGNAL_MARKER] = true;
|
|
1434
|
+
return accessor;
|
|
1435
|
+
}
|
|
1436
|
+
function signalOper(value) {
|
|
1437
|
+
if (arguments.length > 0) {
|
|
1438
|
+
const next = value;
|
|
1439
|
+
const prev = this.pendingValue;
|
|
1440
|
+
if (valuesDiffer(this, prev, next)) {
|
|
1441
|
+
this.pendingValue = next;
|
|
1442
|
+
this.flags = MutableDirty;
|
|
1443
|
+
if (isDev5) updateSignalDevtools(this, next);
|
|
1444
|
+
const subs = this.subs;
|
|
1445
|
+
if (subs !== void 0) {
|
|
1446
|
+
propagate(subs);
|
|
1447
|
+
if (!batchDepth) scheduleFlush();
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
const flags = this.flags;
|
|
1453
|
+
if (flags & Dirty && !inCleanup) {
|
|
1454
|
+
if (updateSignal(this)) {
|
|
1455
|
+
const subs = this.subs;
|
|
1456
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
let sub = activeSub;
|
|
1460
|
+
while (sub !== void 0) {
|
|
1461
|
+
if (sub.flags & 3) {
|
|
1462
|
+
link(this, sub, cycle);
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
const subSubs = sub.subs;
|
|
1466
|
+
sub = subSubs !== void 0 ? subSubs.sub : void 0;
|
|
1467
|
+
}
|
|
1468
|
+
return this.currentValue;
|
|
1469
|
+
}
|
|
1470
|
+
function computed(getter, options2) {
|
|
1471
|
+
const c = {
|
|
1472
|
+
value: void 0,
|
|
1473
|
+
subs: void 0,
|
|
1474
|
+
subsTail: void 0,
|
|
1475
|
+
deps: void 0,
|
|
1476
|
+
depsTail: void 0,
|
|
1477
|
+
flags: 0,
|
|
1478
|
+
getter,
|
|
1479
|
+
__id: void 0,
|
|
1480
|
+
..._optionalChain([options2, 'optionalAccess', _20 => _20.equals]) !== void 0 ? { equals: options2.equals } : {},
|
|
1481
|
+
..._optionalChain([options2, 'optionalAccess', _21 => _21.name]) !== void 0 ? { name: options2.name } : {},
|
|
1482
|
+
..._optionalChain([options2, 'optionalAccess', _22 => _22.devToolsSource]) !== void 0 ? { devToolsSource: options2.devToolsSource } : {}
|
|
1483
|
+
};
|
|
1484
|
+
if (isDev5) registerComputedDevtools(c);
|
|
1485
|
+
const bound = computedOper.bind(
|
|
1486
|
+
c
|
|
1487
|
+
);
|
|
1488
|
+
bound[COMPUTED_MARKER] = true;
|
|
1489
|
+
return bound;
|
|
1490
|
+
}
|
|
1491
|
+
function computedOper() {
|
|
1492
|
+
if (inCleanup) return this.value;
|
|
1493
|
+
const flags = this.flags;
|
|
1494
|
+
if (flags & Dirty) {
|
|
1495
|
+
if (updateComputed(this)) {
|
|
1496
|
+
const subs = this.subs;
|
|
1497
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1498
|
+
}
|
|
1499
|
+
} else if (flags & Pending) {
|
|
1500
|
+
if (this.deps && checkDirty(this.deps, this)) {
|
|
1501
|
+
if (updateComputed(this)) {
|
|
1502
|
+
const subs = this.subs;
|
|
1503
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1504
|
+
}
|
|
1505
|
+
} else {
|
|
1506
|
+
this.flags = flags & ~Pending;
|
|
1507
|
+
}
|
|
1508
|
+
} else if (!flags) {
|
|
1509
|
+
this.flags = MutableRunning;
|
|
1510
|
+
const prevSub = setActiveSub(this);
|
|
1511
|
+
try {
|
|
1512
|
+
this.value = this.getter(void 0);
|
|
1513
|
+
if (isDev5) updateComputedDevtools(this, this.value);
|
|
1514
|
+
} finally {
|
|
1515
|
+
setActiveSub(prevSub);
|
|
1516
|
+
this.flags &= ~Running;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if (activeSub !== void 0) link(this, activeSub, cycle);
|
|
1520
|
+
return this.value;
|
|
1521
|
+
}
|
|
1522
|
+
function effect(fn) {
|
|
1523
|
+
const e = {
|
|
1524
|
+
fn,
|
|
1525
|
+
subs: void 0,
|
|
1526
|
+
subsTail: void 0,
|
|
1527
|
+
deps: void 0,
|
|
1528
|
+
depsTail: void 0,
|
|
1529
|
+
flags: WatchingRunning,
|
|
1530
|
+
__id: void 0
|
|
1531
|
+
};
|
|
1532
|
+
const root = getCurrentRoot();
|
|
1533
|
+
if (root) {
|
|
1534
|
+
e.root = root;
|
|
1535
|
+
}
|
|
1536
|
+
if (isDev5) registerEffectDevtools(e);
|
|
1537
|
+
const prevSub = activeSub;
|
|
1538
|
+
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1539
|
+
activeSub = e;
|
|
1540
|
+
try {
|
|
1541
|
+
if (isDev5) effectRunDevtools(e);
|
|
1542
|
+
fn();
|
|
1543
|
+
} finally {
|
|
1544
|
+
activeSub = prevSub;
|
|
1545
|
+
e.flags &= ~Running;
|
|
1546
|
+
}
|
|
1547
|
+
const disposer = effectOper.bind(e);
|
|
1548
|
+
disposer[EFFECT_MARKER] = true;
|
|
1549
|
+
return disposer;
|
|
1550
|
+
}
|
|
1551
|
+
function effectWithCleanup(fn, cleanupRunner, root) {
|
|
1552
|
+
const e = {
|
|
1553
|
+
fn,
|
|
1554
|
+
subs: void 0,
|
|
1555
|
+
subsTail: void 0,
|
|
1556
|
+
deps: void 0,
|
|
1557
|
+
depsTail: void 0,
|
|
1558
|
+
flags: WatchingRunning,
|
|
1559
|
+
runCleanup: cleanupRunner,
|
|
1560
|
+
__id: void 0
|
|
1561
|
+
};
|
|
1562
|
+
const resolvedRoot = _nullishCoalesce(root, () => ( getCurrentRoot()));
|
|
1563
|
+
if (resolvedRoot) {
|
|
1564
|
+
e.root = resolvedRoot;
|
|
1565
|
+
}
|
|
1566
|
+
if (isDev5) registerEffectDevtools(e);
|
|
1567
|
+
const prevSub = activeSub;
|
|
1568
|
+
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1569
|
+
activeSub = e;
|
|
1570
|
+
try {
|
|
1571
|
+
if (isDev5) effectRunDevtools(e);
|
|
1572
|
+
fn();
|
|
1573
|
+
} finally {
|
|
1574
|
+
activeSub = prevSub;
|
|
1575
|
+
e.flags &= ~Running;
|
|
1576
|
+
}
|
|
1577
|
+
const disposer = effectOper.bind(e);
|
|
1578
|
+
disposer[EFFECT_MARKER] = true;
|
|
1579
|
+
return disposer;
|
|
1580
|
+
}
|
|
1581
|
+
function effectOper() {
|
|
1582
|
+
disposeNode(this);
|
|
1583
|
+
}
|
|
1584
|
+
function effectScope(fn) {
|
|
1585
|
+
const e = { deps: void 0, depsTail: void 0, subs: void 0, subsTail: void 0, flags: 0 };
|
|
1586
|
+
const prevSub = activeSub;
|
|
1587
|
+
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1588
|
+
activeSub = e;
|
|
1589
|
+
try {
|
|
1590
|
+
fn();
|
|
1591
|
+
} finally {
|
|
1592
|
+
activeSub = prevSub;
|
|
1593
|
+
}
|
|
1594
|
+
const disposer = effectScopeOper.bind(e);
|
|
1595
|
+
disposer[EFFECT_SCOPE_MARKER] = true;
|
|
1596
|
+
return disposer;
|
|
1597
|
+
}
|
|
1598
|
+
function effectScopeOper() {
|
|
1599
|
+
disposeNode(this);
|
|
1600
|
+
}
|
|
1601
|
+
function batch(fn) {
|
|
1602
|
+
++batchDepth;
|
|
1603
|
+
let result;
|
|
1604
|
+
let error;
|
|
1605
|
+
try {
|
|
1606
|
+
result = fn();
|
|
1607
|
+
} catch (e) {
|
|
1608
|
+
error = e;
|
|
1609
|
+
} finally {
|
|
1610
|
+
--batchDepth;
|
|
1611
|
+
if (batchDepth === 0) {
|
|
1612
|
+
try {
|
|
1613
|
+
flush();
|
|
1614
|
+
} catch (flushErr) {
|
|
1615
|
+
if (error === void 0) {
|
|
1616
|
+
error = flushErr;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
if (error !== void 0) {
|
|
1622
|
+
throw error;
|
|
1623
|
+
}
|
|
1624
|
+
return result;
|
|
1625
|
+
}
|
|
1626
|
+
function setActiveSub(sub) {
|
|
1627
|
+
const prev = activeSub;
|
|
1628
|
+
activeSub = sub;
|
|
1629
|
+
return prev;
|
|
1630
|
+
}
|
|
1631
|
+
function __resetReactiveState() {
|
|
1632
|
+
highPriorityQueue.length = 0;
|
|
1633
|
+
lowPriorityQueue.length = 0;
|
|
1634
|
+
batchDepth = 0;
|
|
1635
|
+
activeSub = void 0;
|
|
1636
|
+
flushScheduled = false;
|
|
1637
|
+
isInTransition = false;
|
|
1638
|
+
inCleanup = false;
|
|
1639
|
+
cycle = 0;
|
|
1640
|
+
}
|
|
1641
|
+
function untrack(fn) {
|
|
1642
|
+
const prev = activeSub;
|
|
1643
|
+
activeSub = void 0;
|
|
1644
|
+
try {
|
|
1645
|
+
return fn();
|
|
1646
|
+
} finally {
|
|
1647
|
+
activeSub = prev;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
function isSignal(fn) {
|
|
1651
|
+
return typeof fn === "function" && fn[SIGNAL_MARKER] === true;
|
|
1652
|
+
}
|
|
1653
|
+
function isComputed(fn) {
|
|
1654
|
+
return typeof fn === "function" && fn[COMPUTED_MARKER] === true;
|
|
1655
|
+
}
|
|
1656
|
+
function isEffect(fn) {
|
|
1657
|
+
return typeof fn === "function" && fn[EFFECT_MARKER] === true;
|
|
1658
|
+
}
|
|
1659
|
+
function isEffectScope(fn) {
|
|
1660
|
+
return typeof fn === "function" && fn[EFFECT_SCOPE_MARKER] === true;
|
|
1661
|
+
}
|
|
1662
|
+
function setTransitionContext(value) {
|
|
1663
|
+
const prev = isInTransition;
|
|
1664
|
+
isInTransition = value;
|
|
1665
|
+
return prev;
|
|
1666
|
+
}
|
|
1667
|
+
var registerSignalDevtools = () => void 0;
|
|
1668
|
+
var updateSignalDevtools = () => {
|
|
1669
|
+
};
|
|
1670
|
+
var registerComputedDevtools = () => void 0;
|
|
1671
|
+
var updateComputedDevtools = () => {
|
|
1672
|
+
};
|
|
1673
|
+
var registerEffectDevtools = () => void 0;
|
|
1674
|
+
var effectRunDevtools = () => {
|
|
1675
|
+
};
|
|
1676
|
+
var trackDependencyDevtools = () => {
|
|
1677
|
+
};
|
|
1678
|
+
var untrackDependencyDevtools = () => {
|
|
1679
|
+
};
|
|
1680
|
+
if (isDev5) {
|
|
1681
|
+
let nextDevtoolsId = 0;
|
|
1682
|
+
registerSignalDevtools = (node) => {
|
|
1683
|
+
const hook = getDevtoolsHook();
|
|
1684
|
+
if (!hook) return void 0;
|
|
1685
|
+
const id = ++nextDevtoolsId;
|
|
1686
|
+
const options2 = {};
|
|
1687
|
+
if (node.name !== void 0) options2.name = node.name;
|
|
1688
|
+
if (node.devToolsSource !== void 0) options2.source = node.devToolsSource;
|
|
1689
|
+
const ownerId = __fictGetCurrentComponentId();
|
|
1690
|
+
if (ownerId !== void 0) options2.ownerId = ownerId;
|
|
1691
|
+
hook.registerSignal(id, node.currentValue, options2);
|
|
1692
|
+
node.__id = id;
|
|
1693
|
+
return id;
|
|
1694
|
+
};
|
|
1695
|
+
updateSignalDevtools = (node, value) => {
|
|
1696
|
+
const hook = getDevtoolsHook();
|
|
1697
|
+
if (!hook) return;
|
|
1698
|
+
const id = node.__id;
|
|
1699
|
+
if (id) hook.updateSignal(id, value);
|
|
1700
|
+
};
|
|
1701
|
+
registerComputedDevtools = (node) => {
|
|
1702
|
+
const hook = getDevtoolsHook();
|
|
1703
|
+
if (!hook) return void 0;
|
|
1704
|
+
const id = ++nextDevtoolsId;
|
|
1705
|
+
const options2 = {};
|
|
1706
|
+
if (node.name !== void 0) options2.name = node.name;
|
|
1707
|
+
if (node.devToolsSource !== void 0) options2.source = node.devToolsSource;
|
|
1708
|
+
const ownerId = __fictGetCurrentComponentId();
|
|
1709
|
+
if (ownerId !== void 0) options2.ownerId = ownerId;
|
|
1710
|
+
options2.hasValue = false;
|
|
1711
|
+
hook.registerComputed(id, node.value, options2);
|
|
1712
|
+
node.__id = id;
|
|
1713
|
+
return id;
|
|
1714
|
+
};
|
|
1715
|
+
updateComputedDevtools = (node, value) => {
|
|
1716
|
+
const hook = getDevtoolsHook();
|
|
1717
|
+
if (!hook) return;
|
|
1718
|
+
const id = node.__id;
|
|
1719
|
+
if (id) hook.updateComputed(id, value);
|
|
1720
|
+
};
|
|
1721
|
+
registerEffectDevtools = (node) => {
|
|
1722
|
+
const hook = getDevtoolsHook();
|
|
1723
|
+
if (!hook) return void 0;
|
|
1724
|
+
const id = ++nextDevtoolsId;
|
|
1725
|
+
const ownerId = __fictGetCurrentComponentId();
|
|
1726
|
+
hook.registerEffect(id, ownerId !== void 0 ? { ownerId } : void 0);
|
|
1727
|
+
node.__id = id;
|
|
1728
|
+
return id;
|
|
1729
|
+
};
|
|
1730
|
+
effectRunDevtools = (node) => {
|
|
1731
|
+
const hook = getDevtoolsHook();
|
|
1732
|
+
if (!hook) return;
|
|
1733
|
+
const id = node.__id;
|
|
1734
|
+
if (id) hook.effectRun(id);
|
|
1735
|
+
};
|
|
1736
|
+
trackDependencyDevtools = (dep, sub) => {
|
|
1737
|
+
const hook = getDevtoolsHook();
|
|
1738
|
+
if (!_optionalChain([hook, 'optionalAccess', _23 => _23.trackDependency])) return;
|
|
1739
|
+
const depId = dep.__id;
|
|
1740
|
+
const subId = sub.__id;
|
|
1741
|
+
if (depId && subId) hook.trackDependency(subId, depId);
|
|
1742
|
+
};
|
|
1743
|
+
untrackDependencyDevtools = (dep, sub) => {
|
|
1744
|
+
const hook = getDevtoolsHook();
|
|
1745
|
+
if (!_optionalChain([hook, 'optionalAccess', _24 => _24.untrackDependency])) return;
|
|
1746
|
+
const depId = dep.__id;
|
|
1747
|
+
const subId = sub.__id;
|
|
1748
|
+
if (depId && subId) hook.untrackDependency(subId, depId);
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
function createSelector(source, equalityFn = (a, b) => a === b) {
|
|
1752
|
+
let current = source();
|
|
1753
|
+
const observers = /* @__PURE__ */ new Map();
|
|
1754
|
+
const dispose = effect(() => {
|
|
1755
|
+
const next = source();
|
|
1756
|
+
if (equalityFn(current, next)) return;
|
|
1757
|
+
const prevSig = observers.get(current);
|
|
1758
|
+
if (prevSig) prevSig(false);
|
|
1759
|
+
const nextSig = observers.get(next);
|
|
1760
|
+
if (nextSig) nextSig(true);
|
|
1761
|
+
current = next;
|
|
1762
|
+
});
|
|
1763
|
+
registerRootCleanup(() => {
|
|
1764
|
+
dispose();
|
|
1765
|
+
observers.clear();
|
|
1766
|
+
});
|
|
1767
|
+
return (key) => {
|
|
1768
|
+
let sig = observers.get(key);
|
|
1769
|
+
if (!sig) {
|
|
1770
|
+
sig = signal(equalityFn(key, current));
|
|
1771
|
+
observers.set(key, sig);
|
|
1772
|
+
registerRootCleanup(() => observers.delete(key));
|
|
1773
|
+
}
|
|
1774
|
+
return sig();
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
// src/memo.ts
|
|
1779
|
+
function createMemo(fn, options2) {
|
|
1780
|
+
return computed(fn, options2);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// src/store.ts
|
|
1784
|
+
var PROXY = Symbol("fict:store-proxy");
|
|
1785
|
+
var TARGET = Symbol("fict:store-target");
|
|
1786
|
+
var ITERATE_KEY = Symbol("fict:iterate");
|
|
1787
|
+
function createStore(initialValue) {
|
|
1788
|
+
const unwrapped = unwrap(initialValue);
|
|
1789
|
+
const wrapped = wrap(unwrapped);
|
|
1790
|
+
function setStore(fn) {
|
|
1791
|
+
batch(() => {
|
|
1792
|
+
const result = fn(wrapped);
|
|
1793
|
+
if (result !== void 0) {
|
|
1794
|
+
reconcile(wrapped, result);
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
return [wrapped, setStore];
|
|
1799
|
+
}
|
|
1800
|
+
var proxyCache = /* @__PURE__ */ new WeakMap();
|
|
1801
|
+
var signalCache = /* @__PURE__ */ new WeakMap();
|
|
1802
|
+
function wrap(value) {
|
|
1803
|
+
if (value === null || typeof value !== "object") return value;
|
|
1804
|
+
if (Reflect.get(value, PROXY)) return value;
|
|
1805
|
+
if (proxyCache.has(value)) return proxyCache.get(value);
|
|
1806
|
+
const handler = {
|
|
1807
|
+
get(target, prop, receiver) {
|
|
1808
|
+
if (prop === PROXY) return true;
|
|
1809
|
+
if (prop === TARGET) return target;
|
|
1810
|
+
const value2 = Reflect.get(target, prop, receiver);
|
|
1811
|
+
track(target, prop);
|
|
1812
|
+
return wrap(value2);
|
|
1813
|
+
},
|
|
1814
|
+
has(target, prop) {
|
|
1815
|
+
const result = Reflect.has(target, prop);
|
|
1816
|
+
track(target, prop);
|
|
1817
|
+
return result;
|
|
1818
|
+
},
|
|
1819
|
+
ownKeys(target) {
|
|
1820
|
+
track(target, ITERATE_KEY);
|
|
1821
|
+
return Reflect.ownKeys(target);
|
|
1822
|
+
},
|
|
1823
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
1824
|
+
track(target, prop);
|
|
1825
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1826
|
+
},
|
|
1827
|
+
set(target, prop, value2, receiver) {
|
|
1828
|
+
if (prop === PROXY || prop === TARGET) return false;
|
|
1829
|
+
const isArrayLength = Array.isArray(target) && prop === "length";
|
|
1830
|
+
const oldLength = isArrayLength ? target.length : void 0;
|
|
1831
|
+
const hadKey = Object.prototype.hasOwnProperty.call(target, prop);
|
|
1832
|
+
const oldValue = Reflect.get(target, prop, receiver);
|
|
1833
|
+
if (oldValue === value2) return true;
|
|
1834
|
+
const result = Reflect.set(target, prop, value2, receiver);
|
|
1835
|
+
if (result) {
|
|
1836
|
+
trigger(target, prop);
|
|
1837
|
+
if (!hadKey) {
|
|
1838
|
+
trigger(target, ITERATE_KEY);
|
|
1839
|
+
}
|
|
1840
|
+
if (isArrayLength) {
|
|
1841
|
+
const nextLength = target.length;
|
|
1842
|
+
if (typeof oldLength === "number" && nextLength < oldLength) {
|
|
1843
|
+
const signals = signalCache.get(target);
|
|
1844
|
+
if (signals) {
|
|
1845
|
+
for (const key of signals.keys()) {
|
|
1846
|
+
if (typeof key !== "string") continue;
|
|
1847
|
+
const index = Number(key);
|
|
1848
|
+
if (!Number.isInteger(index) || String(index) !== key) continue;
|
|
1849
|
+
if (index >= nextLength && index < oldLength) {
|
|
1850
|
+
trigger(target, key);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
trigger(target, ITERATE_KEY);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
return result;
|
|
1859
|
+
},
|
|
1860
|
+
deleteProperty(target, prop) {
|
|
1861
|
+
const hadKey = Object.prototype.hasOwnProperty.call(target, prop);
|
|
1862
|
+
const result = Reflect.deleteProperty(target, prop);
|
|
1863
|
+
if (result) {
|
|
1864
|
+
trigger(target, prop);
|
|
1865
|
+
if (hadKey) {
|
|
1866
|
+
trigger(target, ITERATE_KEY);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
return result;
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
const proxy = new Proxy(value, handler);
|
|
1873
|
+
proxyCache.set(value, proxy);
|
|
1874
|
+
return proxy;
|
|
1875
|
+
}
|
|
1876
|
+
function unwrap(value) {
|
|
1877
|
+
if (value && typeof value === "object" && Reflect.get(value, PROXY)) {
|
|
1878
|
+
return Reflect.get(value, TARGET);
|
|
1879
|
+
}
|
|
1880
|
+
return value;
|
|
1881
|
+
}
|
|
1882
|
+
function isStoreProxy(value) {
|
|
1883
|
+
return !!(value && typeof value === "object" && Reflect.get(value, PROXY));
|
|
1884
|
+
}
|
|
1885
|
+
function unwrapStore(value) {
|
|
1886
|
+
return unwrap(value);
|
|
1887
|
+
}
|
|
1888
|
+
function track(target, prop) {
|
|
1889
|
+
let signals = signalCache.get(target);
|
|
1890
|
+
if (!signals) {
|
|
1891
|
+
signals = /* @__PURE__ */ new Map();
|
|
1892
|
+
signalCache.set(target, signals);
|
|
1893
|
+
}
|
|
1894
|
+
let s = signals.get(prop);
|
|
1895
|
+
if (!s) {
|
|
1896
|
+
const initial = prop === ITERATE_KEY ? Reflect.ownKeys(target).length : getLastValue(target, prop);
|
|
1897
|
+
s = signal(initial);
|
|
1898
|
+
signals.set(prop, s);
|
|
1899
|
+
}
|
|
1900
|
+
s();
|
|
1901
|
+
}
|
|
1902
|
+
function trigger(target, prop) {
|
|
1903
|
+
const signals = signalCache.get(target);
|
|
1904
|
+
if (signals) {
|
|
1905
|
+
const s = signals.get(prop);
|
|
1906
|
+
if (s) {
|
|
1907
|
+
if (prop === ITERATE_KEY) {
|
|
1908
|
+
s(Reflect.ownKeys(target).length);
|
|
1909
|
+
} else {
|
|
1910
|
+
s(getLastValue(target, prop));
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
function getLastValue(target, prop) {
|
|
1916
|
+
return Reflect.get(target, prop);
|
|
1917
|
+
}
|
|
1918
|
+
function reconcile(target, value) {
|
|
1919
|
+
if (target === value) return;
|
|
1920
|
+
if (value === null || typeof value !== "object") {
|
|
1921
|
+
throw new Error(
|
|
1922
|
+
`[Fict] Cannot replace store with primitive value: ${String(
|
|
1923
|
+
value
|
|
1924
|
+
)}. setStore should return an object/array to merge.`
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
const realTarget = unwrap(target);
|
|
1928
|
+
const realValue = unwrap(value);
|
|
1929
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(realTarget), ...Object.keys(realValue)]);
|
|
1930
|
+
for (const key of keys) {
|
|
1931
|
+
const rTarget = realTarget;
|
|
1932
|
+
const rValue = realValue;
|
|
1933
|
+
if (rValue[key] === void 0 && rTarget[key] !== void 0) {
|
|
1934
|
+
delete target[key];
|
|
1935
|
+
} else if (rTarget[key] !== rValue[key]) {
|
|
1936
|
+
;
|
|
1937
|
+
target[key] = rValue[key];
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (Array.isArray(target) && Array.isArray(realValue) && target.length !== realValue.length) {
|
|
1941
|
+
target.length = realValue.length;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
// src/resume.ts
|
|
1946
|
+
var ssrEnabled = false;
|
|
1947
|
+
var resumableEnabled = false;
|
|
1948
|
+
var hydrating = false;
|
|
1949
|
+
var scopeCounter = 0;
|
|
1950
|
+
var scopeRegistry = /* @__PURE__ */ new Map();
|
|
1951
|
+
var snapshotState = null;
|
|
1952
|
+
var resumedScopes = /* @__PURE__ */ new Map();
|
|
1953
|
+
function __fictEnableSSR() {
|
|
1954
|
+
ssrEnabled = true;
|
|
1955
|
+
scopeCounter = 0;
|
|
1956
|
+
scopeRegistry = /* @__PURE__ */ new Map();
|
|
1957
|
+
resumedScopes.clear();
|
|
1958
|
+
snapshotState = null;
|
|
1959
|
+
}
|
|
1960
|
+
function __fictDisableSSR() {
|
|
1961
|
+
ssrEnabled = false;
|
|
1962
|
+
}
|
|
1963
|
+
function __fictEnableResumable() {
|
|
1964
|
+
resumableEnabled = true;
|
|
1965
|
+
}
|
|
1966
|
+
function __fictDisableResumable() {
|
|
1967
|
+
resumableEnabled = false;
|
|
1968
|
+
resumedScopes.clear();
|
|
1969
|
+
}
|
|
1970
|
+
function __fictIsResumable() {
|
|
1971
|
+
return ssrEnabled || resumableEnabled;
|
|
1972
|
+
}
|
|
1973
|
+
function __fictIsSSR() {
|
|
1974
|
+
return ssrEnabled;
|
|
1975
|
+
}
|
|
1976
|
+
function __fictEnterHydration() {
|
|
1977
|
+
hydrating = true;
|
|
1978
|
+
}
|
|
1979
|
+
function __fictExitHydration() {
|
|
1980
|
+
hydrating = false;
|
|
1981
|
+
}
|
|
1982
|
+
function __fictIsHydrating() {
|
|
1983
|
+
return hydrating;
|
|
1984
|
+
}
|
|
1985
|
+
function __fictRegisterScope(ctx, host, type, props) {
|
|
1986
|
+
if (!__fictIsResumable()) return "";
|
|
1987
|
+
const id = `s${++scopeCounter}`;
|
|
1988
|
+
ctx.scopeId = id;
|
|
1989
|
+
if (type !== void 0) {
|
|
1990
|
+
ctx.scopeType = type;
|
|
1991
|
+
}
|
|
1992
|
+
host.setAttribute("data-fict-s", id);
|
|
1993
|
+
if (type) {
|
|
1994
|
+
host.setAttribute("data-fict-t", type);
|
|
1995
|
+
}
|
|
1996
|
+
const record = { id, ctx, host };
|
|
1997
|
+
if (type !== void 0) {
|
|
1998
|
+
record.type = type;
|
|
1999
|
+
}
|
|
2000
|
+
if (props !== void 0) {
|
|
2001
|
+
record.props = props;
|
|
2002
|
+
}
|
|
2003
|
+
scopeRegistry.set(id, record);
|
|
2004
|
+
return id;
|
|
2005
|
+
}
|
|
2006
|
+
function __fictGetScopeRegistry() {
|
|
2007
|
+
return scopeRegistry;
|
|
2008
|
+
}
|
|
2009
|
+
function __fictSerializeSSRState() {
|
|
2010
|
+
const scopes = {};
|
|
2011
|
+
for (const [id, record] of scopeRegistry.entries()) {
|
|
2012
|
+
const snapshot = {
|
|
2013
|
+
id,
|
|
2014
|
+
slots: serializeSlots(record.ctx)
|
|
2015
|
+
};
|
|
2016
|
+
if (record.type !== void 0) {
|
|
2017
|
+
snapshot.t = record.type;
|
|
2018
|
+
}
|
|
2019
|
+
if (record.props !== void 0) {
|
|
2020
|
+
snapshot.props = record.props;
|
|
2021
|
+
}
|
|
2022
|
+
if (record.ctx.slotMap !== void 0) {
|
|
2023
|
+
snapshot.vars = record.ctx.slotMap;
|
|
2024
|
+
}
|
|
2025
|
+
scopes[id] = snapshot;
|
|
2026
|
+
}
|
|
2027
|
+
return { scopes };
|
|
2028
|
+
}
|
|
2029
|
+
function __fictSetSSRState(state) {
|
|
2030
|
+
snapshotState = state;
|
|
2031
|
+
if (!state) {
|
|
2032
|
+
resumedScopes.clear();
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
function __fictGetSSRScope(id) {
|
|
2036
|
+
return _optionalChain([snapshotState, 'optionalAccess', _25 => _25.scopes, 'access', _26 => _26[id]]);
|
|
2037
|
+
}
|
|
2038
|
+
function __fictEnsureScope(scopeId, host, snapshot) {
|
|
2039
|
+
const existing = resumedScopes.get(scopeId);
|
|
2040
|
+
if (existing) return existing.ctx;
|
|
2041
|
+
const ctx = createContextFromSnapshot(snapshot);
|
|
2042
|
+
ctx.scopeId = scopeId;
|
|
2043
|
+
if (_optionalChain([snapshot, 'optionalAccess', _27 => _27.t]) !== void 0) {
|
|
2044
|
+
ctx.scopeType = snapshot.t;
|
|
2045
|
+
}
|
|
2046
|
+
const entry = { ctx, host };
|
|
2047
|
+
if (_optionalChain([snapshot, 'optionalAccess', _28 => _28.props]) !== void 0) {
|
|
2048
|
+
entry.props = snapshot.props;
|
|
2049
|
+
}
|
|
2050
|
+
resumedScopes.set(scopeId, entry);
|
|
2051
|
+
return ctx;
|
|
2052
|
+
}
|
|
2053
|
+
function __fictUseLexicalScope(scopeId, names) {
|
|
2054
|
+
const record = resumedScopes.get(scopeId);
|
|
2055
|
+
if (!record) {
|
|
2056
|
+
throw new Error(`[fict] Missing resumed scope for ${scopeId}`);
|
|
2057
|
+
}
|
|
2058
|
+
const ctx = record.ctx;
|
|
2059
|
+
const map = _nullishCoalesce(ctx.slotMap, () => ( {}));
|
|
2060
|
+
return names.map((name) => ctx.slots[_nullishCoalesce(map[name], () => ( -1))]);
|
|
2061
|
+
}
|
|
2062
|
+
function __fictGetScopeProps(scopeId) {
|
|
2063
|
+
return _optionalChain([resumedScopes, 'access', _29 => _29.get, 'call', _30 => _30(scopeId), 'optionalAccess', _31 => _31.props]);
|
|
2064
|
+
}
|
|
2065
|
+
function __fictQrl(moduleId, exportName) {
|
|
2066
|
+
const manifest = globalThis.__FICT_MANIFEST__;
|
|
2067
|
+
if (_optionalChain([manifest, 'optionalAccess', _32 => _32[moduleId]])) {
|
|
2068
|
+
return `${manifest[moduleId]}#${exportName}`;
|
|
2069
|
+
}
|
|
2070
|
+
if (moduleId.startsWith("file://")) {
|
|
2071
|
+
const filePath = moduleId.slice(7);
|
|
2072
|
+
const ssrBase = globalThis.__FICT_SSR_BASE__;
|
|
2073
|
+
if (ssrBase) {
|
|
2074
|
+
if (filePath.startsWith(ssrBase)) {
|
|
2075
|
+
const relativePath = filePath.slice(ssrBase.length);
|
|
2076
|
+
return `${relativePath}#${exportName}`;
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
return `/@fs${filePath}#${exportName}`;
|
|
2080
|
+
}
|
|
2081
|
+
return `${moduleId}#${exportName}`;
|
|
2082
|
+
}
|
|
2083
|
+
var resumeFunctionRegistry = /* @__PURE__ */ new Map();
|
|
2084
|
+
function __fictRegisterResume(name, fn) {
|
|
2085
|
+
resumeFunctionRegistry.set(name, fn);
|
|
2086
|
+
}
|
|
2087
|
+
function __fictGetResume(name) {
|
|
2088
|
+
return resumeFunctionRegistry.get(name);
|
|
2089
|
+
}
|
|
2090
|
+
function serializeSlots(ctx) {
|
|
2091
|
+
const slots = [];
|
|
2092
|
+
const values = _nullishCoalesce(ctx.slots, () => ( []));
|
|
2093
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2094
|
+
for (let i = 0; i < values.length; i++) {
|
|
2095
|
+
const value = values[i];
|
|
2096
|
+
if (value === void 0) {
|
|
2097
|
+
slots.push([i, "raw", serializeValue(void 0, seen, `$[${i}]`)]);
|
|
2098
|
+
continue;
|
|
2099
|
+
}
|
|
2100
|
+
if (isSignal(value)) {
|
|
2101
|
+
try {
|
|
2102
|
+
const raw = value();
|
|
2103
|
+
slots.push([i, "sig", serializeValue(raw, seen, `$[${i}]`)]);
|
|
2104
|
+
} catch (e2) {
|
|
2105
|
+
}
|
|
2106
|
+
continue;
|
|
2107
|
+
}
|
|
2108
|
+
if (isStoreProxy(value)) {
|
|
2109
|
+
const raw = unwrapStore(value);
|
|
2110
|
+
slots.push([i, "store", serializeValue(raw, seen, `$[${i}]`)]);
|
|
2111
|
+
continue;
|
|
2112
|
+
}
|
|
2113
|
+
slots.push([i, "raw", serializeValue(value, seen, `$[${i}]`)]);
|
|
2114
|
+
}
|
|
2115
|
+
return slots;
|
|
2116
|
+
}
|
|
2117
|
+
function createContextFromSnapshot(snapshot) {
|
|
2118
|
+
const ctx = { slots: [], cursor: 0 };
|
|
2119
|
+
if (!snapshot) return ctx;
|
|
2120
|
+
for (const slot of snapshot.slots) {
|
|
2121
|
+
const [index, type, value] = slot;
|
|
2122
|
+
if (type === "sig") {
|
|
2123
|
+
ctx.slots[index] = signal(deserializeValue(value));
|
|
2124
|
+
} else if (type === "store") {
|
|
2125
|
+
ctx.slots[index] = createStore(deserializeValue(value))[0];
|
|
2126
|
+
} else {
|
|
2127
|
+
ctx.slots[index] = deserializeValue(value);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
if (snapshot.vars) {
|
|
2131
|
+
ctx.slotMap = { ...snapshot.vars };
|
|
2132
|
+
}
|
|
2133
|
+
return ctx;
|
|
2134
|
+
}
|
|
2135
|
+
function isSerializedMarker(value) {
|
|
2136
|
+
return typeof value === "object" && value !== null && "__t" in value && typeof value.__t === "string";
|
|
2137
|
+
}
|
|
2138
|
+
function serializeValue(value, seen = /* @__PURE__ */ new Map(), path = "$") {
|
|
2139
|
+
if (value === void 0) {
|
|
2140
|
+
return { __t: "u" };
|
|
2141
|
+
}
|
|
2142
|
+
if (typeof value === "number") {
|
|
2143
|
+
if (Number.isNaN(value)) {
|
|
2144
|
+
return { __t: "n" };
|
|
2145
|
+
}
|
|
2146
|
+
if (value === Infinity) {
|
|
2147
|
+
return { __t: "+i" };
|
|
2148
|
+
}
|
|
2149
|
+
if (value === -Infinity) {
|
|
2150
|
+
return { __t: "-i" };
|
|
2151
|
+
}
|
|
2152
|
+
return value;
|
|
2153
|
+
}
|
|
2154
|
+
if (typeof value === "bigint") {
|
|
2155
|
+
return { __t: "b", v: value.toString() };
|
|
2156
|
+
}
|
|
2157
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
2158
|
+
return value;
|
|
2159
|
+
}
|
|
2160
|
+
if (typeof value === "function") {
|
|
2161
|
+
return void 0;
|
|
2162
|
+
}
|
|
2163
|
+
if (typeof value === "object") {
|
|
2164
|
+
if (seen.has(value)) {
|
|
2165
|
+
return { __t: "ref", v: seen.get(value) };
|
|
2166
|
+
}
|
|
2167
|
+
if (value instanceof Date) {
|
|
2168
|
+
return { __t: "d", v: value.getTime() };
|
|
2169
|
+
}
|
|
2170
|
+
if (value instanceof RegExp) {
|
|
2171
|
+
return { __t: "r", v: { s: value.source, f: value.flags } };
|
|
2172
|
+
}
|
|
2173
|
+
if (value instanceof Map) {
|
|
2174
|
+
seen.set(value, path);
|
|
2175
|
+
const entries = [];
|
|
2176
|
+
let i = 0;
|
|
2177
|
+
for (const [k, v] of value) {
|
|
2178
|
+
entries.push([
|
|
2179
|
+
serializeValue(k, seen, `${path}.k${i}`),
|
|
2180
|
+
serializeValue(v, seen, `${path}.v${i}`)
|
|
2181
|
+
]);
|
|
2182
|
+
i++;
|
|
2183
|
+
}
|
|
2184
|
+
return { __t: "m", v: entries };
|
|
2185
|
+
}
|
|
2186
|
+
if (value instanceof Set) {
|
|
2187
|
+
seen.set(value, path);
|
|
2188
|
+
const items = [];
|
|
2189
|
+
let i = 0;
|
|
2190
|
+
for (const item of value) {
|
|
2191
|
+
items.push(serializeValue(item, seen, `${path}[${i}]`));
|
|
2192
|
+
i++;
|
|
2193
|
+
}
|
|
2194
|
+
return { __t: "s", v: items };
|
|
2195
|
+
}
|
|
2196
|
+
if (Array.isArray(value)) {
|
|
2197
|
+
seen.set(value, path);
|
|
2198
|
+
return value.map((item, i) => serializeValue(item, seen, `${path}[${i}]`));
|
|
2199
|
+
}
|
|
2200
|
+
seen.set(value, path);
|
|
2201
|
+
const result = {};
|
|
2202
|
+
for (const key of Object.keys(value)) {
|
|
2203
|
+
const serialized = serializeValue(
|
|
2204
|
+
value[key],
|
|
2205
|
+
seen,
|
|
2206
|
+
`${path}.${key}`
|
|
2207
|
+
);
|
|
2208
|
+
if (serialized !== void 0) {
|
|
2209
|
+
result[key] = serialized;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
return result;
|
|
2213
|
+
}
|
|
2214
|
+
return value;
|
|
2215
|
+
}
|
|
2216
|
+
function deserializeValue(value, refs = /* @__PURE__ */ new Map(), path = "$") {
|
|
2217
|
+
if (value === null) {
|
|
2218
|
+
return null;
|
|
2219
|
+
}
|
|
2220
|
+
if (typeof value !== "object") {
|
|
2221
|
+
return value;
|
|
2222
|
+
}
|
|
2223
|
+
if (isSerializedMarker(value)) {
|
|
2224
|
+
switch (value.__t) {
|
|
2225
|
+
case "u":
|
|
2226
|
+
return void 0;
|
|
2227
|
+
case "n":
|
|
2228
|
+
return NaN;
|
|
2229
|
+
case "+i":
|
|
2230
|
+
return Infinity;
|
|
2231
|
+
case "-i":
|
|
2232
|
+
return -Infinity;
|
|
2233
|
+
case "b":
|
|
2234
|
+
return BigInt(value.v);
|
|
2235
|
+
case "d":
|
|
2236
|
+
return new Date(value.v);
|
|
2237
|
+
case "r":
|
|
2238
|
+
return new RegExp(value.v.s, value.v.f);
|
|
2239
|
+
case "m": {
|
|
2240
|
+
const map = /* @__PURE__ */ new Map();
|
|
2241
|
+
refs.set(path, map);
|
|
2242
|
+
for (let i = 0; i < value.v.length; i++) {
|
|
2243
|
+
const entry = value.v[i];
|
|
2244
|
+
if (!entry) continue;
|
|
2245
|
+
const [k, v] = entry;
|
|
2246
|
+
map.set(
|
|
2247
|
+
deserializeValue(k, refs, `${path}.k${i}`),
|
|
2248
|
+
deserializeValue(v, refs, `${path}.v${i}`)
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
return map;
|
|
2252
|
+
}
|
|
2253
|
+
case "s": {
|
|
2254
|
+
const set = /* @__PURE__ */ new Set();
|
|
2255
|
+
refs.set(path, set);
|
|
2256
|
+
for (let i = 0; i < value.v.length; i++) {
|
|
2257
|
+
set.add(deserializeValue(value.v[i], refs, `${path}[${i}]`));
|
|
2258
|
+
}
|
|
2259
|
+
return set;
|
|
2260
|
+
}
|
|
2261
|
+
case "ref":
|
|
2262
|
+
return refs.get(value.v);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
if (Array.isArray(value)) {
|
|
2266
|
+
const arr = [];
|
|
2267
|
+
refs.set(path, arr);
|
|
2268
|
+
for (let i = 0; i < value.length; i++) {
|
|
2269
|
+
arr.push(deserializeValue(value[i], refs, `${path}[${i}]`));
|
|
2270
|
+
}
|
|
2271
|
+
return arr;
|
|
2272
|
+
}
|
|
2273
|
+
const obj = {};
|
|
2274
|
+
refs.set(path, obj);
|
|
2275
|
+
for (const key of Object.keys(value)) {
|
|
2276
|
+
obj[key] = deserializeValue(value[key], refs, `${path}.${key}`);
|
|
2277
|
+
}
|
|
2278
|
+
return obj;
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
|
|
2295
|
+
|
|
2296
|
+
|
|
2297
|
+
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2331
|
+
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2340
|
+
|
|
2341
|
+
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
|
|
2347
|
+
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
|
|
2351
|
+
|
|
2352
|
+
|
|
2353
|
+
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
|
|
2358
|
+
|
|
2359
|
+
|
|
2360
|
+
|
|
2361
|
+
|
|
2362
|
+
exports.BooleanAttributes = BooleanAttributes; exports.Properties = Properties; exports.ChildProperties = ChildProperties; exports.Aliases = Aliases; exports.getPropAlias = getPropAlias; exports.$$EVENTS = $$EVENTS; exports.DelegatedEvents = DelegatedEvents; exports.SVGElements = SVGElements; exports.SVGNamespace = SVGNamespace; exports.UnitlessStyles = UnitlessStyles; exports.getDevtoolsHook = getDevtoolsHook; exports.setCycleProtectionOptions = setCycleProtectionOptions; exports.createRootContext = createRootContext; exports.pushRoot = pushRoot; exports.getCurrentRoot = getCurrentRoot; exports.popRoot = popRoot; exports.onMount = onMount; exports.onDestroy = onDestroy; exports.onCleanup = onCleanup; exports.flushOnMount = flushOnMount; exports.registerRootCleanup = registerRootCleanup; exports.destroyRoot = destroyRoot; exports.createRoot = createRoot; exports.registerErrorHandler = registerErrorHandler; exports.registerSuspenseHandler = registerSuspenseHandler; exports.handleError = handleError; exports.handleSuspend = handleSuspend; exports.createMemo = createMemo; exports.__fictUseContext = __fictUseContext; exports.__fictPushContext = __fictPushContext; exports.__fictPrepareContext = __fictPrepareContext; exports.__fictGetCurrentComponentId = __fictGetCurrentComponentId; exports.__fictPopContext = __fictPopContext; exports.__fictResetContext = __fictResetContext; exports.__fictUseSignal = __fictUseSignal; exports.__fictUseMemo = __fictUseMemo; exports.__fictUseEffect = __fictUseEffect; exports.__fictRender = __fictRender; exports.scheduleFlush = scheduleFlush; exports.flush = flush; exports.signal = signal; exports.computed = computed; exports.effectScope = effectScope; exports.batch = batch; exports.setActiveSub = setActiveSub; exports.__resetReactiveState = __resetReactiveState; exports.untrack = untrack; exports.isSignal = isSignal; exports.isComputed = isComputed; exports.isEffect = isEffect; exports.isEffectScope = isEffectScope; exports.setTransitionContext = setTransitionContext; exports.createSelector = createSelector; exports.createEffect = createEffect; exports.createRenderEffect = createRenderEffect; exports.createStore = createStore; exports.isStoreProxy = isStoreProxy; exports.unwrapStore = unwrapStore; exports.__fictEnableSSR = __fictEnableSSR; exports.__fictDisableSSR = __fictDisableSSR; exports.__fictEnableResumable = __fictEnableResumable; exports.__fictDisableResumable = __fictDisableResumable; exports.__fictIsResumable = __fictIsResumable; exports.__fictIsSSR = __fictIsSSR; exports.__fictEnterHydration = __fictEnterHydration; exports.__fictExitHydration = __fictExitHydration; exports.__fictIsHydrating = __fictIsHydrating; exports.__fictRegisterScope = __fictRegisterScope; exports.__fictGetScopeRegistry = __fictGetScopeRegistry; exports.__fictSerializeSSRState = __fictSerializeSSRState; exports.__fictSetSSRState = __fictSetSSRState; exports.__fictGetSSRScope = __fictGetSSRScope; exports.__fictEnsureScope = __fictEnsureScope; exports.__fictUseLexicalScope = __fictUseLexicalScope; exports.__fictGetScopeProps = __fictGetScopeProps; exports.__fictQrl = __fictQrl; exports.__fictRegisterResume = __fictRegisterResume; exports.__fictGetResume = __fictGetResume; exports.serializeValue = serializeValue; exports.deserializeValue = deserializeValue;
|
|
2363
|
+
//# sourceMappingURL=chunk-6SOPF5LZ.cjs.map
|