@zeus-js/zeus 0.1.0-beta.7 → 0.1.0-beta.9
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/capabilities.cjs.js +6 -10
- package/dist/capabilities.cjs.prod.js +6 -10
- package/dist/capabilities.d.ts +4 -8
- package/dist/capabilities.js +5 -9
- package/dist/capabilities.prod.js +5 -9
- package/dist/zeus.cjs.js +5 -8
- package/dist/zeus.cjs.prod.js +5 -8
- package/dist/zeus.d.mts +1 -1
- package/dist/zeus.d.ts +1 -1
- package/dist/zeus.esm-browser.js +511 -435
- package/dist/zeus.esm-browser.prod.js +1 -1
- package/dist/zeus.esm-bundler.js +3 -3
- package/dist/zeus.global.js +514 -441
- package/dist/zeus.global.prod.js +1 -1
- package/package.json +3 -17
- package/dist/advanced.cjs.js +0 -26
- package/dist/advanced.cjs.prod.js +0 -26
- package/dist/advanced.d.ts +0 -1
- package/dist/advanced.js +0 -7
- package/dist/advanced.prod.js +0 -7
package/dist/zeus.esm-browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.1.0-beta.
|
|
2
|
+
* zeus v0.1.0-beta.9
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -17,21 +17,13 @@ function makeMap(str) {
|
|
|
17
17
|
for (const key of str.split(",")) map[key] = 1;
|
|
18
18
|
return (val) => val in map;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
//#region packages/core/shared/src/general.ts
|
|
22
|
-
const EMPTY_OBJ = Object.freeze({});
|
|
20
|
+
Object.freeze({});
|
|
23
21
|
Object.freeze([]);
|
|
24
|
-
const NOOP = () => {};
|
|
25
22
|
const extend = Object.assign;
|
|
26
|
-
const remove = (arr, el) => {
|
|
27
|
-
const i = arr.indexOf(el);
|
|
28
|
-
if (i > -1) arr.splice(i, 1);
|
|
29
|
-
};
|
|
30
23
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
31
24
|
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
32
25
|
const isArray = Array.isArray;
|
|
33
26
|
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
34
|
-
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
35
27
|
const isFunction = (val) => typeof val === "function";
|
|
36
28
|
const isString = (val) => typeof val === "string";
|
|
37
29
|
const isSymbol = (val) => typeof val === "symbol";
|
|
@@ -41,7 +33,6 @@ const toTypeString = (value) => objectToString.call(value);
|
|
|
41
33
|
const toRawType = (value) => {
|
|
42
34
|
return toTypeString(value).slice(8, -1);
|
|
43
35
|
};
|
|
44
|
-
const isPlainObject$1 = (val) => toTypeString(val) === "[object Object]";
|
|
45
36
|
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
46
37
|
const cacheStringFunction = (fn) => {
|
|
47
38
|
const cache = Object.create(null);
|
|
@@ -212,8 +203,9 @@ var ReactiveEffect = class {
|
|
|
212
203
|
this.depsTail = void 0;
|
|
213
204
|
this.flags = 5;
|
|
214
205
|
this.next = void 0;
|
|
215
|
-
this.
|
|
206
|
+
this.cleanups = void 0;
|
|
216
207
|
this.scheduler = void 0;
|
|
208
|
+
this.scope = activeEffectScope;
|
|
217
209
|
if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
|
|
218
210
|
else this.flags &= -2;
|
|
219
211
|
}
|
|
@@ -478,17 +470,26 @@ function resetTracking() {
|
|
|
478
470
|
* an active effect.
|
|
479
471
|
*/
|
|
480
472
|
function onEffectCleanup(fn, failSilently = false) {
|
|
481
|
-
if (activeSub instanceof ReactiveEffect)
|
|
482
|
-
|
|
473
|
+
if (activeSub instanceof ReactiveEffect) {
|
|
474
|
+
var _activeSub, _activeSub$cleanups;
|
|
475
|
+
((_activeSub$cleanups = (_activeSub = activeSub).cleanups) !== null && _activeSub$cleanups !== void 0 ? _activeSub$cleanups : _activeSub.cleanups = []).push(fn);
|
|
476
|
+
} else if (!failSilently) warn("onEffectCleanup() was called when there was no active effect to associate with.");
|
|
483
477
|
}
|
|
484
478
|
function cleanupEffect(e) {
|
|
485
|
-
const
|
|
486
|
-
e.
|
|
487
|
-
if (
|
|
479
|
+
const cleanups = e.cleanups;
|
|
480
|
+
e.cleanups = void 0;
|
|
481
|
+
if (cleanups) {
|
|
488
482
|
const prevSub = activeSub;
|
|
489
483
|
activeSub = void 0;
|
|
490
484
|
try {
|
|
491
|
-
|
|
485
|
+
let error;
|
|
486
|
+
for (const cleanup of cleanups) try {
|
|
487
|
+
cleanup();
|
|
488
|
+
} catch (cleanupError) {
|
|
489
|
+
var _error;
|
|
490
|
+
(_error = error) !== null && _error !== void 0 || (error = cleanupError);
|
|
491
|
+
}
|
|
492
|
+
if (error) throw error;
|
|
492
493
|
} finally {
|
|
493
494
|
activeSub = prevSub;
|
|
494
495
|
}
|
|
@@ -508,18 +509,6 @@ function batch(fn) {
|
|
|
508
509
|
}
|
|
509
510
|
}
|
|
510
511
|
/**
|
|
511
|
-
* Executes the given function without tracking reactive dependencies.
|
|
512
|
-
* Any reactive reads inside `fn` will not trigger effect re-runs.
|
|
513
|
-
*/
|
|
514
|
-
function untrack(fn) {
|
|
515
|
-
pauseTracking();
|
|
516
|
-
try {
|
|
517
|
-
return fn();
|
|
518
|
-
} finally {
|
|
519
|
-
resetTracking();
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
512
|
* Returns the currently executing reactive effect, if any.
|
|
524
513
|
*/
|
|
525
514
|
function getCurrentEffect() {
|
|
@@ -717,6 +706,87 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
717
706
|
endBatch();
|
|
718
707
|
}
|
|
719
708
|
//#endregion
|
|
709
|
+
//#region packages/core/signal/src/computed.ts
|
|
710
|
+
/**
|
|
711
|
+
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
712
|
+
* the main vue package
|
|
713
|
+
*/
|
|
714
|
+
var ComputedRefImpl = class {
|
|
715
|
+
constructor(fn, setter, isSSR) {
|
|
716
|
+
this.fn = fn;
|
|
717
|
+
this.setter = setter;
|
|
718
|
+
this._value = void 0;
|
|
719
|
+
this.dep = new Dep(this);
|
|
720
|
+
this.__v_isRef = true;
|
|
721
|
+
this.deps = void 0;
|
|
722
|
+
this.depsTail = void 0;
|
|
723
|
+
this.flags = 16;
|
|
724
|
+
this.globalVersion = globalVersion - 1;
|
|
725
|
+
this.next = void 0;
|
|
726
|
+
this["__v_isReadonly"] = !setter;
|
|
727
|
+
this.isSSR = isSSR;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* @internal
|
|
731
|
+
*/
|
|
732
|
+
notify() {
|
|
733
|
+
this.flags |= 16;
|
|
734
|
+
if (!(this.flags & 8) && activeSub !== this) {
|
|
735
|
+
queueSubscriber(this, true);
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
get value() {
|
|
740
|
+
const link = this.dep.track({
|
|
741
|
+
target: this,
|
|
742
|
+
type: "get",
|
|
743
|
+
key: "value"
|
|
744
|
+
});
|
|
745
|
+
refreshComputed(this);
|
|
746
|
+
if (link) link.version = this.dep.version;
|
|
747
|
+
return this._value;
|
|
748
|
+
}
|
|
749
|
+
set value(newValue) {
|
|
750
|
+
if (this.setter) this.setter(newValue);
|
|
751
|
+
else warn("Write operation failed: computed value is readonly");
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
755
|
+
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
756
|
+
let getter;
|
|
757
|
+
let setter;
|
|
758
|
+
if (isFunction(getterOrOptions)) getter = getterOrOptions;
|
|
759
|
+
else {
|
|
760
|
+
getter = getterOrOptions.get;
|
|
761
|
+
setter = getterOrOptions.set;
|
|
762
|
+
}
|
|
763
|
+
const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
|
764
|
+
if (debugOptions && !isSSR) {
|
|
765
|
+
cRef.onTrack = debugOptions.onTrack;
|
|
766
|
+
cRef.onTrigger = debugOptions.onTrigger;
|
|
767
|
+
}
|
|
768
|
+
return cRef;
|
|
769
|
+
}
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
772
|
+
function onCleanup(fn) {
|
|
773
|
+
const effect = getCurrentEffect();
|
|
774
|
+
const scope = getCurrentScope();
|
|
775
|
+
if (scope && (effect === null || effect === void 0 ? void 0 : effect.scope) !== scope) {
|
|
776
|
+
onScopeDispose(fn, true);
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
if (effect) {
|
|
780
|
+
onEffectCleanup(fn, true);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
if (scope) {
|
|
784
|
+
onScopeDispose(fn, true);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
warn("onCleanup() was called without active effect or scope.");
|
|
788
|
+
}
|
|
789
|
+
//#endregion
|
|
720
790
|
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
721
791
|
/**
|
|
722
792
|
* Track array iteration and return:
|
|
@@ -902,60 +972,6 @@ function noTracking(self, method, args = []) {
|
|
|
902
972
|
return res;
|
|
903
973
|
}
|
|
904
974
|
//#endregion
|
|
905
|
-
//#region packages/core/signal/src/ref.ts
|
|
906
|
-
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
907
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
908
|
-
function isRef(r) {
|
|
909
|
-
return r ? r["__v_isRef"] === true : false;
|
|
910
|
-
}
|
|
911
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
912
|
-
function ref(value) {
|
|
913
|
-
return createRef(value, false);
|
|
914
|
-
}
|
|
915
|
-
function createRef(rawValue, shallow) {
|
|
916
|
-
if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
|
|
917
|
-
return new RefImpl(rawValue, shallow);
|
|
918
|
-
}
|
|
919
|
-
_ReactiveFlags$IS_REF = "__v_isRef";
|
|
920
|
-
_ReactiveFlags$IS_SHA = "__v_isShallow";
|
|
921
|
-
/**
|
|
922
|
-
* @internal
|
|
923
|
-
*/
|
|
924
|
-
var RefImpl = class {
|
|
925
|
-
constructor(value, isShallow) {
|
|
926
|
-
this.dep = new Dep();
|
|
927
|
-
this[_ReactiveFlags$IS_REF] = true;
|
|
928
|
-
this[_ReactiveFlags$IS_SHA] = false;
|
|
929
|
-
this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
|
|
930
|
-
this._value = isShallow ? value : toReactive(value);
|
|
931
|
-
this["__v_isShallow"] = isShallow;
|
|
932
|
-
}
|
|
933
|
-
get value() {
|
|
934
|
-
this.dep.track({
|
|
935
|
-
target: this,
|
|
936
|
-
type: "get",
|
|
937
|
-
key: "value"
|
|
938
|
-
});
|
|
939
|
-
return this._value;
|
|
940
|
-
}
|
|
941
|
-
set value(newValue) {
|
|
942
|
-
const oldValue = this._rawValue;
|
|
943
|
-
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
944
|
-
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
945
|
-
if (hasChanged(newValue, oldValue)) {
|
|
946
|
-
this._rawValue = newValue;
|
|
947
|
-
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
948
|
-
this.dep.trigger({
|
|
949
|
-
target: this,
|
|
950
|
-
type: "set",
|
|
951
|
-
key: "value",
|
|
952
|
-
newValue,
|
|
953
|
-
oldValue
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
//#endregion
|
|
959
975
|
//#region packages/core/signal/src/baseHandlers.ts
|
|
960
976
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
961
977
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
@@ -1388,256 +1404,152 @@ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value)
|
|
|
1388
1404
|
*/
|
|
1389
1405
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1390
1406
|
//#endregion
|
|
1391
|
-
//#region packages/core/signal/src/
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1407
|
+
//#region packages/core/signal/src/ref.ts
|
|
1408
|
+
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
1409
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1410
|
+
function isRef(r) {
|
|
1411
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1395
1412
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
|
|
1400
|
-
return isPlainObject(value);
|
|
1413
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1414
|
+
function ref(value) {
|
|
1415
|
+
return createRef(value, false);
|
|
1401
1416
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
return
|
|
1417
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1418
|
+
function shallowRef(value) {
|
|
1419
|
+
return createRef(value, true);
|
|
1405
1420
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1421
|
+
function createRef(rawValue, shallow) {
|
|
1422
|
+
if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
|
|
1423
|
+
return new RefImpl(rawValue, shallow);
|
|
1424
|
+
}
|
|
1425
|
+
_ReactiveFlags$IS_REF = "__v_isRef";
|
|
1426
|
+
_ReactiveFlags$IS_SHA = "__v_isShallow";
|
|
1408
1427
|
/**
|
|
1409
|
-
* @
|
|
1410
|
-
* the main vue package
|
|
1428
|
+
* @internal
|
|
1411
1429
|
*/
|
|
1412
|
-
var
|
|
1413
|
-
constructor(
|
|
1414
|
-
this.
|
|
1415
|
-
this
|
|
1416
|
-
this
|
|
1417
|
-
this.
|
|
1418
|
-
this.
|
|
1419
|
-
this
|
|
1420
|
-
this.depsTail = void 0;
|
|
1421
|
-
this.flags = 16;
|
|
1422
|
-
this.globalVersion = globalVersion - 1;
|
|
1423
|
-
this.next = void 0;
|
|
1424
|
-
this["__v_isReadonly"] = !setter;
|
|
1425
|
-
this.isSSR = isSSR;
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* @internal
|
|
1429
|
-
*/
|
|
1430
|
-
notify() {
|
|
1431
|
-
this.flags |= 16;
|
|
1432
|
-
if (!(this.flags & 8) && activeSub !== this) {
|
|
1433
|
-
queueSubscriber(this, true);
|
|
1434
|
-
return true;
|
|
1435
|
-
}
|
|
1430
|
+
var RefImpl = class {
|
|
1431
|
+
constructor(value, isShallow) {
|
|
1432
|
+
this.dep = new Dep();
|
|
1433
|
+
this[_ReactiveFlags$IS_REF] = true;
|
|
1434
|
+
this[_ReactiveFlags$IS_SHA] = false;
|
|
1435
|
+
this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
|
|
1436
|
+
this._value = isShallow ? value : toReactive(value);
|
|
1437
|
+
this["__v_isShallow"] = isShallow;
|
|
1436
1438
|
}
|
|
1437
1439
|
get value() {
|
|
1438
|
-
|
|
1440
|
+
this.dep.track({
|
|
1439
1441
|
target: this,
|
|
1440
1442
|
type: "get",
|
|
1441
1443
|
key: "value"
|
|
1442
1444
|
});
|
|
1443
|
-
refreshComputed(this);
|
|
1444
|
-
if (link) link.version = this.dep.version;
|
|
1445
1445
|
return this._value;
|
|
1446
1446
|
}
|
|
1447
1447
|
set value(newValue) {
|
|
1448
|
-
|
|
1449
|
-
|
|
1448
|
+
const oldValue = this._rawValue;
|
|
1449
|
+
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
1450
|
+
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
1451
|
+
if (hasChanged(newValue, oldValue)) {
|
|
1452
|
+
this._rawValue = newValue;
|
|
1453
|
+
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
1454
|
+
this.dep.trigger({
|
|
1455
|
+
target: this,
|
|
1456
|
+
type: "set",
|
|
1457
|
+
key: "value",
|
|
1458
|
+
newValue,
|
|
1459
|
+
oldValue
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1450
1462
|
}
|
|
1451
1463
|
};
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1464
|
+
//#endregion
|
|
1465
|
+
//#region packages/core/signal/src/primitives.ts
|
|
1466
|
+
function createSignal(initialValue) {
|
|
1467
|
+
const source = /* @__PURE__ */ shallowRef(initialValue);
|
|
1468
|
+
const read = () => source.value;
|
|
1469
|
+
const write = (value) => {
|
|
1470
|
+
const next = typeof value === "function" ? value(source.value) : value;
|
|
1471
|
+
source.value = next;
|
|
1472
|
+
return next;
|
|
1473
|
+
};
|
|
1474
|
+
return [read, write];
|
|
1475
|
+
}
|
|
1476
|
+
function createMemo(compute) {
|
|
1477
|
+
const memo = /* @__PURE__ */ computed(compute);
|
|
1478
|
+
return () => memo.value;
|
|
1479
|
+
}
|
|
1480
|
+
function createEffect(run) {
|
|
1481
|
+
effect(run);
|
|
1482
|
+
}
|
|
1483
|
+
function createRoot(run) {
|
|
1484
|
+
const root = effectScope(true);
|
|
1485
|
+
let disposed = false;
|
|
1486
|
+
const dispose = () => {
|
|
1487
|
+
if (disposed) return;
|
|
1488
|
+
disposed = true;
|
|
1489
|
+
root.stop();
|
|
1490
|
+
};
|
|
1491
|
+
try {
|
|
1492
|
+
return root.run(() => run(dispose));
|
|
1493
|
+
} catch (error) {
|
|
1494
|
+
dispose();
|
|
1495
|
+
throw error;
|
|
1465
1496
|
}
|
|
1466
|
-
return cRef;
|
|
1467
1497
|
}
|
|
1468
1498
|
//#endregion
|
|
1469
|
-
//#region packages/core/signal/src/
|
|
1470
|
-
function
|
|
1471
|
-
return
|
|
1499
|
+
//#region packages/core/signal/src/state.ts
|
|
1500
|
+
function state(value) {
|
|
1501
|
+
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1502
|
+
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
1503
|
+
}
|
|
1504
|
+
function isProxyable(value) {
|
|
1505
|
+
if (value === null || typeof value !== "object") return false;
|
|
1506
|
+
if (Array.isArray(value)) return true;
|
|
1507
|
+
if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
|
|
1508
|
+
return isPlainObject(value);
|
|
1509
|
+
}
|
|
1510
|
+
function isPlainObject(value) {
|
|
1511
|
+
const proto = Object.getPrototypeOf(value);
|
|
1512
|
+
return proto === Object.prototype || proto === null;
|
|
1472
1513
|
}
|
|
1473
1514
|
//#endregion
|
|
1474
|
-
//#region packages/core/
|
|
1475
|
-
const
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
*
|
|
1483
|
-
* @param cleanupFn - The callback function to attach to the effect's cleanup.
|
|
1484
|
-
* @param failSilently - if `true`, will not throw warning when called without
|
|
1485
|
-
* an active effect.
|
|
1486
|
-
* @param owner - The effect that this cleanup function should be attached to.
|
|
1487
|
-
* By default, the current active effect.
|
|
1488
|
-
*/
|
|
1489
|
-
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
1490
|
-
if (owner) {
|
|
1491
|
-
let cleanups = cleanupMap.get(owner);
|
|
1492
|
-
if (!cleanups) cleanupMap.set(owner, cleanups = []);
|
|
1493
|
-
cleanups.push(cleanupFn);
|
|
1494
|
-
} else if (!failSilently) warn("onWatcherCleanup() was called when there was no active watcher to associate with.");
|
|
1495
|
-
}
|
|
1496
|
-
function watch(source, cb, options = EMPTY_OBJ) {
|
|
1497
|
-
const { immediate, deep, once, scheduler, augmentJob, call } = options;
|
|
1498
|
-
const warnInvalidSource = (s) => {
|
|
1499
|
-
(options.onWarn || warn)(`Invalid watch source: `, s, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
|
|
1500
|
-
};
|
|
1501
|
-
const reactiveGetter = (source) => {
|
|
1502
|
-
if (deep) return source;
|
|
1503
|
-
if (/* @__PURE__ */ isShallow(source) || deep === false || deep === 0) return traverse(source, 1);
|
|
1504
|
-
return traverse(source);
|
|
1505
|
-
};
|
|
1506
|
-
let effect;
|
|
1507
|
-
let getter;
|
|
1508
|
-
let cleanup;
|
|
1509
|
-
let boundCleanup;
|
|
1510
|
-
let forceTrigger = false;
|
|
1511
|
-
let isMultiSource = false;
|
|
1512
|
-
if (/* @__PURE__ */ isRef(source)) {
|
|
1513
|
-
getter = () => source.value;
|
|
1514
|
-
forceTrigger = /* @__PURE__ */ isShallow(source);
|
|
1515
|
-
} else if (/* @__PURE__ */ isReactive(source)) {
|
|
1516
|
-
getter = () => reactiveGetter(source);
|
|
1517
|
-
forceTrigger = true;
|
|
1518
|
-
} else if (isArray(source)) {
|
|
1519
|
-
isMultiSource = true;
|
|
1520
|
-
forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s));
|
|
1521
|
-
getter = () => source.map((s) => {
|
|
1522
|
-
if (/* @__PURE__ */ isRef(s)) return s.value;
|
|
1523
|
-
else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s);
|
|
1524
|
-
else if (isFunction(s)) return call ? call(s, 2) : s();
|
|
1525
|
-
else warnInvalidSource(s);
|
|
1526
|
-
});
|
|
1527
|
-
} else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
|
|
1528
|
-
else getter = () => {
|
|
1529
|
-
if (cleanup) {
|
|
1530
|
-
pauseTracking();
|
|
1531
|
-
try {
|
|
1532
|
-
cleanup();
|
|
1533
|
-
} finally {
|
|
1534
|
-
resetTracking();
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
const currentEffect = activeWatcher;
|
|
1538
|
-
activeWatcher = effect;
|
|
1539
|
-
try {
|
|
1540
|
-
return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
|
|
1541
|
-
} finally {
|
|
1542
|
-
activeWatcher = currentEffect;
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
|
-
else {
|
|
1546
|
-
getter = NOOP;
|
|
1547
|
-
warnInvalidSource(source);
|
|
1548
|
-
}
|
|
1549
|
-
if (cb && deep) {
|
|
1550
|
-
const baseGetter = getter;
|
|
1551
|
-
const depth = deep === true ? Infinity : deep;
|
|
1552
|
-
getter = () => traverse(baseGetter(), depth);
|
|
1553
|
-
}
|
|
1554
|
-
const scope = getCurrentScope();
|
|
1555
|
-
const watchHandle = () => {
|
|
1556
|
-
effect.stop();
|
|
1557
|
-
if (scope && scope.active) remove(scope.effects, effect);
|
|
1558
|
-
};
|
|
1559
|
-
if (once && cb) {
|
|
1560
|
-
const _cb = cb;
|
|
1561
|
-
cb = (...args) => {
|
|
1562
|
-
_cb(...args);
|
|
1563
|
-
watchHandle();
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1567
|
-
const job = (immediateFirstRun) => {
|
|
1568
|
-
if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) return;
|
|
1569
|
-
if (cb) {
|
|
1570
|
-
const newValue = effect.run();
|
|
1571
|
-
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
1572
|
-
if (cleanup) cleanup();
|
|
1573
|
-
const currentWatcher = activeWatcher;
|
|
1574
|
-
activeWatcher = effect;
|
|
1575
|
-
try {
|
|
1576
|
-
const args = [
|
|
1577
|
-
newValue,
|
|
1578
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1579
|
-
boundCleanup
|
|
1580
|
-
];
|
|
1581
|
-
oldValue = newValue;
|
|
1582
|
-
call ? call(cb, 3, args) : cb(...args);
|
|
1583
|
-
} finally {
|
|
1584
|
-
activeWatcher = currentWatcher;
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
} else effect.run();
|
|
1588
|
-
};
|
|
1589
|
-
if (augmentJob) augmentJob(job);
|
|
1590
|
-
effect = new ReactiveEffect(getter);
|
|
1591
|
-
effect.scheduler = scheduler ? () => scheduler(job, false) : job;
|
|
1592
|
-
boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
|
|
1593
|
-
cleanup = effect.onStop = () => {
|
|
1594
|
-
const cleanups = cleanupMap.get(effect);
|
|
1595
|
-
if (cleanups) {
|
|
1596
|
-
if (call) call(cleanups, 4);
|
|
1597
|
-
else for (const cleanup of cleanups) cleanup();
|
|
1598
|
-
cleanupMap.delete(effect);
|
|
1599
|
-
}
|
|
1515
|
+
//#region packages/core/runtime-dom/src/domOwnership.ts
|
|
1516
|
+
const activeLightDomHosts = /* @__PURE__ */ new WeakMap();
|
|
1517
|
+
const runtimeOwnedNodes = /* @__PURE__ */ new WeakSet();
|
|
1518
|
+
function registerLightDomHost(host, lightChildren) {
|
|
1519
|
+
const ownership = { lightChildren };
|
|
1520
|
+
activeLightDomHosts.set(host, ownership);
|
|
1521
|
+
return () => {
|
|
1522
|
+
if (activeLightDomHosts.get(host) === ownership) activeLightDomHosts.delete(host);
|
|
1600
1523
|
};
|
|
1601
|
-
effect.onTrack = options.onTrack;
|
|
1602
|
-
effect.onTrigger = options.onTrigger;
|
|
1603
|
-
if (cb) if (immediate) job(true);
|
|
1604
|
-
else oldValue = effect.run();
|
|
1605
|
-
else if (scheduler) scheduler(job.bind(null, true), true);
|
|
1606
|
-
else effect.run();
|
|
1607
|
-
watchHandle.pause = effect.pause.bind(effect);
|
|
1608
|
-
watchHandle.resume = effect.resume.bind(effect);
|
|
1609
|
-
watchHandle.stop = watchHandle;
|
|
1610
|
-
return watchHandle;
|
|
1611
|
-
}
|
|
1612
|
-
function traverse(value, depth = Infinity, seen) {
|
|
1613
|
-
if (depth <= 0 || !isObject(value) || value["__v_skip"]) return value;
|
|
1614
|
-
seen = seen || /* @__PURE__ */ new Map();
|
|
1615
|
-
if ((seen.get(value) || 0) >= depth) return value;
|
|
1616
|
-
seen.set(value, depth);
|
|
1617
|
-
depth--;
|
|
1618
|
-
if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen);
|
|
1619
|
-
else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen);
|
|
1620
|
-
else if (isSet(value) || isMap(value)) value.forEach((v) => {
|
|
1621
|
-
traverse(v, depth, seen);
|
|
1622
|
-
});
|
|
1623
|
-
else if (isPlainObject$1(value)) {
|
|
1624
|
-
for (const key in value) traverse(value[key], depth, seen);
|
|
1625
|
-
for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen);
|
|
1626
|
-
}
|
|
1627
|
-
return value;
|
|
1628
1524
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
if (
|
|
1633
|
-
|
|
1525
|
+
function trackRuntimeDomInsertion(parent, node) {
|
|
1526
|
+
const ownership = activeLightDomHosts.get(parent);
|
|
1527
|
+
if (!ownership) return;
|
|
1528
|
+
if (node.nodeType === 11) {
|
|
1529
|
+
for (const child of node.childNodes) trackRuntimeNode(ownership, child);
|
|
1634
1530
|
return;
|
|
1635
1531
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1532
|
+
trackRuntimeNode(ownership, node);
|
|
1533
|
+
}
|
|
1534
|
+
function isRuntimeOwnedNode(node) {
|
|
1535
|
+
return runtimeOwnedNodes.has(node);
|
|
1536
|
+
}
|
|
1537
|
+
function trackRuntimeNode(ownership, node) {
|
|
1538
|
+
if (!ownership.lightChildren.includes(node)) runtimeOwnedNodes.add(node);
|
|
1539
|
+
}
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region packages/core/runtime-dom/src/range.ts
|
|
1542
|
+
function insertTracked(parent, value, marker = null) {
|
|
1543
|
+
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
1544
|
+
if (Array.isArray(value)) {
|
|
1545
|
+
const nodes = [];
|
|
1546
|
+
for (const item of value) nodes.push(...insertTracked(parent, item, marker));
|
|
1547
|
+
return nodes;
|
|
1639
1548
|
}
|
|
1640
|
-
|
|
1549
|
+
const node = value instanceof Node ? value : document.createTextNode(String(value));
|
|
1550
|
+
trackRuntimeDomInsertion(parent, node);
|
|
1551
|
+
parent.insertBefore(node, marker);
|
|
1552
|
+
return [node];
|
|
1641
1553
|
}
|
|
1642
1554
|
//#endregion
|
|
1643
1555
|
//#region packages/core/runtime-dom/src/hostContext.ts
|
|
@@ -1655,19 +1567,6 @@ function withHostContext(context, fn) {
|
|
|
1655
1567
|
}
|
|
1656
1568
|
}
|
|
1657
1569
|
//#endregion
|
|
1658
|
-
//#region packages/core/runtime-dom/src/range.ts
|
|
1659
|
-
function insertTracked(parent, value, marker = null) {
|
|
1660
|
-
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
1661
|
-
if (Array.isArray(value)) {
|
|
1662
|
-
const nodes = [];
|
|
1663
|
-
for (const item of value) nodes.push(...insertTracked(parent, item, marker));
|
|
1664
|
-
return nodes;
|
|
1665
|
-
}
|
|
1666
|
-
const node = value instanceof Node ? value : document.createTextNode(String(value));
|
|
1667
|
-
parent.insertBefore(node, marker);
|
|
1668
|
-
return [node];
|
|
1669
|
-
}
|
|
1670
|
-
//#endregion
|
|
1671
1570
|
//#region packages/core/runtime-dom/src/insert.ts
|
|
1672
1571
|
function insert(parent, value, marker = null) {
|
|
1673
1572
|
if (value === void 0) {
|
|
@@ -1924,11 +1823,11 @@ function bindStyle(el, value) {
|
|
|
1924
1823
|
function patchStyle(el, prev, next) {
|
|
1925
1824
|
const style = el.style;
|
|
1926
1825
|
if (prev) {
|
|
1927
|
-
for (const key in prev) if (!(key in next)) style.setProperty(toKebabCase$
|
|
1826
|
+
for (const key in prev) if (!(key in next)) style.setProperty(toKebabCase$2(key), "");
|
|
1928
1827
|
}
|
|
1929
1828
|
for (const key in next) {
|
|
1930
1829
|
const value = next[key];
|
|
1931
|
-
const name = toKebabCase$
|
|
1830
|
+
const name = toKebabCase$2(key);
|
|
1932
1831
|
if (value == null) style.setProperty(name, "");
|
|
1933
1832
|
else style.setProperty(name, normalizeStyleValue(key, value));
|
|
1934
1833
|
}
|
|
@@ -1950,7 +1849,7 @@ const unitlessNumbers = /* @__PURE__ */ new Set([
|
|
|
1950
1849
|
function isUnitlessNumber(key) {
|
|
1951
1850
|
return unitlessNumbers.has(key);
|
|
1952
1851
|
}
|
|
1953
|
-
function toKebabCase$
|
|
1852
|
+
function toKebabCase$2(value) {
|
|
1954
1853
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1955
1854
|
}
|
|
1956
1855
|
//#endregion
|
|
@@ -1972,6 +1871,248 @@ function For(props) {
|
|
|
1972
1871
|
return (_props$each$map = (_props$each = props.each) === null || _props$each === void 0 ? void 0 : _props$each.map((item, index) => props.children(item, index))) !== null && _props$each$map !== void 0 ? _props$each$map : null;
|
|
1973
1872
|
}
|
|
1974
1873
|
//#endregion
|
|
1874
|
+
//#region packages/core/runtime-dom/src/customElementContract.ts
|
|
1875
|
+
function getCustomElementAttributeName(prop) {
|
|
1876
|
+
var _prop$attrName;
|
|
1877
|
+
if (prop.attrName === false) return void 0;
|
|
1878
|
+
if (!isAttributeBackedType(prop.type) && !prop.deserialize) return;
|
|
1879
|
+
return normalizeAttributeName((_prop$attrName = prop.attrName) !== null && _prop$attrName !== void 0 ? _prop$attrName : toKebabCase$1(prop.name));
|
|
1880
|
+
}
|
|
1881
|
+
function getCustomElementObservedAttributes(props) {
|
|
1882
|
+
const attributes = /* @__PURE__ */ new Set();
|
|
1883
|
+
for (const prop of props) {
|
|
1884
|
+
const attrName = getCustomElementAttributeName(prop);
|
|
1885
|
+
if (attrName) attributes.add(attrName);
|
|
1886
|
+
}
|
|
1887
|
+
return Array.from(attributes);
|
|
1888
|
+
}
|
|
1889
|
+
function coerceCustomElementAttribute(prop, value) {
|
|
1890
|
+
if (typeof prop.deserialize === "function") return prop.deserialize(value);
|
|
1891
|
+
if (prop.deserialize === true) return value;
|
|
1892
|
+
switch (prop.type) {
|
|
1893
|
+
case "boolean": return value !== null;
|
|
1894
|
+
case "number": return value === null ? void 0 : Number(value);
|
|
1895
|
+
case "string": return value !== null && value !== void 0 ? value : void 0;
|
|
1896
|
+
case "object":
|
|
1897
|
+
case "array": return coerceStructuredAttribute(prop, value);
|
|
1898
|
+
case "function": return;
|
|
1899
|
+
default: return value;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
function reflectCustomElementProperty(element, prop, value, reflectingAttrs) {
|
|
1903
|
+
const attrName = getCustomElementAttributeName(prop);
|
|
1904
|
+
if (!attrName || prop.serialize === true) return;
|
|
1905
|
+
reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.add(attrName);
|
|
1906
|
+
try {
|
|
1907
|
+
const serialized = serializeCustomElementProperty(prop, value);
|
|
1908
|
+
if (serialized == null) element.removeAttribute(attrName);
|
|
1909
|
+
else element.setAttribute(attrName, serialized);
|
|
1910
|
+
} finally {
|
|
1911
|
+
reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.delete(attrName);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
function createCustomElementMountLifecycle(mount) {
|
|
1915
|
+
let mounted;
|
|
1916
|
+
return {
|
|
1917
|
+
connect() {
|
|
1918
|
+
var _mounted;
|
|
1919
|
+
(_mounted = mounted) !== null && _mounted !== void 0 || (mounted = mount());
|
|
1920
|
+
return mounted;
|
|
1921
|
+
},
|
|
1922
|
+
disconnect() {
|
|
1923
|
+
const current = mounted;
|
|
1924
|
+
mounted = void 0;
|
|
1925
|
+
current === null || current === void 0 || current.dispose();
|
|
1926
|
+
},
|
|
1927
|
+
current() {
|
|
1928
|
+
return mounted;
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
function serializeCustomElementProperty(prop, value) {
|
|
1933
|
+
if (typeof prop.serialize === "function") return prop.serialize(value);
|
|
1934
|
+
if (prop.type === "boolean") return value ? "" : null;
|
|
1935
|
+
if (value == null) return null;
|
|
1936
|
+
if (prop.type === "object" || prop.type === "array") return JSON.stringify(value);
|
|
1937
|
+
if (prop.type === "function") return void 0;
|
|
1938
|
+
return String(value);
|
|
1939
|
+
}
|
|
1940
|
+
function coerceStructuredAttribute(prop, value) {
|
|
1941
|
+
if (value === null) return void 0;
|
|
1942
|
+
try {
|
|
1943
|
+
return JSON.parse(value);
|
|
1944
|
+
} catch (_unused) {
|
|
1945
|
+
console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${getCustomElementAttributeName(prop)}".`);
|
|
1946
|
+
return prop.type === "array" ? [] : {};
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
function isAttributeBackedType(type) {
|
|
1950
|
+
return type === "string" || type === "number" || type === "boolean";
|
|
1951
|
+
}
|
|
1952
|
+
function normalizeAttributeName(value) {
|
|
1953
|
+
return value.toLowerCase();
|
|
1954
|
+
}
|
|
1955
|
+
function toKebabCase$1(value) {
|
|
1956
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1957
|
+
}
|
|
1958
|
+
//#endregion
|
|
1959
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
1960
|
+
function createSlot(name, fallback) {
|
|
1961
|
+
const context = getCurrentHostContext();
|
|
1962
|
+
if (!context) return createNativeSlot(name, fallback);
|
|
1963
|
+
if (context.mode === "shadow") return createNativeSlot(name, fallback);
|
|
1964
|
+
if (context.projection) return context.projection.createSlot(name, fallback);
|
|
1965
|
+
const assigned = findLightSlotNodes(context.lightChildren, name);
|
|
1966
|
+
if (assigned.length > 0) return Array.from(assigned);
|
|
1967
|
+
return fallback ? fallback() : null;
|
|
1968
|
+
}
|
|
1969
|
+
function createLightDomProjection(host, lightChildren) {
|
|
1970
|
+
const outlets = [];
|
|
1971
|
+
let observer;
|
|
1972
|
+
let unregisterHost;
|
|
1973
|
+
const observe = () => {
|
|
1974
|
+
observer === null || observer === void 0 || observer.observe(host, {
|
|
1975
|
+
attributes: true,
|
|
1976
|
+
attributeFilter: ["slot"],
|
|
1977
|
+
childList: true,
|
|
1978
|
+
subtree: true
|
|
1979
|
+
});
|
|
1980
|
+
for (const node of lightChildren) {
|
|
1981
|
+
if (node.nodeType !== Node.ELEMENT_NODE || host.contains(node)) continue;
|
|
1982
|
+
observer === null || observer === void 0 || observer.observe(node, {
|
|
1983
|
+
attributes: true,
|
|
1984
|
+
attributeFilter: ["slot"]
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
const reconcile = () => {
|
|
1989
|
+
observer === null || observer === void 0 || observer.disconnect();
|
|
1990
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
1991
|
+
for (const outlet of outlets) {
|
|
1992
|
+
const assigned = lightChildren.filter((node) => {
|
|
1993
|
+
if (claimed.has(node) || !matchesLightSlot(node, outlet.name)) return false;
|
|
1994
|
+
claimed.add(node);
|
|
1995
|
+
return true;
|
|
1996
|
+
});
|
|
1997
|
+
replaceOutletNodes(outlet, assigned.length > 0 ? assigned : outlet.fallbackNodes);
|
|
1998
|
+
}
|
|
1999
|
+
for (const node of lightChildren) if (!claimed.has(node) && host.contains(node)) {
|
|
2000
|
+
var _node$parentNode;
|
|
2001
|
+
(_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 || _node$parentNode.removeChild(node);
|
|
2002
|
+
}
|
|
2003
|
+
observer === null || observer === void 0 || observer.takeRecords();
|
|
2004
|
+
observe();
|
|
2005
|
+
};
|
|
2006
|
+
const handleMutations = (records) => {
|
|
2007
|
+
const added = /* @__PURE__ */ new Set();
|
|
2008
|
+
const removed = /* @__PURE__ */ new Set();
|
|
2009
|
+
let changed = false;
|
|
2010
|
+
for (const record of records) {
|
|
2011
|
+
if (record.type === "attributes") {
|
|
2012
|
+
if (lightChildren.includes(record.target)) changed = true;
|
|
2013
|
+
continue;
|
|
2014
|
+
}
|
|
2015
|
+
for (const node of record.removedNodes) if (lightChildren.includes(node)) removed.add(node);
|
|
2016
|
+
if (record.target !== host) continue;
|
|
2017
|
+
const additions = Array.from(record.addedNodes).filter((node) => {
|
|
2018
|
+
return !isRuntimeOwnedNode(node);
|
|
2019
|
+
});
|
|
2020
|
+
if (additions.length === 0) continue;
|
|
2021
|
+
for (const node of additions) added.add(node);
|
|
2022
|
+
insertLightChildren(lightChildren, additions, record);
|
|
2023
|
+
changed = true;
|
|
2024
|
+
}
|
|
2025
|
+
for (const node of removed) {
|
|
2026
|
+
if (added.has(node) || host.contains(node)) continue;
|
|
2027
|
+
const index = lightChildren.indexOf(node);
|
|
2028
|
+
if (index >= 0) {
|
|
2029
|
+
lightChildren.splice(index, 1);
|
|
2030
|
+
changed = true;
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
if (changed) reconcile();
|
|
2034
|
+
};
|
|
2035
|
+
return {
|
|
2036
|
+
createSlot(name, fallback) {
|
|
2037
|
+
const fragment = document.createDocumentFragment();
|
|
2038
|
+
const start = document.createComment(name ? `zeus-slot:${name}` : "zeus-slot");
|
|
2039
|
+
const end = document.createComment("/zeus-slot");
|
|
2040
|
+
fragment.append(start, end);
|
|
2041
|
+
const outlet = {
|
|
2042
|
+
name,
|
|
2043
|
+
start,
|
|
2044
|
+
end,
|
|
2045
|
+
fallbackNodes: fallback ? insertTracked(fragment, fallback(), end) : []
|
|
2046
|
+
};
|
|
2047
|
+
outlets.push(outlet);
|
|
2048
|
+
reconcile();
|
|
2049
|
+
return fragment;
|
|
2050
|
+
},
|
|
2051
|
+
connect() {
|
|
2052
|
+
var _host$ownerDocument$d;
|
|
2053
|
+
if (observer) return;
|
|
2054
|
+
const Observer = (_host$ownerDocument$d = host.ownerDocument.defaultView) === null || _host$ownerDocument$d === void 0 ? void 0 : _host$ownerDocument$d.MutationObserver;
|
|
2055
|
+
if (!Observer) return;
|
|
2056
|
+
unregisterHost = registerLightDomHost(host, lightChildren);
|
|
2057
|
+
observer = new Observer(handleMutations);
|
|
2058
|
+
observe();
|
|
2059
|
+
},
|
|
2060
|
+
disconnect() {
|
|
2061
|
+
observer === null || observer === void 0 || observer.disconnect();
|
|
2062
|
+
observer = void 0;
|
|
2063
|
+
unregisterHost === null || unregisterHost === void 0 || unregisterHost();
|
|
2064
|
+
unregisterHost = void 0;
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
function replaceOutletNodes(outlet, nextNodes) {
|
|
2069
|
+
const parent = outlet.end.parentNode;
|
|
2070
|
+
if (!parent || parent !== outlet.start.parentNode) return;
|
|
2071
|
+
let current = outlet.start.nextSibling;
|
|
2072
|
+
while (current && current !== outlet.end) {
|
|
2073
|
+
const next = current.nextSibling;
|
|
2074
|
+
parent.removeChild(current);
|
|
2075
|
+
current = next;
|
|
2076
|
+
}
|
|
2077
|
+
for (const node of nextNodes) parent.insertBefore(node, outlet.end);
|
|
2078
|
+
}
|
|
2079
|
+
function insertLightChildren(lightChildren, additions, record) {
|
|
2080
|
+
for (const node of additions) {
|
|
2081
|
+
const currentIndex = lightChildren.indexOf(node);
|
|
2082
|
+
if (currentIndex >= 0) lightChildren.splice(currentIndex, 1);
|
|
2083
|
+
}
|
|
2084
|
+
let insertionIndex = lightChildren.length;
|
|
2085
|
+
const previousIndex = record.previousSibling ? lightChildren.indexOf(record.previousSibling) : -1;
|
|
2086
|
+
const nextIndex = record.nextSibling ? lightChildren.indexOf(record.nextSibling) : -1;
|
|
2087
|
+
if (previousIndex >= 0) insertionIndex = previousIndex + 1;
|
|
2088
|
+
else if (nextIndex >= 0) insertionIndex = nextIndex;
|
|
2089
|
+
else if (record.previousSibling === null) insertionIndex = 0;
|
|
2090
|
+
lightChildren.splice(insertionIndex, 0, ...additions);
|
|
2091
|
+
}
|
|
2092
|
+
function createNativeSlot(name, fallback) {
|
|
2093
|
+
const slot = document.createElement("slot");
|
|
2094
|
+
if (name) slot.setAttribute("name", name);
|
|
2095
|
+
const fallbackValue = fallback === null || fallback === void 0 ? void 0 : fallback();
|
|
2096
|
+
if (fallbackValue != null) insert(slot, fallbackValue);
|
|
2097
|
+
return slot;
|
|
2098
|
+
}
|
|
2099
|
+
function findLightSlotNodes(nodes, name) {
|
|
2100
|
+
return nodes.filter((node) => matchesLightSlot(node, name));
|
|
2101
|
+
}
|
|
2102
|
+
function matchesLightSlot(node, name) {
|
|
2103
|
+
if (name) {
|
|
2104
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return false;
|
|
2105
|
+
return node.getAttribute("slot") === name;
|
|
2106
|
+
}
|
|
2107
|
+
if (node.nodeType === Node.ELEMENT_NODE) return !node.hasAttribute("slot");
|
|
2108
|
+
return isMeaningfulTextNode(node);
|
|
2109
|
+
}
|
|
2110
|
+
function isMeaningfulTextNode(node) {
|
|
2111
|
+
var _node$textContent;
|
|
2112
|
+
if (node.nodeType !== Node.TEXT_NODE) return false;
|
|
2113
|
+
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
2114
|
+
}
|
|
2115
|
+
//#endregion
|
|
1975
2116
|
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
1976
2117
|
const ZEUS_ELEMENT_DEFINITION = Symbol.for("zeus.element.definition");
|
|
1977
2118
|
function prop(input, options = {}) {
|
|
@@ -2013,8 +2154,8 @@ function createPropStore(defs) {
|
|
|
2013
2154
|
const props = {};
|
|
2014
2155
|
for (const def of defs) {
|
|
2015
2156
|
const slot = state();
|
|
2016
|
-
slots.set(def.
|
|
2017
|
-
Object.defineProperty(props, def.
|
|
2157
|
+
slots.set(def.name, slot);
|
|
2158
|
+
Object.defineProperty(props, def.name, {
|
|
2018
2159
|
configurable: false,
|
|
2019
2160
|
enumerable: true,
|
|
2020
2161
|
get() {
|
|
@@ -2053,7 +2194,7 @@ function defineElement(tagName, options, setup) {
|
|
|
2053
2194
|
setup,
|
|
2054
2195
|
propDefs
|
|
2055
2196
|
};
|
|
2056
|
-
const observedAttributes = propDefs
|
|
2197
|
+
const observedAttributes = getCustomElementObservedAttributes(propDefs);
|
|
2057
2198
|
class ZeusElement extends HTMLElement {
|
|
2058
2199
|
static get observedAttributes() {
|
|
2059
2200
|
return observedAttributes;
|
|
@@ -2062,7 +2203,8 @@ function defineElement(tagName, options, setup) {
|
|
|
2062
2203
|
super();
|
|
2063
2204
|
this.lightChildren = [];
|
|
2064
2205
|
this.capturedLightChildren = false;
|
|
2065
|
-
this.
|
|
2206
|
+
this.attributeProps = /* @__PURE__ */ new Set();
|
|
2207
|
+
this.reflectingAttrs = /* @__PURE__ */ new Set();
|
|
2066
2208
|
this.propStore = createPropStore(propDefs);
|
|
2067
2209
|
this.props = this.propStore.props;
|
|
2068
2210
|
applyPropDefaults(this.propStore, propDefs);
|
|
@@ -2074,17 +2216,23 @@ function defineElement(tagName, options, setup) {
|
|
|
2074
2216
|
emit: createEmitApi(this, options.emits),
|
|
2075
2217
|
expose: createExpose(this)
|
|
2076
2218
|
};
|
|
2219
|
+
this.mountLifecycle = createCustomElementMountLifecycle(() => this.mountElement());
|
|
2077
2220
|
}
|
|
2078
2221
|
connectedCallback() {
|
|
2222
|
+
this.mountLifecycle.connect();
|
|
2223
|
+
}
|
|
2224
|
+
disconnectedCallback() {
|
|
2225
|
+
this.mountLifecycle.disconnect();
|
|
2226
|
+
}
|
|
2227
|
+
mountElement() {
|
|
2079
2228
|
var _options$shadow, _options$consumes;
|
|
2080
|
-
if (this.dispose) return;
|
|
2081
2229
|
const shadow = (_options$shadow = options.shadow) !== null && _options$shadow !== void 0 ? _options$shadow : false;
|
|
2082
2230
|
const mode = shadow ? "shadow" : "light";
|
|
2083
2231
|
if (mode === "light" && !this.capturedLightChildren) {
|
|
2084
2232
|
this.lightChildren = Array.from(this.childNodes);
|
|
2085
2233
|
this.capturedLightChildren = true;
|
|
2086
2234
|
}
|
|
2087
|
-
this.
|
|
2235
|
+
const projection = mode === "light" ? createLightDomProjection(this, this.lightChildren) : void 0;
|
|
2088
2236
|
const owner = createOwner();
|
|
2089
2237
|
for (const context of (_options$consumes = options.consumes) !== null && _options$consumes !== void 0 ? _options$consumes : []) {
|
|
2090
2238
|
const resolved = resolveDOMContext(this, context);
|
|
@@ -2095,18 +2243,19 @@ function defineElement(tagName, options, setup) {
|
|
|
2095
2243
|
const hostContext = {
|
|
2096
2244
|
host: this,
|
|
2097
2245
|
mode,
|
|
2098
|
-
lightChildren: this.lightChildren
|
|
2246
|
+
lightChildren: this.lightChildren,
|
|
2247
|
+
projection
|
|
2099
2248
|
};
|
|
2100
|
-
|
|
2249
|
+
const dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => {
|
|
2101
2250
|
syncFormValue(this.props, this.setupContext, options.form);
|
|
2102
2251
|
return setup(this.props, this.setupContext);
|
|
2103
2252
|
})), target, { owner });
|
|
2104
2253
|
mountStyles(target, options.styles);
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2254
|
+
projection === null || projection === void 0 || projection.connect();
|
|
2255
|
+
return { dispose() {
|
|
2256
|
+
projection === null || projection === void 0 || projection.disconnect();
|
|
2257
|
+
dispose();
|
|
2258
|
+
} };
|
|
2110
2259
|
}
|
|
2111
2260
|
formAssociatedCallback(form) {
|
|
2112
2261
|
var _options$form, _options$form$associa;
|
|
@@ -2125,10 +2274,11 @@ function defineElement(tagName, options, setup) {
|
|
|
2125
2274
|
(_options$form4 = options.form) === null || _options$form4 === void 0 || (_options$form4$stateR = _options$form4.stateRestore) === null || _options$form4$stateR === void 0 || _options$form4$stateR.call(_options$form4, state, mode, this.props, this.setupContext);
|
|
2126
2275
|
}
|
|
2127
2276
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2128
|
-
if (oldValue === newValue || this.
|
|
2129
|
-
const def = propDefs.find((item) => item.
|
|
2277
|
+
if (oldValue === newValue || this.reflectingAttrs.has(name)) return;
|
|
2278
|
+
const def = propDefs.find((item) => item.attrName === name);
|
|
2130
2279
|
if (!def) return;
|
|
2131
|
-
this.
|
|
2280
|
+
this.attributeProps.add(def.name);
|
|
2281
|
+
this.propStore.set(def.name, coerceCustomElementAttribute(def, newValue));
|
|
2132
2282
|
}
|
|
2133
2283
|
resolveRenderTarget(shadow) {
|
|
2134
2284
|
if (this.target) return this.target;
|
|
@@ -2139,24 +2289,11 @@ function defineElement(tagName, options, setup) {
|
|
|
2139
2289
|
this.target = this.attachShadow(typeof shadow === "object" ? shadow : { mode: "open" });
|
|
2140
2290
|
return this.target;
|
|
2141
2291
|
}
|
|
2142
|
-
syncAttributesToProps(defs) {
|
|
2143
|
-
for (const def of defs) {
|
|
2144
|
-
if (def.attr === false) continue;
|
|
2145
|
-
const value = this.getAttribute(def.attr);
|
|
2146
|
-
if (value !== null || def.type === Boolean) this.propStore.set(def.key, castAttributeValue(value, def));
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
2292
|
_writePropFromProperty(key, value) {
|
|
2150
|
-
const def = propDefs.find((item) => item.
|
|
2293
|
+
const def = propDefs.find((item) => item.name === key);
|
|
2294
|
+
this.attributeProps.delete(key);
|
|
2151
2295
|
this.propStore.set(key, value);
|
|
2152
|
-
if (
|
|
2153
|
-
this.reflecting = true;
|
|
2154
|
-
try {
|
|
2155
|
-
reflectPropToAttribute(this, def, value);
|
|
2156
|
-
} finally {
|
|
2157
|
-
this.reflecting = false;
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2296
|
+
if (def === null || def === void 0 ? void 0 : def.reflect) reflectCustomElementProperty(this, def, value, this.reflectingAttrs);
|
|
2160
2297
|
}
|
|
2161
2298
|
}
|
|
2162
2299
|
ZeusElement.formAssociated = Boolean(options.formAssociated);
|
|
@@ -2174,18 +2311,18 @@ function normalizePropDefinitions(props) {
|
|
|
2174
2311
|
if (typeof input === "function") {
|
|
2175
2312
|
const type = input;
|
|
2176
2313
|
return {
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
type,
|
|
2314
|
+
name: propKey,
|
|
2315
|
+
attrName: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
|
|
2316
|
+
type: normalizePropType(type),
|
|
2180
2317
|
reflect: false
|
|
2181
2318
|
};
|
|
2182
2319
|
}
|
|
2183
2320
|
const type = input === null || input === void 0 ? void 0 : input.type;
|
|
2184
2321
|
const defaultAttr = isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false;
|
|
2185
2322
|
return {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
type,
|
|
2323
|
+
name: propKey,
|
|
2324
|
+
attrName: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
|
|
2325
|
+
type: normalizePropType(type),
|
|
2189
2326
|
reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
|
|
2190
2327
|
default: input === null || input === void 0 ? void 0 : input.default,
|
|
2191
2328
|
serialize: input === null || input === void 0 ? void 0 : input.serialize,
|
|
@@ -2197,12 +2334,12 @@ function applyPropDefaults(store, defs) {
|
|
|
2197
2334
|
for (const def of defs) {
|
|
2198
2335
|
if (!("default" in def)) continue;
|
|
2199
2336
|
const value = typeof def.default === "function" ? def.default() : def.default;
|
|
2200
|
-
store.set(def.
|
|
2337
|
+
store.set(def.name, value);
|
|
2201
2338
|
}
|
|
2202
2339
|
}
|
|
2203
2340
|
function definePropAccessors(element, store, defs) {
|
|
2204
2341
|
for (const def of defs) {
|
|
2205
|
-
const key = def.
|
|
2342
|
+
const key = def.name;
|
|
2206
2343
|
const hadOwnValue = Object.prototype.hasOwnProperty.call(element, key);
|
|
2207
2344
|
const ownValue = hadOwnValue ? element[key] : void 0;
|
|
2208
2345
|
if (hadOwnValue) delete element[key];
|
|
@@ -2224,44 +2361,6 @@ function definePropAccessors(element, store, defs) {
|
|
|
2224
2361
|
if (hadOwnValue) element._writePropFromProperty(key, ownValue);
|
|
2225
2362
|
}
|
|
2226
2363
|
}
|
|
2227
|
-
function castAttributeValue(value, def) {
|
|
2228
|
-
if (def.deserialize) return def.deserialize(value);
|
|
2229
|
-
if (def.type === Boolean) return value !== null;
|
|
2230
|
-
if (value === null) return;
|
|
2231
|
-
if (def.type === Number) return Number(value);
|
|
2232
|
-
if (def.type === Object || def.type === Array) try {
|
|
2233
|
-
return JSON.parse(value);
|
|
2234
|
-
} catch (_unused) {
|
|
2235
|
-
console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${def.attr}".`);
|
|
2236
|
-
return def.type === Array ? [] : {};
|
|
2237
|
-
}
|
|
2238
|
-
if (def.type === Function) return;
|
|
2239
|
-
return value;
|
|
2240
|
-
}
|
|
2241
|
-
function reflectPropToAttribute(element, def, value) {
|
|
2242
|
-
if (def.attr === false) return;
|
|
2243
|
-
if (def.serialize) {
|
|
2244
|
-
const serialized = def.serialize(value);
|
|
2245
|
-
if (serialized == null) element.removeAttribute(def.attr);
|
|
2246
|
-
else element.setAttribute(def.attr, serialized);
|
|
2247
|
-
return;
|
|
2248
|
-
}
|
|
2249
|
-
if (def.type === Boolean) {
|
|
2250
|
-
if (value) element.setAttribute(def.attr, "");
|
|
2251
|
-
else element.removeAttribute(def.attr);
|
|
2252
|
-
return;
|
|
2253
|
-
}
|
|
2254
|
-
if (value == null) {
|
|
2255
|
-
element.removeAttribute(def.attr);
|
|
2256
|
-
return;
|
|
2257
|
-
}
|
|
2258
|
-
if (def.type === Object || def.type === Array) {
|
|
2259
|
-
element.setAttribute(def.attr, JSON.stringify(value));
|
|
2260
|
-
return;
|
|
2261
|
-
}
|
|
2262
|
-
if (def.type === Function) return;
|
|
2263
|
-
element.setAttribute(def.attr, String(value));
|
|
2264
|
-
}
|
|
2265
2364
|
function syncFormValue(props, context, form) {
|
|
2266
2365
|
const valueResolver = form === null || form === void 0 ? void 0 : form.value;
|
|
2267
2366
|
const stateResolver = form === null || form === void 0 ? void 0 : form.state;
|
|
@@ -2323,6 +2422,15 @@ function createExpose(host) {
|
|
|
2323
2422
|
function isAttributeBackedConstructor(type) {
|
|
2324
2423
|
return type === String || type === Number || type === Boolean;
|
|
2325
2424
|
}
|
|
2425
|
+
function normalizePropType(type) {
|
|
2426
|
+
if (type === String) return "string";
|
|
2427
|
+
if (type === Number) return "number";
|
|
2428
|
+
if (type === Boolean) return "boolean";
|
|
2429
|
+
if (type === Object) return "object";
|
|
2430
|
+
if (type === Array) return "array";
|
|
2431
|
+
if (type === Function) return "function";
|
|
2432
|
+
return "unknown";
|
|
2433
|
+
}
|
|
2326
2434
|
function mountStyles(target, styles) {
|
|
2327
2435
|
if (!styles) return;
|
|
2328
2436
|
const list = Array.isArray(styles) ? styles : [styles];
|
|
@@ -2360,38 +2468,6 @@ function bindRef(el, target) {
|
|
|
2360
2468
|
}, true);
|
|
2361
2469
|
}
|
|
2362
2470
|
//#endregion
|
|
2363
|
-
//#region packages/core/runtime-dom/src/slot.ts
|
|
2364
|
-
function createSlot(name, fallback) {
|
|
2365
|
-
const context = getCurrentHostContext();
|
|
2366
|
-
if (!context) return createNativeSlot(name, fallback);
|
|
2367
|
-
if (context.mode === "shadow") return createNativeSlot(name, fallback);
|
|
2368
|
-
const assigned = findLightSlotNodes(context.lightChildren, name);
|
|
2369
|
-
if (assigned.length > 0) return Array.from(assigned);
|
|
2370
|
-
return fallback ? fallback() : null;
|
|
2371
|
-
}
|
|
2372
|
-
function createNativeSlot(name, fallback) {
|
|
2373
|
-
const slot = document.createElement("slot");
|
|
2374
|
-
if (name) slot.setAttribute("name", name);
|
|
2375
|
-
const fallbackValue = fallback === null || fallback === void 0 ? void 0 : fallback();
|
|
2376
|
-
if (fallbackValue != null) insert(slot, fallbackValue);
|
|
2377
|
-
return slot;
|
|
2378
|
-
}
|
|
2379
|
-
function findLightSlotNodes(nodes, name) {
|
|
2380
|
-
if (name) return nodes.filter((node) => {
|
|
2381
|
-
if (node.nodeType !== Node.ELEMENT_NODE) return false;
|
|
2382
|
-
return node.getAttribute("slot") === name;
|
|
2383
|
-
});
|
|
2384
|
-
return nodes.filter((node) => {
|
|
2385
|
-
if (node.nodeType === Node.ELEMENT_NODE) return !node.hasAttribute("slot");
|
|
2386
|
-
return isMeaningfulTextNode(node);
|
|
2387
|
-
});
|
|
2388
|
-
}
|
|
2389
|
-
function isMeaningfulTextNode(node) {
|
|
2390
|
-
var _node$textContent;
|
|
2391
|
-
if (node.nodeType !== Node.TEXT_NODE) return false;
|
|
2392
|
-
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
2393
|
-
}
|
|
2394
|
-
//#endregion
|
|
2395
2471
|
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
2396
2472
|
const HOST_RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
2397
2473
|
"children",
|
|
@@ -2532,4 +2608,4 @@ function setFallbackRef(target, el) {
|
|
|
2532
2608
|
}
|
|
2533
2609
|
}
|
|
2534
2610
|
//#endregion
|
|
2535
|
-
export { For, Fragment, Host, Show, Slot, batch,
|
|
2611
|
+
export { For, Fragment, Host, Show, Slot, batch, createContext, createEffect, createMemo, createRoot, createSignal, defineElement, event, inject, jsx, jsxDEV, jsxs, onCleanup, prop, provide, render, useContext };
|