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