@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,5 +1,5 @@
|
|
|
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
|
**/
|
|
@@ -7,1310 +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
|
-
//#endregion
|
|
34
|
-
//#region packages/core/shared/src/general.ts
|
|
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 hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region packages/core/signal/src/effectScope.ts
|
|
52
|
-
let activeEffectScope;
|
|
53
|
-
var EffectScope = class {
|
|
54
|
-
constructor(detached = false) {
|
|
55
|
-
this.detached = detached;
|
|
56
|
-
this._active = true;
|
|
57
|
-
this._on = 0;
|
|
58
|
-
this.effects = [];
|
|
59
|
-
this.cleanups = [];
|
|
60
|
-
this._isPaused = false;
|
|
61
|
-
this._warnOnRun = true;
|
|
62
|
-
this.__v_skip = true;
|
|
63
|
-
if (!detached && activeEffectScope) if (activeEffectScope.active) {
|
|
64
|
-
this.parent = activeEffectScope;
|
|
65
|
-
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
66
|
-
} else {
|
|
67
|
-
this._active = false;
|
|
68
|
-
this._warnOnRun = false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
get active() {
|
|
72
|
-
return this._active;
|
|
73
|
-
}
|
|
74
|
-
pause() {
|
|
75
|
-
if (this._active) {
|
|
76
|
-
this._isPaused = true;
|
|
77
|
-
let i, l;
|
|
78
|
-
if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
|
|
79
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resumes the effect scope, including all child scopes and effects.
|
|
84
|
-
*/
|
|
85
|
-
resume() {
|
|
86
|
-
if (this._active) {
|
|
87
|
-
if (this._isPaused) {
|
|
88
|
-
this._isPaused = false;
|
|
89
|
-
let i, l;
|
|
90
|
-
if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
|
|
91
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
run(fn) {
|
|
96
|
-
if (this._active) {
|
|
97
|
-
const currentEffectScope = activeEffectScope;
|
|
98
|
-
try {
|
|
99
|
-
activeEffectScope = this;
|
|
100
|
-
return fn();
|
|
101
|
-
} finally {
|
|
102
|
-
activeEffectScope = currentEffectScope;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* This should only be called on non-detached scopes
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
on() {
|
|
111
|
-
if (++this._on === 1) {
|
|
112
|
-
this.prevScope = activeEffectScope;
|
|
113
|
-
activeEffectScope = this;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* This should only be called on non-detached scopes
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
off() {
|
|
121
|
-
if (this._on > 0 && --this._on === 0) {
|
|
122
|
-
if (activeEffectScope === this) activeEffectScope = this.prevScope;
|
|
123
|
-
else {
|
|
124
|
-
let current = activeEffectScope;
|
|
125
|
-
while (current) {
|
|
126
|
-
if (current.prevScope === this) {
|
|
127
|
-
current.prevScope = this.prevScope;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
current = current.prevScope;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
this.prevScope = void 0;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
stop(fromParent) {
|
|
137
|
-
if (this._active) {
|
|
138
|
-
this._active = false;
|
|
139
|
-
let i, l;
|
|
140
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
|
|
141
|
-
this.effects.length = 0;
|
|
142
|
-
for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
|
|
143
|
-
this.cleanups.length = 0;
|
|
144
|
-
if (this.scopes) {
|
|
145
|
-
for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
|
|
146
|
-
this.scopes.length = 0;
|
|
147
|
-
}
|
|
148
|
-
if (!this.detached && this.parent && !fromParent) {
|
|
149
|
-
const last = this.parent.scopes.pop();
|
|
150
|
-
if (last && last !== this) {
|
|
151
|
-
this.parent.scopes[this.index] = last;
|
|
152
|
-
last.index = this.index;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
this.parent = void 0;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
161
|
-
* computed and watchers) created within it so that these effects can be
|
|
162
|
-
* disposed together. For detailed use cases of this API, please consult its
|
|
163
|
-
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
164
|
-
*
|
|
165
|
-
* @param detached - Can be used to create a "detached" effect scope.
|
|
166
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
167
|
-
*/
|
|
168
|
-
function effectScope(detached) {
|
|
169
|
-
return new EffectScope(detached);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Returns the current active effect scope if there is one.
|
|
173
|
-
*
|
|
174
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
175
|
-
*/
|
|
176
|
-
function getCurrentScope() {
|
|
177
|
-
return activeEffectScope;
|
|
18
|
+
function createHtmlContent(html) {
|
|
19
|
+
const template = document.createElement("template");
|
|
20
|
+
template.innerHTML = html;
|
|
21
|
+
return template.content;
|
|
178
22
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
function onScopeDispose(fn, failSilently = false) {
|
|
187
|
-
if (activeEffectScope) activeEffectScope.cleanups.push(fn);
|
|
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;
|
|
188
29
|
}
|
|
189
30
|
//#endregion
|
|
190
|
-
//#region packages/core/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
constructor(fn) {
|
|
195
|
-
this.fn = fn;
|
|
196
|
-
this.deps = void 0;
|
|
197
|
-
this.depsTail = void 0;
|
|
198
|
-
this.flags = 5;
|
|
199
|
-
this.next = void 0;
|
|
200
|
-
this.cleanups = void 0;
|
|
201
|
-
this.scheduler = void 0;
|
|
202
|
-
this.scope = activeEffectScope;
|
|
203
|
-
if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
|
|
204
|
-
else this.flags &= -2;
|
|
205
|
-
}
|
|
206
|
-
pause() {
|
|
207
|
-
this.flags |= 64;
|
|
208
|
-
}
|
|
209
|
-
resume() {
|
|
210
|
-
if (this.flags & 64) {
|
|
211
|
-
this.flags &= -65;
|
|
212
|
-
if (pausedQueueEffects.has(this)) {
|
|
213
|
-
pausedQueueEffects.delete(this);
|
|
214
|
-
this.trigger();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* @internal
|
|
220
|
-
*/
|
|
221
|
-
notify() {
|
|
222
|
-
if (this.flags & 2 && !(this.flags & 32)) return;
|
|
223
|
-
if (!(this.flags & 8)) queueSubscriber(this);
|
|
224
|
-
}
|
|
225
|
-
run() {
|
|
226
|
-
if (!(this.flags & 1)) return this.fn();
|
|
227
|
-
this.flags |= 2;
|
|
228
|
-
cleanupEffect(this);
|
|
229
|
-
prepareDeps(this);
|
|
230
|
-
const prevEffect = activeSub;
|
|
231
|
-
const prevShouldTrack = shouldTrack;
|
|
232
|
-
activeSub = this;
|
|
233
|
-
shouldTrack = true;
|
|
234
|
-
try {
|
|
235
|
-
return this.fn();
|
|
236
|
-
} finally {
|
|
237
|
-
cleanupDeps(this);
|
|
238
|
-
activeSub = prevEffect;
|
|
239
|
-
shouldTrack = prevShouldTrack;
|
|
240
|
-
this.flags &= -3;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
stop() {
|
|
244
|
-
if (this.flags & 1) {
|
|
245
|
-
for (let link = this.deps; link; link = link.nextDep) removeSub(link);
|
|
246
|
-
this.deps = this.depsTail = void 0;
|
|
247
|
-
cleanupEffect(this);
|
|
248
|
-
this.onStop && this.onStop();
|
|
249
|
-
this.flags &= -2;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
trigger() {
|
|
253
|
-
if (this.flags & 64) pausedQueueEffects.add(this);
|
|
254
|
-
else if (this.scheduler) this.scheduler();
|
|
255
|
-
else this.runIfDirty();
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* @internal
|
|
259
|
-
*/
|
|
260
|
-
runIfDirty() {
|
|
261
|
-
if (isDirty(this)) this.run();
|
|
262
|
-
}
|
|
263
|
-
get dirty() {
|
|
264
|
-
return isDirty(this);
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
/**
|
|
268
|
-
* For debugging
|
|
269
|
-
*/
|
|
270
|
-
let batchDepth = 0;
|
|
271
|
-
let batchedSub;
|
|
272
|
-
let batchedComputed;
|
|
273
|
-
/**
|
|
274
|
-
* @internal
|
|
275
|
-
*/
|
|
276
|
-
function queueSubscriber(sub, isComputed = false) {
|
|
277
|
-
sub.flags |= 8;
|
|
278
|
-
if (isComputed) {
|
|
279
|
-
sub.next = batchedComputed;
|
|
280
|
-
batchedComputed = sub;
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
sub.next = batchedSub;
|
|
284
|
-
batchedSub = sub;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* @internal
|
|
288
|
-
*/
|
|
289
|
-
function startBatch() {
|
|
290
|
-
batchDepth++;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Run batched effects when all batches have ended
|
|
294
|
-
* @internal
|
|
295
|
-
*/
|
|
296
|
-
function endBatch() {
|
|
297
|
-
if (--batchDepth > 0) return;
|
|
298
|
-
if (batchedComputed) {
|
|
299
|
-
let e = batchedComputed;
|
|
300
|
-
batchedComputed = void 0;
|
|
301
|
-
while (e) {
|
|
302
|
-
const next = e.next;
|
|
303
|
-
e.next = void 0;
|
|
304
|
-
e.flags &= -9;
|
|
305
|
-
e = next;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
let error;
|
|
309
|
-
while (batchedSub) {
|
|
310
|
-
let e = batchedSub;
|
|
311
|
-
batchedSub = void 0;
|
|
312
|
-
while (e) {
|
|
313
|
-
const next = e.next;
|
|
314
|
-
e.next = void 0;
|
|
315
|
-
e.flags &= -9;
|
|
316
|
-
if (e.flags & 1) try {
|
|
317
|
-
e.trigger();
|
|
318
|
-
} catch (err) {
|
|
319
|
-
if (!error) error = err;
|
|
320
|
-
}
|
|
321
|
-
e = next;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (error) throw error;
|
|
325
|
-
}
|
|
326
|
-
function prepareDeps(sub) {
|
|
327
|
-
for (let link = sub.deps; link; link = link.nextDep) {
|
|
328
|
-
link.version = -1;
|
|
329
|
-
link.prevActiveLink = link.dep.activeLink;
|
|
330
|
-
link.dep.activeLink = link;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
function cleanupDeps(sub) {
|
|
334
|
-
let head;
|
|
335
|
-
let tail = sub.depsTail;
|
|
336
|
-
let link = tail;
|
|
337
|
-
while (link) {
|
|
338
|
-
const prev = link.prevDep;
|
|
339
|
-
if (link.version === -1) {
|
|
340
|
-
if (link === tail) tail = prev;
|
|
341
|
-
removeSub(link);
|
|
342
|
-
removeDep(link);
|
|
343
|
-
} else head = link;
|
|
344
|
-
link.dep.activeLink = link.prevActiveLink;
|
|
345
|
-
link.prevActiveLink = void 0;
|
|
346
|
-
link = prev;
|
|
347
|
-
}
|
|
348
|
-
sub.deps = head;
|
|
349
|
-
sub.depsTail = tail;
|
|
350
|
-
}
|
|
351
|
-
function isDirty(sub) {
|
|
352
|
-
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;
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Returning false indicates the refresh failed
|
|
357
|
-
* @internal
|
|
358
|
-
*/
|
|
359
|
-
function refreshComputed(computed) {
|
|
360
|
-
if (computed.flags & 4 && !(computed.flags & 16)) return;
|
|
361
|
-
computed.flags &= -17;
|
|
362
|
-
if (computed.globalVersion === globalVersion) return;
|
|
363
|
-
computed.globalVersion = globalVersion;
|
|
364
|
-
if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
|
|
365
|
-
computed.flags |= 2;
|
|
366
|
-
const dep = computed.dep;
|
|
367
|
-
const prevSub = activeSub;
|
|
368
|
-
const prevShouldTrack = shouldTrack;
|
|
369
|
-
activeSub = computed;
|
|
370
|
-
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);
|
|
371
35
|
try {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
computed.flags |= 128;
|
|
376
|
-
computed._value = value;
|
|
377
|
-
dep.version++;
|
|
378
|
-
}
|
|
379
|
-
} catch (err) {
|
|
380
|
-
dep.version++;
|
|
381
|
-
throw err;
|
|
36
|
+
const moveBefore = parent.moveBefore;
|
|
37
|
+
if (typeof moveBefore === "function") moveBefore.call(parent, node, marker);
|
|
38
|
+
else parent.insertBefore(node, marker);
|
|
382
39
|
} finally {
|
|
383
|
-
|
|
384
|
-
shouldTrack = prevShouldTrack;
|
|
385
|
-
cleanupDeps(computed);
|
|
386
|
-
computed.flags &= -3;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
function removeSub(link, soft = false) {
|
|
390
|
-
const { dep, prevSub, nextSub } = link;
|
|
391
|
-
if (prevSub) {
|
|
392
|
-
prevSub.nextSub = nextSub;
|
|
393
|
-
link.prevSub = void 0;
|
|
40
|
+
activeMoveRoots.delete(node);
|
|
394
41
|
}
|
|
395
|
-
if (nextSub) {
|
|
396
|
-
nextSub.prevSub = prevSub;
|
|
397
|
-
link.nextSub = void 0;
|
|
398
|
-
}
|
|
399
|
-
if (dep.subs === link) {
|
|
400
|
-
dep.subs = prevSub;
|
|
401
|
-
if (!prevSub && dep.computed) {
|
|
402
|
-
dep.computed.flags &= -5;
|
|
403
|
-
for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
|
|
407
|
-
}
|
|
408
|
-
function removeDep(link) {
|
|
409
|
-
const { prevDep, nextDep } = link;
|
|
410
|
-
if (prevDep) {
|
|
411
|
-
prevDep.nextDep = nextDep;
|
|
412
|
-
link.prevDep = void 0;
|
|
413
|
-
}
|
|
414
|
-
if (nextDep) {
|
|
415
|
-
nextDep.prevDep = prevDep;
|
|
416
|
-
link.nextDep = void 0;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
function effect(fn, options) {
|
|
420
|
-
if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
|
|
421
|
-
const e = new ReactiveEffect(fn);
|
|
422
|
-
if (options) extend(e, options);
|
|
423
|
-
try {
|
|
424
|
-
e.run();
|
|
425
|
-
} catch (err) {
|
|
426
|
-
e.stop();
|
|
427
|
-
throw err;
|
|
428
|
-
}
|
|
429
|
-
const runner = e.run.bind(e);
|
|
430
|
-
runner.effect = e;
|
|
431
|
-
return runner;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Stops the effect associated with the given runner.
|
|
435
|
-
*
|
|
436
|
-
* @param runner - Association with the effect to stop tracking.
|
|
437
|
-
*/
|
|
438
|
-
function stop(runner) {
|
|
439
|
-
runner.effect.stop();
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* @internal
|
|
443
|
-
*/
|
|
444
|
-
let shouldTrack = true;
|
|
445
|
-
const trackStack = [];
|
|
446
|
-
/**
|
|
447
|
-
* Temporarily pauses tracking.
|
|
448
|
-
*/
|
|
449
|
-
function pauseTracking() {
|
|
450
|
-
trackStack.push(shouldTrack);
|
|
451
|
-
shouldTrack = false;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Resets the previous global effect tracking state.
|
|
455
|
-
*/
|
|
456
|
-
function resetTracking() {
|
|
457
|
-
const last = trackStack.pop();
|
|
458
|
-
shouldTrack = last === void 0 ? true : last;
|
|
459
|
-
}
|
|
460
|
-
function cleanupEffect(e) {
|
|
461
|
-
const cleanups = e.cleanups;
|
|
462
|
-
e.cleanups = void 0;
|
|
463
|
-
if (cleanups) {
|
|
464
|
-
const prevSub = activeSub;
|
|
465
|
-
activeSub = void 0;
|
|
466
|
-
try {
|
|
467
|
-
let error;
|
|
468
|
-
for (const cleanup of cleanups) try {
|
|
469
|
-
cleanup();
|
|
470
|
-
} catch (cleanupError) {
|
|
471
|
-
var _error;
|
|
472
|
-
(_error = error) !== null && _error !== void 0 || (error = cleanupError);
|
|
473
|
-
}
|
|
474
|
-
if (error) throw error;
|
|
475
|
-
} finally {
|
|
476
|
-
activeSub = prevSub;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
//#endregion
|
|
481
|
-
//#region packages/core/signal/src/dep.ts
|
|
482
|
-
/**
|
|
483
|
-
* Incremented every time a reactive change happens
|
|
484
|
-
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
485
|
-
* has changed.
|
|
486
|
-
*/
|
|
487
|
-
let globalVersion = 0;
|
|
488
|
-
/**
|
|
489
|
-
* Represents a link between a source (Dep) and a subscriber (Effect or Computed).
|
|
490
|
-
* Deps and subs have a many-to-many relationship - each link between a
|
|
491
|
-
* dep and a sub is represented by a Link instance.
|
|
492
|
-
*
|
|
493
|
-
* A Link is also a node in two doubly-linked lists - one for the associated
|
|
494
|
-
* sub to track all its deps, and one for the associated dep to track all its
|
|
495
|
-
* subs.
|
|
496
|
-
*
|
|
497
|
-
* @internal
|
|
498
|
-
*/
|
|
499
|
-
var Link = class {
|
|
500
|
-
constructor(sub, dep) {
|
|
501
|
-
this.sub = sub;
|
|
502
|
-
this.dep = dep;
|
|
503
|
-
this.version = dep.version;
|
|
504
|
-
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
/**
|
|
508
|
-
* @internal
|
|
509
|
-
*/
|
|
510
|
-
var Dep = class {
|
|
511
|
-
constructor(computed) {
|
|
512
|
-
this.computed = computed;
|
|
513
|
-
this.version = 0;
|
|
514
|
-
this.activeLink = void 0;
|
|
515
|
-
this.subs = void 0;
|
|
516
|
-
this.map = void 0;
|
|
517
|
-
this.key = void 0;
|
|
518
|
-
this.sc = 0;
|
|
519
|
-
this.__v_skip = true;
|
|
520
|
-
}
|
|
521
|
-
track(debugInfo) {
|
|
522
|
-
if (!activeSub || !shouldTrack || activeSub === this.computed) return;
|
|
523
|
-
let link = this.activeLink;
|
|
524
|
-
if (link === void 0 || link.sub !== activeSub) {
|
|
525
|
-
link = this.activeLink = new Link(activeSub, this);
|
|
526
|
-
if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
|
|
527
|
-
else {
|
|
528
|
-
link.prevDep = activeSub.depsTail;
|
|
529
|
-
activeSub.depsTail.nextDep = link;
|
|
530
|
-
activeSub.depsTail = link;
|
|
531
|
-
}
|
|
532
|
-
addSub(link);
|
|
533
|
-
} else if (link.version === -1) {
|
|
534
|
-
link.version = this.version;
|
|
535
|
-
if (link.nextDep) {
|
|
536
|
-
const next = link.nextDep;
|
|
537
|
-
next.prevDep = link.prevDep;
|
|
538
|
-
if (link.prevDep) link.prevDep.nextDep = next;
|
|
539
|
-
link.prevDep = activeSub.depsTail;
|
|
540
|
-
link.nextDep = void 0;
|
|
541
|
-
activeSub.depsTail.nextDep = link;
|
|
542
|
-
activeSub.depsTail = link;
|
|
543
|
-
if (activeSub.deps === link) activeSub.deps = next;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return link;
|
|
547
|
-
}
|
|
548
|
-
trigger(debugInfo) {
|
|
549
|
-
this.version++;
|
|
550
|
-
globalVersion++;
|
|
551
|
-
this.notify(debugInfo);
|
|
552
|
-
}
|
|
553
|
-
notify(debugInfo) {
|
|
554
|
-
startBatch();
|
|
555
|
-
try {
|
|
556
|
-
for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
|
|
557
|
-
} finally {
|
|
558
|
-
endBatch();
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
function addSub(link) {
|
|
563
|
-
link.dep.sc++;
|
|
564
|
-
if (link.sub.flags & 4) {
|
|
565
|
-
const computed = link.dep.computed;
|
|
566
|
-
if (computed && !link.dep.subs) {
|
|
567
|
-
computed.flags |= 20;
|
|
568
|
-
for (let l = computed.deps; l; l = l.nextDep) addSub(l);
|
|
569
|
-
}
|
|
570
|
-
const currentTail = link.dep.subs;
|
|
571
|
-
if (currentTail !== link) {
|
|
572
|
-
link.prevSub = currentTail;
|
|
573
|
-
if (currentTail) currentTail.nextSub = link;
|
|
574
|
-
}
|
|
575
|
-
link.dep.subs = link;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
579
|
-
const ITERATE_KEY = Symbol("");
|
|
580
|
-
const MAP_KEY_ITERATE_KEY = Symbol("");
|
|
581
|
-
const ARRAY_ITERATE_KEY = Symbol("");
|
|
582
|
-
/**
|
|
583
|
-
* Tracks access to a reactive property.
|
|
584
|
-
*
|
|
585
|
-
* This will check which effect is running at the moment and record it as dep
|
|
586
|
-
* which records all effects that depend on the reactive property.
|
|
587
|
-
*
|
|
588
|
-
* @param target - Object holding the reactive property.
|
|
589
|
-
* @param type - Defines the type of access to the reactive property.
|
|
590
|
-
* @param key - Identifier of the reactive property to track.
|
|
591
|
-
*/
|
|
592
|
-
function track(target, type, key) {
|
|
593
|
-
if (shouldTrack && activeSub) {
|
|
594
|
-
let depsMap = targetMap.get(target);
|
|
595
|
-
if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
596
|
-
let dep = depsMap.get(key);
|
|
597
|
-
if (!dep) {
|
|
598
|
-
depsMap.set(key, dep = new Dep());
|
|
599
|
-
dep.map = depsMap;
|
|
600
|
-
dep.key = key;
|
|
601
|
-
}
|
|
602
|
-
dep.track();
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* Finds all deps associated with the target (or a specific property) and
|
|
607
|
-
* triggers the effects stored within.
|
|
608
|
-
*
|
|
609
|
-
* @param target - The reactive object.
|
|
610
|
-
* @param type - Defines the type of the operation that needs to trigger effects.
|
|
611
|
-
* @param key - Can be used to target a specific reactive property in the target object.
|
|
612
|
-
*/
|
|
613
|
-
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
614
|
-
const depsMap = targetMap.get(target);
|
|
615
|
-
if (!depsMap) {
|
|
616
|
-
globalVersion++;
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
const run = (dep) => {
|
|
620
|
-
if (dep) dep.trigger();
|
|
621
|
-
};
|
|
622
|
-
startBatch();
|
|
623
|
-
if (type === "clear") depsMap.forEach(run);
|
|
624
|
-
else {
|
|
625
|
-
const targetIsArray = isArray(target);
|
|
626
|
-
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
627
|
-
if (targetIsArray && key === "length") {
|
|
628
|
-
const newLength = Number(newValue);
|
|
629
|
-
depsMap.forEach((dep, key) => {
|
|
630
|
-
if (key === "length" || key === ARRAY_ITERATE_KEY || !isSymbol(key) && key >= newLength) run(dep);
|
|
631
|
-
});
|
|
632
|
-
} else {
|
|
633
|
-
if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
|
|
634
|
-
if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
635
|
-
switch (type) {
|
|
636
|
-
case "add":
|
|
637
|
-
if (!targetIsArray) {
|
|
638
|
-
run(depsMap.get(ITERATE_KEY));
|
|
639
|
-
if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
640
|
-
} else if (isArrayIndex) run(depsMap.get("length"));
|
|
641
|
-
break;
|
|
642
|
-
case "delete":
|
|
643
|
-
if (!targetIsArray) {
|
|
644
|
-
run(depsMap.get(ITERATE_KEY));
|
|
645
|
-
if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
646
|
-
}
|
|
647
|
-
break;
|
|
648
|
-
case "set":
|
|
649
|
-
if (isMap(target)) run(depsMap.get(ITERATE_KEY));
|
|
650
|
-
break;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
endBatch();
|
|
655
|
-
}
|
|
656
|
-
//#endregion
|
|
657
|
-
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
658
|
-
/**
|
|
659
|
-
* Track array iteration and return:
|
|
660
|
-
* - if input is reactive: a cloned raw array with reactive values
|
|
661
|
-
* - if input is non-reactive or shallowReactive: the original raw array
|
|
662
|
-
*/
|
|
663
|
-
function reactiveReadArray(array) {
|
|
664
|
-
const raw = /* @__PURE__ */ toRaw(array);
|
|
665
|
-
if (raw === array) return raw;
|
|
666
|
-
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
667
|
-
return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Track array iteration and return raw array
|
|
671
|
-
*/
|
|
672
|
-
function shallowReadArray(arr) {
|
|
673
|
-
track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
674
|
-
return arr;
|
|
675
|
-
}
|
|
676
|
-
function toWrapped(target, item) {
|
|
677
|
-
if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
|
|
678
|
-
return toReactive(item);
|
|
679
|
-
}
|
|
680
|
-
const arrayInstrumentations = {
|
|
681
|
-
__proto__: null,
|
|
682
|
-
[Symbol.iterator]() {
|
|
683
|
-
return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
|
|
684
|
-
},
|
|
685
|
-
concat(...args) {
|
|
686
|
-
return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
|
|
687
|
-
},
|
|
688
|
-
entries() {
|
|
689
|
-
return iterator(this, "entries", (value) => {
|
|
690
|
-
value[1] = toWrapped(this, value[1]);
|
|
691
|
-
return value;
|
|
692
|
-
});
|
|
693
|
-
},
|
|
694
|
-
every(fn, thisArg) {
|
|
695
|
-
return apply(this, "every", fn, thisArg, void 0, arguments);
|
|
696
|
-
},
|
|
697
|
-
filter(fn, thisArg) {
|
|
698
|
-
return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
|
|
699
|
-
},
|
|
700
|
-
find(fn, thisArg) {
|
|
701
|
-
return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
702
|
-
},
|
|
703
|
-
findIndex(fn, thisArg) {
|
|
704
|
-
return apply(this, "findIndex", fn, thisArg, void 0, arguments);
|
|
705
|
-
},
|
|
706
|
-
findLast(fn, thisArg) {
|
|
707
|
-
return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
708
|
-
},
|
|
709
|
-
findLastIndex(fn, thisArg) {
|
|
710
|
-
return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
|
711
|
-
},
|
|
712
|
-
forEach(fn, thisArg) {
|
|
713
|
-
return apply(this, "forEach", fn, thisArg, void 0, arguments);
|
|
714
|
-
},
|
|
715
|
-
includes(...args) {
|
|
716
|
-
return searchProxy(this, "includes", args);
|
|
717
|
-
},
|
|
718
|
-
indexOf(...args) {
|
|
719
|
-
return searchProxy(this, "indexOf", args);
|
|
720
|
-
},
|
|
721
|
-
join(separator) {
|
|
722
|
-
return reactiveReadArray(this).join(separator);
|
|
723
|
-
},
|
|
724
|
-
lastIndexOf(...args) {
|
|
725
|
-
return searchProxy(this, "lastIndexOf", args);
|
|
726
|
-
},
|
|
727
|
-
map(fn, thisArg) {
|
|
728
|
-
return apply(this, "map", fn, thisArg, void 0, arguments);
|
|
729
|
-
},
|
|
730
|
-
pop() {
|
|
731
|
-
return noTracking(this, "pop");
|
|
732
|
-
},
|
|
733
|
-
push(...args) {
|
|
734
|
-
return noTracking(this, "push", args);
|
|
735
|
-
},
|
|
736
|
-
reduce(fn, ...args) {
|
|
737
|
-
return reduce(this, "reduce", fn, args);
|
|
738
|
-
},
|
|
739
|
-
reduceRight(fn, ...args) {
|
|
740
|
-
return reduce(this, "reduceRight", fn, args);
|
|
741
|
-
},
|
|
742
|
-
shift() {
|
|
743
|
-
return noTracking(this, "shift");
|
|
744
|
-
},
|
|
745
|
-
some(fn, thisArg) {
|
|
746
|
-
return apply(this, "some", fn, thisArg, void 0, arguments);
|
|
747
|
-
},
|
|
748
|
-
splice(...args) {
|
|
749
|
-
return noTracking(this, "splice", args);
|
|
750
|
-
},
|
|
751
|
-
toReversed() {
|
|
752
|
-
return reactiveReadArray(this).toReversed();
|
|
753
|
-
},
|
|
754
|
-
toSorted(comparer) {
|
|
755
|
-
return reactiveReadArray(this).toSorted(comparer);
|
|
756
|
-
},
|
|
757
|
-
toSpliced(...args) {
|
|
758
|
-
return reactiveReadArray(this).toSpliced(...args);
|
|
759
|
-
},
|
|
760
|
-
unshift(...args) {
|
|
761
|
-
return noTracking(this, "unshift", args);
|
|
762
|
-
},
|
|
763
|
-
values() {
|
|
764
|
-
return iterator(this, "values", (item) => toWrapped(this, item));
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
function iterator(self, method, wrapValue) {
|
|
768
|
-
const arr = shallowReadArray(self);
|
|
769
|
-
const iter = arr[method]();
|
|
770
|
-
if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
|
|
771
|
-
iter._next = iter.next;
|
|
772
|
-
iter.next = () => {
|
|
773
|
-
const result = iter._next();
|
|
774
|
-
if (!result.done) result.value = wrapValue(result.value);
|
|
775
|
-
return result;
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
return iter;
|
|
779
|
-
}
|
|
780
|
-
const arrayProto = Array.prototype;
|
|
781
|
-
function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
782
|
-
const arr = shallowReadArray(self);
|
|
783
|
-
const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
|
|
784
|
-
const methodFn = arr[method];
|
|
785
|
-
if (methodFn !== arrayProto[method]) {
|
|
786
|
-
const result = methodFn.apply(self, args);
|
|
787
|
-
return needsWrap ? toReactive(result) : result;
|
|
788
|
-
}
|
|
789
|
-
let wrappedFn = fn;
|
|
790
|
-
if (arr !== self) {
|
|
791
|
-
if (needsWrap) wrappedFn = function(item, index) {
|
|
792
|
-
return fn.call(this, toWrapped(self, item), index, self);
|
|
793
|
-
};
|
|
794
|
-
else if (fn.length > 2) wrappedFn = function(item, index) {
|
|
795
|
-
return fn.call(this, item, index, self);
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
799
|
-
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
800
|
-
}
|
|
801
|
-
function reduce(self, method, fn, args) {
|
|
802
|
-
const arr = shallowReadArray(self);
|
|
803
|
-
const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
|
|
804
|
-
let wrappedFn = fn;
|
|
805
|
-
let wrapInitialAccumulator = false;
|
|
806
|
-
if (arr !== self) {
|
|
807
|
-
if (needsWrap) {
|
|
808
|
-
wrapInitialAccumulator = args.length === 0;
|
|
809
|
-
wrappedFn = function(acc, item, index) {
|
|
810
|
-
if (wrapInitialAccumulator) {
|
|
811
|
-
wrapInitialAccumulator = false;
|
|
812
|
-
acc = toWrapped(self, acc);
|
|
813
|
-
}
|
|
814
|
-
return fn.call(this, acc, toWrapped(self, item), index, self);
|
|
815
|
-
};
|
|
816
|
-
} else if (fn.length > 3) wrappedFn = function(acc, item, index) {
|
|
817
|
-
return fn.call(this, acc, item, index, self);
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
const result = arr[method](wrappedFn, ...args);
|
|
821
|
-
return wrapInitialAccumulator ? toWrapped(self, result) : result;
|
|
822
|
-
}
|
|
823
|
-
function searchProxy(self, method, args) {
|
|
824
|
-
const arr = /* @__PURE__ */ toRaw(self);
|
|
825
|
-
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
826
|
-
const res = arr[method](...args);
|
|
827
|
-
if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
|
|
828
|
-
args[0] = /* @__PURE__ */ toRaw(args[0]);
|
|
829
|
-
return arr[method](...args);
|
|
830
|
-
}
|
|
831
|
-
return res;
|
|
832
|
-
}
|
|
833
|
-
function noTracking(self, method, args = []) {
|
|
834
|
-
pauseTracking();
|
|
835
|
-
startBatch();
|
|
836
|
-
const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
|
|
837
|
-
endBatch();
|
|
838
|
-
resetTracking();
|
|
839
|
-
return res;
|
|
840
42
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
849
|
-
function ref(value) {
|
|
850
|
-
return createRef(value, false);
|
|
851
|
-
}
|
|
852
|
-
function createRef(rawValue, shallow) {
|
|
853
|
-
if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
|
|
854
|
-
return new RefImpl(rawValue, shallow);
|
|
855
|
-
}
|
|
856
|
-
_ReactiveFlags$IS_REF = "__v_isRef";
|
|
857
|
-
_ReactiveFlags$IS_SHA = "__v_isShallow";
|
|
858
|
-
/**
|
|
859
|
-
* @internal
|
|
860
|
-
*/
|
|
861
|
-
var RefImpl = class {
|
|
862
|
-
constructor(value, isShallow) {
|
|
863
|
-
this.dep = new Dep();
|
|
864
|
-
this[_ReactiveFlags$IS_REF] = true;
|
|
865
|
-
this[_ReactiveFlags$IS_SHA] = false;
|
|
866
|
-
this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
|
|
867
|
-
this._value = isShallow ? value : toReactive(value);
|
|
868
|
-
this["__v_isShallow"] = isShallow;
|
|
869
|
-
}
|
|
870
|
-
get value() {
|
|
871
|
-
this.dep.track();
|
|
872
|
-
return this._value;
|
|
873
|
-
}
|
|
874
|
-
set value(newValue) {
|
|
875
|
-
const oldValue = this._rawValue;
|
|
876
|
-
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
877
|
-
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
878
|
-
if (hasChanged(newValue, oldValue)) {
|
|
879
|
-
this._rawValue = newValue;
|
|
880
|
-
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
881
|
-
this.dep.trigger();
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
//#endregion
|
|
886
|
-
//#region packages/core/signal/src/baseHandlers.ts
|
|
887
|
-
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
888
|
-
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
889
|
-
function hasOwnProperty(key) {
|
|
890
|
-
if (!isSymbol(key)) key = String(key);
|
|
891
|
-
const obj = /* @__PURE__ */ toRaw(this);
|
|
892
|
-
track(obj, "has", key);
|
|
893
|
-
return obj.hasOwnProperty(key);
|
|
894
|
-
}
|
|
895
|
-
var BaseReactiveHandler = class {
|
|
896
|
-
constructor(_isReadonly = false, _isShallow = false) {
|
|
897
|
-
this._isReadonly = _isReadonly;
|
|
898
|
-
this._isShallow = _isShallow;
|
|
899
|
-
}
|
|
900
|
-
get(target, key, receiver) {
|
|
901
|
-
if (key === "__v_skip") return target["__v_skip"];
|
|
902
|
-
const isReadonly = this._isReadonly, isShallow = this._isShallow;
|
|
903
|
-
if (key === "__v_isReactive") return !isReadonly;
|
|
904
|
-
else if (key === "__v_isReadonly") return isReadonly;
|
|
905
|
-
else if (key === "__v_isShallow") return isShallow;
|
|
906
|
-
else if (key === "__v_raw") {
|
|
907
|
-
if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
const targetIsArray = isArray(target);
|
|
911
|
-
if (!isReadonly) {
|
|
912
|
-
let fn;
|
|
913
|
-
if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
|
|
914
|
-
if (key === "hasOwnProperty") return hasOwnProperty;
|
|
915
|
-
}
|
|
916
|
-
const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
917
|
-
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
|
|
918
|
-
if (!isReadonly) track(target, "get", key);
|
|
919
|
-
if (isShallow) return res;
|
|
920
|
-
if (/* @__PURE__ */ isRef(res)) {
|
|
921
|
-
const value = targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
922
|
-
return isReadonly && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
923
|
-
}
|
|
924
|
-
if (isObject(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
|
|
925
|
-
return res;
|
|
926
|
-
}
|
|
927
|
-
};
|
|
928
|
-
var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
929
|
-
constructor(isShallow = false) {
|
|
930
|
-
super(false, isShallow);
|
|
931
|
-
}
|
|
932
|
-
set(target, key, value, receiver) {
|
|
933
|
-
let oldValue = target[key];
|
|
934
|
-
const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
|
|
935
|
-
if (!this._isShallow) {
|
|
936
|
-
const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
|
|
937
|
-
if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
|
|
938
|
-
oldValue = /* @__PURE__ */ toRaw(oldValue);
|
|
939
|
-
value = /* @__PURE__ */ toRaw(value);
|
|
940
|
-
}
|
|
941
|
-
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) return true;
|
|
942
|
-
else {
|
|
943
|
-
oldValue.value = value;
|
|
944
|
-
return true;
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
|
|
948
|
-
const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
949
|
-
if (target === /* @__PURE__ */ toRaw(receiver)) {
|
|
950
|
-
if (!hadKey) trigger(target, "add", key, value);
|
|
951
|
-
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
952
|
-
}
|
|
953
|
-
return result;
|
|
954
|
-
}
|
|
955
|
-
deleteProperty(target, key) {
|
|
956
|
-
const hadKey = hasOwn(target, key);
|
|
957
|
-
const oldValue = target[key];
|
|
958
|
-
const result = Reflect.deleteProperty(target, key);
|
|
959
|
-
if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
960
|
-
return result;
|
|
961
|
-
}
|
|
962
|
-
has(target, key) {
|
|
963
|
-
const result = Reflect.has(target, key);
|
|
964
|
-
if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
|
|
965
|
-
return result;
|
|
966
|
-
}
|
|
967
|
-
ownKeys(target) {
|
|
968
|
-
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
969
|
-
return Reflect.ownKeys(target);
|
|
970
|
-
}
|
|
971
|
-
};
|
|
972
|
-
var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
973
|
-
constructor(isShallow = false) {
|
|
974
|
-
super(true, isShallow);
|
|
975
|
-
}
|
|
976
|
-
set(target, key) {
|
|
977
|
-
return true;
|
|
978
|
-
}
|
|
979
|
-
deleteProperty(target, key) {
|
|
980
|
-
return true;
|
|
981
|
-
}
|
|
982
|
-
};
|
|
983
|
-
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
984
|
-
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
985
|
-
//#endregion
|
|
986
|
-
//#region packages/core/signal/src/collectionHandlers.ts
|
|
987
|
-
const toShallow = (value) => value;
|
|
988
|
-
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
989
|
-
function createIterableMethod(method, isReadonly, isShallow) {
|
|
990
|
-
return function(...args) {
|
|
991
|
-
const target = this["__v_raw"];
|
|
992
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
993
|
-
const targetIsMap = isMap(rawTarget);
|
|
994
|
-
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
995
|
-
const isKeyOnly = method === "keys" && targetIsMap;
|
|
996
|
-
const innerIterator = target[method](...args);
|
|
997
|
-
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
|
998
|
-
!isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
999
|
-
return extend(Object.create(innerIterator), { next() {
|
|
1000
|
-
const { value, done } = innerIterator.next();
|
|
1001
|
-
return done ? {
|
|
1002
|
-
value,
|
|
1003
|
-
done
|
|
1004
|
-
} : {
|
|
1005
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
1006
|
-
done
|
|
1007
|
-
};
|
|
1008
|
-
} });
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
function createReadonlyMethod(type) {
|
|
1012
|
-
return function(...args) {
|
|
1013
|
-
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
1014
|
-
};
|
|
1015
|
-
}
|
|
1016
|
-
function createInstrumentations(readonly, shallow) {
|
|
1017
|
-
const instrumentations = {
|
|
1018
|
-
get(key) {
|
|
1019
|
-
const target = this["__v_raw"];
|
|
1020
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1021
|
-
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
1022
|
-
if (!readonly) {
|
|
1023
|
-
if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
|
|
1024
|
-
track(rawTarget, "get", rawKey);
|
|
1025
|
-
}
|
|
1026
|
-
const { has } = getProto(rawTarget);
|
|
1027
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1028
|
-
if (has.call(rawTarget, key)) return wrap(target.get(key));
|
|
1029
|
-
else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
|
|
1030
|
-
else if (target !== rawTarget) target.get(key);
|
|
1031
|
-
},
|
|
1032
|
-
get size() {
|
|
1033
|
-
const target = this["__v_raw"];
|
|
1034
|
-
!readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
|
|
1035
|
-
return target.size;
|
|
1036
|
-
},
|
|
1037
|
-
has(key) {
|
|
1038
|
-
const target = this["__v_raw"];
|
|
1039
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1040
|
-
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
1041
|
-
if (!readonly) {
|
|
1042
|
-
if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
|
|
1043
|
-
track(rawTarget, "has", rawKey);
|
|
1044
|
-
}
|
|
1045
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1046
|
-
},
|
|
1047
|
-
forEach(callback, thisArg) {
|
|
1048
|
-
const observed = this;
|
|
1049
|
-
const target = observed["__v_raw"];
|
|
1050
|
-
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
1051
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1052
|
-
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1053
|
-
return target.forEach((value, key) => {
|
|
1054
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
};
|
|
1058
|
-
extend(instrumentations, readonly ? {
|
|
1059
|
-
add: createReadonlyMethod("add"),
|
|
1060
|
-
set: createReadonlyMethod("set"),
|
|
1061
|
-
delete: createReadonlyMethod("delete"),
|
|
1062
|
-
clear: createReadonlyMethod("clear")
|
|
1063
|
-
} : {
|
|
1064
|
-
add(value) {
|
|
1065
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1066
|
-
const proto = getProto(target);
|
|
1067
|
-
const rawValue = /* @__PURE__ */ toRaw(value);
|
|
1068
|
-
const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
|
|
1069
|
-
if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
|
|
1070
|
-
target.add(valueToAdd);
|
|
1071
|
-
trigger(target, "add", valueToAdd, valueToAdd);
|
|
1072
|
-
}
|
|
1073
|
-
return this;
|
|
1074
|
-
},
|
|
1075
|
-
set(key, value) {
|
|
1076
|
-
if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
|
|
1077
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1078
|
-
const { has, get } = getProto(target);
|
|
1079
|
-
let hadKey = has.call(target, key);
|
|
1080
|
-
if (!hadKey) {
|
|
1081
|
-
key = /* @__PURE__ */ toRaw(key);
|
|
1082
|
-
hadKey = has.call(target, key);
|
|
1083
|
-
}
|
|
1084
|
-
const oldValue = get.call(target, key);
|
|
1085
|
-
target.set(key, value);
|
|
1086
|
-
if (!hadKey) trigger(target, "add", key, value);
|
|
1087
|
-
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
1088
|
-
return this;
|
|
1089
|
-
},
|
|
1090
|
-
delete(key) {
|
|
1091
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1092
|
-
const { has, get } = getProto(target);
|
|
1093
|
-
let hadKey = has.call(target, key);
|
|
1094
|
-
if (!hadKey) {
|
|
1095
|
-
key = /* @__PURE__ */ toRaw(key);
|
|
1096
|
-
hadKey = has.call(target, key);
|
|
1097
|
-
}
|
|
1098
|
-
const oldValue = get ? get.call(target, key) : void 0;
|
|
1099
|
-
const result = target.delete(key);
|
|
1100
|
-
if (hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
1101
|
-
return result;
|
|
1102
|
-
},
|
|
1103
|
-
clear() {
|
|
1104
|
-
const target = /* @__PURE__ */ toRaw(this);
|
|
1105
|
-
const hadItems = target.size !== 0;
|
|
1106
|
-
const oldTarget = void 0;
|
|
1107
|
-
const result = target.clear();
|
|
1108
|
-
if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
|
|
1109
|
-
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;
|
|
1110
50
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
"keys",
|
|
1114
|
-
"values",
|
|
1115
|
-
"entries",
|
|
1116
|
-
Symbol.iterator
|
|
1117
|
-
].forEach((method) => {
|
|
1118
|
-
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
1119
|
-
});
|
|
1120
|
-
return instrumentations;
|
|
1121
|
-
}
|
|
1122
|
-
function createInstrumentationGetter(isReadonly, shallow) {
|
|
1123
|
-
const instrumentations = createInstrumentations(isReadonly, shallow);
|
|
1124
|
-
return (target, key, receiver) => {
|
|
1125
|
-
if (key === "__v_isReactive") return !isReadonly;
|
|
1126
|
-
else if (key === "__v_isReadonly") return isReadonly;
|
|
1127
|
-
else if (key === "__v_raw") return target;
|
|
1128
|
-
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
|
|
1132
|
-
const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
|
|
1133
|
-
//#endregion
|
|
1134
|
-
//#region packages/core/signal/src/reactive.ts
|
|
1135
|
-
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1136
|
-
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1137
|
-
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1138
|
-
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1139
|
-
function targetTypeMap(rawType) {
|
|
1140
|
-
switch (rawType) {
|
|
1141
|
-
case "Object":
|
|
1142
|
-
case "Array": return 1;
|
|
1143
|
-
case "Map":
|
|
1144
|
-
case "Set":
|
|
1145
|
-
case "WeakMap":
|
|
1146
|
-
case "WeakSet": return 2;
|
|
1147
|
-
default: return 0;
|
|
51
|
+
const root = current.getRootNode();
|
|
52
|
+
current = "host" in root ? root.host : null;
|
|
1148
53
|
}
|
|
1149
|
-
|
|
1150
|
-
function getTargetType(value) {
|
|
1151
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
1152
|
-
}
|
|
1153
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1154
|
-
function reactive(target) {
|
|
1155
|
-
if (/* @__PURE__ */ isReadonly(target)) return target;
|
|
1156
|
-
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
1157
|
-
}
|
|
1158
|
-
/**
|
|
1159
|
-
* Takes an object (reactive or plain) or a ref and returns a readonly proxy to
|
|
1160
|
-
* the original.
|
|
1161
|
-
*
|
|
1162
|
-
* A readonly proxy is deep: any nested property accessed will be readonly as
|
|
1163
|
-
* well. It also has the same ref-unwrapping behavior as {@link reactive},
|
|
1164
|
-
* except the unwrapped values will also be made readonly.
|
|
1165
|
-
*
|
|
1166
|
-
* @example
|
|
1167
|
-
* ```js
|
|
1168
|
-
* const original = reactive({ count: 0 })
|
|
1169
|
-
*
|
|
1170
|
-
* const copy = readonly(original)
|
|
1171
|
-
*
|
|
1172
|
-
* watchEffect(() => {
|
|
1173
|
-
* // works for reactivity tracking
|
|
1174
|
-
* console.log(copy.count)
|
|
1175
|
-
* })
|
|
1176
|
-
*
|
|
1177
|
-
* // mutating original will trigger watchers relying on the copy
|
|
1178
|
-
* original.count++
|
|
1179
|
-
*
|
|
1180
|
-
* // mutating the copy will fail and result in a warning
|
|
1181
|
-
* copy.count++ // warning!
|
|
1182
|
-
* ```
|
|
1183
|
-
*
|
|
1184
|
-
* @param target - The source object.
|
|
1185
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
1186
|
-
*/
|
|
1187
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1188
|
-
function readonly(target) {
|
|
1189
|
-
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
1190
|
-
}
|
|
1191
|
-
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
|
1192
|
-
if (!isObject(target)) return target;
|
|
1193
|
-
if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
|
|
1194
|
-
const targetType = getTargetType(target);
|
|
1195
|
-
if (targetType === 0) return target;
|
|
1196
|
-
const existingProxy = proxyMap.get(target);
|
|
1197
|
-
if (existingProxy) return existingProxy;
|
|
1198
|
-
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
1199
|
-
proxyMap.set(target, proxy);
|
|
1200
|
-
return proxy;
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* Checks if an object is a proxy created by {@link reactive} or
|
|
1204
|
-
* {@link shallowReactive} (or {@link ref} in some cases).
|
|
1205
|
-
*
|
|
1206
|
-
* @example
|
|
1207
|
-
* ```js
|
|
1208
|
-
* isReactive(reactive({})) // => true
|
|
1209
|
-
* isReactive(readonly(reactive({}))) // => true
|
|
1210
|
-
* isReactive(ref({}).value) // => true
|
|
1211
|
-
* isReactive(readonly(ref({})).value) // => true
|
|
1212
|
-
* isReactive(ref(true)) // => false
|
|
1213
|
-
* isReactive(shallowRef({}).value) // => false
|
|
1214
|
-
* isReactive(shallowReactive({})) // => true
|
|
1215
|
-
* ```
|
|
1216
|
-
*
|
|
1217
|
-
* @param value - The value to check.
|
|
1218
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
1219
|
-
*/
|
|
1220
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1221
|
-
function isReactive(value) {
|
|
1222
|
-
if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
1223
|
-
return !!(value && value["__v_isReactive"]);
|
|
1224
|
-
}
|
|
1225
|
-
/**
|
|
1226
|
-
* Checks whether the passed value is a readonly object. The properties of a
|
|
1227
|
-
* readonly object can change, but they can't be assigned directly via the
|
|
1228
|
-
* passed object.
|
|
1229
|
-
*
|
|
1230
|
-
* The proxies created by {@link readonly} and {@link shallowReadonly} are
|
|
1231
|
-
* both considered readonly, as is a computed ref without a set function.
|
|
1232
|
-
*
|
|
1233
|
-
* @param value - The value to check.
|
|
1234
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
1235
|
-
*/
|
|
1236
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1237
|
-
function isReadonly(value) {
|
|
1238
|
-
return !!(value && value["__v_isReadonly"]);
|
|
1239
|
-
}
|
|
1240
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1241
|
-
function isShallow(value) {
|
|
1242
|
-
return !!(value && value["__v_isShallow"]);
|
|
1243
|
-
}
|
|
1244
|
-
/**
|
|
1245
|
-
* Checks if an object is a proxy created by {@link reactive},
|
|
1246
|
-
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
|
|
1247
|
-
*
|
|
1248
|
-
* @param value - The value to check.
|
|
1249
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
1250
|
-
*/
|
|
1251
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1252
|
-
function isProxy(value) {
|
|
1253
|
-
return value ? !!value["__v_raw"] : false;
|
|
1254
|
-
}
|
|
1255
|
-
/**
|
|
1256
|
-
* Returns the raw, original object of a Vue-created proxy.
|
|
1257
|
-
*
|
|
1258
|
-
* `toRaw()` can return the original object from proxies created by
|
|
1259
|
-
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
1260
|
-
* {@link shallowReadonly}.
|
|
1261
|
-
*
|
|
1262
|
-
* This is an escape hatch that can be used to temporarily read without
|
|
1263
|
-
* incurring proxy access / tracking overhead or write without triggering
|
|
1264
|
-
* changes. It is **not** recommended to hold a persistent reference to the
|
|
1265
|
-
* original object. Use with caution.
|
|
1266
|
-
*
|
|
1267
|
-
* @example
|
|
1268
|
-
* ```js
|
|
1269
|
-
* const foo = {}
|
|
1270
|
-
* const reactiveFoo = reactive(foo)
|
|
1271
|
-
*
|
|
1272
|
-
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
1273
|
-
* ```
|
|
1274
|
-
*
|
|
1275
|
-
* @param observed - The object for which the "raw" value is requested.
|
|
1276
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
1277
|
-
*/
|
|
1278
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
1279
|
-
function toRaw(observed) {
|
|
1280
|
-
const raw = observed && observed["__v_raw"];
|
|
1281
|
-
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
1282
|
-
}
|
|
1283
|
-
/**
|
|
1284
|
-
* Returns a reactive proxy of the given value (if possible).
|
|
1285
|
-
*
|
|
1286
|
-
* If the given value is not an object, the original value itself is returned.
|
|
1287
|
-
*
|
|
1288
|
-
* @param value - The value for which a reactive proxy shall be created.
|
|
1289
|
-
*/
|
|
1290
|
-
const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
|
|
1291
|
-
/**
|
|
1292
|
-
* Returns a readonly proxy of the given value (if possible).
|
|
1293
|
-
*
|
|
1294
|
-
* If the given value is not an object, the original value itself is returned.
|
|
1295
|
-
*
|
|
1296
|
-
* @param value - The value for which a readonly proxy shall be created.
|
|
1297
|
-
*/
|
|
1298
|
-
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1299
|
-
//#endregion
|
|
1300
|
-
//#region packages/core/signal/src/state.ts
|
|
1301
|
-
function state(value) {
|
|
1302
|
-
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1303
|
-
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
1304
|
-
}
|
|
1305
|
-
function isProxyable(value) {
|
|
1306
|
-
if (value === null || typeof value !== "object") return false;
|
|
1307
|
-
if (Array.isArray(value)) return true;
|
|
1308
|
-
if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
|
|
1309
|
-
return isPlainObject(value);
|
|
1310
|
-
}
|
|
1311
|
-
function isPlainObject(value) {
|
|
1312
|
-
const proto = Object.getPrototypeOf(value);
|
|
1313
|
-
return proto === Object.prototype || proto === null;
|
|
54
|
+
return false;
|
|
1314
55
|
}
|
|
1315
56
|
//#endregion
|
|
1316
57
|
//#region packages/core/runtime-dom/src/domOwnership.ts
|
|
@@ -1347,6 +88,14 @@ function insertTracked(parent, value, marker = null) {
|
|
|
1347
88
|
for (const item of value) nodes.push(...insertTracked(parent, item, marker));
|
|
1348
89
|
return nodes;
|
|
1349
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
|
+
}
|
|
1350
99
|
const node = value instanceof Node ? value : document.createTextNode(String(value));
|
|
1351
100
|
trackRuntimeDomInsertion(parent, node);
|
|
1352
101
|
parent.insertBefore(node, marker);
|
|
@@ -1361,7 +110,7 @@ function removeNodes$1(nodes) {
|
|
|
1361
110
|
function moveRangeBefore(nodes, parent, marker = null) {
|
|
1362
111
|
for (const node of nodes) {
|
|
1363
112
|
trackRuntimeDomInsertion(parent, node);
|
|
1364
|
-
parent
|
|
113
|
+
moveNodeBefore(parent, node, marker);
|
|
1365
114
|
}
|
|
1366
115
|
}
|
|
1367
116
|
//#endregion
|
|
@@ -1405,11 +154,12 @@ var ScopedSubtree = class {
|
|
|
1405
154
|
}
|
|
1406
155
|
replace(render) {
|
|
1407
156
|
this.dispose();
|
|
1408
|
-
const scope = effectScope(true);
|
|
157
|
+
const scope = (0, _zeus_js_signal_internal.effectScope)(true);
|
|
158
|
+
const parent = this.resolveParent(this.marker);
|
|
1409
159
|
let nodes = [];
|
|
1410
160
|
try {
|
|
1411
161
|
scope.run(() => {
|
|
1412
|
-
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)));
|
|
1413
163
|
});
|
|
1414
164
|
} catch (error) {
|
|
1415
165
|
scope.stop();
|
|
@@ -1427,11 +177,15 @@ var ScopedSubtree = class {
|
|
|
1427
177
|
this.nodes = [];
|
|
1428
178
|
}
|
|
1429
179
|
moveBefore(marker) {
|
|
1430
|
-
moveRangeBefore(this.nodes, this.
|
|
180
|
+
moveRangeBefore(this.nodes, this.resolveParent(marker), marker);
|
|
1431
181
|
}
|
|
1432
182
|
current() {
|
|
1433
183
|
return this.nodes;
|
|
1434
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
|
+
}
|
|
1435
189
|
};
|
|
1436
190
|
//#endregion
|
|
1437
191
|
//#region packages/core/runtime-dom/src/insert.ts
|
|
@@ -1441,11 +195,11 @@ function insert(parent, value, marker = null) {
|
|
|
1441
195
|
}
|
|
1442
196
|
function mountDynamic(parent, marker, value) {
|
|
1443
197
|
const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
|
|
1444
|
-
const runner = effect(() => {
|
|
198
|
+
const runner = (0, _zeus_js_signal_internal.effect)(() => {
|
|
1445
199
|
subtree.replace(value);
|
|
1446
200
|
});
|
|
1447
|
-
onScopeDispose(() => {
|
|
1448
|
-
stop(runner);
|
|
201
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
202
|
+
(0, _zeus_js_signal_internal.stop)(runner);
|
|
1449
203
|
subtree.dispose();
|
|
1450
204
|
}, true);
|
|
1451
205
|
}
|
|
@@ -1536,7 +290,7 @@ function provideDOMContext(target, context, value) {
|
|
|
1536
290
|
request.detail.resolve(value);
|
|
1537
291
|
};
|
|
1538
292
|
target.addEventListener(ZEUS_CONTEXT_REQUEST, handler);
|
|
1539
|
-
onScopeDispose(() => {
|
|
293
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
1540
294
|
target.removeEventListener(ZEUS_CONTEXT_REQUEST, handler);
|
|
1541
295
|
}, true);
|
|
1542
296
|
}
|
|
@@ -1586,7 +340,7 @@ function emitDevtoolsEvent(event) {
|
|
|
1586
340
|
//#region packages/core/runtime-dom/src/render.ts
|
|
1587
341
|
function render(value, container, options = {}) {
|
|
1588
342
|
var _options$owner;
|
|
1589
|
-
const renderScope =
|
|
343
|
+
const renderScope = (0, _zeus_js_signal_internal.scope)();
|
|
1590
344
|
const owner = (_options$owner = options.owner) !== null && _options$owner !== void 0 ? _options$owner : createOwner();
|
|
1591
345
|
renderScope.run(() => {
|
|
1592
346
|
container.textContent = "";
|
|
@@ -1635,14 +389,23 @@ function removeNodes(nodes) {
|
|
|
1635
389
|
}
|
|
1636
390
|
//#endregion
|
|
1637
391
|
//#region packages/core/runtime-dom/src/bindings.ts
|
|
1638
|
-
function bindText(node, value) {
|
|
1639
|
-
|
|
1640
|
-
node.data = stringifyText(
|
|
392
|
+
function bindText(node, value, once = false) {
|
|
393
|
+
applyBinding(value, once, (next) => {
|
|
394
|
+
node.data = stringifyText(next);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function bindTextContent(el, value, once = false) {
|
|
398
|
+
applyBinding(value, once, (next) => {
|
|
399
|
+
el.textContent = stringifyText(next);
|
|
1641
400
|
});
|
|
1642
401
|
}
|
|
1643
|
-
function
|
|
1644
|
-
|
|
1645
|
-
|
|
402
|
+
function applyBinding(value, once, apply) {
|
|
403
|
+
if (once) {
|
|
404
|
+
(0, _zeus_js_signal_internal.untrack)(() => apply(value()));
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
(0, _zeus_js_signal_internal.effect)(() => {
|
|
408
|
+
apply(value());
|
|
1646
409
|
});
|
|
1647
410
|
}
|
|
1648
411
|
function stringifyText(value) {
|
|
@@ -1695,19 +458,19 @@ const BOOLEAN_DOM_PROPERTY_NAME = {
|
|
|
1695
458
|
function normalizeAttrName(name) {
|
|
1696
459
|
return name === "className" ? "class" : name;
|
|
1697
460
|
}
|
|
1698
|
-
function bindAttr(el, name, value) {
|
|
1699
|
-
|
|
1700
|
-
setAttr(el, name,
|
|
461
|
+
function bindAttr(el, name, value, once = false) {
|
|
462
|
+
applyBinding(value, once, (next) => {
|
|
463
|
+
setAttr(el, name, next);
|
|
1701
464
|
});
|
|
1702
465
|
}
|
|
1703
|
-
function bindProp(el, name, value) {
|
|
1704
|
-
|
|
1705
|
-
el[name] =
|
|
466
|
+
function bindProp(el, name, value, once = false) {
|
|
467
|
+
applyBinding(value, once, (next) => {
|
|
468
|
+
el[name] = next;
|
|
1706
469
|
});
|
|
1707
470
|
}
|
|
1708
|
-
function bindClass(el, value) {
|
|
1709
|
-
|
|
1710
|
-
const next = normalizeClass(value
|
|
471
|
+
function bindClass(el, value, once = false) {
|
|
472
|
+
applyBinding(value, once, (value) => {
|
|
473
|
+
const next = normalizeClass(value);
|
|
1711
474
|
if (next) el.setAttribute("class", next);
|
|
1712
475
|
else el.removeAttribute("class");
|
|
1713
476
|
});
|
|
@@ -1719,10 +482,9 @@ function normalizeClass(value) {
|
|
|
1719
482
|
if (typeof value === "object") return Object.keys(value).filter((key) => value[key]).join(" ");
|
|
1720
483
|
return "";
|
|
1721
484
|
}
|
|
1722
|
-
function bindStyle(el, value) {
|
|
485
|
+
function bindStyle(el, value, once = false) {
|
|
1723
486
|
let prev;
|
|
1724
|
-
|
|
1725
|
-
const next = value();
|
|
487
|
+
applyBinding(value, once, (next) => {
|
|
1726
488
|
if (next == null) {
|
|
1727
489
|
el.removeAttribute("style");
|
|
1728
490
|
prev = void 0;
|
|
@@ -1781,7 +543,7 @@ function bindEvent(el, name, handler) {
|
|
|
1781
543
|
const target = el;
|
|
1782
544
|
const events = target.__zeusEvents || (target.__zeusEvents = {});
|
|
1783
545
|
events[name] = handler;
|
|
1784
|
-
onScopeDispose(() => {
|
|
546
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
1785
547
|
var _target$__zeusEvents;
|
|
1786
548
|
if (((_target$__zeusEvents = target.__zeusEvents) === null || _target$__zeusEvents === void 0 ? void 0 : _target$__zeusEvents[name]) === handler) delete target.__zeusEvents[name];
|
|
1787
549
|
}, true);
|
|
@@ -1863,7 +625,7 @@ function setRef(target, value) {
|
|
|
1863
625
|
}
|
|
1864
626
|
function bindRef(el, target) {
|
|
1865
627
|
setRef(target, el);
|
|
1866
|
-
if (getCurrentScope()) onScopeDispose(() => {
|
|
628
|
+
if ((0, _zeus_js_signal_internal.getCurrentScope)()) (0, _zeus_js_signal_internal.onScopeDispose)(() => {
|
|
1867
629
|
setRef(target, null);
|
|
1868
630
|
}, true);
|
|
1869
631
|
}
|
|
@@ -1877,6 +639,30 @@ function createComponent(component, props) {
|
|
|
1877
639
|
function disposeListRecord(record) {
|
|
1878
640
|
record.subtree.dispose();
|
|
1879
641
|
}
|
|
642
|
+
function isImmediatelyBefore(record, anchor) {
|
|
643
|
+
const nodes = record.subtree.current();
|
|
644
|
+
const last = nodes[nodes.length - 1];
|
|
645
|
+
return last === void 0 || last.nextSibling === anchor;
|
|
646
|
+
}
|
|
647
|
+
function containsNode(record, node) {
|
|
648
|
+
let current = node;
|
|
649
|
+
while (current) {
|
|
650
|
+
if (record.subtree.current().some((root) => root === current || root.contains(current))) return true;
|
|
651
|
+
const treeRoot = current.getRootNode();
|
|
652
|
+
current = "host" in treeRoot ? treeRoot.host : null;
|
|
653
|
+
}
|
|
654
|
+
return false;
|
|
655
|
+
}
|
|
656
|
+
function getDeepestActiveElement(parent) {
|
|
657
|
+
var _parent$ownerDocument, _parent$ownerDocument2, _active$shadowRoot;
|
|
658
|
+
const treeRoot = parent.getRootNode();
|
|
659
|
+
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;
|
|
660
|
+
while (active === null || active === void 0 || (_active$shadowRoot = active.shadowRoot) === null || _active$shadowRoot === void 0 ? void 0 : _active$shadowRoot.activeElement) active = active.shadowRoot.activeElement;
|
|
661
|
+
return active;
|
|
662
|
+
}
|
|
663
|
+
function duplicateKeyError(key, index) {
|
|
664
|
+
return /* @__PURE__ */ new Error(`[Zeus runtime] <For> received duplicate key ${String(key)} at index ${index}.`);
|
|
665
|
+
}
|
|
1880
666
|
function mountFor$1(parent, marker, each, key, render) {
|
|
1881
667
|
if (!key) {
|
|
1882
668
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -1886,63 +672,210 @@ function mountFor$1(parent, marker, each, key, render) {
|
|
|
1886
672
|
}
|
|
1887
673
|
function mountIndexFor(parent, marker, each, render) {
|
|
1888
674
|
const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
675
|
+
let latestItems = [];
|
|
676
|
+
let reconcileRequested = false;
|
|
677
|
+
let reconciling = false;
|
|
678
|
+
let disposed = false;
|
|
679
|
+
let runner;
|
|
680
|
+
const dispose = () => {
|
|
681
|
+
if (disposed) return;
|
|
682
|
+
disposed = true;
|
|
683
|
+
if (runner) (0, _zeus_js_signal_internal.stop)(runner);
|
|
1896
684
|
subtree.dispose();
|
|
1897
|
-
}
|
|
685
|
+
};
|
|
686
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(dispose, true);
|
|
687
|
+
const drainReconciliations = () => {
|
|
688
|
+
if (disposed || reconciling) return;
|
|
689
|
+
reconciling = true;
|
|
690
|
+
try {
|
|
691
|
+
while (reconcileRequested && !disposed) {
|
|
692
|
+
reconcileRequested = false;
|
|
693
|
+
(0, _zeus_js_signal_internal.untrack)(() => {
|
|
694
|
+
subtree.replace(() => latestItems.map((item, index) => render(() => item, () => index)));
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
} finally {
|
|
698
|
+
reconciling = false;
|
|
699
|
+
if (disposed) subtree.dispose();
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
const scheduleReconciliation = () => {
|
|
703
|
+
if (disposed || !runner) return;
|
|
704
|
+
runner();
|
|
705
|
+
if (disposed) return;
|
|
706
|
+
reconcileRequested = true;
|
|
707
|
+
drainReconciliations();
|
|
708
|
+
};
|
|
709
|
+
try {
|
|
710
|
+
runner = (0, _zeus_js_signal_internal.effect)(() => {
|
|
711
|
+
var _each;
|
|
712
|
+
const nextItems = (_each = each()) !== null && _each !== void 0 ? _each : [];
|
|
713
|
+
for (let i = 0; i < nextItems.length; i++) nextItems[i];
|
|
714
|
+
latestItems = nextItems;
|
|
715
|
+
}, { scheduler: scheduleReconciliation });
|
|
716
|
+
} catch (error) {
|
|
717
|
+
dispose();
|
|
718
|
+
throw error;
|
|
719
|
+
}
|
|
720
|
+
if (disposed) {
|
|
721
|
+
(0, _zeus_js_signal_internal.stop)(runner);
|
|
722
|
+
subtree.dispose();
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
reconcileRequested = true;
|
|
726
|
+
try {
|
|
727
|
+
drainReconciliations();
|
|
728
|
+
} catch (error) {
|
|
729
|
+
dispose();
|
|
730
|
+
throw error;
|
|
731
|
+
}
|
|
1898
732
|
}
|
|
1899
733
|
function mountKeyedFor(parent, marker, each, key, render) {
|
|
1900
734
|
let records = [];
|
|
1901
735
|
const subtreeContext = captureScopedSubtreeContext();
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
736
|
+
let latestEntries = [];
|
|
737
|
+
let reconcileRequested = false;
|
|
738
|
+
let reconciling = false;
|
|
739
|
+
let disposed = false;
|
|
740
|
+
let runner;
|
|
741
|
+
const dispose = () => {
|
|
742
|
+
if (disposed) return;
|
|
743
|
+
disposed = true;
|
|
744
|
+
if (runner) (0, _zeus_js_signal_internal.stop)(runner);
|
|
745
|
+
const currentRecords = records;
|
|
746
|
+
records = [];
|
|
747
|
+
for (const record of currentRecords) disposeListRecord(record);
|
|
748
|
+
};
|
|
749
|
+
(0, _zeus_js_signal_internal.onScopeDispose)(dispose, true);
|
|
750
|
+
const reconcile = (nextEntries) => {
|
|
751
|
+
if (disposed) return;
|
|
1905
752
|
const oldMap = /* @__PURE__ */ new Map();
|
|
1906
753
|
for (const record of records) oldMap.set(record.key, record);
|
|
1907
754
|
const nextRecords = [];
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
755
|
+
const createdRecords = [];
|
|
756
|
+
try {
|
|
757
|
+
(0, _zeus_js_signal_internal.batch)(() => {
|
|
758
|
+
for (let i = 0; i < nextEntries.length; i++) {
|
|
759
|
+
const { item, key: itemKey } = nextEntries[i];
|
|
760
|
+
const oldRecord = oldMap.get(itemKey);
|
|
761
|
+
if (oldRecord) {
|
|
762
|
+
oldMap.delete(itemKey);
|
|
763
|
+
oldRecord.setItem(() => item);
|
|
764
|
+
oldRecord.setIndex(i);
|
|
765
|
+
nextRecords.push(oldRecord);
|
|
766
|
+
} else {
|
|
767
|
+
const [readItem, setItem] = (0, _zeus_js_signal_internal.createSignal)(item);
|
|
768
|
+
const [readIndex, setIndex] = (0, _zeus_js_signal_internal.createSignal)(i);
|
|
769
|
+
const subtree = new ScopedSubtree(parent, marker, subtreeContext);
|
|
770
|
+
const record = {
|
|
771
|
+
key: itemKey,
|
|
772
|
+
setItem,
|
|
773
|
+
setIndex,
|
|
774
|
+
subtree
|
|
775
|
+
};
|
|
776
|
+
createdRecords.push(record);
|
|
777
|
+
subtree.replace(() => render(readItem, readIndex));
|
|
778
|
+
nextRecords.push(record);
|
|
779
|
+
}
|
|
780
|
+
if (disposed) break;
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
} catch (error) {
|
|
784
|
+
for (const record of createdRecords) disposeListRecord(record);
|
|
785
|
+
throw error;
|
|
786
|
+
}
|
|
787
|
+
if (disposed) {
|
|
788
|
+
for (const record of createdRecords) disposeListRecord(record);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
const activeElement = getDeepestActiveElement(parent);
|
|
792
|
+
const shouldRestoreFocus = Boolean(activeElement && nextRecords.some((record) => containsNode(record, activeElement)));
|
|
793
|
+
let committed = false;
|
|
794
|
+
try {
|
|
795
|
+
for (const record of oldMap.values()) disposeListRecord(record);
|
|
796
|
+
if (disposed) {
|
|
797
|
+
for (const record of createdRecords) disposeListRecord(record);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
records = nextRecords;
|
|
801
|
+
committed = true;
|
|
802
|
+
let moved = false;
|
|
803
|
+
let anchor = marker;
|
|
804
|
+
for (let i = nextRecords.length - 1; i >= 0; i--) {
|
|
805
|
+
var _record$subtree$curre;
|
|
806
|
+
const record = nextRecords[i];
|
|
807
|
+
if (!isImmediatelyBefore(record, anchor)) {
|
|
808
|
+
record.subtree.moveBefore(anchor);
|
|
809
|
+
moved = true;
|
|
810
|
+
}
|
|
811
|
+
anchor = (_record$subtree$curre = record.subtree.current()[0]) !== null && _record$subtree$curre !== void 0 ? _record$subtree$curre : anchor;
|
|
1926
812
|
}
|
|
813
|
+
if (disposed) return;
|
|
814
|
+
if (moved && shouldRestoreFocus) {
|
|
815
|
+
var _focus;
|
|
816
|
+
(_focus = activeElement.focus) === null || _focus === void 0 || _focus.call(activeElement, { preventScroll: true });
|
|
817
|
+
}
|
|
818
|
+
if (!disposed) emitDevtoolsEvent({
|
|
819
|
+
type: "mount-for",
|
|
820
|
+
length: nextRecords.length
|
|
821
|
+
});
|
|
822
|
+
} catch (error) {
|
|
823
|
+
if (!committed) for (const record of createdRecords) disposeListRecord(record);
|
|
824
|
+
throw error;
|
|
1927
825
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
826
|
+
};
|
|
827
|
+
const drainReconciliations = () => {
|
|
828
|
+
if (reconciling) return;
|
|
829
|
+
reconciling = true;
|
|
830
|
+
try {
|
|
831
|
+
while (reconcileRequested) {
|
|
832
|
+
reconcileRequested = false;
|
|
833
|
+
(0, _zeus_js_signal_internal.untrack)(() => reconcile(latestEntries));
|
|
834
|
+
}
|
|
835
|
+
} finally {
|
|
836
|
+
reconciling = false;
|
|
1934
837
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
838
|
+
};
|
|
839
|
+
const scheduleReconciliation = () => {
|
|
840
|
+
if (disposed || !runner) return;
|
|
841
|
+
runner();
|
|
842
|
+
if (disposed) return;
|
|
843
|
+
reconcileRequested = true;
|
|
844
|
+
drainReconciliations();
|
|
845
|
+
};
|
|
846
|
+
try {
|
|
847
|
+
runner = (0, _zeus_js_signal_internal.effect)(() => {
|
|
848
|
+
var _each2;
|
|
849
|
+
const nextItems = (_each2 = each()) !== null && _each2 !== void 0 ? _each2 : [];
|
|
850
|
+
const nextEntries = [];
|
|
851
|
+
const nextKeys = /* @__PURE__ */ new Set();
|
|
852
|
+
for (let i = 0; i < nextItems.length; i++) {
|
|
853
|
+
const item = nextItems[i];
|
|
854
|
+
const itemKey = key(item, i);
|
|
855
|
+
if (nextKeys.has(itemKey)) throw duplicateKeyError(itemKey, i);
|
|
856
|
+
nextKeys.add(itemKey);
|
|
857
|
+
nextEntries.push({
|
|
858
|
+
item,
|
|
859
|
+
key: itemKey
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
latestEntries = nextEntries;
|
|
863
|
+
}, { scheduler: scheduleReconciliation });
|
|
864
|
+
} catch (error) {
|
|
865
|
+
dispose();
|
|
866
|
+
throw error;
|
|
867
|
+
}
|
|
868
|
+
if (disposed) {
|
|
869
|
+
(0, _zeus_js_signal_internal.stop)(runner);
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
reconcileRequested = true;
|
|
873
|
+
try {
|
|
874
|
+
drainReconciliations();
|
|
875
|
+
} catch (error) {
|
|
876
|
+
dispose();
|
|
877
|
+
throw error;
|
|
878
|
+
}
|
|
1946
879
|
}
|
|
1947
880
|
//#endregion
|
|
1948
881
|
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
@@ -2166,7 +1099,14 @@ function createLightDomProjection(host, lightChildren) {
|
|
|
2166
1099
|
function replaceOutletNodes(outlet, nextNodes) {
|
|
2167
1100
|
const parent = outlet.end.parentNode;
|
|
2168
1101
|
if (!parent || parent !== outlet.start.parentNode) return;
|
|
1102
|
+
const currentNodes = [];
|
|
2169
1103
|
let current = outlet.start.nextSibling;
|
|
1104
|
+
while (current && current !== outlet.end) {
|
|
1105
|
+
currentNodes.push(current);
|
|
1106
|
+
current = current.nextSibling;
|
|
1107
|
+
}
|
|
1108
|
+
if (currentNodes.length === nextNodes.length && currentNodes.every((node, index) => node === nextNodes[index])) return;
|
|
1109
|
+
current = outlet.start.nextSibling;
|
|
2170
1110
|
while (current && current !== outlet.end) {
|
|
2171
1111
|
const next = current.nextSibling;
|
|
2172
1112
|
parent.removeChild(current);
|
|
@@ -2220,6 +1160,7 @@ function prop(input, options = {}) {
|
|
|
2220
1160
|
values: input,
|
|
2221
1161
|
attr: options.attr,
|
|
2222
1162
|
reflect: options.reflect,
|
|
1163
|
+
reactivity: options.reactivity,
|
|
2223
1164
|
default: options.default,
|
|
2224
1165
|
serialize: options.serialize,
|
|
2225
1166
|
deserialize: options.deserialize
|
|
@@ -2229,6 +1170,7 @@ function prop(input, options = {}) {
|
|
|
2229
1170
|
type,
|
|
2230
1171
|
attr: options.attr,
|
|
2231
1172
|
reflect: type === Boolean ? (_options$reflect = options.reflect) !== null && _options$reflect !== void 0 ? _options$reflect : true : options.reflect,
|
|
1173
|
+
reactivity: options.reactivity,
|
|
2232
1174
|
default: type === Boolean ? (_options$default = options.default) !== null && _options$default !== void 0 ? _options$default : false : options.default,
|
|
2233
1175
|
serialize: options.serialize,
|
|
2234
1176
|
deserialize: options.deserialize
|
|
@@ -2251,7 +1193,7 @@ function createPropStore(defs) {
|
|
|
2251
1193
|
const slots = /* @__PURE__ */ new Map();
|
|
2252
1194
|
const props = {};
|
|
2253
1195
|
for (const def of defs) {
|
|
2254
|
-
const slot = state();
|
|
1196
|
+
const slot = def.reactivity === "shallow" ? (0, _zeus_js_signal_internal.shallowState)() : (0, _zeus_js_signal_internal.state)();
|
|
2255
1197
|
slots.set(def.name, slot);
|
|
2256
1198
|
Object.defineProperty(props, def.name, {
|
|
2257
1199
|
configurable: false,
|
|
@@ -2317,6 +1259,7 @@ function defineElement(tagName, options, setup) {
|
|
|
2317
1259
|
this.mountLifecycle.connect();
|
|
2318
1260
|
}
|
|
2319
1261
|
disconnectedCallback() {
|
|
1262
|
+
if (isWithinRuntimeDomMove(this)) return;
|
|
2320
1263
|
this.mountLifecycle.disconnect();
|
|
2321
1264
|
}
|
|
2322
1265
|
mountElement() {
|
|
@@ -2507,7 +1450,8 @@ function normalizePropDefinitions(props) {
|
|
|
2507
1450
|
name: propKey,
|
|
2508
1451
|
attrName: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
|
|
2509
1452
|
type: normalizePropType(type),
|
|
2510
|
-
reflect: false
|
|
1453
|
+
reflect: false,
|
|
1454
|
+
reactivity: "deep"
|
|
2511
1455
|
};
|
|
2512
1456
|
}
|
|
2513
1457
|
const type = input === null || input === void 0 ? void 0 : input.type;
|
|
@@ -2517,6 +1461,7 @@ function normalizePropDefinitions(props) {
|
|
|
2517
1461
|
attrName: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
|
|
2518
1462
|
type: normalizePropType(type),
|
|
2519
1463
|
reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
|
|
1464
|
+
reactivity: (input === null || input === void 0 ? void 0 : input.reactivity) === "shallow" ? "shallow" : "deep",
|
|
2520
1465
|
default: input === null || input === void 0 ? void 0 : input.default,
|
|
2521
1466
|
serialize: input === null || input === void 0 ? void 0 : input.serialize,
|
|
2522
1467
|
deserialize: input === null || input === void 0 ? void 0 : input.deserialize
|
|
@@ -2555,7 +1500,7 @@ function syncFormValue(props, context, form) {
|
|
|
2555
1500
|
const valueResolver = form === null || form === void 0 ? void 0 : form.value;
|
|
2556
1501
|
const stateResolver = form === null || form === void 0 ? void 0 : form.state;
|
|
2557
1502
|
if (!context.internals || valueResolver === void 0) return;
|
|
2558
|
-
effect(() => {
|
|
1503
|
+
(0, _zeus_js_signal_internal.effect)(() => {
|
|
2559
1504
|
const value = resolveFormValue(props, valueResolver);
|
|
2560
1505
|
const state = stateResolver === void 0 ? void 0 : resolveFormValue(props, stateResolver);
|
|
2561
1506
|
context.internals.setFormValue(value, state);
|