@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,9 +1,9 @@
|
|
|
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
|
-
//#region packages/runtime-dom/src/template.ts
|
|
6
|
+
//#region packages/core/runtime-dom/src/template.ts
|
|
7
7
|
function template(html, _isImportNode = false, _isSVG = false, _isMathML = false) {
|
|
8
8
|
const t = document.createElement("template");
|
|
9
9
|
t.innerHTML = html;
|
|
@@ -12,7 +12,7 @@ function template(html, _isImportNode = false, _isSVG = false, _isMathML = false
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
|
-
//#region packages/shared/src/makeMap.ts
|
|
15
|
+
//#region packages/core/shared/src/makeMap.ts
|
|
16
16
|
/**
|
|
17
17
|
* Make a map and return a function for checking if a key
|
|
18
18
|
* is in that map.
|
|
@@ -56,12 +56,12 @@ const capitalize = cacheStringFunction((str) => {
|
|
|
56
56
|
});
|
|
57
57
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
58
58
|
//#endregion
|
|
59
|
-
//#region packages/signal/src/warning.ts
|
|
59
|
+
//#region packages/core/signal/src/warning.ts
|
|
60
60
|
function warn(msg, ...args) {
|
|
61
61
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
62
62
|
}
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region packages/signal/src/effectScope.ts
|
|
64
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
65
65
|
let activeEffectScope;
|
|
66
66
|
var EffectScope = class {
|
|
67
67
|
constructor(detached = false) {
|
|
@@ -201,7 +201,7 @@ function onScopeDispose(fn, failSilently = false) {
|
|
|
201
201
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
202
202
|
}
|
|
203
203
|
//#endregion
|
|
204
|
-
//#region packages/signal/src/effect.ts
|
|
204
|
+
//#region packages/core/signal/src/effect.ts
|
|
205
205
|
let activeSub;
|
|
206
206
|
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
|
207
207
|
var ReactiveEffect = class {
|
|
@@ -487,7 +487,7 @@ function cleanupEffect(e) {
|
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
//#endregion
|
|
490
|
-
//#region packages/signal/src/dep.ts
|
|
490
|
+
//#region packages/core/signal/src/dep.ts
|
|
491
491
|
/**
|
|
492
492
|
* Incremented every time a reactive change happens
|
|
493
493
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -678,7 +678,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
678
678
|
endBatch();
|
|
679
679
|
}
|
|
680
680
|
//#endregion
|
|
681
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
681
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
682
682
|
/**
|
|
683
683
|
* Track array iteration and return:
|
|
684
684
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -863,7 +863,7 @@ function noTracking(self, method, args = []) {
|
|
|
863
863
|
return res;
|
|
864
864
|
}
|
|
865
865
|
//#endregion
|
|
866
|
-
//#region packages/signal/src/ref.ts
|
|
866
|
+
//#region packages/core/signal/src/ref.ts
|
|
867
867
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
868
868
|
/*@__NO_SIDE_EFFECTS__*/
|
|
869
869
|
function isRef(r) {
|
|
@@ -917,7 +917,7 @@ var RefImpl = class {
|
|
|
917
917
|
}
|
|
918
918
|
};
|
|
919
919
|
//#endregion
|
|
920
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
920
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
921
921
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
922
922
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
923
923
|
function hasOwnProperty(key) {
|
|
@@ -1021,7 +1021,7 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
1021
1021
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1022
1022
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1023
1023
|
//#endregion
|
|
1024
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1024
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1025
1025
|
const toShallow = (value) => value;
|
|
1026
1026
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1027
1027
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1180,7 +1180,7 @@ function checkIdentityKeys(target, has, key) {
|
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
1182
|
//#endregion
|
|
1183
|
-
//#region packages/signal/src/reactive.ts
|
|
1183
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1184
1184
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1185
1185
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1186
1186
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1349,7 +1349,7 @@ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value)
|
|
|
1349
1349
|
*/
|
|
1350
1350
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1351
1351
|
//#endregion
|
|
1352
|
-
//#region packages/signal/src/state.ts
|
|
1352
|
+
//#region packages/core/signal/src/state.ts
|
|
1353
1353
|
function state(value) {
|
|
1354
1354
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1355
1355
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1365,7 +1365,7 @@ function isPlainObject(value) {
|
|
|
1365
1365
|
return proto === Object.prototype || proto === null;
|
|
1366
1366
|
}
|
|
1367
1367
|
//#endregion
|
|
1368
|
-
//#region packages/runtime-dom/src/hostContext.ts
|
|
1368
|
+
//#region packages/core/runtime-dom/src/hostContext.ts
|
|
1369
1369
|
let currentHostContext;
|
|
1370
1370
|
function getCurrentHostContext() {
|
|
1371
1371
|
return currentHostContext;
|
|
@@ -1389,7 +1389,7 @@ function withCapturedHostContext(fn) {
|
|
|
1389
1389
|
});
|
|
1390
1390
|
}
|
|
1391
1391
|
//#endregion
|
|
1392
|
-
//#region packages/runtime-dom/src/range.ts
|
|
1392
|
+
//#region packages/core/runtime-dom/src/range.ts
|
|
1393
1393
|
var DynamicRange = class {
|
|
1394
1394
|
constructor(parent, marker) {
|
|
1395
1395
|
this.parent = parent;
|
|
@@ -1411,7 +1411,7 @@ var DynamicRange = class {
|
|
|
1411
1411
|
return this.nodes;
|
|
1412
1412
|
}
|
|
1413
1413
|
};
|
|
1414
|
-
function insertTracked(parent, value, marker) {
|
|
1414
|
+
function insertTracked(parent, value, marker = null) {
|
|
1415
1415
|
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
1416
1416
|
if (Array.isArray(value)) {
|
|
1417
1417
|
const nodes = [];
|
|
@@ -1428,11 +1428,11 @@ function removeNodes$1(nodes) {
|
|
|
1428
1428
|
(_node$parentNode2 = node.parentNode) === null || _node$parentNode2 === void 0 || _node$parentNode2.removeChild(node);
|
|
1429
1429
|
}
|
|
1430
1430
|
}
|
|
1431
|
-
function moveRangeBefore(nodes, parent, marker) {
|
|
1431
|
+
function moveRangeBefore(nodes, parent, marker = null) {
|
|
1432
1432
|
for (const node of nodes) parent.insertBefore(node, marker);
|
|
1433
1433
|
}
|
|
1434
1434
|
//#endregion
|
|
1435
|
-
//#region packages/runtime-dom/src/insert.ts
|
|
1435
|
+
//#region packages/core/runtime-dom/src/insert.ts
|
|
1436
1436
|
function insert(parent, value, marker = null) {
|
|
1437
1437
|
if (value === void 0) {
|
|
1438
1438
|
console.warn("[Zeus runtime] insert received `undefined`, which is ignored. Use `null` or a fallback value explicitly if you want to suppress this warning.");
|
|
@@ -1454,7 +1454,7 @@ function mountDynamic(parent, marker, value) {
|
|
|
1454
1454
|
}, true);
|
|
1455
1455
|
}
|
|
1456
1456
|
//#endregion
|
|
1457
|
-
//#region packages/runtime-dom/src/context.ts
|
|
1457
|
+
//#region packages/core/runtime-dom/src/context.ts
|
|
1458
1458
|
let currentOwner;
|
|
1459
1459
|
function getCurrentOwner() {
|
|
1460
1460
|
return currentOwner;
|
|
@@ -1593,14 +1593,14 @@ function resolveValue$3(value) {
|
|
|
1593
1593
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
1594
1594
|
}
|
|
1595
1595
|
//#endregion
|
|
1596
|
-
//#region packages/runtime-dom/src/devtools.ts
|
|
1596
|
+
//#region packages/core/runtime-dom/src/devtools.ts
|
|
1597
1597
|
function emitDevtoolsEvent(event) {
|
|
1598
1598
|
var _window$__ZEUS_DEVTOO;
|
|
1599
1599
|
if (typeof window === "undefined") return;
|
|
1600
1600
|
(_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
|
|
1601
1601
|
}
|
|
1602
1602
|
//#endregion
|
|
1603
|
-
//#region packages/runtime-dom/src/render.ts
|
|
1603
|
+
//#region packages/core/runtime-dom/src/render.ts
|
|
1604
1604
|
function render(value, container, options = {}) {
|
|
1605
1605
|
var _options$owner;
|
|
1606
1606
|
const renderScope = effectScope();
|
|
@@ -1627,7 +1627,7 @@ function resolveValue$2(value) {
|
|
|
1627
1627
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
1628
1628
|
}
|
|
1629
1629
|
//#endregion
|
|
1630
|
-
//#region packages/runtime-dom/src/dom.ts
|
|
1630
|
+
//#region packages/core/runtime-dom/src/dom.ts
|
|
1631
1631
|
function marker(parent, index) {
|
|
1632
1632
|
let seen = 0;
|
|
1633
1633
|
for (const node of parent.childNodes) {
|
|
@@ -1651,7 +1651,7 @@ function removeNodes(nodes) {
|
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
1653
|
//#endregion
|
|
1654
|
-
//#region packages/runtime-dom/src/bindings.ts
|
|
1654
|
+
//#region packages/core/runtime-dom/src/bindings.ts
|
|
1655
1655
|
function bindText(node, value) {
|
|
1656
1656
|
effect(() => {
|
|
1657
1657
|
node.data = stringifyText(value());
|
|
@@ -1672,17 +1672,43 @@ function stringifyText(value) {
|
|
|
1672
1672
|
return String(value);
|
|
1673
1673
|
}
|
|
1674
1674
|
function setAttr(el, name, value) {
|
|
1675
|
+
const attrName = normalizeAttrName(name);
|
|
1676
|
+
const propName = getBooleanDomPropertyName(name);
|
|
1677
|
+
if (propName && el instanceof HTMLElement) {
|
|
1678
|
+
el[propName] = Boolean(value);
|
|
1679
|
+
if (value == null || value === false) el.removeAttribute(attrName);
|
|
1680
|
+
else if (value === true) el.setAttribute(attrName, "");
|
|
1681
|
+
else el.setAttribute(attrName, String(value));
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1675
1684
|
if (value == null || value === false) {
|
|
1676
|
-
el.removeAttribute(
|
|
1685
|
+
el.removeAttribute(attrName);
|
|
1677
1686
|
return;
|
|
1678
1687
|
}
|
|
1679
|
-
const attrName = normalizeAttrName(name);
|
|
1680
1688
|
if (value === true) {
|
|
1681
1689
|
el.setAttribute(attrName, "");
|
|
1682
1690
|
return;
|
|
1683
1691
|
}
|
|
1684
1692
|
el.setAttribute(attrName, String(value));
|
|
1685
1693
|
}
|
|
1694
|
+
function getBooleanDomPropertyName(name) {
|
|
1695
|
+
return BOOLEAN_DOM_PROPERTY_NAME[name];
|
|
1696
|
+
}
|
|
1697
|
+
const BOOLEAN_DOM_PROPERTY_NAME = {
|
|
1698
|
+
hidden: "hidden",
|
|
1699
|
+
disabled: "disabled",
|
|
1700
|
+
readonly: "readOnly",
|
|
1701
|
+
readOnly: "readOnly",
|
|
1702
|
+
multiple: "multiple",
|
|
1703
|
+
selected: "selected",
|
|
1704
|
+
checked: "checked",
|
|
1705
|
+
open: "open",
|
|
1706
|
+
autofocus: "autofocus",
|
|
1707
|
+
autoFocus: "autofocus",
|
|
1708
|
+
indeterminate: "indeterminate",
|
|
1709
|
+
noValidate: "noValidate",
|
|
1710
|
+
novalidate: "noValidate"
|
|
1711
|
+
};
|
|
1686
1712
|
function normalizeAttrName(name) {
|
|
1687
1713
|
return name === "className" ? "class" : name;
|
|
1688
1714
|
}
|
|
@@ -1761,7 +1787,7 @@ function toKebabCase$1(value) {
|
|
|
1761
1787
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1762
1788
|
}
|
|
1763
1789
|
//#endregion
|
|
1764
|
-
//#region packages/runtime-dom/src/events.ts
|
|
1790
|
+
//#region packages/core/runtime-dom/src/events.ts
|
|
1765
1791
|
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
1766
1792
|
const delegatedListeners = [];
|
|
1767
1793
|
const nonBubblingEventMap = {
|
|
@@ -1836,7 +1862,7 @@ function callDelegatedHandler(el, handler, event) {
|
|
|
1836
1862
|
}
|
|
1837
1863
|
}
|
|
1838
1864
|
//#endregion
|
|
1839
|
-
//#region packages/runtime-dom/src/refs.ts
|
|
1865
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
1840
1866
|
function setRef(target, value) {
|
|
1841
1867
|
if (target == null) return;
|
|
1842
1868
|
if (typeof target === "function") {
|
|
@@ -1860,12 +1886,12 @@ function bindRef(el, target) {
|
|
|
1860
1886
|
}, true);
|
|
1861
1887
|
}
|
|
1862
1888
|
//#endregion
|
|
1863
|
-
//#region packages/runtime-dom/src/component.ts
|
|
1889
|
+
//#region packages/core/runtime-dom/src/component.ts
|
|
1864
1890
|
function createComponent(component, props) {
|
|
1865
1891
|
return runWithOwner(createOwner(), () => component(props));
|
|
1866
1892
|
}
|
|
1867
1893
|
//#endregion
|
|
1868
|
-
//#region packages/runtime-dom/src/list.ts
|
|
1894
|
+
//#region packages/core/runtime-dom/src/list.ts
|
|
1869
1895
|
function mountFor$1(parent, marker, each, key, render) {
|
|
1870
1896
|
if (!key) {
|
|
1871
1897
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -1923,7 +1949,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
1923
1949
|
}
|
|
1924
1950
|
emitDevtoolsEvent({
|
|
1925
1951
|
type: "mount-for",
|
|
1926
|
-
length:
|
|
1952
|
+
length: nextRecords.length
|
|
1927
1953
|
});
|
|
1928
1954
|
records = nextRecords;
|
|
1929
1955
|
});
|
|
@@ -1934,7 +1960,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
1934
1960
|
}, true);
|
|
1935
1961
|
}
|
|
1936
1962
|
//#endregion
|
|
1937
|
-
//#region packages/runtime-dom/src/controlFlow.ts
|
|
1963
|
+
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
1938
1964
|
function Show(props) {
|
|
1939
1965
|
return resolveValue(props.when ? props.children : props.fallback);
|
|
1940
1966
|
}
|
|
@@ -2014,7 +2040,43 @@ function _objectSpread2(e) {
|
|
|
2014
2040
|
return e;
|
|
2015
2041
|
}
|
|
2016
2042
|
//#endregion
|
|
2017
|
-
//#region packages/runtime-dom/src/defineElement.ts
|
|
2043
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
2044
|
+
function createPropStore(defs) {
|
|
2045
|
+
const slots = /* @__PURE__ */ new Map();
|
|
2046
|
+
const props = {};
|
|
2047
|
+
for (const def of defs) {
|
|
2048
|
+
const slot = state();
|
|
2049
|
+
slots.set(def.key, slot);
|
|
2050
|
+
Object.defineProperty(props, def.key, {
|
|
2051
|
+
configurable: false,
|
|
2052
|
+
enumerable: true,
|
|
2053
|
+
get() {
|
|
2054
|
+
return slot.value;
|
|
2055
|
+
},
|
|
2056
|
+
set(value) {
|
|
2057
|
+
slot.value = value;
|
|
2058
|
+
}
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
return {
|
|
2062
|
+
props,
|
|
2063
|
+
get(key) {
|
|
2064
|
+
var _slots$get;
|
|
2065
|
+
return (_slots$get = slots.get(key)) === null || _slots$get === void 0 ? void 0 : _slots$get.value;
|
|
2066
|
+
},
|
|
2067
|
+
set(key, value) {
|
|
2068
|
+
const slot = slots.get(key);
|
|
2069
|
+
if (!slot) {
|
|
2070
|
+
console.warn(`[Zeus custom-element] Unknown prop "${key}" was written.`);
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
slot.value = value;
|
|
2074
|
+
},
|
|
2075
|
+
has(key) {
|
|
2076
|
+
return slots.has(key);
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
}
|
|
2018
2080
|
function defineElement(tagName, options, setup) {
|
|
2019
2081
|
var _options$props;
|
|
2020
2082
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
@@ -2025,12 +2087,13 @@ function defineElement(tagName, options, setup) {
|
|
|
2025
2087
|
}
|
|
2026
2088
|
constructor() {
|
|
2027
2089
|
super();
|
|
2028
|
-
this.props = state({});
|
|
2029
2090
|
this.lightChildren = [];
|
|
2030
2091
|
this.capturedLightChildren = false;
|
|
2031
2092
|
this.reflecting = false;
|
|
2032
|
-
|
|
2033
|
-
|
|
2093
|
+
this.propStore = createPropStore(propDefs);
|
|
2094
|
+
this.props = this.propStore.props;
|
|
2095
|
+
applyPropDefaults(this.propStore, propDefs);
|
|
2096
|
+
definePropAccessors(this, this.propStore, propDefs);
|
|
2034
2097
|
}
|
|
2035
2098
|
connectedCallback() {
|
|
2036
2099
|
var _options$shadow, _options$consumes;
|
|
@@ -2066,22 +2129,17 @@ function defineElement(tagName, options, setup) {
|
|
|
2066
2129
|
};
|
|
2067
2130
|
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
2068
2131
|
mountStyles(target, options.styles);
|
|
2069
|
-
onScopeDispose(() => {
|
|
2070
|
-
var _this$dispose;
|
|
2071
|
-
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
2072
|
-
this.dispose = void 0;
|
|
2073
|
-
}, true);
|
|
2074
2132
|
}
|
|
2075
2133
|
disconnectedCallback() {
|
|
2076
|
-
var _this$
|
|
2077
|
-
(_this$
|
|
2134
|
+
var _this$dispose;
|
|
2135
|
+
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
2078
2136
|
this.dispose = void 0;
|
|
2079
2137
|
}
|
|
2080
2138
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2081
2139
|
if (oldValue === newValue || this.reflecting) return;
|
|
2082
2140
|
const def = propDefs.find((item) => item.attr === name);
|
|
2083
2141
|
if (!def) return;
|
|
2084
|
-
this.
|
|
2142
|
+
this.propStore.set(def.key, castAttributeValue(newValue, def));
|
|
2085
2143
|
}
|
|
2086
2144
|
resolveRenderTarget(shadow) {
|
|
2087
2145
|
if (this.target) return this.target;
|
|
@@ -2096,12 +2154,12 @@ function defineElement(tagName, options, setup) {
|
|
|
2096
2154
|
for (const def of defs) {
|
|
2097
2155
|
if (def.attr === false) continue;
|
|
2098
2156
|
const value = this.getAttribute(def.attr);
|
|
2099
|
-
if (value !== null || def.type === Boolean) this.
|
|
2157
|
+
if (value !== null || def.type === Boolean) this.propStore.set(def.key, castAttributeValue(value, def));
|
|
2100
2158
|
}
|
|
2101
2159
|
}
|
|
2102
2160
|
_writePropFromProperty(key, value) {
|
|
2103
2161
|
const def = propDefs.find((item) => item.key === key);
|
|
2104
|
-
this.
|
|
2162
|
+
this.propStore.set(key, value);
|
|
2105
2163
|
if ((def === null || def === void 0 ? void 0 : def.reflect) && def.attr !== false) {
|
|
2106
2164
|
this.reflecting = true;
|
|
2107
2165
|
try {
|
|
@@ -2133,26 +2191,35 @@ function normalizePropDefinitions(props) {
|
|
|
2133
2191
|
};
|
|
2134
2192
|
});
|
|
2135
2193
|
}
|
|
2136
|
-
function applyPropDefaults(
|
|
2194
|
+
function applyPropDefaults(store, defs) {
|
|
2137
2195
|
for (const def of defs) {
|
|
2138
2196
|
if (!("default" in def)) continue;
|
|
2139
2197
|
const value = typeof def.default === "function" ? def.default() : def.default;
|
|
2140
|
-
|
|
2198
|
+
store.set(def.key, value);
|
|
2141
2199
|
}
|
|
2142
2200
|
}
|
|
2143
|
-
function definePropAccessors(element,
|
|
2201
|
+
function definePropAccessors(element, store, defs) {
|
|
2144
2202
|
for (const def of defs) {
|
|
2145
|
-
|
|
2146
|
-
Object.
|
|
2203
|
+
const key = def.key;
|
|
2204
|
+
const hadOwnValue = Object.prototype.hasOwnProperty.call(element, key);
|
|
2205
|
+
const ownValue = hadOwnValue ? element[key] : void 0;
|
|
2206
|
+
if (hadOwnValue) delete element[key];
|
|
2207
|
+
const existing = Object.getOwnPropertyDescriptor(element, key);
|
|
2208
|
+
if (existing && existing.configurable === false) {
|
|
2209
|
+
console.warn(`[Zeus custom-element] Cannot define prop "${key}" because an own non-configurable property already exists.`);
|
|
2210
|
+
continue;
|
|
2211
|
+
}
|
|
2212
|
+
Object.defineProperty(element, key, {
|
|
2147
2213
|
configurable: true,
|
|
2148
2214
|
enumerable: true,
|
|
2149
2215
|
get() {
|
|
2150
|
-
return
|
|
2216
|
+
return store.get(key);
|
|
2151
2217
|
},
|
|
2152
2218
|
set(value) {
|
|
2153
|
-
element._writePropFromProperty(
|
|
2219
|
+
element._writePropFromProperty(key, value);
|
|
2154
2220
|
}
|
|
2155
2221
|
});
|
|
2222
|
+
if (hadOwnValue) element._writePropFromProperty(key, ownValue);
|
|
2156
2223
|
}
|
|
2157
2224
|
}
|
|
2158
2225
|
function castAttributeValue(value, def) {
|
|
@@ -2197,7 +2264,7 @@ function toKebabCase(value) {
|
|
|
2197
2264
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
2198
2265
|
}
|
|
2199
2266
|
//#endregion
|
|
2200
|
-
//#region packages/runtime-dom/src/slot.ts
|
|
2267
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
2201
2268
|
function createSlot(name, fallback) {
|
|
2202
2269
|
const context = getCurrentHostContext();
|
|
2203
2270
|
if (!context) return createNativeSlot(name, fallback);
|
|
@@ -2229,15 +2296,95 @@ function isMeaningfulTextNode(node) {
|
|
|
2229
2296
|
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
2230
2297
|
}
|
|
2231
2298
|
//#endregion
|
|
2232
|
-
//#region packages/runtime-dom/src/webComponents.ts
|
|
2299
|
+
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
2300
|
+
const HOST_RESERVED_KEYS = new Set([
|
|
2301
|
+
"children",
|
|
2302
|
+
"ref",
|
|
2303
|
+
"class",
|
|
2304
|
+
"className",
|
|
2305
|
+
"style",
|
|
2306
|
+
"_elements"
|
|
2307
|
+
]);
|
|
2233
2308
|
function Host(props) {
|
|
2309
|
+
const context = getCurrentHostContext();
|
|
2310
|
+
if (context) bindHostProps(context.host, props);
|
|
2234
2311
|
return resolveValue$1(props.children);
|
|
2235
2312
|
}
|
|
2236
2313
|
function Slot(props) {
|
|
2237
2314
|
return createSlot(props.name, () => resolveValue$1(props.children));
|
|
2238
2315
|
}
|
|
2316
|
+
function bindHostProps(host, props) {
|
|
2317
|
+
bindHostRef(host, props);
|
|
2318
|
+
bindHostClass(host, props);
|
|
2319
|
+
bindHostStyle(host, props);
|
|
2320
|
+
bindHostAttributes(host, props);
|
|
2321
|
+
if ("_elements" in props) bindHostElementBindings(host, props);
|
|
2322
|
+
}
|
|
2323
|
+
function bindHostRef(host, props) {
|
|
2324
|
+
if (!("ref" in props)) return;
|
|
2325
|
+
bindRef(host, props.ref);
|
|
2326
|
+
}
|
|
2327
|
+
function bindHostClass(host, props) {
|
|
2328
|
+
if (!("class" in props) && !("className" in props)) return;
|
|
2329
|
+
const value = props.className !== void 0 ? props.className : props.class;
|
|
2330
|
+
bindClass(host, () => {
|
|
2331
|
+
return resolveHostValue(value);
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
function bindHostStyle(host, props) {
|
|
2335
|
+
if (!("style" in props)) return;
|
|
2336
|
+
bindStyle(host, () => {
|
|
2337
|
+
return resolveHostValue(props.style);
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
function bindHostAttributes(host, props) {
|
|
2341
|
+
for (const key of Object.keys(props)) {
|
|
2342
|
+
if (HOST_RESERVED_KEYS.has(key)) continue;
|
|
2343
|
+
if (isEventLikeProp(key)) continue;
|
|
2344
|
+
const value = props[key];
|
|
2345
|
+
bindAttr(host, normalizeHostAttrName(key), () => {
|
|
2346
|
+
return resolveHostValue(value);
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
function bindHostElementBindings(host, props) {
|
|
2351
|
+
const elements = props._elements;
|
|
2352
|
+
for (const _key of Object.keys(elements)) {
|
|
2353
|
+
const getEl = elements[_key];
|
|
2354
|
+
const el = getEl();
|
|
2355
|
+
if (!el) continue;
|
|
2356
|
+
for (const attrKey of Object.keys(props)) {
|
|
2357
|
+
if (HOST_RESERVED_KEYS.has(attrKey)) continue;
|
|
2358
|
+
if (isEventLikeProp(attrKey)) continue;
|
|
2359
|
+
const value = props[attrKey];
|
|
2360
|
+
bindAttr(el, normalizeHostAttrName(attrKey), () => {
|
|
2361
|
+
return resolveHostValue(value);
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
function resolveHostValue(value) {
|
|
2367
|
+
if (typeof value === "function") return value();
|
|
2368
|
+
return value;
|
|
2369
|
+
}
|
|
2239
2370
|
function resolveValue$1(value) {
|
|
2240
2371
|
return typeof value === "function" ? value() : value;
|
|
2241
2372
|
}
|
|
2373
|
+
function isEventLikeProp(key) {
|
|
2374
|
+
/**
|
|
2375
|
+
* Host Phase 1 does not bind event listeners.
|
|
2376
|
+
* Keep event handling inside component template + emit().
|
|
2377
|
+
*/
|
|
2378
|
+
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
2379
|
+
}
|
|
2380
|
+
function normalizeHostAttrName(name) {
|
|
2381
|
+
switch (name) {
|
|
2382
|
+
case "className": return "class";
|
|
2383
|
+
case "htmlFor": return "for";
|
|
2384
|
+
case "tabIndex": return "tabindex";
|
|
2385
|
+
case "readOnly": return "readonly";
|
|
2386
|
+
default: return name;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2242
2389
|
//#endregion
|
|
2243
|
-
export { For, Host, Show, Slot, ZEUS_CONTEXT_REQUEST, bindAttr, bindClass, bindEvent, bindProp, bindRef, bindStyle, bindText, bindTextContent, captureCurrentHostContext, child, createComponent, createContext, createDOMContextBoundary, createOwner, createSlot, defineElement, delegateEvents, getCurrentHostContext, getCurrentOwner, inject, insert, marker, mountDynamic, mountFor, mountShow, normalizeClass, provide, provideDOMContext, removeNodes, render, requestDOMContext, resolveDOMContext, resolveValue, runWithOwner, setAttr, setRef, template, useContext, withCapturedHostContext, withHostContext };
|
|
2390
|
+
export { For, Host, Show, Slot, ZEUS_CONTEXT_REQUEST, bindAttr, bindClass, bindEvent, bindProp, bindRef, bindStyle, bindText, bindTextContent, captureCurrentHostContext, child, createComponent, createContext, createDOMContextBoundary, createOwner, createSlot, defineElement, delegateEvents, getCurrentHostContext, getCurrentOwner, inject, insert, insertTracked, marker, mountDynamic, mountFor, mountShow, normalizeClass, provide, provideDOMContext, removeNodes, render, requestDOMContext, resolveDOMContext, resolveValue, runWithOwner, setAttr, setRef, template, useContext, withCapturedHostContext, withHostContext };
|