@zeus-js/runtime-dom 0.0.2 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime-dom.cjs.js +191 -43
- package/dist/runtime-dom.cjs.prod.js +185 -43
- package/dist/runtime-dom.d.ts +54 -39
- package/dist/runtime-dom.esm-browser.js +202 -55
- package/dist/runtime-dom.esm-browser.prod.js +1 -1
- package/dist/runtime-dom.esm-bundler.js +191 -44
- package/dist/runtime-dom.global.js +202 -54
- package/dist/runtime-dom.global.prod.js +1 -1
- package/package.json +4 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* runtime-dom v0.0.
|
|
2
|
+
* runtime-dom v0.1.0-beta.1
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
6
6
|
var ZeusRuntimeDOM = (function(exports) {
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
//#region packages/runtime-dom/src/template.ts
|
|
8
|
+
//#region packages/core/runtime-dom/src/template.ts
|
|
9
9
|
function template(html, _isImportNode = false, _isSVG = false, _isMathML = false) {
|
|
10
10
|
const t = document.createElement("template");
|
|
11
11
|
t.innerHTML = html;
|
|
@@ -14,7 +14,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region packages/shared/src/makeMap.ts
|
|
17
|
+
//#region packages/core/shared/src/makeMap.ts
|
|
18
18
|
/**
|
|
19
19
|
* Make a map and return a function for checking if a key
|
|
20
20
|
* is in that map.
|
|
@@ -58,12 +58,12 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
58
58
|
});
|
|
59
59
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
60
60
|
//#endregion
|
|
61
|
-
//#region packages/signal/src/warning.ts
|
|
61
|
+
//#region packages/core/signal/src/warning.ts
|
|
62
62
|
function warn(msg, ...args) {
|
|
63
63
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
|
-
//#region packages/signal/src/effectScope.ts
|
|
66
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
67
67
|
let activeEffectScope;
|
|
68
68
|
var EffectScope = class {
|
|
69
69
|
constructor(detached = false) {
|
|
@@ -203,7 +203,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
203
203
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
204
204
|
}
|
|
205
205
|
//#endregion
|
|
206
|
-
//#region packages/signal/src/effect.ts
|
|
206
|
+
//#region packages/core/signal/src/effect.ts
|
|
207
207
|
let activeSub;
|
|
208
208
|
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
|
209
209
|
var ReactiveEffect = class {
|
|
@@ -489,7 +489,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
//#endregion
|
|
492
|
-
//#region packages/signal/src/dep.ts
|
|
492
|
+
//#region packages/core/signal/src/dep.ts
|
|
493
493
|
/**
|
|
494
494
|
* Incremented every time a reactive change happens
|
|
495
495
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -680,7 +680,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
680
680
|
endBatch();
|
|
681
681
|
}
|
|
682
682
|
//#endregion
|
|
683
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
683
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
684
684
|
/**
|
|
685
685
|
* Track array iteration and return:
|
|
686
686
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -865,7 +865,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
865
865
|
return res;
|
|
866
866
|
}
|
|
867
867
|
//#endregion
|
|
868
|
-
//#region packages/signal/src/ref.ts
|
|
868
|
+
//#region packages/core/signal/src/ref.ts
|
|
869
869
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
870
870
|
/*@__NO_SIDE_EFFECTS__*/
|
|
871
871
|
function isRef(r) {
|
|
@@ -919,7 +919,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
919
919
|
}
|
|
920
920
|
};
|
|
921
921
|
//#endregion
|
|
922
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
922
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
923
923
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
924
924
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
925
925
|
function hasOwnProperty(key) {
|
|
@@ -1023,7 +1023,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1023
1023
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1024
1024
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1025
1025
|
//#endregion
|
|
1026
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1026
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1027
1027
|
const toShallow = (value) => value;
|
|
1028
1028
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1029
1029
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1182,7 +1182,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
1184
1184
|
//#endregion
|
|
1185
|
-
//#region packages/signal/src/reactive.ts
|
|
1185
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1186
1186
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1187
1187
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1188
1188
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1351,7 +1351,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1351
1351
|
*/
|
|
1352
1352
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1353
1353
|
//#endregion
|
|
1354
|
-
//#region packages/signal/src/state.ts
|
|
1354
|
+
//#region packages/core/signal/src/state.ts
|
|
1355
1355
|
function state(value) {
|
|
1356
1356
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1357
1357
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1367,7 +1367,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1367
1367
|
return proto === Object.prototype || proto === null;
|
|
1368
1368
|
}
|
|
1369
1369
|
//#endregion
|
|
1370
|
-
//#region packages/runtime-dom/src/hostContext.ts
|
|
1370
|
+
//#region packages/core/runtime-dom/src/hostContext.ts
|
|
1371
1371
|
let currentHostContext;
|
|
1372
1372
|
function getCurrentHostContext() {
|
|
1373
1373
|
return currentHostContext;
|
|
@@ -1391,7 +1391,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1391
1391
|
});
|
|
1392
1392
|
}
|
|
1393
1393
|
//#endregion
|
|
1394
|
-
//#region packages/runtime-dom/src/range.ts
|
|
1394
|
+
//#region packages/core/runtime-dom/src/range.ts
|
|
1395
1395
|
var DynamicRange = class {
|
|
1396
1396
|
constructor(parent, marker) {
|
|
1397
1397
|
this.parent = parent;
|
|
@@ -1413,7 +1413,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1413
1413
|
return this.nodes;
|
|
1414
1414
|
}
|
|
1415
1415
|
};
|
|
1416
|
-
function insertTracked(parent, value, marker) {
|
|
1416
|
+
function insertTracked(parent, value, marker = null) {
|
|
1417
1417
|
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
1418
1418
|
if (Array.isArray(value)) {
|
|
1419
1419
|
const nodes = [];
|
|
@@ -1430,11 +1430,11 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1430
1430
|
(_node$parentNode2 = node.parentNode) === null || _node$parentNode2 === void 0 || _node$parentNode2.removeChild(node);
|
|
1431
1431
|
}
|
|
1432
1432
|
}
|
|
1433
|
-
function moveRangeBefore(nodes, parent, marker) {
|
|
1433
|
+
function moveRangeBefore(nodes, parent, marker = null) {
|
|
1434
1434
|
for (const node of nodes) parent.insertBefore(node, marker);
|
|
1435
1435
|
}
|
|
1436
1436
|
//#endregion
|
|
1437
|
-
//#region packages/runtime-dom/src/insert.ts
|
|
1437
|
+
//#region packages/core/runtime-dom/src/insert.ts
|
|
1438
1438
|
function insert(parent, value, marker = null) {
|
|
1439
1439
|
if (value === void 0) {
|
|
1440
1440
|
console.warn("[Zeus runtime] insert received `undefined`, which is ignored. Use `null` or a fallback value explicitly if you want to suppress this warning.");
|
|
@@ -1456,7 +1456,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1456
1456
|
}, true);
|
|
1457
1457
|
}
|
|
1458
1458
|
//#endregion
|
|
1459
|
-
//#region packages/runtime-dom/src/context.ts
|
|
1459
|
+
//#region packages/core/runtime-dom/src/context.ts
|
|
1460
1460
|
let currentOwner;
|
|
1461
1461
|
function getCurrentOwner() {
|
|
1462
1462
|
return currentOwner;
|
|
@@ -1595,14 +1595,14 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1595
1595
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
1596
1596
|
}
|
|
1597
1597
|
//#endregion
|
|
1598
|
-
//#region packages/runtime-dom/src/devtools.ts
|
|
1598
|
+
//#region packages/core/runtime-dom/src/devtools.ts
|
|
1599
1599
|
function emitDevtoolsEvent(event) {
|
|
1600
1600
|
var _window$__ZEUS_DEVTOO;
|
|
1601
1601
|
if (typeof window === "undefined") return;
|
|
1602
1602
|
(_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
|
|
1603
1603
|
}
|
|
1604
1604
|
//#endregion
|
|
1605
|
-
//#region packages/runtime-dom/src/render.ts
|
|
1605
|
+
//#region packages/core/runtime-dom/src/render.ts
|
|
1606
1606
|
function render(value, container, options = {}) {
|
|
1607
1607
|
var _options$owner;
|
|
1608
1608
|
const renderScope = effectScope();
|
|
@@ -1629,7 +1629,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1629
1629
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
1630
1630
|
}
|
|
1631
1631
|
//#endregion
|
|
1632
|
-
//#region packages/runtime-dom/src/dom.ts
|
|
1632
|
+
//#region packages/core/runtime-dom/src/dom.ts
|
|
1633
1633
|
function marker(parent, index) {
|
|
1634
1634
|
let seen = 0;
|
|
1635
1635
|
for (const node of parent.childNodes) {
|
|
@@ -1653,7 +1653,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1653
1653
|
}
|
|
1654
1654
|
}
|
|
1655
1655
|
//#endregion
|
|
1656
|
-
//#region packages/runtime-dom/src/bindings.ts
|
|
1656
|
+
//#region packages/core/runtime-dom/src/bindings.ts
|
|
1657
1657
|
function bindText(node, value) {
|
|
1658
1658
|
effect(() => {
|
|
1659
1659
|
node.data = stringifyText(value());
|
|
@@ -1674,17 +1674,43 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1674
1674
|
return String(value);
|
|
1675
1675
|
}
|
|
1676
1676
|
function setAttr(el, name, value) {
|
|
1677
|
+
const attrName = normalizeAttrName(name);
|
|
1678
|
+
const propName = getBooleanDomPropertyName(name);
|
|
1679
|
+
if (propName && el instanceof HTMLElement) {
|
|
1680
|
+
el[propName] = Boolean(value);
|
|
1681
|
+
if (value == null || value === false) el.removeAttribute(attrName);
|
|
1682
|
+
else if (value === true) el.setAttribute(attrName, "");
|
|
1683
|
+
else el.setAttribute(attrName, String(value));
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1677
1686
|
if (value == null || value === false) {
|
|
1678
|
-
el.removeAttribute(
|
|
1687
|
+
el.removeAttribute(attrName);
|
|
1679
1688
|
return;
|
|
1680
1689
|
}
|
|
1681
|
-
const attrName = normalizeAttrName(name);
|
|
1682
1690
|
if (value === true) {
|
|
1683
1691
|
el.setAttribute(attrName, "");
|
|
1684
1692
|
return;
|
|
1685
1693
|
}
|
|
1686
1694
|
el.setAttribute(attrName, String(value));
|
|
1687
1695
|
}
|
|
1696
|
+
function getBooleanDomPropertyName(name) {
|
|
1697
|
+
return BOOLEAN_DOM_PROPERTY_NAME[name];
|
|
1698
|
+
}
|
|
1699
|
+
const BOOLEAN_DOM_PROPERTY_NAME = {
|
|
1700
|
+
hidden: "hidden",
|
|
1701
|
+
disabled: "disabled",
|
|
1702
|
+
readonly: "readOnly",
|
|
1703
|
+
readOnly: "readOnly",
|
|
1704
|
+
multiple: "multiple",
|
|
1705
|
+
selected: "selected",
|
|
1706
|
+
checked: "checked",
|
|
1707
|
+
open: "open",
|
|
1708
|
+
autofocus: "autofocus",
|
|
1709
|
+
autoFocus: "autofocus",
|
|
1710
|
+
indeterminate: "indeterminate",
|
|
1711
|
+
noValidate: "noValidate",
|
|
1712
|
+
novalidate: "noValidate"
|
|
1713
|
+
};
|
|
1688
1714
|
function normalizeAttrName(name) {
|
|
1689
1715
|
return name === "className" ? "class" : name;
|
|
1690
1716
|
}
|
|
@@ -1763,7 +1789,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1763
1789
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1764
1790
|
}
|
|
1765
1791
|
//#endregion
|
|
1766
|
-
//#region packages/runtime-dom/src/events.ts
|
|
1792
|
+
//#region packages/core/runtime-dom/src/events.ts
|
|
1767
1793
|
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
1768
1794
|
const delegatedListeners = [];
|
|
1769
1795
|
const nonBubblingEventMap = {
|
|
@@ -1838,7 +1864,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1838
1864
|
}
|
|
1839
1865
|
}
|
|
1840
1866
|
//#endregion
|
|
1841
|
-
//#region packages/runtime-dom/src/refs.ts
|
|
1867
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
1842
1868
|
function setRef(target, value) {
|
|
1843
1869
|
if (target == null) return;
|
|
1844
1870
|
if (typeof target === "function") {
|
|
@@ -1862,12 +1888,12 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1862
1888
|
}, true);
|
|
1863
1889
|
}
|
|
1864
1890
|
//#endregion
|
|
1865
|
-
//#region packages/runtime-dom/src/component.ts
|
|
1891
|
+
//#region packages/core/runtime-dom/src/component.ts
|
|
1866
1892
|
function createComponent(component, props) {
|
|
1867
1893
|
return runWithOwner(createOwner(), () => component(props));
|
|
1868
1894
|
}
|
|
1869
1895
|
//#endregion
|
|
1870
|
-
//#region packages/runtime-dom/src/list.ts
|
|
1896
|
+
//#region packages/core/runtime-dom/src/list.ts
|
|
1871
1897
|
function mountFor$1(parent, marker, each, key, render) {
|
|
1872
1898
|
if (!key) {
|
|
1873
1899
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -1925,7 +1951,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1925
1951
|
}
|
|
1926
1952
|
emitDevtoolsEvent({
|
|
1927
1953
|
type: "mount-for",
|
|
1928
|
-
length:
|
|
1954
|
+
length: nextRecords.length
|
|
1929
1955
|
});
|
|
1930
1956
|
records = nextRecords;
|
|
1931
1957
|
});
|
|
@@ -1936,7 +1962,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
1936
1962
|
}, true);
|
|
1937
1963
|
}
|
|
1938
1964
|
//#endregion
|
|
1939
|
-
//#region packages/runtime-dom/src/controlFlow.ts
|
|
1965
|
+
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
1940
1966
|
function Show(props) {
|
|
1941
1967
|
return resolveValue(props.when ? props.children : props.fallback);
|
|
1942
1968
|
}
|
|
@@ -2016,7 +2042,43 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2016
2042
|
return e;
|
|
2017
2043
|
}
|
|
2018
2044
|
//#endregion
|
|
2019
|
-
//#region packages/runtime-dom/src/defineElement.ts
|
|
2045
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
2046
|
+
function createPropStore(defs) {
|
|
2047
|
+
const slots = /* @__PURE__ */ new Map();
|
|
2048
|
+
const props = {};
|
|
2049
|
+
for (const def of defs) {
|
|
2050
|
+
const slot = state();
|
|
2051
|
+
slots.set(def.key, slot);
|
|
2052
|
+
Object.defineProperty(props, def.key, {
|
|
2053
|
+
configurable: false,
|
|
2054
|
+
enumerable: true,
|
|
2055
|
+
get() {
|
|
2056
|
+
return slot.value;
|
|
2057
|
+
},
|
|
2058
|
+
set(value) {
|
|
2059
|
+
slot.value = value;
|
|
2060
|
+
}
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
return {
|
|
2064
|
+
props,
|
|
2065
|
+
get(key) {
|
|
2066
|
+
var _slots$get;
|
|
2067
|
+
return (_slots$get = slots.get(key)) === null || _slots$get === void 0 ? void 0 : _slots$get.value;
|
|
2068
|
+
},
|
|
2069
|
+
set(key, value) {
|
|
2070
|
+
const slot = slots.get(key);
|
|
2071
|
+
if (!slot) {
|
|
2072
|
+
console.warn(`[Zeus custom-element] Unknown prop "${key}" was written.`);
|
|
2073
|
+
return;
|
|
2074
|
+
}
|
|
2075
|
+
slot.value = value;
|
|
2076
|
+
},
|
|
2077
|
+
has(key) {
|
|
2078
|
+
return slots.has(key);
|
|
2079
|
+
}
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2020
2082
|
function defineElement(tagName, options, setup) {
|
|
2021
2083
|
var _options$props;
|
|
2022
2084
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
@@ -2027,12 +2089,13 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2027
2089
|
}
|
|
2028
2090
|
constructor() {
|
|
2029
2091
|
super();
|
|
2030
|
-
this.props = state({});
|
|
2031
2092
|
this.lightChildren = [];
|
|
2032
2093
|
this.capturedLightChildren = false;
|
|
2033
2094
|
this.reflecting = false;
|
|
2034
|
-
|
|
2035
|
-
|
|
2095
|
+
this.propStore = createPropStore(propDefs);
|
|
2096
|
+
this.props = this.propStore.props;
|
|
2097
|
+
applyPropDefaults(this.propStore, propDefs);
|
|
2098
|
+
definePropAccessors(this, this.propStore, propDefs);
|
|
2036
2099
|
}
|
|
2037
2100
|
connectedCallback() {
|
|
2038
2101
|
var _options$shadow, _options$consumes;
|
|
@@ -2068,22 +2131,17 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2068
2131
|
};
|
|
2069
2132
|
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
2070
2133
|
mountStyles(target, options.styles);
|
|
2071
|
-
onScopeDispose(() => {
|
|
2072
|
-
var _this$dispose;
|
|
2073
|
-
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
2074
|
-
this.dispose = void 0;
|
|
2075
|
-
}, true);
|
|
2076
2134
|
}
|
|
2077
2135
|
disconnectedCallback() {
|
|
2078
|
-
var _this$
|
|
2079
|
-
(_this$
|
|
2136
|
+
var _this$dispose;
|
|
2137
|
+
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
2080
2138
|
this.dispose = void 0;
|
|
2081
2139
|
}
|
|
2082
2140
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2083
2141
|
if (oldValue === newValue || this.reflecting) return;
|
|
2084
2142
|
const def = propDefs.find((item) => item.attr === name);
|
|
2085
2143
|
if (!def) return;
|
|
2086
|
-
this.
|
|
2144
|
+
this.propStore.set(def.key, castAttributeValue(newValue, def));
|
|
2087
2145
|
}
|
|
2088
2146
|
resolveRenderTarget(shadow) {
|
|
2089
2147
|
if (this.target) return this.target;
|
|
@@ -2098,12 +2156,12 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2098
2156
|
for (const def of defs) {
|
|
2099
2157
|
if (def.attr === false) continue;
|
|
2100
2158
|
const value = this.getAttribute(def.attr);
|
|
2101
|
-
if (value !== null || def.type === Boolean) this.
|
|
2159
|
+
if (value !== null || def.type === Boolean) this.propStore.set(def.key, castAttributeValue(value, def));
|
|
2102
2160
|
}
|
|
2103
2161
|
}
|
|
2104
2162
|
_writePropFromProperty(key, value) {
|
|
2105
2163
|
const def = propDefs.find((item) => item.key === key);
|
|
2106
|
-
this.
|
|
2164
|
+
this.propStore.set(key, value);
|
|
2107
2165
|
if ((def === null || def === void 0 ? void 0 : def.reflect) && def.attr !== false) {
|
|
2108
2166
|
this.reflecting = true;
|
|
2109
2167
|
try {
|
|
@@ -2135,26 +2193,35 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2135
2193
|
};
|
|
2136
2194
|
});
|
|
2137
2195
|
}
|
|
2138
|
-
function applyPropDefaults(
|
|
2196
|
+
function applyPropDefaults(store, defs) {
|
|
2139
2197
|
for (const def of defs) {
|
|
2140
2198
|
if (!("default" in def)) continue;
|
|
2141
2199
|
const value = typeof def.default === "function" ? def.default() : def.default;
|
|
2142
|
-
|
|
2200
|
+
store.set(def.key, value);
|
|
2143
2201
|
}
|
|
2144
2202
|
}
|
|
2145
|
-
function definePropAccessors(element,
|
|
2203
|
+
function definePropAccessors(element, store, defs) {
|
|
2146
2204
|
for (const def of defs) {
|
|
2147
|
-
|
|
2148
|
-
Object.
|
|
2205
|
+
const key = def.key;
|
|
2206
|
+
const hadOwnValue = Object.prototype.hasOwnProperty.call(element, key);
|
|
2207
|
+
const ownValue = hadOwnValue ? element[key] : void 0;
|
|
2208
|
+
if (hadOwnValue) delete element[key];
|
|
2209
|
+
const existing = Object.getOwnPropertyDescriptor(element, key);
|
|
2210
|
+
if (existing && existing.configurable === false) {
|
|
2211
|
+
console.warn(`[Zeus custom-element] Cannot define prop "${key}" because an own non-configurable property already exists.`);
|
|
2212
|
+
continue;
|
|
2213
|
+
}
|
|
2214
|
+
Object.defineProperty(element, key, {
|
|
2149
2215
|
configurable: true,
|
|
2150
2216
|
enumerable: true,
|
|
2151
2217
|
get() {
|
|
2152
|
-
return
|
|
2218
|
+
return store.get(key);
|
|
2153
2219
|
},
|
|
2154
2220
|
set(value) {
|
|
2155
|
-
element._writePropFromProperty(
|
|
2221
|
+
element._writePropFromProperty(key, value);
|
|
2156
2222
|
}
|
|
2157
2223
|
});
|
|
2224
|
+
if (hadOwnValue) element._writePropFromProperty(key, ownValue);
|
|
2158
2225
|
}
|
|
2159
2226
|
}
|
|
2160
2227
|
function castAttributeValue(value, def) {
|
|
@@ -2199,7 +2266,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2199
2266
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
2200
2267
|
}
|
|
2201
2268
|
//#endregion
|
|
2202
|
-
//#region packages/runtime-dom/src/slot.ts
|
|
2269
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
2203
2270
|
function createSlot(name, fallback) {
|
|
2204
2271
|
const context = getCurrentHostContext();
|
|
2205
2272
|
if (!context) return createNativeSlot(name, fallback);
|
|
@@ -2231,16 +2298,96 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2231
2298
|
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
2232
2299
|
}
|
|
2233
2300
|
//#endregion
|
|
2234
|
-
//#region packages/runtime-dom/src/webComponents.ts
|
|
2301
|
+
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
2302
|
+
const HOST_RESERVED_KEYS = new Set([
|
|
2303
|
+
"children",
|
|
2304
|
+
"ref",
|
|
2305
|
+
"class",
|
|
2306
|
+
"className",
|
|
2307
|
+
"style",
|
|
2308
|
+
"_elements"
|
|
2309
|
+
]);
|
|
2235
2310
|
function Host(props) {
|
|
2311
|
+
const context = getCurrentHostContext();
|
|
2312
|
+
if (context) bindHostProps(context.host, props);
|
|
2236
2313
|
return resolveValue$1(props.children);
|
|
2237
2314
|
}
|
|
2238
2315
|
function Slot(props) {
|
|
2239
2316
|
return createSlot(props.name, () => resolveValue$1(props.children));
|
|
2240
2317
|
}
|
|
2318
|
+
function bindHostProps(host, props) {
|
|
2319
|
+
bindHostRef(host, props);
|
|
2320
|
+
bindHostClass(host, props);
|
|
2321
|
+
bindHostStyle(host, props);
|
|
2322
|
+
bindHostAttributes(host, props);
|
|
2323
|
+
if ("_elements" in props) bindHostElementBindings(host, props);
|
|
2324
|
+
}
|
|
2325
|
+
function bindHostRef(host, props) {
|
|
2326
|
+
if (!("ref" in props)) return;
|
|
2327
|
+
bindRef(host, props.ref);
|
|
2328
|
+
}
|
|
2329
|
+
function bindHostClass(host, props) {
|
|
2330
|
+
if (!("class" in props) && !("className" in props)) return;
|
|
2331
|
+
const value = props.className !== void 0 ? props.className : props.class;
|
|
2332
|
+
bindClass(host, () => {
|
|
2333
|
+
return resolveHostValue(value);
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
function bindHostStyle(host, props) {
|
|
2337
|
+
if (!("style" in props)) return;
|
|
2338
|
+
bindStyle(host, () => {
|
|
2339
|
+
return resolveHostValue(props.style);
|
|
2340
|
+
});
|
|
2341
|
+
}
|
|
2342
|
+
function bindHostAttributes(host, props) {
|
|
2343
|
+
for (const key of Object.keys(props)) {
|
|
2344
|
+
if (HOST_RESERVED_KEYS.has(key)) continue;
|
|
2345
|
+
if (isEventLikeProp(key)) continue;
|
|
2346
|
+
const value = props[key];
|
|
2347
|
+
bindAttr(host, normalizeHostAttrName(key), () => {
|
|
2348
|
+
return resolveHostValue(value);
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
function bindHostElementBindings(host, props) {
|
|
2353
|
+
const elements = props._elements;
|
|
2354
|
+
for (const _key of Object.keys(elements)) {
|
|
2355
|
+
const getEl = elements[_key];
|
|
2356
|
+
const el = getEl();
|
|
2357
|
+
if (!el) continue;
|
|
2358
|
+
for (const attrKey of Object.keys(props)) {
|
|
2359
|
+
if (HOST_RESERVED_KEYS.has(attrKey)) continue;
|
|
2360
|
+
if (isEventLikeProp(attrKey)) continue;
|
|
2361
|
+
const value = props[attrKey];
|
|
2362
|
+
bindAttr(el, normalizeHostAttrName(attrKey), () => {
|
|
2363
|
+
return resolveHostValue(value);
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
function resolveHostValue(value) {
|
|
2369
|
+
if (typeof value === "function") return value();
|
|
2370
|
+
return value;
|
|
2371
|
+
}
|
|
2241
2372
|
function resolveValue$1(value) {
|
|
2242
2373
|
return typeof value === "function" ? value() : value;
|
|
2243
2374
|
}
|
|
2375
|
+
function isEventLikeProp(key) {
|
|
2376
|
+
/**
|
|
2377
|
+
* Host Phase 1 does not bind event listeners.
|
|
2378
|
+
* Keep event handling inside component template + emit().
|
|
2379
|
+
*/
|
|
2380
|
+
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
2381
|
+
}
|
|
2382
|
+
function normalizeHostAttrName(name) {
|
|
2383
|
+
switch (name) {
|
|
2384
|
+
case "className": return "class";
|
|
2385
|
+
case "htmlFor": return "for";
|
|
2386
|
+
case "tabIndex": return "tabindex";
|
|
2387
|
+
case "readOnly": return "readonly";
|
|
2388
|
+
default: return name;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2244
2391
|
//#endregion
|
|
2245
2392
|
exports.For = For;
|
|
2246
2393
|
exports.Host = Host;
|
|
@@ -2268,6 +2415,7 @@ var ZeusRuntimeDOM = (function(exports) {
|
|
|
2268
2415
|
exports.getCurrentOwner = getCurrentOwner;
|
|
2269
2416
|
exports.inject = inject;
|
|
2270
2417
|
exports.insert = insert;
|
|
2418
|
+
exports.insertTracked = insertTracked;
|
|
2271
2419
|
exports.marker = marker;
|
|
2272
2420
|
exports.mountDynamic = mountDynamic;
|
|
2273
2421
|
exports.mountFor = mountFor;
|