@zeus-js/runtime-dom 0.1.1-beta.0 → 0.1.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime-dom.cjs +376 -1457
- package/dist/runtime-dom.d.ts +13 -8
- package/dist/runtime-dom.esm-browser.js +474 -150
- package/dist/runtime-dom.esm-browser.prod.js +1 -1
- package/dist/runtime-dom.esm-bundler.js +365 -1446
- package/dist/runtime-dom.global.js +474 -150
- package/dist/runtime-dom.global.prod.js +1 -1
- package/dist/runtime-dom.prod.cjs +376 -1394
- package/package.json +2 -2
package/dist/runtime-dom.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* runtime-dom v0.1.1-beta.
|
|
2
|
+
* runtime-dom v0.1.1-beta.10
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -7,1373 +7,51 @@ Object.defineProperties(exports, {
|
|
|
7
7
|
__esModule: { value: true },
|
|
8
8
|
[Symbol.toStringTag]: { value: "Module" }
|
|
9
9
|
});
|
|
10
|
+
let _zeus_js_signal_internal = require("@zeus-js/signal/internal");
|
|
10
11
|
//#region packages/core/runtime-dom/src/template.ts
|
|
11
|
-
function template(html, _isImportNode = false,
|
|
12
|
-
const
|
|
13
|
-
t.innerHTML = html;
|
|
12
|
+
function template(html, _isImportNode = false, isSVG = false, _isMathML = false) {
|
|
13
|
+
const content = isSVG ? createSvgContent(html) : createHtmlContent(html);
|
|
14
14
|
return function clone() {
|
|
15
|
-
return
|
|
15
|
+
return content.cloneNode(true);
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* is in that map.
|
|
23
|
-
* IMPORTANT: all calls of this function must be prefixed with
|
|
24
|
-
* \/\*#\_\_PURE\_\_\*\/
|
|
25
|
-
* So that rollup can tree-shake them if necessary.
|
|
26
|
-
*/
|
|
27
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
28
|
-
function makeMap(str) {
|
|
29
|
-
const map = Object.create(null);
|
|
30
|
-
for (const key of str.split(",")) map[key] = 1;
|
|
31
|
-
return (val) => val in map;
|
|
32
|
-
}
|
|
33
|
-
Object.freeze({});
|
|
34
|
-
Object.freeze([]);
|
|
35
|
-
const extend = Object.assign;
|
|
36
|
-
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
37
|
-
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
38
|
-
const isArray = Array.isArray;
|
|
39
|
-
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
40
|
-
const isString = (val) => typeof val === "string";
|
|
41
|
-
const isSymbol = (val) => typeof val === "symbol";
|
|
42
|
-
const isObject = (val) => val !== null && typeof val === "object";
|
|
43
|
-
const objectToString = Object.prototype.toString;
|
|
44
|
-
const toTypeString = (value) => objectToString.call(value);
|
|
45
|
-
const toRawType = (value) => {
|
|
46
|
-
return toTypeString(value).slice(8, -1);
|
|
47
|
-
};
|
|
48
|
-
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
49
|
-
const cacheStringFunction = (fn) => {
|
|
50
|
-
const cache = Object.create(null);
|
|
51
|
-
return ((str) => {
|
|
52
|
-
return cache[str] || (cache[str] = fn(str));
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
const capitalize = cacheStringFunction((str) => {
|
|
59
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
60
|
-
});
|
|
61
|
-
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region packages/core/signal/src/warning.ts
|
|
64
|
-
function warn(msg, ...args) {
|
|
65
|
-
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
18
|
+
function createHtmlContent(html) {
|
|
19
|
+
const template = document.createElement("template");
|
|
20
|
+
template.innerHTML = html;
|
|
21
|
+
return template.content;
|
|
66
22
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this._active = true;
|
|
74
|
-
this._on = 0;
|
|
75
|
-
this.effects = [];
|
|
76
|
-
this.cleanups = [];
|
|
77
|
-
this._isPaused = false;
|
|
78
|
-
this._warnOnRun = true;
|
|
79
|
-
this.__v_skip = true;
|
|
80
|
-
if (!detached && activeEffectScope) if (activeEffectScope.active) {
|
|
81
|
-
this.parent = activeEffectScope;
|
|
82
|
-
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
83
|
-
} else {
|
|
84
|
-
this._active = false;
|
|
85
|
-
this._warnOnRun = false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
get active() {
|
|
89
|
-
return this._active;
|
|
90
|
-
}
|
|
91
|
-
pause() {
|
|
92
|
-
if (this._active) {
|
|
93
|
-
this._isPaused = true;
|
|
94
|
-
let i, l;
|
|
95
|
-
if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
|
|
96
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Resumes the effect scope, including all child scopes and effects.
|
|
101
|
-
*/
|
|
102
|
-
resume() {
|
|
103
|
-
if (this._active) {
|
|
104
|
-
if (this._isPaused) {
|
|
105
|
-
this._isPaused = false;
|
|
106
|
-
let i, l;
|
|
107
|
-
if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
|
|
108
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
run(fn) {
|
|
113
|
-
if (this._active) {
|
|
114
|
-
const currentEffectScope = activeEffectScope;
|
|
115
|
-
try {
|
|
116
|
-
activeEffectScope = this;
|
|
117
|
-
return fn();
|
|
118
|
-
} finally {
|
|
119
|
-
activeEffectScope = currentEffectScope;
|
|
120
|
-
}
|
|
121
|
-
} else if (this._warnOnRun) warn(`cannot run an inactive effect scope.`);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* This should only be called on non-detached scopes
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
on() {
|
|
128
|
-
if (++this._on === 1) {
|
|
129
|
-
this.prevScope = activeEffectScope;
|
|
130
|
-
activeEffectScope = this;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* This should only be called on non-detached scopes
|
|
135
|
-
* @internal
|
|
136
|
-
*/
|
|
137
|
-
off() {
|
|
138
|
-
if (this._on > 0 && --this._on === 0) {
|
|
139
|
-
if (activeEffectScope === this) activeEffectScope = this.prevScope;
|
|
140
|
-
else {
|
|
141
|
-
let current = activeEffectScope;
|
|
142
|
-
while (current) {
|
|
143
|
-
if (current.prevScope === this) {
|
|
144
|
-
current.prevScope = this.prevScope;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
current = current.prevScope;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
this.prevScope = void 0;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
stop(fromParent) {
|
|
154
|
-
if (this._active) {
|
|
155
|
-
this._active = false;
|
|
156
|
-
let i, l;
|
|
157
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
|
|
158
|
-
this.effects.length = 0;
|
|
159
|
-
for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
|
|
160
|
-
this.cleanups.length = 0;
|
|
161
|
-
if (this.scopes) {
|
|
162
|
-
for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
|
|
163
|
-
this.scopes.length = 0;
|
|
164
|
-
}
|
|
165
|
-
if (!this.detached && this.parent && !fromParent) {
|
|
166
|
-
const last = this.parent.scopes.pop();
|
|
167
|
-
if (last && last !== this) {
|
|
168
|
-
this.parent.scopes[this.index] = last;
|
|
169
|
-
last.index = this.index;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
this.parent = void 0;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
178
|
-
* computed and watchers) created within it so that these effects can be
|
|
179
|
-
* disposed together. For detailed use cases of this API, please consult its
|
|
180
|
-
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
181
|
-
*
|
|
182
|
-
* @param detached - Can be used to create a "detached" effect scope.
|
|
183
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
184
|
-
*/
|
|
185
|
-
function effectScope(detached) {
|
|
186
|
-
return new EffectScope(detached);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Returns the current active effect scope if there is one.
|
|
190
|
-
*
|
|
191
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
192
|
-
*/
|
|
193
|
-
function getCurrentScope() {
|
|
194
|
-
return activeEffectScope;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Registers a dispose callback on the current active effect scope. The
|
|
198
|
-
* callback will be invoked when the associated effect scope is stopped.
|
|
199
|
-
*
|
|
200
|
-
* @param fn - The callback function to attach to the scope's cleanup.
|
|
201
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
202
|
-
*/
|
|
203
|
-
function onScopeDispose(fn, failSilently = false) {
|
|
204
|
-
if (activeEffectScope) activeEffectScope.cleanups.push(fn);
|
|
205
|
-
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
23
|
+
function createSvgContent(html) {
|
|
24
|
+
const wrapper = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
25
|
+
wrapper.innerHTML = html;
|
|
26
|
+
const content = document.createDocumentFragment();
|
|
27
|
+
while (wrapper.firstChild) content.appendChild(wrapper.firstChild);
|
|
28
|
+
return content;
|
|
206
29
|
}
|
|
207
30
|
//#endregion
|
|
208
|
-
//#region packages/core/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
constructor(fn) {
|
|
213
|
-
this.fn = fn;
|
|
214
|
-
this.deps = void 0;
|
|
215
|
-
this.depsTail = void 0;
|
|
216
|
-
this.flags = 5;
|
|
217
|
-
this.next = void 0;
|
|
218
|
-
this.cleanups = void 0;
|
|
219
|
-
this.scheduler = void 0;
|
|
220
|
-
this.scope = activeEffectScope;
|
|
221
|
-
if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
|
|
222
|
-
else this.flags &= -2;
|
|
223
|
-
}
|
|
224
|
-
pause() {
|
|
225
|
-
this.flags |= 64;
|
|
226
|
-
}
|
|
227
|
-
resume() {
|
|
228
|
-
if (this.flags & 64) {
|
|
229
|
-
this.flags &= -65;
|
|
230
|
-
if (pausedQueueEffects.has(this)) {
|
|
231
|
-
pausedQueueEffects.delete(this);
|
|
232
|
-
this.trigger();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* @internal
|
|
238
|
-
*/
|
|
239
|
-
notify() {
|
|
240
|
-
if (this.flags & 2 && !(this.flags & 32)) return;
|
|
241
|
-
if (!(this.flags & 8)) queueSubscriber(this);
|
|
242
|
-
}
|
|
243
|
-
run() {
|
|
244
|
-
if (!(this.flags & 1)) return this.fn();
|
|
245
|
-
this.flags |= 2;
|
|
246
|
-
cleanupEffect(this);
|
|
247
|
-
prepareDeps(this);
|
|
248
|
-
const prevEffect = activeSub;
|
|
249
|
-
const prevShouldTrack = shouldTrack;
|
|
250
|
-
activeSub = this;
|
|
251
|
-
shouldTrack = true;
|
|
252
|
-
try {
|
|
253
|
-
return this.fn();
|
|
254
|
-
} finally {
|
|
255
|
-
if (activeSub !== this) warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
|
|
256
|
-
cleanupDeps(this);
|
|
257
|
-
activeSub = prevEffect;
|
|
258
|
-
shouldTrack = prevShouldTrack;
|
|
259
|
-
this.flags &= -3;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
stop() {
|
|
263
|
-
if (this.flags & 1) {
|
|
264
|
-
for (let link = this.deps; link; link = link.nextDep) removeSub(link);
|
|
265
|
-
this.deps = this.depsTail = void 0;
|
|
266
|
-
cleanupEffect(this);
|
|
267
|
-
this.onStop && this.onStop();
|
|
268
|
-
this.flags &= -2;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
trigger() {
|
|
272
|
-
if (this.flags & 64) pausedQueueEffects.add(this);
|
|
273
|
-
else if (this.scheduler) this.scheduler();
|
|
274
|
-
else this.runIfDirty();
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* @internal
|
|
278
|
-
*/
|
|
279
|
-
runIfDirty() {
|
|
280
|
-
if (isDirty(this)) this.run();
|
|
281
|
-
}
|
|
282
|
-
get dirty() {
|
|
283
|
-
return isDirty(this);
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
/**
|
|
287
|
-
* For debugging
|
|
288
|
-
*/
|
|
289
|
-
let batchDepth = 0;
|
|
290
|
-
let batchedSub;
|
|
291
|
-
let batchedComputed;
|
|
292
|
-
/**
|
|
293
|
-
* @internal
|
|
294
|
-
*/
|
|
295
|
-
function queueSubscriber(sub, isComputed = false) {
|
|
296
|
-
sub.flags |= 8;
|
|
297
|
-
if (isComputed) {
|
|
298
|
-
sub.next = batchedComputed;
|
|
299
|
-
batchedComputed = sub;
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
sub.next = batchedSub;
|
|
303
|
-
batchedSub = sub;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* @internal
|
|
307
|
-
*/
|
|
308
|
-
function startBatch() {
|
|
309
|
-
batchDepth++;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Run batched effects when all batches have ended
|
|
313
|
-
* @internal
|
|
314
|
-
*/
|
|
315
|
-
function endBatch() {
|
|
316
|
-
if (--batchDepth > 0) return;
|
|
317
|
-
if (batchedComputed) {
|
|
318
|
-
let e = batchedComputed;
|
|
319
|
-
batchedComputed = void 0;
|
|
320
|
-
while (e) {
|
|
321
|
-
const next = e.next;
|
|
322
|
-
e.next = void 0;
|
|
323
|
-
e.flags &= -9;
|
|
324
|
-
e = next;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
let error;
|
|
328
|
-
while (batchedSub) {
|
|
329
|
-
let e = batchedSub;
|
|
330
|
-
batchedSub = void 0;
|
|
331
|
-
while (e) {
|
|
332
|
-
const next = e.next;
|
|
333
|
-
e.next = void 0;
|
|
334
|
-
e.flags &= -9;
|
|
335
|
-
if (e.flags & 1) try {
|
|
336
|
-
e.trigger();
|
|
337
|
-
} catch (err) {
|
|
338
|
-
if (!error) error = err;
|
|
339
|
-
}
|
|
340
|
-
e = next;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (error) throw error;
|
|
344
|
-
}
|
|
345
|
-
function prepareDeps(sub) {
|
|
346
|
-
for (let link = sub.deps; link; link = link.nextDep) {
|
|
347
|
-
link.version = -1;
|
|
348
|
-
link.prevActiveLink = link.dep.activeLink;
|
|
349
|
-
link.dep.activeLink = link;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
function cleanupDeps(sub) {
|
|
353
|
-
let head;
|
|
354
|
-
let tail = sub.depsTail;
|
|
355
|
-
let link = tail;
|
|
356
|
-
while (link) {
|
|
357
|
-
const prev = link.prevDep;
|
|
358
|
-
if (link.version === -1) {
|
|
359
|
-
if (link === tail) tail = prev;
|
|
360
|
-
removeSub(link);
|
|
361
|
-
removeDep(link);
|
|
362
|
-
} else head = link;
|
|
363
|
-
link.dep.activeLink = link.prevActiveLink;
|
|
364
|
-
link.prevActiveLink = void 0;
|
|
365
|
-
link = prev;
|
|
366
|
-
}
|
|
367
|
-
sub.deps = head;
|
|
368
|
-
sub.depsTail = tail;
|
|
369
|
-
}
|
|
370
|
-
function isDirty(sub) {
|
|
371
|
-
for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true;
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Returning false indicates the refresh failed
|
|
376
|
-
* @internal
|
|
377
|
-
*/
|
|
378
|
-
function refreshComputed(computed) {
|
|
379
|
-
if (computed.flags & 4 && !(computed.flags & 16)) return;
|
|
380
|
-
computed.flags &= -17;
|
|
381
|
-
if (computed.globalVersion === globalVersion) return;
|
|
382
|
-
computed.globalVersion = globalVersion;
|
|
383
|
-
if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
|
|
384
|
-
computed.flags |= 2;
|
|
385
|
-
const dep = computed.dep;
|
|
386
|
-
const prevSub = activeSub;
|
|
387
|
-
const prevShouldTrack = shouldTrack;
|
|
388
|
-
activeSub = computed;
|
|
389
|
-
shouldTrack = true;
|
|
31
|
+
//#region packages/core/runtime-dom/src/domMove.ts
|
|
32
|
+
const activeMoveRoots = /* @__PURE__ */ new Set();
|
|
33
|
+
function moveNodeBefore(parent, node, marker) {
|
|
34
|
+
activeMoveRoots.add(node);
|
|
390
35
|
try {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
computed.flags |= 128;
|
|
395
|
-
computed._value = value;
|
|
396
|
-
dep.version++;
|
|
397
|
-
}
|
|
398
|
-
} catch (err) {
|
|
399
|
-
dep.version++;
|
|
400
|
-
throw err;
|
|
36
|
+
const moveBefore = parent.moveBefore;
|
|
37
|
+
if (typeof moveBefore === "function") moveBefore.call(parent, node, marker);
|
|
38
|
+
else parent.insertBefore(node, marker);
|
|
401
39
|
} finally {
|
|
402
|
-
|
|
403
|
-
shouldTrack = prevShouldTrack;
|
|
404
|
-
cleanupDeps(computed);
|
|
405
|
-
computed.flags &= -3;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
function removeSub(link, soft = false) {
|
|
409
|
-
const { dep, prevSub, nextSub } = link;
|
|
410
|
-
if (prevSub) {
|
|
411
|
-
prevSub.nextSub = nextSub;
|
|
412
|
-
link.prevSub = void 0;
|
|
413
|
-
}
|
|
414
|
-
if (nextSub) {
|
|
415
|
-
nextSub.prevSub = prevSub;
|
|
416
|
-
link.nextSub = void 0;
|
|
417
|
-
}
|
|
418
|
-
if (dep.subsHead === link) dep.subsHead = nextSub;
|
|
419
|
-
if (dep.subs === link) {
|
|
420
|
-
dep.subs = prevSub;
|
|
421
|
-
if (!prevSub && dep.computed) {
|
|
422
|
-
dep.computed.flags &= -5;
|
|
423
|
-
for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
|
|
427
|
-
}
|
|
428
|
-
function removeDep(link) {
|
|
429
|
-
const { prevDep, nextDep } = link;
|
|
430
|
-
if (prevDep) {
|
|
431
|
-
prevDep.nextDep = nextDep;
|
|
432
|
-
link.prevDep = void 0;
|
|
433
|
-
}
|
|
434
|
-
if (nextDep) {
|
|
435
|
-
nextDep.prevDep = prevDep;
|
|
436
|
-
link.nextDep = void 0;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
function effect(fn, options) {
|
|
440
|
-
if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
|
|
441
|
-
const e = new ReactiveEffect(fn);
|
|
442
|
-
if (options) extend(e, options);
|
|
443
|
-
try {
|
|
444
|
-
e.run();
|
|
445
|
-
} catch (err) {
|
|
446
|
-
e.stop();
|
|
447
|
-
throw err;
|
|
448
|
-
}
|
|
449
|
-
const runner = e.run.bind(e);
|
|
450
|
-
runner.effect = e;
|
|
451
|
-
return runner;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Stops the effect associated with the given runner.
|
|
455
|
-
*
|
|
456
|
-
* @param runner - Association with the effect to stop tracking.
|
|
457
|
-
*/
|
|
458
|
-
function stop(runner) {
|
|
459
|
-
runner.effect.stop();
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* @internal
|
|
463
|
-
*/
|
|
464
|
-
let shouldTrack = true;
|
|
465
|
-
const trackStack = [];
|
|
466
|
-
/**
|
|
467
|
-
* Temporarily pauses tracking.
|
|
468
|
-
*/
|
|
469
|
-
function pauseTracking() {
|
|
470
|
-
trackStack.push(shouldTrack);
|
|
471
|
-
shouldTrack = false;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Resets the previous global effect tracking state.
|
|
475
|
-
*/
|
|
476
|
-
function resetTracking() {
|
|
477
|
-
const last = trackStack.pop();
|
|
478
|
-
shouldTrack = last === void 0 ? true : last;
|
|
479
|
-
}
|
|
480
|
-
function cleanupEffect(e) {
|
|
481
|
-
const cleanups = e.cleanups;
|
|
482
|
-
e.cleanups = void 0;
|
|
483
|
-
if (cleanups) {
|
|
484
|
-
const prevSub = activeSub;
|
|
485
|
-
activeSub = void 0;
|
|
486
|
-
try {
|
|
487
|
-
let error;
|
|
488
|
-
for (const cleanup of cleanups) try {
|
|
489
|
-
cleanup();
|
|
490
|
-
} catch (cleanupError) {
|
|
491
|
-
var _error;
|
|
492
|
-
(_error = error) !== null && _error !== void 0 || (error = cleanupError);
|
|
493
|
-
}
|
|
494
|
-
if (error) throw error;
|
|
495
|
-
} finally {
|
|
496
|
-
activeSub = prevSub;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
//#endregion
|
|
501
|
-
//#region packages/core/signal/src/dep.ts
|
|
502
|
-
/**
|
|
503
|
-
* Incremented every time a reactive change happens
|
|
504
|
-
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
505
|
-
* has changed.
|
|
506
|
-
*/
|
|
507
|
-
let globalVersion = 0;
|
|
508
|
-
/**
|
|
509
|
-
* Represents a link between a source (Dep) and a subscriber (Effect or Computed).
|
|
510
|
-
* Deps and subs have a many-to-many relationship - each link between a
|
|
511
|
-
* dep and a sub is represented by a Link instance.
|
|
512
|
-
*
|
|
513
|
-
* A Link is also a node in two doubly-linked lists - one for the associated
|
|
514
|
-
* sub to track all its deps, and one for the associated dep to track all its
|
|
515
|
-
* subs.
|
|
516
|
-
*
|
|
517
|
-
* @internal
|
|
518
|
-
*/
|
|
519
|
-
var Link = class {
|
|
520
|
-
constructor(sub, dep) {
|
|
521
|
-
this.sub = sub;
|
|
522
|
-
this.dep = dep;
|
|
523
|
-
this.version = dep.version;
|
|
524
|
-
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
/**
|
|
528
|
-
* @internal
|
|
529
|
-
*/
|
|
530
|
-
var Dep = class {
|
|
531
|
-
constructor(computed) {
|
|
532
|
-
this.computed = computed;
|
|
533
|
-
this.version = 0;
|
|
534
|
-
this.activeLink = void 0;
|
|
535
|
-
this.subs = void 0;
|
|
536
|
-
this.map = void 0;
|
|
537
|
-
this.key = void 0;
|
|
538
|
-
this.sc = 0;
|
|
539
|
-
this.__v_skip = true;
|
|
540
|
-
this.subsHead = void 0;
|
|
541
|
-
}
|
|
542
|
-
track(debugInfo) {
|
|
543
|
-
if (!activeSub || !shouldTrack || activeSub === this.computed) return;
|
|
544
|
-
let link = this.activeLink;
|
|
545
|
-
if (link === void 0 || link.sub !== activeSub) {
|
|
546
|
-
link = this.activeLink = new Link(activeSub, this);
|
|
547
|
-
if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
|
|
548
|
-
else {
|
|
549
|
-
link.prevDep = activeSub.depsTail;
|
|
550
|
-
activeSub.depsTail.nextDep = link;
|
|
551
|
-
activeSub.depsTail = link;
|
|
552
|
-
}
|
|
553
|
-
addSub(link);
|
|
554
|
-
} else if (link.version === -1) {
|
|
555
|
-
link.version = this.version;
|
|
556
|
-
if (link.nextDep) {
|
|
557
|
-
const next = link.nextDep;
|
|
558
|
-
next.prevDep = link.prevDep;
|
|
559
|
-
if (link.prevDep) link.prevDep.nextDep = next;
|
|
560
|
-
link.prevDep = activeSub.depsTail;
|
|
561
|
-
link.nextDep = void 0;
|
|
562
|
-
activeSub.depsTail.nextDep = link;
|
|
563
|
-
activeSub.depsTail = link;
|
|
564
|
-
if (activeSub.deps === link) activeSub.deps = next;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
if (activeSub.onTrack) activeSub.onTrack(extend({ effect: activeSub }, debugInfo));
|
|
568
|
-
return link;
|
|
569
|
-
}
|
|
570
|
-
trigger(debugInfo) {
|
|
571
|
-
this.version++;
|
|
572
|
-
globalVersion++;
|
|
573
|
-
this.notify(debugInfo);
|
|
574
|
-
}
|
|
575
|
-
notify(debugInfo) {
|
|
576
|
-
startBatch();
|
|
577
|
-
try {
|
|
578
|
-
for (let head = this.subsHead; head; head = head.nextSub) if (head.sub.onTrigger && !(head.sub.flags & 8)) head.sub.onTrigger(extend({ effect: head.sub }, debugInfo));
|
|
579
|
-
for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
|
|
580
|
-
} finally {
|
|
581
|
-
endBatch();
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
function addSub(link) {
|
|
586
|
-
link.dep.sc++;
|
|
587
|
-
if (link.sub.flags & 4) {
|
|
588
|
-
const computed = link.dep.computed;
|
|
589
|
-
if (computed && !link.dep.subs) {
|
|
590
|
-
computed.flags |= 20;
|
|
591
|
-
for (let l = computed.deps; l; l = l.nextDep) addSub(l);
|
|
592
|
-
}
|
|
593
|
-
const currentTail = link.dep.subs;
|
|
594
|
-
if (currentTail !== link) {
|
|
595
|
-
link.prevSub = currentTail;
|
|
596
|
-
if (currentTail) currentTail.nextSub = link;
|
|
597
|
-
}
|
|
598
|
-
if (link.dep.subsHead === void 0) link.dep.subsHead = link;
|
|
599
|
-
link.dep.subs = link;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
603
|
-
const ITERATE_KEY = Symbol("Object iterate");
|
|
604
|
-
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
|
|
605
|
-
const ARRAY_ITERATE_KEY = Symbol("Array iterate");
|
|
606
|
-
/**
|
|
607
|
-
* Tracks access to a reactive property.
|
|
608
|
-
*
|
|
609
|
-
* This will check which effect is running at the moment and record it as dep
|
|
610
|
-
* which records all effects that depend on the reactive property.
|
|
611
|
-
*
|
|
612
|
-
* @param target - Object holding the reactive property.
|
|
613
|
-
* @param type - Defines the type of access to the reactive property.
|
|
614
|
-
* @param key - Identifier of the reactive property to track.
|
|
615
|
-
*/
|
|
616
|
-
function track(target, type, key) {
|
|
617
|
-
if (shouldTrack && activeSub) {
|
|
618
|
-
let depsMap = targetMap.get(target);
|
|
619
|
-
if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
620
|
-
let dep = depsMap.get(key);
|
|
621
|
-
if (!dep) {
|
|
622
|
-
depsMap.set(key, dep = new Dep());
|
|
623
|
-
dep.map = depsMap;
|
|
624
|
-
dep.key = key;
|
|
625
|
-
}
|
|
626
|
-
dep.track({
|
|
627
|
-
target,
|
|
628
|
-
type,
|
|
629
|
-
key
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Finds all deps associated with the target (or a specific property) and
|
|
635
|
-
* triggers the effects stored within.
|
|
636
|
-
*
|
|
637
|
-
* @param target - The reactive object.
|
|
638
|
-
* @param type - Defines the type of the operation that needs to trigger effects.
|
|
639
|
-
* @param key - Can be used to target a specific reactive property in the target object.
|
|
640
|
-
*/
|
|
641
|
-
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
642
|
-
const depsMap = targetMap.get(target);
|
|
643
|
-
if (!depsMap) {
|
|
644
|
-
globalVersion++;
|
|
645
|
-
return;
|
|
40
|
+
activeMoveRoots.delete(node);
|
|
646
41
|
}
|
|
647
|
-
const run = (dep) => {
|
|
648
|
-
if (dep) dep.trigger({
|
|
649
|
-
target,
|
|
650
|
-
type,
|
|
651
|
-
key,
|
|
652
|
-
newValue,
|
|
653
|
-
oldValue,
|
|
654
|
-
oldTarget
|
|
655
|
-
});
|
|
656
|
-
};
|
|
657
|
-
startBatch();
|
|
658
|
-
if (type === "clear") depsMap.forEach(run);
|
|
659
|
-
else {
|
|
660
|
-
const targetIsArray = isArray(target);
|
|
661
|
-
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
662
|
-
if (targetIsArray && key === "length") {
|
|
663
|
-
const newLength = Number(newValue);
|
|
664
|
-
depsMap.forEach((dep, key) => {
|
|
665
|
-
if (key === "length" || key === ARRAY_ITERATE_KEY || !isSymbol(key) && key >= newLength) run(dep);
|
|
666
|
-
});
|
|
667
|
-
} else {
|
|
668
|
-
if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
|
|
669
|
-
if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
670
|
-
switch (type) {
|
|
671
|
-
case "add":
|
|
672
|
-
if (!targetIsArray) {
|
|
673
|
-
run(depsMap.get(ITERATE_KEY));
|
|
674
|
-
if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
675
|
-
} else if (isArrayIndex) run(depsMap.get("length"));
|
|
676
|
-
break;
|
|
677
|
-
case "delete":
|
|
678
|
-
if (!targetIsArray) {
|
|
679
|
-
run(depsMap.get(ITERATE_KEY));
|
|
680
|
-
if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
681
|
-
}
|
|
682
|
-
break;
|
|
683
|
-
case "set":
|
|
684
|
-
if (isMap(target)) run(depsMap.get(ITERATE_KEY));
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
endBatch();
|
|
690
42
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
function reactiveReadArray(array) {
|
|
699
|
-
const raw = /* @__PURE__ */ toRaw(array);
|
|
700
|
-
if (raw === array) return raw;
|
|
701
|
-
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
702
|
-
return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Track array iteration and return raw array
|
|
706
|
-
*/
|
|
707
|
-
function shallowReadArray(arr) {
|
|
708
|
-
track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
709
|
-
return arr;
|
|
710
|
-
}
|
|
711
|
-
function toWrapped(target, item) {
|
|
712
|
-
if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
|
|
713
|
-
return toReactive(item);
|
|
714
|
-
}
|
|
715
|
-
const arrayInstrumentations = {
|
|
716
|
-
__proto__: null,
|
|
717
|
-
[Symbol.iterator]() {
|
|
718
|
-
return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
|
|
719
|
-
},
|
|
720
|
-
concat(...args) {
|
|
721
|
-
return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
|
|
722
|
-
},
|
|
723
|
-
entries() {
|
|
724
|
-
return iterator(this, "entries", (value) => {
|
|
725
|
-
value[1] = toWrapped(this, value[1]);
|
|
726
|
-
return value;
|
|
727
|
-
});
|
|
728
|
-
},
|
|
729
|
-
every(fn, thisArg) {
|
|
730
|
-
return apply(this, "every", fn, thisArg, void 0, arguments);
|
|
731
|
-
},
|
|
732
|
-
filter(fn, thisArg) {
|
|
733
|
-
return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
|
|
734
|
-
},
|
|
735
|
-
find(fn, thisArg) {
|
|
736
|
-
return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
737
|
-
},
|
|
738
|
-
findIndex(fn, thisArg) {
|
|
739
|
-
return apply(this, "findIndex", fn, thisArg, void 0, arguments);
|
|
740
|
-
},
|
|
741
|
-
findLast(fn, thisArg) {
|
|
742
|
-
return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
743
|
-
},
|
|
744
|
-
findLastIndex(fn, thisArg) {
|
|
745
|
-
return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
|
746
|
-
},
|
|
747
|
-
forEach(fn, thisArg) {
|
|
748
|
-
return apply(this, "forEach", fn, thisArg, void 0, arguments);
|
|
749
|
-
},
|
|
750
|
-
includes(...args) {
|
|
751
|
-
return searchProxy(this, "includes", args);
|
|
752
|
-
},
|
|
753
|
-
indexOf(...args) {
|
|
754
|
-
return searchProxy(this, "indexOf", args);
|
|
755
|
-
},
|
|
756
|
-
join(separator) {
|
|
757
|
-
return reactiveReadArray(this).join(separator);
|
|
758
|
-
},
|
|
759
|
-
lastIndexOf(...args) {
|
|
760
|
-
return searchProxy(this, "lastIndexOf", args);
|
|
761
|
-
},
|
|
762
|
-
map(fn, thisArg) {
|
|
763
|
-
return apply(this, "map", fn, thisArg, void 0, arguments);
|
|
764
|
-
},
|
|
765
|
-
pop() {
|
|
766
|
-
return noTracking(this, "pop");
|
|
767
|
-
},
|
|
768
|
-
push(...args) {
|
|
769
|
-
return noTracking(this, "push", args);
|
|
770
|
-
},
|
|
771
|
-
reduce(fn, ...args) {
|
|
772
|
-
return reduce(this, "reduce", fn, args);
|
|
773
|
-
},
|
|
774
|
-
reduceRight(fn, ...args) {
|
|
775
|
-
return reduce(this, "reduceRight", fn, args);
|
|
776
|
-
},
|
|
777
|
-
shift() {
|
|
778
|
-
return noTracking(this, "shift");
|
|
779
|
-
},
|
|
780
|
-
some(fn, thisArg) {
|
|
781
|
-
return apply(this, "some", fn, thisArg, void 0, arguments);
|
|
782
|
-
},
|
|
783
|
-
splice(...args) {
|
|
784
|
-
return noTracking(this, "splice", args);
|
|
785
|
-
},
|
|
786
|
-
toReversed() {
|
|
787
|
-
return reactiveReadArray(this).toReversed();
|
|
788
|
-
},
|
|
789
|
-
toSorted(comparer) {
|
|
790
|
-
return reactiveReadArray(this).toSorted(comparer);
|
|
791
|
-
},
|
|
792
|
-
toSpliced(...args) {
|
|
793
|
-
return reactiveReadArray(this).toSpliced(...args);
|
|
794
|
-
},
|
|
795
|
-
unshift(...args) {
|
|
796
|
-
return noTracking(this, "unshift", args);
|
|
797
|
-
},
|
|
798
|
-
values() {
|
|
799
|
-
return iterator(this, "values", (item) => toWrapped(this, item));
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
function iterator(self, method, wrapValue) {
|
|
803
|
-
const arr = shallowReadArray(self);
|
|
804
|
-
const iter = arr[method]();
|
|
805
|
-
if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
|
|
806
|
-
iter._next = iter.next;
|
|
807
|
-
iter.next = () => {
|
|
808
|
-
const result = iter._next();
|
|
809
|
-
if (!result.done) result.value = wrapValue(result.value);
|
|
810
|
-
return result;
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
return iter;
|
|
814
|
-
}
|
|
815
|
-
const arrayProto = Array.prototype;
|
|
816
|
-
function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
817
|
-
const arr = shallowReadArray(self);
|
|
818
|
-
const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
|
|
819
|
-
const methodFn = arr[method];
|
|
820
|
-
if (methodFn !== arrayProto[method]) {
|
|
821
|
-
const result = methodFn.apply(self, args);
|
|
822
|
-
return needsWrap ? toReactive(result) : result;
|
|
823
|
-
}
|
|
824
|
-
let wrappedFn = fn;
|
|
825
|
-
if (arr !== self) {
|
|
826
|
-
if (needsWrap) wrappedFn = function(item, index) {
|
|
827
|
-
return fn.call(this, toWrapped(self, item), index, self);
|
|
828
|
-
};
|
|
829
|
-
else if (fn.length > 2) wrappedFn = function(item, index) {
|
|
830
|
-
return fn.call(this, item, index, self);
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
834
|
-
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
835
|
-
}
|
|
836
|
-
function reduce(self, method, fn, args) {
|
|
837
|
-
const arr = shallowReadArray(self);
|
|
838
|
-
const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
|
|
839
|
-
let wrappedFn = fn;
|
|
840
|
-
let wrapInitialAccumulator = false;
|
|
841
|
-
if (arr !== self) {
|
|
842
|
-
if (needsWrap) {
|
|
843
|
-
wrapInitialAccumulator = args.length === 0;
|
|
844
|
-
wrappedFn = function(acc, item, index) {
|
|
845
|
-
if (wrapInitialAccumulator) {
|
|
846
|
-
wrapInitialAccumulator = false;
|
|
847
|
-
acc = toWrapped(self, acc);
|
|
848
|
-
}
|
|
849
|
-
return fn.call(this, acc, toWrapped(self, item), index, self);
|
|
850
|
-
};
|
|
851
|
-
} else if (fn.length > 3) wrappedFn = function(acc, item, index) {
|
|
852
|
-
return fn.call(this, acc, item, index, self);
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
const result = arr[method](wrappedFn, ...args);
|
|
856
|
-
return wrapInitialAccumulator ? toWrapped(self, result) : result;
|
|
857
|
-
}
|
|
858
|
-
function searchProxy(self, method, args) {
|
|
859
|
-
const arr = /* @__PURE__ */ toRaw(self);
|
|
860
|
-
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
861
|
-
const res = arr[method](...args);
|
|
862
|
-
if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
|
|
863
|
-
args[0] = /* @__PURE__ */ toRaw(args[0]);
|
|
864
|
-
return arr[method](...args);
|
|
865
|
-
}
|
|
866
|
-
return res;
|
|
867
|
-
}
|
|
868
|
-
function noTracking(self, method, args = []) {
|
|
869
|
-
pauseTracking();
|
|
870
|
-
startBatch();
|
|
871
|
-
const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
|
|
872
|
-
endBatch();
|
|
873
|
-
resetTracking();
|
|
874
|
-
return res;
|
|
875
|
-
}
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region packages/core/signal/src/ref.ts
|
|
878
|
-
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
879
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
880
|
-
function isRef(r) {
|
|
881
|
-
return r ? r["__v_isRef"] === true : false;
|
|
882
|
-
}
|
|
883
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
884
|
-
function ref(value) {
|
|
885
|
-
return createRef(value, false);
|
|
886
|
-
}
|
|
887
|
-
function createRef(rawValue, shallow) {
|
|
888
|
-
if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
|
|
889
|
-
return new RefImpl(rawValue, shallow);
|
|
890
|
-
}
|
|
891
|
-
_ReactiveFlags$IS_REF = "__v_isRef";
|
|
892
|
-
_ReactiveFlags$IS_SHA = "__v_isShallow";
|
|
893
|
-
/**
|
|
894
|
-
* @internal
|
|
895
|
-
*/
|
|
896
|
-
var RefImpl = class {
|
|
897
|
-
constructor(value, isShallow) {
|
|
898
|
-
this.dep = new Dep();
|
|
899
|
-
this[_ReactiveFlags$IS_REF] = true;
|
|
900
|
-
this[_ReactiveFlags$IS_SHA] = false;
|
|
901
|
-
this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
|
|
902
|
-
this._value = isShallow ? value : toReactive(value);
|
|
903
|
-
this["__v_isShallow"] = isShallow;
|
|
904
|
-
}
|
|
905
|
-
get value() {
|
|
906
|
-
this.dep.track({
|
|
907
|
-
target: this,
|
|
908
|
-
type: "get",
|
|
909
|
-
key: "value"
|
|
910
|
-
});
|
|
911
|
-
return this._value;
|
|
912
|
-
}
|
|
913
|
-
set value(newValue) {
|
|
914
|
-
const oldValue = this._rawValue;
|
|
915
|
-
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
916
|
-
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
917
|
-
if (hasChanged(newValue, oldValue)) {
|
|
918
|
-
this._rawValue = newValue;
|
|
919
|
-
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
920
|
-
this.dep.trigger({
|
|
921
|
-
target: this,
|
|
922
|
-
type: "set",
|
|
923
|
-
key: "value",
|
|
924
|
-
newValue,
|
|
925
|
-
oldValue
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
//#endregion
|
|
931
|
-
//#region packages/core/signal/src/baseHandlers.ts
|
|
932
|
-
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
933
|
-
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
934
|
-
function hasOwnProperty(key) {
|
|
935
|
-
if (!isSymbol(key)) key = String(key);
|
|
936
|
-
const obj = /* @__PURE__ */ toRaw(this);
|
|
937
|
-
track(obj, "has", key);
|
|
938
|
-
return obj.hasOwnProperty(key);
|
|
939
|
-
}
|
|
940
|
-
var BaseReactiveHandler = class {
|
|
941
|
-
constructor(_isReadonly = false, _isShallow = false) {
|
|
942
|
-
this._isReadonly = _isReadonly;
|
|
943
|
-
this._isShallow = _isShallow;
|
|
944
|
-
}
|
|
945
|
-
get(target, key, receiver) {
|
|
946
|
-
if (key === "__v_skip") return target["__v_skip"];
|
|
947
|
-
const isReadonly = this._isReadonly, isShallow = this._isShallow;
|
|
948
|
-
if (key === "__v_isReactive") return !isReadonly;
|
|
949
|
-
else if (key === "__v_isReadonly") return isReadonly;
|
|
950
|
-
else if (key === "__v_isShallow") return isShallow;
|
|
951
|
-
else if (key === "__v_raw") {
|
|
952
|
-
if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
const targetIsArray = isArray(target);
|
|
956
|
-
if (!isReadonly) {
|
|
957
|
-
let fn;
|
|
958
|
-
if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
|
|
959
|
-
if (key === "hasOwnProperty") return hasOwnProperty;
|
|
960
|
-
}
|
|
961
|
-
const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
962
|
-
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
|
|
963
|
-
if (!isReadonly) track(target, "get", key);
|
|
964
|
-
if (isShallow) return res;
|
|
965
|
-
if (/* @__PURE__ */ isRef(res)) {
|
|
966
|
-
const value = targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
967
|
-
return isReadonly && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
968
|
-
}
|
|
969
|
-
if (isObject(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
|
|
970
|
-
return res;
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
974
|
-
constructor(isShallow = false) {
|
|
975
|
-
super(false, isShallow);
|
|
976
|
-
}
|
|
977
|
-
set(target, key, value, receiver) {
|
|
978
|
-
let oldValue = target[key];
|
|
979
|
-
const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
|
|
980
|
-
if (!this._isShallow) {
|
|
981
|
-
const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
|
|
982
|
-
if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
|
|
983
|
-
oldValue = /* @__PURE__ */ toRaw(oldValue);
|
|
984
|
-
value = /* @__PURE__ */ toRaw(value);
|
|
985
|
-
}
|
|
986
|
-
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
|
|
987
|
-
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
|
|
988
|
-
return true;
|
|
989
|
-
} else {
|
|
990
|
-
oldValue.value = value;
|
|
991
|
-
return true;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
|
|
995
|
-
const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
996
|
-
if (target === /* @__PURE__ */ toRaw(receiver)) {
|
|
997
|
-
if (!hadKey) trigger(target, "add", key, value);
|
|
998
|
-
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
999
|
-
}
|
|
1000
|
-
return result;
|
|
1001
|
-
}
|
|
1002
|
-
deleteProperty(target, key) {
|
|
1003
|
-
const hadKey = hasOwn(target, key);
|
|
1004
|
-
const oldValue = target[key];
|
|
1005
|
-
const result = Reflect.deleteProperty(target, key);
|
|
1006
|
-
if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
1007
|
-
return result;
|
|
1008
|
-
}
|
|
1009
|
-
has(target, key) {
|
|
1010
|
-
const result = Reflect.has(target, key);
|
|
1011
|
-
if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
|
|
1012
|
-
return result;
|
|
1013
|
-
}
|
|
1014
|
-
ownKeys(target) {
|
|
1015
|
-
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
1016
|
-
return Reflect.ownKeys(target);
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
1020
|
-
constructor(isShallow = false) {
|
|
1021
|
-
super(true, isShallow);
|
|
1022
|
-
}
|
|
1023
|
-
set(target, key) {
|
|
1024
|
-
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
1025
|
-
return true;
|
|
1026
|
-
}
|
|
1027
|
-
deleteProperty(target, key) {
|
|
1028
|
-
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
1029
|
-
return true;
|
|
1030
|
-
}
|
|
1031
|
-
};
|
|
1032
|
-
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1033
|
-
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1034
|
-
//#endregion
|
|
1035
|
-
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1036
|
-
const toShallow = (value) => value;
|
|
1037
|
-
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1038
|
-
function createIterableMethod(method, isReadonly, isShallow) {
|
|
1039
|
-
return function(...args) {
|
|
1040
|
-
const target = this["__v_raw"];
|
|
1041
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1042
|
-
const targetIsMap = isMap(rawTarget);
|
|
1043
|
-
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1044
|
-
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1045
|
-
const innerIterator = target[method](...args);
|
|
1046
|
-
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
|
1047
|
-
!isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
1048
|
-
return extend(Object.create(innerIterator), { next() {
|
|
1049
|
-
const { value, done } = innerIterator.next();
|
|
1050
|
-
return done ? {
|
|
1051
|
-
value,
|
|
1052
|
-
done
|
|
1053
|
-
} : {
|
|
1054
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
1055
|
-
done
|
|
1056
|
-
};
|
|
1057
|
-
} });
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
function createReadonlyMethod(type) {
|
|
1061
|
-
return function(...args) {
|
|
1062
|
-
{
|
|
1063
|
-
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
1064
|
-
warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
|
|
1065
|
-
}
|
|
1066
|
-
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
function createInstrumentations(readonly, shallow) {
|
|
1070
|
-
const instrumentations = {
|
|
1071
|
-
get(key) {
|
|
1072
|
-
const target = this["__v_raw"];
|
|
1073
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1074
|
-
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
1075
|
-
if (!readonly) {
|
|
1076
|
-
if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
|
|
1077
|
-
track(rawTarget, "get", rawKey);
|
|
1078
|
-
}
|
|
1079
|
-
const { has } = getProto(rawTarget);
|
|
1080
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1081
|
-
if (has.call(rawTarget, key)) return wrap(target.get(key));
|
|
1082
|
-
else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
|
|
1083
|
-
else if (target !== rawTarget) target.get(key);
|
|
1084
|
-
},
|
|
1085
|
-
get size() {
|
|
1086
|
-
const target = this["__v_raw"];
|
|
1087
|
-
!readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
|
|
1088
|
-
return target.size;
|
|
1089
|
-
},
|
|
1090
|
-
has(key) {
|
|
1091
|
-
const target = this["__v_raw"];
|
|
1092
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1093
|
-
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
1094
|
-
if (!readonly) {
|
|
1095
|
-
if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
|
|
1096
|
-
track(rawTarget, "has", rawKey);
|
|
1097
|
-
}
|
|
1098
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1099
|
-
},
|
|
1100
|
-
forEach(callback, thisArg) {
|
|
1101
|
-
const observed = this;
|
|
1102
|
-
const target = observed["__v_raw"];
|
|
1103
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1104
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1105
|
-
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1106
|
-
return target.forEach((value, key) => {
|
|
1107
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
extend(instrumentations, readonly ? {
|
|
1112
|
-
add: createReadonlyMethod("add"),
|
|
1113
|
-
set: createReadonlyMethod("set"),
|
|
1114
|
-
delete: createReadonlyMethod("delete"),
|
|
1115
|
-
clear: createReadonlyMethod("clear")
|
|
1116
|
-
} : {
|
|
1117
|
-
add(value) {
|
|
1118
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1119
|
-
const proto = getProto(target);
|
|
1120
|
-
const rawValue = /* @__PURE__ */ toRaw(value);
|
|
1121
|
-
const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
|
|
1122
|
-
if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
|
|
1123
|
-
target.add(valueToAdd);
|
|
1124
|
-
trigger(target, "add", valueToAdd, valueToAdd);
|
|
1125
|
-
}
|
|
1126
|
-
return this;
|
|
1127
|
-
},
|
|
1128
|
-
set(key, value) {
|
|
1129
|
-
if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
|
|
1130
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1131
|
-
const { has, get } = getProto(target);
|
|
1132
|
-
let hadKey = has.call(target, key);
|
|
1133
|
-
if (!hadKey) {
|
|
1134
|
-
key = /* @__PURE__ */ toRaw(key);
|
|
1135
|
-
hadKey = has.call(target, key);
|
|
1136
|
-
} else checkIdentityKeys(target, has, key);
|
|
1137
|
-
const oldValue = get.call(target, key);
|
|
1138
|
-
target.set(key, value);
|
|
1139
|
-
if (!hadKey) trigger(target, "add", key, value);
|
|
1140
|
-
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
1141
|
-
return this;
|
|
1142
|
-
},
|
|
1143
|
-
delete(key) {
|
|
1144
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1145
|
-
const { has, get } = getProto(target);
|
|
1146
|
-
let hadKey = has.call(target, key);
|
|
1147
|
-
if (!hadKey) {
|
|
1148
|
-
key = /* @__PURE__ */ toRaw(key);
|
|
1149
|
-
hadKey = has.call(target, key);
|
|
1150
|
-
} else checkIdentityKeys(target, has, key);
|
|
1151
|
-
const oldValue = get ? get.call(target, key) : void 0;
|
|
1152
|
-
const result = target.delete(key);
|
|
1153
|
-
if (hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
1154
|
-
return result;
|
|
1155
|
-
},
|
|
1156
|
-
clear() {
|
|
1157
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1158
|
-
const hadItems = target.size !== 0;
|
|
1159
|
-
const oldTarget = isMap(target) ? new Map(target) : new Set(target);
|
|
1160
|
-
const result = target.clear();
|
|
1161
|
-
if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
|
|
1162
|
-
return result;
|
|
43
|
+
function isWithinRuntimeDomMove(node) {
|
|
44
|
+
let current = node;
|
|
45
|
+
while (current) {
|
|
46
|
+
if (activeMoveRoots.has(current)) return true;
|
|
47
|
+
if (current.parentNode) {
|
|
48
|
+
current = current.parentNode;
|
|
49
|
+
continue;
|
|
1163
50
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
"keys",
|
|
1167
|
-
"values",
|
|
1168
|
-
"entries",
|
|
1169
|
-
Symbol.iterator
|
|
1170
|
-
].forEach((method) => {
|
|
1171
|
-
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
1172
|
-
});
|
|
1173
|
-
return instrumentations;
|
|
1174
|
-
}
|
|
1175
|
-
function createInstrumentationGetter(isReadonly, shallow) {
|
|
1176
|
-
const instrumentations = createInstrumentations(isReadonly, shallow);
|
|
1177
|
-
return (target, key, receiver) => {
|
|
1178
|
-
if (key === "__v_isReactive") return !isReadonly;
|
|
1179
|
-
else if (key === "__v_isReadonly") return isReadonly;
|
|
1180
|
-
else if (key === "__v_raw") return target;
|
|
1181
|
-
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
|
|
1185
|
-
const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
|
|
1186
|
-
function checkIdentityKeys(target, has, key) {
|
|
1187
|
-
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
1188
|
-
if (rawKey !== key && has.call(target, rawKey)) {
|
|
1189
|
-
const type = toRawType(target);
|
|
1190
|
-
warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
//#endregion
|
|
1194
|
-
//#region packages/core/signal/src/reactive.ts
|
|
1195
|
-
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1196
|
-
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1197
|
-
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1198
|
-
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1199
|
-
function targetTypeMap(rawType) {
|
|
1200
|
-
switch (rawType) {
|
|
1201
|
-
case "Object":
|
|
1202
|
-
case "Array": return 1;
|
|
1203
|
-
case "Map":
|
|
1204
|
-
case "Set":
|
|
1205
|
-
case "WeakMap":
|
|
1206
|
-
case "WeakSet": return 2;
|
|
1207
|
-
default: return 0;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
function getTargetType(value) {
|
|
1211
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
1212
|
-
}
|
|
1213
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1214
|
-
function reactive(target) {
|
|
1215
|
-
if (/* @__PURE__ */ isReadonly(target)) return target;
|
|
1216
|
-
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
1217
|
-
}
|
|
1218
|
-
/**
|
|
1219
|
-
* Takes an object (reactive or plain) or a ref and returns a readonly proxy to
|
|
1220
|
-
* the original.
|
|
1221
|
-
*
|
|
1222
|
-
* A readonly proxy is deep: any nested property accessed will be readonly as
|
|
1223
|
-
* well. It also has the same ref-unwrapping behavior as {@link reactive},
|
|
1224
|
-
* except the unwrapped values will also be made readonly.
|
|
1225
|
-
*
|
|
1226
|
-
* @example
|
|
1227
|
-
* ```js
|
|
1228
|
-
* const original = reactive({ count: 0 })
|
|
1229
|
-
*
|
|
1230
|
-
* const copy = readonly(original)
|
|
1231
|
-
*
|
|
1232
|
-
* watchEffect(() => {
|
|
1233
|
-
* // works for reactivity tracking
|
|
1234
|
-
* console.log(copy.count)
|
|
1235
|
-
* })
|
|
1236
|
-
*
|
|
1237
|
-
* // mutating original will trigger watchers relying on the copy
|
|
1238
|
-
* original.count++
|
|
1239
|
-
*
|
|
1240
|
-
* // mutating the copy will fail and result in a warning
|
|
1241
|
-
* copy.count++ // warning!
|
|
1242
|
-
* ```
|
|
1243
|
-
*
|
|
1244
|
-
* @param target - The source object.
|
|
1245
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
1246
|
-
*/
|
|
1247
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1248
|
-
function readonly(target) {
|
|
1249
|
-
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
1250
|
-
}
|
|
1251
|
-
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
|
1252
|
-
if (!isObject(target)) {
|
|
1253
|
-
warn(`value cannot be made ${isReadonly ? "readonly" : "reactive"}: ${String(target)}`);
|
|
1254
|
-
return target;
|
|
51
|
+
const root = current.getRootNode();
|
|
52
|
+
current = "host" in root ? root.host : null;
|
|
1255
53
|
}
|
|
1256
|
-
|
|
1257
|
-
const targetType = getTargetType(target);
|
|
1258
|
-
if (targetType === 0) return target;
|
|
1259
|
-
const existingProxy = proxyMap.get(target);
|
|
1260
|
-
if (existingProxy) return existingProxy;
|
|
1261
|
-
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
1262
|
-
proxyMap.set(target, proxy);
|
|
1263
|
-
return proxy;
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Checks if an object is a proxy created by {@link reactive} or
|
|
1267
|
-
* {@link shallowReactive} (or {@link ref} in some cases).
|
|
1268
|
-
*
|
|
1269
|
-
* @example
|
|
1270
|
-
* ```js
|
|
1271
|
-
* isReactive(reactive({})) // => true
|
|
1272
|
-
* isReactive(readonly(reactive({}))) // => true
|
|
1273
|
-
* isReactive(ref({}).value) // => true
|
|
1274
|
-
* isReactive(readonly(ref({})).value) // => true
|
|
1275
|
-
* isReactive(ref(true)) // => false
|
|
1276
|
-
* isReactive(shallowRef({}).value) // => false
|
|
1277
|
-
* isReactive(shallowReactive({})) // => true
|
|
1278
|
-
* ```
|
|
1279
|
-
*
|
|
1280
|
-
* @param value - The value to check.
|
|
1281
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
1282
|
-
*/
|
|
1283
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1284
|
-
function isReactive(value) {
|
|
1285
|
-
if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
1286
|
-
return !!(value && value["__v_isReactive"]);
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* Checks whether the passed value is a readonly object. The properties of a
|
|
1290
|
-
* readonly object can change, but they can't be assigned directly via the
|
|
1291
|
-
* passed object.
|
|
1292
|
-
*
|
|
1293
|
-
* The proxies created by {@link readonly} and {@link shallowReadonly} are
|
|
1294
|
-
* both considered readonly, as is a computed ref without a set function.
|
|
1295
|
-
*
|
|
1296
|
-
* @param value - The value to check.
|
|
1297
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
1298
|
-
*/
|
|
1299
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1300
|
-
function isReadonly(value) {
|
|
1301
|
-
return !!(value && value["__v_isReadonly"]);
|
|
1302
|
-
}
|
|
1303
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1304
|
-
function isShallow(value) {
|
|
1305
|
-
return !!(value && value["__v_isShallow"]);
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* Checks if an object is a proxy created by {@link reactive},
|
|
1309
|
-
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
|
|
1310
|
-
*
|
|
1311
|
-
* @param value - The value to check.
|
|
1312
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
1313
|
-
*/
|
|
1314
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1315
|
-
function isProxy(value) {
|
|
1316
|
-
return value ? !!value["__v_raw"] : false;
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
* Returns the raw, original object of a Vue-created proxy.
|
|
1320
|
-
*
|
|
1321
|
-
* `toRaw()` can return the original object from proxies created by
|
|
1322
|
-
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
1323
|
-
* {@link shallowReadonly}.
|
|
1324
|
-
*
|
|
1325
|
-
* This is an escape hatch that can be used to temporarily read without
|
|
1326
|
-
* incurring proxy access / tracking overhead or write without triggering
|
|
1327
|
-
* changes. It is **not** recommended to hold a persistent reference to the
|
|
1328
|
-
* original object. Use with caution.
|
|
1329
|
-
*
|
|
1330
|
-
* @example
|
|
1331
|
-
* ```js
|
|
1332
|
-
* const foo = {}
|
|
1333
|
-
* const reactiveFoo = reactive(foo)
|
|
1334
|
-
*
|
|
1335
|
-
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
1336
|
-
* ```
|
|
1337
|
-
*
|
|
1338
|
-
* @param observed - The object for which the "raw" value is requested.
|
|
1339
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
1340
|
-
*/
|
|
1341
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1342
|
-
function toRaw(observed) {
|
|
1343
|
-
const raw = observed && observed["__v_raw"];
|
|
1344
|
-
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* Returns a reactive proxy of the given value (if possible).
|
|
1348
|
-
*
|
|
1349
|
-
* If the given value is not an object, the original value itself is returned.
|
|
1350
|
-
*
|
|
1351
|
-
* @param value - The value for which a reactive proxy shall be created.
|
|
1352
|
-
*/
|
|
1353
|
-
const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
|
|
1354
|
-
/**
|
|
1355
|
-
* Returns a readonly proxy of the given value (if possible).
|
|
1356
|
-
*
|
|
1357
|
-
* If the given value is not an object, the original value itself is returned.
|
|
1358
|
-
*
|
|
1359
|
-
* @param value - The value for which a readonly proxy shall be created.
|
|
1360
|
-
*/
|
|
1361
|
-
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1362
|
-
//#endregion
|
|
1363
|
-
//#region packages/core/signal/src/state.ts
|
|
1364
|
-
function state(value) {
|
|
1365
|
-
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1366
|
-
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
1367
|
-
}
|
|
1368
|
-
function isProxyable(value) {
|
|
1369
|
-
if (value === null || typeof value !== "object") return false;
|
|
1370
|
-
if (Array.isArray(value)) return true;
|
|
1371
|
-
if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
|
|
1372
|
-
return isPlainObject(value);
|
|
1373
|
-
}
|
|
1374
|
-
function isPlainObject(value) {
|
|
1375
|
-
const proto = Object.getPrototypeOf(value);
|
|
1376
|
-
return proto === Object.prototype || proto === null;
|
|
54
|
+
return false;
|
|
1377
55
|
}
|
|
1378
56
|
//#endregion
|
|
1379
57
|
//#region packages/core/runtime-dom/src/domOwnership.ts
|
|
@@ -1410,6 +88,14 @@ function insertTracked(parent, value, marker = null) {
|
|
|
1410
88
|
for (const item of value) nodes.push(...insertTracked(parent, item, marker));
|
|
1411
89
|
return nodes;
|
|
1412
90
|
}
|
|
91
|
+
if (value instanceof Node && value.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
92
|
+
const nodes = Array.from(value.childNodes);
|
|
93
|
+
for (const node of nodes) {
|
|
94
|
+
trackRuntimeDomInsertion(parent, node);
|
|
95
|
+
parent.insertBefore(node, marker);
|
|
96
|
+
}
|
|
97
|
+
return nodes;
|
|
98
|
+
}
|
|
1413
99
|
const node = value instanceof Node ? value : document.createTextNode(String(value));
|
|
1414
100
|
trackRuntimeDomInsertion(parent, node);
|
|
1415
101
|
parent.insertBefore(node, marker);
|
|
@@ -1424,7 +110,7 @@ function removeNodes$1(nodes) {
|
|
|
1424
110
|
function moveRangeBefore(nodes, parent, marker = null) {
|
|
1425
111
|
for (const node of nodes) {
|
|
1426
112
|
trackRuntimeDomInsertion(parent, node);
|
|
1427
|
-
parent
|
|
113
|
+
moveNodeBefore(parent, node, marker);
|
|
1428
114
|
}
|
|
1429
115
|
}
|
|
1430
116
|
//#endregion
|
|
@@ -1468,11 +154,12 @@ var ScopedSubtree = class {
|
|
|
1468
154
|
}
|
|
1469
155
|
replace(render) {
|
|
1470
156
|
this.dispose();
|
|
1471
|
-
const scope = effectScope(true);
|
|
157
|
+
const scope = (0, _zeus_js_signal_internal.effectScope)(true);
|
|
158
|
+
const parent = this.resolveParent(this.marker);
|
|
1472
159
|
let nodes = [];
|
|
1473
160
|
try {
|
|
1474
161
|
scope.run(() => {
|
|
1475
|
-
nodes = runWithOwner(this.context.owner, () => withHostContext(this.context.host, () => insertTracked(
|
|
162
|
+
nodes = runWithOwner(this.context.owner, () => withHostContext(this.context.host, () => insertTracked(parent, render(), this.marker)));
|
|
1476
163
|
});
|
|
1477
164
|
} catch (error) {
|
|
1478
165
|
scope.stop();
|
|
@@ -1490,11 +177,15 @@ var ScopedSubtree = class {
|
|
|
1490
177
|
this.nodes = [];
|
|
1491
178
|
}
|
|
1492
179
|
moveBefore(marker) {
|
|
1493
|
-
moveRangeBefore(this.nodes, this.
|
|
180
|
+
moveRangeBefore(this.nodes, this.resolveParent(marker), marker);
|
|
1494
181
|
}
|
|
1495
182
|
current() {
|
|
1496
183
|
return this.nodes;
|
|
1497
184
|
}
|
|
185
|
+
resolveParent(marker) {
|
|
186
|
+
var _ref, _marker$parentNode, _this$marker;
|
|
187
|
+
return (_ref = (_marker$parentNode = marker === null || marker === void 0 ? void 0 : marker.parentNode) !== null && _marker$parentNode !== void 0 ? _marker$parentNode : (_this$marker = this.marker) === null || _this$marker === void 0 ? void 0 : _this$marker.parentNode) !== null && _ref !== void 0 ? _ref : this.parent;
|
|
188
|
+
}
|
|
1498
189
|
};
|
|
1499
190
|
//#endregion
|
|
1500
191
|
//#region packages/core/runtime-dom/src/insert.ts
|
|
@@ -1507,11 +198,11 @@ function insert(parent, value, marker = null) {
|
|
|
1507
198
|
}
|
|
1508
199
|
function mountDynamic(parent, marker, value) {
|
|
1509
200
|
const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
|
|
1510
|
-
const runner = effect(() => {
|
|
201
|
+
const runner = (0, _zeus_js_signal_internal.effect)(() => {
|
|
1511
202
|
subtree.replace(value);
|
|
1512
203
|
});
|
|
1513
|
-
onScopeDispose(() => {
|
|
1514
|
-
stop(runner);
|
|
204
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
205
|
+
(0, _zeus_js_signal_internal.stop)(runner);
|
|
1515
206
|
subtree.dispose();
|
|
1516
207
|
}, true);
|
|
1517
208
|
}
|
|
@@ -1605,7 +296,7 @@ function provideDOMContext(target, context, value) {
|
|
|
1605
296
|
request.detail.resolve(value);
|
|
1606
297
|
};
|
|
1607
298
|
target.addEventListener(ZEUS_CONTEXT_REQUEST, handler);
|
|
1608
|
-
onScopeDispose(() => {
|
|
299
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
1609
300
|
target.removeEventListener(ZEUS_CONTEXT_REQUEST, handler);
|
|
1610
301
|
}, true);
|
|
1611
302
|
}
|
|
@@ -1655,7 +346,7 @@ function emitDevtoolsEvent(event) {
|
|
|
1655
346
|
//#region packages/core/runtime-dom/src/render.ts
|
|
1656
347
|
function render(value, container, options = {}) {
|
|
1657
348
|
var _options$owner;
|
|
1658
|
-
const renderScope =
|
|
349
|
+
const renderScope = (0, _zeus_js_signal_internal.scope)();
|
|
1659
350
|
const owner = (_options$owner = options.owner) !== null && _options$owner !== void 0 ? _options$owner : createOwner();
|
|
1660
351
|
renderScope.run(() => {
|
|
1661
352
|
container.textContent = "";
|
|
@@ -1704,14 +395,23 @@ function removeNodes(nodes) {
|
|
|
1704
395
|
}
|
|
1705
396
|
//#endregion
|
|
1706
397
|
//#region packages/core/runtime-dom/src/bindings.ts
|
|
1707
|
-
function bindText(node, value) {
|
|
1708
|
-
|
|
1709
|
-
node.data = stringifyText(
|
|
398
|
+
function bindText(node, value, once = false) {
|
|
399
|
+
applyBinding(value, once, (next) => {
|
|
400
|
+
node.data = stringifyText(next);
|
|
1710
401
|
});
|
|
1711
402
|
}
|
|
1712
|
-
function bindTextContent(el, value) {
|
|
1713
|
-
|
|
1714
|
-
el.textContent = stringifyText(
|
|
403
|
+
function bindTextContent(el, value, once = false) {
|
|
404
|
+
applyBinding(value, once, (next) => {
|
|
405
|
+
el.textContent = stringifyText(next);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
function applyBinding(value, once, apply) {
|
|
409
|
+
if (once) {
|
|
410
|
+
(0, _zeus_js_signal_internal.untrack)(() => apply(value()));
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
(0, _zeus_js_signal_internal.effect)(() => {
|
|
414
|
+
apply(value());
|
|
1715
415
|
});
|
|
1716
416
|
}
|
|
1717
417
|
function stringifyText(value) {
|
|
@@ -1764,19 +464,19 @@ const BOOLEAN_DOM_PROPERTY_NAME = {
|
|
|
1764
464
|
function normalizeAttrName(name) {
|
|
1765
465
|
return name === "className" ? "class" : name;
|
|
1766
466
|
}
|
|
1767
|
-
function bindAttr(el, name, value) {
|
|
1768
|
-
|
|
1769
|
-
setAttr(el, name,
|
|
467
|
+
function bindAttr(el, name, value, once = false) {
|
|
468
|
+
applyBinding(value, once, (next) => {
|
|
469
|
+
setAttr(el, name, next);
|
|
1770
470
|
});
|
|
1771
471
|
}
|
|
1772
|
-
function bindProp(el, name, value) {
|
|
1773
|
-
|
|
1774
|
-
el[name] =
|
|
472
|
+
function bindProp(el, name, value, once = false) {
|
|
473
|
+
applyBinding(value, once, (next) => {
|
|
474
|
+
el[name] = next;
|
|
1775
475
|
});
|
|
1776
476
|
}
|
|
1777
|
-
function bindClass(el, value) {
|
|
1778
|
-
|
|
1779
|
-
const next = normalizeClass(value
|
|
477
|
+
function bindClass(el, value, once = false) {
|
|
478
|
+
applyBinding(value, once, (value) => {
|
|
479
|
+
const next = normalizeClass(value);
|
|
1780
480
|
if (next) el.setAttribute("class", next);
|
|
1781
481
|
else el.removeAttribute("class");
|
|
1782
482
|
});
|
|
@@ -1788,10 +488,9 @@ function normalizeClass(value) {
|
|
|
1788
488
|
if (typeof value === "object") return Object.keys(value).filter((key) => value[key]).join(" ");
|
|
1789
489
|
return "";
|
|
1790
490
|
}
|
|
1791
|
-
function bindStyle(el, value) {
|
|
491
|
+
function bindStyle(el, value, once = false) {
|
|
1792
492
|
let prev;
|
|
1793
|
-
|
|
1794
|
-
const next = value();
|
|
493
|
+
applyBinding(value, once, (next) => {
|
|
1795
494
|
if (next == null) {
|
|
1796
495
|
el.removeAttribute("style");
|
|
1797
496
|
prev = void 0;
|
|
@@ -1802,42 +501,41 @@ function bindStyle(el, value) {
|
|
|
1802
501
|
prev = void 0;
|
|
1803
502
|
return;
|
|
1804
503
|
}
|
|
1805
|
-
patchStyle(el, prev, next);
|
|
1806
|
-
prev = next;
|
|
504
|
+
prev = patchStyle(el, prev, next);
|
|
1807
505
|
});
|
|
1808
506
|
}
|
|
1809
507
|
function patchStyle(el, prev, next) {
|
|
1810
508
|
const style = el.style;
|
|
1811
|
-
|
|
1812
|
-
|
|
509
|
+
const values = prev ? prev[0] : Object.create(null);
|
|
510
|
+
const state = style.cssText + Object.keys(next);
|
|
511
|
+
const styleChanged = prev && state != prev[1];
|
|
512
|
+
for (const key in values) if (!(key in next)) {
|
|
513
|
+
style.setProperty(key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`), "");
|
|
514
|
+
delete values[key];
|
|
1813
515
|
}
|
|
1814
516
|
for (const key in next) {
|
|
1815
517
|
const value = next[key];
|
|
1816
|
-
const
|
|
1817
|
-
if (
|
|
1818
|
-
|
|
518
|
+
const expected = value == null ? "" : normalizeStyleValue(key, value);
|
|
519
|
+
if (values[key] === expected && !styleChanged) continue;
|
|
520
|
+
style.setProperty(key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`), expected);
|
|
521
|
+
values[key] = expected;
|
|
1819
522
|
}
|
|
523
|
+
return [values, style.cssText + Object.keys(next)];
|
|
1820
524
|
}
|
|
1821
525
|
function normalizeStyleValue(key, value) {
|
|
1822
|
-
if (typeof value === "number" && value !== 0 &&
|
|
526
|
+
if (typeof value === "number" && value !== 0 && unitlessNumbers[key] !== true) return `${value}px`;
|
|
1823
527
|
return String(value);
|
|
1824
528
|
}
|
|
1825
|
-
const unitlessNumbers =
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
function isUnitlessNumber(key) {
|
|
1836
|
-
return unitlessNumbers.has(key);
|
|
1837
|
-
}
|
|
1838
|
-
function toKebabCase$2(value) {
|
|
1839
|
-
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1840
|
-
}
|
|
529
|
+
const unitlessNumbers = {
|
|
530
|
+
opacity: true,
|
|
531
|
+
zIndex: true,
|
|
532
|
+
fontWeight: true,
|
|
533
|
+
lineHeight: true,
|
|
534
|
+
flex: true,
|
|
535
|
+
flexGrow: true,
|
|
536
|
+
flexShrink: true,
|
|
537
|
+
order: true
|
|
538
|
+
};
|
|
1841
539
|
//#endregion
|
|
1842
540
|
//#region packages/core/runtime-dom/src/events.ts
|
|
1843
541
|
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
@@ -1850,7 +548,7 @@ function bindEvent(el, name, handler) {
|
|
|
1850
548
|
const target = el;
|
|
1851
549
|
const events = target.__zeusEvents || (target.__zeusEvents = {});
|
|
1852
550
|
events[name] = handler;
|
|
1853
|
-
onScopeDispose(() => {
|
|
551
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
1854
552
|
var _target$__zeusEvents;
|
|
1855
553
|
if (((_target$__zeusEvents = target.__zeusEvents) === null || _target$__zeusEvents === void 0 ? void 0 : _target$__zeusEvents[name]) === handler) delete target.__zeusEvents[name];
|
|
1856
554
|
}, true);
|
|
@@ -1933,7 +631,7 @@ function setRef(target, value) {
|
|
|
1933
631
|
}
|
|
1934
632
|
function bindRef(el, target) {
|
|
1935
633
|
setRef(target, el);
|
|
1936
|
-
if (getCurrentScope()) onScopeDispose(() => {
|
|
634
|
+
if ((0, _zeus_js_signal_internal.getCurrentScope)()) (0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
1937
635
|
setRef(target, null);
|
|
1938
636
|
}, true);
|
|
1939
637
|
}
|
|
@@ -1947,6 +645,30 @@ function createComponent(component, props) {
|
|
|
1947
645
|
function disposeListRecord(record) {
|
|
1948
646
|
record.subtree.dispose();
|
|
1949
647
|
}
|
|
648
|
+
function isImmediatelyBefore(record, anchor) {
|
|
649
|
+
const nodes = record.subtree.current();
|
|
650
|
+
const last = nodes[nodes.length - 1];
|
|
651
|
+
return last === void 0 || last.nextSibling === anchor;
|
|
652
|
+
}
|
|
653
|
+
function containsNode(record, node) {
|
|
654
|
+
let current = node;
|
|
655
|
+
while (current) {
|
|
656
|
+
if (record.subtree.current().some((root) => root === current || root.contains(current))) return true;
|
|
657
|
+
const treeRoot = current.getRootNode();
|
|
658
|
+
current = "host" in treeRoot ? treeRoot.host : null;
|
|
659
|
+
}
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
function getDeepestActiveElement(parent) {
|
|
663
|
+
var _parent$ownerDocument, _parent$ownerDocument2, _active$shadowRoot;
|
|
664
|
+
const treeRoot = parent.getRootNode();
|
|
665
|
+
let active = "activeElement" in treeRoot ? treeRoot.activeElement : (_parent$ownerDocument = (_parent$ownerDocument2 = parent.ownerDocument) === null || _parent$ownerDocument2 === void 0 ? void 0 : _parent$ownerDocument2.activeElement) !== null && _parent$ownerDocument !== void 0 ? _parent$ownerDocument : null;
|
|
666
|
+
while (active === null || active === void 0 || (_active$shadowRoot = active.shadowRoot) === null || _active$shadowRoot === void 0 ? void 0 : _active$shadowRoot.activeElement) active = active.shadowRoot.activeElement;
|
|
667
|
+
return active;
|
|
668
|
+
}
|
|
669
|
+
function duplicateKeyError(key, index) {
|
|
670
|
+
return /* @__PURE__ */ new Error(`[Zeus runtime] <For> received duplicate key ${String(key)} at index ${index}.`);
|
|
671
|
+
}
|
|
1950
672
|
function mountFor$1(parent, marker, each, key, render) {
|
|
1951
673
|
if (!key) {
|
|
1952
674
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -1956,63 +678,248 @@ function mountFor$1(parent, marker, each, key, render) {
|
|
|
1956
678
|
}
|
|
1957
679
|
function mountIndexFor(parent, marker, each, render) {
|
|
1958
680
|
const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
681
|
+
let latestItems = [];
|
|
682
|
+
let reconcileRequested = false;
|
|
683
|
+
let reconciling = false;
|
|
684
|
+
let disposed = false;
|
|
685
|
+
let runner;
|
|
686
|
+
const dispose = () => {
|
|
687
|
+
if (disposed) return;
|
|
688
|
+
disposed = true;
|
|
689
|
+
if (runner) (0, _zeus_js_signal_internal.stop)(runner);
|
|
1966
690
|
subtree.dispose();
|
|
1967
|
-
}
|
|
691
|
+
};
|
|
692
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(dispose, true);
|
|
693
|
+
const drainReconciliations = () => {
|
|
694
|
+
if (disposed || reconciling) return;
|
|
695
|
+
reconciling = true;
|
|
696
|
+
try {
|
|
697
|
+
while (reconcileRequested && !disposed) {
|
|
698
|
+
reconcileRequested = false;
|
|
699
|
+
(0, _zeus_js_signal_internal.untrack)(() => {
|
|
700
|
+
subtree.replace(() => latestItems.map((item, index) => render(() => item, () => index)));
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
} finally {
|
|
704
|
+
reconciling = false;
|
|
705
|
+
if (disposed) subtree.dispose();
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
const scheduleReconciliation = () => {
|
|
709
|
+
if (disposed || !runner) return;
|
|
710
|
+
runner();
|
|
711
|
+
if (disposed) return;
|
|
712
|
+
reconcileRequested = true;
|
|
713
|
+
drainReconciliations();
|
|
714
|
+
};
|
|
715
|
+
try {
|
|
716
|
+
runner = (0, _zeus_js_signal_internal.effect)(() => {
|
|
717
|
+
var _each;
|
|
718
|
+
const nextItems = (_each = each()) !== null && _each !== void 0 ? _each : [];
|
|
719
|
+
for (let i = 0; i < nextItems.length; i++) nextItems[i];
|
|
720
|
+
latestItems = nextItems;
|
|
721
|
+
}, { scheduler: scheduleReconciliation });
|
|
722
|
+
} catch (error) {
|
|
723
|
+
dispose();
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
726
|
+
if (disposed) {
|
|
727
|
+
(0, _zeus_js_signal_internal.stop)(runner);
|
|
728
|
+
subtree.dispose();
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
reconcileRequested = true;
|
|
732
|
+
try {
|
|
733
|
+
drainReconciliations();
|
|
734
|
+
} catch (error) {
|
|
735
|
+
dispose();
|
|
736
|
+
throw error;
|
|
737
|
+
}
|
|
1968
738
|
}
|
|
1969
739
|
function mountKeyedFor(parent, marker, each, key, render) {
|
|
1970
740
|
let records = [];
|
|
1971
741
|
const subtreeContext = captureScopedSubtreeContext();
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
742
|
+
let latestItems = [];
|
|
743
|
+
const latestKeys = [];
|
|
744
|
+
let latestItemsUseFixedSlots = false;
|
|
745
|
+
let reconcileRequested = false;
|
|
746
|
+
let reconciling = false;
|
|
747
|
+
let disposed = false;
|
|
748
|
+
let runner;
|
|
749
|
+
const dispose = () => {
|
|
750
|
+
if (disposed) return;
|
|
751
|
+
disposed = true;
|
|
752
|
+
if (runner) (0, _zeus_js_signal_internal.stop)(runner);
|
|
753
|
+
const currentRecords = records;
|
|
754
|
+
records = [];
|
|
755
|
+
for (const record of currentRecords) disposeListRecord(record);
|
|
756
|
+
};
|
|
757
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(dispose, true);
|
|
758
|
+
const reconcileEntries = (nextEntries) => {
|
|
759
|
+
if (disposed) return;
|
|
1975
760
|
const oldMap = /* @__PURE__ */ new Map();
|
|
1976
761
|
for (const record of records) oldMap.set(record.key, record);
|
|
1977
762
|
const nextRecords = [];
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
763
|
+
const createdRecords = [];
|
|
764
|
+
try {
|
|
765
|
+
(0, _zeus_js_signal_internal.batch)(() => {
|
|
766
|
+
for (let i = 0; i < nextEntries.length; i++) {
|
|
767
|
+
const { item, key: itemKey } = nextEntries[i];
|
|
768
|
+
const oldRecord = oldMap.get(itemKey);
|
|
769
|
+
if (oldRecord) {
|
|
770
|
+
oldMap.delete(itemKey);
|
|
771
|
+
if (!Object.is(oldRecord.item, item)) {
|
|
772
|
+
oldRecord.item = item;
|
|
773
|
+
oldRecord.setItem(() => item);
|
|
774
|
+
}
|
|
775
|
+
oldRecord.setIndex(i);
|
|
776
|
+
nextRecords.push(oldRecord);
|
|
777
|
+
} else {
|
|
778
|
+
const [readItem, setItem] = (0, _zeus_js_signal_internal.createSignal)(item);
|
|
779
|
+
const [readIndex, setIndex] = (0, _zeus_js_signal_internal.createSignal)(i);
|
|
780
|
+
const subtree = new ScopedSubtree(parent, marker, subtreeContext);
|
|
781
|
+
const record = {
|
|
782
|
+
item,
|
|
783
|
+
key: itemKey,
|
|
784
|
+
setItem,
|
|
785
|
+
setIndex,
|
|
786
|
+
subtree
|
|
787
|
+
};
|
|
788
|
+
createdRecords.push(record);
|
|
789
|
+
subtree.replace(() => render(readItem, readIndex));
|
|
790
|
+
nextRecords.push(record);
|
|
791
|
+
}
|
|
792
|
+
if (disposed) break;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
} catch (error) {
|
|
796
|
+
for (const record of createdRecords) disposeListRecord(record);
|
|
797
|
+
throw error;
|
|
798
|
+
}
|
|
799
|
+
if (disposed) {
|
|
800
|
+
for (const record of createdRecords) disposeListRecord(record);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const activeElement = getDeepestActiveElement(parent);
|
|
804
|
+
const shouldRestoreFocus = Boolean(activeElement && nextRecords.some((record) => containsNode(record, activeElement)));
|
|
805
|
+
let committed = false;
|
|
806
|
+
try {
|
|
807
|
+
for (const record of oldMap.values()) disposeListRecord(record);
|
|
808
|
+
if (disposed) {
|
|
809
|
+
for (const record of createdRecords) disposeListRecord(record);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
records = nextRecords;
|
|
813
|
+
committed = true;
|
|
814
|
+
let moved = false;
|
|
815
|
+
let anchor = marker;
|
|
816
|
+
for (let i = nextRecords.length - 1; i >= 0; i--) {
|
|
817
|
+
var _record$subtree$curre;
|
|
818
|
+
const record = nextRecords[i];
|
|
819
|
+
if (!isImmediatelyBefore(record, anchor)) {
|
|
820
|
+
record.subtree.moveBefore(anchor);
|
|
821
|
+
moved = true;
|
|
822
|
+
}
|
|
823
|
+
anchor = (_record$subtree$curre = record.subtree.current()[0]) !== null && _record$subtree$curre !== void 0 ? _record$subtree$curre : anchor;
|
|
1996
824
|
}
|
|
825
|
+
if (disposed) return;
|
|
826
|
+
if (moved && shouldRestoreFocus) {
|
|
827
|
+
var _focus;
|
|
828
|
+
(_focus = activeElement.focus) === null || _focus === void 0 || _focus.call(activeElement, { preventScroll: true });
|
|
829
|
+
}
|
|
830
|
+
if (!disposed) emitDevtoolsEvent({
|
|
831
|
+
type: "mount-for",
|
|
832
|
+
length: nextRecords.length
|
|
833
|
+
});
|
|
834
|
+
} catch (error) {
|
|
835
|
+
if (!committed) for (const record of createdRecords) disposeListRecord(record);
|
|
836
|
+
throw error;
|
|
1997
837
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
const
|
|
2003
|
-
|
|
838
|
+
};
|
|
839
|
+
const reconcileLatestItems = () => {
|
|
840
|
+
if (disposed) return;
|
|
841
|
+
if (latestItemsUseFixedSlots) {
|
|
842
|
+
const items = latestItems;
|
|
843
|
+
(0, _zeus_js_signal_internal.batch)(() => {
|
|
844
|
+
for (let i = 0; i < items.length; i++) {
|
|
845
|
+
const item = items[i];
|
|
846
|
+
const record = records[i];
|
|
847
|
+
if (!Object.is(record.item, item)) {
|
|
848
|
+
record.item = item;
|
|
849
|
+
record.setItem(() => item);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
if (!disposed) emitDevtoolsEvent({
|
|
854
|
+
type: "mount-for",
|
|
855
|
+
length: records.length
|
|
856
|
+
});
|
|
857
|
+
return;
|
|
2004
858
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
859
|
+
const items = latestItems;
|
|
860
|
+
const nextEntries = [];
|
|
861
|
+
const nextKeys = /* @__PURE__ */ new Set();
|
|
862
|
+
for (let i = 0; i < items.length; i++) {
|
|
863
|
+
const item = items[i];
|
|
864
|
+
const itemKey = latestKeys[i];
|
|
865
|
+
if (nextKeys.has(itemKey)) throw duplicateKeyError(itemKey, i);
|
|
866
|
+
nextKeys.add(itemKey);
|
|
867
|
+
nextEntries.push({
|
|
868
|
+
item,
|
|
869
|
+
key: itemKey
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
reconcileEntries(nextEntries);
|
|
873
|
+
};
|
|
874
|
+
const drainReconciliations = () => {
|
|
875
|
+
if (reconciling) return;
|
|
876
|
+
reconciling = true;
|
|
877
|
+
try {
|
|
878
|
+
while (reconcileRequested) {
|
|
879
|
+
reconcileRequested = false;
|
|
880
|
+
(0, _zeus_js_signal_internal.untrack)(reconcileLatestItems);
|
|
881
|
+
}
|
|
882
|
+
} finally {
|
|
883
|
+
reconciling = false;
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
const scheduleReconciliation = () => {
|
|
887
|
+
if (disposed || !runner) return;
|
|
888
|
+
runner();
|
|
889
|
+
if (disposed) return;
|
|
890
|
+
reconcileRequested = true;
|
|
891
|
+
drainReconciliations();
|
|
892
|
+
};
|
|
893
|
+
try {
|
|
894
|
+
runner = (0, _zeus_js_signal_internal.effect)(() => {
|
|
895
|
+
var _each2;
|
|
896
|
+
const nextItems = (_each2 = each()) !== null && _each2 !== void 0 ? _each2 : [];
|
|
897
|
+
let useFixedSlots = nextItems.length === records.length;
|
|
898
|
+
for (let i = 0; i < nextItems.length; i++) {
|
|
899
|
+
const item = nextItems[i];
|
|
900
|
+
const itemKey = key(item, i);
|
|
901
|
+
latestKeys[i] = itemKey;
|
|
902
|
+
if (useFixedSlots && !Object.is(itemKey, records[i].key)) useFixedSlots = false;
|
|
903
|
+
}
|
|
904
|
+
latestKeys.length = nextItems.length;
|
|
905
|
+
latestItems = nextItems;
|
|
906
|
+
latestItemsUseFixedSlots = useFixedSlots;
|
|
907
|
+
}, { scheduler: scheduleReconciliation });
|
|
908
|
+
} catch (error) {
|
|
909
|
+
dispose();
|
|
910
|
+
throw error;
|
|
911
|
+
}
|
|
912
|
+
if (disposed) {
|
|
913
|
+
(0, _zeus_js_signal_internal.stop)(runner);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
reconcileRequested = true;
|
|
917
|
+
try {
|
|
918
|
+
drainReconciliations();
|
|
919
|
+
} catch (error) {
|
|
920
|
+
dispose();
|
|
921
|
+
throw error;
|
|
922
|
+
}
|
|
2016
923
|
}
|
|
2017
924
|
//#endregion
|
|
2018
925
|
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
@@ -2237,7 +1144,14 @@ function createLightDomProjection(host, lightChildren) {
|
|
|
2237
1144
|
function replaceOutletNodes(outlet, nextNodes) {
|
|
2238
1145
|
const parent = outlet.end.parentNode;
|
|
2239
1146
|
if (!parent || parent !== outlet.start.parentNode) return;
|
|
1147
|
+
const currentNodes = [];
|
|
2240
1148
|
let current = outlet.start.nextSibling;
|
|
1149
|
+
while (current && current !== outlet.end) {
|
|
1150
|
+
currentNodes.push(current);
|
|
1151
|
+
current = current.nextSibling;
|
|
1152
|
+
}
|
|
1153
|
+
if (currentNodes.length === nextNodes.length && currentNodes.every((node, index) => node === nextNodes[index])) return;
|
|
1154
|
+
current = outlet.start.nextSibling;
|
|
2241
1155
|
while (current && current !== outlet.end) {
|
|
2242
1156
|
const next = current.nextSibling;
|
|
2243
1157
|
parent.removeChild(current);
|
|
@@ -2291,6 +1205,7 @@ function prop(input, options = {}) {
|
|
|
2291
1205
|
values: input,
|
|
2292
1206
|
attr: options.attr,
|
|
2293
1207
|
reflect: options.reflect,
|
|
1208
|
+
reactivity: options.reactivity,
|
|
2294
1209
|
default: options.default,
|
|
2295
1210
|
serialize: options.serialize,
|
|
2296
1211
|
deserialize: options.deserialize
|
|
@@ -2300,6 +1215,7 @@ function prop(input, options = {}) {
|
|
|
2300
1215
|
type,
|
|
2301
1216
|
attr: options.attr,
|
|
2302
1217
|
reflect: type === Boolean ? (_options$reflect = options.reflect) !== null && _options$reflect !== void 0 ? _options$reflect : true : options.reflect,
|
|
1218
|
+
reactivity: options.reactivity,
|
|
2303
1219
|
default: type === Boolean ? (_options$default = options.default) !== null && _options$default !== void 0 ? _options$default : false : options.default,
|
|
2304
1220
|
serialize: options.serialize,
|
|
2305
1221
|
deserialize: options.deserialize
|
|
@@ -2322,7 +1238,7 @@ function createPropStore(defs) {
|
|
|
2322
1238
|
const slots = /* @__PURE__ */ new Map();
|
|
2323
1239
|
const props = {};
|
|
2324
1240
|
for (const def of defs) {
|
|
2325
|
-
const slot = state();
|
|
1241
|
+
const slot = def.reactivity === "shallow" ? (0, _zeus_js_signal_internal.shallowState)() : (0, _zeus_js_signal_internal.state)();
|
|
2326
1242
|
slots.set(def.name, slot);
|
|
2327
1243
|
Object.defineProperty(props, def.name, {
|
|
2328
1244
|
configurable: false,
|
|
@@ -2391,6 +1307,7 @@ function defineElement(tagName, options, setup) {
|
|
|
2391
1307
|
this.mountLifecycle.connect();
|
|
2392
1308
|
}
|
|
2393
1309
|
disconnectedCallback() {
|
|
1310
|
+
if (isWithinRuntimeDomMove(this)) return;
|
|
2394
1311
|
this.mountLifecycle.disconnect();
|
|
2395
1312
|
}
|
|
2396
1313
|
mountElement() {
|
|
@@ -2581,7 +1498,8 @@ function normalizePropDefinitions(props) {
|
|
|
2581
1498
|
name: propKey,
|
|
2582
1499
|
attrName: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
|
|
2583
1500
|
type: normalizePropType(type),
|
|
2584
|
-
reflect: false
|
|
1501
|
+
reflect: false,
|
|
1502
|
+
reactivity: "deep"
|
|
2585
1503
|
};
|
|
2586
1504
|
}
|
|
2587
1505
|
const type = input === null || input === void 0 ? void 0 : input.type;
|
|
@@ -2591,6 +1509,7 @@ function normalizePropDefinitions(props) {
|
|
|
2591
1509
|
attrName: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
|
|
2592
1510
|
type: normalizePropType(type),
|
|
2593
1511
|
reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
|
|
1512
|
+
reactivity: (input === null || input === void 0 ? void 0 : input.reactivity) === "shallow" ? "shallow" : "deep",
|
|
2594
1513
|
default: input === null || input === void 0 ? void 0 : input.default,
|
|
2595
1514
|
serialize: input === null || input === void 0 ? void 0 : input.serialize,
|
|
2596
1515
|
deserialize: input === null || input === void 0 ? void 0 : input.deserialize
|
|
@@ -2632,7 +1551,7 @@ function syncFormValue(props, context, form) {
|
|
|
2632
1551
|
const valueResolver = form === null || form === void 0 ? void 0 : form.value;
|
|
2633
1552
|
const stateResolver = form === null || form === void 0 ? void 0 : form.state;
|
|
2634
1553
|
if (!context.internals || valueResolver === void 0) return;
|
|
2635
|
-
effect(() => {
|
|
1554
|
+
(0, _zeus_js_signal_internal.effect)(() => {
|
|
2636
1555
|
const value = resolveFormValue(props, valueResolver);
|
|
2637
1556
|
const state = stateResolver === void 0 ? void 0 : resolveFormValue(props, stateResolver);
|
|
2638
1557
|
context.internals.setFormValue(value, state);
|