@fictjs/runtime 0.0.13 → 0.0.15
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 +79 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +50 -0
- package/dist/advanced.d.ts +50 -0
- package/dist/advanced.js +79 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-624QY53A.cjs +45 -0
- package/dist/chunk-624QY53A.cjs.map +1 -0
- package/dist/chunk-F3AIYQB7.js +45 -0
- package/dist/chunk-F3AIYQB7.js.map +1 -0
- package/dist/chunk-GJTYOFMO.cjs +109 -0
- package/dist/chunk-GJTYOFMO.cjs.map +1 -0
- package/dist/chunk-IUZXKAAY.js +109 -0
- package/dist/chunk-IUZXKAAY.js.map +1 -0
- package/dist/chunk-PMF6MWEV.cjs +3301 -0
- package/dist/chunk-PMF6MWEV.cjs.map +1 -0
- package/dist/chunk-RY4WDS6R.js +3301 -0
- package/dist/chunk-RY4WDS6R.js.map +1 -0
- package/dist/context-B7UYnfzM.d.ts +153 -0
- package/dist/context-UXySaqI_.d.cts +153 -0
- package/dist/effect-Auji1rz9.d.cts +350 -0
- package/dist/effect-Auji1rz9.d.ts +350 -0
- package/dist/index.cjs +98 -3558
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1358
- package/dist/index.d.ts +5 -1358
- package/dist/index.dev.js +240 -1698
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +63 -3435
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +901 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +158 -0
- package/dist/internal.d.ts +158 -0
- package/dist/internal.js +901 -0
- package/dist/internal.js.map +1 -0
- package/dist/{jsx-dev-runtime.d.ts → props-CrOMYbLv.d.cts} +107 -18
- package/dist/{jsx-dev-runtime.d.cts → props-ES0Ag_Wd.d.ts} +107 -18
- package/dist/scope-DKYzWfTn.d.cts +55 -0
- package/dist/scope-S6eAzBJZ.d.ts +55 -0
- package/package.json +11 -1
- package/src/advanced.ts +101 -0
- package/src/constants.ts +3 -26
- package/src/context.ts +300 -0
- package/src/delegated-events.ts +24 -0
- package/src/index.ts +41 -112
- package/src/internal.ts +130 -0
- package/src/props.ts +48 -46
- package/src/store.ts +47 -7
- package/src/versioned-signal.ts +3 -3
- package/dist/jsx-runtime.d.cts +0 -671
- package/dist/jsx-runtime.d.ts +0 -671
|
@@ -0,0 +1,3301 @@
|
|
|
1
|
+
// 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 = true ? false : typeof process === "undefined" || process.env?.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(prop2, tagName) {
|
|
208
|
+
if (!isDev) return void 0;
|
|
209
|
+
const a = PropAliases[prop2];
|
|
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 = isDev ? DelegatedEventNames : [];
|
|
217
|
+
var DelegatedEvents = new Set(delegatedEvents);
|
|
218
|
+
var svgElements = isDev ? [
|
|
219
|
+
"altGlyph",
|
|
220
|
+
"altGlyphDef",
|
|
221
|
+
"altGlyphItem",
|
|
222
|
+
"animate",
|
|
223
|
+
"animateColor",
|
|
224
|
+
"animateMotion",
|
|
225
|
+
"animateTransform",
|
|
226
|
+
"circle",
|
|
227
|
+
"clipPath",
|
|
228
|
+
"color-profile",
|
|
229
|
+
"cursor",
|
|
230
|
+
"defs",
|
|
231
|
+
"desc",
|
|
232
|
+
"ellipse",
|
|
233
|
+
"feBlend",
|
|
234
|
+
"feColorMatrix",
|
|
235
|
+
"feComponentTransfer",
|
|
236
|
+
"feComposite",
|
|
237
|
+
"feConvolveMatrix",
|
|
238
|
+
"feDiffuseLighting",
|
|
239
|
+
"feDisplacementMap",
|
|
240
|
+
"feDistantLight",
|
|
241
|
+
"feDropShadow",
|
|
242
|
+
"feFlood",
|
|
243
|
+
"feFuncA",
|
|
244
|
+
"feFuncB",
|
|
245
|
+
"feFuncG",
|
|
246
|
+
"feFuncR",
|
|
247
|
+
"feGaussianBlur",
|
|
248
|
+
"feImage",
|
|
249
|
+
"feMerge",
|
|
250
|
+
"feMergeNode",
|
|
251
|
+
"feMorphology",
|
|
252
|
+
"feOffset",
|
|
253
|
+
"fePointLight",
|
|
254
|
+
"feSpecularLighting",
|
|
255
|
+
"feSpotLight",
|
|
256
|
+
"feTile",
|
|
257
|
+
"feTurbulence",
|
|
258
|
+
"filter",
|
|
259
|
+
"font",
|
|
260
|
+
"font-face",
|
|
261
|
+
"font-face-format",
|
|
262
|
+
"font-face-name",
|
|
263
|
+
"font-face-src",
|
|
264
|
+
"font-face-uri",
|
|
265
|
+
"foreignObject",
|
|
266
|
+
"g",
|
|
267
|
+
"glyph",
|
|
268
|
+
"glyphRef",
|
|
269
|
+
"hkern",
|
|
270
|
+
"image",
|
|
271
|
+
"line",
|
|
272
|
+
"linearGradient",
|
|
273
|
+
"marker",
|
|
274
|
+
"mask",
|
|
275
|
+
"metadata",
|
|
276
|
+
"missing-glyph",
|
|
277
|
+
"mpath",
|
|
278
|
+
"path",
|
|
279
|
+
"pattern",
|
|
280
|
+
"polygon",
|
|
281
|
+
"polyline",
|
|
282
|
+
"radialGradient",
|
|
283
|
+
"rect",
|
|
284
|
+
"set",
|
|
285
|
+
"stop",
|
|
286
|
+
"svg",
|
|
287
|
+
"switch",
|
|
288
|
+
"symbol",
|
|
289
|
+
"text",
|
|
290
|
+
"textPath",
|
|
291
|
+
"tref",
|
|
292
|
+
"tspan",
|
|
293
|
+
"use",
|
|
294
|
+
"view",
|
|
295
|
+
"vkern"
|
|
296
|
+
] : [];
|
|
297
|
+
var SVGElements = new Set(svgElements);
|
|
298
|
+
var SVGNamespace = {
|
|
299
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
300
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
301
|
+
};
|
|
302
|
+
var unitlessList = isDev ? [
|
|
303
|
+
"animationIterationCount",
|
|
304
|
+
"animation-iteration-count",
|
|
305
|
+
"borderImageOutset",
|
|
306
|
+
"border-image-outset",
|
|
307
|
+
"borderImageSlice",
|
|
308
|
+
"border-image-slice",
|
|
309
|
+
"borderImageWidth",
|
|
310
|
+
"border-image-width",
|
|
311
|
+
"boxFlex",
|
|
312
|
+
"box-flex",
|
|
313
|
+
"boxFlexGroup",
|
|
314
|
+
"box-flex-group",
|
|
315
|
+
"boxOrdinalGroup",
|
|
316
|
+
"box-ordinal-group",
|
|
317
|
+
"columnCount",
|
|
318
|
+
"column-count",
|
|
319
|
+
"columns",
|
|
320
|
+
"flex",
|
|
321
|
+
"flexGrow",
|
|
322
|
+
"flex-grow",
|
|
323
|
+
"flexPositive",
|
|
324
|
+
"flex-positive",
|
|
325
|
+
"flexShrink",
|
|
326
|
+
"flex-shrink",
|
|
327
|
+
"flexNegative",
|
|
328
|
+
"flex-negative",
|
|
329
|
+
"flexOrder",
|
|
330
|
+
"flex-order",
|
|
331
|
+
"gridRow",
|
|
332
|
+
"grid-row",
|
|
333
|
+
"gridRowEnd",
|
|
334
|
+
"grid-row-end",
|
|
335
|
+
"gridRowSpan",
|
|
336
|
+
"grid-row-span",
|
|
337
|
+
"gridRowStart",
|
|
338
|
+
"grid-row-start",
|
|
339
|
+
"gridColumn",
|
|
340
|
+
"grid-column",
|
|
341
|
+
"gridColumnEnd",
|
|
342
|
+
"grid-column-end",
|
|
343
|
+
"gridColumnSpan",
|
|
344
|
+
"grid-column-span",
|
|
345
|
+
"gridColumnStart",
|
|
346
|
+
"grid-column-start",
|
|
347
|
+
"fontWeight",
|
|
348
|
+
"font-weight",
|
|
349
|
+
"lineClamp",
|
|
350
|
+
"line-clamp",
|
|
351
|
+
"lineHeight",
|
|
352
|
+
"line-height",
|
|
353
|
+
"opacity",
|
|
354
|
+
"order",
|
|
355
|
+
"orphans",
|
|
356
|
+
"tabSize",
|
|
357
|
+
"tab-size",
|
|
358
|
+
"widows",
|
|
359
|
+
"zIndex",
|
|
360
|
+
"z-index",
|
|
361
|
+
"zoom",
|
|
362
|
+
"fillOpacity",
|
|
363
|
+
"fill-opacity",
|
|
364
|
+
"floodOpacity",
|
|
365
|
+
"flood-opacity",
|
|
366
|
+
"stopOpacity",
|
|
367
|
+
"stop-opacity",
|
|
368
|
+
"strokeDasharray",
|
|
369
|
+
"stroke-dasharray",
|
|
370
|
+
"strokeDashoffset",
|
|
371
|
+
"stroke-dashoffset",
|
|
372
|
+
"strokeMiterlimit",
|
|
373
|
+
"stroke-miterlimit",
|
|
374
|
+
"strokeOpacity",
|
|
375
|
+
"stroke-opacity",
|
|
376
|
+
"strokeWidth",
|
|
377
|
+
"stroke-width"
|
|
378
|
+
] : ["opacity", "zIndex"];
|
|
379
|
+
var UnitlessStyles = new Set(unitlessList);
|
|
380
|
+
|
|
381
|
+
// src/devtools.ts
|
|
382
|
+
function getGlobalHook() {
|
|
383
|
+
if (typeof globalThis === "undefined") return void 0;
|
|
384
|
+
return globalThis.__FICT_DEVTOOLS_HOOK__;
|
|
385
|
+
}
|
|
386
|
+
function getDevtoolsHook() {
|
|
387
|
+
return getGlobalHook();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/cycle-guard.ts
|
|
391
|
+
var isDev2 = true ? false : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
392
|
+
var setCycleProtectionOptions = () => {
|
|
393
|
+
};
|
|
394
|
+
var resetCycleProtectionStateForTests = () => {
|
|
395
|
+
};
|
|
396
|
+
var beginFlushGuard = () => {
|
|
397
|
+
};
|
|
398
|
+
var beforeEffectRunGuard = () => true;
|
|
399
|
+
var endFlushGuard = () => {
|
|
400
|
+
};
|
|
401
|
+
var enterRootGuard = () => true;
|
|
402
|
+
var exitRootGuard = () => {
|
|
403
|
+
};
|
|
404
|
+
if (isDev2) {
|
|
405
|
+
const defaultOptions = {
|
|
406
|
+
maxFlushCyclesPerMicrotask: 1e4,
|
|
407
|
+
maxEffectRunsPerFlush: 2e4,
|
|
408
|
+
windowSize: 5,
|
|
409
|
+
highUsageRatio: 0.8,
|
|
410
|
+
maxRootReentrantDepth: 10,
|
|
411
|
+
enableWindowWarning: true,
|
|
412
|
+
devMode: false
|
|
413
|
+
};
|
|
414
|
+
let options = {
|
|
415
|
+
...defaultOptions
|
|
416
|
+
};
|
|
417
|
+
let effectRunsThisFlush = 0;
|
|
418
|
+
let windowUsage = [];
|
|
419
|
+
let rootDepth = /* @__PURE__ */ new WeakMap();
|
|
420
|
+
let flushWarned = false;
|
|
421
|
+
let rootWarned = false;
|
|
422
|
+
let windowWarned = false;
|
|
423
|
+
setCycleProtectionOptions = (opts) => {
|
|
424
|
+
options = { ...options, ...opts };
|
|
425
|
+
};
|
|
426
|
+
resetCycleProtectionStateForTests = () => {
|
|
427
|
+
options = { ...defaultOptions };
|
|
428
|
+
effectRunsThisFlush = 0;
|
|
429
|
+
windowUsage = [];
|
|
430
|
+
rootDepth = /* @__PURE__ */ new WeakMap();
|
|
431
|
+
flushWarned = false;
|
|
432
|
+
rootWarned = false;
|
|
433
|
+
windowWarned = false;
|
|
434
|
+
};
|
|
435
|
+
beginFlushGuard = () => {
|
|
436
|
+
effectRunsThisFlush = 0;
|
|
437
|
+
flushWarned = false;
|
|
438
|
+
windowWarned = false;
|
|
439
|
+
};
|
|
440
|
+
beforeEffectRunGuard = () => {
|
|
441
|
+
const next = ++effectRunsThisFlush;
|
|
442
|
+
if (next > options.maxFlushCyclesPerMicrotask || next > options.maxEffectRunsPerFlush) {
|
|
443
|
+
const message = `[fict] cycle protection triggered: flush-budget-exceeded`;
|
|
444
|
+
if (options.devMode) {
|
|
445
|
+
throw new Error(message);
|
|
446
|
+
}
|
|
447
|
+
if (!flushWarned) {
|
|
448
|
+
flushWarned = true;
|
|
449
|
+
console.warn(message, { effectRuns: next });
|
|
450
|
+
}
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
return true;
|
|
454
|
+
};
|
|
455
|
+
endFlushGuard = () => {
|
|
456
|
+
recordWindowUsage(effectRunsThisFlush, options.maxFlushCyclesPerMicrotask);
|
|
457
|
+
effectRunsThisFlush = 0;
|
|
458
|
+
};
|
|
459
|
+
enterRootGuard = (root) => {
|
|
460
|
+
const depth = (rootDepth.get(root) ?? 0) + 1;
|
|
461
|
+
if (depth > options.maxRootReentrantDepth) {
|
|
462
|
+
const message = `[fict] cycle protection triggered: root-reentry`;
|
|
463
|
+
if (options.devMode) {
|
|
464
|
+
throw new Error(message);
|
|
465
|
+
}
|
|
466
|
+
if (!rootWarned) {
|
|
467
|
+
rootWarned = true;
|
|
468
|
+
console.warn(message, { depth });
|
|
469
|
+
}
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
rootDepth.set(root, depth);
|
|
473
|
+
return true;
|
|
474
|
+
};
|
|
475
|
+
exitRootGuard = (root) => {
|
|
476
|
+
const depth = rootDepth.get(root);
|
|
477
|
+
if (depth === void 0) return;
|
|
478
|
+
if (depth <= 1) {
|
|
479
|
+
rootDepth.delete(root);
|
|
480
|
+
} else {
|
|
481
|
+
rootDepth.set(root, depth - 1);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
const recordWindowUsage = (used, budget) => {
|
|
485
|
+
if (!options.enableWindowWarning) return;
|
|
486
|
+
const entry = { used, budget };
|
|
487
|
+
windowUsage.push(entry);
|
|
488
|
+
if (windowUsage.length > options.windowSize) {
|
|
489
|
+
windowUsage.shift();
|
|
490
|
+
}
|
|
491
|
+
if (windowWarned) return;
|
|
492
|
+
if (windowUsage.length >= options.windowSize && windowUsage.every(
|
|
493
|
+
(item) => item.budget > 0 && item.used / item.budget >= options.highUsageRatio
|
|
494
|
+
)) {
|
|
495
|
+
windowWarned = true;
|
|
496
|
+
reportCycle("high-usage-window", {
|
|
497
|
+
windowSize: options.windowSize,
|
|
498
|
+
ratio: options.highUsageRatio
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
const reportCycle = (reason, detail = void 0) => {
|
|
503
|
+
const hook = getDevtoolsHook();
|
|
504
|
+
hook?.cycleDetected?.(detail ? { reason, detail } : { reason });
|
|
505
|
+
console.warn(`[fict] cycle protection triggered: ${reason}`, detail ?? "");
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// src/lifecycle.ts
|
|
510
|
+
var isDev3 = true ? false : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
511
|
+
var currentRoot;
|
|
512
|
+
var currentEffectCleanups;
|
|
513
|
+
var globalErrorHandlers = /* @__PURE__ */ new WeakMap();
|
|
514
|
+
var globalSuspenseHandlers = /* @__PURE__ */ new WeakMap();
|
|
515
|
+
function createRootContext(parent = currentRoot) {
|
|
516
|
+
return { parent, cleanups: [], destroyCallbacks: [] };
|
|
517
|
+
}
|
|
518
|
+
function pushRoot(root) {
|
|
519
|
+
if (!enterRootGuard(root)) {
|
|
520
|
+
return currentRoot;
|
|
521
|
+
}
|
|
522
|
+
const prev = currentRoot;
|
|
523
|
+
currentRoot = root;
|
|
524
|
+
return prev;
|
|
525
|
+
}
|
|
526
|
+
function getCurrentRoot() {
|
|
527
|
+
return currentRoot;
|
|
528
|
+
}
|
|
529
|
+
function popRoot(prev) {
|
|
530
|
+
if (currentRoot) {
|
|
531
|
+
exitRootGuard(currentRoot);
|
|
532
|
+
}
|
|
533
|
+
currentRoot = prev;
|
|
534
|
+
}
|
|
535
|
+
function onMount(fn) {
|
|
536
|
+
if (currentRoot) {
|
|
537
|
+
;
|
|
538
|
+
(currentRoot.onMountCallbacks || (currentRoot.onMountCallbacks = [])).push(fn);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
runLifecycle(fn);
|
|
542
|
+
}
|
|
543
|
+
function onDestroy(fn) {
|
|
544
|
+
if (currentRoot) {
|
|
545
|
+
currentRoot.destroyCallbacks.push(() => runLifecycle(fn));
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
runLifecycle(fn);
|
|
549
|
+
}
|
|
550
|
+
function onCleanup(fn) {
|
|
551
|
+
registerEffectCleanup(fn);
|
|
552
|
+
}
|
|
553
|
+
function flushOnMount(root) {
|
|
554
|
+
const cbs = root.onMountCallbacks;
|
|
555
|
+
if (!cbs || cbs.length === 0) return;
|
|
556
|
+
for (let i = 0; i < cbs.length; i++) {
|
|
557
|
+
const cleanup = cbs[i]();
|
|
558
|
+
if (typeof cleanup === "function") {
|
|
559
|
+
root.cleanups.push(cleanup);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
cbs.length = 0;
|
|
563
|
+
}
|
|
564
|
+
function registerRootCleanup(fn) {
|
|
565
|
+
if (currentRoot) {
|
|
566
|
+
currentRoot.cleanups.push(fn);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
function clearRoot(root) {
|
|
570
|
+
runCleanupList(root.cleanups);
|
|
571
|
+
if (root.onMountCallbacks) {
|
|
572
|
+
root.onMountCallbacks.length = 0;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function destroyRoot(root) {
|
|
576
|
+
clearRoot(root);
|
|
577
|
+
runCleanupList(root.destroyCallbacks);
|
|
578
|
+
if (root.errorHandlers) {
|
|
579
|
+
root.errorHandlers.length = 0;
|
|
580
|
+
}
|
|
581
|
+
if (globalErrorHandlers.has(root)) {
|
|
582
|
+
globalErrorHandlers.delete(root);
|
|
583
|
+
}
|
|
584
|
+
if (root.suspenseHandlers) {
|
|
585
|
+
root.suspenseHandlers.length = 0;
|
|
586
|
+
}
|
|
587
|
+
if (globalSuspenseHandlers.has(root)) {
|
|
588
|
+
globalSuspenseHandlers.delete(root);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
function createRoot(fn) {
|
|
592
|
+
const root = createRootContext();
|
|
593
|
+
const prev = pushRoot(root);
|
|
594
|
+
let value;
|
|
595
|
+
try {
|
|
596
|
+
value = fn();
|
|
597
|
+
} finally {
|
|
598
|
+
popRoot(prev);
|
|
599
|
+
}
|
|
600
|
+
flushOnMount(root);
|
|
601
|
+
return {
|
|
602
|
+
dispose: () => destroyRoot(root),
|
|
603
|
+
value
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function withEffectCleanups(bucket, fn) {
|
|
607
|
+
const prev = currentEffectCleanups;
|
|
608
|
+
currentEffectCleanups = bucket;
|
|
609
|
+
try {
|
|
610
|
+
return fn();
|
|
611
|
+
} finally {
|
|
612
|
+
currentEffectCleanups = prev;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function registerEffectCleanup(fn) {
|
|
616
|
+
if (currentEffectCleanups) {
|
|
617
|
+
currentEffectCleanups.push(fn);
|
|
618
|
+
} else {
|
|
619
|
+
registerRootCleanup(fn);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function runCleanupList(list) {
|
|
623
|
+
let error;
|
|
624
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
625
|
+
try {
|
|
626
|
+
const cleanup = list[i];
|
|
627
|
+
if (cleanup) cleanup();
|
|
628
|
+
} catch (err) {
|
|
629
|
+
if (error === void 0) {
|
|
630
|
+
error = err;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
list.length = 0;
|
|
635
|
+
if (error !== void 0) {
|
|
636
|
+
if (!handleError(error, { source: "cleanup" })) {
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function runLifecycle(fn) {
|
|
642
|
+
const cleanup = fn();
|
|
643
|
+
if (typeof cleanup === "function") {
|
|
644
|
+
cleanup();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function registerErrorHandler(fn) {
|
|
648
|
+
if (!currentRoot) {
|
|
649
|
+
const message = isDev3 ? "registerErrorHandler must be called within a root" : "FICT:E_ROOT_HANDLER";
|
|
650
|
+
throw new Error(message);
|
|
651
|
+
}
|
|
652
|
+
if (!currentRoot.errorHandlers) {
|
|
653
|
+
currentRoot.errorHandlers = [];
|
|
654
|
+
}
|
|
655
|
+
currentRoot.errorHandlers.push(fn);
|
|
656
|
+
const existing = globalErrorHandlers.get(currentRoot);
|
|
657
|
+
if (existing) {
|
|
658
|
+
existing.push(fn);
|
|
659
|
+
} else {
|
|
660
|
+
globalErrorHandlers.set(currentRoot, [fn]);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function registerSuspenseHandler(fn) {
|
|
664
|
+
if (!currentRoot) {
|
|
665
|
+
const message = isDev3 ? "registerSuspenseHandler must be called within a root" : "FICT:E_ROOT_SUSPENSE";
|
|
666
|
+
throw new Error(message);
|
|
667
|
+
}
|
|
668
|
+
if (!currentRoot.suspenseHandlers) {
|
|
669
|
+
currentRoot.suspenseHandlers = [];
|
|
670
|
+
}
|
|
671
|
+
currentRoot.suspenseHandlers.push(fn);
|
|
672
|
+
const existing = globalSuspenseHandlers.get(currentRoot);
|
|
673
|
+
if (existing) {
|
|
674
|
+
existing.push(fn);
|
|
675
|
+
} else {
|
|
676
|
+
globalSuspenseHandlers.set(currentRoot, [fn]);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function handleError(err, info, startRoot) {
|
|
680
|
+
let root = startRoot ?? currentRoot;
|
|
681
|
+
let error = err;
|
|
682
|
+
while (root) {
|
|
683
|
+
const handlers = root.errorHandlers;
|
|
684
|
+
if (handlers && handlers.length) {
|
|
685
|
+
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
686
|
+
const handler = handlers[i];
|
|
687
|
+
try {
|
|
688
|
+
const handled = handler(error, info);
|
|
689
|
+
if (handled !== false) {
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
} catch (nextErr) {
|
|
693
|
+
error = nextErr;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
root = root.parent;
|
|
698
|
+
}
|
|
699
|
+
const globalForRoot = startRoot ? globalErrorHandlers.get(startRoot) : currentRoot ? globalErrorHandlers.get(currentRoot) : void 0;
|
|
700
|
+
if (globalForRoot && globalForRoot.length) {
|
|
701
|
+
for (let i = globalForRoot.length - 1; i >= 0; i--) {
|
|
702
|
+
const handler = globalForRoot[i];
|
|
703
|
+
try {
|
|
704
|
+
const handled = handler(error, info);
|
|
705
|
+
if (handled !== false) {
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
} catch (nextErr) {
|
|
709
|
+
error = nextErr;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
function handleSuspend(token, startRoot) {
|
|
716
|
+
let root = startRoot ?? currentRoot;
|
|
717
|
+
while (root) {
|
|
718
|
+
const handlers = root.suspenseHandlers;
|
|
719
|
+
if (handlers && handlers.length) {
|
|
720
|
+
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
721
|
+
const handler = handlers[i];
|
|
722
|
+
const handled = handler(token);
|
|
723
|
+
if (handled !== false) return true;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
root = root.parent;
|
|
727
|
+
}
|
|
728
|
+
const globalForRoot = startRoot && globalSuspenseHandlers.get(startRoot) ? globalSuspenseHandlers.get(startRoot) : currentRoot ? globalSuspenseHandlers.get(currentRoot) : void 0;
|
|
729
|
+
if (globalForRoot && globalForRoot.length) {
|
|
730
|
+
for (let i = globalForRoot.length - 1; i >= 0; i--) {
|
|
731
|
+
const handler = globalForRoot[i];
|
|
732
|
+
const handled = handler(token);
|
|
733
|
+
if (handled !== false) return true;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// src/signal.ts
|
|
740
|
+
var isDev4 = true ? false : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
741
|
+
var Mutable = 1;
|
|
742
|
+
var Watching = 2;
|
|
743
|
+
var Running = 4;
|
|
744
|
+
var Recursed = 8;
|
|
745
|
+
var Dirty = 16;
|
|
746
|
+
var Pending = 32;
|
|
747
|
+
var MutableDirty = 17;
|
|
748
|
+
var MutablePending = 33;
|
|
749
|
+
var MutableRunning = 5;
|
|
750
|
+
var WatchingRunning = 6;
|
|
751
|
+
var cycle = 0;
|
|
752
|
+
var batchDepth = 0;
|
|
753
|
+
var activeSub;
|
|
754
|
+
var flushScheduled = false;
|
|
755
|
+
var highPriorityQueue = [];
|
|
756
|
+
var lowPriorityQueue = [];
|
|
757
|
+
var isInTransition = false;
|
|
758
|
+
var enqueueMicrotask = typeof queueMicrotask === "function" ? queueMicrotask : (fn) => {
|
|
759
|
+
Promise.resolve().then(fn);
|
|
760
|
+
};
|
|
761
|
+
var inCleanup = false;
|
|
762
|
+
var SIGNAL_MARKER = Symbol.for("fict:signal");
|
|
763
|
+
var COMPUTED_MARKER = Symbol.for("fict:computed");
|
|
764
|
+
var EFFECT_MARKER = Symbol.for("fict:effect");
|
|
765
|
+
var EFFECT_SCOPE_MARKER = Symbol.for("fict:effectScope");
|
|
766
|
+
function link(dep, sub, version) {
|
|
767
|
+
const prevDep = sub.depsTail;
|
|
768
|
+
if (prevDep !== void 0 && prevDep.dep === dep) return;
|
|
769
|
+
const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
|
|
770
|
+
if (nextDep !== void 0 && nextDep.dep === dep) {
|
|
771
|
+
nextDep.version = version;
|
|
772
|
+
sub.depsTail = nextDep;
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
const prevSub = dep.subsTail;
|
|
776
|
+
if (prevSub !== void 0 && prevSub.version === version && prevSub.sub === sub) return;
|
|
777
|
+
const newLink = { version, dep, sub, prevDep, nextDep, prevSub, nextSub: void 0 };
|
|
778
|
+
sub.depsTail = newLink;
|
|
779
|
+
dep.subsTail = newLink;
|
|
780
|
+
if (nextDep !== void 0) nextDep.prevDep = newLink;
|
|
781
|
+
if (prevDep !== void 0) prevDep.nextDep = newLink;
|
|
782
|
+
else sub.deps = newLink;
|
|
783
|
+
if (prevSub !== void 0) prevSub.nextSub = newLink;
|
|
784
|
+
else dep.subs = newLink;
|
|
785
|
+
}
|
|
786
|
+
function unlink(lnk, sub = lnk.sub) {
|
|
787
|
+
const dep = lnk.dep;
|
|
788
|
+
const prevDep = lnk.prevDep;
|
|
789
|
+
const nextDep = lnk.nextDep;
|
|
790
|
+
const nextSub = lnk.nextSub;
|
|
791
|
+
const prevSub = lnk.prevSub;
|
|
792
|
+
if (nextDep !== void 0) nextDep.prevDep = prevDep;
|
|
793
|
+
else sub.depsTail = prevDep;
|
|
794
|
+
if (prevDep !== void 0) prevDep.nextDep = nextDep;
|
|
795
|
+
else sub.deps = nextDep;
|
|
796
|
+
if (nextSub !== void 0) nextSub.prevSub = prevSub;
|
|
797
|
+
else dep.subsTail = prevSub;
|
|
798
|
+
if (prevSub !== void 0) prevSub.nextSub = nextSub;
|
|
799
|
+
else if ((dep.subs = nextSub) === void 0) unwatched(dep);
|
|
800
|
+
return nextDep;
|
|
801
|
+
}
|
|
802
|
+
function unwatched(dep) {
|
|
803
|
+
if (!(dep.flags & Mutable)) {
|
|
804
|
+
disposeNode(dep);
|
|
805
|
+
} else if ("getter" in dep && dep.getter !== void 0) {
|
|
806
|
+
dep.depsTail = void 0;
|
|
807
|
+
dep.flags = MutableDirty;
|
|
808
|
+
purgeDeps(dep);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function propagate(firstLink) {
|
|
812
|
+
let link2 = firstLink;
|
|
813
|
+
let next = link2.nextSub;
|
|
814
|
+
let stack;
|
|
815
|
+
top: for (; ; ) {
|
|
816
|
+
const sub = link2.sub;
|
|
817
|
+
let flags = sub.flags;
|
|
818
|
+
if (!(flags & 60)) {
|
|
819
|
+
sub.flags = flags | Pending;
|
|
820
|
+
} else if (!(flags & 12)) {
|
|
821
|
+
flags = 0;
|
|
822
|
+
} else if (!(flags & Running)) {
|
|
823
|
+
sub.flags = flags & ~Recursed | Pending;
|
|
824
|
+
} else if (!(flags & 48)) {
|
|
825
|
+
let vlink = sub.depsTail;
|
|
826
|
+
let valid = false;
|
|
827
|
+
while (vlink !== void 0) {
|
|
828
|
+
if (vlink === link2) {
|
|
829
|
+
valid = true;
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
vlink = vlink.prevDep;
|
|
833
|
+
}
|
|
834
|
+
if (valid) {
|
|
835
|
+
sub.flags = flags | 40;
|
|
836
|
+
flags &= Mutable;
|
|
837
|
+
} else {
|
|
838
|
+
flags = 0;
|
|
839
|
+
}
|
|
840
|
+
} else {
|
|
841
|
+
flags = 0;
|
|
842
|
+
}
|
|
843
|
+
if (flags & Watching) notify(sub);
|
|
844
|
+
if (flags & Mutable) {
|
|
845
|
+
const subSubs = sub.subs;
|
|
846
|
+
if (subSubs !== void 0) {
|
|
847
|
+
const nextSub = subSubs.nextSub;
|
|
848
|
+
if (nextSub !== void 0) {
|
|
849
|
+
stack = { value: next, prev: stack };
|
|
850
|
+
next = nextSub;
|
|
851
|
+
}
|
|
852
|
+
link2 = subSubs;
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (next !== void 0) {
|
|
857
|
+
link2 = next;
|
|
858
|
+
next = link2.nextSub;
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
while (stack !== void 0) {
|
|
862
|
+
link2 = stack.value;
|
|
863
|
+
stack = stack.prev;
|
|
864
|
+
if (link2 !== void 0) {
|
|
865
|
+
next = link2.nextSub;
|
|
866
|
+
continue top;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function checkDirty(firstLink, sub) {
|
|
873
|
+
let link2 = firstLink;
|
|
874
|
+
let stack;
|
|
875
|
+
let checkDepth = 0;
|
|
876
|
+
let dirty = false;
|
|
877
|
+
top: for (; ; ) {
|
|
878
|
+
const dep = link2.dep;
|
|
879
|
+
const depFlags = dep.flags;
|
|
880
|
+
if (sub.flags & Dirty) {
|
|
881
|
+
dirty = true;
|
|
882
|
+
} else if ((depFlags & MutableDirty) === MutableDirty) {
|
|
883
|
+
if (update(dep)) {
|
|
884
|
+
const subs = dep.subs;
|
|
885
|
+
if (subs !== void 0 && subs.nextSub !== void 0) shallowPropagate(subs);
|
|
886
|
+
dirty = true;
|
|
887
|
+
}
|
|
888
|
+
} else if ((depFlags & MutablePending) === MutablePending) {
|
|
889
|
+
if (!dep.deps) {
|
|
890
|
+
const nextDep = link2.nextDep;
|
|
891
|
+
if (nextDep !== void 0) {
|
|
892
|
+
link2 = nextDep;
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
} else {
|
|
896
|
+
if (link2.nextSub !== void 0 || link2.prevSub !== void 0) {
|
|
897
|
+
stack = { value: link2, prev: stack };
|
|
898
|
+
}
|
|
899
|
+
link2 = dep.deps;
|
|
900
|
+
sub = dep;
|
|
901
|
+
++checkDepth;
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
if (!dirty) {
|
|
906
|
+
const nextDep = link2.nextDep;
|
|
907
|
+
if (nextDep !== void 0) {
|
|
908
|
+
link2 = nextDep;
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
while (checkDepth-- > 0) {
|
|
913
|
+
const firstSub = sub.subs;
|
|
914
|
+
const hasMultipleSubs = firstSub.nextSub !== void 0;
|
|
915
|
+
if (hasMultipleSubs) {
|
|
916
|
+
link2 = stack.value;
|
|
917
|
+
stack = stack.prev;
|
|
918
|
+
} else {
|
|
919
|
+
link2 = firstSub;
|
|
920
|
+
}
|
|
921
|
+
if (dirty) {
|
|
922
|
+
if (update(sub)) {
|
|
923
|
+
if (hasMultipleSubs) shallowPropagate(firstSub);
|
|
924
|
+
sub = link2.sub;
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
dirty = false;
|
|
928
|
+
} else {
|
|
929
|
+
sub.flags &= ~Pending;
|
|
930
|
+
}
|
|
931
|
+
sub = link2.sub;
|
|
932
|
+
const nextDep = link2.nextDep;
|
|
933
|
+
if (nextDep !== void 0) {
|
|
934
|
+
link2 = nextDep;
|
|
935
|
+
continue top;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return dirty;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
function shallowPropagate(firstLink) {
|
|
942
|
+
let link2 = firstLink;
|
|
943
|
+
do {
|
|
944
|
+
const sub = link2.sub;
|
|
945
|
+
const flags = sub.flags;
|
|
946
|
+
if ((flags & 48) === Pending) {
|
|
947
|
+
sub.flags = flags | Dirty;
|
|
948
|
+
if ((flags & 6) === Watching) notify(sub);
|
|
949
|
+
}
|
|
950
|
+
link2 = link2.nextSub;
|
|
951
|
+
} while (link2 !== void 0);
|
|
952
|
+
}
|
|
953
|
+
function update(node) {
|
|
954
|
+
return "getter" in node && node.getter !== void 0 ? updateComputed(node) : updateSignal(node);
|
|
955
|
+
}
|
|
956
|
+
function notify(effect2) {
|
|
957
|
+
effect2.flags &= ~Watching;
|
|
958
|
+
const effects = [];
|
|
959
|
+
for (; ; ) {
|
|
960
|
+
effects.push(effect2);
|
|
961
|
+
const nextLink = effect2.subs;
|
|
962
|
+
if (nextLink === void 0) break;
|
|
963
|
+
effect2 = nextLink.sub;
|
|
964
|
+
if (effect2 === void 0 || !(effect2.flags & Watching)) break;
|
|
965
|
+
effect2.flags &= ~Watching;
|
|
966
|
+
}
|
|
967
|
+
const targetQueue = isInTransition ? lowPriorityQueue : highPriorityQueue;
|
|
968
|
+
for (let i = effects.length - 1; i >= 0; i--) {
|
|
969
|
+
targetQueue.push(effects[i]);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
function purgeDeps(sub) {
|
|
973
|
+
const depsTail = sub.depsTail;
|
|
974
|
+
let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
975
|
+
while (dep !== void 0) dep = unlink(dep, sub);
|
|
976
|
+
}
|
|
977
|
+
function disposeNode(node) {
|
|
978
|
+
node.depsTail = void 0;
|
|
979
|
+
node.flags = 0;
|
|
980
|
+
purgeDeps(node);
|
|
981
|
+
let sub = node.subs;
|
|
982
|
+
while (sub !== void 0) {
|
|
983
|
+
const next = sub.nextSub;
|
|
984
|
+
unlink(sub);
|
|
985
|
+
sub = next;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
function updateSignal(s) {
|
|
989
|
+
s.flags = Mutable;
|
|
990
|
+
const current = s.currentValue;
|
|
991
|
+
const pending = s.pendingValue;
|
|
992
|
+
if (current !== pending) {
|
|
993
|
+
s.currentValue = pending;
|
|
994
|
+
return true;
|
|
995
|
+
}
|
|
996
|
+
return false;
|
|
997
|
+
}
|
|
998
|
+
function updateComputed(c) {
|
|
999
|
+
++cycle;
|
|
1000
|
+
const oldValue = c.value;
|
|
1001
|
+
c.depsTail = void 0;
|
|
1002
|
+
c.flags = MutableRunning;
|
|
1003
|
+
const prevSub = activeSub;
|
|
1004
|
+
activeSub = c;
|
|
1005
|
+
try {
|
|
1006
|
+
const newValue = c.getter(oldValue);
|
|
1007
|
+
activeSub = prevSub;
|
|
1008
|
+
c.flags &= ~Running;
|
|
1009
|
+
purgeDeps(c);
|
|
1010
|
+
if (oldValue !== newValue) {
|
|
1011
|
+
c.value = newValue;
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
return false;
|
|
1015
|
+
} catch (e) {
|
|
1016
|
+
activeSub = prevSub;
|
|
1017
|
+
c.flags &= ~Running;
|
|
1018
|
+
throw e;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function runEffect(e) {
|
|
1022
|
+
const flags = e.flags;
|
|
1023
|
+
if (flags & Dirty) {
|
|
1024
|
+
if (e.runCleanup) {
|
|
1025
|
+
inCleanup = true;
|
|
1026
|
+
try {
|
|
1027
|
+
e.runCleanup();
|
|
1028
|
+
} finally {
|
|
1029
|
+
inCleanup = false;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
++cycle;
|
|
1033
|
+
effectRunDevtools(e);
|
|
1034
|
+
e.depsTail = void 0;
|
|
1035
|
+
e.flags = WatchingRunning;
|
|
1036
|
+
const prevSub = activeSub;
|
|
1037
|
+
activeSub = e;
|
|
1038
|
+
try {
|
|
1039
|
+
e.fn();
|
|
1040
|
+
activeSub = prevSub;
|
|
1041
|
+
e.flags = Watching;
|
|
1042
|
+
purgeDeps(e);
|
|
1043
|
+
} catch (err) {
|
|
1044
|
+
activeSub = prevSub;
|
|
1045
|
+
e.flags = Watching;
|
|
1046
|
+
throw err;
|
|
1047
|
+
}
|
|
1048
|
+
} else if (flags & Pending && e.deps) {
|
|
1049
|
+
if (e.runCleanup) {
|
|
1050
|
+
inCleanup = true;
|
|
1051
|
+
try {
|
|
1052
|
+
e.runCleanup();
|
|
1053
|
+
} finally {
|
|
1054
|
+
inCleanup = false;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (checkDirty(e.deps, e)) {
|
|
1058
|
+
++cycle;
|
|
1059
|
+
effectRunDevtools(e);
|
|
1060
|
+
e.depsTail = void 0;
|
|
1061
|
+
e.flags = WatchingRunning;
|
|
1062
|
+
const prevSub = activeSub;
|
|
1063
|
+
activeSub = e;
|
|
1064
|
+
try {
|
|
1065
|
+
e.fn();
|
|
1066
|
+
activeSub = prevSub;
|
|
1067
|
+
e.flags = Watching;
|
|
1068
|
+
purgeDeps(e);
|
|
1069
|
+
} catch (err) {
|
|
1070
|
+
activeSub = prevSub;
|
|
1071
|
+
e.flags = Watching;
|
|
1072
|
+
throw err;
|
|
1073
|
+
}
|
|
1074
|
+
} else {
|
|
1075
|
+
e.flags = Watching;
|
|
1076
|
+
}
|
|
1077
|
+
} else {
|
|
1078
|
+
e.flags = Watching;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
function scheduleFlush() {
|
|
1082
|
+
const hasWork = highPriorityQueue.length > 0 || lowPriorityQueue.length > 0;
|
|
1083
|
+
if (flushScheduled || !hasWork) return;
|
|
1084
|
+
if (batchDepth > 0) return;
|
|
1085
|
+
flushScheduled = true;
|
|
1086
|
+
enqueueMicrotask(() => {
|
|
1087
|
+
flush();
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
function flush() {
|
|
1091
|
+
beginFlushGuard();
|
|
1092
|
+
if (batchDepth > 0) {
|
|
1093
|
+
scheduleFlush();
|
|
1094
|
+
endFlushGuard();
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const hasWork = highPriorityQueue.length > 0 || lowPriorityQueue.length > 0;
|
|
1098
|
+
if (!hasWork) {
|
|
1099
|
+
flushScheduled = false;
|
|
1100
|
+
endFlushGuard();
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
flushScheduled = false;
|
|
1104
|
+
let highIndex = 0;
|
|
1105
|
+
while (highIndex < highPriorityQueue.length) {
|
|
1106
|
+
const e = highPriorityQueue[highIndex];
|
|
1107
|
+
if (!beforeEffectRunGuard()) {
|
|
1108
|
+
if (highIndex > 0) {
|
|
1109
|
+
highPriorityQueue.copyWithin(0, highIndex);
|
|
1110
|
+
highPriorityQueue.length -= highIndex;
|
|
1111
|
+
}
|
|
1112
|
+
endFlushGuard();
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
highIndex++;
|
|
1116
|
+
runEffect(e);
|
|
1117
|
+
}
|
|
1118
|
+
highPriorityQueue.length = 0;
|
|
1119
|
+
let lowIndex = 0;
|
|
1120
|
+
while (lowIndex < lowPriorityQueue.length) {
|
|
1121
|
+
if (highPriorityQueue.length > 0) {
|
|
1122
|
+
if (lowIndex > 0) {
|
|
1123
|
+
lowPriorityQueue.copyWithin(0, lowIndex);
|
|
1124
|
+
lowPriorityQueue.length -= lowIndex;
|
|
1125
|
+
}
|
|
1126
|
+
scheduleFlush();
|
|
1127
|
+
endFlushGuard();
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
const e = lowPriorityQueue[lowIndex];
|
|
1131
|
+
if (!beforeEffectRunGuard()) {
|
|
1132
|
+
if (lowIndex > 0) {
|
|
1133
|
+
lowPriorityQueue.copyWithin(0, lowIndex);
|
|
1134
|
+
lowPriorityQueue.length -= lowIndex;
|
|
1135
|
+
}
|
|
1136
|
+
endFlushGuard();
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
lowIndex++;
|
|
1140
|
+
runEffect(e);
|
|
1141
|
+
}
|
|
1142
|
+
lowPriorityQueue.length = 0;
|
|
1143
|
+
endFlushGuard();
|
|
1144
|
+
}
|
|
1145
|
+
function signal(initialValue) {
|
|
1146
|
+
const s = {
|
|
1147
|
+
currentValue: initialValue,
|
|
1148
|
+
pendingValue: initialValue,
|
|
1149
|
+
subs: void 0,
|
|
1150
|
+
subsTail: void 0,
|
|
1151
|
+
flags: Mutable,
|
|
1152
|
+
__id: void 0
|
|
1153
|
+
};
|
|
1154
|
+
registerSignalDevtools(initialValue, s);
|
|
1155
|
+
const accessor = signalOper.bind(s);
|
|
1156
|
+
accessor[SIGNAL_MARKER] = true;
|
|
1157
|
+
return accessor;
|
|
1158
|
+
}
|
|
1159
|
+
function signalOper(value) {
|
|
1160
|
+
if (arguments.length > 0) {
|
|
1161
|
+
if (this.pendingValue !== value) {
|
|
1162
|
+
this.pendingValue = value;
|
|
1163
|
+
this.flags = MutableDirty;
|
|
1164
|
+
updateSignalDevtools(this, value);
|
|
1165
|
+
const subs = this.subs;
|
|
1166
|
+
if (subs !== void 0) {
|
|
1167
|
+
propagate(subs);
|
|
1168
|
+
if (!batchDepth) scheduleFlush();
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
const flags = this.flags;
|
|
1174
|
+
if (flags & Dirty && !inCleanup) {
|
|
1175
|
+
if (updateSignal(this)) {
|
|
1176
|
+
const subs = this.subs;
|
|
1177
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
let sub = activeSub;
|
|
1181
|
+
while (sub !== void 0) {
|
|
1182
|
+
if (sub.flags & 3) {
|
|
1183
|
+
link(this, sub, cycle);
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
const subSubs = sub.subs;
|
|
1187
|
+
sub = subSubs !== void 0 ? subSubs.sub : void 0;
|
|
1188
|
+
}
|
|
1189
|
+
return this.currentValue;
|
|
1190
|
+
}
|
|
1191
|
+
function computed(getter) {
|
|
1192
|
+
const c = {
|
|
1193
|
+
value: void 0,
|
|
1194
|
+
subs: void 0,
|
|
1195
|
+
subsTail: void 0,
|
|
1196
|
+
deps: void 0,
|
|
1197
|
+
depsTail: void 0,
|
|
1198
|
+
flags: 0,
|
|
1199
|
+
getter
|
|
1200
|
+
};
|
|
1201
|
+
const bound = computedOper.bind(c);
|
|
1202
|
+
bound[COMPUTED_MARKER] = true;
|
|
1203
|
+
return bound;
|
|
1204
|
+
}
|
|
1205
|
+
function computedOper() {
|
|
1206
|
+
const flags = this.flags;
|
|
1207
|
+
if (flags & Dirty) {
|
|
1208
|
+
if (updateComputed(this)) {
|
|
1209
|
+
const subs = this.subs;
|
|
1210
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1211
|
+
}
|
|
1212
|
+
} else if (flags & Pending) {
|
|
1213
|
+
if (this.deps && checkDirty(this.deps, this)) {
|
|
1214
|
+
if (updateComputed(this)) {
|
|
1215
|
+
const subs = this.subs;
|
|
1216
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1217
|
+
}
|
|
1218
|
+
} else {
|
|
1219
|
+
this.flags = flags & ~Pending;
|
|
1220
|
+
}
|
|
1221
|
+
} else if (!flags) {
|
|
1222
|
+
this.flags = MutableRunning;
|
|
1223
|
+
const prevSub = setActiveSub(this);
|
|
1224
|
+
try {
|
|
1225
|
+
this.value = this.getter(void 0);
|
|
1226
|
+
} finally {
|
|
1227
|
+
setActiveSub(prevSub);
|
|
1228
|
+
this.flags &= ~Running;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
if (activeSub !== void 0) link(this, activeSub, cycle);
|
|
1232
|
+
return this.value;
|
|
1233
|
+
}
|
|
1234
|
+
function effect(fn) {
|
|
1235
|
+
const e = {
|
|
1236
|
+
fn,
|
|
1237
|
+
subs: void 0,
|
|
1238
|
+
subsTail: void 0,
|
|
1239
|
+
deps: void 0,
|
|
1240
|
+
depsTail: void 0,
|
|
1241
|
+
flags: WatchingRunning,
|
|
1242
|
+
__id: void 0
|
|
1243
|
+
};
|
|
1244
|
+
registerEffectDevtools(e);
|
|
1245
|
+
const prevSub = activeSub;
|
|
1246
|
+
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1247
|
+
activeSub = e;
|
|
1248
|
+
try {
|
|
1249
|
+
effectRunDevtools(e);
|
|
1250
|
+
fn();
|
|
1251
|
+
} finally {
|
|
1252
|
+
activeSub = prevSub;
|
|
1253
|
+
e.flags &= ~Running;
|
|
1254
|
+
}
|
|
1255
|
+
const disposer = effectOper.bind(e);
|
|
1256
|
+
disposer[EFFECT_MARKER] = true;
|
|
1257
|
+
return disposer;
|
|
1258
|
+
}
|
|
1259
|
+
function effectWithCleanup(fn, cleanupRunner) {
|
|
1260
|
+
const e = {
|
|
1261
|
+
fn,
|
|
1262
|
+
subs: void 0,
|
|
1263
|
+
subsTail: void 0,
|
|
1264
|
+
deps: void 0,
|
|
1265
|
+
depsTail: void 0,
|
|
1266
|
+
flags: WatchingRunning,
|
|
1267
|
+
runCleanup: cleanupRunner,
|
|
1268
|
+
__id: void 0
|
|
1269
|
+
};
|
|
1270
|
+
registerEffectDevtools(e);
|
|
1271
|
+
const prevSub = activeSub;
|
|
1272
|
+
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1273
|
+
activeSub = e;
|
|
1274
|
+
try {
|
|
1275
|
+
effectRunDevtools(e);
|
|
1276
|
+
fn();
|
|
1277
|
+
} finally {
|
|
1278
|
+
activeSub = prevSub;
|
|
1279
|
+
e.flags &= ~Running;
|
|
1280
|
+
}
|
|
1281
|
+
const disposer = effectOper.bind(e);
|
|
1282
|
+
disposer[EFFECT_MARKER] = true;
|
|
1283
|
+
return disposer;
|
|
1284
|
+
}
|
|
1285
|
+
function effectOper() {
|
|
1286
|
+
disposeNode(this);
|
|
1287
|
+
}
|
|
1288
|
+
function effectScope(fn) {
|
|
1289
|
+
const e = { deps: void 0, depsTail: void 0, subs: void 0, subsTail: void 0, flags: 0 };
|
|
1290
|
+
const prevSub = activeSub;
|
|
1291
|
+
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1292
|
+
activeSub = e;
|
|
1293
|
+
try {
|
|
1294
|
+
fn();
|
|
1295
|
+
} finally {
|
|
1296
|
+
activeSub = prevSub;
|
|
1297
|
+
}
|
|
1298
|
+
const disposer = effectScopeOper.bind(e);
|
|
1299
|
+
disposer[EFFECT_SCOPE_MARKER] = true;
|
|
1300
|
+
return disposer;
|
|
1301
|
+
}
|
|
1302
|
+
function effectScopeOper() {
|
|
1303
|
+
disposeNode(this);
|
|
1304
|
+
}
|
|
1305
|
+
function batch(fn) {
|
|
1306
|
+
++batchDepth;
|
|
1307
|
+
let result;
|
|
1308
|
+
let error;
|
|
1309
|
+
try {
|
|
1310
|
+
result = fn();
|
|
1311
|
+
} catch (e) {
|
|
1312
|
+
error = e;
|
|
1313
|
+
} finally {
|
|
1314
|
+
--batchDepth;
|
|
1315
|
+
if (batchDepth === 0) {
|
|
1316
|
+
try {
|
|
1317
|
+
flush();
|
|
1318
|
+
} catch (flushErr) {
|
|
1319
|
+
if (error === void 0) {
|
|
1320
|
+
error = flushErr;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
if (error !== void 0) {
|
|
1326
|
+
throw error;
|
|
1327
|
+
}
|
|
1328
|
+
return result;
|
|
1329
|
+
}
|
|
1330
|
+
function setActiveSub(sub) {
|
|
1331
|
+
const prev = activeSub;
|
|
1332
|
+
activeSub = sub;
|
|
1333
|
+
return prev;
|
|
1334
|
+
}
|
|
1335
|
+
function untrack(fn) {
|
|
1336
|
+
const prev = activeSub;
|
|
1337
|
+
activeSub = void 0;
|
|
1338
|
+
try {
|
|
1339
|
+
return fn();
|
|
1340
|
+
} finally {
|
|
1341
|
+
activeSub = prev;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
function setTransitionContext(value) {
|
|
1345
|
+
const prev = isInTransition;
|
|
1346
|
+
isInTransition = value;
|
|
1347
|
+
return prev;
|
|
1348
|
+
}
|
|
1349
|
+
var registerSignalDevtools = () => void 0;
|
|
1350
|
+
var updateSignalDevtools = () => {
|
|
1351
|
+
};
|
|
1352
|
+
var registerEffectDevtools = () => void 0;
|
|
1353
|
+
var effectRunDevtools = () => {
|
|
1354
|
+
};
|
|
1355
|
+
if (isDev4) {
|
|
1356
|
+
let devtoolsSignalId = 0;
|
|
1357
|
+
let devtoolsEffectId = 0;
|
|
1358
|
+
registerSignalDevtools = (value, node) => {
|
|
1359
|
+
const hook = getDevtoolsHook();
|
|
1360
|
+
if (!hook) return void 0;
|
|
1361
|
+
const id = ++devtoolsSignalId;
|
|
1362
|
+
hook.registerSignal(id, value);
|
|
1363
|
+
node.__id = id;
|
|
1364
|
+
return id;
|
|
1365
|
+
};
|
|
1366
|
+
updateSignalDevtools = (node, value) => {
|
|
1367
|
+
const hook = getDevtoolsHook();
|
|
1368
|
+
if (!hook) return;
|
|
1369
|
+
const id = node.__id;
|
|
1370
|
+
if (id) hook.updateSignal(id, value);
|
|
1371
|
+
};
|
|
1372
|
+
registerEffectDevtools = (node) => {
|
|
1373
|
+
const hook = getDevtoolsHook();
|
|
1374
|
+
if (!hook) return void 0;
|
|
1375
|
+
const id = ++devtoolsEffectId;
|
|
1376
|
+
hook.registerEffect(id);
|
|
1377
|
+
node.__id = id;
|
|
1378
|
+
return id;
|
|
1379
|
+
};
|
|
1380
|
+
effectRunDevtools = (node) => {
|
|
1381
|
+
const hook = getDevtoolsHook();
|
|
1382
|
+
if (!hook) return;
|
|
1383
|
+
const id = node.__id;
|
|
1384
|
+
if (id) hook.effectRun(id);
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
function createSelector(source, equalityFn = (a, b) => a === b) {
|
|
1388
|
+
let current = source();
|
|
1389
|
+
const observers = /* @__PURE__ */ new Map();
|
|
1390
|
+
const dispose = effect(() => {
|
|
1391
|
+
const next = source();
|
|
1392
|
+
if (equalityFn(current, next)) return;
|
|
1393
|
+
const prevSig = observers.get(current);
|
|
1394
|
+
if (prevSig) prevSig(false);
|
|
1395
|
+
const nextSig = observers.get(next);
|
|
1396
|
+
if (nextSig) nextSig(true);
|
|
1397
|
+
current = next;
|
|
1398
|
+
});
|
|
1399
|
+
registerRootCleanup(() => {
|
|
1400
|
+
dispose();
|
|
1401
|
+
observers.clear();
|
|
1402
|
+
});
|
|
1403
|
+
return (key) => {
|
|
1404
|
+
let sig = observers.get(key);
|
|
1405
|
+
if (!sig) {
|
|
1406
|
+
sig = signal(equalityFn(key, current));
|
|
1407
|
+
observers.set(key, sig);
|
|
1408
|
+
registerRootCleanup(() => observers.delete(key));
|
|
1409
|
+
}
|
|
1410
|
+
return sig();
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// src/effect.ts
|
|
1415
|
+
function createEffect(fn) {
|
|
1416
|
+
let cleanups = [];
|
|
1417
|
+
const rootForError = getCurrentRoot();
|
|
1418
|
+
const doCleanup = () => {
|
|
1419
|
+
runCleanupList(cleanups);
|
|
1420
|
+
cleanups = [];
|
|
1421
|
+
};
|
|
1422
|
+
const run = () => {
|
|
1423
|
+
const bucket = [];
|
|
1424
|
+
withEffectCleanups(bucket, () => {
|
|
1425
|
+
try {
|
|
1426
|
+
const maybeCleanup = fn();
|
|
1427
|
+
if (typeof maybeCleanup === "function") {
|
|
1428
|
+
bucket.push(maybeCleanup);
|
|
1429
|
+
}
|
|
1430
|
+
} catch (err) {
|
|
1431
|
+
if (handleError(err, { source: "effect" }, rootForError)) {
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
throw err;
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
cleanups = bucket;
|
|
1438
|
+
};
|
|
1439
|
+
const disposeEffect = effectWithCleanup(run, doCleanup);
|
|
1440
|
+
const teardown = () => {
|
|
1441
|
+
runCleanupList(cleanups);
|
|
1442
|
+
disposeEffect();
|
|
1443
|
+
};
|
|
1444
|
+
registerRootCleanup(teardown);
|
|
1445
|
+
return teardown;
|
|
1446
|
+
}
|
|
1447
|
+
function createRenderEffect(fn) {
|
|
1448
|
+
let cleanup;
|
|
1449
|
+
const rootForError = getCurrentRoot();
|
|
1450
|
+
const doCleanup = () => {
|
|
1451
|
+
if (cleanup) {
|
|
1452
|
+
cleanup();
|
|
1453
|
+
cleanup = void 0;
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
const run = () => {
|
|
1457
|
+
try {
|
|
1458
|
+
const maybeCleanup = fn();
|
|
1459
|
+
if (typeof maybeCleanup === "function") {
|
|
1460
|
+
cleanup = maybeCleanup;
|
|
1461
|
+
}
|
|
1462
|
+
} catch (err) {
|
|
1463
|
+
const handled = handleError(err, { source: "effect" }, rootForError);
|
|
1464
|
+
if (handled) {
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
throw err;
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1470
|
+
const disposeEffect = effectWithCleanup(run, doCleanup);
|
|
1471
|
+
const teardown = () => {
|
|
1472
|
+
if (cleanup) {
|
|
1473
|
+
cleanup();
|
|
1474
|
+
cleanup = void 0;
|
|
1475
|
+
}
|
|
1476
|
+
disposeEffect();
|
|
1477
|
+
};
|
|
1478
|
+
registerRootCleanup(teardown);
|
|
1479
|
+
return teardown;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
// src/jsx.ts
|
|
1483
|
+
var Fragment = Symbol("Fragment");
|
|
1484
|
+
|
|
1485
|
+
// src/node-ops.ts
|
|
1486
|
+
function toNodeArray(node) {
|
|
1487
|
+
try {
|
|
1488
|
+
if (Array.isArray(node)) {
|
|
1489
|
+
let allNodes = true;
|
|
1490
|
+
for (const item of node) {
|
|
1491
|
+
let isItemNode = false;
|
|
1492
|
+
try {
|
|
1493
|
+
isItemNode = item instanceof Node;
|
|
1494
|
+
} catch {
|
|
1495
|
+
isItemNode = false;
|
|
1496
|
+
}
|
|
1497
|
+
if (!isItemNode) {
|
|
1498
|
+
allNodes = false;
|
|
1499
|
+
break;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
if (allNodes) {
|
|
1503
|
+
return node;
|
|
1504
|
+
}
|
|
1505
|
+
const result = [];
|
|
1506
|
+
for (const item of node) {
|
|
1507
|
+
result.push(...toNodeArray(item));
|
|
1508
|
+
}
|
|
1509
|
+
return result;
|
|
1510
|
+
}
|
|
1511
|
+
if (node === null || node === void 0 || node === false) {
|
|
1512
|
+
return [];
|
|
1513
|
+
}
|
|
1514
|
+
} catch {
|
|
1515
|
+
return [];
|
|
1516
|
+
}
|
|
1517
|
+
let isNode = false;
|
|
1518
|
+
try {
|
|
1519
|
+
isNode = node instanceof Node;
|
|
1520
|
+
} catch {
|
|
1521
|
+
isNode = false;
|
|
1522
|
+
}
|
|
1523
|
+
if (isNode) {
|
|
1524
|
+
try {
|
|
1525
|
+
if (node instanceof DocumentFragment) {
|
|
1526
|
+
return Array.from(node.childNodes);
|
|
1527
|
+
}
|
|
1528
|
+
} catch {
|
|
1529
|
+
}
|
|
1530
|
+
return [node];
|
|
1531
|
+
}
|
|
1532
|
+
try {
|
|
1533
|
+
if (typeof node === "object" && node !== null && "marker" in node) {
|
|
1534
|
+
return toNodeArray(node.marker);
|
|
1535
|
+
}
|
|
1536
|
+
} catch {
|
|
1537
|
+
}
|
|
1538
|
+
try {
|
|
1539
|
+
return [document.createTextNode(String(node))];
|
|
1540
|
+
} catch {
|
|
1541
|
+
return [document.createTextNode("")];
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
function insertNodesBefore(parent, nodes, anchor) {
|
|
1545
|
+
if (nodes.length === 0) return;
|
|
1546
|
+
if (nodes.length === 1) {
|
|
1547
|
+
const node = nodes[0];
|
|
1548
|
+
if (node === void 0 || node === null) return;
|
|
1549
|
+
if (node.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
|
|
1550
|
+
parent.ownerDocument.adoptNode(node);
|
|
1551
|
+
}
|
|
1552
|
+
try {
|
|
1553
|
+
parent.insertBefore(node, anchor);
|
|
1554
|
+
} catch (e) {
|
|
1555
|
+
if (parent.ownerDocument) {
|
|
1556
|
+
try {
|
|
1557
|
+
const clone = parent.ownerDocument.importNode(node, true);
|
|
1558
|
+
parent.insertBefore(clone, anchor);
|
|
1559
|
+
return;
|
|
1560
|
+
} catch {
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
throw e;
|
|
1564
|
+
}
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
const doc = parent.ownerDocument;
|
|
1568
|
+
if (doc) {
|
|
1569
|
+
const frag = doc.createDocumentFragment();
|
|
1570
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1571
|
+
const node = nodes[i];
|
|
1572
|
+
if (node === void 0 || node === null) continue;
|
|
1573
|
+
if (node.nodeType === 11) {
|
|
1574
|
+
const childrenArr = Array.from(node.childNodes);
|
|
1575
|
+
for (let j = 0; j < childrenArr.length; j++) {
|
|
1576
|
+
frag.appendChild(childrenArr[j]);
|
|
1577
|
+
}
|
|
1578
|
+
} else {
|
|
1579
|
+
if (node.ownerDocument !== doc) {
|
|
1580
|
+
doc.adoptNode(node);
|
|
1581
|
+
}
|
|
1582
|
+
frag.appendChild(node);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
parent.insertBefore(frag, anchor);
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
const insertSingle = (nodeToInsert, anchorNode) => {
|
|
1589
|
+
if (nodeToInsert.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
|
|
1590
|
+
parent.ownerDocument.adoptNode(nodeToInsert);
|
|
1591
|
+
}
|
|
1592
|
+
try {
|
|
1593
|
+
parent.insertBefore(nodeToInsert, anchorNode);
|
|
1594
|
+
return nodeToInsert;
|
|
1595
|
+
} catch (e) {
|
|
1596
|
+
if (parent.ownerDocument) {
|
|
1597
|
+
try {
|
|
1598
|
+
const clone = parent.ownerDocument.importNode(nodeToInsert, true);
|
|
1599
|
+
parent.insertBefore(clone, anchorNode);
|
|
1600
|
+
return clone;
|
|
1601
|
+
} catch {
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
throw e;
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1607
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
1608
|
+
const node = nodes[i];
|
|
1609
|
+
if (node === void 0 || node === null) continue;
|
|
1610
|
+
const isFrag = node.nodeType === 11;
|
|
1611
|
+
if (isFrag) {
|
|
1612
|
+
const childrenArr = Array.from(node.childNodes);
|
|
1613
|
+
for (let j = childrenArr.length - 1; j >= 0; j--) {
|
|
1614
|
+
const child = childrenArr[j];
|
|
1615
|
+
anchor = insertSingle(child, anchor);
|
|
1616
|
+
}
|
|
1617
|
+
} else {
|
|
1618
|
+
anchor = insertSingle(node, anchor);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
function removeNodes(nodes) {
|
|
1623
|
+
for (const node of nodes) {
|
|
1624
|
+
node.parentNode?.removeChild(node);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// src/transition.ts
|
|
1629
|
+
function startTransition(fn) {
|
|
1630
|
+
const prev = setTransitionContext(true);
|
|
1631
|
+
try {
|
|
1632
|
+
fn();
|
|
1633
|
+
} finally {
|
|
1634
|
+
setTransitionContext(prev);
|
|
1635
|
+
scheduleFlush();
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
function useTransition() {
|
|
1639
|
+
const pending = signal(false);
|
|
1640
|
+
const start = (fn) => {
|
|
1641
|
+
startTransition(() => {
|
|
1642
|
+
pending(true);
|
|
1643
|
+
try {
|
|
1644
|
+
fn();
|
|
1645
|
+
} finally {
|
|
1646
|
+
pending(false);
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
};
|
|
1650
|
+
return [() => pending(), start];
|
|
1651
|
+
}
|
|
1652
|
+
function useDeferredValue(getValue) {
|
|
1653
|
+
const deferredValue = signal(getValue());
|
|
1654
|
+
createEffect(() => {
|
|
1655
|
+
const newValue = getValue();
|
|
1656
|
+
const currentDeferred = untrack(() => deferredValue());
|
|
1657
|
+
if (currentDeferred !== newValue) {
|
|
1658
|
+
startTransition(() => {
|
|
1659
|
+
deferredValue(newValue);
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
return () => deferredValue();
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
// src/scheduler.ts
|
|
1667
|
+
function batch2(fn) {
|
|
1668
|
+
return batch(fn);
|
|
1669
|
+
}
|
|
1670
|
+
function untrack2(fn) {
|
|
1671
|
+
return untrack(fn);
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
// src/binding.ts
|
|
1675
|
+
var isDev5 = true ? false : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
1676
|
+
function isReactive(value) {
|
|
1677
|
+
return typeof value === "function" && value.length === 0;
|
|
1678
|
+
}
|
|
1679
|
+
function unwrap(value) {
|
|
1680
|
+
return isReactive(value) ? value() : value;
|
|
1681
|
+
}
|
|
1682
|
+
function callEventHandler(handler, event, node, data) {
|
|
1683
|
+
if (!handler) return;
|
|
1684
|
+
const context = node ?? event.currentTarget ?? void 0;
|
|
1685
|
+
const invoke = (fn) => {
|
|
1686
|
+
if (typeof fn === "function") {
|
|
1687
|
+
const result = data === void 0 ? fn.call(context, event) : fn.call(context, data, event);
|
|
1688
|
+
if (typeof result === "function" && result !== fn) {
|
|
1689
|
+
if (data === void 0) {
|
|
1690
|
+
;
|
|
1691
|
+
result.call(context, event);
|
|
1692
|
+
} else {
|
|
1693
|
+
;
|
|
1694
|
+
result.call(context, data, event);
|
|
1695
|
+
}
|
|
1696
|
+
} else if (result && typeof result.handleEvent === "function") {
|
|
1697
|
+
;
|
|
1698
|
+
result.handleEvent.call(result, event);
|
|
1699
|
+
}
|
|
1700
|
+
} else if (fn && typeof fn.handleEvent === "function") {
|
|
1701
|
+
fn.handleEvent.call(fn, event);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
invoke(handler);
|
|
1705
|
+
}
|
|
1706
|
+
function createTextBinding(value) {
|
|
1707
|
+
const text = document.createTextNode("");
|
|
1708
|
+
if (isReactive(value)) {
|
|
1709
|
+
createRenderEffect(() => {
|
|
1710
|
+
const v = value();
|
|
1711
|
+
const fmt = formatTextValue(v);
|
|
1712
|
+
if (text.data !== fmt) {
|
|
1713
|
+
text.data = fmt;
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
} else {
|
|
1717
|
+
text.data = formatTextValue(value);
|
|
1718
|
+
}
|
|
1719
|
+
return text;
|
|
1720
|
+
}
|
|
1721
|
+
function bindText(textNode, getValue) {
|
|
1722
|
+
return createRenderEffect(() => {
|
|
1723
|
+
const value = formatTextValue(getValue());
|
|
1724
|
+
if (textNode.data !== value) {
|
|
1725
|
+
textNode.data = value;
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
function formatTextValue(value) {
|
|
1730
|
+
if (value == null || value === false) {
|
|
1731
|
+
return "";
|
|
1732
|
+
}
|
|
1733
|
+
return String(value);
|
|
1734
|
+
}
|
|
1735
|
+
function createAttributeBinding(el, key, value, setter) {
|
|
1736
|
+
if (isReactive(value)) {
|
|
1737
|
+
createRenderEffect(() => {
|
|
1738
|
+
setter(el, key, value());
|
|
1739
|
+
});
|
|
1740
|
+
} else {
|
|
1741
|
+
setter(el, key, value);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
function bindAttribute(el, key, getValue) {
|
|
1745
|
+
let prevValue = void 0;
|
|
1746
|
+
return createRenderEffect(() => {
|
|
1747
|
+
const value = getValue();
|
|
1748
|
+
if (value === prevValue) return;
|
|
1749
|
+
prevValue = value;
|
|
1750
|
+
if (value === void 0 || value === null || value === false) {
|
|
1751
|
+
el.removeAttribute(key);
|
|
1752
|
+
} else if (value === true) {
|
|
1753
|
+
el.setAttribute(key, "");
|
|
1754
|
+
} else {
|
|
1755
|
+
el.setAttribute(key, String(value));
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
function bindProperty(el, key, getValue) {
|
|
1760
|
+
const PROPERTY_BINDING_KEYS = /* @__PURE__ */ new Set([
|
|
1761
|
+
"value",
|
|
1762
|
+
"checked",
|
|
1763
|
+
"selected",
|
|
1764
|
+
"disabled",
|
|
1765
|
+
"readOnly",
|
|
1766
|
+
"multiple",
|
|
1767
|
+
"muted"
|
|
1768
|
+
]);
|
|
1769
|
+
let prevValue = void 0;
|
|
1770
|
+
return createRenderEffect(() => {
|
|
1771
|
+
const next = getValue();
|
|
1772
|
+
if (next === prevValue) return;
|
|
1773
|
+
prevValue = next;
|
|
1774
|
+
if (PROPERTY_BINDING_KEYS.has(key) && (next === void 0 || next === null)) {
|
|
1775
|
+
const fallback = key === "checked" || key === "selected" ? false : "";
|
|
1776
|
+
el[key] = fallback;
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
;
|
|
1780
|
+
el[key] = next;
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
function createStyleBinding(el, value) {
|
|
1784
|
+
const target = el;
|
|
1785
|
+
if (isReactive(value)) {
|
|
1786
|
+
let prev;
|
|
1787
|
+
createRenderEffect(() => {
|
|
1788
|
+
const next = value();
|
|
1789
|
+
applyStyle(target, next, prev);
|
|
1790
|
+
prev = next;
|
|
1791
|
+
});
|
|
1792
|
+
} else {
|
|
1793
|
+
applyStyle(target, value, void 0);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
function bindStyle(el, getValue) {
|
|
1797
|
+
const target = el;
|
|
1798
|
+
let prev;
|
|
1799
|
+
return createRenderEffect(() => {
|
|
1800
|
+
const next = getValue();
|
|
1801
|
+
applyStyle(target, next, prev);
|
|
1802
|
+
prev = next;
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
function applyStyle(el, value, prev) {
|
|
1806
|
+
if (typeof value === "string") {
|
|
1807
|
+
el.style.cssText = value;
|
|
1808
|
+
} else if (value && typeof value === "object") {
|
|
1809
|
+
const styles = value;
|
|
1810
|
+
if (typeof prev === "string") {
|
|
1811
|
+
el.style.cssText = "";
|
|
1812
|
+
}
|
|
1813
|
+
if (prev && typeof prev === "object") {
|
|
1814
|
+
const prevStyles = prev;
|
|
1815
|
+
for (const key of Object.keys(prevStyles)) {
|
|
1816
|
+
if (!(key in styles)) {
|
|
1817
|
+
const cssProperty = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1818
|
+
el.style.removeProperty(cssProperty);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
for (const [prop2, v] of Object.entries(styles)) {
|
|
1823
|
+
if (v != null) {
|
|
1824
|
+
const cssProperty = prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1825
|
+
const unitless = isUnitlessStyleProperty(prop2) || isUnitlessStyleProperty(cssProperty);
|
|
1826
|
+
const valueStr = typeof v === "number" && !unitless ? `${v}px` : String(v);
|
|
1827
|
+
el.style.setProperty(cssProperty, valueStr);
|
|
1828
|
+
} else {
|
|
1829
|
+
const cssProperty = prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1830
|
+
el.style.removeProperty(cssProperty);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
} else {
|
|
1834
|
+
if (prev && typeof prev === "object") {
|
|
1835
|
+
const prevStyles = prev;
|
|
1836
|
+
for (const key of Object.keys(prevStyles)) {
|
|
1837
|
+
const cssProperty = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1838
|
+
el.style.removeProperty(cssProperty);
|
|
1839
|
+
}
|
|
1840
|
+
} else if (typeof prev === "string") {
|
|
1841
|
+
el.style.cssText = "";
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
var isUnitlessStyleProperty = isDev5 ? (prop2) => UnitlessStyles.has(prop2) : (prop2) => prop2 === "opacity" || prop2 === "zIndex";
|
|
1846
|
+
function createClassBinding(el, value) {
|
|
1847
|
+
if (isReactive(value)) {
|
|
1848
|
+
let prev = {};
|
|
1849
|
+
createRenderEffect(() => {
|
|
1850
|
+
const next = value();
|
|
1851
|
+
prev = applyClass(el, next, prev);
|
|
1852
|
+
});
|
|
1853
|
+
} else {
|
|
1854
|
+
applyClass(el, value, {});
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
function bindClass(el, getValue) {
|
|
1858
|
+
let prev = {};
|
|
1859
|
+
let prevString;
|
|
1860
|
+
return createRenderEffect(() => {
|
|
1861
|
+
const next = getValue();
|
|
1862
|
+
if (typeof next === "string") {
|
|
1863
|
+
if (next === prevString) return;
|
|
1864
|
+
prevString = next;
|
|
1865
|
+
el.className = next;
|
|
1866
|
+
prev = {};
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
prevString = void 0;
|
|
1870
|
+
prev = applyClass(el, next, prev);
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
function toggleClassKey(node, key, value) {
|
|
1874
|
+
const classNames = key.trim().split(/\s+/);
|
|
1875
|
+
for (let i = 0, len = classNames.length; i < len; i++) {
|
|
1876
|
+
node.classList.toggle(classNames[i], value);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
function applyClass(el, value, prev) {
|
|
1880
|
+
const prevState = prev && typeof prev === "object" ? prev : {};
|
|
1881
|
+
if (typeof value === "string") {
|
|
1882
|
+
el.className = value;
|
|
1883
|
+
return {};
|
|
1884
|
+
}
|
|
1885
|
+
if (value && typeof value === "object") {
|
|
1886
|
+
const classes = value;
|
|
1887
|
+
const classKeys = Object.keys(classes);
|
|
1888
|
+
const prevKeys = Object.keys(prevState);
|
|
1889
|
+
for (let i = 0, len = prevKeys.length; i < len; i++) {
|
|
1890
|
+
const key = prevKeys[i];
|
|
1891
|
+
if (!key || key === "undefined" || classes[key]) continue;
|
|
1892
|
+
toggleClassKey(el, key, false);
|
|
1893
|
+
delete prevState[key];
|
|
1894
|
+
}
|
|
1895
|
+
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
1896
|
+
const key = classKeys[i];
|
|
1897
|
+
const classValue = !!classes[key];
|
|
1898
|
+
if (!key || key === "undefined" || prevState[key] === classValue || !classValue) continue;
|
|
1899
|
+
toggleClassKey(el, key, true);
|
|
1900
|
+
prevState[key] = classValue;
|
|
1901
|
+
}
|
|
1902
|
+
return prevState;
|
|
1903
|
+
}
|
|
1904
|
+
if (!value) {
|
|
1905
|
+
for (const key of Object.keys(prevState)) {
|
|
1906
|
+
if (key && key !== "undefined") {
|
|
1907
|
+
toggleClassKey(el, key, false);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
return {};
|
|
1911
|
+
}
|
|
1912
|
+
return prevState;
|
|
1913
|
+
}
|
|
1914
|
+
function classList(node, value, prev = {}) {
|
|
1915
|
+
return applyClass(node, value, prev);
|
|
1916
|
+
}
|
|
1917
|
+
function insert(parent, getValue, markerOrCreateElement, createElementFn) {
|
|
1918
|
+
const hostRoot = getCurrentRoot();
|
|
1919
|
+
let marker;
|
|
1920
|
+
let ownsMarker = false;
|
|
1921
|
+
let createFn = createElementFn;
|
|
1922
|
+
if (markerOrCreateElement instanceof Node) {
|
|
1923
|
+
marker = markerOrCreateElement;
|
|
1924
|
+
createFn = createElementFn;
|
|
1925
|
+
} else {
|
|
1926
|
+
marker = document.createComment("fict:insert");
|
|
1927
|
+
parent.appendChild(marker);
|
|
1928
|
+
createFn = markerOrCreateElement;
|
|
1929
|
+
ownsMarker = true;
|
|
1930
|
+
}
|
|
1931
|
+
let currentNodes = [];
|
|
1932
|
+
let currentText = null;
|
|
1933
|
+
let currentRoot2 = null;
|
|
1934
|
+
const clearCurrentNodes = () => {
|
|
1935
|
+
if (currentNodes.length > 0) {
|
|
1936
|
+
removeNodes(currentNodes);
|
|
1937
|
+
currentNodes = [];
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
const setTextNode = (textValue, shouldInsert, parentNode) => {
|
|
1941
|
+
if (!currentText) {
|
|
1942
|
+
currentText = document.createTextNode(textValue);
|
|
1943
|
+
} else if (currentText.data !== textValue) {
|
|
1944
|
+
currentText.data = textValue;
|
|
1945
|
+
}
|
|
1946
|
+
if (!shouldInsert) {
|
|
1947
|
+
clearCurrentNodes();
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
if (currentNodes.length === 1 && currentNodes[0] === currentText) {
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
clearCurrentNodes();
|
|
1954
|
+
insertNodesBefore(parentNode, [currentText], marker);
|
|
1955
|
+
currentNodes = [currentText];
|
|
1956
|
+
};
|
|
1957
|
+
const dispose = createRenderEffect(() => {
|
|
1958
|
+
const value = getValue();
|
|
1959
|
+
const parentNode = marker.parentNode;
|
|
1960
|
+
const isPrimitive = value == null || value === false || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
1961
|
+
if (isPrimitive) {
|
|
1962
|
+
if (currentRoot2) {
|
|
1963
|
+
destroyRoot(currentRoot2);
|
|
1964
|
+
currentRoot2 = null;
|
|
1965
|
+
}
|
|
1966
|
+
if (!parentNode) {
|
|
1967
|
+
clearCurrentNodes();
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
const textValue = value == null || value === false ? "" : String(value);
|
|
1971
|
+
const shouldInsert = value != null && value !== false;
|
|
1972
|
+
setTextNode(textValue, shouldInsert, parentNode);
|
|
1973
|
+
return;
|
|
1974
|
+
}
|
|
1975
|
+
if (currentRoot2) {
|
|
1976
|
+
destroyRoot(currentRoot2);
|
|
1977
|
+
currentRoot2 = null;
|
|
1978
|
+
}
|
|
1979
|
+
clearCurrentNodes();
|
|
1980
|
+
const root = createRootContext(hostRoot);
|
|
1981
|
+
const prev = pushRoot(root);
|
|
1982
|
+
let nodes = [];
|
|
1983
|
+
try {
|
|
1984
|
+
let newNode;
|
|
1985
|
+
if (value instanceof Node) {
|
|
1986
|
+
newNode = value;
|
|
1987
|
+
} else if (Array.isArray(value)) {
|
|
1988
|
+
if (value.every((v) => v instanceof Node)) {
|
|
1989
|
+
newNode = value;
|
|
1990
|
+
} else {
|
|
1991
|
+
if (createFn) {
|
|
1992
|
+
const mapped = [];
|
|
1993
|
+
for (const item of value) {
|
|
1994
|
+
mapped.push(...toNodeArray(createFn(item)));
|
|
1995
|
+
}
|
|
1996
|
+
newNode = mapped;
|
|
1997
|
+
} else {
|
|
1998
|
+
newNode = document.createTextNode(String(value));
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
} else {
|
|
2002
|
+
newNode = createFn ? createFn(value) : document.createTextNode(String(value));
|
|
2003
|
+
}
|
|
2004
|
+
nodes = toNodeArray(newNode);
|
|
2005
|
+
if (parentNode) {
|
|
2006
|
+
insertNodesBefore(parentNode, nodes, marker);
|
|
2007
|
+
}
|
|
2008
|
+
} finally {
|
|
2009
|
+
popRoot(prev);
|
|
2010
|
+
flushOnMount(root);
|
|
2011
|
+
}
|
|
2012
|
+
currentRoot2 = root;
|
|
2013
|
+
currentNodes = nodes;
|
|
2014
|
+
});
|
|
2015
|
+
return () => {
|
|
2016
|
+
dispose();
|
|
2017
|
+
if (currentRoot2) {
|
|
2018
|
+
destroyRoot(currentRoot2);
|
|
2019
|
+
currentRoot2 = null;
|
|
2020
|
+
}
|
|
2021
|
+
clearCurrentNodes();
|
|
2022
|
+
if (ownsMarker) {
|
|
2023
|
+
marker.parentNode?.removeChild(marker);
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
function createChildBinding(parent, getValue, createElementFn) {
|
|
2028
|
+
const marker = document.createComment("fict:child");
|
|
2029
|
+
parent.appendChild(marker);
|
|
2030
|
+
const hostRoot = getCurrentRoot();
|
|
2031
|
+
const dispose = createRenderEffect(() => {
|
|
2032
|
+
const root = createRootContext(hostRoot);
|
|
2033
|
+
const prev = pushRoot(root);
|
|
2034
|
+
let nodes = [];
|
|
2035
|
+
let handledError = false;
|
|
2036
|
+
try {
|
|
2037
|
+
const value = getValue();
|
|
2038
|
+
if (value == null || value === false) {
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
const output = createElementFn(value);
|
|
2042
|
+
nodes = toNodeArray(output);
|
|
2043
|
+
const parentNode = marker.parentNode;
|
|
2044
|
+
if (parentNode) {
|
|
2045
|
+
insertNodesBefore(parentNode, nodes, marker);
|
|
2046
|
+
}
|
|
2047
|
+
return () => {
|
|
2048
|
+
destroyRoot(root);
|
|
2049
|
+
removeNodes(nodes);
|
|
2050
|
+
};
|
|
2051
|
+
} catch (err) {
|
|
2052
|
+
if (handleSuspend(err, root)) {
|
|
2053
|
+
handledError = true;
|
|
2054
|
+
destroyRoot(root);
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
if (handleError(err, { source: "renderChild" }, root)) {
|
|
2058
|
+
handledError = true;
|
|
2059
|
+
destroyRoot(root);
|
|
2060
|
+
return;
|
|
2061
|
+
}
|
|
2062
|
+
throw err;
|
|
2063
|
+
} finally {
|
|
2064
|
+
popRoot(prev);
|
|
2065
|
+
if (!handledError) {
|
|
2066
|
+
flushOnMount(root);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
});
|
|
2070
|
+
return {
|
|
2071
|
+
marker,
|
|
2072
|
+
dispose: () => {
|
|
2073
|
+
dispose();
|
|
2074
|
+
marker.parentNode?.removeChild(marker);
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
function delegateEvents(eventNames, doc = window.document) {
|
|
2079
|
+
const e = doc[$$EVENTS] || (doc[$$EVENTS] = /* @__PURE__ */ new Set());
|
|
2080
|
+
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
2081
|
+
const name = eventNames[i];
|
|
2082
|
+
if (!e.has(name)) {
|
|
2083
|
+
e.add(name);
|
|
2084
|
+
doc.addEventListener(name, globalEventHandler);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
function clearDelegatedEvents(doc = window.document) {
|
|
2089
|
+
const e = doc[$$EVENTS];
|
|
2090
|
+
if (e) {
|
|
2091
|
+
for (const name of e.keys()) {
|
|
2092
|
+
doc.removeEventListener(name, globalEventHandler);
|
|
2093
|
+
}
|
|
2094
|
+
delete doc[$$EVENTS];
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
function globalEventHandler(e) {
|
|
2098
|
+
const asNode = (value) => value && typeof value.nodeType === "number" ? value : null;
|
|
2099
|
+
const asElement = (value) => {
|
|
2100
|
+
const n = asNode(value);
|
|
2101
|
+
if (!n) return null;
|
|
2102
|
+
if (n.nodeType === 1) return n;
|
|
2103
|
+
return n.parentElement;
|
|
2104
|
+
};
|
|
2105
|
+
let node = asElement(e.target);
|
|
2106
|
+
const key = `$$${e.type}`;
|
|
2107
|
+
const dataKey = `${key}Data`;
|
|
2108
|
+
const oriTarget = e.target;
|
|
2109
|
+
const oriCurrentTarget = e.currentTarget;
|
|
2110
|
+
let lastHandled = null;
|
|
2111
|
+
const retarget = (value) => Object.defineProperty(e, "target", {
|
|
2112
|
+
configurable: true,
|
|
2113
|
+
value
|
|
2114
|
+
});
|
|
2115
|
+
const handleNode = () => {
|
|
2116
|
+
if (!node) return false;
|
|
2117
|
+
const handler = node[key];
|
|
2118
|
+
if (handler && !node.disabled) {
|
|
2119
|
+
const resolveData = (value) => {
|
|
2120
|
+
if (typeof value === "function") {
|
|
2121
|
+
try {
|
|
2122
|
+
const fn = value;
|
|
2123
|
+
return fn.length > 0 ? fn(e) : fn();
|
|
2124
|
+
} catch {
|
|
2125
|
+
return value();
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
return value;
|
|
2129
|
+
};
|
|
2130
|
+
const rawData = node[dataKey];
|
|
2131
|
+
const hasData = rawData !== void 0;
|
|
2132
|
+
const resolvedNodeData = hasData ? resolveData(rawData) : void 0;
|
|
2133
|
+
batch2(() => {
|
|
2134
|
+
if (typeof handler === "function") {
|
|
2135
|
+
callEventHandler(handler, e, node, hasData ? resolvedNodeData : void 0);
|
|
2136
|
+
} else if (Array.isArray(handler)) {
|
|
2137
|
+
const tupleData = resolveData(handler[1]);
|
|
2138
|
+
callEventHandler(handler[0], e, node, tupleData);
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
if (e.cancelBubble) return false;
|
|
2142
|
+
}
|
|
2143
|
+
const shadowHost = node.host;
|
|
2144
|
+
if (shadowHost && typeof shadowHost !== "string" && !shadowHost._$host && (() => {
|
|
2145
|
+
const targetNode = asNode(e.target);
|
|
2146
|
+
return targetNode ? node.contains(targetNode) : false;
|
|
2147
|
+
})()) {
|
|
2148
|
+
retarget(shadowHost);
|
|
2149
|
+
}
|
|
2150
|
+
return true;
|
|
2151
|
+
};
|
|
2152
|
+
const walkUpTree = () => {
|
|
2153
|
+
while (handleNode() && node) {
|
|
2154
|
+
node = asElement(node._$host || node.parentNode || node.host);
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
Object.defineProperty(e, "currentTarget", {
|
|
2158
|
+
configurable: true,
|
|
2159
|
+
get() {
|
|
2160
|
+
return node || document;
|
|
2161
|
+
}
|
|
2162
|
+
});
|
|
2163
|
+
if (e.composedPath) {
|
|
2164
|
+
const path = e.composedPath();
|
|
2165
|
+
retarget(path[0]);
|
|
2166
|
+
for (let i = 0; i < path.length - 2; i++) {
|
|
2167
|
+
const nextNode = asElement(path[i]);
|
|
2168
|
+
if (!nextNode || nextNode === lastHandled) continue;
|
|
2169
|
+
node = nextNode;
|
|
2170
|
+
if (!handleNode()) break;
|
|
2171
|
+
lastHandled = node;
|
|
2172
|
+
if (node._$host) {
|
|
2173
|
+
node = node._$host;
|
|
2174
|
+
walkUpTree();
|
|
2175
|
+
break;
|
|
2176
|
+
}
|
|
2177
|
+
if (node.parentNode === oriCurrentTarget) {
|
|
2178
|
+
break;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
} else {
|
|
2182
|
+
walkUpTree();
|
|
2183
|
+
}
|
|
2184
|
+
retarget(oriTarget);
|
|
2185
|
+
}
|
|
2186
|
+
function addEventListener(node, name, handler, delegate) {
|
|
2187
|
+
if (handler == null) return;
|
|
2188
|
+
if (delegate) {
|
|
2189
|
+
if (Array.isArray(handler)) {
|
|
2190
|
+
;
|
|
2191
|
+
node[`$$${name}`] = handler[0];
|
|
2192
|
+
node[`$$${name}Data`] = handler[1];
|
|
2193
|
+
} else {
|
|
2194
|
+
;
|
|
2195
|
+
node[`$$${name}`] = handler;
|
|
2196
|
+
}
|
|
2197
|
+
} else if (Array.isArray(handler)) {
|
|
2198
|
+
const handlerFn = handler[0];
|
|
2199
|
+
node.addEventListener(name, (e) => handlerFn.call(node, handler[1], e));
|
|
2200
|
+
} else {
|
|
2201
|
+
node.addEventListener(name, handler);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
function bindEvent(el, eventName, handler, options) {
|
|
2205
|
+
if (handler == null) return () => {
|
|
2206
|
+
};
|
|
2207
|
+
const rootRef = getCurrentRoot();
|
|
2208
|
+
if (isDev5 && DelegatedEvents.has(eventName) && !options) {
|
|
2209
|
+
const key = `$$${eventName}`;
|
|
2210
|
+
delegateEvents([eventName]);
|
|
2211
|
+
const resolveHandler = isReactive(handler) ? handler : () => handler;
|
|
2212
|
+
el[key] = function(...args) {
|
|
2213
|
+
try {
|
|
2214
|
+
const fn = resolveHandler();
|
|
2215
|
+
callEventHandler(fn, args[0], el);
|
|
2216
|
+
} catch (err) {
|
|
2217
|
+
if (!handleError(err, { source: "event", eventName }, rootRef)) {
|
|
2218
|
+
throw err;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
};
|
|
2222
|
+
return () => {
|
|
2223
|
+
el[key] = void 0;
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
const getHandler = isReactive(handler) ? handler : () => handler;
|
|
2227
|
+
const wrapped = (event) => {
|
|
2228
|
+
try {
|
|
2229
|
+
const resolved = getHandler();
|
|
2230
|
+
callEventHandler(resolved, event, el);
|
|
2231
|
+
} catch (err) {
|
|
2232
|
+
if (handleError(err, { source: "event", eventName }, rootRef)) {
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
throw err;
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
el.addEventListener(eventName, wrapped, options);
|
|
2239
|
+
const cleanup = () => el.removeEventListener(eventName, wrapped, options);
|
|
2240
|
+
registerRootCleanup(cleanup);
|
|
2241
|
+
return cleanup;
|
|
2242
|
+
}
|
|
2243
|
+
function bindRef(el, ref) {
|
|
2244
|
+
if (ref == null) return () => {
|
|
2245
|
+
};
|
|
2246
|
+
const getRef = isReactive(ref) ? ref : () => ref;
|
|
2247
|
+
const applyRef2 = (refValue) => {
|
|
2248
|
+
if (refValue == null) return;
|
|
2249
|
+
if (typeof refValue === "function") {
|
|
2250
|
+
;
|
|
2251
|
+
refValue(el);
|
|
2252
|
+
} else if (typeof refValue === "object" && "current" in refValue) {
|
|
2253
|
+
;
|
|
2254
|
+
refValue.current = el;
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
const initialRef = getRef();
|
|
2258
|
+
applyRef2(initialRef);
|
|
2259
|
+
if (isReactive(ref)) {
|
|
2260
|
+
const cleanup2 = createRenderEffect(() => {
|
|
2261
|
+
const currentRef = getRef();
|
|
2262
|
+
applyRef2(currentRef);
|
|
2263
|
+
});
|
|
2264
|
+
registerRootCleanup(cleanup2);
|
|
2265
|
+
const nullifyCleanup = () => {
|
|
2266
|
+
const currentRef = getRef();
|
|
2267
|
+
if (currentRef && typeof currentRef === "object" && "current" in currentRef) {
|
|
2268
|
+
;
|
|
2269
|
+
currentRef.current = null;
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
registerRootCleanup(nullifyCleanup);
|
|
2273
|
+
return () => {
|
|
2274
|
+
cleanup2();
|
|
2275
|
+
nullifyCleanup();
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
const cleanup = () => {
|
|
2279
|
+
const refValue = getRef();
|
|
2280
|
+
if (refValue && typeof refValue === "object" && "current" in refValue) {
|
|
2281
|
+
;
|
|
2282
|
+
refValue.current = null;
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
registerRootCleanup(cleanup);
|
|
2286
|
+
return cleanup;
|
|
2287
|
+
}
|
|
2288
|
+
function spread(node, props = {}, isSVG = false, skipChildren = false) {
|
|
2289
|
+
const prevProps = {};
|
|
2290
|
+
if (!skipChildren && "children" in props) {
|
|
2291
|
+
createRenderEffect(() => {
|
|
2292
|
+
prevProps.children = props.children;
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2295
|
+
createRenderEffect(() => {
|
|
2296
|
+
if (typeof props.ref === "function") {
|
|
2297
|
+
;
|
|
2298
|
+
props.ref(node);
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
createRenderEffect(() => {
|
|
2302
|
+
assign(node, props, isSVG, true, prevProps, true);
|
|
2303
|
+
});
|
|
2304
|
+
return prevProps;
|
|
2305
|
+
}
|
|
2306
|
+
function assign(node, props, isSVG = false, skipChildren = false, prevProps = {}, skipRef = false) {
|
|
2307
|
+
props = props || {};
|
|
2308
|
+
for (const prop2 in prevProps) {
|
|
2309
|
+
if (!(prop2 in props)) {
|
|
2310
|
+
if (prop2 === "children") continue;
|
|
2311
|
+
prevProps[prop2] = assignProp(node, prop2, null, prevProps[prop2], isSVG, skipRef, props);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
for (const prop2 in props) {
|
|
2315
|
+
if (prop2 === "children") {
|
|
2316
|
+
if (!skipChildren) {
|
|
2317
|
+
prevProps.children = props.children;
|
|
2318
|
+
}
|
|
2319
|
+
continue;
|
|
2320
|
+
}
|
|
2321
|
+
const value = props[prop2];
|
|
2322
|
+
prevProps[prop2] = assignProp(node, prop2, value, prevProps[prop2], isSVG, skipRef, props);
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
function assignProp(node, prop2, value, prev, isSVG, skipRef, props) {
|
|
2326
|
+
if (prop2 === "style") {
|
|
2327
|
+
applyStyle(node, value, prev);
|
|
2328
|
+
return value;
|
|
2329
|
+
}
|
|
2330
|
+
if (prop2 === "classList") {
|
|
2331
|
+
return applyClass(node, value, prev);
|
|
2332
|
+
}
|
|
2333
|
+
if (value === prev) return prev;
|
|
2334
|
+
if (prop2 === "ref") {
|
|
2335
|
+
if (!skipRef && typeof value === "function") {
|
|
2336
|
+
;
|
|
2337
|
+
value(node);
|
|
2338
|
+
}
|
|
2339
|
+
return value;
|
|
2340
|
+
}
|
|
2341
|
+
if (prop2.slice(0, 3) === "on:") {
|
|
2342
|
+
const eventName = prop2.slice(3);
|
|
2343
|
+
if (prev) node.removeEventListener(eventName, prev);
|
|
2344
|
+
if (value) node.addEventListener(eventName, value);
|
|
2345
|
+
return value;
|
|
2346
|
+
}
|
|
2347
|
+
if (prop2.slice(0, 10) === "oncapture:") {
|
|
2348
|
+
const eventName = prop2.slice(10);
|
|
2349
|
+
if (prev) node.removeEventListener(eventName, prev, true);
|
|
2350
|
+
if (value) node.addEventListener(eventName, value, true);
|
|
2351
|
+
return value;
|
|
2352
|
+
}
|
|
2353
|
+
if (prop2.slice(0, 2) === "on") {
|
|
2354
|
+
const eventName = prop2.slice(2).toLowerCase();
|
|
2355
|
+
const shouldDelegate = isDev5 && DelegatedEvents.has(eventName);
|
|
2356
|
+
if (!shouldDelegate && prev) {
|
|
2357
|
+
const handler = Array.isArray(prev) ? prev[0] : prev;
|
|
2358
|
+
node.removeEventListener(eventName, handler);
|
|
2359
|
+
}
|
|
2360
|
+
if (shouldDelegate || value) {
|
|
2361
|
+
addEventListener(node, eventName, value, shouldDelegate);
|
|
2362
|
+
if (shouldDelegate) delegateEvents([eventName]);
|
|
2363
|
+
}
|
|
2364
|
+
return value;
|
|
2365
|
+
}
|
|
2366
|
+
if (prop2.slice(0, 5) === "attr:") {
|
|
2367
|
+
if (value == null) node.removeAttribute(prop2.slice(5));
|
|
2368
|
+
else node.setAttribute(prop2.slice(5), String(value));
|
|
2369
|
+
return value;
|
|
2370
|
+
}
|
|
2371
|
+
if (prop2.slice(0, 5) === "bool:") {
|
|
2372
|
+
if (value) node.setAttribute(prop2.slice(5), "");
|
|
2373
|
+
else node.removeAttribute(prop2.slice(5));
|
|
2374
|
+
return value;
|
|
2375
|
+
}
|
|
2376
|
+
if (prop2.slice(0, 5) === "prop:") {
|
|
2377
|
+
;
|
|
2378
|
+
node[prop2.slice(5)] = value;
|
|
2379
|
+
return value;
|
|
2380
|
+
}
|
|
2381
|
+
if (prop2 === "class" || prop2 === "className") {
|
|
2382
|
+
if (value == null) node.removeAttribute("class");
|
|
2383
|
+
else node.className = String(value);
|
|
2384
|
+
return value;
|
|
2385
|
+
}
|
|
2386
|
+
const isCE = node.nodeName.includes("-") || "is" in props;
|
|
2387
|
+
if (!isSVG) {
|
|
2388
|
+
const propAlias = isDev5 ? getPropAlias(prop2, node.tagName) : void 0;
|
|
2389
|
+
const isProperty = isDev5 ? Properties.has(prop2) : prop2 in node;
|
|
2390
|
+
const isChildProp = isDev5 ? ChildProperties.has(prop2) : prop2 === "innerHTML" || prop2 === "textContent" || prop2 === "innerText" || prop2 === "children";
|
|
2391
|
+
if (propAlias || isProperty || isChildProp || isCE) {
|
|
2392
|
+
const propName = propAlias || prop2;
|
|
2393
|
+
if (isCE && !isProperty && !isChildProp && !propAlias) {
|
|
2394
|
+
;
|
|
2395
|
+
node[toPropertyName(propName)] = value;
|
|
2396
|
+
} else {
|
|
2397
|
+
;
|
|
2398
|
+
node[propName] = value;
|
|
2399
|
+
}
|
|
2400
|
+
return value;
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
if (isSVG && prop2.indexOf(":") > -1) {
|
|
2404
|
+
const [prefix, name] = prop2.split(":");
|
|
2405
|
+
const ns = SVGNamespace[prefix];
|
|
2406
|
+
if (ns) {
|
|
2407
|
+
if (value == null) node.removeAttributeNS(ns, name);
|
|
2408
|
+
else node.setAttributeNS(ns, name, String(value));
|
|
2409
|
+
return value;
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
const attrName = prop2 === "htmlFor" ? "for" : prop2;
|
|
2413
|
+
if (value == null) node.removeAttribute(attrName);
|
|
2414
|
+
else node.setAttribute(attrName, String(value));
|
|
2415
|
+
return value;
|
|
2416
|
+
}
|
|
2417
|
+
function toPropertyName(name) {
|
|
2418
|
+
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
2419
|
+
}
|
|
2420
|
+
function createConditional(condition, renderTrue, createElementFn, renderFalse) {
|
|
2421
|
+
const startMarker = document.createComment("fict:cond:start");
|
|
2422
|
+
const endMarker = document.createComment("fict:cond:end");
|
|
2423
|
+
const fragment = document.createDocumentFragment();
|
|
2424
|
+
fragment.append(startMarker, endMarker);
|
|
2425
|
+
const hostRoot = getCurrentRoot();
|
|
2426
|
+
let currentNodes = [];
|
|
2427
|
+
let currentRoot2 = null;
|
|
2428
|
+
let lastCondition = void 0;
|
|
2429
|
+
let pendingRender = false;
|
|
2430
|
+
const conditionMemo = computed(condition);
|
|
2431
|
+
const runConditional = () => {
|
|
2432
|
+
const cond = conditionMemo();
|
|
2433
|
+
const parent = startMarker.parentNode;
|
|
2434
|
+
if (!parent) {
|
|
2435
|
+
pendingRender = true;
|
|
2436
|
+
return;
|
|
2437
|
+
}
|
|
2438
|
+
pendingRender = false;
|
|
2439
|
+
if (lastCondition === cond && currentNodes.length > 0) {
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
if (lastCondition === cond && lastCondition === false && renderFalse === void 0) {
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
lastCondition = cond;
|
|
2446
|
+
if (currentRoot2) {
|
|
2447
|
+
destroyRoot(currentRoot2);
|
|
2448
|
+
currentRoot2 = null;
|
|
2449
|
+
}
|
|
2450
|
+
removeNodes(currentNodes);
|
|
2451
|
+
currentNodes = [];
|
|
2452
|
+
const render2 = cond ? renderTrue : renderFalse;
|
|
2453
|
+
if (!render2) {
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
const root = createRootContext(hostRoot);
|
|
2457
|
+
const prev = pushRoot(root);
|
|
2458
|
+
let handledError = false;
|
|
2459
|
+
try {
|
|
2460
|
+
const output = untrack(render2);
|
|
2461
|
+
if (output == null || output === false) {
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
const el = createElementFn(output);
|
|
2465
|
+
const nodes = toNodeArray(el);
|
|
2466
|
+
insertNodesBefore(parent, nodes, endMarker);
|
|
2467
|
+
currentNodes = nodes;
|
|
2468
|
+
} catch (err) {
|
|
2469
|
+
if (handleSuspend(err, root)) {
|
|
2470
|
+
handledError = true;
|
|
2471
|
+
destroyRoot(root);
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2474
|
+
if (handleError(err, { source: "renderChild" }, root)) {
|
|
2475
|
+
handledError = true;
|
|
2476
|
+
destroyRoot(root);
|
|
2477
|
+
return;
|
|
2478
|
+
}
|
|
2479
|
+
throw err;
|
|
2480
|
+
} finally {
|
|
2481
|
+
popRoot(prev);
|
|
2482
|
+
if (!handledError) {
|
|
2483
|
+
flushOnMount(root);
|
|
2484
|
+
currentRoot2 = root;
|
|
2485
|
+
} else {
|
|
2486
|
+
currentRoot2 = null;
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
};
|
|
2490
|
+
const dispose = createRenderEffect(runConditional);
|
|
2491
|
+
return {
|
|
2492
|
+
marker: fragment,
|
|
2493
|
+
flush: () => {
|
|
2494
|
+
if (pendingRender) {
|
|
2495
|
+
runConditional();
|
|
2496
|
+
}
|
|
2497
|
+
},
|
|
2498
|
+
dispose: () => {
|
|
2499
|
+
dispose();
|
|
2500
|
+
if (currentRoot2) {
|
|
2501
|
+
destroyRoot(currentRoot2);
|
|
2502
|
+
}
|
|
2503
|
+
removeNodes(currentNodes);
|
|
2504
|
+
currentNodes = [];
|
|
2505
|
+
startMarker.parentNode?.removeChild(startMarker);
|
|
2506
|
+
endMarker.parentNode?.removeChild(endMarker);
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
function createShow(el, condition, displayValue) {
|
|
2511
|
+
const originalDisplay = displayValue ?? el.style.display;
|
|
2512
|
+
createRenderEffect(() => {
|
|
2513
|
+
el.style.display = condition() ? originalDisplay : "none";
|
|
2514
|
+
});
|
|
2515
|
+
}
|
|
2516
|
+
function createPortal(container, render2, createElementFn) {
|
|
2517
|
+
const parentRoot = getCurrentRoot();
|
|
2518
|
+
const marker = document.createComment("fict:portal");
|
|
2519
|
+
container.appendChild(marker);
|
|
2520
|
+
let currentNodes = [];
|
|
2521
|
+
let currentRoot2 = null;
|
|
2522
|
+
const dispose = createRenderEffect(() => {
|
|
2523
|
+
if (currentRoot2) {
|
|
2524
|
+
destroyRoot(currentRoot2);
|
|
2525
|
+
currentRoot2 = null;
|
|
2526
|
+
}
|
|
2527
|
+
if (currentNodes.length > 0) {
|
|
2528
|
+
removeNodes(currentNodes);
|
|
2529
|
+
currentNodes = [];
|
|
2530
|
+
}
|
|
2531
|
+
const root = createRootContext(parentRoot);
|
|
2532
|
+
const prev = pushRoot(root);
|
|
2533
|
+
let handledError = false;
|
|
2534
|
+
try {
|
|
2535
|
+
const output = render2();
|
|
2536
|
+
if (output != null && output !== false) {
|
|
2537
|
+
const el = createElementFn(output);
|
|
2538
|
+
const nodes = toNodeArray(el);
|
|
2539
|
+
if (marker.parentNode) {
|
|
2540
|
+
insertNodesBefore(marker.parentNode, nodes, marker);
|
|
2541
|
+
}
|
|
2542
|
+
currentNodes = nodes;
|
|
2543
|
+
}
|
|
2544
|
+
} catch (err) {
|
|
2545
|
+
if (handleSuspend(err, root)) {
|
|
2546
|
+
handledError = true;
|
|
2547
|
+
destroyRoot(root);
|
|
2548
|
+
currentNodes = [];
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
if (handleError(err, { source: "renderChild" }, root)) {
|
|
2552
|
+
handledError = true;
|
|
2553
|
+
destroyRoot(root);
|
|
2554
|
+
currentNodes = [];
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
throw err;
|
|
2558
|
+
} finally {
|
|
2559
|
+
popRoot(prev);
|
|
2560
|
+
if (!handledError) {
|
|
2561
|
+
flushOnMount(root);
|
|
2562
|
+
currentRoot2 = root;
|
|
2563
|
+
} else {
|
|
2564
|
+
currentRoot2 = null;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
const portalDispose = () => {
|
|
2569
|
+
dispose();
|
|
2570
|
+
if (currentRoot2) {
|
|
2571
|
+
destroyRoot(currentRoot2);
|
|
2572
|
+
}
|
|
2573
|
+
if (currentNodes.length > 0) {
|
|
2574
|
+
removeNodes(currentNodes);
|
|
2575
|
+
}
|
|
2576
|
+
marker.parentNode?.removeChild(marker);
|
|
2577
|
+
};
|
|
2578
|
+
if (parentRoot) {
|
|
2579
|
+
parentRoot.destroyCallbacks.push(portalDispose);
|
|
2580
|
+
}
|
|
2581
|
+
return {
|
|
2582
|
+
marker,
|
|
2583
|
+
dispose: portalDispose
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
// src/memo.ts
|
|
2588
|
+
function createMemo(fn) {
|
|
2589
|
+
return computed(fn);
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
// src/hooks.ts
|
|
2593
|
+
var isDev6 = true ? false : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
2594
|
+
var ctxStack = [];
|
|
2595
|
+
function assertRenderContext(ctx, hookName) {
|
|
2596
|
+
if (!ctx.rendering) {
|
|
2597
|
+
const message = isDev6 ? `${hookName} can only be used during render execution` : "FICT:E_HOOK_RENDER";
|
|
2598
|
+
throw new Error(message);
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
function __fictUseContext() {
|
|
2602
|
+
if (ctxStack.length === 0) {
|
|
2603
|
+
const ctx2 = { slots: [], cursor: 0, rendering: true };
|
|
2604
|
+
ctxStack.push(ctx2);
|
|
2605
|
+
return ctx2;
|
|
2606
|
+
}
|
|
2607
|
+
const ctx = ctxStack[ctxStack.length - 1];
|
|
2608
|
+
ctx.cursor = 0;
|
|
2609
|
+
ctx.rendering = true;
|
|
2610
|
+
return ctx;
|
|
2611
|
+
}
|
|
2612
|
+
function __fictPushContext() {
|
|
2613
|
+
const ctx = { slots: [], cursor: 0 };
|
|
2614
|
+
ctxStack.push(ctx);
|
|
2615
|
+
return ctx;
|
|
2616
|
+
}
|
|
2617
|
+
function __fictPopContext() {
|
|
2618
|
+
ctxStack.pop();
|
|
2619
|
+
}
|
|
2620
|
+
function __fictResetContext() {
|
|
2621
|
+
ctxStack.length = 0;
|
|
2622
|
+
}
|
|
2623
|
+
function __fictUseSignal(ctx, initial, slot) {
|
|
2624
|
+
assertRenderContext(ctx, "__fictUseSignal");
|
|
2625
|
+
const index = slot ?? ctx.cursor++;
|
|
2626
|
+
if (!ctx.slots[index]) {
|
|
2627
|
+
ctx.slots[index] = signal(initial);
|
|
2628
|
+
}
|
|
2629
|
+
return ctx.slots[index];
|
|
2630
|
+
}
|
|
2631
|
+
function __fictUseMemo(ctx, fn, slot) {
|
|
2632
|
+
assertRenderContext(ctx, "__fictUseMemo");
|
|
2633
|
+
const index = slot ?? ctx.cursor++;
|
|
2634
|
+
if (!ctx.slots[index]) {
|
|
2635
|
+
ctx.slots[index] = createMemo(fn);
|
|
2636
|
+
}
|
|
2637
|
+
return ctx.slots[index];
|
|
2638
|
+
}
|
|
2639
|
+
function __fictUseEffect(ctx, fn, slot) {
|
|
2640
|
+
assertRenderContext(ctx, "__fictUseEffect");
|
|
2641
|
+
const index = slot ?? ctx.cursor++;
|
|
2642
|
+
if (!ctx.slots[index]) {
|
|
2643
|
+
ctx.slots[index] = createEffect(fn);
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
function __fictRender(ctx, fn) {
|
|
2647
|
+
ctxStack.push(ctx);
|
|
2648
|
+
ctx.cursor = 0;
|
|
2649
|
+
ctx.rendering = true;
|
|
2650
|
+
try {
|
|
2651
|
+
return fn();
|
|
2652
|
+
} finally {
|
|
2653
|
+
ctx.rendering = false;
|
|
2654
|
+
ctxStack.pop();
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
// src/props.ts
|
|
2659
|
+
var propGetters = /* @__PURE__ */ new WeakSet();
|
|
2660
|
+
var rawToProxy = /* @__PURE__ */ new WeakMap();
|
|
2661
|
+
var proxyToRaw = /* @__PURE__ */ new WeakMap();
|
|
2662
|
+
function __fictProp(getter) {
|
|
2663
|
+
if (typeof getter === "function" && getter.length === 0) {
|
|
2664
|
+
propGetters.add(getter);
|
|
2665
|
+
}
|
|
2666
|
+
return getter;
|
|
2667
|
+
}
|
|
2668
|
+
function isPropGetter(value) {
|
|
2669
|
+
return typeof value === "function" && propGetters.has(value);
|
|
2670
|
+
}
|
|
2671
|
+
function createPropsProxy(props) {
|
|
2672
|
+
if (!props || typeof props !== "object") {
|
|
2673
|
+
return props;
|
|
2674
|
+
}
|
|
2675
|
+
if (proxyToRaw.has(props)) {
|
|
2676
|
+
return props;
|
|
2677
|
+
}
|
|
2678
|
+
const cached = rawToProxy.get(props);
|
|
2679
|
+
if (cached) {
|
|
2680
|
+
return cached;
|
|
2681
|
+
}
|
|
2682
|
+
const proxy = new Proxy(props, {
|
|
2683
|
+
get(target, prop2, receiver) {
|
|
2684
|
+
const value = Reflect.get(target, prop2, receiver);
|
|
2685
|
+
if (isPropGetter(value)) {
|
|
2686
|
+
return value();
|
|
2687
|
+
}
|
|
2688
|
+
return value;
|
|
2689
|
+
},
|
|
2690
|
+
set(target, prop2, value, receiver) {
|
|
2691
|
+
return Reflect.set(target, prop2, value, receiver);
|
|
2692
|
+
},
|
|
2693
|
+
has(target, prop2) {
|
|
2694
|
+
return prop2 in target;
|
|
2695
|
+
},
|
|
2696
|
+
ownKeys(target) {
|
|
2697
|
+
return Reflect.ownKeys(target);
|
|
2698
|
+
},
|
|
2699
|
+
getOwnPropertyDescriptor(target, prop2) {
|
|
2700
|
+
return Object.getOwnPropertyDescriptor(target, prop2);
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
rawToProxy.set(props, proxy);
|
|
2704
|
+
proxyToRaw.set(proxy, props);
|
|
2705
|
+
return proxy;
|
|
2706
|
+
}
|
|
2707
|
+
function unwrapProps(props) {
|
|
2708
|
+
if (!props || typeof props !== "object") {
|
|
2709
|
+
return props;
|
|
2710
|
+
}
|
|
2711
|
+
return proxyToRaw.get(props) ?? props;
|
|
2712
|
+
}
|
|
2713
|
+
function __fictPropsRest(props, exclude) {
|
|
2714
|
+
const raw = unwrapProps(props);
|
|
2715
|
+
const out = {};
|
|
2716
|
+
const excludeSet = new Set(exclude);
|
|
2717
|
+
for (const key of Reflect.ownKeys(raw)) {
|
|
2718
|
+
if (excludeSet.has(key)) continue;
|
|
2719
|
+
out[key] = raw[key];
|
|
2720
|
+
}
|
|
2721
|
+
return createPropsProxy(out);
|
|
2722
|
+
}
|
|
2723
|
+
function mergeProps(...sources) {
|
|
2724
|
+
const validSources = sources.filter(
|
|
2725
|
+
(s) => s != null && (typeof s === "object" || typeof s === "function")
|
|
2726
|
+
);
|
|
2727
|
+
if (validSources.length === 0) {
|
|
2728
|
+
return {};
|
|
2729
|
+
}
|
|
2730
|
+
if (validSources.length === 1 && typeof validSources[0] === "object") {
|
|
2731
|
+
return validSources[0];
|
|
2732
|
+
}
|
|
2733
|
+
const resolveSource = (src) => {
|
|
2734
|
+
const value = typeof src === "function" ? src() : src;
|
|
2735
|
+
if (!value || typeof value !== "object") return void 0;
|
|
2736
|
+
return unwrapProps(value);
|
|
2737
|
+
};
|
|
2738
|
+
const hasProp = (prop2) => {
|
|
2739
|
+
for (const src of validSources) {
|
|
2740
|
+
const raw = resolveSource(src);
|
|
2741
|
+
if (raw && prop2 in raw) {
|
|
2742
|
+
return true;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
return false;
|
|
2746
|
+
};
|
|
2747
|
+
const readProp = (prop2) => {
|
|
2748
|
+
for (let i = validSources.length - 1; i >= 0; i--) {
|
|
2749
|
+
const src = validSources[i];
|
|
2750
|
+
const raw = resolveSource(src);
|
|
2751
|
+
if (!raw || !(prop2 in raw)) continue;
|
|
2752
|
+
const value = raw[prop2];
|
|
2753
|
+
if (typeof src === "function" && !isPropGetter(value)) {
|
|
2754
|
+
return __fictProp(() => {
|
|
2755
|
+
const latest = resolveSource(src);
|
|
2756
|
+
if (!latest || !(prop2 in latest)) return void 0;
|
|
2757
|
+
return latest[prop2];
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
return value;
|
|
2761
|
+
}
|
|
2762
|
+
return void 0;
|
|
2763
|
+
};
|
|
2764
|
+
return new Proxy({}, {
|
|
2765
|
+
get(_, prop2) {
|
|
2766
|
+
return readProp(prop2);
|
|
2767
|
+
},
|
|
2768
|
+
has(_, prop2) {
|
|
2769
|
+
return hasProp(prop2);
|
|
2770
|
+
},
|
|
2771
|
+
ownKeys() {
|
|
2772
|
+
const keys = /* @__PURE__ */ new Set();
|
|
2773
|
+
for (const src of validSources) {
|
|
2774
|
+
const raw = resolveSource(src);
|
|
2775
|
+
if (raw) {
|
|
2776
|
+
for (const key of Reflect.ownKeys(raw)) {
|
|
2777
|
+
keys.add(key);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return Array.from(keys);
|
|
2782
|
+
},
|
|
2783
|
+
getOwnPropertyDescriptor(_, prop2) {
|
|
2784
|
+
if (!hasProp(prop2)) return void 0;
|
|
2785
|
+
return {
|
|
2786
|
+
enumerable: true,
|
|
2787
|
+
configurable: true,
|
|
2788
|
+
get: () => readProp(prop2)
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
function prop(getter) {
|
|
2794
|
+
if (isPropGetter(getter)) {
|
|
2795
|
+
return getter;
|
|
2796
|
+
}
|
|
2797
|
+
return __fictProp(createMemo(getter));
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
// src/dom.ts
|
|
2801
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
2802
|
+
var MATHML_NS = "http://www.w3.org/1998/Math/MathML";
|
|
2803
|
+
var isDev7 = true ? false : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
2804
|
+
function render(view, container) {
|
|
2805
|
+
const root = createRootContext();
|
|
2806
|
+
const prev = pushRoot(root);
|
|
2807
|
+
let dom;
|
|
2808
|
+
try {
|
|
2809
|
+
const output = view();
|
|
2810
|
+
dom = createElement(output);
|
|
2811
|
+
} finally {
|
|
2812
|
+
popRoot(prev);
|
|
2813
|
+
}
|
|
2814
|
+
container.replaceChildren(dom);
|
|
2815
|
+
container.setAttribute("data-fict-fine-grained", "1");
|
|
2816
|
+
flushOnMount(root);
|
|
2817
|
+
const teardown = () => {
|
|
2818
|
+
destroyRoot(root);
|
|
2819
|
+
container.innerHTML = "";
|
|
2820
|
+
};
|
|
2821
|
+
return teardown;
|
|
2822
|
+
}
|
|
2823
|
+
function createElement(node) {
|
|
2824
|
+
return createElementWithContext(node, null);
|
|
2825
|
+
}
|
|
2826
|
+
function resolveNamespace(tagName, namespace) {
|
|
2827
|
+
if (tagName === "svg") return "svg";
|
|
2828
|
+
if (tagName === "math") return "mathml";
|
|
2829
|
+
if (namespace === "mathml") return "mathml";
|
|
2830
|
+
if (namespace === "svg") return "svg";
|
|
2831
|
+
if (isDev7 && SVGElements.has(tagName)) return "svg";
|
|
2832
|
+
return null;
|
|
2833
|
+
}
|
|
2834
|
+
function createElementWithContext(node, namespace) {
|
|
2835
|
+
if (node instanceof Node) {
|
|
2836
|
+
return node;
|
|
2837
|
+
}
|
|
2838
|
+
if (node === null || node === void 0 || node === false) {
|
|
2839
|
+
return document.createTextNode("");
|
|
2840
|
+
}
|
|
2841
|
+
if (typeof node === "object" && node !== null && !(node instanceof Node)) {
|
|
2842
|
+
if ("marker" in node) {
|
|
2843
|
+
const handle = node;
|
|
2844
|
+
if (typeof handle.dispose === "function") {
|
|
2845
|
+
registerRootCleanup(handle.dispose);
|
|
2846
|
+
}
|
|
2847
|
+
if (typeof handle.flush === "function") {
|
|
2848
|
+
const runFlush = () => handle.flush && handle.flush();
|
|
2849
|
+
if (typeof queueMicrotask === "function") {
|
|
2850
|
+
queueMicrotask(runFlush);
|
|
2851
|
+
} else {
|
|
2852
|
+
Promise.resolve().then(runFlush).catch(() => void 0);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
return createElement(handle.marker);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
if (Array.isArray(node)) {
|
|
2859
|
+
const frag = document.createDocumentFragment();
|
|
2860
|
+
for (const child of node) {
|
|
2861
|
+
appendChildNode(frag, child, namespace);
|
|
2862
|
+
}
|
|
2863
|
+
return frag;
|
|
2864
|
+
}
|
|
2865
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
2866
|
+
return document.createTextNode(String(node));
|
|
2867
|
+
}
|
|
2868
|
+
if (typeof node === "boolean") {
|
|
2869
|
+
return document.createTextNode("");
|
|
2870
|
+
}
|
|
2871
|
+
const vnode = node;
|
|
2872
|
+
if (typeof vnode.type === "function") {
|
|
2873
|
+
const rawProps = unwrapProps(vnode.props ?? {});
|
|
2874
|
+
const baseProps = vnode.key === void 0 ? rawProps : new Proxy(rawProps, {
|
|
2875
|
+
get(target, prop2, receiver) {
|
|
2876
|
+
if (prop2 === "key") return vnode.key;
|
|
2877
|
+
return Reflect.get(target, prop2, receiver);
|
|
2878
|
+
},
|
|
2879
|
+
has(target, prop2) {
|
|
2880
|
+
if (prop2 === "key") return true;
|
|
2881
|
+
return prop2 in target;
|
|
2882
|
+
},
|
|
2883
|
+
ownKeys(target) {
|
|
2884
|
+
const keys = new Set(Reflect.ownKeys(target));
|
|
2885
|
+
keys.add("key");
|
|
2886
|
+
return Array.from(keys);
|
|
2887
|
+
},
|
|
2888
|
+
getOwnPropertyDescriptor(target, prop2) {
|
|
2889
|
+
if (prop2 === "key") {
|
|
2890
|
+
return { enumerable: true, configurable: true, value: vnode.key };
|
|
2891
|
+
}
|
|
2892
|
+
return Object.getOwnPropertyDescriptor(target, prop2);
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
const props = createPropsProxy(baseProps);
|
|
2896
|
+
__fictPushContext();
|
|
2897
|
+
try {
|
|
2898
|
+
const rendered = vnode.type(props);
|
|
2899
|
+
return createElementWithContext(rendered, namespace);
|
|
2900
|
+
} catch (err) {
|
|
2901
|
+
if (handleSuspend(err)) {
|
|
2902
|
+
return document.createComment("fict:suspend");
|
|
2903
|
+
}
|
|
2904
|
+
handleError(err, { source: "render", componentName: vnode.type.name });
|
|
2905
|
+
throw err;
|
|
2906
|
+
} finally {
|
|
2907
|
+
__fictPopContext();
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
if (vnode.type === Fragment) {
|
|
2911
|
+
const frag = document.createDocumentFragment();
|
|
2912
|
+
const children = vnode.props?.children;
|
|
2913
|
+
appendChildren(frag, children, namespace);
|
|
2914
|
+
return frag;
|
|
2915
|
+
}
|
|
2916
|
+
const tagName = typeof vnode.type === "string" ? vnode.type : "div";
|
|
2917
|
+
const resolvedNamespace = resolveNamespace(tagName, namespace);
|
|
2918
|
+
const el = resolvedNamespace === "svg" ? document.createElementNS(SVG_NS, tagName) : resolvedNamespace === "mathml" ? document.createElementNS(MATHML_NS, tagName) : document.createElement(tagName);
|
|
2919
|
+
applyProps(el, vnode.props ?? {}, resolvedNamespace === "svg");
|
|
2920
|
+
appendChildren(
|
|
2921
|
+
el,
|
|
2922
|
+
vnode.props?.children,
|
|
2923
|
+
tagName === "foreignObject" ? null : resolvedNamespace
|
|
2924
|
+
);
|
|
2925
|
+
return el;
|
|
2926
|
+
}
|
|
2927
|
+
function template(html, isImportNode, isSVG, isMathML) {
|
|
2928
|
+
let node = null;
|
|
2929
|
+
const create = () => {
|
|
2930
|
+
const t = isMathML ? document.createElementNS(MATHML_NS, "template") : document.createElement("template");
|
|
2931
|
+
t.innerHTML = html;
|
|
2932
|
+
if (isSVG) {
|
|
2933
|
+
return t.content.firstChild.firstChild;
|
|
2934
|
+
}
|
|
2935
|
+
if (isMathML) {
|
|
2936
|
+
return t.firstChild;
|
|
2937
|
+
}
|
|
2938
|
+
return t.content.firstChild;
|
|
2939
|
+
};
|
|
2940
|
+
const fn = isImportNode ? () => untrack2(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
2941
|
+
fn.cloneNode = fn;
|
|
2942
|
+
return fn;
|
|
2943
|
+
}
|
|
2944
|
+
function isBindingHandle(node) {
|
|
2945
|
+
return node !== null && typeof node === "object" && "marker" in node && "dispose" in node && typeof node.dispose === "function";
|
|
2946
|
+
}
|
|
2947
|
+
function appendChildNode(parent, child, namespace) {
|
|
2948
|
+
if (child === null || child === void 0 || child === false) {
|
|
2949
|
+
return;
|
|
2950
|
+
}
|
|
2951
|
+
if (isBindingHandle(child)) {
|
|
2952
|
+
appendChildNode(parent, child.marker, namespace);
|
|
2953
|
+
child.flush?.();
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
if (typeof child === "function" && child.length === 0) {
|
|
2957
|
+
const childGetter = child;
|
|
2958
|
+
createChildBinding(parent, childGetter, (node) => createElementWithContext(node, namespace));
|
|
2959
|
+
return;
|
|
2960
|
+
}
|
|
2961
|
+
if (Array.isArray(child)) {
|
|
2962
|
+
for (const item of child) {
|
|
2963
|
+
appendChildNode(parent, item, namespace);
|
|
2964
|
+
}
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
let domNode;
|
|
2968
|
+
if (typeof child !== "object" || child === null) {
|
|
2969
|
+
domNode = document.createTextNode(String(child ?? ""));
|
|
2970
|
+
} else {
|
|
2971
|
+
domNode = createElementWithContext(child, namespace);
|
|
2972
|
+
}
|
|
2973
|
+
if (domNode.nodeType === 11) {
|
|
2974
|
+
const children = Array.from(domNode.childNodes);
|
|
2975
|
+
for (const node of children) {
|
|
2976
|
+
appendChildNode(parent, node, namespace);
|
|
2977
|
+
}
|
|
2978
|
+
return;
|
|
2979
|
+
}
|
|
2980
|
+
if (domNode.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
|
|
2981
|
+
parent.ownerDocument.adoptNode(domNode);
|
|
2982
|
+
}
|
|
2983
|
+
try {
|
|
2984
|
+
parent.appendChild(domNode);
|
|
2985
|
+
} catch (e) {
|
|
2986
|
+
if (parent.ownerDocument) {
|
|
2987
|
+
const clone = parent.ownerDocument.importNode(domNode, true);
|
|
2988
|
+
parent.appendChild(clone);
|
|
2989
|
+
return;
|
|
2990
|
+
}
|
|
2991
|
+
throw e;
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
function appendChildren(parent, children, namespace) {
|
|
2995
|
+
if (children === void 0) return;
|
|
2996
|
+
if (Array.isArray(children)) {
|
|
2997
|
+
for (const child of children) {
|
|
2998
|
+
appendChildren(parent, child, namespace);
|
|
2999
|
+
}
|
|
3000
|
+
return;
|
|
3001
|
+
}
|
|
3002
|
+
appendChildNode(parent, children, namespace);
|
|
3003
|
+
}
|
|
3004
|
+
function applyRef(el, value) {
|
|
3005
|
+
if (typeof value === "function") {
|
|
3006
|
+
const refFn = value;
|
|
3007
|
+
refFn(el);
|
|
3008
|
+
const root = getCurrentRoot();
|
|
3009
|
+
if (root) {
|
|
3010
|
+
registerRootCleanup(() => {
|
|
3011
|
+
refFn(null);
|
|
3012
|
+
});
|
|
3013
|
+
} else if (isDev7) {
|
|
3014
|
+
console.warn(
|
|
3015
|
+
"[fict] Ref applied outside of a root context. The ref cleanup (setting to null) will not run automatically. Consider using createRoot() or ensure the element is created within a component."
|
|
3016
|
+
);
|
|
3017
|
+
}
|
|
3018
|
+
} else if (value && typeof value === "object" && "current" in value) {
|
|
3019
|
+
const refObj = value;
|
|
3020
|
+
refObj.current = el;
|
|
3021
|
+
const root = getCurrentRoot();
|
|
3022
|
+
if (root) {
|
|
3023
|
+
registerRootCleanup(() => {
|
|
3024
|
+
refObj.current = null;
|
|
3025
|
+
});
|
|
3026
|
+
} else if (isDev7) {
|
|
3027
|
+
console.warn(
|
|
3028
|
+
"[fict] Ref applied outside of a root context. The ref cleanup (setting to null) will not run automatically. Consider using createRoot() or ensure the element is created within a component."
|
|
3029
|
+
);
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
function applyProps(el, props, isSVG = false) {
|
|
3034
|
+
props = unwrapProps(props);
|
|
3035
|
+
const tagName = el.tagName;
|
|
3036
|
+
const isCE = tagName.includes("-") || "is" in props;
|
|
3037
|
+
for (const [key, value] of Object.entries(props)) {
|
|
3038
|
+
if (key === "children") continue;
|
|
3039
|
+
if (key === "ref") {
|
|
3040
|
+
applyRef(el, value);
|
|
3041
|
+
continue;
|
|
3042
|
+
}
|
|
3043
|
+
if (isEventKey(key)) {
|
|
3044
|
+
bindEvent(
|
|
3045
|
+
el,
|
|
3046
|
+
eventNameFromProp(key),
|
|
3047
|
+
value
|
|
3048
|
+
);
|
|
3049
|
+
continue;
|
|
3050
|
+
}
|
|
3051
|
+
if (key.slice(0, 3) === "on:") {
|
|
3052
|
+
bindEvent(
|
|
3053
|
+
el,
|
|
3054
|
+
key.slice(3),
|
|
3055
|
+
value,
|
|
3056
|
+
false
|
|
3057
|
+
// Non-delegated
|
|
3058
|
+
);
|
|
3059
|
+
continue;
|
|
3060
|
+
}
|
|
3061
|
+
if (key.slice(0, 10) === "oncapture:") {
|
|
3062
|
+
bindEvent(
|
|
3063
|
+
el,
|
|
3064
|
+
key.slice(10),
|
|
3065
|
+
value,
|
|
3066
|
+
true
|
|
3067
|
+
// Capture
|
|
3068
|
+
);
|
|
3069
|
+
continue;
|
|
3070
|
+
}
|
|
3071
|
+
if (key === "class" || key === "className") {
|
|
3072
|
+
createClassBinding(el, value);
|
|
3073
|
+
continue;
|
|
3074
|
+
}
|
|
3075
|
+
if (key === "classList") {
|
|
3076
|
+
createClassBinding(el, value);
|
|
3077
|
+
continue;
|
|
3078
|
+
}
|
|
3079
|
+
if (key === "style") {
|
|
3080
|
+
createStyleBinding(
|
|
3081
|
+
el,
|
|
3082
|
+
value
|
|
3083
|
+
);
|
|
3084
|
+
continue;
|
|
3085
|
+
}
|
|
3086
|
+
if (key === "dangerouslySetInnerHTML" && value && typeof value === "object") {
|
|
3087
|
+
const htmlValue = value.__html;
|
|
3088
|
+
if (htmlValue !== void 0) {
|
|
3089
|
+
if (isReactive(htmlValue)) {
|
|
3090
|
+
createAttributeBinding(el, "innerHTML", htmlValue, setInnerHTML);
|
|
3091
|
+
} else {
|
|
3092
|
+
el.innerHTML = htmlValue;
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
continue;
|
|
3096
|
+
}
|
|
3097
|
+
if (isDev7 && ChildProperties.has(key) || key === "innerHTML" || key === "textContent" || key === "innerText" || key === "children") {
|
|
3098
|
+
createAttributeBinding(el, key, value, setProperty);
|
|
3099
|
+
continue;
|
|
3100
|
+
}
|
|
3101
|
+
if (key.slice(0, 5) === "attr:") {
|
|
3102
|
+
createAttributeBinding(el, key.slice(5), value, setAttribute);
|
|
3103
|
+
continue;
|
|
3104
|
+
}
|
|
3105
|
+
if (key.slice(0, 5) === "bool:") {
|
|
3106
|
+
createAttributeBinding(el, key.slice(5), value, setBoolAttribute);
|
|
3107
|
+
continue;
|
|
3108
|
+
}
|
|
3109
|
+
if (key.slice(0, 5) === "prop:") {
|
|
3110
|
+
createAttributeBinding(el, key.slice(5), value, setProperty);
|
|
3111
|
+
continue;
|
|
3112
|
+
}
|
|
3113
|
+
const propAlias = !isSVG && isDev7 ? getPropAlias(key, tagName) : void 0;
|
|
3114
|
+
const isProperty = !isSVG ? isDev7 ? Properties.has(key) : key in el : false;
|
|
3115
|
+
if (propAlias || isProperty || isCE && !isSVG) {
|
|
3116
|
+
const propName = propAlias || key;
|
|
3117
|
+
if (isCE && !isProperty && !propAlias) {
|
|
3118
|
+
createAttributeBinding(
|
|
3119
|
+
el,
|
|
3120
|
+
toPropertyName2(propName),
|
|
3121
|
+
value,
|
|
3122
|
+
setProperty
|
|
3123
|
+
);
|
|
3124
|
+
} else {
|
|
3125
|
+
createAttributeBinding(el, propName, value, setProperty);
|
|
3126
|
+
}
|
|
3127
|
+
continue;
|
|
3128
|
+
}
|
|
3129
|
+
if (isSVG && key.indexOf(":") > -1) {
|
|
3130
|
+
const [prefix, name] = key.split(":");
|
|
3131
|
+
const ns = SVGNamespace[prefix];
|
|
3132
|
+
if (ns) {
|
|
3133
|
+
createAttributeBinding(
|
|
3134
|
+
el,
|
|
3135
|
+
key,
|
|
3136
|
+
value,
|
|
3137
|
+
(el2, _key, val) => setAttributeNS(el2, ns, name, val)
|
|
3138
|
+
);
|
|
3139
|
+
continue;
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
const attrName = key === "htmlFor" ? "for" : key;
|
|
3143
|
+
createAttributeBinding(el, attrName, value, setAttribute);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
function toPropertyName2(name) {
|
|
3147
|
+
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
3148
|
+
}
|
|
3149
|
+
var setAttribute = (el, key, value) => {
|
|
3150
|
+
if (value === void 0 || value === null || value === false) {
|
|
3151
|
+
el.removeAttribute(key);
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3154
|
+
if (value === true) {
|
|
3155
|
+
el.setAttribute(key, "");
|
|
3156
|
+
return;
|
|
3157
|
+
}
|
|
3158
|
+
const valueType = typeof value;
|
|
3159
|
+
if (valueType === "string" || valueType === "number") {
|
|
3160
|
+
el.setAttribute(key, String(value));
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
if (key in el) {
|
|
3164
|
+
;
|
|
3165
|
+
el[key] = value;
|
|
3166
|
+
return;
|
|
3167
|
+
}
|
|
3168
|
+
el.setAttribute(key, String(value));
|
|
3169
|
+
};
|
|
3170
|
+
var setProperty = (el, key, value) => {
|
|
3171
|
+
if (value === void 0 || value === null) {
|
|
3172
|
+
const fallback = key === "checked" || key === "selected" ? false : "";
|
|
3173
|
+
el[key] = fallback;
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
if (key === "style" && typeof value === "object" && value !== null) {
|
|
3177
|
+
for (const k in value) {
|
|
3178
|
+
const v = value[k];
|
|
3179
|
+
if (v !== void 0) {
|
|
3180
|
+
;
|
|
3181
|
+
el.style[k] = String(v);
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
;
|
|
3187
|
+
el[key] = value;
|
|
3188
|
+
};
|
|
3189
|
+
var setInnerHTML = (el, _key, value) => {
|
|
3190
|
+
;
|
|
3191
|
+
el.innerHTML = value == null ? "" : String(value);
|
|
3192
|
+
};
|
|
3193
|
+
var setBoolAttribute = (el, key, value) => {
|
|
3194
|
+
if (value) {
|
|
3195
|
+
el.setAttribute(key, "");
|
|
3196
|
+
} else {
|
|
3197
|
+
el.removeAttribute(key);
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
function setAttributeNS(el, namespace, name, value) {
|
|
3201
|
+
if (value == null) {
|
|
3202
|
+
el.removeAttributeNS(namespace, name);
|
|
3203
|
+
} else {
|
|
3204
|
+
el.setAttributeNS(namespace, name, String(value));
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
function isEventKey(key) {
|
|
3208
|
+
return key.startsWith("on") && key.length > 2 && key[2].toUpperCase() === key[2];
|
|
3209
|
+
}
|
|
3210
|
+
function eventNameFromProp(key) {
|
|
3211
|
+
return key.slice(2).toLowerCase();
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
export {
|
|
3215
|
+
BooleanAttributes,
|
|
3216
|
+
Properties,
|
|
3217
|
+
ChildProperties,
|
|
3218
|
+
Aliases,
|
|
3219
|
+
getPropAlias,
|
|
3220
|
+
DelegatedEvents,
|
|
3221
|
+
SVGElements,
|
|
3222
|
+
SVGNamespace,
|
|
3223
|
+
UnitlessStyles,
|
|
3224
|
+
getDevtoolsHook,
|
|
3225
|
+
setCycleProtectionOptions,
|
|
3226
|
+
createRootContext,
|
|
3227
|
+
pushRoot,
|
|
3228
|
+
getCurrentRoot,
|
|
3229
|
+
popRoot,
|
|
3230
|
+
onMount,
|
|
3231
|
+
onDestroy,
|
|
3232
|
+
onCleanup,
|
|
3233
|
+
flushOnMount,
|
|
3234
|
+
registerRootCleanup,
|
|
3235
|
+
destroyRoot,
|
|
3236
|
+
createRoot,
|
|
3237
|
+
registerErrorHandler,
|
|
3238
|
+
registerSuspenseHandler,
|
|
3239
|
+
handleError,
|
|
3240
|
+
flush,
|
|
3241
|
+
signal,
|
|
3242
|
+
effectScope,
|
|
3243
|
+
batch,
|
|
3244
|
+
setActiveSub,
|
|
3245
|
+
untrack,
|
|
3246
|
+
createSelector,
|
|
3247
|
+
createEffect,
|
|
3248
|
+
createRenderEffect,
|
|
3249
|
+
Fragment,
|
|
3250
|
+
toNodeArray,
|
|
3251
|
+
insertNodesBefore,
|
|
3252
|
+
removeNodes,
|
|
3253
|
+
startTransition,
|
|
3254
|
+
useTransition,
|
|
3255
|
+
useDeferredValue,
|
|
3256
|
+
batch2,
|
|
3257
|
+
untrack2,
|
|
3258
|
+
isReactive,
|
|
3259
|
+
unwrap,
|
|
3260
|
+
callEventHandler,
|
|
3261
|
+
createTextBinding,
|
|
3262
|
+
bindText,
|
|
3263
|
+
createAttributeBinding,
|
|
3264
|
+
bindAttribute,
|
|
3265
|
+
bindProperty,
|
|
3266
|
+
createStyleBinding,
|
|
3267
|
+
bindStyle,
|
|
3268
|
+
createClassBinding,
|
|
3269
|
+
bindClass,
|
|
3270
|
+
classList,
|
|
3271
|
+
insert,
|
|
3272
|
+
createChildBinding,
|
|
3273
|
+
delegateEvents,
|
|
3274
|
+
clearDelegatedEvents,
|
|
3275
|
+
addEventListener,
|
|
3276
|
+
bindEvent,
|
|
3277
|
+
bindRef,
|
|
3278
|
+
spread,
|
|
3279
|
+
assign,
|
|
3280
|
+
createConditional,
|
|
3281
|
+
createShow,
|
|
3282
|
+
createPortal,
|
|
3283
|
+
createMemo,
|
|
3284
|
+
__fictUseContext,
|
|
3285
|
+
__fictPushContext,
|
|
3286
|
+
__fictPopContext,
|
|
3287
|
+
__fictResetContext,
|
|
3288
|
+
__fictUseSignal,
|
|
3289
|
+
__fictUseMemo,
|
|
3290
|
+
__fictUseEffect,
|
|
3291
|
+
__fictRender,
|
|
3292
|
+
__fictProp,
|
|
3293
|
+
createPropsProxy,
|
|
3294
|
+
__fictPropsRest,
|
|
3295
|
+
mergeProps,
|
|
3296
|
+
prop,
|
|
3297
|
+
render,
|
|
3298
|
+
createElement,
|
|
3299
|
+
template
|
|
3300
|
+
};
|
|
3301
|
+
//# sourceMappingURL=chunk-RY4WDS6R.js.map
|