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