essor 0.0.15 → 0.0.16-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/dist/chunk-FIBC7TTZ.esm.js +4361 -0
- package/dist/chunk-FIBC7TTZ.esm.js.map +1 -0
- package/dist/chunk-LKZM76RW.dev.esm.js +19 -0
- package/dist/chunk-LKZM76RW.dev.esm.js.map +1 -0
- package/dist/essor.cjs.js +2049 -1760
- package/dist/essor.cjs.js.map +1 -1
- package/dist/essor.d.cts +1 -1
- package/dist/essor.d.ts +1 -1
- package/dist/essor.dev.cjs.js +9 -9
- package/dist/essor.dev.cjs.js.map +1 -1
- package/dist/essor.dev.esm.js +3 -3
- package/dist/essor.esm.js +4 -4
- package/dist/server.cjs.js +402 -251
- package/dist/server.cjs.js.map +1 -1
- package/dist/server.dev.cjs.js +5 -5
- package/dist/server.dev.cjs.js.map +1 -1
- package/dist/server.dev.esm.js +5 -4
- package/dist/server.dev.esm.js.map +1 -1
- package/dist/server.esm.js +253 -56
- package/dist/server.esm.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-JCUBHQNX.dev.esm.js +0 -19
- package/dist/chunk-JCUBHQNX.dev.esm.js.map +0 -1
- package/dist/chunk-OUS4E62E.esm.js +0 -4038
- package/dist/chunk-OUS4E62E.esm.js.map +0 -1
|
@@ -0,0 +1,4361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* essor v0.0.16-beta.2
|
|
3
|
+
* build time 2026-05-08T05:50:51.766Z
|
|
4
|
+
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
5
|
+
* @license MIT
|
|
6
|
+
**/
|
|
7
|
+
|
|
8
|
+
// src/version.ts
|
|
9
|
+
var __version = "0.0.16-beta.2";
|
|
10
|
+
|
|
11
|
+
// ../shared/dist/shared.esm.js
|
|
12
|
+
var isObject = (val) => val !== null && typeof val === "object";
|
|
13
|
+
function isPromise(val) {
|
|
14
|
+
return _toString.call(val) === "[object Promise]";
|
|
15
|
+
}
|
|
16
|
+
var isArray = Array.isArray;
|
|
17
|
+
function isString(val) {
|
|
18
|
+
return typeof val === "string";
|
|
19
|
+
}
|
|
20
|
+
function isNumber(val) {
|
|
21
|
+
return typeof val === "number";
|
|
22
|
+
}
|
|
23
|
+
function isSymbol(val) {
|
|
24
|
+
return typeof val === "symbol";
|
|
25
|
+
}
|
|
26
|
+
function isSet(val) {
|
|
27
|
+
return _toString.call(val) === "[object Set]";
|
|
28
|
+
}
|
|
29
|
+
function isWeakMap(val) {
|
|
30
|
+
return _toString.call(val) === "[object WeakMap]";
|
|
31
|
+
}
|
|
32
|
+
function isWeakSet(val) {
|
|
33
|
+
return _toString.call(val) === "[object WeakSet]";
|
|
34
|
+
}
|
|
35
|
+
function isMap(val) {
|
|
36
|
+
return _toString.call(val) === "[object Map]";
|
|
37
|
+
}
|
|
38
|
+
function isNil(val) {
|
|
39
|
+
return val === null || val === void 0;
|
|
40
|
+
}
|
|
41
|
+
var isFunction = (val) => typeof val === "function";
|
|
42
|
+
var isPlainObject = (val) => _toString.call(val) === "[object Object]";
|
|
43
|
+
function isStringNumber(val) {
|
|
44
|
+
if (!isString(val) || val === "") {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return !Number.isNaN(Number(val));
|
|
48
|
+
}
|
|
49
|
+
var _toString = Object.prototype.toString;
|
|
50
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
51
|
+
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
52
|
+
function coerceArray(data) {
|
|
53
|
+
return isArray(data) ? data : [data];
|
|
54
|
+
}
|
|
55
|
+
var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
56
|
+
function isBrowser() {
|
|
57
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
58
|
+
}
|
|
59
|
+
var cacheStringFunction = (fn) => {
|
|
60
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
61
|
+
return ((str) => {
|
|
62
|
+
const hit = cache[str];
|
|
63
|
+
return hit || (cache[str] = fn(str));
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
var isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) >= 65 && // uppercase letter A-Z
|
|
67
|
+
key.charCodeAt(2) <= 90;
|
|
68
|
+
var hyphenateRE = /\B([A-Z])/g;
|
|
69
|
+
var kebabCase = cacheStringFunction(
|
|
70
|
+
(str) => str.replaceAll(hyphenateRE, "-$1").toLowerCase()
|
|
71
|
+
);
|
|
72
|
+
var camelizeRE = /[_-](\w)/g;
|
|
73
|
+
var camelCase = cacheStringFunction((str) => {
|
|
74
|
+
str = str.replaceAll(/^[_-]+|[_-]+$/g, "");
|
|
75
|
+
str = str.replaceAll(/[_-]+/g, "-");
|
|
76
|
+
return str.replaceAll(camelizeRE, (_, c) => c.toUpperCase());
|
|
77
|
+
});
|
|
78
|
+
var capitalize = cacheStringFunction(
|
|
79
|
+
(str) => {
|
|
80
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
function warn(msg, ...args) {
|
|
84
|
+
console.warn(`[Essor warn]: ${msg}`, ...args);
|
|
85
|
+
}
|
|
86
|
+
function error(msg, ...args) {
|
|
87
|
+
console.error(`[Essor error]: ${msg}`, ...args);
|
|
88
|
+
}
|
|
89
|
+
var escapeRE = /["&'<>]/;
|
|
90
|
+
function escapeHTML(string) {
|
|
91
|
+
const str = `${string}`;
|
|
92
|
+
const match = escapeRE.exec(str);
|
|
93
|
+
if (!match) {
|
|
94
|
+
return str;
|
|
95
|
+
}
|
|
96
|
+
let html = "";
|
|
97
|
+
let escaped;
|
|
98
|
+
let index;
|
|
99
|
+
let lastIndex = 0;
|
|
100
|
+
for (index = match.index; index < str.length; index++) {
|
|
101
|
+
switch (str.charCodeAt(index)) {
|
|
102
|
+
case 34:
|
|
103
|
+
escaped = """;
|
|
104
|
+
break;
|
|
105
|
+
case 38:
|
|
106
|
+
escaped = "&";
|
|
107
|
+
break;
|
|
108
|
+
case 39:
|
|
109
|
+
escaped = "'";
|
|
110
|
+
break;
|
|
111
|
+
case 60:
|
|
112
|
+
escaped = "<";
|
|
113
|
+
break;
|
|
114
|
+
case 62:
|
|
115
|
+
escaped = ">";
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (lastIndex !== index) {
|
|
121
|
+
html += str.slice(lastIndex, index);
|
|
122
|
+
}
|
|
123
|
+
lastIndex = index + 1;
|
|
124
|
+
html += escaped;
|
|
125
|
+
}
|
|
126
|
+
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
|
127
|
+
}
|
|
128
|
+
function makeMap(str) {
|
|
129
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
130
|
+
for (const key of str.split(",")) {
|
|
131
|
+
map[key] = 1;
|
|
132
|
+
}
|
|
133
|
+
return (val) => val in map;
|
|
134
|
+
}
|
|
135
|
+
var specialBooleanAttrs = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";
|
|
136
|
+
var isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
|
|
137
|
+
var isBooleanAttr = /* @__PURE__ */ makeMap(
|
|
138
|
+
`${specialBooleanAttrs},async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
|
139
|
+
);
|
|
140
|
+
function includeBooleanAttr(value) {
|
|
141
|
+
return !!value || value === "";
|
|
142
|
+
}
|
|
143
|
+
var STYLE_SEPARATOR_REGEX = /;(?![^(]*\))/g;
|
|
144
|
+
var PROPERTY_VALUE_SEPARATOR_REGEX = /:([\s\S]+)/;
|
|
145
|
+
var STYLE_COMMENT_REGEX = /\/\*[\s\S]*?\*\//g;
|
|
146
|
+
function parseStyleString(cssText) {
|
|
147
|
+
const styleObject = {};
|
|
148
|
+
cssText.replaceAll(STYLE_COMMENT_REGEX, "").split(STYLE_SEPARATOR_REGEX).forEach((styleItem) => {
|
|
149
|
+
if (styleItem) {
|
|
150
|
+
const parts = styleItem.split(PROPERTY_VALUE_SEPARATOR_REGEX);
|
|
151
|
+
if (parts.length > 1) {
|
|
152
|
+
styleObject[parts[0].trim()] = parts[1].trim();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return styleObject;
|
|
157
|
+
}
|
|
158
|
+
function normalizeStyle(styleValue) {
|
|
159
|
+
if (isArray(styleValue)) {
|
|
160
|
+
const normalizedStyleObject = {};
|
|
161
|
+
for (const styleItem of styleValue) {
|
|
162
|
+
const normalizedItem = isString(styleItem) ? parseStyleString(styleItem) : normalizeStyle(styleItem);
|
|
163
|
+
if (normalizedItem) {
|
|
164
|
+
for (const key in normalizedItem) {
|
|
165
|
+
normalizedStyleObject[key] = normalizedItem[key];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return normalizedStyleObject;
|
|
170
|
+
}
|
|
171
|
+
if (isString(styleValue) || isObject(styleValue)) {
|
|
172
|
+
return styleValue;
|
|
173
|
+
}
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
176
|
+
function styleToString(styleValue) {
|
|
177
|
+
if (!styleValue) {
|
|
178
|
+
return "";
|
|
179
|
+
}
|
|
180
|
+
if (isString(styleValue)) {
|
|
181
|
+
return styleValue;
|
|
182
|
+
}
|
|
183
|
+
let cssText = "";
|
|
184
|
+
for (const propName in styleValue) {
|
|
185
|
+
const propValue = styleValue[propName];
|
|
186
|
+
if (isString(propValue) || isNumber(propValue)) {
|
|
187
|
+
const normalizedPropName = propName.startsWith("--") ? propName : kebabCase(propName);
|
|
188
|
+
cssText += `${normalizedPropName}:${propValue};`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return cssText;
|
|
192
|
+
}
|
|
193
|
+
function normalizeClassName(classValue) {
|
|
194
|
+
if (classValue == null) {
|
|
195
|
+
return "";
|
|
196
|
+
}
|
|
197
|
+
if (isString(classValue)) {
|
|
198
|
+
return classValue.trim();
|
|
199
|
+
}
|
|
200
|
+
if (isArray(classValue)) {
|
|
201
|
+
return classValue.map(normalizeClassName).filter(Boolean).join(" ");
|
|
202
|
+
}
|
|
203
|
+
if (isObject(classValue)) {
|
|
204
|
+
let count = 0;
|
|
205
|
+
for (const key in classValue) {
|
|
206
|
+
if (classValue[key]) count++;
|
|
207
|
+
}
|
|
208
|
+
if (count === 0) return "";
|
|
209
|
+
const result = new Array(count);
|
|
210
|
+
let index = 0;
|
|
211
|
+
for (const key in classValue) {
|
|
212
|
+
if (classValue[key]) {
|
|
213
|
+
result[index++] = key;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return result.join(" ");
|
|
217
|
+
}
|
|
218
|
+
return String(classValue).trim();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ../signals/dist/signals.dev.esm.js
|
|
222
|
+
var __defProp = Object.defineProperty;
|
|
223
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
224
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
225
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
226
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
227
|
+
var __spreadValues = (a, b) => {
|
|
228
|
+
for (var prop in b || (b = {}))
|
|
229
|
+
if (__hasOwnProp.call(b, prop))
|
|
230
|
+
__defNormalProp(a, prop, b[prop]);
|
|
231
|
+
if (__getOwnPropSymbols)
|
|
232
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
233
|
+
if (__propIsEnum.call(b, prop))
|
|
234
|
+
__defNormalProp(a, prop, b[prop]);
|
|
235
|
+
}
|
|
236
|
+
return a;
|
|
237
|
+
};
|
|
238
|
+
var TriggerOpTypes = {
|
|
239
|
+
SET: "SET",
|
|
240
|
+
ADD: "ADD",
|
|
241
|
+
DELETE: "DELETE",
|
|
242
|
+
CLEAR: "CLEAR"
|
|
243
|
+
};
|
|
244
|
+
var ARRAY_KEY = /* @__PURE__ */ Symbol("Array_Key");
|
|
245
|
+
var COLLECTION_KEY = /* @__PURE__ */ Symbol("Collection_Key");
|
|
246
|
+
var WEAK_COLLECTION_KEY = /* @__PURE__ */ Symbol("WeakCollection_Key");
|
|
247
|
+
var ITERATE_KEY = /* @__PURE__ */ Symbol("Iterate_Key");
|
|
248
|
+
var ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol("Array_Iterate_Key");
|
|
249
|
+
function enqueueEffect(effect2) {
|
|
250
|
+
var _a52;
|
|
251
|
+
(_a52 = effect2 == null ? void 0 : effect2.notify) == null ? void 0 : _a52.call(effect2);
|
|
252
|
+
}
|
|
253
|
+
function propagate(link) {
|
|
254
|
+
let next2 = link.nextSubLink;
|
|
255
|
+
let stack;
|
|
256
|
+
top: do {
|
|
257
|
+
const sub = link.subNode;
|
|
258
|
+
const watcherBit = sub.flag & 2;
|
|
259
|
+
let flags = sub.flag;
|
|
260
|
+
if (!(flags & (16 | 32 | 8 | 4))) {
|
|
261
|
+
sub.flag = flags | 32;
|
|
262
|
+
if (watcherBit) {
|
|
263
|
+
enqueueEffect(sub);
|
|
264
|
+
}
|
|
265
|
+
} else if (!(flags & (8 | 4))) {
|
|
266
|
+
flags = 0;
|
|
267
|
+
} else if (!(flags & 4)) {
|
|
268
|
+
sub.flag = flags & -9 | 32;
|
|
269
|
+
} else if (!(flags & (16 | 32)) && isValidLink(link, sub)) {
|
|
270
|
+
sub.flag = flags | (8 | 32);
|
|
271
|
+
if (watcherBit) {
|
|
272
|
+
enqueueEffect(sub);
|
|
273
|
+
}
|
|
274
|
+
flags &= 1;
|
|
275
|
+
} else {
|
|
276
|
+
flags = 0;
|
|
277
|
+
}
|
|
278
|
+
if (flags & 1) {
|
|
279
|
+
const subSubs = sub.subLink;
|
|
280
|
+
if (subSubs !== void 0) {
|
|
281
|
+
const nextSub = subSubs.nextSubLink;
|
|
282
|
+
if (nextSub !== void 0) {
|
|
283
|
+
stack = { value: next2, prev: stack };
|
|
284
|
+
next2 = nextSub;
|
|
285
|
+
}
|
|
286
|
+
link = subSubs;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if ((link = next2) !== void 0) {
|
|
291
|
+
next2 = link.nextSubLink;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
while (stack !== void 0) {
|
|
295
|
+
link = stack.value;
|
|
296
|
+
stack = stack.prev;
|
|
297
|
+
if (link !== void 0) {
|
|
298
|
+
next2 = link.nextSubLink;
|
|
299
|
+
continue top;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
} while (true);
|
|
304
|
+
}
|
|
305
|
+
function shallowPropagate(link) {
|
|
306
|
+
while (link) {
|
|
307
|
+
const sub = link.subNode;
|
|
308
|
+
const flags = sub.flag;
|
|
309
|
+
if ((flags & (32 | 16)) === 32) {
|
|
310
|
+
sub.flag = flags | 16;
|
|
311
|
+
if ((flags & (2 | 4)) === 2) {
|
|
312
|
+
enqueueEffect(sub);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
link = link.nextSubLink;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
var currentLinkVersion = 0;
|
|
319
|
+
var activeSub;
|
|
320
|
+
var isUntracking = false;
|
|
321
|
+
var Dep = class {
|
|
322
|
+
constructor(map, key) {
|
|
323
|
+
this.map = map;
|
|
324
|
+
this.key = key;
|
|
325
|
+
this.isDep = true;
|
|
326
|
+
this.flag = 0;
|
|
327
|
+
}
|
|
328
|
+
get subLink() {
|
|
329
|
+
return this._subLink;
|
|
330
|
+
}
|
|
331
|
+
set subLink(value) {
|
|
332
|
+
this._subLink = value;
|
|
333
|
+
if (value === void 0) {
|
|
334
|
+
this.map.delete(this.key);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
function linkReactiveNode(depNode, subNode) {
|
|
339
|
+
if (isUntracking) {
|
|
340
|
+
return void 0;
|
|
341
|
+
}
|
|
342
|
+
const prevDep = subNode.depLinkTail;
|
|
343
|
+
if (prevDep && prevDep.depNode === depNode) {
|
|
344
|
+
return prevDep;
|
|
345
|
+
}
|
|
346
|
+
const nextDep = prevDep ? prevDep.nextDepLink : subNode.depLink;
|
|
347
|
+
if (nextDep && nextDep.depNode === depNode) {
|
|
348
|
+
nextDep.version = currentLinkVersion;
|
|
349
|
+
subNode.depLinkTail = nextDep;
|
|
350
|
+
return nextDep;
|
|
351
|
+
}
|
|
352
|
+
const prevSub = depNode.subLinkTail;
|
|
353
|
+
if (prevSub && prevSub.version === currentLinkVersion && prevSub.subNode === subNode) {
|
|
354
|
+
subNode.depLinkTail = prevSub;
|
|
355
|
+
return prevSub;
|
|
356
|
+
}
|
|
357
|
+
const newLink = {
|
|
358
|
+
version: currentLinkVersion,
|
|
359
|
+
depNode,
|
|
360
|
+
subNode,
|
|
361
|
+
// Subscriber chain pointers (horizontal)
|
|
362
|
+
prevSubLink: prevSub,
|
|
363
|
+
nextSubLink: void 0,
|
|
364
|
+
// Dependency chain pointers (vertical)
|
|
365
|
+
prevDepLink: prevDep,
|
|
366
|
+
nextDepLink: nextDep
|
|
367
|
+
};
|
|
368
|
+
if (nextDep) {
|
|
369
|
+
nextDep.prevDepLink = newLink;
|
|
370
|
+
}
|
|
371
|
+
if (prevDep) {
|
|
372
|
+
prevDep.nextDepLink = newLink;
|
|
373
|
+
} else {
|
|
374
|
+
subNode.depLink = newLink;
|
|
375
|
+
}
|
|
376
|
+
if (prevSub) {
|
|
377
|
+
prevSub.nextSubLink = newLink;
|
|
378
|
+
} else {
|
|
379
|
+
depNode.subLink = newLink;
|
|
380
|
+
}
|
|
381
|
+
depNode.subLinkTail = newLink;
|
|
382
|
+
subNode.depLinkTail = newLink;
|
|
383
|
+
{
|
|
384
|
+
if (subNode.onTrack && isFunction(subNode == null ? void 0 : subNode.onTrack)) {
|
|
385
|
+
subNode.onTrack({
|
|
386
|
+
effect: subNode,
|
|
387
|
+
target: depNode,
|
|
388
|
+
type: "get",
|
|
389
|
+
key: void 0
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return newLink;
|
|
394
|
+
}
|
|
395
|
+
function unlinkReactiveNode(linkNode, subNode = linkNode.subNode) {
|
|
396
|
+
const depNode = linkNode.depNode;
|
|
397
|
+
const prevSub = linkNode.prevSubLink;
|
|
398
|
+
const nextSub = linkNode.nextSubLink;
|
|
399
|
+
const prevDep = linkNode.prevDepLink;
|
|
400
|
+
const nextDep = linkNode.nextDepLink;
|
|
401
|
+
if (nextDep) {
|
|
402
|
+
nextDep.prevDepLink = prevDep;
|
|
403
|
+
} else {
|
|
404
|
+
subNode.depLinkTail = prevDep;
|
|
405
|
+
}
|
|
406
|
+
if (prevDep) {
|
|
407
|
+
prevDep.nextDepLink = nextDep;
|
|
408
|
+
} else {
|
|
409
|
+
subNode.depLink = nextDep;
|
|
410
|
+
}
|
|
411
|
+
if (nextSub) {
|
|
412
|
+
nextSub.prevSubLink = prevSub;
|
|
413
|
+
} else {
|
|
414
|
+
depNode.subLinkTail = prevSub;
|
|
415
|
+
}
|
|
416
|
+
if (prevSub) {
|
|
417
|
+
prevSub.nextSubLink = nextSub;
|
|
418
|
+
} else {
|
|
419
|
+
depNode.subLink = nextSub;
|
|
420
|
+
if (nextSub === void 0) {
|
|
421
|
+
let toRemove = depNode.depLink;
|
|
422
|
+
while (toRemove) {
|
|
423
|
+
toRemove = unlinkReactiveNode(toRemove, depNode);
|
|
424
|
+
}
|
|
425
|
+
depNode.depLinkTail = void 0;
|
|
426
|
+
if (!depNode.isDep) {
|
|
427
|
+
depNode.flag |= 16;
|
|
428
|
+
}
|
|
429
|
+
{
|
|
430
|
+
if (depNode.depLink) {
|
|
431
|
+
error(
|
|
432
|
+
"[Link] Cascading cleanup failed: depNode still has dependency links. This indicates a bug in the unlinking logic."
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return nextDep;
|
|
439
|
+
}
|
|
440
|
+
function checkDirty(link, sub) {
|
|
441
|
+
let stack;
|
|
442
|
+
let checkDepth = 0;
|
|
443
|
+
let dirty = false;
|
|
444
|
+
top: do {
|
|
445
|
+
let currentDirty = false;
|
|
446
|
+
if (sub.flag & 16) {
|
|
447
|
+
currentDirty = true;
|
|
448
|
+
} else {
|
|
449
|
+
const dep = link.depNode;
|
|
450
|
+
const depFlags = dep.flag;
|
|
451
|
+
if ((depFlags & (1 | 16)) === (1 | 16)) {
|
|
452
|
+
const subs = dep.subLink;
|
|
453
|
+
if (subs && subs.nextSubLink) {
|
|
454
|
+
shallowPropagate2(subs);
|
|
455
|
+
}
|
|
456
|
+
currentDirty = true;
|
|
457
|
+
} else if ((depFlags & (1 | 32)) === (1 | 32)) {
|
|
458
|
+
if (dep.depLink) {
|
|
459
|
+
stack = { link, prev: stack };
|
|
460
|
+
link = dep.depLink;
|
|
461
|
+
sub = dep;
|
|
462
|
+
++checkDepth;
|
|
463
|
+
continue top;
|
|
464
|
+
} else {
|
|
465
|
+
dep.flag &= -33;
|
|
466
|
+
}
|
|
467
|
+
} else if (depFlags & 32) {
|
|
468
|
+
dep.flag &= -33;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (!currentDirty && link.nextDepLink !== void 0) {
|
|
472
|
+
link = link.nextDepLink;
|
|
473
|
+
continue top;
|
|
474
|
+
}
|
|
475
|
+
dirty = currentDirty;
|
|
476
|
+
while (checkDepth--) {
|
|
477
|
+
link = stack.link;
|
|
478
|
+
stack = stack.prev;
|
|
479
|
+
sub = link.subNode;
|
|
480
|
+
const checkedDep = link.depNode;
|
|
481
|
+
if (dirty) {
|
|
482
|
+
checkedDep.flag = checkedDep.flag & -33 | 16;
|
|
483
|
+
} else {
|
|
484
|
+
checkedDep.flag &= -33;
|
|
485
|
+
}
|
|
486
|
+
if (checkedDep.flag & 16) {
|
|
487
|
+
dirty = true;
|
|
488
|
+
}
|
|
489
|
+
if (!dirty && link.nextDepLink !== void 0) {
|
|
490
|
+
link = link.nextDepLink;
|
|
491
|
+
continue top;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (dirty) {
|
|
495
|
+
sub.flag = sub.flag & -33 | 16;
|
|
496
|
+
} else {
|
|
497
|
+
sub.flag &= -33;
|
|
498
|
+
}
|
|
499
|
+
return dirty;
|
|
500
|
+
} while (true);
|
|
501
|
+
}
|
|
502
|
+
function shallowPropagate2(link) {
|
|
503
|
+
while (link) {
|
|
504
|
+
const sub = link.subNode;
|
|
505
|
+
const flags = sub.flag;
|
|
506
|
+
if ((flags & (32 | 16)) === 32) {
|
|
507
|
+
sub.flag = flags | 16;
|
|
508
|
+
}
|
|
509
|
+
link = link.nextSubLink;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function setActiveSub(sub) {
|
|
513
|
+
const prev = activeSub;
|
|
514
|
+
activeSub = sub;
|
|
515
|
+
return prev;
|
|
516
|
+
}
|
|
517
|
+
function startTracking(sub) {
|
|
518
|
+
currentLinkVersion++;
|
|
519
|
+
sub.depLinkTail = void 0;
|
|
520
|
+
sub.flag = sub.flag & -57 | 4;
|
|
521
|
+
return setActiveSub(sub);
|
|
522
|
+
}
|
|
523
|
+
function endTracking(sub, prevSub) {
|
|
524
|
+
activeSub = prevSub;
|
|
525
|
+
const depsTail = sub.depLinkTail;
|
|
526
|
+
let toRemove = depsTail ? depsTail.nextDepLink : sub.depLink;
|
|
527
|
+
while (toRemove) {
|
|
528
|
+
toRemove = unlinkReactiveNode(toRemove, sub);
|
|
529
|
+
}
|
|
530
|
+
sub.flag &= -5;
|
|
531
|
+
}
|
|
532
|
+
function untrack(fn) {
|
|
533
|
+
const prevSub = setActiveSub(void 0);
|
|
534
|
+
const prevUntracking = isUntracking;
|
|
535
|
+
isUntracking = true;
|
|
536
|
+
try {
|
|
537
|
+
return fn();
|
|
538
|
+
} finally {
|
|
539
|
+
isUntracking = prevUntracking;
|
|
540
|
+
setActiveSub(prevSub);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function isValidLink(checkLink, sub) {
|
|
544
|
+
let link = sub.depLinkTail;
|
|
545
|
+
while (link) {
|
|
546
|
+
if (link === checkLink) {
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
link = link.prevDepLink;
|
|
550
|
+
}
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
var targetMap = /* @__PURE__ */ new WeakMap();
|
|
554
|
+
var triggerVersion = 0;
|
|
555
|
+
function collectTriggeredEffects(dep, effects, version) {
|
|
556
|
+
if (!dep) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
for (let link = dep.subLink; link; link = link.nextSubLink) {
|
|
560
|
+
const effect2 = link.subNode;
|
|
561
|
+
if (effect2._triggerVersion === version) {
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
effect2._triggerVersion = version;
|
|
565
|
+
effects.push(effect2);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function track(target, key) {
|
|
569
|
+
if (!activeSub || isUntracking) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
let depsMap = targetMap.get(target);
|
|
573
|
+
if (!depsMap) {
|
|
574
|
+
depsMap = /* @__PURE__ */ new Map();
|
|
575
|
+
targetMap.set(target, depsMap);
|
|
576
|
+
}
|
|
577
|
+
let dep = depsMap.get(key);
|
|
578
|
+
if (!dep) {
|
|
579
|
+
dep = new Dep(depsMap, key);
|
|
580
|
+
depsMap.set(key, dep);
|
|
581
|
+
}
|
|
582
|
+
linkReactiveNode(dep, activeSub);
|
|
583
|
+
}
|
|
584
|
+
function trigger(target, type, key, newValue) {
|
|
585
|
+
var _a52;
|
|
586
|
+
const depsMap = targetMap.get(target);
|
|
587
|
+
if (!depsMap) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const effects = [];
|
|
591
|
+
const version = ++triggerVersion;
|
|
592
|
+
if (key !== void 0) {
|
|
593
|
+
if (Array.isArray(key)) {
|
|
594
|
+
for (const element of key) {
|
|
595
|
+
collectTriggeredEffects(depsMap.get(element), effects, version);
|
|
596
|
+
}
|
|
597
|
+
} else {
|
|
598
|
+
collectTriggeredEffects(depsMap.get(key), effects, version);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
if (type === "ADD" || type === "DELETE" || type === "CLEAR") {
|
|
602
|
+
const iterationKey = Array.isArray(target) ? ARRAY_ITERATE_KEY : ITERATE_KEY;
|
|
603
|
+
collectTriggeredEffects(depsMap.get(iterationKey), effects, version);
|
|
604
|
+
}
|
|
605
|
+
for (const effect2 of effects) {
|
|
606
|
+
if (isFunction(effect2.onTrigger)) {
|
|
607
|
+
effect2.onTrigger({
|
|
608
|
+
effect: effect2,
|
|
609
|
+
target,
|
|
610
|
+
type,
|
|
611
|
+
key,
|
|
612
|
+
newValue
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
if (effect2.flag & 2) {
|
|
616
|
+
(_a52 = effect2.notify) == null ? void 0 : _a52.call(effect2);
|
|
617
|
+
} else if (effect2.flag & 1) {
|
|
618
|
+
effect2.flag |= 16;
|
|
619
|
+
if (effect2.subLink) {
|
|
620
|
+
propagate(effect2.subLink);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
var reactiveCaches = /* @__PURE__ */ new WeakMap();
|
|
626
|
+
function toRaw(value) {
|
|
627
|
+
if (!value || !isObject(value)) {
|
|
628
|
+
return value;
|
|
629
|
+
}
|
|
630
|
+
const raw = value[
|
|
631
|
+
"_RAW"
|
|
632
|
+
/* RAW */
|
|
633
|
+
];
|
|
634
|
+
if (raw) {
|
|
635
|
+
return toRaw(raw);
|
|
636
|
+
}
|
|
637
|
+
if (isSignal(value)) {
|
|
638
|
+
return toRaw(value.peek());
|
|
639
|
+
}
|
|
640
|
+
return value;
|
|
641
|
+
}
|
|
642
|
+
var arrayInstrumentations = createArrayInstrumentations();
|
|
643
|
+
function createArrayInstrumentations() {
|
|
644
|
+
const instrumentations = {};
|
|
645
|
+
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
646
|
+
instrumentations[key] = function(...args) {
|
|
647
|
+
const arr = toRaw(this);
|
|
648
|
+
track(arr, ARRAY_ITERATE_KEY);
|
|
649
|
+
let res = arr[key](...args);
|
|
650
|
+
if ((res === -1 || res === false) && args.length > 0) {
|
|
651
|
+
const rawArgs = args.map((arg) => toRaw(arg));
|
|
652
|
+
res = arr[key](...rawArgs);
|
|
653
|
+
}
|
|
654
|
+
return res;
|
|
655
|
+
};
|
|
656
|
+
});
|
|
657
|
+
["find", "findIndex", "findLast", "findLastIndex"].forEach((key) => {
|
|
658
|
+
instrumentations[key] = function(...args) {
|
|
659
|
+
const arr = toRaw(this);
|
|
660
|
+
const isShallowMode = isShallow(this);
|
|
661
|
+
track(arr, ARRAY_ITERATE_KEY);
|
|
662
|
+
const res = arr[key](...args);
|
|
663
|
+
if ((key === "find" || key === "findLast") && isObject(res) && !isShallowMode) {
|
|
664
|
+
return reactiveImpl(res);
|
|
665
|
+
}
|
|
666
|
+
return res;
|
|
667
|
+
};
|
|
668
|
+
});
|
|
669
|
+
["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"].forEach(
|
|
670
|
+
(key) => {
|
|
671
|
+
instrumentations[key] = function(...args) {
|
|
672
|
+
const arr = toRaw(this);
|
|
673
|
+
const res = Array.prototype[key].apply(arr, args);
|
|
674
|
+
trigger(arr, TriggerOpTypes.SET, [ARRAY_KEY, ARRAY_ITERATE_KEY]);
|
|
675
|
+
return res;
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
);
|
|
679
|
+
["toReversed", "toSorted", "toSpliced"].forEach((key) => {
|
|
680
|
+
instrumentations[key] = function(...args) {
|
|
681
|
+
const arr = toRaw(this);
|
|
682
|
+
const isShallowMode = isShallow(this);
|
|
683
|
+
track(arr, ARRAY_ITERATE_KEY);
|
|
684
|
+
if (key === "toSpliced") {
|
|
685
|
+
for (let i = 0, l = arr.length; i < l; i++) {
|
|
686
|
+
track(arr, `${i}`);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
const res = Array.prototype[key].apply(arr, args);
|
|
690
|
+
if (!Array.isArray(res)) {
|
|
691
|
+
return res;
|
|
692
|
+
}
|
|
693
|
+
return res.map((item) => isObject(item) ? reactiveImpl(item, isShallowMode) : item);
|
|
694
|
+
};
|
|
695
|
+
});
|
|
696
|
+
["concat", "slice", "filter", "map", "flatMap", "flat"].forEach((key) => {
|
|
697
|
+
instrumentations[key] = function(...args) {
|
|
698
|
+
const arr = toRaw(this);
|
|
699
|
+
track(arr, ARRAY_ITERATE_KEY);
|
|
700
|
+
return Array.prototype[key].apply(this, args);
|
|
701
|
+
};
|
|
702
|
+
});
|
|
703
|
+
["join", "toString", "toLocaleString"].forEach((key) => {
|
|
704
|
+
instrumentations[key] = function(...args) {
|
|
705
|
+
const arr = toRaw(this);
|
|
706
|
+
track(arr, ARRAY_ITERATE_KEY);
|
|
707
|
+
return Array.prototype[key].apply(arr, args);
|
|
708
|
+
};
|
|
709
|
+
});
|
|
710
|
+
["values", "keys", "entries", Symbol.iterator].forEach((key) => {
|
|
711
|
+
instrumentations[key] = function() {
|
|
712
|
+
const arr = toRaw(this);
|
|
713
|
+
const isShallowMode = isShallow(this);
|
|
714
|
+
track(arr, ARRAY_KEY);
|
|
715
|
+
const rawIterator = key === Symbol.iterator ? arr[Symbol.iterator]() : arr[key]();
|
|
716
|
+
return {
|
|
717
|
+
/**
|
|
718
|
+
* Returns the next iterator result.
|
|
719
|
+
*/
|
|
720
|
+
next() {
|
|
721
|
+
const { value, done } = rawIterator.next();
|
|
722
|
+
if (done) {
|
|
723
|
+
return { value, done };
|
|
724
|
+
}
|
|
725
|
+
if (Array.isArray(value)) {
|
|
726
|
+
return {
|
|
727
|
+
value: value.map((v) => isObject(v) ? reactiveImpl(v, isShallowMode) : v),
|
|
728
|
+
done
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
return {
|
|
732
|
+
value: isObject(value) ? reactiveImpl(value, isShallowMode) : value,
|
|
733
|
+
done
|
|
734
|
+
};
|
|
735
|
+
},
|
|
736
|
+
/**
|
|
737
|
+
* Returns an iterator for the current collection.
|
|
738
|
+
*/
|
|
739
|
+
[Symbol.iterator]() {
|
|
740
|
+
return this;
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
};
|
|
744
|
+
});
|
|
745
|
+
return instrumentations;
|
|
746
|
+
}
|
|
747
|
+
var arrayHandlers = (shallow) => ({
|
|
748
|
+
get: (target, key, receiver) => {
|
|
749
|
+
if (key === "_RAW") {
|
|
750
|
+
return target;
|
|
751
|
+
}
|
|
752
|
+
if (key === "_IS_REACTIVE") {
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
if (key === "_IS_SHALLOW") {
|
|
756
|
+
return shallow;
|
|
757
|
+
}
|
|
758
|
+
if (hasOwn(arrayInstrumentations, key)) {
|
|
759
|
+
return arrayInstrumentations[key];
|
|
760
|
+
}
|
|
761
|
+
const value = Reflect.get(target, key, receiver);
|
|
762
|
+
if (isStringNumber(key)) {
|
|
763
|
+
track(target, key);
|
|
764
|
+
}
|
|
765
|
+
track(target, ARRAY_KEY);
|
|
766
|
+
if (isObject(value) && !shallow) {
|
|
767
|
+
return reactiveImpl(value);
|
|
768
|
+
}
|
|
769
|
+
return value;
|
|
770
|
+
},
|
|
771
|
+
set: (target, key, value, receiver) => {
|
|
772
|
+
const oldValue = Reflect.get(target, key, receiver);
|
|
773
|
+
const result = Reflect.set(target, key, value, receiver);
|
|
774
|
+
if (hasChanged(value, oldValue)) {
|
|
775
|
+
if (isStringNumber(key)) {
|
|
776
|
+
trigger(target, TriggerOpTypes.SET, [key, ARRAY_ITERATE_KEY, ARRAY_KEY]);
|
|
777
|
+
} else {
|
|
778
|
+
trigger(target, TriggerOpTypes.SET, key);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return result;
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
var shallowArrayHandlers = arrayHandlers(true);
|
|
785
|
+
var deepArrayHandlers = arrayHandlers(false);
|
|
786
|
+
var collectionHandlers = {
|
|
787
|
+
/**
|
|
788
|
+
* Exposes collection proxy flags and instrumented methods.
|
|
789
|
+
*/
|
|
790
|
+
get(target, key) {
|
|
791
|
+
if (key === "_IS_REACTIVE") {
|
|
792
|
+
return true;
|
|
793
|
+
}
|
|
794
|
+
if (key === "_RAW") {
|
|
795
|
+
return target;
|
|
796
|
+
}
|
|
797
|
+
return Reflect.get(
|
|
798
|
+
hasOwn(collectionInstrumentations, key) ? collectionInstrumentations : target,
|
|
799
|
+
key,
|
|
800
|
+
target
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
var weakCollectionHandlers = {
|
|
805
|
+
/**
|
|
806
|
+
* Exposes weak-collection proxy flags and instrumented methods.
|
|
807
|
+
*/
|
|
808
|
+
get(target, key) {
|
|
809
|
+
if (key === "_IS_REACTIVE") {
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
812
|
+
if (key === "_RAW") {
|
|
813
|
+
return target;
|
|
814
|
+
}
|
|
815
|
+
return Reflect.get(
|
|
816
|
+
hasOwn(weakInstrumentations, key) && key in target ? weakInstrumentations : target,
|
|
817
|
+
key,
|
|
818
|
+
target
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
var collectionInstrumentations = {
|
|
823
|
+
/**
|
|
824
|
+
* Reads a Map entry with dependency tracking.
|
|
825
|
+
*/
|
|
826
|
+
get(key) {
|
|
827
|
+
const target = toRaw(this);
|
|
828
|
+
track(target, COLLECTION_KEY);
|
|
829
|
+
const value = target.get(key);
|
|
830
|
+
if (isObject(value) && !isShallow(this)) {
|
|
831
|
+
return reactiveImpl(value);
|
|
832
|
+
}
|
|
833
|
+
return value;
|
|
834
|
+
},
|
|
835
|
+
/**
|
|
836
|
+
* Sets the requested value.
|
|
837
|
+
*/
|
|
838
|
+
set(key, value) {
|
|
839
|
+
const target = toRaw(this);
|
|
840
|
+
const hadKey = target.has(key);
|
|
841
|
+
const oldValue = target.get(key);
|
|
842
|
+
const rawValue = toRaw(value);
|
|
843
|
+
target.set(key, rawValue);
|
|
844
|
+
if (!hadKey || hasChanged(oldValue, rawValue)) {
|
|
845
|
+
trigger(target, TriggerOpTypes.SET, COLLECTION_KEY);
|
|
846
|
+
}
|
|
847
|
+
return this;
|
|
848
|
+
},
|
|
849
|
+
/**
|
|
850
|
+
* Adds the requested value.
|
|
851
|
+
*/
|
|
852
|
+
add(value) {
|
|
853
|
+
const target = toRaw(this);
|
|
854
|
+
const rawValue = toRaw(value);
|
|
855
|
+
const hadValue = target.has(rawValue);
|
|
856
|
+
target.add(rawValue);
|
|
857
|
+
if (!hadValue) {
|
|
858
|
+
trigger(target, TriggerOpTypes.ADD, COLLECTION_KEY);
|
|
859
|
+
}
|
|
860
|
+
return this;
|
|
861
|
+
},
|
|
862
|
+
/**
|
|
863
|
+
* Returns whether the requested value exists.
|
|
864
|
+
*/
|
|
865
|
+
has(key) {
|
|
866
|
+
const target = toRaw(this);
|
|
867
|
+
track(target, COLLECTION_KEY);
|
|
868
|
+
const hasKey = target.has(key);
|
|
869
|
+
if (!hasKey && isObject(key)) {
|
|
870
|
+
return target.has(toRaw(key));
|
|
871
|
+
}
|
|
872
|
+
return hasKey;
|
|
873
|
+
},
|
|
874
|
+
/**
|
|
875
|
+
* Deletes the requested value.
|
|
876
|
+
*/
|
|
877
|
+
delete(key) {
|
|
878
|
+
const target = toRaw(this);
|
|
879
|
+
const hadKey = target.has(key);
|
|
880
|
+
let result = target.delete(key);
|
|
881
|
+
if (!result && isObject(key)) {
|
|
882
|
+
result = target.delete(toRaw(key));
|
|
883
|
+
}
|
|
884
|
+
if (hadKey || result) {
|
|
885
|
+
trigger(target, TriggerOpTypes.DELETE, COLLECTION_KEY);
|
|
886
|
+
}
|
|
887
|
+
return result;
|
|
888
|
+
},
|
|
889
|
+
/**
|
|
890
|
+
* Clears the current collection.
|
|
891
|
+
*/
|
|
892
|
+
clear() {
|
|
893
|
+
const target = toRaw(this);
|
|
894
|
+
const hadItems = target.size > 0;
|
|
895
|
+
const result = target.clear();
|
|
896
|
+
if (hadItems) {
|
|
897
|
+
trigger(target, TriggerOpTypes.CLEAR, COLLECTION_KEY);
|
|
898
|
+
}
|
|
899
|
+
return result;
|
|
900
|
+
},
|
|
901
|
+
/**
|
|
902
|
+
* Iterates over each collection entry.
|
|
903
|
+
*/
|
|
904
|
+
forEach(callback, thisArg) {
|
|
905
|
+
const target = toRaw(this);
|
|
906
|
+
const isShallowMode = isShallow(this);
|
|
907
|
+
track(target, COLLECTION_KEY);
|
|
908
|
+
target.forEach((value, key) => {
|
|
909
|
+
const wrappedValue = isShallowMode || !isObject(value) ? value : reactiveImpl(value);
|
|
910
|
+
const wrappedKey = isShallowMode || !isObject(key) ? key : reactiveImpl(key);
|
|
911
|
+
callback.call(thisArg, wrappedValue, wrappedKey, this);
|
|
912
|
+
});
|
|
913
|
+
},
|
|
914
|
+
/**
|
|
915
|
+
* Returns an iterator for the current collection.
|
|
916
|
+
*/
|
|
917
|
+
[Symbol.iterator]() {
|
|
918
|
+
const target = toRaw(this);
|
|
919
|
+
const isShallowMode = isShallow(this);
|
|
920
|
+
track(target, COLLECTION_KEY);
|
|
921
|
+
const rawIterator = target[Symbol.iterator]();
|
|
922
|
+
return {
|
|
923
|
+
/**
|
|
924
|
+
* Returns the next iterator result.
|
|
925
|
+
*/
|
|
926
|
+
next() {
|
|
927
|
+
const { value, done } = rawIterator.next();
|
|
928
|
+
if (done) {
|
|
929
|
+
return { value, done };
|
|
930
|
+
}
|
|
931
|
+
if (isShallowMode) {
|
|
932
|
+
return { value, done };
|
|
933
|
+
}
|
|
934
|
+
if (Array.isArray(value)) {
|
|
935
|
+
return {
|
|
936
|
+
value: value.map((v) => isObject(v) ? reactiveImpl(v) : v),
|
|
937
|
+
done
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
return {
|
|
941
|
+
value: isObject(value) ? reactiveImpl(value) : value,
|
|
942
|
+
done
|
|
943
|
+
};
|
|
944
|
+
},
|
|
945
|
+
/**
|
|
946
|
+
* Returns an iterator for the current collection.
|
|
947
|
+
*/
|
|
948
|
+
[Symbol.iterator]() {
|
|
949
|
+
return this;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
},
|
|
953
|
+
/**
|
|
954
|
+
* Returns the current collection size.
|
|
955
|
+
*/
|
|
956
|
+
get size() {
|
|
957
|
+
const target = toRaw(this);
|
|
958
|
+
track(target, COLLECTION_KEY);
|
|
959
|
+
return target.size;
|
|
960
|
+
},
|
|
961
|
+
/**
|
|
962
|
+
* Returns an iterator over the current keys.
|
|
963
|
+
*/
|
|
964
|
+
keys() {
|
|
965
|
+
const target = toRaw(this);
|
|
966
|
+
const isShallowMode = isShallow(this);
|
|
967
|
+
track(target, COLLECTION_KEY);
|
|
968
|
+
const rawIterator = target.keys();
|
|
969
|
+
return {
|
|
970
|
+
/**
|
|
971
|
+
* Returns the next iterator result.
|
|
972
|
+
*/
|
|
973
|
+
next() {
|
|
974
|
+
const { value, done } = rawIterator.next();
|
|
975
|
+
if (done) {
|
|
976
|
+
return { value, done };
|
|
977
|
+
}
|
|
978
|
+
return {
|
|
979
|
+
value: isShallowMode || !isObject(value) ? value : reactiveImpl(value),
|
|
980
|
+
done
|
|
981
|
+
};
|
|
982
|
+
},
|
|
983
|
+
/**
|
|
984
|
+
* Returns an iterator for the current collection.
|
|
985
|
+
*/
|
|
986
|
+
[Symbol.iterator]() {
|
|
987
|
+
return this;
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
},
|
|
991
|
+
/**
|
|
992
|
+
* Returns an iterator over the current values.
|
|
993
|
+
*/
|
|
994
|
+
values() {
|
|
995
|
+
const target = toRaw(this);
|
|
996
|
+
const isShallowMode = isShallow(this);
|
|
997
|
+
track(target, COLLECTION_KEY);
|
|
998
|
+
const rawIterator = target.values();
|
|
999
|
+
return {
|
|
1000
|
+
/**
|
|
1001
|
+
* Returns the next iterator result.
|
|
1002
|
+
*/
|
|
1003
|
+
next() {
|
|
1004
|
+
const { value, done } = rawIterator.next();
|
|
1005
|
+
if (done) {
|
|
1006
|
+
return { value, done };
|
|
1007
|
+
}
|
|
1008
|
+
return {
|
|
1009
|
+
value: isShallowMode || !isObject(value) ? value : reactiveImpl(value),
|
|
1010
|
+
done
|
|
1011
|
+
};
|
|
1012
|
+
},
|
|
1013
|
+
/**
|
|
1014
|
+
* Returns an iterator for the current collection.
|
|
1015
|
+
*/
|
|
1016
|
+
[Symbol.iterator]() {
|
|
1017
|
+
return this;
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
},
|
|
1021
|
+
/**
|
|
1022
|
+
* Returns an iterator over the current entries.
|
|
1023
|
+
*/
|
|
1024
|
+
entries() {
|
|
1025
|
+
const target = toRaw(this);
|
|
1026
|
+
const isShallowMode = isShallow(this);
|
|
1027
|
+
track(target, COLLECTION_KEY);
|
|
1028
|
+
const rawIterator = target.entries();
|
|
1029
|
+
return {
|
|
1030
|
+
/**
|
|
1031
|
+
* Returns the next iterator result.
|
|
1032
|
+
*/
|
|
1033
|
+
next() {
|
|
1034
|
+
const { value, done } = rawIterator.next();
|
|
1035
|
+
if (done) {
|
|
1036
|
+
return { value, done };
|
|
1037
|
+
}
|
|
1038
|
+
if (isShallowMode) {
|
|
1039
|
+
return { value, done };
|
|
1040
|
+
}
|
|
1041
|
+
return {
|
|
1042
|
+
value: value.map((v) => isObject(v) ? reactiveImpl(v) : v),
|
|
1043
|
+
done
|
|
1044
|
+
};
|
|
1045
|
+
},
|
|
1046
|
+
/**
|
|
1047
|
+
* Returns an iterator for the current collection.
|
|
1048
|
+
*/
|
|
1049
|
+
[Symbol.iterator]() {
|
|
1050
|
+
return this;
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
var weakInstrumentations = {
|
|
1056
|
+
/**
|
|
1057
|
+
* Reads a WeakMap entry with dependency tracking.
|
|
1058
|
+
*/
|
|
1059
|
+
get(key) {
|
|
1060
|
+
const target = toRaw(this);
|
|
1061
|
+
track(target, WEAK_COLLECTION_KEY);
|
|
1062
|
+
let value = target.get(key);
|
|
1063
|
+
if (value === void 0 && isReactive(key)) {
|
|
1064
|
+
value = target.get(toRaw(key));
|
|
1065
|
+
}
|
|
1066
|
+
if (isObject(value) && !isShallow(this)) {
|
|
1067
|
+
return reactiveImpl(value);
|
|
1068
|
+
}
|
|
1069
|
+
return value;
|
|
1070
|
+
},
|
|
1071
|
+
/**
|
|
1072
|
+
* Sets the requested value.
|
|
1073
|
+
*/
|
|
1074
|
+
set(key, value) {
|
|
1075
|
+
const target = toRaw(this);
|
|
1076
|
+
const rawKey = toRaw(key);
|
|
1077
|
+
const hadKey = target.has(rawKey);
|
|
1078
|
+
const oldValue = target.get(rawKey);
|
|
1079
|
+
const rawValue = toRaw(value);
|
|
1080
|
+
target.set(rawKey, rawValue);
|
|
1081
|
+
if (!hadKey || hasChanged(oldValue, rawValue)) {
|
|
1082
|
+
trigger(target, TriggerOpTypes.SET, WEAK_COLLECTION_KEY);
|
|
1083
|
+
}
|
|
1084
|
+
return this;
|
|
1085
|
+
},
|
|
1086
|
+
/**
|
|
1087
|
+
* Adds the requested value.
|
|
1088
|
+
*/
|
|
1089
|
+
add(value) {
|
|
1090
|
+
const target = toRaw(this);
|
|
1091
|
+
const rawValue = toRaw(value);
|
|
1092
|
+
const hadValue = target.has(rawValue);
|
|
1093
|
+
target.add(rawValue);
|
|
1094
|
+
if (!hadValue) {
|
|
1095
|
+
trigger(target, TriggerOpTypes.ADD, WEAK_COLLECTION_KEY);
|
|
1096
|
+
}
|
|
1097
|
+
return this;
|
|
1098
|
+
},
|
|
1099
|
+
/**
|
|
1100
|
+
* Returns whether the requested value exists.
|
|
1101
|
+
*/
|
|
1102
|
+
has(key) {
|
|
1103
|
+
const target = toRaw(this);
|
|
1104
|
+
track(target, WEAK_COLLECTION_KEY);
|
|
1105
|
+
let hasKey = target.has(key);
|
|
1106
|
+
if (!hasKey && isReactive(key)) {
|
|
1107
|
+
hasKey = target.has(toRaw(key));
|
|
1108
|
+
}
|
|
1109
|
+
return hasKey;
|
|
1110
|
+
},
|
|
1111
|
+
/**
|
|
1112
|
+
* Deletes the requested value.
|
|
1113
|
+
*/
|
|
1114
|
+
delete(key) {
|
|
1115
|
+
const target = toRaw(this);
|
|
1116
|
+
const rawKey = toRaw(key);
|
|
1117
|
+
const hadKey = target.has(rawKey);
|
|
1118
|
+
const result = target.delete(rawKey);
|
|
1119
|
+
if (hadKey || result) {
|
|
1120
|
+
trigger(target, TriggerOpTypes.DELETE, WEAK_COLLECTION_KEY);
|
|
1121
|
+
}
|
|
1122
|
+
return result;
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
var objectHandlers = (shallow) => ({
|
|
1126
|
+
/**
|
|
1127
|
+
* Reads an object property, unwraps signals, and tracks the access.
|
|
1128
|
+
*/
|
|
1129
|
+
get(target, key, receiver) {
|
|
1130
|
+
if (key === "_RAW") {
|
|
1131
|
+
return target;
|
|
1132
|
+
}
|
|
1133
|
+
if (key === "_IS_REACTIVE") {
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1136
|
+
if (key === "_IS_SHALLOW") {
|
|
1137
|
+
return shallow;
|
|
1138
|
+
}
|
|
1139
|
+
const value = Reflect.get(target, key, receiver);
|
|
1140
|
+
const valueUnwrapped = isSignal(value) ? value.value : value;
|
|
1141
|
+
track(target, key);
|
|
1142
|
+
if (isObject(valueUnwrapped) && !shallow) {
|
|
1143
|
+
return reactiveImpl(valueUnwrapped);
|
|
1144
|
+
}
|
|
1145
|
+
return valueUnwrapped;
|
|
1146
|
+
},
|
|
1147
|
+
set: (target, key, value, receiver) => {
|
|
1148
|
+
const oldValue = Reflect.get(target, key, receiver);
|
|
1149
|
+
const result = Reflect.set(target, key, toRaw(value), receiver);
|
|
1150
|
+
if (hasChanged(value, oldValue)) {
|
|
1151
|
+
trigger(target, TriggerOpTypes.SET, key, value);
|
|
1152
|
+
}
|
|
1153
|
+
return result;
|
|
1154
|
+
},
|
|
1155
|
+
deleteProperty: (target, key) => {
|
|
1156
|
+
const hadKey = hasOwn(target, key);
|
|
1157
|
+
const result = Reflect.deleteProperty(target, key);
|
|
1158
|
+
if (hadKey && result) {
|
|
1159
|
+
trigger(target, TriggerOpTypes.DELETE, key, void 0);
|
|
1160
|
+
}
|
|
1161
|
+
return result;
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
var shallowObjectHandlers = objectHandlers(true);
|
|
1165
|
+
var deepObjectHandlers = objectHandlers(false);
|
|
1166
|
+
function reactiveImpl(target, shallow = false) {
|
|
1167
|
+
if (!isObject(target)) {
|
|
1168
|
+
return target;
|
|
1169
|
+
}
|
|
1170
|
+
if (isReactive(target)) {
|
|
1171
|
+
return target;
|
|
1172
|
+
}
|
|
1173
|
+
const existingProxy = reactiveCaches.get(target);
|
|
1174
|
+
if (existingProxy) {
|
|
1175
|
+
return existingProxy;
|
|
1176
|
+
}
|
|
1177
|
+
let handler;
|
|
1178
|
+
if (isArray(target)) {
|
|
1179
|
+
handler = shallow ? shallowArrayHandlers : deepArrayHandlers;
|
|
1180
|
+
} else if (isSet(target) || isMap(target)) {
|
|
1181
|
+
handler = collectionHandlers;
|
|
1182
|
+
} else if (isWeakMap(target) || isWeakSet(target)) {
|
|
1183
|
+
handler = weakCollectionHandlers;
|
|
1184
|
+
} else {
|
|
1185
|
+
handler = shallow ? shallowObjectHandlers : deepObjectHandlers;
|
|
1186
|
+
}
|
|
1187
|
+
const proxy = new Proxy(target, handler);
|
|
1188
|
+
reactiveCaches.set(target, proxy);
|
|
1189
|
+
return proxy;
|
|
1190
|
+
}
|
|
1191
|
+
function isReactive(target) {
|
|
1192
|
+
return !!(target && target[
|
|
1193
|
+
"_IS_REACTIVE"
|
|
1194
|
+
/* IS_REACTIVE */
|
|
1195
|
+
]);
|
|
1196
|
+
}
|
|
1197
|
+
function reactive(target) {
|
|
1198
|
+
if (isReactive(target)) {
|
|
1199
|
+
return target;
|
|
1200
|
+
}
|
|
1201
|
+
if (isSignal(target)) {
|
|
1202
|
+
return target;
|
|
1203
|
+
}
|
|
1204
|
+
return reactiveImpl(target);
|
|
1205
|
+
}
|
|
1206
|
+
function shallowReactive(target) {
|
|
1207
|
+
if (isReactive(target)) {
|
|
1208
|
+
return target;
|
|
1209
|
+
}
|
|
1210
|
+
if (isSignal(target)) {
|
|
1211
|
+
return target;
|
|
1212
|
+
}
|
|
1213
|
+
return reactiveImpl(target, true);
|
|
1214
|
+
}
|
|
1215
|
+
function isShallow(value) {
|
|
1216
|
+
return !!(value && value[
|
|
1217
|
+
"_IS_SHALLOW"
|
|
1218
|
+
/* IS_SHALLOW */
|
|
1219
|
+
]);
|
|
1220
|
+
}
|
|
1221
|
+
var toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
1222
|
+
var _a;
|
|
1223
|
+
_a = "_IS_SIGNAL";
|
|
1224
|
+
var SignalImpl = class {
|
|
1225
|
+
// Mark as Signal
|
|
1226
|
+
/**
|
|
1227
|
+
* Create a new Signal with the given initial value.
|
|
1228
|
+
*
|
|
1229
|
+
* @param value - Initial value
|
|
1230
|
+
* @param shallow - Whether only the top level should be reactive
|
|
1231
|
+
*/
|
|
1232
|
+
constructor(value, shallow = false) {
|
|
1233
|
+
this.flag = 1;
|
|
1234
|
+
this[_a] = true;
|
|
1235
|
+
const unwrapped = toRaw(value);
|
|
1236
|
+
this._rawValue = unwrapped;
|
|
1237
|
+
this[
|
|
1238
|
+
"_IS_SHALLOW"
|
|
1239
|
+
/* IS_SHALLOW */
|
|
1240
|
+
] = shallow;
|
|
1241
|
+
if (!shouldWrapReactiveValue(unwrapped)) {
|
|
1242
|
+
this._value = unwrapped;
|
|
1243
|
+
} else {
|
|
1244
|
+
if (isReactive(value)) {
|
|
1245
|
+
this._value = value;
|
|
1246
|
+
} else {
|
|
1247
|
+
this._value = shallow ? shallowReactive(unwrapped) : reactive(unwrapped);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Returns the dependency node used for tracking.
|
|
1253
|
+
*
|
|
1254
|
+
* @returns {this} The dependency node.
|
|
1255
|
+
*/
|
|
1256
|
+
get dep() {
|
|
1257
|
+
return this;
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Returns the current value.
|
|
1261
|
+
*
|
|
1262
|
+
* @returns {T} The current value.
|
|
1263
|
+
*/
|
|
1264
|
+
get value() {
|
|
1265
|
+
const sub = activeSub;
|
|
1266
|
+
if (sub) {
|
|
1267
|
+
linkReactiveNode(this, sub);
|
|
1268
|
+
}
|
|
1269
|
+
const flags = this.flag;
|
|
1270
|
+
if (flags & 16 && this.shouldUpdate()) {
|
|
1271
|
+
const subs = this.subLink;
|
|
1272
|
+
if (subs) {
|
|
1273
|
+
shallowPropagate2(subs);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
return this._value;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Updates the current value.
|
|
1280
|
+
*
|
|
1281
|
+
* @param newValue - The new value to set.
|
|
1282
|
+
*/
|
|
1283
|
+
set value(newValue) {
|
|
1284
|
+
if (isSignal(newValue)) {
|
|
1285
|
+
{
|
|
1286
|
+
warn(
|
|
1287
|
+
"Setting a signal value to another signal is not recommended. The value will be unwrapped automatically."
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
newValue = newValue.peek();
|
|
1291
|
+
}
|
|
1292
|
+
const originalValue = newValue;
|
|
1293
|
+
const rawValue = toRaw(newValue);
|
|
1294
|
+
if (!hasChanged(this._rawValue, rawValue)) {
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
this._oldValue = this._rawValue;
|
|
1298
|
+
this._rawValue = rawValue;
|
|
1299
|
+
this.flag |= 16;
|
|
1300
|
+
if (!shouldWrapReactiveValue(rawValue)) {
|
|
1301
|
+
this._value = rawValue;
|
|
1302
|
+
} else if (isReactive(originalValue)) {
|
|
1303
|
+
this._value = originalValue;
|
|
1304
|
+
} else {
|
|
1305
|
+
const shallow = this[
|
|
1306
|
+
"_IS_SHALLOW"
|
|
1307
|
+
/* IS_SHALLOW */
|
|
1308
|
+
];
|
|
1309
|
+
this._value = shallow ? shallowReactive(rawValue) : reactive(rawValue);
|
|
1310
|
+
}
|
|
1311
|
+
const subs = this.subLink;
|
|
1312
|
+
if (subs) {
|
|
1313
|
+
propagate(subs);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Check if the value should be updated.
|
|
1318
|
+
*
|
|
1319
|
+
* @returns {boolean} True if the value should be updated.
|
|
1320
|
+
*/
|
|
1321
|
+
shouldUpdate() {
|
|
1322
|
+
this.flag &= -17;
|
|
1323
|
+
if (!("_oldValue" in this)) {
|
|
1324
|
+
return true;
|
|
1325
|
+
}
|
|
1326
|
+
const changed = hasChanged(this._oldValue, this._rawValue);
|
|
1327
|
+
this._oldValue = this._rawValue;
|
|
1328
|
+
return changed;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Get current value without triggering dependency tracking.
|
|
1332
|
+
*
|
|
1333
|
+
* @returns {T} The current value.
|
|
1334
|
+
*/
|
|
1335
|
+
peek() {
|
|
1336
|
+
return this._value;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Sets the requested value.
|
|
1340
|
+
*
|
|
1341
|
+
* @param value - The new value to set.
|
|
1342
|
+
* @returns {void}
|
|
1343
|
+
*/
|
|
1344
|
+
set(value) {
|
|
1345
|
+
this.value = value;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Update value using an updater function.
|
|
1349
|
+
*
|
|
1350
|
+
* @param updater - A function that receives the current value and returns the new value.
|
|
1351
|
+
* @returns {void}
|
|
1352
|
+
*/
|
|
1353
|
+
update(updater) {
|
|
1354
|
+
const nextValue = updater(this.peek());
|
|
1355
|
+
if (isSignal(nextValue)) {
|
|
1356
|
+
{
|
|
1357
|
+
warn(
|
|
1358
|
+
"Returning a signal from an update function is not recommended. The value will be unwrapped."
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
this.value = nextValue.peek();
|
|
1362
|
+
} else {
|
|
1363
|
+
this.value = nextValue;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
function shouldWrapReactiveValue(value) {
|
|
1368
|
+
if (!isObject(value)) return false;
|
|
1369
|
+
return isArray(value) || isMap(value) || isSet(value) || isWeakMap(value) || isWeakSet(value) || isPlainObject(value);
|
|
1370
|
+
}
|
|
1371
|
+
function signal(value) {
|
|
1372
|
+
if (isSignal(value)) {
|
|
1373
|
+
{
|
|
1374
|
+
warn(
|
|
1375
|
+
"Creating a signal with another signal is not recommended. The value will be unwrapped."
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
return value;
|
|
1379
|
+
}
|
|
1380
|
+
return new SignalImpl(value);
|
|
1381
|
+
}
|
|
1382
|
+
function shallowSignal(value) {
|
|
1383
|
+
if (isSignal(value)) {
|
|
1384
|
+
value = value.peek();
|
|
1385
|
+
}
|
|
1386
|
+
return new SignalImpl(value, true);
|
|
1387
|
+
}
|
|
1388
|
+
function isSignal(value) {
|
|
1389
|
+
return !!value && !!value[
|
|
1390
|
+
"_IS_SIGNAL"
|
|
1391
|
+
/* IS_SIGNAL */
|
|
1392
|
+
];
|
|
1393
|
+
}
|
|
1394
|
+
var queue = /* @__PURE__ */ new Set();
|
|
1395
|
+
var activePreFlushCbs = /* @__PURE__ */ new Set();
|
|
1396
|
+
var p = Promise.resolve();
|
|
1397
|
+
var isFlushPending = false;
|
|
1398
|
+
function nextTick(fn) {
|
|
1399
|
+
return fn ? p.then(fn) : p;
|
|
1400
|
+
}
|
|
1401
|
+
function queueJob(job) {
|
|
1402
|
+
queue.add(job);
|
|
1403
|
+
queueFlush();
|
|
1404
|
+
}
|
|
1405
|
+
function queueFlush() {
|
|
1406
|
+
if (!isFlushPending) {
|
|
1407
|
+
isFlushPending = true;
|
|
1408
|
+
nextTick(flushJobs);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
function queuePreFlushCb(cb) {
|
|
1412
|
+
activePreFlushCbs.add(cb);
|
|
1413
|
+
queueFlush();
|
|
1414
|
+
}
|
|
1415
|
+
function flushJobs() {
|
|
1416
|
+
isFlushPending = false;
|
|
1417
|
+
flushPreFlushCbs();
|
|
1418
|
+
while (queue.size > 0) {
|
|
1419
|
+
for (const job of queue) {
|
|
1420
|
+
try {
|
|
1421
|
+
job();
|
|
1422
|
+
} catch (_error) {
|
|
1423
|
+
{
|
|
1424
|
+
error("Error executing queued job:", _error);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
queue.clear();
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
function flushPreFlushCbs() {
|
|
1432
|
+
const callbacks = Array.from(activePreFlushCbs);
|
|
1433
|
+
activePreFlushCbs.clear();
|
|
1434
|
+
for (const callback of callbacks) {
|
|
1435
|
+
try {
|
|
1436
|
+
callback();
|
|
1437
|
+
} catch (_error) {
|
|
1438
|
+
{
|
|
1439
|
+
error("Error executing pre-flush callback:", _error);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function createScheduler(effect2, flush) {
|
|
1445
|
+
switch (flush) {
|
|
1446
|
+
case "sync":
|
|
1447
|
+
return () => effect2();
|
|
1448
|
+
case "pre":
|
|
1449
|
+
return () => queuePreFlushCb(effect2);
|
|
1450
|
+
case "post":
|
|
1451
|
+
return () => queueJob(effect2);
|
|
1452
|
+
default:
|
|
1453
|
+
{
|
|
1454
|
+
warn(`Invalid flush timing: ${flush}. Defaulting to 'post'.`);
|
|
1455
|
+
}
|
|
1456
|
+
return () => queueJob(effect2);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
var batchDepth = 0;
|
|
1460
|
+
function batch(fn) {
|
|
1461
|
+
startBatch();
|
|
1462
|
+
try {
|
|
1463
|
+
return fn();
|
|
1464
|
+
} finally {
|
|
1465
|
+
endBatch();
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
function startBatch() {
|
|
1469
|
+
batchDepth++;
|
|
1470
|
+
}
|
|
1471
|
+
function endBatch() {
|
|
1472
|
+
if (batchDepth === 0) {
|
|
1473
|
+
warn(
|
|
1474
|
+
"[Batch] endBatch() called without matching startBatch(). This indicates unbalanced batch calls in your code. Make sure every startBatch() has a corresponding endBatch(), or use the batch() function which handles this automatically."
|
|
1475
|
+
);
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
batchDepth--;
|
|
1479
|
+
if (batchDepth === 0) {
|
|
1480
|
+
flushJobs();
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function isBatching() {
|
|
1484
|
+
return batchDepth > 0;
|
|
1485
|
+
}
|
|
1486
|
+
function getBatchDepth() {
|
|
1487
|
+
return batchDepth;
|
|
1488
|
+
}
|
|
1489
|
+
var _a2;
|
|
1490
|
+
_a2 = "_IS_EFFECT";
|
|
1491
|
+
var EffectImpl = class {
|
|
1492
|
+
/**
|
|
1493
|
+
* Create an Effect instance.
|
|
1494
|
+
*
|
|
1495
|
+
* @param fn - The effect function.
|
|
1496
|
+
* @param options - Configuration options.
|
|
1497
|
+
*/
|
|
1498
|
+
constructor(fn, options) {
|
|
1499
|
+
this.flag = 2 | 16;
|
|
1500
|
+
this[_a2] = true;
|
|
1501
|
+
this._active = true;
|
|
1502
|
+
this.fn = fn;
|
|
1503
|
+
if (options) {
|
|
1504
|
+
this.options = options;
|
|
1505
|
+
const scheduler = options.flush || options.scheduler;
|
|
1506
|
+
if (scheduler && !isFunction(scheduler)) {
|
|
1507
|
+
this._flushScheduler = createScheduler(() => this.run(), scheduler);
|
|
1508
|
+
}
|
|
1509
|
+
{
|
|
1510
|
+
if (options.onTrack) this.onTrack = options.onTrack;
|
|
1511
|
+
if (options.onTrigger) this.onTrigger = options.onTrigger;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Check if the Effect is active.
|
|
1517
|
+
*
|
|
1518
|
+
* @returns {boolean} True if the effect is active.
|
|
1519
|
+
*/
|
|
1520
|
+
get active() {
|
|
1521
|
+
return this._active;
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Check if the Effect is dirty (needs re-execution).
|
|
1525
|
+
*
|
|
1526
|
+
* @returns {boolean} True if the effect is dirty.
|
|
1527
|
+
*/
|
|
1528
|
+
get dirty() {
|
|
1529
|
+
const flags = this.flag;
|
|
1530
|
+
if (flags & 16) {
|
|
1531
|
+
return true;
|
|
1532
|
+
}
|
|
1533
|
+
if (flags & 32) {
|
|
1534
|
+
if (this.depLink && checkDirty(this.depLink, this)) {
|
|
1535
|
+
this.flag = flags & -33 | 16;
|
|
1536
|
+
return true;
|
|
1537
|
+
}
|
|
1538
|
+
this.flag = flags & -33;
|
|
1539
|
+
}
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Pause Effect execution.
|
|
1544
|
+
*
|
|
1545
|
+
* When an effect is paused:
|
|
1546
|
+
* - It stops responding to dependency changes.
|
|
1547
|
+
* - Notifications are ignored (see notify method).
|
|
1548
|
+
* - DIRTY and PENDING flags are still set when dependencies change.
|
|
1549
|
+
* - The effect remains active and maintains its dependency links.
|
|
1550
|
+
*
|
|
1551
|
+
* Use cases:
|
|
1552
|
+
* - Temporarily disable effects during bulk updates.
|
|
1553
|
+
* - Prevent effects from running during initialization.
|
|
1554
|
+
* - Control when side effects should execute.
|
|
1555
|
+
*
|
|
1556
|
+
* @returns {void}
|
|
1557
|
+
*/
|
|
1558
|
+
pause() {
|
|
1559
|
+
this.flag |= 256;
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Resume Effect execution.
|
|
1563
|
+
*
|
|
1564
|
+
* When an effect is resumed:
|
|
1565
|
+
* - The PAUSED flag is cleared.
|
|
1566
|
+
* - If dependencies changed during pause (DIRTY or PENDING flags set),
|
|
1567
|
+
* the effect executes immediately via notify().
|
|
1568
|
+
* - If no changes occurred, the effect simply becomes active again.
|
|
1569
|
+
*
|
|
1570
|
+
* State management:
|
|
1571
|
+
* - Clears PAUSED flag atomically.
|
|
1572
|
+
* - Checks for accumulated DIRTY/PENDING flags.
|
|
1573
|
+
* - Triggers execution if needed.
|
|
1574
|
+
*
|
|
1575
|
+
* @returns {void}
|
|
1576
|
+
*/
|
|
1577
|
+
resume() {
|
|
1578
|
+
const flags = this.flag;
|
|
1579
|
+
const nextFlags = flags & -257;
|
|
1580
|
+
this.flag = nextFlags;
|
|
1581
|
+
const wasDirty = (nextFlags & 16) !== 0;
|
|
1582
|
+
const wasPending = (nextFlags & 32) !== 0;
|
|
1583
|
+
if (wasDirty || wasPending) {
|
|
1584
|
+
this.notify();
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Execute the Effect function.
|
|
1589
|
+
*
|
|
1590
|
+
* Core execution flow:
|
|
1591
|
+
* 1. Check if active
|
|
1592
|
+
* 2. Clear dirty flag
|
|
1593
|
+
* 3. Start tracking dependencies
|
|
1594
|
+
* 4. Execute user function
|
|
1595
|
+
* 5. End tracking, clean up stale dependencies
|
|
1596
|
+
*
|
|
1597
|
+
* @returns {T} The return value of the effect function.
|
|
1598
|
+
*/
|
|
1599
|
+
run() {
|
|
1600
|
+
if (!this._active) {
|
|
1601
|
+
return this.fn();
|
|
1602
|
+
}
|
|
1603
|
+
const flags = this.flag;
|
|
1604
|
+
this.flag = flags & -49 | 512;
|
|
1605
|
+
const prevSub = startTracking(this);
|
|
1606
|
+
try {
|
|
1607
|
+
return this.fn();
|
|
1608
|
+
} catch (error5) {
|
|
1609
|
+
this.flag |= 16;
|
|
1610
|
+
throw error5;
|
|
1611
|
+
} finally {
|
|
1612
|
+
this.flag &= -513;
|
|
1613
|
+
endTracking(this, prevSub);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Get or create the job function for this effect.
|
|
1618
|
+
*
|
|
1619
|
+
* @returns {() => void} The job function.
|
|
1620
|
+
*/
|
|
1621
|
+
getJob() {
|
|
1622
|
+
if (!this._job) {
|
|
1623
|
+
this._job = () => this.run();
|
|
1624
|
+
}
|
|
1625
|
+
return this._job;
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Notify that the Effect needs to execute.
|
|
1629
|
+
*
|
|
1630
|
+
* Called by dependent reactive values.
|
|
1631
|
+
* Decides whether to execute immediately or defer based on scheduling strategy.
|
|
1632
|
+
*
|
|
1633
|
+
* @returns {void}
|
|
1634
|
+
*/
|
|
1635
|
+
notify() {
|
|
1636
|
+
var _a52, _b2, _c, _d;
|
|
1637
|
+
const flags = this.flag;
|
|
1638
|
+
if (!this._active || flags & (256 | 512 | 16)) {
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
this.flag = flags | 16;
|
|
1642
|
+
if ((_a52 = this.options) == null ? void 0 : _a52.onTrigger) {
|
|
1643
|
+
this.options.onTrigger({
|
|
1644
|
+
effect: this,
|
|
1645
|
+
target: {},
|
|
1646
|
+
type: "set"
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
const scheduler = ((_b2 = this.options) == null ? void 0 : _b2.flush) || ((_c = this.options) == null ? void 0 : _c.scheduler);
|
|
1650
|
+
if (scheduler) {
|
|
1651
|
+
if (isFunction(scheduler)) {
|
|
1652
|
+
scheduler(this);
|
|
1653
|
+
} else {
|
|
1654
|
+
(_d = this._flushScheduler) == null ? void 0 : _d.call(this);
|
|
1655
|
+
}
|
|
1656
|
+
} else if (isBatching()) {
|
|
1657
|
+
queueJob(this.getJob());
|
|
1658
|
+
} else {
|
|
1659
|
+
this.run();
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Stop the Effect.
|
|
1664
|
+
*
|
|
1665
|
+
* After stopping:
|
|
1666
|
+
* - No longer responds to dependency changes.
|
|
1667
|
+
* - Disconnects all dependency links.
|
|
1668
|
+
* - Clears cached job function.
|
|
1669
|
+
* - Calls onStop callback.
|
|
1670
|
+
* - Verifies complete cleanup in development mode.
|
|
1671
|
+
*
|
|
1672
|
+
* @returns {void}
|
|
1673
|
+
*/
|
|
1674
|
+
stop() {
|
|
1675
|
+
var _a52;
|
|
1676
|
+
if (!this._active) {
|
|
1677
|
+
{
|
|
1678
|
+
warn("[Effect] Attempting to stop an already stopped effect.");
|
|
1679
|
+
}
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
this._active = false;
|
|
1683
|
+
let dep = this.depLink;
|
|
1684
|
+
while (dep) {
|
|
1685
|
+
dep = unlinkReactiveNode(dep, this);
|
|
1686
|
+
}
|
|
1687
|
+
let sub = this.subLink;
|
|
1688
|
+
while (sub) {
|
|
1689
|
+
sub = unlinkReactiveNode(sub);
|
|
1690
|
+
}
|
|
1691
|
+
this._job = void 0;
|
|
1692
|
+
this._flushScheduler = void 0;
|
|
1693
|
+
this.depLinkTail = void 0;
|
|
1694
|
+
this.subLinkTail = void 0;
|
|
1695
|
+
{
|
|
1696
|
+
if (this.depLink) {
|
|
1697
|
+
error(
|
|
1698
|
+
"[Effect] Cleanup verification failed: depLink not cleared. This indicates a memory leak in the dependency tracking system."
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1701
|
+
if (this.subLink) {
|
|
1702
|
+
error(
|
|
1703
|
+
"[Effect] Cleanup verification failed: subLink not cleared. This indicates a memory leak in the subscription system."
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
if ((_a52 = this.options) == null ? void 0 : _a52.onStop) {
|
|
1708
|
+
this.options.onStop();
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
function effect(fn, options) {
|
|
1713
|
+
const effectInstance = new EffectImpl(fn, options);
|
|
1714
|
+
try {
|
|
1715
|
+
effectInstance.run();
|
|
1716
|
+
} catch (_error) {
|
|
1717
|
+
effectInstance.stop();
|
|
1718
|
+
{
|
|
1719
|
+
error(
|
|
1720
|
+
"[Effect] Effect failed during initial execution and has been stopped. Fix the error in your effect function.",
|
|
1721
|
+
_error
|
|
1722
|
+
);
|
|
1723
|
+
}
|
|
1724
|
+
throw _error;
|
|
1725
|
+
}
|
|
1726
|
+
const runner = () => effectInstance.run();
|
|
1727
|
+
runner.effect = effectInstance;
|
|
1728
|
+
runner.stop = () => effectInstance.stop();
|
|
1729
|
+
return runner;
|
|
1730
|
+
}
|
|
1731
|
+
function stop(runner) {
|
|
1732
|
+
runner.effect.stop();
|
|
1733
|
+
}
|
|
1734
|
+
function isEffect(value) {
|
|
1735
|
+
return !!(value && value[
|
|
1736
|
+
"_IS_EFFECT"
|
|
1737
|
+
/* IS_EFFECT */
|
|
1738
|
+
]);
|
|
1739
|
+
}
|
|
1740
|
+
function memoEffect(fn, initialState, options) {
|
|
1741
|
+
let currentState = initialState;
|
|
1742
|
+
const effectFn = () => {
|
|
1743
|
+
const result = fn(currentState);
|
|
1744
|
+
currentState = result;
|
|
1745
|
+
};
|
|
1746
|
+
return effect(effectFn, options);
|
|
1747
|
+
}
|
|
1748
|
+
var NO_VALUE = /* @__PURE__ */ Symbol("computed-no-value");
|
|
1749
|
+
var _a3;
|
|
1750
|
+
_a3 = "_IS_COMPUTED";
|
|
1751
|
+
var ComputedImpl = class {
|
|
1752
|
+
/**
|
|
1753
|
+
* Create a Computed instance.
|
|
1754
|
+
*
|
|
1755
|
+
* @param getter - The computation function.
|
|
1756
|
+
* @param setter - Optional setter function.
|
|
1757
|
+
* @param onTrack - Optional debug callback for dependency tracking.
|
|
1758
|
+
* @param onTrigger - Optional debug callback for triggers.
|
|
1759
|
+
*/
|
|
1760
|
+
constructor(getter, setter, onTrack, onTrigger) {
|
|
1761
|
+
this.flag = 1 | 16;
|
|
1762
|
+
this[_a3] = true;
|
|
1763
|
+
this._value = NO_VALUE;
|
|
1764
|
+
this.getter = getter;
|
|
1765
|
+
this.setter = setter;
|
|
1766
|
+
this.onTrack = onTrack;
|
|
1767
|
+
this.onTrigger = onTrigger;
|
|
1768
|
+
this.flag |= 16;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Returns the current value.
|
|
1772
|
+
*
|
|
1773
|
+
* @returns {T} The current value.
|
|
1774
|
+
*/
|
|
1775
|
+
get value() {
|
|
1776
|
+
if (activeSub) {
|
|
1777
|
+
linkReactiveNode(this, activeSub);
|
|
1778
|
+
}
|
|
1779
|
+
const flags = this.flag;
|
|
1780
|
+
const hasValue = this._value !== NO_VALUE;
|
|
1781
|
+
if (hasValue && !(flags & (16 | 32))) {
|
|
1782
|
+
return this._value;
|
|
1783
|
+
}
|
|
1784
|
+
if (!hasValue || flags & 16) {
|
|
1785
|
+
this.recompute();
|
|
1786
|
+
return this._value;
|
|
1787
|
+
}
|
|
1788
|
+
if (flags & 32) {
|
|
1789
|
+
if (this.depLink && checkDirty(this.depLink, this)) {
|
|
1790
|
+
this.recompute();
|
|
1791
|
+
} else {
|
|
1792
|
+
this.flag = flags & -33;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return this._value;
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Set value (only effective when setter is provided).
|
|
1799
|
+
*
|
|
1800
|
+
* @param newValue - The new value.
|
|
1801
|
+
*/
|
|
1802
|
+
set value(newValue) {
|
|
1803
|
+
if (this.setter) {
|
|
1804
|
+
this.setter(newValue);
|
|
1805
|
+
} else {
|
|
1806
|
+
warn(
|
|
1807
|
+
"[Computed] Cannot set readonly computed value. Provide a setter in the computed options to make it writable.\nExample: computed({ get: () => value, set: (v) => { ... } })"
|
|
1808
|
+
);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Read value without tracking dependencies.
|
|
1813
|
+
*
|
|
1814
|
+
* @returns {T} The current value.
|
|
1815
|
+
*/
|
|
1816
|
+
peek() {
|
|
1817
|
+
if (this._value === NO_VALUE) {
|
|
1818
|
+
this.recompute();
|
|
1819
|
+
}
|
|
1820
|
+
return this._value;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Recompute the value
|
|
1824
|
+
*
|
|
1825
|
+
* computation logic:
|
|
1826
|
+
* 1. Start tracking dependencies
|
|
1827
|
+
* 2. Execute getter function
|
|
1828
|
+
* 3. Check if value changed using optimized comparison
|
|
1829
|
+
* 4. If changed, update cache and notify subscribers
|
|
1830
|
+
* 5. End tracking, clean up stale dependencies
|
|
1831
|
+
* @private
|
|
1832
|
+
*/
|
|
1833
|
+
recompute() {
|
|
1834
|
+
const oldValue = this._value;
|
|
1835
|
+
const hadValue = oldValue !== NO_VALUE;
|
|
1836
|
+
const prevSub = startTracking(this);
|
|
1837
|
+
try {
|
|
1838
|
+
const newValue = this.getter();
|
|
1839
|
+
const flags = this.flag;
|
|
1840
|
+
const subs = this.subLink;
|
|
1841
|
+
const clearMask = ~(16 | 32);
|
|
1842
|
+
const valueChanged = !hadValue || hasChanged(oldValue, newValue);
|
|
1843
|
+
if (valueChanged) {
|
|
1844
|
+
this._value = newValue;
|
|
1845
|
+
this.flag = flags & clearMask;
|
|
1846
|
+
if (this.onTrigger) {
|
|
1847
|
+
this.onTrigger({
|
|
1848
|
+
effect: this,
|
|
1849
|
+
target: this,
|
|
1850
|
+
type: "set",
|
|
1851
|
+
key: "value",
|
|
1852
|
+
newValue
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
if (subs) {
|
|
1856
|
+
shallowPropagate(subs);
|
|
1857
|
+
}
|
|
1858
|
+
} else {
|
|
1859
|
+
this.flag = flags & clearMask;
|
|
1860
|
+
}
|
|
1861
|
+
} catch (_error) {
|
|
1862
|
+
const clearMask = -49;
|
|
1863
|
+
this.flag &= clearMask;
|
|
1864
|
+
this._value = NO_VALUE;
|
|
1865
|
+
{
|
|
1866
|
+
error(
|
|
1867
|
+
"[Computed] Error occurred while computing value.\nThe computed will retry on next access.\nCommon causes:\n - Accessing undefined properties\n - Circular dependencies\n - Exceptions in getter function\nCheck your getter function for errors.",
|
|
1868
|
+
_error
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1871
|
+
throw _error;
|
|
1872
|
+
} finally {
|
|
1873
|
+
endTracking(this, prevSub);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Check if update is needed.
|
|
1878
|
+
*
|
|
1879
|
+
* Internal use, called by reactive system.
|
|
1880
|
+
*
|
|
1881
|
+
* @returns {boolean} True if value changed.
|
|
1882
|
+
*/
|
|
1883
|
+
shouldUpdate() {
|
|
1884
|
+
const hadValue = this._value !== NO_VALUE;
|
|
1885
|
+
const oldValue = this._value;
|
|
1886
|
+
this.recompute();
|
|
1887
|
+
if (!hadValue) {
|
|
1888
|
+
return true;
|
|
1889
|
+
}
|
|
1890
|
+
return hasChanged(this._value, oldValue);
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1893
|
+
function computed(getterOrOptions) {
|
|
1894
|
+
if (isComputed(getterOrOptions)) {
|
|
1895
|
+
{
|
|
1896
|
+
warn(
|
|
1897
|
+
"[Computed] Creating a computed from another computed is not recommended. The existing computed will be returned to avoid unnecessary wrapping."
|
|
1898
|
+
);
|
|
1899
|
+
}
|
|
1900
|
+
return getterOrOptions;
|
|
1901
|
+
}
|
|
1902
|
+
if (!getterOrOptions) {
|
|
1903
|
+
throw new Error(
|
|
1904
|
+
"[Computed] Invalid argument: computed() requires a getter function or options object."
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
if (isFunction(getterOrOptions)) {
|
|
1908
|
+
return new ComputedImpl(getterOrOptions);
|
|
1909
|
+
}
|
|
1910
|
+
if (isPlainObject(getterOrOptions)) {
|
|
1911
|
+
const { get, set, onTrack, onTrigger } = getterOrOptions;
|
|
1912
|
+
if (!get) {
|
|
1913
|
+
throw new Error(
|
|
1914
|
+
"[Computed] Invalid options: getter function is required.\nUsage: computed({ get: () => value, set: (v) => { ... } })"
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1917
|
+
if (!isFunction(get)) {
|
|
1918
|
+
throw new TypeError(
|
|
1919
|
+
`[Computed] Invalid options: getter must be a function.
|
|
1920
|
+
Received: ${typeof get}`
|
|
1921
|
+
);
|
|
1922
|
+
}
|
|
1923
|
+
return new ComputedImpl(get, set, onTrack, onTrigger);
|
|
1924
|
+
}
|
|
1925
|
+
throw new Error(
|
|
1926
|
+
`[Computed] Invalid argument: expected a function or options object.
|
|
1927
|
+
Received: ${typeof getterOrOptions}`
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1930
|
+
function isComputed(value) {
|
|
1931
|
+
return !!value && !!value[
|
|
1932
|
+
"_IS_COMPUTED"
|
|
1933
|
+
/* IS_COMPUTED */
|
|
1934
|
+
];
|
|
1935
|
+
}
|
|
1936
|
+
function createOptionsStore(options) {
|
|
1937
|
+
if (!options.state) {
|
|
1938
|
+
warn("Store state is required");
|
|
1939
|
+
throw new Error("Store state is required");
|
|
1940
|
+
}
|
|
1941
|
+
const { state, getters, actions } = options;
|
|
1942
|
+
const initState = __spreadValues({}, state);
|
|
1943
|
+
const reactiveState = reactive(state);
|
|
1944
|
+
const subscriptions = /* @__PURE__ */ new Set();
|
|
1945
|
+
const actionCallbacks = /* @__PURE__ */ new Set();
|
|
1946
|
+
const notifySubscribers = (state2) => {
|
|
1947
|
+
subscriptions.forEach((callback) => callback(state2));
|
|
1948
|
+
actionCallbacks.forEach((callback) => callback(state2));
|
|
1949
|
+
};
|
|
1950
|
+
const defaultActions = {
|
|
1951
|
+
/**
|
|
1952
|
+
* Applies a partial patch to the reactive store state.
|
|
1953
|
+
*/
|
|
1954
|
+
patch$(payload) {
|
|
1955
|
+
if (!payload) {
|
|
1956
|
+
warn("Patch payload is required");
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1959
|
+
batch(() => {
|
|
1960
|
+
Object.assign(reactiveState, payload);
|
|
1961
|
+
});
|
|
1962
|
+
notifySubscribers(reactiveState);
|
|
1963
|
+
},
|
|
1964
|
+
/**
|
|
1965
|
+
* Registers a store subscriber callback.
|
|
1966
|
+
*/
|
|
1967
|
+
subscribe$(callback) {
|
|
1968
|
+
if (!callback) {
|
|
1969
|
+
warn("Subscribe callback is required");
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
subscriptions.add(callback);
|
|
1973
|
+
},
|
|
1974
|
+
/**
|
|
1975
|
+
* Removes a previously registered store subscriber.
|
|
1976
|
+
*/
|
|
1977
|
+
unsubscribe$(callback) {
|
|
1978
|
+
subscriptions.delete(callback);
|
|
1979
|
+
},
|
|
1980
|
+
/**
|
|
1981
|
+
* Registers a callback for store action notifications.
|
|
1982
|
+
*/
|
|
1983
|
+
onAction$(callback) {
|
|
1984
|
+
if (!callback) {
|
|
1985
|
+
warn("Action callback is required");
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
actionCallbacks.add(callback);
|
|
1989
|
+
},
|
|
1990
|
+
/**
|
|
1991
|
+
* Removes a previously registered action callback.
|
|
1992
|
+
*/
|
|
1993
|
+
offAction$(callback) {
|
|
1994
|
+
actionCallbacks.delete(callback);
|
|
1995
|
+
},
|
|
1996
|
+
/**
|
|
1997
|
+
* Resets the reactive state back to its initial snapshot.
|
|
1998
|
+
*/
|
|
1999
|
+
reset$() {
|
|
2000
|
+
batch(() => {
|
|
2001
|
+
Object.assign(reactiveState, initState);
|
|
2002
|
+
});
|
|
2003
|
+
notifySubscribers(reactiveState);
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
const store = {};
|
|
2007
|
+
for (const key of Object.keys(initState)) {
|
|
2008
|
+
Object.defineProperty(store, key, {
|
|
2009
|
+
get: () => reactiveState[key],
|
|
2010
|
+
set: (value) => {
|
|
2011
|
+
reactiveState[key] = value;
|
|
2012
|
+
},
|
|
2013
|
+
enumerable: true,
|
|
2014
|
+
configurable: true
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
Object.defineProperty(store, "state", {
|
|
2018
|
+
value: reactiveState,
|
|
2019
|
+
enumerable: true,
|
|
2020
|
+
configurable: true,
|
|
2021
|
+
writable: true
|
|
2022
|
+
});
|
|
2023
|
+
Object.assign(store, defaultActions);
|
|
2024
|
+
if (getters) {
|
|
2025
|
+
for (const key in getters) {
|
|
2026
|
+
const getter = getters[key];
|
|
2027
|
+
if (!getter) continue;
|
|
2028
|
+
const getterValue = computed(() => getter.call(store, reactiveState));
|
|
2029
|
+
Object.defineProperty(store, key, {
|
|
2030
|
+
get: () => getterValue.value,
|
|
2031
|
+
enumerable: true,
|
|
2032
|
+
configurable: true
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
if (actions) {
|
|
2037
|
+
for (const key in actions) {
|
|
2038
|
+
const action = actions[key];
|
|
2039
|
+
if (action) {
|
|
2040
|
+
store[key] = (...args) => {
|
|
2041
|
+
const result = action.apply(store, args);
|
|
2042
|
+
actionCallbacks.forEach((callback) => callback(reactiveState));
|
|
2043
|
+
return result;
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
return store;
|
|
2049
|
+
}
|
|
2050
|
+
function createClassStore(StoreClass) {
|
|
2051
|
+
const instance = new StoreClass();
|
|
2052
|
+
const state = /* @__PURE__ */ Object.create(null);
|
|
2053
|
+
const getters = {};
|
|
2054
|
+
const actions = {};
|
|
2055
|
+
Object.getOwnPropertyNames(instance).forEach((key) => {
|
|
2056
|
+
state[key] = instance[key];
|
|
2057
|
+
});
|
|
2058
|
+
Object.getOwnPropertyNames(StoreClass.prototype).forEach((key) => {
|
|
2059
|
+
const descriptor = Object.getOwnPropertyDescriptor(StoreClass.prototype, key);
|
|
2060
|
+
if (descriptor) {
|
|
2061
|
+
if (isFunction(descriptor.get)) {
|
|
2062
|
+
getters[key] = function() {
|
|
2063
|
+
return descriptor.get.call(this);
|
|
2064
|
+
};
|
|
2065
|
+
} else if (isFunction(descriptor.value) && key !== "constructor") {
|
|
2066
|
+
actions[key] = function(...args) {
|
|
2067
|
+
return descriptor.value.apply(this, args);
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
return {
|
|
2073
|
+
state,
|
|
2074
|
+
getters,
|
|
2075
|
+
actions
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
function createStore(storeDefinition) {
|
|
2079
|
+
if (!storeDefinition) {
|
|
2080
|
+
warn("Store definition is required");
|
|
2081
|
+
throw new Error("Store definition is required");
|
|
2082
|
+
}
|
|
2083
|
+
return () => {
|
|
2084
|
+
let options;
|
|
2085
|
+
if (isFunction(storeDefinition)) {
|
|
2086
|
+
options = createClassStore(storeDefinition);
|
|
2087
|
+
} else {
|
|
2088
|
+
options = storeDefinition;
|
|
2089
|
+
}
|
|
2090
|
+
return createOptionsStore(options);
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
var _a4;
|
|
2094
|
+
var _b;
|
|
2095
|
+
var RefImpl = class extends (_b = SignalImpl, _a4 = "_IS_REF", _b) {
|
|
2096
|
+
/**
|
|
2097
|
+
* Creates a new ref with the given initial value.
|
|
2098
|
+
*
|
|
2099
|
+
* @param value - The initial value
|
|
2100
|
+
*/
|
|
2101
|
+
constructor(value) {
|
|
2102
|
+
super(value, true);
|
|
2103
|
+
this[_a4] = true;
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Returns the current value.
|
|
2107
|
+
*
|
|
2108
|
+
* @returns {T} The current value.
|
|
2109
|
+
*/
|
|
2110
|
+
get value() {
|
|
2111
|
+
const sub = activeSub;
|
|
2112
|
+
if (sub) {
|
|
2113
|
+
linkReactiveNode(this, sub);
|
|
2114
|
+
}
|
|
2115
|
+
return this._value;
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* Updates the current value.
|
|
2119
|
+
*
|
|
2120
|
+
* @param newValue - The new value.
|
|
2121
|
+
*/
|
|
2122
|
+
set value(newValue) {
|
|
2123
|
+
if (isSignal(newValue)) {
|
|
2124
|
+
newValue = newValue.peek();
|
|
2125
|
+
}
|
|
2126
|
+
if (isRef(newValue)) {
|
|
2127
|
+
newValue = newValue.value;
|
|
2128
|
+
}
|
|
2129
|
+
if (hasChanged(this._value, newValue)) {
|
|
2130
|
+
this._rawValue = newValue;
|
|
2131
|
+
this._value = newValue;
|
|
2132
|
+
this.flag |= 16;
|
|
2133
|
+
if (this.subLink) {
|
|
2134
|
+
propagate(this.subLink);
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
function ref(value = void 0) {
|
|
2140
|
+
if (isRef(value)) {
|
|
2141
|
+
return value;
|
|
2142
|
+
}
|
|
2143
|
+
if (isSignal(value)) {
|
|
2144
|
+
return new RefImpl(value.peek());
|
|
2145
|
+
}
|
|
2146
|
+
return new RefImpl(value);
|
|
2147
|
+
}
|
|
2148
|
+
function isRef(value) {
|
|
2149
|
+
return !!value && !!value[
|
|
2150
|
+
"_IS_REF"
|
|
2151
|
+
/* IS_REF */
|
|
2152
|
+
];
|
|
2153
|
+
}
|
|
2154
|
+
var INITIAL_WATCHER_VALUE = {};
|
|
2155
|
+
var _traverseSeen = /* @__PURE__ */ new Set();
|
|
2156
|
+
function traverse(value, seen) {
|
|
2157
|
+
if (!seen) {
|
|
2158
|
+
_traverseSeen.clear();
|
|
2159
|
+
seen = _traverseSeen;
|
|
2160
|
+
}
|
|
2161
|
+
if (!isObject(value) || seen.has(value)) {
|
|
2162
|
+
return value;
|
|
2163
|
+
}
|
|
2164
|
+
seen.add(value);
|
|
2165
|
+
if (isSignal(value) || isComputed(value)) {
|
|
2166
|
+
return traverse(value.value, seen);
|
|
2167
|
+
}
|
|
2168
|
+
if (Array.isArray(value)) {
|
|
2169
|
+
for (const element of value) {
|
|
2170
|
+
traverse(element, seen);
|
|
2171
|
+
}
|
|
2172
|
+
} else if (isMap(value)) {
|
|
2173
|
+
value.forEach((v) => {
|
|
2174
|
+
traverse(v, seen);
|
|
2175
|
+
});
|
|
2176
|
+
value.keys();
|
|
2177
|
+
value.values();
|
|
2178
|
+
} else if (isSet(value)) {
|
|
2179
|
+
value.forEach((v) => {
|
|
2180
|
+
traverse(v, seen);
|
|
2181
|
+
});
|
|
2182
|
+
value.values();
|
|
2183
|
+
} else {
|
|
2184
|
+
Object.keys(value).forEach((key) => {
|
|
2185
|
+
traverse(value[key], seen);
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
return value;
|
|
2189
|
+
}
|
|
2190
|
+
function cloneValue(value) {
|
|
2191
|
+
return value;
|
|
2192
|
+
}
|
|
2193
|
+
function resolveSingleSource(source) {
|
|
2194
|
+
if (isFunction(source)) {
|
|
2195
|
+
return source;
|
|
2196
|
+
}
|
|
2197
|
+
if (isSignal(source) || isComputed(source)) {
|
|
2198
|
+
return () => source.value;
|
|
2199
|
+
}
|
|
2200
|
+
if (isReactive(source)) {
|
|
2201
|
+
return () => traverse(source);
|
|
2202
|
+
}
|
|
2203
|
+
return () => source;
|
|
2204
|
+
}
|
|
2205
|
+
function resolveSource(source) {
|
|
2206
|
+
if (Array.isArray(source)) {
|
|
2207
|
+
const getters = source.map((s) => resolveSingleSource(s));
|
|
2208
|
+
return () => getters.map((g) => g());
|
|
2209
|
+
}
|
|
2210
|
+
return resolveSingleSource(source);
|
|
2211
|
+
}
|
|
2212
|
+
function watch(source, callback, options = {}) {
|
|
2213
|
+
const { immediate = false, deep = false } = options;
|
|
2214
|
+
let oldValue = INITIAL_WATCHER_VALUE;
|
|
2215
|
+
const getter = resolveSource(source);
|
|
2216
|
+
const job = () => {
|
|
2217
|
+
const currentEffect = runner.effect;
|
|
2218
|
+
if (!currentEffect.run) {
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2221
|
+
const newValue = currentEffect.run();
|
|
2222
|
+
if (deep || isObject(newValue) || hasChanged(newValue, oldValue)) {
|
|
2223
|
+
callback(newValue, oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue);
|
|
2224
|
+
oldValue = cloneValue(newValue);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
const runner = effect(
|
|
2228
|
+
() => {
|
|
2229
|
+
const value = getter();
|
|
2230
|
+
if (deep) {
|
|
2231
|
+
traverse(value);
|
|
2232
|
+
}
|
|
2233
|
+
return value;
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
// Use scheduler to queue job, implementing async and debouncing.
|
|
2237
|
+
scheduler: () => queueJob(job)
|
|
2238
|
+
}
|
|
2239
|
+
);
|
|
2240
|
+
if (immediate) {
|
|
2241
|
+
job();
|
|
2242
|
+
} else {
|
|
2243
|
+
oldValue = cloneValue(runner.effect.run());
|
|
2244
|
+
}
|
|
2245
|
+
return () => {
|
|
2246
|
+
runner.stop();
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
// ../template/dist/chunk-3E4EK64L.dev.esm.js
|
|
2251
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
2252
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
2253
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
2254
|
+
var __objRest = (source, exclude) => {
|
|
2255
|
+
var target = {};
|
|
2256
|
+
for (var prop in source)
|
|
2257
|
+
if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2258
|
+
target[prop] = source[prop];
|
|
2259
|
+
if (source != null && __getOwnPropSymbols2)
|
|
2260
|
+
for (var prop of __getOwnPropSymbols2(source)) {
|
|
2261
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
|
|
2262
|
+
target[prop] = source[prop];
|
|
2263
|
+
}
|
|
2264
|
+
return target;
|
|
2265
|
+
};
|
|
2266
|
+
var __async = (__this, __arguments, generator) => {
|
|
2267
|
+
return new Promise((resolve2, reject) => {
|
|
2268
|
+
var fulfilled = (value) => {
|
|
2269
|
+
try {
|
|
2270
|
+
step(generator.next(value));
|
|
2271
|
+
} catch (e) {
|
|
2272
|
+
reject(e);
|
|
2273
|
+
}
|
|
2274
|
+
};
|
|
2275
|
+
var rejected = (value) => {
|
|
2276
|
+
try {
|
|
2277
|
+
step(generator.throw(value));
|
|
2278
|
+
} catch (e) {
|
|
2279
|
+
reject(e);
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2283
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2284
|
+
});
|
|
2285
|
+
};
|
|
2286
|
+
var activeScope = null;
|
|
2287
|
+
var scopeId = 0;
|
|
2288
|
+
function getActiveScope() {
|
|
2289
|
+
return activeScope;
|
|
2290
|
+
}
|
|
2291
|
+
function createScope(parent = activeScope) {
|
|
2292
|
+
const scope = {
|
|
2293
|
+
id: ++scopeId,
|
|
2294
|
+
parent,
|
|
2295
|
+
children: null,
|
|
2296
|
+
// Lazy initialized
|
|
2297
|
+
provides: null,
|
|
2298
|
+
// Lazy initialized
|
|
2299
|
+
cleanup: null,
|
|
2300
|
+
// Lazy initialized
|
|
2301
|
+
onMount: null,
|
|
2302
|
+
// Lazy initialized
|
|
2303
|
+
onUpdate: null,
|
|
2304
|
+
// Lazy initialized
|
|
2305
|
+
onDestroy: null,
|
|
2306
|
+
// Lazy initialized
|
|
2307
|
+
isMounted: false,
|
|
2308
|
+
isDestroyed: false
|
|
2309
|
+
};
|
|
2310
|
+
if (parent) {
|
|
2311
|
+
if (!parent.children) {
|
|
2312
|
+
parent.children = /* @__PURE__ */ new Set();
|
|
2313
|
+
}
|
|
2314
|
+
parent.children.add(scope);
|
|
2315
|
+
}
|
|
2316
|
+
return scope;
|
|
2317
|
+
}
|
|
2318
|
+
function runWithScope(scope, fn) {
|
|
2319
|
+
const prevScope = activeScope;
|
|
2320
|
+
activeScope = scope;
|
|
2321
|
+
try {
|
|
2322
|
+
return fn();
|
|
2323
|
+
} finally {
|
|
2324
|
+
activeScope = prevScope;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
function disposeScope(scope) {
|
|
2328
|
+
var _a6;
|
|
2329
|
+
if (!scope || scope.isDestroyed) {
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
scope.isDestroyed = true;
|
|
2333
|
+
if (scope.children && scope.children.size > 0) {
|
|
2334
|
+
for (const child2 of scope.children) {
|
|
2335
|
+
if (child2) {
|
|
2336
|
+
child2.parent = null;
|
|
2337
|
+
disposeScope(child2);
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
scope.children.clear();
|
|
2341
|
+
}
|
|
2342
|
+
const prevScope = activeScope;
|
|
2343
|
+
activeScope = scope;
|
|
2344
|
+
try {
|
|
2345
|
+
if (scope.onDestroy) {
|
|
2346
|
+
for (let i = 0; i < scope.onDestroy.length; i++) {
|
|
2347
|
+
try {
|
|
2348
|
+
scope.onDestroy[i]();
|
|
2349
|
+
} catch (error_) {
|
|
2350
|
+
if (true) {
|
|
2351
|
+
error(`Scope(${scope.id}): Error in destroy hook:`, error_);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
scope.onDestroy = null;
|
|
2356
|
+
}
|
|
2357
|
+
if (scope.cleanup) {
|
|
2358
|
+
for (let i = 0; i < scope.cleanup.length; i++) {
|
|
2359
|
+
try {
|
|
2360
|
+
scope.cleanup[i]();
|
|
2361
|
+
} catch (error_) {
|
|
2362
|
+
if (true) {
|
|
2363
|
+
error(`Scope(${scope.id}): Error in cleanup:`, error_);
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
scope.cleanup = null;
|
|
2368
|
+
}
|
|
2369
|
+
} finally {
|
|
2370
|
+
activeScope = prevScope;
|
|
2371
|
+
}
|
|
2372
|
+
if ((_a6 = scope.parent) == null ? void 0 : _a6.children) {
|
|
2373
|
+
scope.parent.children.delete(scope);
|
|
2374
|
+
}
|
|
2375
|
+
if (scope.provides) {
|
|
2376
|
+
scope.provides.clear();
|
|
2377
|
+
scope.provides = null;
|
|
2378
|
+
}
|
|
2379
|
+
scope.onMount = null;
|
|
2380
|
+
scope.onUpdate = null;
|
|
2381
|
+
scope.children = null;
|
|
2382
|
+
scope.parent = null;
|
|
2383
|
+
}
|
|
2384
|
+
function onCleanup(fn) {
|
|
2385
|
+
const scope = activeScope;
|
|
2386
|
+
if (!scope) {
|
|
2387
|
+
{
|
|
2388
|
+
error("onCleanup() must be called within a scope");
|
|
2389
|
+
}
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
if (!scope.cleanup) {
|
|
2393
|
+
scope.cleanup = [];
|
|
2394
|
+
}
|
|
2395
|
+
scope.cleanup.push(fn);
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
// ../template/dist/template.dev.esm.js
|
|
2399
|
+
var SPREAD_NAME = "_$spread$";
|
|
2400
|
+
var REF_KEY = "ref";
|
|
2401
|
+
var KEY_PROP = "key";
|
|
2402
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
2403
|
+
var XLINK_NAMESPACE = "http://www.w3.org/2000/xlink";
|
|
2404
|
+
var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
|
|
2405
|
+
var FRAGMENT_COMPONENT = /* @__PURE__ */ Symbol("Fragment Component");
|
|
2406
|
+
var PORTAL_COMPONENT = /* @__PURE__ */ Symbol("Portal Component");
|
|
2407
|
+
var SUSPENSE_COMPONENT = /* @__PURE__ */ Symbol("Suspense Component");
|
|
2408
|
+
var FOR_COMPONENT = /* @__PURE__ */ Symbol("For Component");
|
|
2409
|
+
function patchAttr(el, key, prev, next2) {
|
|
2410
|
+
if (key === KEY_PROP) {
|
|
2411
|
+
if (next2 == null) {
|
|
2412
|
+
el.removeAttribute(key);
|
|
2413
|
+
} else {
|
|
2414
|
+
el.setAttribute(key, String(next2));
|
|
2415
|
+
}
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
if (key === SPREAD_NAME) {
|
|
2419
|
+
const prevObj = isObject(prev) ? prev : null;
|
|
2420
|
+
const nextObj = isObject(next2) ? next2 : null;
|
|
2421
|
+
{
|
|
2422
|
+
if (next2 != null && !nextObj) {
|
|
2423
|
+
warn("spread attribute must be an object");
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
if (prevObj) {
|
|
2427
|
+
for (const attrKey in prevObj) {
|
|
2428
|
+
if (attrKey === SPREAD_NAME) {
|
|
2429
|
+
{
|
|
2430
|
+
warn("nested spread attributes are ignored");
|
|
2431
|
+
}
|
|
2432
|
+
continue;
|
|
2433
|
+
}
|
|
2434
|
+
if (!nextObj || !(attrKey in nextObj)) {
|
|
2435
|
+
patchAttr(el, attrKey, prevObj[attrKey], null);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
if (nextObj) {
|
|
2440
|
+
for (const attrKey in nextObj) {
|
|
2441
|
+
if (attrKey === SPREAD_NAME) {
|
|
2442
|
+
{
|
|
2443
|
+
warn("nested spread attributes are ignored");
|
|
2444
|
+
}
|
|
2445
|
+
continue;
|
|
2446
|
+
}
|
|
2447
|
+
patchAttr(el, attrKey, prevObj == null ? void 0 : prevObj[attrKey], nextObj[attrKey]);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
const elementIsSVG = (el == null ? void 0 : el.namespaceURI) === SVG_NAMESPACE;
|
|
2453
|
+
const isXlink = elementIsSVG && key.startsWith("xlink:");
|
|
2454
|
+
const isXmlns = elementIsSVG && key.startsWith("xmlns:");
|
|
2455
|
+
const isBoolean = isSpecialBooleanAttr(key) || isBooleanAttr(key);
|
|
2456
|
+
if (prev === next2) {
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110) {
|
|
2460
|
+
return;
|
|
2461
|
+
}
|
|
2462
|
+
const lowerKey = key.toLowerCase();
|
|
2463
|
+
if (lowerKey === "innerhtml" || lowerKey === "srcdoc") {
|
|
2464
|
+
{
|
|
2465
|
+
warn(`${key} updates are ignored by patchAttr`);
|
|
2466
|
+
}
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
if (next2 == null) {
|
|
2470
|
+
if (isXlink) {
|
|
2471
|
+
el.removeAttributeNS(XLINK_NAMESPACE, key.slice(6));
|
|
2472
|
+
} else if (isXmlns) {
|
|
2473
|
+
const localName = key.slice(6);
|
|
2474
|
+
el.removeAttributeNS(XMLNS_NAMESPACE, localName);
|
|
2475
|
+
} else {
|
|
2476
|
+
el.removeAttribute(key);
|
|
2477
|
+
}
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2480
|
+
if (isBoolean) {
|
|
2481
|
+
if (includeBooleanAttr(next2)) {
|
|
2482
|
+
el.setAttribute(key, "");
|
|
2483
|
+
} else {
|
|
2484
|
+
el.removeAttribute(key);
|
|
2485
|
+
}
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
const attrValue = isSymbol(next2) ? String(next2) : next2;
|
|
2489
|
+
const isUrlAttr = lowerKey === "href" || lowerKey === "src" || lowerKey === "xlink:href" || lowerKey === "action" || lowerKey === "formaction" || lowerKey === "poster";
|
|
2490
|
+
if (isUrlAttr && isString(attrValue)) {
|
|
2491
|
+
const v = attrValue.trim().toLowerCase();
|
|
2492
|
+
if (v.startsWith("javascript:") || v.startsWith("data:")) {
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
if (isXlink) {
|
|
2497
|
+
el.setAttributeNS(XLINK_NAMESPACE, key, String(attrValue));
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
if (isXmlns) {
|
|
2501
|
+
el.setAttributeNS(XMLNS_NAMESPACE, key, String(attrValue));
|
|
2502
|
+
return;
|
|
2503
|
+
}
|
|
2504
|
+
if (elementIsSVG) {
|
|
2505
|
+
el.setAttribute(key, String(attrValue));
|
|
2506
|
+
} else {
|
|
2507
|
+
if (key in el) {
|
|
2508
|
+
try {
|
|
2509
|
+
el[key] = attrValue;
|
|
2510
|
+
} catch (e) {
|
|
2511
|
+
el.setAttribute(key, String(attrValue));
|
|
2512
|
+
}
|
|
2513
|
+
} else {
|
|
2514
|
+
el.setAttribute(key, String(attrValue));
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
function patchClass(el, prev, next2, isSVG = false) {
|
|
2519
|
+
if (prev === next2) {
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
const normalizedNext = normalizeClass(next2);
|
|
2523
|
+
if (!normalizedNext) {
|
|
2524
|
+
el.removeAttribute("class");
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
const normalizedPrev = isString(prev) ? prev : normalizeClass(prev);
|
|
2528
|
+
if (normalizedPrev === normalizedNext) {
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
if (isSVG) {
|
|
2532
|
+
el.setAttribute("class", normalizedNext);
|
|
2533
|
+
} else {
|
|
2534
|
+
el.className = normalizedNext;
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
var normalizeClass = normalizeClassName;
|
|
2538
|
+
var importantRE = /\s*!important$/;
|
|
2539
|
+
var prefixes = ["Webkit", "Moz", "ms"];
|
|
2540
|
+
var prefixCache = {};
|
|
2541
|
+
function patchStyle(el, prev, next2) {
|
|
2542
|
+
const style = el.style;
|
|
2543
|
+
if (next2 && isString(next2)) {
|
|
2544
|
+
if (prev !== next2) {
|
|
2545
|
+
style.cssText = next2;
|
|
2546
|
+
}
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
if (!next2) {
|
|
2550
|
+
if (prev) {
|
|
2551
|
+
el.removeAttribute("style");
|
|
2552
|
+
}
|
|
2553
|
+
return;
|
|
2554
|
+
}
|
|
2555
|
+
if (prev && !isString(prev)) {
|
|
2556
|
+
const prevObj = prev;
|
|
2557
|
+
for (const key in prevObj) {
|
|
2558
|
+
if (!next2 || next2[key] == null) {
|
|
2559
|
+
setStyle(style, key, "");
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
} else if (prev && isString(prev)) {
|
|
2563
|
+
const declRE = /(?:^|;)\s*([a-z][a-z\d-]*)\s*:/gi;
|
|
2564
|
+
let match;
|
|
2565
|
+
while ((match = declRE.exec(prev)) !== null) {
|
|
2566
|
+
const key = match[1].trim();
|
|
2567
|
+
if (key && next2 && isObject(next2) && next2[key] == null) {
|
|
2568
|
+
setStyle(style, key, "");
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
if (next2 && !isString(next2)) {
|
|
2573
|
+
const nextObj = next2;
|
|
2574
|
+
for (const key in nextObj) {
|
|
2575
|
+
const value = nextObj[key];
|
|
2576
|
+
if ((!prev || isString(prev) || prev[key] !== value) && value != null) {
|
|
2577
|
+
setStyle(style, key, value);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
function setStyle(style, name, val) {
|
|
2583
|
+
if (isArray(val)) {
|
|
2584
|
+
for (const element of val) {
|
|
2585
|
+
setStyle(style, name, element);
|
|
2586
|
+
}
|
|
2587
|
+
return;
|
|
2588
|
+
}
|
|
2589
|
+
if (val == null || val === "") {
|
|
2590
|
+
val = "";
|
|
2591
|
+
}
|
|
2592
|
+
if (name.startsWith("--")) {
|
|
2593
|
+
style.setProperty(name, val);
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2596
|
+
const prefixed = autoPrefix(style, name);
|
|
2597
|
+
if (isString(val) && importantRE.test(val)) {
|
|
2598
|
+
style.setProperty(camelCase(prefixed), val.replace(importantRE, ""), "important");
|
|
2599
|
+
} else {
|
|
2600
|
+
style[prefixed] = val;
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
function autoPrefix(style, rawName) {
|
|
2604
|
+
const cached = prefixCache[rawName];
|
|
2605
|
+
if (cached) {
|
|
2606
|
+
return cached;
|
|
2607
|
+
}
|
|
2608
|
+
let name = camelCase(rawName);
|
|
2609
|
+
if (name !== "filter" && name in style) {
|
|
2610
|
+
return prefixCache[rawName] = name;
|
|
2611
|
+
}
|
|
2612
|
+
name = capitalize(name);
|
|
2613
|
+
for (const prefix of prefixes) {
|
|
2614
|
+
const prefixed = prefix + name;
|
|
2615
|
+
if (prefixed in style) {
|
|
2616
|
+
return prefixCache[rawName] = prefixed;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
return rawName;
|
|
2620
|
+
}
|
|
2621
|
+
var _hydrationKey = 0;
|
|
2622
|
+
function getHydrationKey() {
|
|
2623
|
+
return String(_hydrationKey++);
|
|
2624
|
+
}
|
|
2625
|
+
function resetHydrationKey() {
|
|
2626
|
+
_hydrationKey = 0;
|
|
2627
|
+
}
|
|
2628
|
+
var _isHydrating = false;
|
|
2629
|
+
function isHydrating() {
|
|
2630
|
+
return _isHydrating;
|
|
2631
|
+
}
|
|
2632
|
+
var _registry = /* @__PURE__ */ new Map();
|
|
2633
|
+
function gatherHydratable(root) {
|
|
2634
|
+
const nodes = root.querySelectorAll("[data-hk]");
|
|
2635
|
+
for (const node of nodes) {
|
|
2636
|
+
const key = node.dataset.hk;
|
|
2637
|
+
if (key != null && !_registry.has(key)) {
|
|
2638
|
+
_registry.set(key, node);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
var _teleportCallsiteAnchors = [];
|
|
2643
|
+
var _teleportTargetStarts = /* @__PURE__ */ new Map();
|
|
2644
|
+
function gatherTeleportAnchors() {
|
|
2645
|
+
if (typeof document === "undefined") return;
|
|
2646
|
+
const walker = document.createNodeIterator(document.body, NodeFilter.SHOW_COMMENT);
|
|
2647
|
+
let node;
|
|
2648
|
+
while (node = walker.nextNode()) {
|
|
2649
|
+
const data = node.data;
|
|
2650
|
+
if (data === "teleport-anchor") {
|
|
2651
|
+
_teleportCallsiteAnchors.push(node);
|
|
2652
|
+
} else if (data === "teleport-start") {
|
|
2653
|
+
const parent = node.parentElement;
|
|
2654
|
+
if (!parent) continue;
|
|
2655
|
+
let bucket = _teleportTargetStarts.get(parent);
|
|
2656
|
+
if (!bucket) {
|
|
2657
|
+
bucket = [];
|
|
2658
|
+
_teleportTargetStarts.set(parent, bucket);
|
|
2659
|
+
}
|
|
2660
|
+
bucket.push(node);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
function consumeTeleportAnchor() {
|
|
2665
|
+
var _a22;
|
|
2666
|
+
return (_a22 = _teleportCallsiteAnchors.shift()) != null ? _a22 : null;
|
|
2667
|
+
}
|
|
2668
|
+
function consumeTeleportBlock(target) {
|
|
2669
|
+
const bucket = _teleportTargetStarts.get(target);
|
|
2670
|
+
const start = bucket == null ? void 0 : bucket.shift();
|
|
2671
|
+
if (!start) return null;
|
|
2672
|
+
const nodes = [];
|
|
2673
|
+
let cursor = start.nextSibling;
|
|
2674
|
+
while (cursor) {
|
|
2675
|
+
if (cursor.nodeType === Node.COMMENT_NODE && cursor.data === "teleport-end") {
|
|
2676
|
+
return { start, end: cursor, nodes };
|
|
2677
|
+
}
|
|
2678
|
+
nodes.push(cursor);
|
|
2679
|
+
cursor = cursor.nextSibling;
|
|
2680
|
+
}
|
|
2681
|
+
{
|
|
2682
|
+
warn("[Portal] hydration: orphaned <!--teleport-start--> without matching <!--teleport-end-->");
|
|
2683
|
+
}
|
|
2684
|
+
return null;
|
|
2685
|
+
}
|
|
2686
|
+
function beginHydration(root) {
|
|
2687
|
+
_isHydrating = true;
|
|
2688
|
+
_hydrationKey = 0;
|
|
2689
|
+
_registry.clear();
|
|
2690
|
+
_teleportCallsiteAnchors.length = 0;
|
|
2691
|
+
_teleportTargetStarts.clear();
|
|
2692
|
+
gatherHydratable(root);
|
|
2693
|
+
gatherTeleportAnchors();
|
|
2694
|
+
}
|
|
2695
|
+
function endHydration() {
|
|
2696
|
+
_isHydrating = false;
|
|
2697
|
+
_registry.clear();
|
|
2698
|
+
_teleportCallsiteAnchors.length = 0;
|
|
2699
|
+
_teleportTargetStarts.clear();
|
|
2700
|
+
}
|
|
2701
|
+
function getRenderedElement(html) {
|
|
2702
|
+
if (!isBrowser()) {
|
|
2703
|
+
return () => {
|
|
2704
|
+
throw new Error("[essor] getRenderedElement called in non-browser environment");
|
|
2705
|
+
};
|
|
2706
|
+
}
|
|
2707
|
+
let _csrFactory = null;
|
|
2708
|
+
return () => {
|
|
2709
|
+
if (!_isHydrating) {
|
|
2710
|
+
if (!_csrFactory) _csrFactory = template(html);
|
|
2711
|
+
return _csrFactory();
|
|
2712
|
+
}
|
|
2713
|
+
const key = getHydrationKey();
|
|
2714
|
+
const node = _registry.get(key);
|
|
2715
|
+
if (node) {
|
|
2716
|
+
_registry.delete(key);
|
|
2717
|
+
return node;
|
|
2718
|
+
}
|
|
2719
|
+
warn(`[essor] hydration mismatch: no SSR element for key "${key}"`);
|
|
2720
|
+
if (!_csrFactory) _csrFactory = template(html);
|
|
2721
|
+
return _csrFactory();
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
function patchClassHydrate(el, prev, next2, isSVG) {
|
|
2725
|
+
if (_isHydrating) return;
|
|
2726
|
+
patchClass(el, prev, next2, isSVG);
|
|
2727
|
+
}
|
|
2728
|
+
function patchAttrHydrate(el, key, prev, next2) {
|
|
2729
|
+
if (_isHydrating) return;
|
|
2730
|
+
patchAttr(el, key, prev, next2);
|
|
2731
|
+
}
|
|
2732
|
+
function patchStyleHydrate(el, prev, next2) {
|
|
2733
|
+
if (_isHydrating) return;
|
|
2734
|
+
patchStyle(el, prev, next2);
|
|
2735
|
+
}
|
|
2736
|
+
function resolveInsertAnchor(parent, candidate) {
|
|
2737
|
+
return candidate && candidate.parentNode === parent ? candidate : null;
|
|
2738
|
+
}
|
|
2739
|
+
function reconcileArrays(parent, oldNodes, newNodes, anchor) {
|
|
2740
|
+
const fallbackAnchor = resolveInsertAnchor(parent, anchor);
|
|
2741
|
+
const oldLength = oldNodes.length;
|
|
2742
|
+
const newLength = newNodes.length;
|
|
2743
|
+
if (oldLength === 0 && newLength === 0) return newNodes;
|
|
2744
|
+
if (oldLength === 0) {
|
|
2745
|
+
for (let i = 0; i < newLength; i++) {
|
|
2746
|
+
insertNode(parent, newNodes[i], fallbackAnchor);
|
|
2747
|
+
}
|
|
2748
|
+
return newNodes;
|
|
2749
|
+
}
|
|
2750
|
+
if (newLength === 0) {
|
|
2751
|
+
for (let i = 0; i < oldLength; i++) {
|
|
2752
|
+
removeNode(oldNodes[i]);
|
|
2753
|
+
}
|
|
2754
|
+
return [];
|
|
2755
|
+
}
|
|
2756
|
+
let start = 0;
|
|
2757
|
+
let oldEnd = oldLength - 1;
|
|
2758
|
+
let newEnd = newLength - 1;
|
|
2759
|
+
while (start <= oldEnd && start <= newEnd) {
|
|
2760
|
+
if (oldNodes[start] === newNodes[start]) {
|
|
2761
|
+
start++;
|
|
2762
|
+
} else {
|
|
2763
|
+
break;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
while (oldEnd >= start && newEnd >= start) {
|
|
2767
|
+
if (oldNodes[oldEnd] === newNodes[newEnd]) {
|
|
2768
|
+
oldEnd--;
|
|
2769
|
+
newEnd--;
|
|
2770
|
+
} else {
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
if (start > oldEnd) {
|
|
2775
|
+
if (start <= newEnd) {
|
|
2776
|
+
const nextPos = newEnd + 1;
|
|
2777
|
+
const nextNode = resolveInsertAnchor(
|
|
2778
|
+
parent,
|
|
2779
|
+
nextPos < newLength ? newNodes[nextPos] : fallbackAnchor
|
|
2780
|
+
);
|
|
2781
|
+
for (let i = start; i <= newEnd; i++) {
|
|
2782
|
+
insertNode(parent, newNodes[i], nextNode);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
} else if (start > newEnd) {
|
|
2786
|
+
for (let i = start; i <= oldEnd; i++) {
|
|
2787
|
+
removeNode(oldNodes[i]);
|
|
2788
|
+
}
|
|
2789
|
+
} else {
|
|
2790
|
+
reconcileUnknownSequence(parent, oldNodes, newNodes, start, oldEnd, newEnd, fallbackAnchor);
|
|
2791
|
+
}
|
|
2792
|
+
return newNodes;
|
|
2793
|
+
}
|
|
2794
|
+
function reconcileUnknownSequence(parent, oldNodes, newNodes, start, oldEnd, newEnd, anchor) {
|
|
2795
|
+
const newLength = newEnd - start + 1;
|
|
2796
|
+
const newIndexMap = /* @__PURE__ */ new Map();
|
|
2797
|
+
for (let i = start; i <= newEnd; i++) {
|
|
2798
|
+
newIndexMap.set(newNodes[i], i);
|
|
2799
|
+
}
|
|
2800
|
+
const newIndexToOldIndexMap = new Int32Array(newLength);
|
|
2801
|
+
newIndexToOldIndexMap.fill(0);
|
|
2802
|
+
let patched = 0;
|
|
2803
|
+
let moved = false;
|
|
2804
|
+
let maxNewIndexSoFar = 0;
|
|
2805
|
+
for (let i = start; i <= oldEnd; i++) {
|
|
2806
|
+
const oldNode = oldNodes[i];
|
|
2807
|
+
if (patched >= newLength) {
|
|
2808
|
+
removeNode(oldNode);
|
|
2809
|
+
continue;
|
|
2810
|
+
}
|
|
2811
|
+
const newIndex = newIndexMap.get(oldNode);
|
|
2812
|
+
if (newIndex === void 0) {
|
|
2813
|
+
removeNode(oldNode);
|
|
2814
|
+
} else {
|
|
2815
|
+
newIndexToOldIndexMap[newIndex - start] = i + 1;
|
|
2816
|
+
if (newIndex >= maxNewIndexSoFar) {
|
|
2817
|
+
maxNewIndexSoFar = newIndex;
|
|
2818
|
+
} else {
|
|
2819
|
+
moved = true;
|
|
2820
|
+
}
|
|
2821
|
+
patched++;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : [];
|
|
2825
|
+
let j = increasingNewIndexSequence.length - 1;
|
|
2826
|
+
for (let i = newLength - 1; i >= 0; i--) {
|
|
2827
|
+
const nextIndex = start + i;
|
|
2828
|
+
const nextNode = newNodes[nextIndex];
|
|
2829
|
+
const anchorNode = resolveInsertAnchor(
|
|
2830
|
+
parent,
|
|
2831
|
+
nextIndex + 1 < newNodes.length ? newNodes[nextIndex + 1] : anchor
|
|
2832
|
+
);
|
|
2833
|
+
if (newIndexToOldIndexMap[i] === 0) {
|
|
2834
|
+
insertNode(parent, nextNode, anchorNode);
|
|
2835
|
+
} else if (moved) {
|
|
2836
|
+
if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
|
2837
|
+
insertNode(parent, nextNode, anchorNode);
|
|
2838
|
+
} else {
|
|
2839
|
+
j--;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
function getSequence(arr) {
|
|
2845
|
+
const p2 = new Int32Array(arr.length);
|
|
2846
|
+
const result = [0];
|
|
2847
|
+
const len = arr.length;
|
|
2848
|
+
let i;
|
|
2849
|
+
let j;
|
|
2850
|
+
let u;
|
|
2851
|
+
let v;
|
|
2852
|
+
let c;
|
|
2853
|
+
for (i = 0; i < len; i++) {
|
|
2854
|
+
const arrI = arr[i];
|
|
2855
|
+
if (arrI !== 0) {
|
|
2856
|
+
j = result[result.length - 1];
|
|
2857
|
+
if (arr[j] < arrI) {
|
|
2858
|
+
p2[i] = j;
|
|
2859
|
+
result.push(i);
|
|
2860
|
+
continue;
|
|
2861
|
+
}
|
|
2862
|
+
u = 0;
|
|
2863
|
+
v = result.length - 1;
|
|
2864
|
+
while (u < v) {
|
|
2865
|
+
c = u + v >> 1;
|
|
2866
|
+
if (arr[result[c]] < arrI) {
|
|
2867
|
+
u = c + 1;
|
|
2868
|
+
} else {
|
|
2869
|
+
v = c;
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
if (arrI < arr[result[u]]) {
|
|
2873
|
+
if (u > 0) {
|
|
2874
|
+
p2[i] = result[u - 1];
|
|
2875
|
+
}
|
|
2876
|
+
result[u] = i;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
u = result.length;
|
|
2881
|
+
v = result[u - 1];
|
|
2882
|
+
while (u-- > 0) {
|
|
2883
|
+
result[u] = v;
|
|
2884
|
+
v = p2[v];
|
|
2885
|
+
}
|
|
2886
|
+
return result;
|
|
2887
|
+
}
|
|
2888
|
+
function removeNode(node) {
|
|
2889
|
+
if (!node) return;
|
|
2890
|
+
if (isComponent(node)) {
|
|
2891
|
+
node.destroy();
|
|
2892
|
+
} else {
|
|
2893
|
+
const element = node;
|
|
2894
|
+
if (element.parentNode) {
|
|
2895
|
+
element.remove();
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
function insertNode(parent, child2, before) {
|
|
2900
|
+
if (!parent || !child2) return;
|
|
2901
|
+
const beforeNode = isComponent(before) ? before.firstChild : before;
|
|
2902
|
+
if (isComponent(child2)) {
|
|
2903
|
+
child2.mount(parent, beforeNode);
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
if (beforeNode) {
|
|
2907
|
+
parent.insertBefore(child2, beforeNode);
|
|
2908
|
+
} else {
|
|
2909
|
+
{
|
|
2910
|
+
if (!child2) {
|
|
2911
|
+
error("insertNode: child is not a Node", child2);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
parent.appendChild(child2);
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
function normalizeNode(node) {
|
|
2918
|
+
if (node instanceof Node) return node;
|
|
2919
|
+
if (isComponent(node)) return node;
|
|
2920
|
+
const t = typeof node;
|
|
2921
|
+
if (node == null || t === "string" || t === "number" || t === "boolean" || t === "symbol") {
|
|
2922
|
+
return document.createTextNode(node === false || node == null ? "" : String(node));
|
|
2923
|
+
}
|
|
2924
|
+
if (isObject(node)) {
|
|
2925
|
+
warn(
|
|
2926
|
+
"Rendering a plain object as a node is not recommended. The object will be converted to its string representation.",
|
|
2927
|
+
node
|
|
2928
|
+
);
|
|
2929
|
+
}
|
|
2930
|
+
return document.createTextNode(String(node));
|
|
2931
|
+
}
|
|
2932
|
+
function insert(parent, nodeFactory, before) {
|
|
2933
|
+
if (!parent) return;
|
|
2934
|
+
const ownerScope = getActiveScope();
|
|
2935
|
+
let renderedNodes = [];
|
|
2936
|
+
let isFirstRun = true;
|
|
2937
|
+
const resolveNodes = (raw) => {
|
|
2938
|
+
if (raw instanceof Node) return [raw];
|
|
2939
|
+
if (isComponent(raw)) return [raw];
|
|
2940
|
+
const t = typeof raw;
|
|
2941
|
+
if (raw == null || t === "string" || t === "number" || t === "boolean") {
|
|
2942
|
+
return [normalizeNode(raw)];
|
|
2943
|
+
}
|
|
2944
|
+
return coerceArray(raw).map((item) => isFunction(item) ? item() : item).flatMap((i) => i).map(normalizeNode);
|
|
2945
|
+
};
|
|
2946
|
+
const effectRunner = effect(() => {
|
|
2947
|
+
const executeUpdate = () => {
|
|
2948
|
+
const rawNodes = isFunction(nodeFactory) ? nodeFactory() : nodeFactory;
|
|
2949
|
+
const nodes = resolveNodes(rawNodes);
|
|
2950
|
+
if (isFirstRun && isHydrating() && nodes.every((node) => node instanceof Node && node.parentNode === parent)) {
|
|
2951
|
+
renderedNodes = nodes;
|
|
2952
|
+
isFirstRun = false;
|
|
2953
|
+
return;
|
|
2954
|
+
}
|
|
2955
|
+
renderedNodes = reconcileArrays(parent, renderedNodes, nodes, before);
|
|
2956
|
+
isFirstRun = false;
|
|
2957
|
+
};
|
|
2958
|
+
if (ownerScope && !ownerScope.isDestroyed) {
|
|
2959
|
+
runWithScope(ownerScope, executeUpdate);
|
|
2960
|
+
} else {
|
|
2961
|
+
executeUpdate();
|
|
2962
|
+
}
|
|
2963
|
+
});
|
|
2964
|
+
onCleanup(() => {
|
|
2965
|
+
effectRunner.stop();
|
|
2966
|
+
for (const node of renderedNodes) removeNode(node);
|
|
2967
|
+
renderedNodes = [];
|
|
2968
|
+
});
|
|
2969
|
+
return renderedNodes;
|
|
2970
|
+
}
|
|
2971
|
+
function child(node) {
|
|
2972
|
+
return (node == null ? void 0 : node.firstChild) || null;
|
|
2973
|
+
}
|
|
2974
|
+
function next(node, step = 1) {
|
|
2975
|
+
while (node && step > 0) {
|
|
2976
|
+
node = node.nextSibling;
|
|
2977
|
+
step--;
|
|
2978
|
+
}
|
|
2979
|
+
return node || null;
|
|
2980
|
+
}
|
|
2981
|
+
function nthChild(node, index) {
|
|
2982
|
+
if (!node || index < 0) return null;
|
|
2983
|
+
let current = node.firstChild;
|
|
2984
|
+
while (current && index > 0) {
|
|
2985
|
+
current = current.nextSibling;
|
|
2986
|
+
index--;
|
|
2987
|
+
}
|
|
2988
|
+
return current || null;
|
|
2989
|
+
}
|
|
2990
|
+
function addEvent(el, event, handler, options) {
|
|
2991
|
+
if (!(options == null ? void 0 : options.delegate)) {
|
|
2992
|
+
el.addEventListener(event, handler, options);
|
|
2993
|
+
return () => el.removeEventListener(event, handler, options);
|
|
2994
|
+
}
|
|
2995
|
+
const selector = options.delegate;
|
|
2996
|
+
const wrappedHandler = (e) => {
|
|
2997
|
+
const target = e.target;
|
|
2998
|
+
if (target.matches(selector) || target.closest(selector)) {
|
|
2999
|
+
handler.call(el, e);
|
|
3000
|
+
}
|
|
3001
|
+
};
|
|
3002
|
+
const _a22 = options, { delegate: _ } = _a22, nativeOptions = __objRest(_a22, ["delegate"]);
|
|
3003
|
+
el.addEventListener(event, wrappedHandler, nativeOptions);
|
|
3004
|
+
return () => {
|
|
3005
|
+
el.removeEventListener(event, wrappedHandler, nativeOptions);
|
|
3006
|
+
};
|
|
3007
|
+
}
|
|
3008
|
+
function registerScopedHook(scope, listKey, hook) {
|
|
3009
|
+
let hookList = scope[listKey];
|
|
3010
|
+
if (!hookList) {
|
|
3011
|
+
hookList = [];
|
|
3012
|
+
scope[listKey] = hookList;
|
|
3013
|
+
}
|
|
3014
|
+
hookList.push(hook);
|
|
3015
|
+
}
|
|
3016
|
+
function executeHooks(hooks, scopeId2, phase) {
|
|
3017
|
+
const len = hooks.length;
|
|
3018
|
+
if (len === 0) return;
|
|
3019
|
+
let pending;
|
|
3020
|
+
for (let i = 0; i < len; i++) {
|
|
3021
|
+
try {
|
|
3022
|
+
const result = hooks[i]();
|
|
3023
|
+
if (isPromise(result)) {
|
|
3024
|
+
const safePromise = result.catch((error_) => {
|
|
3025
|
+
if (true) {
|
|
3026
|
+
error(`Scope(${scopeId2}): Async ${phase} hook rejected:`, error_);
|
|
3027
|
+
}
|
|
3028
|
+
});
|
|
3029
|
+
(pending || (pending = [])).push(safePromise);
|
|
3030
|
+
}
|
|
3031
|
+
} catch (error_) {
|
|
3032
|
+
{
|
|
3033
|
+
error(`Scope(${scopeId2}): Error in ${phase} hook:`, error_);
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
if (!pending) return;
|
|
3038
|
+
return Promise.all(pending).then(() => {
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
function onMount(hook) {
|
|
3042
|
+
const scope = getActiveScope();
|
|
3043
|
+
if (!scope) {
|
|
3044
|
+
error("onMount() must be called within a scope");
|
|
3045
|
+
return;
|
|
3046
|
+
}
|
|
3047
|
+
if (scope.isMounted) {
|
|
3048
|
+
try {
|
|
3049
|
+
const result = hook();
|
|
3050
|
+
if (isPromise(result)) {
|
|
3051
|
+
result.catch((error_) => {
|
|
3052
|
+
if (true) error(`Scope(${scope.id}): Async mount hook rejected:`, error_);
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
} catch (error_) {
|
|
3056
|
+
error(`Scope(${scope.id}): Error in mount hook:`, error_);
|
|
3057
|
+
}
|
|
3058
|
+
return;
|
|
3059
|
+
}
|
|
3060
|
+
registerScopedHook(scope, "onMount", hook);
|
|
3061
|
+
}
|
|
3062
|
+
function onUpdate(hook) {
|
|
3063
|
+
const scope = getActiveScope();
|
|
3064
|
+
if (!scope) {
|
|
3065
|
+
error("onUpdate() must be called within a scope");
|
|
3066
|
+
return;
|
|
3067
|
+
}
|
|
3068
|
+
registerScopedHook(scope, "onUpdate", hook);
|
|
3069
|
+
}
|
|
3070
|
+
function onDestroy(hook) {
|
|
3071
|
+
const scope = getActiveScope();
|
|
3072
|
+
if (!scope) {
|
|
3073
|
+
error("onDestroy() must be called within a scope");
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
3076
|
+
registerScopedHook(scope, "onDestroy", hook);
|
|
3077
|
+
}
|
|
3078
|
+
function triggerMountHooks(scope) {
|
|
3079
|
+
if (scope.isDestroyed) {
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
if (!scope.onMount || scope.onMount.length === 0) {
|
|
3083
|
+
scope.isMounted = true;
|
|
3084
|
+
return;
|
|
3085
|
+
}
|
|
3086
|
+
const mountHooks = scope.onMount;
|
|
3087
|
+
const result = runWithScope(scope, () => executeHooks(mountHooks, scope.id, "mount"));
|
|
3088
|
+
mountHooks.length = 0;
|
|
3089
|
+
scope.isMounted = true;
|
|
3090
|
+
return result;
|
|
3091
|
+
}
|
|
3092
|
+
function triggerUpdateHooks(scope) {
|
|
3093
|
+
if (scope.isDestroyed || !scope.onUpdate || scope.onUpdate.length === 0) return;
|
|
3094
|
+
return runWithScope(scope, () => executeHooks(scope.onUpdate, scope.id, "update"));
|
|
3095
|
+
}
|
|
3096
|
+
function syncDescriptors(target, source, pruneMissing = false) {
|
|
3097
|
+
const seen = pruneMissing ? /* @__PURE__ */ new Set() : null;
|
|
3098
|
+
for (const key of Object.getOwnPropertyNames(source)) {
|
|
3099
|
+
seen == null ? void 0 : seen.add(key);
|
|
3100
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3101
|
+
}
|
|
3102
|
+
if (seen) {
|
|
3103
|
+
for (const key of Object.getOwnPropertyNames(target)) {
|
|
3104
|
+
if (!seen.has(key)) delete target[key];
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
function readProp(source, key) {
|
|
3109
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
3110
|
+
return descriptor.get ? descriptor.get.call(source) : descriptor.value;
|
|
3111
|
+
}
|
|
3112
|
+
var _a5;
|
|
3113
|
+
_a5 = "normal";
|
|
3114
|
+
var Component = class {
|
|
3115
|
+
constructor(component, props = {}) {
|
|
3116
|
+
this.component = component;
|
|
3117
|
+
this.props = props;
|
|
3118
|
+
this[_a5] = true;
|
|
3119
|
+
this.scope = null;
|
|
3120
|
+
this.state = 0;
|
|
3121
|
+
this.beforeNode = void 0;
|
|
3122
|
+
this.renderedNodes = [];
|
|
3123
|
+
this.firstChild = void 0;
|
|
3124
|
+
this.parentNode = void 0;
|
|
3125
|
+
this.rootEventCleanups = [];
|
|
3126
|
+
this.parentScope = getActiveScope();
|
|
3127
|
+
const container = {};
|
|
3128
|
+
syncDescriptors(container, props);
|
|
3129
|
+
this.reactiveProps = shallowReactive(container);
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Mount the component into `parentNode` (optionally before `beforeNode`).
|
|
3133
|
+
* If already rendered, the existing DOM is re-inserted without re-running
|
|
3134
|
+
* the component function.
|
|
3135
|
+
*/
|
|
3136
|
+
mount(parentNode, beforeNode) {
|
|
3137
|
+
var _a22;
|
|
3138
|
+
this.parentNode = parentNode;
|
|
3139
|
+
this.beforeNode = beforeNode;
|
|
3140
|
+
this.state = 1;
|
|
3141
|
+
if (this.renderedNodes.length > 0) {
|
|
3142
|
+
for (const node of this.renderedNodes) {
|
|
3143
|
+
insertNode(parentNode, node, beforeNode);
|
|
3144
|
+
}
|
|
3145
|
+
this.state = 2;
|
|
3146
|
+
return this.renderedNodes;
|
|
3147
|
+
}
|
|
3148
|
+
const scope = createScope((_a22 = this.parentScope) != null ? _a22 : getActiveScope());
|
|
3149
|
+
this.scope = scope;
|
|
3150
|
+
const renderedNodes = runWithScope(scope, () => {
|
|
3151
|
+
var _a32;
|
|
3152
|
+
let result = this.component(this.reactiveProps);
|
|
3153
|
+
if (isFunction(result)) {
|
|
3154
|
+
result = result(this.reactiveProps);
|
|
3155
|
+
}
|
|
3156
|
+
if (isSignal(result) || isComputed(result)) {
|
|
3157
|
+
result = result.value;
|
|
3158
|
+
}
|
|
3159
|
+
return (_a32 = insert(parentNode, result, beforeNode)) != null ? _a32 : [];
|
|
3160
|
+
});
|
|
3161
|
+
this.renderedNodes = renderedNodes;
|
|
3162
|
+
this.firstChild = renderedNodes[0];
|
|
3163
|
+
this.syncSpecialProps(this.props);
|
|
3164
|
+
this.state = 2;
|
|
3165
|
+
triggerMountHooks(scope);
|
|
3166
|
+
return this.renderedNodes;
|
|
3167
|
+
}
|
|
3168
|
+
/**
|
|
3169
|
+
* Re-install props into the same `reactiveProps` container (preserving
|
|
3170
|
+
* any closures already holding a reference to it) and re-apply
|
|
3171
|
+
* refs/events against the current root element.
|
|
3172
|
+
*/
|
|
3173
|
+
update(props) {
|
|
3174
|
+
this.props = props;
|
|
3175
|
+
const scope = this.scope;
|
|
3176
|
+
if (!scope || scope.isDestroyed) return;
|
|
3177
|
+
syncDescriptors(
|
|
3178
|
+
this.reactiveProps,
|
|
3179
|
+
props != null ? props : {},
|
|
3180
|
+
/* pruneMissing */
|
|
3181
|
+
true
|
|
3182
|
+
);
|
|
3183
|
+
this.syncSpecialProps(props);
|
|
3184
|
+
triggerUpdateHooks(scope);
|
|
3185
|
+
}
|
|
3186
|
+
/**
|
|
3187
|
+
* Tear down and re-mount the component at its current insertion point.
|
|
3188
|
+
* No-op if the component has never been mounted.
|
|
3189
|
+
*/
|
|
3190
|
+
forceUpdate() {
|
|
3191
|
+
if (!this.parentNode) return;
|
|
3192
|
+
const parent = this.parentNode;
|
|
3193
|
+
const before = this.beforeNode;
|
|
3194
|
+
this.destroy();
|
|
3195
|
+
this.mount(parent, before);
|
|
3196
|
+
}
|
|
3197
|
+
/**
|
|
3198
|
+
* Dispose the scope, remove all rendered nodes, and clear bookkeeping.
|
|
3199
|
+
* Idempotent: subsequent calls are no-ops.
|
|
3200
|
+
*/
|
|
3201
|
+
destroy() {
|
|
3202
|
+
const scope = this.scope;
|
|
3203
|
+
if (!scope || scope.isDestroyed) return;
|
|
3204
|
+
this.scope = null;
|
|
3205
|
+
this.releaseSpecialProps();
|
|
3206
|
+
disposeScope(scope);
|
|
3207
|
+
for (const node of this.renderedNodes) removeNode(node);
|
|
3208
|
+
this.renderedNodes = [];
|
|
3209
|
+
this.firstChild = void 0;
|
|
3210
|
+
this.parentNode = void 0;
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Apply props that bind to the root DOM element rather than flowing into
|
|
3214
|
+
* the component body: `ref` (signal/function) and `onXxx` event handlers.
|
|
3215
|
+
* The render-facing `reactiveProps` already has those keys; here we just
|
|
3216
|
+
* wire them to the actual DOM node.
|
|
3217
|
+
*/
|
|
3218
|
+
syncSpecialProps(props) {
|
|
3219
|
+
if (!props) return;
|
|
3220
|
+
const root = this.firstChild;
|
|
3221
|
+
if (!root) return;
|
|
3222
|
+
this.releaseSpecialProps();
|
|
3223
|
+
for (const key of Object.getOwnPropertyNames(props)) {
|
|
3224
|
+
const value = readProp(props, key);
|
|
3225
|
+
if (key === REF_KEY) {
|
|
3226
|
+
this.rootRefCleanup = this.bindRootRef(value, root);
|
|
3227
|
+
continue;
|
|
3228
|
+
}
|
|
3229
|
+
if (isOn(key) && isFunction(value)) {
|
|
3230
|
+
const eventName = key.slice(2).toLowerCase();
|
|
3231
|
+
this.rootEventCleanups.push(addEvent(root, eventName, value));
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
/**
|
|
3236
|
+
* Remove all listeners/ref bindings currently attached to the root element.
|
|
3237
|
+
*/
|
|
3238
|
+
releaseSpecialProps() {
|
|
3239
|
+
for (const cleanup of this.rootEventCleanups) {
|
|
3240
|
+
cleanup();
|
|
3241
|
+
}
|
|
3242
|
+
this.rootEventCleanups.length = 0;
|
|
3243
|
+
if (this.rootRefCleanup) {
|
|
3244
|
+
this.rootRefCleanup();
|
|
3245
|
+
this.rootRefCleanup = void 0;
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
/**
|
|
3249
|
+
* Bind the root ref prop and return a cleanup that restores the previous ref state.
|
|
3250
|
+
*/
|
|
3251
|
+
bindRootRef(value, root) {
|
|
3252
|
+
if (isFunction(value)) {
|
|
3253
|
+
value(root);
|
|
3254
|
+
return () => value(null);
|
|
3255
|
+
}
|
|
3256
|
+
if (isSignal(value)) {
|
|
3257
|
+
const previousValue = value.value;
|
|
3258
|
+
value.value = root;
|
|
3259
|
+
return () => {
|
|
3260
|
+
if (value.value === root) {
|
|
3261
|
+
value.value = previousValue;
|
|
3262
|
+
}
|
|
3263
|
+
};
|
|
3264
|
+
}
|
|
3265
|
+
return void 0;
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
function isComponent(node) {
|
|
3269
|
+
return !!node && !!node[
|
|
3270
|
+
"normal"
|
|
3271
|
+
/* NORMAL */
|
|
3272
|
+
];
|
|
3273
|
+
}
|
|
3274
|
+
function createComponent(componentFn, props) {
|
|
3275
|
+
if (isComponent(componentFn)) {
|
|
3276
|
+
return componentFn;
|
|
3277
|
+
}
|
|
3278
|
+
return new Component(componentFn, props);
|
|
3279
|
+
}
|
|
3280
|
+
function template(html) {
|
|
3281
|
+
let node;
|
|
3282
|
+
const create = () => {
|
|
3283
|
+
const template2 = document.createElement("template");
|
|
3284
|
+
template2.innerHTML = html;
|
|
3285
|
+
const firstChild = template2.content.firstChild;
|
|
3286
|
+
if (!firstChild) {
|
|
3287
|
+
throw new Error("Invalid template: empty content");
|
|
3288
|
+
}
|
|
3289
|
+
return firstChild;
|
|
3290
|
+
};
|
|
3291
|
+
return () => (node || (node = create())).cloneNode(true);
|
|
3292
|
+
}
|
|
3293
|
+
function createApp(component, target) {
|
|
3294
|
+
const container = isString(target) ? document.querySelector(target) : target;
|
|
3295
|
+
if (!container) {
|
|
3296
|
+
{
|
|
3297
|
+
warn(`Target element not found: ${target}`);
|
|
3298
|
+
}
|
|
3299
|
+
return;
|
|
3300
|
+
}
|
|
3301
|
+
const existingContent = container.innerHTML;
|
|
3302
|
+
if (existingContent) {
|
|
3303
|
+
{
|
|
3304
|
+
warn(`Target element is not empty, it will be cleared: ${target}`);
|
|
3305
|
+
}
|
|
3306
|
+
container.innerHTML = "";
|
|
3307
|
+
}
|
|
3308
|
+
const scope = createScope();
|
|
3309
|
+
let rootNode;
|
|
3310
|
+
try {
|
|
3311
|
+
runWithScope(scope, () => {
|
|
3312
|
+
const mountedRoot = createComponent(component);
|
|
3313
|
+
if (isComponent(mountedRoot)) {
|
|
3314
|
+
rootNode = mountedRoot;
|
|
3315
|
+
insertNode(container, mountedRoot);
|
|
3316
|
+
}
|
|
3317
|
+
});
|
|
3318
|
+
} catch (error_) {
|
|
3319
|
+
disposeScope(scope);
|
|
3320
|
+
throw error_;
|
|
3321
|
+
}
|
|
3322
|
+
return {
|
|
3323
|
+
root: rootNode,
|
|
3324
|
+
unmount: () => {
|
|
3325
|
+
disposeScope(scope);
|
|
3326
|
+
rootNode == null ? void 0 : rootNode.destroy();
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
function hydrate(component, target) {
|
|
3331
|
+
const container = isString(target) ? document.querySelector(target) : target;
|
|
3332
|
+
if (!container) {
|
|
3333
|
+
{
|
|
3334
|
+
warn(`[essor] hydrate: target element not found: ${target}`);
|
|
3335
|
+
}
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
beginHydration(container);
|
|
3339
|
+
const scope = createScope();
|
|
3340
|
+
let rootNode;
|
|
3341
|
+
try {
|
|
3342
|
+
runWithScope(scope, () => {
|
|
3343
|
+
const mountedRoot = createComponent(component);
|
|
3344
|
+
if (isComponent(mountedRoot)) {
|
|
3345
|
+
rootNode = mountedRoot;
|
|
3346
|
+
insert(container, mountedRoot);
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
} catch (error_) {
|
|
3350
|
+
disposeScope(scope);
|
|
3351
|
+
throw error_;
|
|
3352
|
+
} finally {
|
|
3353
|
+
endHydration();
|
|
3354
|
+
}
|
|
3355
|
+
return {
|
|
3356
|
+
root: rootNode,
|
|
3357
|
+
unmount: () => {
|
|
3358
|
+
disposeScope(scope);
|
|
3359
|
+
rootNode == null ? void 0 : rootNode.destroy();
|
|
3360
|
+
}
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
function provide(key, value) {
|
|
3364
|
+
const scope = getActiveScope();
|
|
3365
|
+
if (!scope) {
|
|
3366
|
+
{
|
|
3367
|
+
error("provide() must be called within a scope");
|
|
3368
|
+
}
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
if (!scope.provides) {
|
|
3372
|
+
scope.provides = /* @__PURE__ */ new Map();
|
|
3373
|
+
}
|
|
3374
|
+
scope.provides.set(key, value);
|
|
3375
|
+
}
|
|
3376
|
+
function inject(key, defaultValue) {
|
|
3377
|
+
const scope = getActiveScope();
|
|
3378
|
+
if (!scope) {
|
|
3379
|
+
{
|
|
3380
|
+
error("inject() must be called within a scope");
|
|
3381
|
+
}
|
|
3382
|
+
return defaultValue;
|
|
3383
|
+
}
|
|
3384
|
+
let current = scope;
|
|
3385
|
+
while (current) {
|
|
3386
|
+
if (current.provides) {
|
|
3387
|
+
if (current.provides.has(key)) {
|
|
3388
|
+
return current.provides.get(key);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
current = current.parent;
|
|
3392
|
+
}
|
|
3393
|
+
return defaultValue;
|
|
3394
|
+
}
|
|
3395
|
+
function reTargetEvent(e, value) {
|
|
3396
|
+
Object.defineProperty(e, "target", {
|
|
3397
|
+
configurable: true,
|
|
3398
|
+
value
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
function eventHandler(e) {
|
|
3402
|
+
let node = e.target;
|
|
3403
|
+
const key = e.type;
|
|
3404
|
+
const oriTarget = e.target;
|
|
3405
|
+
const oriCurrentTarget = e.currentTarget;
|
|
3406
|
+
const handleNode = () => {
|
|
3407
|
+
const handler = node[`_$${key}`];
|
|
3408
|
+
if (handler && isFunction(handler) && !node.disabled) {
|
|
3409
|
+
const data = node[`${key}Data`];
|
|
3410
|
+
data ? handler.call(node, data, e) : handler.call(node, e);
|
|
3411
|
+
if (e.cancelBubble) return false;
|
|
3412
|
+
}
|
|
3413
|
+
if (node.host && !isString(node.host) && !node.host._$host && isFunction(node.contains) && node.contains(e.target)) {
|
|
3414
|
+
reTargetEvent(e, node.host);
|
|
3415
|
+
}
|
|
3416
|
+
return true;
|
|
3417
|
+
};
|
|
3418
|
+
const walkUpTree = () => {
|
|
3419
|
+
while (handleNode() && (node = node._$host || node.parentNode || node.host)) ;
|
|
3420
|
+
};
|
|
3421
|
+
Object.defineProperty(e, "currentTarget", {
|
|
3422
|
+
configurable: true,
|
|
3423
|
+
/**
|
|
3424
|
+
* Returns the current delegated target for the event.
|
|
3425
|
+
*/
|
|
3426
|
+
get() {
|
|
3427
|
+
return node || document;
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3430
|
+
if (e.composedPath) {
|
|
3431
|
+
const path = e.composedPath();
|
|
3432
|
+
reTargetEvent(e, path[0]);
|
|
3433
|
+
for (let i = 0; i < path.length - 2; i++) {
|
|
3434
|
+
node = path[i];
|
|
3435
|
+
if (!handleNode()) break;
|
|
3436
|
+
if (node._$host) {
|
|
3437
|
+
node = node._$host;
|
|
3438
|
+
walkUpTree();
|
|
3439
|
+
break;
|
|
3440
|
+
}
|
|
3441
|
+
if (node.parentNode === oriCurrentTarget) {
|
|
3442
|
+
break;
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
} else walkUpTree();
|
|
3446
|
+
reTargetEvent(e, oriTarget);
|
|
3447
|
+
}
|
|
3448
|
+
var $EVENTS = /* @__PURE__ */ Symbol("_$EVENTS");
|
|
3449
|
+
function delegateEvents(eventNames, document2 = window.document) {
|
|
3450
|
+
const docWithEvents = document2;
|
|
3451
|
+
const eventSet = docWithEvents[$EVENTS] || (docWithEvents[$EVENTS] = /* @__PURE__ */ new Set());
|
|
3452
|
+
for (const name of eventNames) {
|
|
3453
|
+
if (!eventSet.has(name)) {
|
|
3454
|
+
eventSet.add(name);
|
|
3455
|
+
document2.addEventListener(name, eventHandler);
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
function clearDelegatedEvents(document2 = window.document) {
|
|
3460
|
+
const docWithEvents = document2;
|
|
3461
|
+
const eventSet = docWithEvents[$EVENTS];
|
|
3462
|
+
if (eventSet) {
|
|
3463
|
+
for (const name of eventSet.keys()) {
|
|
3464
|
+
document2.removeEventListener(name, eventHandler);
|
|
3465
|
+
}
|
|
3466
|
+
delete docWithEvents[$EVENTS];
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
function addEventListener(element, event, handler, options) {
|
|
3470
|
+
const cleanup = addEvent(element, event, handler, options);
|
|
3471
|
+
if (getActiveScope()) {
|
|
3472
|
+
onCleanup(cleanup);
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
function writeValue(el, v) {
|
|
3476
|
+
const target = el;
|
|
3477
|
+
const next2 = v == null ? "" : String(v);
|
|
3478
|
+
if (target.value !== next2) target.value = next2;
|
|
3479
|
+
}
|
|
3480
|
+
var CHECKBOX = {
|
|
3481
|
+
event: "change",
|
|
3482
|
+
forceChange: true,
|
|
3483
|
+
read: (el) => el.checked,
|
|
3484
|
+
write(el, v) {
|
|
3485
|
+
const e = el;
|
|
3486
|
+
const next2 = Boolean(v);
|
|
3487
|
+
if (e.checked !== next2) e.checked = next2;
|
|
3488
|
+
}
|
|
3489
|
+
};
|
|
3490
|
+
var RADIO = {
|
|
3491
|
+
event: "change",
|
|
3492
|
+
forceChange: true,
|
|
3493
|
+
read(el) {
|
|
3494
|
+
const e = el;
|
|
3495
|
+
return e.checked ? e.value : "";
|
|
3496
|
+
},
|
|
3497
|
+
write(el, v) {
|
|
3498
|
+
const e = el;
|
|
3499
|
+
const next2 = String(v) === e.value;
|
|
3500
|
+
if (e.checked !== next2) e.checked = next2;
|
|
3501
|
+
}
|
|
3502
|
+
};
|
|
3503
|
+
var FILE = {
|
|
3504
|
+
event: "change",
|
|
3505
|
+
forceChange: true,
|
|
3506
|
+
read: (el) => el.files,
|
|
3507
|
+
write() {
|
|
3508
|
+
}
|
|
3509
|
+
// browsers forbid programmatic writes to file inputs
|
|
3510
|
+
};
|
|
3511
|
+
var TEXT = {
|
|
3512
|
+
event: "input",
|
|
3513
|
+
ime: true,
|
|
3514
|
+
read: (el) => el.value,
|
|
3515
|
+
write: writeValue
|
|
3516
|
+
};
|
|
3517
|
+
var TEXTAREA = {
|
|
3518
|
+
event: "input",
|
|
3519
|
+
ime: true,
|
|
3520
|
+
read: (el) => el.value,
|
|
3521
|
+
write: writeValue
|
|
3522
|
+
};
|
|
3523
|
+
var SELECT = {
|
|
3524
|
+
event: "change",
|
|
3525
|
+
forceChange: true,
|
|
3526
|
+
read(el) {
|
|
3527
|
+
const s = el;
|
|
3528
|
+
return s.multiple ? Array.from(s.selectedOptions, (o) => o.value) : s.value;
|
|
3529
|
+
},
|
|
3530
|
+
write(el, v) {
|
|
3531
|
+
const s = el;
|
|
3532
|
+
if (s.multiple) {
|
|
3533
|
+
const selected = new Set((Array.isArray(v) ? v : []).map(String));
|
|
3534
|
+
for (const opt of Array.from(s.options)) opt.selected = selected.has(opt.value);
|
|
3535
|
+
} else {
|
|
3536
|
+
writeValue(el, v);
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
};
|
|
3540
|
+
function resolve(node, prop) {
|
|
3541
|
+
switch (node.nodeName) {
|
|
3542
|
+
case "INPUT":
|
|
3543
|
+
if (prop === "checked") return node.type === "radio" ? RADIO : CHECKBOX;
|
|
3544
|
+
if (prop === "files") return FILE;
|
|
3545
|
+
return TEXT;
|
|
3546
|
+
case "SELECT":
|
|
3547
|
+
return SELECT;
|
|
3548
|
+
case "TEXTAREA":
|
|
3549
|
+
return TEXTAREA;
|
|
3550
|
+
default:
|
|
3551
|
+
return {
|
|
3552
|
+
event: "input",
|
|
3553
|
+
read: (el) => el[prop],
|
|
3554
|
+
write(el, v) {
|
|
3555
|
+
el[prop] = v;
|
|
3556
|
+
}
|
|
3557
|
+
};
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
function applyModifiers(v, trim, toNum) {
|
|
3561
|
+
if (!isString(v)) return v;
|
|
3562
|
+
let s = v;
|
|
3563
|
+
if (trim) s = s.trim();
|
|
3564
|
+
if (toNum && s !== "") {
|
|
3565
|
+
const n = Number(s);
|
|
3566
|
+
if (!Number.isNaN(n)) return n;
|
|
3567
|
+
}
|
|
3568
|
+
return s;
|
|
3569
|
+
}
|
|
3570
|
+
function isFocused(el) {
|
|
3571
|
+
const root = el.getRootNode();
|
|
3572
|
+
return (root instanceof Document || root instanceof ShadowRoot) && root.activeElement === el;
|
|
3573
|
+
}
|
|
3574
|
+
function bindElement(node, prop, getter, setter, modifiers = {}) {
|
|
3575
|
+
if (!node) return;
|
|
3576
|
+
const { event, read, write, forceChange, ime } = resolve(node, prop);
|
|
3577
|
+
const trim = modifiers.trim === true;
|
|
3578
|
+
const toNum = modifiers.number === true;
|
|
3579
|
+
const lazy = modifiers.lazy === true;
|
|
3580
|
+
const shouldCast = (trim || toNum) && prop !== "files";
|
|
3581
|
+
const getModel = isFunction(getter) ? getter : () => getter;
|
|
3582
|
+
const cast = shouldCast ? (v) => applyModifiers(v, trim, toNum) : (v) => v;
|
|
3583
|
+
let composing = false;
|
|
3584
|
+
const eventName = lazy || forceChange ? "change" : event;
|
|
3585
|
+
const syncToModel = () => {
|
|
3586
|
+
if (composing) return;
|
|
3587
|
+
const raw = read(node);
|
|
3588
|
+
if (raw === void 0) return;
|
|
3589
|
+
const next2 = cast(raw);
|
|
3590
|
+
if (!Object.is(getModel(), next2)) setter(next2);
|
|
3591
|
+
};
|
|
3592
|
+
addEventListener(node, eventName, syncToModel);
|
|
3593
|
+
if (!lazy && shouldCast && eventName !== "change") {
|
|
3594
|
+
addEventListener(node, "change", () => write(node, cast(read(node))));
|
|
3595
|
+
}
|
|
3596
|
+
if (ime && !lazy) {
|
|
3597
|
+
addEventListener(node, "compositionstart", () => {
|
|
3598
|
+
composing = true;
|
|
3599
|
+
});
|
|
3600
|
+
addEventListener(node, "compositionend", () => {
|
|
3601
|
+
if (!composing) return;
|
|
3602
|
+
composing = false;
|
|
3603
|
+
syncToModel();
|
|
3604
|
+
});
|
|
3605
|
+
}
|
|
3606
|
+
const runner = effect(() => {
|
|
3607
|
+
const value = getModel();
|
|
3608
|
+
if (ime && !lazy && isFocused(node)) {
|
|
3609
|
+
if (composing) return;
|
|
3610
|
+
if (Object.is(cast(read(node)), value)) return;
|
|
3611
|
+
}
|
|
3612
|
+
write(node, value);
|
|
3613
|
+
});
|
|
3614
|
+
if (getActiveScope()) {
|
|
3615
|
+
onCleanup(() => runner.stop());
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
function omitProps(target, keys) {
|
|
3619
|
+
const excludeSet = new Set(keys);
|
|
3620
|
+
return new Proxy(target, {
|
|
3621
|
+
/**
|
|
3622
|
+
* Returns a property unless it is excluded by the proxy.
|
|
3623
|
+
*/
|
|
3624
|
+
get(obj, prop) {
|
|
3625
|
+
if (excludeSet.has(prop)) {
|
|
3626
|
+
return void 0;
|
|
3627
|
+
}
|
|
3628
|
+
return Reflect.get(obj, prop);
|
|
3629
|
+
},
|
|
3630
|
+
/**
|
|
3631
|
+
* Returns the enumerable keys that are not excluded from the proxy.
|
|
3632
|
+
*/
|
|
3633
|
+
ownKeys(obj) {
|
|
3634
|
+
return Reflect.ownKeys(obj).filter((key) => !excludeSet.has(key));
|
|
3635
|
+
},
|
|
3636
|
+
/**
|
|
3637
|
+
* Returns the property descriptor unless the key is excluded.
|
|
3638
|
+
*/
|
|
3639
|
+
getOwnPropertyDescriptor(obj, prop) {
|
|
3640
|
+
if (excludeSet.has(prop)) {
|
|
3641
|
+
return void 0;
|
|
3642
|
+
}
|
|
3643
|
+
return Reflect.getOwnPropertyDescriptor(obj, prop);
|
|
3644
|
+
},
|
|
3645
|
+
/**
|
|
3646
|
+
* Returns whether the requested value exists.
|
|
3647
|
+
*/
|
|
3648
|
+
has(obj, prop) {
|
|
3649
|
+
if (excludeSet.has(prop)) {
|
|
3650
|
+
return false;
|
|
3651
|
+
}
|
|
3652
|
+
return Reflect.has(obj, prop);
|
|
3653
|
+
}
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
function Fragment(props) {
|
|
3657
|
+
if (!props || props.children == null) return null;
|
|
3658
|
+
return props.children;
|
|
3659
|
+
}
|
|
3660
|
+
Fragment[FRAGMENT_COMPONENT] = true;
|
|
3661
|
+
function isFragment(node) {
|
|
3662
|
+
return !!node && !!node[FRAGMENT_COMPONENT];
|
|
3663
|
+
}
|
|
3664
|
+
function resolveTarget(props) {
|
|
3665
|
+
const raw = isFunction(props.target) ? props.target() : props.target;
|
|
3666
|
+
if (raw == null) return null;
|
|
3667
|
+
if (isString(raw)) return document.querySelector(raw);
|
|
3668
|
+
return raw;
|
|
3669
|
+
}
|
|
3670
|
+
function evalDisabled(props) {
|
|
3671
|
+
return isFunction(props.disabled) ? !!props.disabled() : !!props.disabled;
|
|
3672
|
+
}
|
|
3673
|
+
function Portal(props) {
|
|
3674
|
+
if (isHydrating()) {
|
|
3675
|
+
const adopted = tryHydratePortal(props);
|
|
3676
|
+
if (adopted) return adopted;
|
|
3677
|
+
}
|
|
3678
|
+
const placeholder = document.createComment("portal");
|
|
3679
|
+
placeholder[PORTAL_COMPONENT] = true;
|
|
3680
|
+
const { children } = props;
|
|
3681
|
+
if (children == null) return placeholder;
|
|
3682
|
+
const ownerScope = getActiveScope();
|
|
3683
|
+
let innerScope = null;
|
|
3684
|
+
const mountAt = (parent, before) => {
|
|
3685
|
+
innerScope = createScope(ownerScope);
|
|
3686
|
+
runWithScope(innerScope, () => {
|
|
3687
|
+
insert(parent, () => children, before);
|
|
3688
|
+
});
|
|
3689
|
+
};
|
|
3690
|
+
const teardown = () => {
|
|
3691
|
+
if (innerScope) {
|
|
3692
|
+
disposeScope(innerScope);
|
|
3693
|
+
innerScope = null;
|
|
3694
|
+
}
|
|
3695
|
+
};
|
|
3696
|
+
const apply = (disabled, target) => {
|
|
3697
|
+
teardown();
|
|
3698
|
+
if (disabled) {
|
|
3699
|
+
const parent = placeholder.parentNode;
|
|
3700
|
+
if (!parent) return;
|
|
3701
|
+
mountAt(parent, placeholder);
|
|
3702
|
+
return;
|
|
3703
|
+
}
|
|
3704
|
+
if (!target) {
|
|
3705
|
+
{
|
|
3706
|
+
warn(`[Portal] Target element not found: ${String(props.target)}`);
|
|
3707
|
+
}
|
|
3708
|
+
return;
|
|
3709
|
+
}
|
|
3710
|
+
mountAt(target);
|
|
3711
|
+
};
|
|
3712
|
+
let mounted = false;
|
|
3713
|
+
const effectRunner = effect(() => {
|
|
3714
|
+
const disabled = evalDisabled(props);
|
|
3715
|
+
const target = disabled ? null : resolveTarget(props);
|
|
3716
|
+
if (mounted) {
|
|
3717
|
+
apply(disabled, target);
|
|
3718
|
+
}
|
|
3719
|
+
});
|
|
3720
|
+
onMount(() => {
|
|
3721
|
+
mounted = true;
|
|
3722
|
+
const disabled = evalDisabled(props);
|
|
3723
|
+
const target = disabled ? null : resolveTarget(props);
|
|
3724
|
+
if (disabled || target) {
|
|
3725
|
+
apply(disabled, target);
|
|
3726
|
+
return;
|
|
3727
|
+
}
|
|
3728
|
+
queueMicrotask(() => {
|
|
3729
|
+
if (!placeholder.parentNode) return;
|
|
3730
|
+
apply(evalDisabled(props), resolveTarget(props));
|
|
3731
|
+
});
|
|
3732
|
+
});
|
|
3733
|
+
onCleanup(() => {
|
|
3734
|
+
effectRunner.stop();
|
|
3735
|
+
teardown();
|
|
3736
|
+
});
|
|
3737
|
+
return placeholder;
|
|
3738
|
+
}
|
|
3739
|
+
Portal[PORTAL_COMPONENT] = true;
|
|
3740
|
+
function tryHydratePortal(props) {
|
|
3741
|
+
if (evalDisabled(props)) return null;
|
|
3742
|
+
const anchor = consumeTeleportAnchor();
|
|
3743
|
+
if (!anchor) {
|
|
3744
|
+
{
|
|
3745
|
+
warn("[Portal] hydration mismatch: no <!--teleport-anchor--> at call site.");
|
|
3746
|
+
}
|
|
3747
|
+
return null;
|
|
3748
|
+
}
|
|
3749
|
+
const target = resolveTarget(props);
|
|
3750
|
+
if (!target) {
|
|
3751
|
+
{
|
|
3752
|
+
warn(`[Portal] hydration mismatch: target not found: ${String(props.target)}`);
|
|
3753
|
+
}
|
|
3754
|
+
return null;
|
|
3755
|
+
}
|
|
3756
|
+
const block = consumeTeleportBlock(target);
|
|
3757
|
+
if (!block) {
|
|
3758
|
+
{
|
|
3759
|
+
warn(
|
|
3760
|
+
`[Portal] hydration mismatch: no <!--teleport-start--> in target ${String(props.target)}`
|
|
3761
|
+
);
|
|
3762
|
+
}
|
|
3763
|
+
return null;
|
|
3764
|
+
}
|
|
3765
|
+
anchor[PORTAL_COMPONENT] = true;
|
|
3766
|
+
return anchor;
|
|
3767
|
+
}
|
|
3768
|
+
function isPortal(node) {
|
|
3769
|
+
return !!node && !!node[PORTAL_COMPONENT];
|
|
3770
|
+
}
|
|
3771
|
+
function clearContainer(el) {
|
|
3772
|
+
while (el.firstChild) {
|
|
3773
|
+
el.removeChild(el.firstChild);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
function resolveNodeValue(value) {
|
|
3777
|
+
let current = value;
|
|
3778
|
+
while (isFunction(current)) {
|
|
3779
|
+
current = current();
|
|
3780
|
+
}
|
|
3781
|
+
if (isSignal(current) || isComputed(current)) {
|
|
3782
|
+
return resolveNodeValue(current.value);
|
|
3783
|
+
}
|
|
3784
|
+
return current;
|
|
3785
|
+
}
|
|
3786
|
+
var SuspenseContext = /* @__PURE__ */ Symbol("SuspenseContext");
|
|
3787
|
+
function Suspense(props) {
|
|
3788
|
+
var _a22;
|
|
3789
|
+
if (!isBrowser()) {
|
|
3790
|
+
return (_a22 = props.fallback) != null ? _a22 : "";
|
|
3791
|
+
}
|
|
3792
|
+
const container = document.createElement("div");
|
|
3793
|
+
container.style.display = "contents";
|
|
3794
|
+
let isMounted = true;
|
|
3795
|
+
let pendingCount = 0;
|
|
3796
|
+
let isShowingFallback = false;
|
|
3797
|
+
let resolvedChildren = null;
|
|
3798
|
+
const materializeChild = (value) => {
|
|
3799
|
+
const current = resolveNodeValue(value);
|
|
3800
|
+
if (isArray(current)) {
|
|
3801
|
+
const nodes = [];
|
|
3802
|
+
for (const item of current) {
|
|
3803
|
+
const materialized = materializeChild(item);
|
|
3804
|
+
if (isArray(materialized)) {
|
|
3805
|
+
nodes.push(...materialized);
|
|
3806
|
+
} else {
|
|
3807
|
+
nodes.push(materialized);
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
return nodes;
|
|
3811
|
+
}
|
|
3812
|
+
return normalizeNode(current);
|
|
3813
|
+
};
|
|
3814
|
+
const insertMaterializedChild = (value) => {
|
|
3815
|
+
const normalized = materializeChild(value);
|
|
3816
|
+
const nodes = isArray(normalized) ? normalized : [normalized];
|
|
3817
|
+
for (const node of nodes) {
|
|
3818
|
+
if (node != null) {
|
|
3819
|
+
insertNode(container, node);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
};
|
|
3823
|
+
const renderFallbackContent = () => {
|
|
3824
|
+
clearContainer(container);
|
|
3825
|
+
if (props.fallback != null) {
|
|
3826
|
+
insertMaterializedChild(props.fallback);
|
|
3827
|
+
}
|
|
3828
|
+
};
|
|
3829
|
+
const showFallback = () => {
|
|
3830
|
+
if (isShowingFallback) return;
|
|
3831
|
+
isShowingFallback = true;
|
|
3832
|
+
renderFallbackContent();
|
|
3833
|
+
};
|
|
3834
|
+
const showChildren = () => {
|
|
3835
|
+
if (!isShowingFallback) return;
|
|
3836
|
+
const hasContent = resolvedChildren || props.children != null && !isPromise(props.children);
|
|
3837
|
+
if (!hasContent) {
|
|
3838
|
+
return;
|
|
3839
|
+
}
|
|
3840
|
+
isShowingFallback = false;
|
|
3841
|
+
clearContainer(container);
|
|
3842
|
+
if (resolvedChildren) {
|
|
3843
|
+
renderChildren(resolvedChildren);
|
|
3844
|
+
} else if (props.children != null && !isPromise(props.children)) {
|
|
3845
|
+
renderChildren(props.children);
|
|
3846
|
+
}
|
|
3847
|
+
};
|
|
3848
|
+
const renderChildren = (children2) => {
|
|
3849
|
+
if (isShowingFallback) return;
|
|
3850
|
+
clearContainer(container);
|
|
3851
|
+
if (children2 == null) return;
|
|
3852
|
+
const childArray = isArray(children2) ? children2 : [children2];
|
|
3853
|
+
for (const child2 of childArray) {
|
|
3854
|
+
if (child2 != null) {
|
|
3855
|
+
insertMaterializedChild(child2);
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
if (isShowingFallback) {
|
|
3859
|
+
renderFallbackContent();
|
|
3860
|
+
}
|
|
3861
|
+
};
|
|
3862
|
+
const suspenseContext = {
|
|
3863
|
+
register: (promise) => {
|
|
3864
|
+
pendingCount++;
|
|
3865
|
+
showFallback();
|
|
3866
|
+
promise.then(() => {
|
|
3867
|
+
if (!isMounted) return;
|
|
3868
|
+
pendingCount--;
|
|
3869
|
+
if (pendingCount === 0) {
|
|
3870
|
+
showChildren();
|
|
3871
|
+
}
|
|
3872
|
+
}).catch((error4) => {
|
|
3873
|
+
{
|
|
3874
|
+
warn("[Suspense] Resource failed:", error4);
|
|
3875
|
+
}
|
|
3876
|
+
if (!isMounted) return;
|
|
3877
|
+
pendingCount--;
|
|
3878
|
+
if (pendingCount === 0) {
|
|
3879
|
+
showChildren();
|
|
3880
|
+
}
|
|
3881
|
+
});
|
|
3882
|
+
},
|
|
3883
|
+
increment: () => {
|
|
3884
|
+
pendingCount++;
|
|
3885
|
+
showFallback();
|
|
3886
|
+
},
|
|
3887
|
+
decrement: () => {
|
|
3888
|
+
pendingCount = Math.max(0, pendingCount - 1);
|
|
3889
|
+
if (pendingCount === 0) {
|
|
3890
|
+
showChildren();
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
};
|
|
3894
|
+
provide(SuspenseContext, suspenseContext);
|
|
3895
|
+
const children = props.children;
|
|
3896
|
+
if (isPromise(children)) {
|
|
3897
|
+
children.then((resolved) => {
|
|
3898
|
+
resolvedChildren = resolved;
|
|
3899
|
+
}).catch(() => {
|
|
3900
|
+
});
|
|
3901
|
+
suspenseContext.register(children);
|
|
3902
|
+
} else if (children != null) {
|
|
3903
|
+
renderChildren(children);
|
|
3904
|
+
} else {
|
|
3905
|
+
showFallback();
|
|
3906
|
+
}
|
|
3907
|
+
onDestroy(() => {
|
|
3908
|
+
isMounted = false;
|
|
3909
|
+
pendingCount = 0;
|
|
3910
|
+
resolvedChildren = null;
|
|
3911
|
+
clearContainer(container);
|
|
3912
|
+
container.remove();
|
|
3913
|
+
});
|
|
3914
|
+
return container;
|
|
3915
|
+
}
|
|
3916
|
+
Suspense[SUSPENSE_COMPONENT] = true;
|
|
3917
|
+
function isSuspense(node) {
|
|
3918
|
+
return !!node && !!node[SUSPENSE_COMPONENT];
|
|
3919
|
+
}
|
|
3920
|
+
function createResource(fetcher, options) {
|
|
3921
|
+
const value = signal(options == null ? void 0 : options.initialValue);
|
|
3922
|
+
const loading = signal(true);
|
|
3923
|
+
const error4 = signal(null);
|
|
3924
|
+
const state = signal("pending");
|
|
3925
|
+
let fetchId = 0;
|
|
3926
|
+
let currentPromise = null;
|
|
3927
|
+
let suspenseRegistered = false;
|
|
3928
|
+
const suspenseContext = inject(SuspenseContext, null);
|
|
3929
|
+
const fetch = () => __async(null, null, function* () {
|
|
3930
|
+
const currentFetchId = ++fetchId;
|
|
3931
|
+
loading.value = true;
|
|
3932
|
+
state.value = "pending";
|
|
3933
|
+
error4.value = null;
|
|
3934
|
+
suspenseRegistered = false;
|
|
3935
|
+
if (suspenseContext) {
|
|
3936
|
+
suspenseContext.increment();
|
|
3937
|
+
}
|
|
3938
|
+
try {
|
|
3939
|
+
const promise = fetcher();
|
|
3940
|
+
currentPromise = promise;
|
|
3941
|
+
promise.catch(() => {
|
|
3942
|
+
});
|
|
3943
|
+
const result = yield promise;
|
|
3944
|
+
if (currentFetchId === fetchId) {
|
|
3945
|
+
value.value = result;
|
|
3946
|
+
state.value = "ready";
|
|
3947
|
+
loading.value = false;
|
|
3948
|
+
}
|
|
3949
|
+
} catch (error_) {
|
|
3950
|
+
if (currentFetchId === fetchId) {
|
|
3951
|
+
error4.value = error_ instanceof Error ? error_ : new Error(String(error_));
|
|
3952
|
+
state.value = "errored";
|
|
3953
|
+
loading.value = false;
|
|
3954
|
+
}
|
|
3955
|
+
} finally {
|
|
3956
|
+
if (suspenseContext) {
|
|
3957
|
+
suspenseContext.decrement();
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
});
|
|
3961
|
+
fetch();
|
|
3962
|
+
const resource = (() => {
|
|
3963
|
+
if (!suspenseRegistered && loading.value && currentPromise && suspenseContext) {
|
|
3964
|
+
suspenseRegistered = true;
|
|
3965
|
+
suspenseContext.register(currentPromise);
|
|
3966
|
+
}
|
|
3967
|
+
return value.value;
|
|
3968
|
+
});
|
|
3969
|
+
resource.loading = loading;
|
|
3970
|
+
resource.error = error4;
|
|
3971
|
+
resource.state = state;
|
|
3972
|
+
const actions = {
|
|
3973
|
+
mutate: (newValue) => {
|
|
3974
|
+
value.value = newValue;
|
|
3975
|
+
state.value = "ready";
|
|
3976
|
+
loading.value = false;
|
|
3977
|
+
error4.value = null;
|
|
3978
|
+
},
|
|
3979
|
+
refetch: () => __async(null, null, function* () {
|
|
3980
|
+
yield fetch();
|
|
3981
|
+
})
|
|
3982
|
+
};
|
|
3983
|
+
return [resource, actions];
|
|
3984
|
+
}
|
|
3985
|
+
function resolveModule(mod) {
|
|
3986
|
+
return isFunction(mod) ? mod : mod.default;
|
|
3987
|
+
}
|
|
3988
|
+
function renderInto(el, fn, props) {
|
|
3989
|
+
const comp = new Component(fn, props);
|
|
3990
|
+
comp.mount(el);
|
|
3991
|
+
return comp;
|
|
3992
|
+
}
|
|
3993
|
+
function defineAsyncComponent(loader, options = {}) {
|
|
3994
|
+
const { delay = 200, timeout, ssr = "blocking", onError } = options;
|
|
3995
|
+
if (typeof window === "undefined") {
|
|
3996
|
+
if (ssr === "client-only") {
|
|
3997
|
+
const placeholder = () => "";
|
|
3998
|
+
placeholder.__asyncLoader = loader;
|
|
3999
|
+
placeholder.__asyncResolved = () => null;
|
|
4000
|
+
return placeholder;
|
|
4001
|
+
}
|
|
4002
|
+
let ssrResolved = null;
|
|
4003
|
+
let ssrPromise = null;
|
|
4004
|
+
const ssrLoad = () => {
|
|
4005
|
+
if (ssrPromise) return ssrPromise;
|
|
4006
|
+
ssrPromise = loader().then((mod) => {
|
|
4007
|
+
ssrResolved = resolveModule(mod);
|
|
4008
|
+
}).catch(() => {
|
|
4009
|
+
});
|
|
4010
|
+
return ssrPromise;
|
|
4011
|
+
};
|
|
4012
|
+
ssrLoad();
|
|
4013
|
+
const ssrWrapper = (props) => {
|
|
4014
|
+
if (ssrResolved) {
|
|
4015
|
+
return ssrResolved(props);
|
|
4016
|
+
}
|
|
4017
|
+
return "";
|
|
4018
|
+
};
|
|
4019
|
+
ssrWrapper.__asyncLoader = ssrLoad;
|
|
4020
|
+
ssrWrapper.__asyncResolved = () => ssrResolved;
|
|
4021
|
+
return ssrWrapper;
|
|
4022
|
+
}
|
|
4023
|
+
let cachedComponent = null;
|
|
4024
|
+
let cachedError = null;
|
|
4025
|
+
let cachedStatus = "pending";
|
|
4026
|
+
let loadPromise = null;
|
|
4027
|
+
function load() {
|
|
4028
|
+
if (loadPromise) return loadPromise;
|
|
4029
|
+
loadPromise = loader().then((mod) => {
|
|
4030
|
+
cachedComponent = resolveModule(mod);
|
|
4031
|
+
cachedStatus = "resolved";
|
|
4032
|
+
}).catch((error4) => {
|
|
4033
|
+
cachedError = error4 instanceof Error ? error4 : new Error(String(error4));
|
|
4034
|
+
cachedStatus = "errored";
|
|
4035
|
+
loadPromise = null;
|
|
4036
|
+
});
|
|
4037
|
+
return loadPromise;
|
|
4038
|
+
}
|
|
4039
|
+
load();
|
|
4040
|
+
function AsyncWrapper(props) {
|
|
4041
|
+
var _a22;
|
|
4042
|
+
if (cachedStatus === "resolved" && cachedComponent) {
|
|
4043
|
+
const el = document.createElement("div");
|
|
4044
|
+
el.style.display = "contents";
|
|
4045
|
+
const comp = renderInto(el, cachedComponent, props);
|
|
4046
|
+
onCleanup(() => comp.destroy());
|
|
4047
|
+
return el;
|
|
4048
|
+
}
|
|
4049
|
+
if (cachedStatus === "errored" && cachedError) {
|
|
4050
|
+
const el = document.createElement("div");
|
|
4051
|
+
el.style.display = "contents";
|
|
4052
|
+
if (options.error) {
|
|
4053
|
+
let alive2 = true;
|
|
4054
|
+
let currentComp2 = null;
|
|
4055
|
+
const swap2 = (fn, swapProps) => {
|
|
4056
|
+
if (!alive2) return;
|
|
4057
|
+
currentComp2 == null ? void 0 : currentComp2.destroy();
|
|
4058
|
+
currentComp2 = renderInto(el, fn, swapProps);
|
|
4059
|
+
};
|
|
4060
|
+
const retry = () => {
|
|
4061
|
+
loadPromise = null;
|
|
4062
|
+
cachedStatus = "pending";
|
|
4063
|
+
cachedError = null;
|
|
4064
|
+
if (options.loading) swap2(options.loading);
|
|
4065
|
+
load().then(() => {
|
|
4066
|
+
if (!alive2) return;
|
|
4067
|
+
if (cachedStatus === "resolved" && cachedComponent) {
|
|
4068
|
+
swap2(cachedComponent, props);
|
|
4069
|
+
} else if (cachedStatus === "errored" && cachedError) {
|
|
4070
|
+
if (options.error) swap2(options.error, { error: cachedError, retry });
|
|
4071
|
+
}
|
|
4072
|
+
});
|
|
4073
|
+
};
|
|
4074
|
+
swap2(options.error, { error: cachedError, retry });
|
|
4075
|
+
onDestroy(() => {
|
|
4076
|
+
alive2 = false;
|
|
4077
|
+
currentComp2 == null ? void 0 : currentComp2.destroy();
|
|
4078
|
+
currentComp2 = null;
|
|
4079
|
+
});
|
|
4080
|
+
}
|
|
4081
|
+
return el;
|
|
4082
|
+
}
|
|
4083
|
+
const container = document.createElement("div");
|
|
4084
|
+
container.style.display = "contents";
|
|
4085
|
+
let alive = true;
|
|
4086
|
+
let currentComp = null;
|
|
4087
|
+
let delayTimer = null;
|
|
4088
|
+
let timeoutTimer = null;
|
|
4089
|
+
const swap = (fn, swapProps) => {
|
|
4090
|
+
if (!alive) return;
|
|
4091
|
+
currentComp == null ? void 0 : currentComp.destroy();
|
|
4092
|
+
currentComp = renderInto(container, fn, swapProps);
|
|
4093
|
+
};
|
|
4094
|
+
const retryWith = (retryProps) => () => {
|
|
4095
|
+
loadPromise = null;
|
|
4096
|
+
cachedStatus = "pending";
|
|
4097
|
+
cachedError = null;
|
|
4098
|
+
if (options.loading) swap(options.loading);
|
|
4099
|
+
load().then(() => {
|
|
4100
|
+
if (cachedStatus === "resolved" && cachedComponent) {
|
|
4101
|
+
swap(cachedComponent, retryProps);
|
|
4102
|
+
} else if (cachedStatus === "errored" && cachedError) {
|
|
4103
|
+
if (options.error) {
|
|
4104
|
+
swap(options.error, {
|
|
4105
|
+
error: cachedError,
|
|
4106
|
+
retry: retryWith(retryProps)
|
|
4107
|
+
});
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
});
|
|
4111
|
+
};
|
|
4112
|
+
onDestroy(() => {
|
|
4113
|
+
alive = false;
|
|
4114
|
+
currentComp == null ? void 0 : currentComp.destroy();
|
|
4115
|
+
currentComp = null;
|
|
4116
|
+
if (delayTimer != null) clearTimeout(delayTimer);
|
|
4117
|
+
if (timeoutTimer != null) clearTimeout(timeoutTimer);
|
|
4118
|
+
});
|
|
4119
|
+
const suspenseCtx = (_a22 = inject(SuspenseContext)) != null ? _a22 : null;
|
|
4120
|
+
const showResolved = (compFn) => swap(compFn, props);
|
|
4121
|
+
const showError = (err) => {
|
|
4122
|
+
if (options.error) swap(options.error, { error: err, retry: retryWith(props) });
|
|
4123
|
+
};
|
|
4124
|
+
const showLoading = () => {
|
|
4125
|
+
if (options.loading) swap(options.loading);
|
|
4126
|
+
};
|
|
4127
|
+
const instancePromise = load().then(() => {
|
|
4128
|
+
if (!alive) return;
|
|
4129
|
+
if (cachedStatus === "resolved" && cachedComponent) {
|
|
4130
|
+
showResolved(cachedComponent);
|
|
4131
|
+
} else if (cachedStatus === "errored" && cachedError) {
|
|
4132
|
+
showError(cachedError);
|
|
4133
|
+
if (onError) onError(cachedError, retryWith(props));
|
|
4134
|
+
}
|
|
4135
|
+
if (delayTimer != null) clearTimeout(delayTimer);
|
|
4136
|
+
if (timeoutTimer != null) clearTimeout(timeoutTimer);
|
|
4137
|
+
});
|
|
4138
|
+
if (suspenseCtx) {
|
|
4139
|
+
suspenseCtx.register(instancePromise);
|
|
4140
|
+
}
|
|
4141
|
+
if (delay > 0) {
|
|
4142
|
+
delayTimer = setTimeout(() => {
|
|
4143
|
+
if (alive && cachedStatus === "pending") {
|
|
4144
|
+
showLoading();
|
|
4145
|
+
}
|
|
4146
|
+
}, delay);
|
|
4147
|
+
} else if (options.loading) {
|
|
4148
|
+
showLoading();
|
|
4149
|
+
}
|
|
4150
|
+
if (timeout != null) {
|
|
4151
|
+
timeoutTimer = setTimeout(() => {
|
|
4152
|
+
if (alive && cachedStatus === "pending") {
|
|
4153
|
+
const err = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
|
|
4154
|
+
cachedError = err;
|
|
4155
|
+
cachedStatus = "errored";
|
|
4156
|
+
showError(err);
|
|
4157
|
+
if (onError) onError(err, retryWith(props));
|
|
4158
|
+
}
|
|
4159
|
+
}, timeout);
|
|
4160
|
+
}
|
|
4161
|
+
return container;
|
|
4162
|
+
}
|
|
4163
|
+
AsyncWrapper.__asyncLoader = load;
|
|
4164
|
+
AsyncWrapper.__asyncResolved = () => cachedComponent;
|
|
4165
|
+
return AsyncWrapper;
|
|
4166
|
+
}
|
|
4167
|
+
function For(props) {
|
|
4168
|
+
const fragment = document.createDocumentFragment();
|
|
4169
|
+
const marker = document.createComment("");
|
|
4170
|
+
fragment.appendChild(marker);
|
|
4171
|
+
let entries = [];
|
|
4172
|
+
let fallbackNodes = [];
|
|
4173
|
+
const keyFn = props.key;
|
|
4174
|
+
const renderFn = props.children;
|
|
4175
|
+
const getList = () => {
|
|
4176
|
+
var _a22, _b2;
|
|
4177
|
+
const input = props.each;
|
|
4178
|
+
if (isSignal(input)) return (_a22 = input.value) != null ? _a22 : [];
|
|
4179
|
+
if (isFunction(input)) return (_b2 = input()) != null ? _b2 : [];
|
|
4180
|
+
return input != null ? input : [];
|
|
4181
|
+
};
|
|
4182
|
+
const getKey = (item) => keyFn ? keyFn(item) : item;
|
|
4183
|
+
const normalizeNodes = (value) => {
|
|
4184
|
+
if (Array.isArray(value)) {
|
|
4185
|
+
const nodes = [];
|
|
4186
|
+
for (const item of value) {
|
|
4187
|
+
nodes.push(...normalizeNodes(item));
|
|
4188
|
+
}
|
|
4189
|
+
return nodes;
|
|
4190
|
+
}
|
|
4191
|
+
return [normalizeNode(value)];
|
|
4192
|
+
};
|
|
4193
|
+
const mountValue = (value, parent, before) => {
|
|
4194
|
+
const nodes = normalizeNodes(value);
|
|
4195
|
+
for (const node of nodes) {
|
|
4196
|
+
if (before) {
|
|
4197
|
+
parent.insertBefore(node, before);
|
|
4198
|
+
} else {
|
|
4199
|
+
parent.appendChild(node);
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
return nodes;
|
|
4203
|
+
};
|
|
4204
|
+
const mountFallback = (parent, before) => {
|
|
4205
|
+
if (!props.fallback) return;
|
|
4206
|
+
const nodes = mountValue(props.fallback(), parent, before);
|
|
4207
|
+
fallbackNodes = nodes;
|
|
4208
|
+
};
|
|
4209
|
+
const clearFallback = () => {
|
|
4210
|
+
for (const node of fallbackNodes) {
|
|
4211
|
+
if (node.parentNode) {
|
|
4212
|
+
node.parentNode.removeChild(node);
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
fallbackNodes = [];
|
|
4216
|
+
};
|
|
4217
|
+
const renderItem = (item, index, parent, before) => {
|
|
4218
|
+
const parentScope = getActiveScope();
|
|
4219
|
+
const scope = createScope(parentScope);
|
|
4220
|
+
let mountedNodes = [];
|
|
4221
|
+
runWithScope(scope, () => {
|
|
4222
|
+
mountedNodes = mountValue(renderFn(item, index), parent, before);
|
|
4223
|
+
});
|
|
4224
|
+
return { key: getKey(item), item, nodes: mountedNodes, scope };
|
|
4225
|
+
};
|
|
4226
|
+
const disposeItem = (entry) => {
|
|
4227
|
+
disposeScope(entry.scope);
|
|
4228
|
+
for (const node of entry.nodes) {
|
|
4229
|
+
if (node.parentNode) {
|
|
4230
|
+
node.parentNode.removeChild(node);
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
};
|
|
4234
|
+
const effectRunner = effect(() => {
|
|
4235
|
+
const newItems = getList();
|
|
4236
|
+
const parent = marker.parentNode;
|
|
4237
|
+
if (!parent) {
|
|
4238
|
+
if (newItems.length === 0) {
|
|
4239
|
+
mountFallback(fragment, marker);
|
|
4240
|
+
} else {
|
|
4241
|
+
entries = new Array(newItems.length);
|
|
4242
|
+
let idx = 0;
|
|
4243
|
+
for (const newItem of newItems) {
|
|
4244
|
+
entries[idx] = renderItem(newItem, idx, fragment, marker);
|
|
4245
|
+
idx++;
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
return;
|
|
4249
|
+
}
|
|
4250
|
+
reconcile(parent, newItems);
|
|
4251
|
+
});
|
|
4252
|
+
function reconcile(parent, newItems) {
|
|
4253
|
+
const oldLen = entries.length;
|
|
4254
|
+
const newLen = newItems.length;
|
|
4255
|
+
if (newLen === 0) {
|
|
4256
|
+
for (let i = 0; i < oldLen; i++) {
|
|
4257
|
+
disposeItem(entries[i]);
|
|
4258
|
+
}
|
|
4259
|
+
entries = [];
|
|
4260
|
+
if (props.fallback && fallbackNodes.length === 0) {
|
|
4261
|
+
mountFallback(parent, marker);
|
|
4262
|
+
}
|
|
4263
|
+
return;
|
|
4264
|
+
}
|
|
4265
|
+
if (oldLen === 0 || fallbackNodes.length > 0) {
|
|
4266
|
+
if (fallbackNodes.length > 0) {
|
|
4267
|
+
clearFallback();
|
|
4268
|
+
}
|
|
4269
|
+
entries = new Array(newLen);
|
|
4270
|
+
const batchFragment2 = document.createDocumentFragment();
|
|
4271
|
+
for (let i = 0; i < newLen; i++) {
|
|
4272
|
+
entries[i] = renderItem(newItems[i], i, batchFragment2, null);
|
|
4273
|
+
}
|
|
4274
|
+
parent.insertBefore(batchFragment2, marker);
|
|
4275
|
+
return;
|
|
4276
|
+
}
|
|
4277
|
+
const oldKeyMap = /* @__PURE__ */ new Map();
|
|
4278
|
+
for (let i = 0; i < oldLen; i++) {
|
|
4279
|
+
const entry = entries[i];
|
|
4280
|
+
const list = oldKeyMap.get(entry.key);
|
|
4281
|
+
const pair = [entry, i];
|
|
4282
|
+
if (list) list.push(pair);
|
|
4283
|
+
else oldKeyMap.set(entry.key, [pair]);
|
|
4284
|
+
}
|
|
4285
|
+
const newEntries = new Array(newLen);
|
|
4286
|
+
const toRemove = [];
|
|
4287
|
+
let batchFragment = null;
|
|
4288
|
+
const newIndexToOldIndex = new Int32Array(newLen);
|
|
4289
|
+
let moved = false;
|
|
4290
|
+
let maxOldSeen = 0;
|
|
4291
|
+
const newKeys = new Array(newLen);
|
|
4292
|
+
for (let i = 0; i < newLen; i++) {
|
|
4293
|
+
newKeys[i] = getKey(newItems[i]);
|
|
4294
|
+
}
|
|
4295
|
+
for (let i = 0; i < newLen; i++) {
|
|
4296
|
+
const item = newItems[i];
|
|
4297
|
+
const key = newKeys[i];
|
|
4298
|
+
const oldList = oldKeyMap.get(key);
|
|
4299
|
+
if (oldList && oldList.length > 0) {
|
|
4300
|
+
const [reused, oldIndex] = oldList.shift();
|
|
4301
|
+
if (Object.is(reused.item, item)) {
|
|
4302
|
+
reused.item = item;
|
|
4303
|
+
newEntries[i] = reused;
|
|
4304
|
+
newIndexToOldIndex[i] = oldIndex + 1;
|
|
4305
|
+
if (oldIndex < maxOldSeen) moved = true;
|
|
4306
|
+
else maxOldSeen = oldIndex;
|
|
4307
|
+
} else {
|
|
4308
|
+
if (!batchFragment) batchFragment = document.createDocumentFragment();
|
|
4309
|
+
disposeItem(reused);
|
|
4310
|
+
newEntries[i] = renderItem(item, i, batchFragment, null);
|
|
4311
|
+
}
|
|
4312
|
+
} else {
|
|
4313
|
+
if (!batchFragment) batchFragment = document.createDocumentFragment();
|
|
4314
|
+
newEntries[i] = renderItem(item, i, batchFragment, null);
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
for (const list of oldKeyMap.values()) {
|
|
4318
|
+
for (const [entry] of list) toRemove.push(entry);
|
|
4319
|
+
}
|
|
4320
|
+
for (const entry of toRemove) disposeItem(entry);
|
|
4321
|
+
const lis = moved ? getSequence(newIndexToOldIndex) : [];
|
|
4322
|
+
let lisCursor = lis.length - 1;
|
|
4323
|
+
let nextNode = marker;
|
|
4324
|
+
for (let i = newLen - 1; i >= 0; i--) {
|
|
4325
|
+
const entry = newEntries[i];
|
|
4326
|
+
const nodes = entry.nodes;
|
|
4327
|
+
const isFresh = newIndexToOldIndex[i] === 0;
|
|
4328
|
+
const inLis = !isFresh && moved && lisCursor >= 0 && i === lis[lisCursor];
|
|
4329
|
+
if (inLis) {
|
|
4330
|
+
lisCursor--;
|
|
4331
|
+
for (let j = nodes.length - 1; j >= 0; j--) nextNode = nodes[j];
|
|
4332
|
+
continue;
|
|
4333
|
+
}
|
|
4334
|
+
for (let j = nodes.length - 1; j >= 0; j--) {
|
|
4335
|
+
const node = nodes[j];
|
|
4336
|
+
if (node.nextSibling !== nextNode) {
|
|
4337
|
+
parent.insertBefore(node, nextNode);
|
|
4338
|
+
}
|
|
4339
|
+
nextNode = node;
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4342
|
+
entries = newEntries;
|
|
4343
|
+
}
|
|
4344
|
+
onCleanup(() => {
|
|
4345
|
+
effectRunner.stop();
|
|
4346
|
+
for (const entry of entries) {
|
|
4347
|
+
disposeItem(entry);
|
|
4348
|
+
}
|
|
4349
|
+
entries = [];
|
|
4350
|
+
clearFallback();
|
|
4351
|
+
if (marker.parentNode) {
|
|
4352
|
+
marker.parentNode.removeChild(marker);
|
|
4353
|
+
}
|
|
4354
|
+
});
|
|
4355
|
+
return fragment;
|
|
4356
|
+
}
|
|
4357
|
+
For[FOR_COMPONENT] = true;
|
|
4358
|
+
|
|
4359
|
+
export { Component, For, Fragment, Portal, Suspense, TriggerOpTypes, __version, addEvent, addEventListener, batch, beginHydration, bindElement, child, clearDelegatedEvents, computed, consumeTeleportAnchor, consumeTeleportBlock, createApp, createComponent, createResource, createStore, defineAsyncComponent, delegateEvents, effect, endBatch, endHydration, error, escapeHTML, getBatchDepth, getHydrationKey, getRenderedElement, hydrate, inject, insert, isArray, isBatching, isComponent, isComputed, isEffect, isFragment, isFunction, isHydrating, isNil, isObject, isPortal, isPromise, isReactive, isRef, isShallow, isSignal, isString, isSuspense, memoEffect, next, nextTick, normalizeClass, normalizeClassName, normalizeStyle, nthChild, omitProps, onDestroy, onMount, onUpdate, patchAttr, patchAttrHydrate, patchClass, patchClassHydrate, patchStyle, patchStyleHydrate, provide, queueJob, queuePreFlushCb, reactive, ref, resetHydrationKey, setStyle, shallowReactive, shallowSignal, signal, startBatch, stop, styleToString, template, toRaw, toReactive, trigger, untrack, watch };
|
|
4360
|
+
//# sourceMappingURL=chunk-FIBC7TTZ.esm.js.map
|
|
4361
|
+
//# sourceMappingURL=chunk-FIBC7TTZ.esm.js.map
|