@zeus-js/zeus 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/zeus.cjs.js +8 -2
- package/dist/zeus.cjs.prod.js +8 -2
- package/dist/zeus.d.mts +7 -1304
- package/dist/zeus.d.ts +7 -1304
- package/dist/zeus.esm-browser.js +318 -50
- package/dist/zeus.esm-browser.prod.js +1 -1
- package/dist/zeus.esm-bundler.js +9 -3
- package/dist/zeus.global.js +318 -50
- package/dist/zeus.global.prod.js +1 -1
- package/jsx-dev-runtime.d.ts +1 -1
- package/jsx-dev-runtime.js +1 -1
- package/jsx-runtime.d.ts +15 -1
- package/jsx-runtime.js +80 -1
- package/package.json +5 -6
- package/src/jsx.d.ts +88 -85
package/dist/zeus.global.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.0.
|
|
2
|
+
* zeus v0.1.0-beta.1
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
6
6
|
var Zeus = (function(exports) {
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
//#region packages/shared/src/makeMap.ts
|
|
8
|
+
//#region packages/core/shared/src/makeMap.ts
|
|
9
9
|
/**
|
|
10
10
|
* Make a map and return a function for checking if a key
|
|
11
11
|
* is in that map.
|
|
@@ -20,7 +20,7 @@ var Zeus = (function(exports) {
|
|
|
20
20
|
return (val) => val in map;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region packages/shared/src/general.ts
|
|
23
|
+
//#region packages/core/shared/src/general.ts
|
|
24
24
|
const EMPTY_OBJ = Object.freeze({});
|
|
25
25
|
Object.freeze([]);
|
|
26
26
|
const NOOP = () => {};
|
|
@@ -59,12 +59,12 @@ var Zeus = (function(exports) {
|
|
|
59
59
|
});
|
|
60
60
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
61
61
|
//#endregion
|
|
62
|
-
//#region packages/signal/src/warning.ts
|
|
62
|
+
//#region packages/core/signal/src/warning.ts
|
|
63
63
|
function warn(msg, ...args) {
|
|
64
64
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region packages/signal/src/effectScope.ts
|
|
67
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
68
68
|
let activeEffectScope;
|
|
69
69
|
var EffectScope = class {
|
|
70
70
|
constructor(detached = false) {
|
|
@@ -204,7 +204,7 @@ var Zeus = (function(exports) {
|
|
|
204
204
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
205
205
|
}
|
|
206
206
|
//#endregion
|
|
207
|
-
//#region packages/signal/src/effect.ts
|
|
207
|
+
//#region packages/core/signal/src/effect.ts
|
|
208
208
|
let activeSub;
|
|
209
209
|
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
|
210
210
|
var ReactiveEffect = class {
|
|
@@ -529,7 +529,7 @@ var Zeus = (function(exports) {
|
|
|
529
529
|
return activeSub instanceof ReactiveEffect ? activeSub : void 0;
|
|
530
530
|
}
|
|
531
531
|
//#endregion
|
|
532
|
-
//#region packages/signal/src/dep.ts
|
|
532
|
+
//#region packages/core/signal/src/dep.ts
|
|
533
533
|
/**
|
|
534
534
|
* Incremented every time a reactive change happens
|
|
535
535
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -720,7 +720,7 @@ var Zeus = (function(exports) {
|
|
|
720
720
|
endBatch();
|
|
721
721
|
}
|
|
722
722
|
//#endregion
|
|
723
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
723
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
724
724
|
/**
|
|
725
725
|
* Track array iteration and return:
|
|
726
726
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -905,7 +905,7 @@ var Zeus = (function(exports) {
|
|
|
905
905
|
return res;
|
|
906
906
|
}
|
|
907
907
|
//#endregion
|
|
908
|
-
//#region packages/signal/src/ref.ts
|
|
908
|
+
//#region packages/core/signal/src/ref.ts
|
|
909
909
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
910
910
|
/*@__NO_SIDE_EFFECTS__*/
|
|
911
911
|
function isRef(r) {
|
|
@@ -959,7 +959,7 @@ var Zeus = (function(exports) {
|
|
|
959
959
|
}
|
|
960
960
|
};
|
|
961
961
|
//#endregion
|
|
962
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
962
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
963
963
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
964
964
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
965
965
|
function hasOwnProperty(key) {
|
|
@@ -1063,7 +1063,7 @@ var Zeus = (function(exports) {
|
|
|
1063
1063
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1064
1064
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1065
1065
|
//#endregion
|
|
1066
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1066
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1067
1067
|
const toShallow = (value) => value;
|
|
1068
1068
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1069
1069
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1222,7 +1222,7 @@ var Zeus = (function(exports) {
|
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
1224
|
//#endregion
|
|
1225
|
-
//#region packages/signal/src/reactive.ts
|
|
1225
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1226
1226
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1227
1227
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1228
1228
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1391,7 +1391,7 @@ var Zeus = (function(exports) {
|
|
|
1391
1391
|
*/
|
|
1392
1392
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1393
1393
|
//#endregion
|
|
1394
|
-
//#region packages/signal/src/state.ts
|
|
1394
|
+
//#region packages/core/signal/src/state.ts
|
|
1395
1395
|
function state(value) {
|
|
1396
1396
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1397
1397
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1407,7 +1407,7 @@ var Zeus = (function(exports) {
|
|
|
1407
1407
|
return proto === Object.prototype || proto === null;
|
|
1408
1408
|
}
|
|
1409
1409
|
//#endregion
|
|
1410
|
-
//#region packages/signal/src/computed.ts
|
|
1410
|
+
//#region packages/core/signal/src/computed.ts
|
|
1411
1411
|
/**
|
|
1412
1412
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1413
1413
|
* the main vue package
|
|
@@ -1470,12 +1470,12 @@ var Zeus = (function(exports) {
|
|
|
1470
1470
|
return cRef;
|
|
1471
1471
|
}
|
|
1472
1472
|
//#endregion
|
|
1473
|
-
//#region packages/signal/src/scheduler.ts
|
|
1473
|
+
//#region packages/core/signal/src/scheduler.ts
|
|
1474
1474
|
function nextTick() {
|
|
1475
1475
|
return Promise.resolve();
|
|
1476
1476
|
}
|
|
1477
1477
|
//#endregion
|
|
1478
|
-
//#region packages/signal/src/watch.ts
|
|
1478
|
+
//#region packages/core/signal/src/watch.ts
|
|
1479
1479
|
const INITIAL_WATCHER_VALUE = {};
|
|
1480
1480
|
const cleanupMap = /* @__PURE__ */ new WeakMap();
|
|
1481
1481
|
let activeWatcher = void 0;
|
|
@@ -1631,7 +1631,7 @@ var Zeus = (function(exports) {
|
|
|
1631
1631
|
return value;
|
|
1632
1632
|
}
|
|
1633
1633
|
//#endregion
|
|
1634
|
-
//#region packages/signal/src/lifecycle.ts
|
|
1634
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
1635
1635
|
function onCleanup(fn) {
|
|
1636
1636
|
if (getCurrentEffect()) {
|
|
1637
1637
|
onEffectCleanup(fn, true);
|
|
@@ -1644,7 +1644,7 @@ var Zeus = (function(exports) {
|
|
|
1644
1644
|
warn("onCleanup() was called without active effect or scope.");
|
|
1645
1645
|
}
|
|
1646
1646
|
//#endregion
|
|
1647
|
-
//#region packages/runtime-dom/src/hostContext.ts
|
|
1647
|
+
//#region packages/core/runtime-dom/src/hostContext.ts
|
|
1648
1648
|
let currentHostContext;
|
|
1649
1649
|
function getCurrentHostContext() {
|
|
1650
1650
|
return currentHostContext;
|
|
@@ -1659,8 +1659,8 @@ var Zeus = (function(exports) {
|
|
|
1659
1659
|
}
|
|
1660
1660
|
}
|
|
1661
1661
|
//#endregion
|
|
1662
|
-
//#region packages/runtime-dom/src/range.ts
|
|
1663
|
-
function insertTracked(parent, value, marker) {
|
|
1662
|
+
//#region packages/core/runtime-dom/src/range.ts
|
|
1663
|
+
function insertTracked(parent, value, marker = null) {
|
|
1664
1664
|
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
1665
1665
|
if (Array.isArray(value)) {
|
|
1666
1666
|
const nodes = [];
|
|
@@ -1672,7 +1672,7 @@ var Zeus = (function(exports) {
|
|
|
1672
1672
|
return [node];
|
|
1673
1673
|
}
|
|
1674
1674
|
//#endregion
|
|
1675
|
-
//#region packages/runtime-dom/src/insert.ts
|
|
1675
|
+
//#region packages/core/runtime-dom/src/insert.ts
|
|
1676
1676
|
function insert(parent, value, marker = null) {
|
|
1677
1677
|
if (value === void 0) {
|
|
1678
1678
|
console.warn("[Zeus runtime] insert received `undefined`, which is ignored. Use `null` or a fallback value explicitly if you want to suppress this warning.");
|
|
@@ -1681,7 +1681,7 @@ var Zeus = (function(exports) {
|
|
|
1681
1681
|
insertTracked(parent, value, marker);
|
|
1682
1682
|
}
|
|
1683
1683
|
//#endregion
|
|
1684
|
-
//#region packages/runtime-dom/src/context.ts
|
|
1684
|
+
//#region packages/core/runtime-dom/src/context.ts
|
|
1685
1685
|
let currentOwner;
|
|
1686
1686
|
function createOwner(parent = currentOwner) {
|
|
1687
1687
|
return {
|
|
@@ -1807,14 +1807,14 @@ var Zeus = (function(exports) {
|
|
|
1807
1807
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
1808
1808
|
}
|
|
1809
1809
|
//#endregion
|
|
1810
|
-
//#region packages/runtime-dom/src/devtools.ts
|
|
1810
|
+
//#region packages/core/runtime-dom/src/devtools.ts
|
|
1811
1811
|
function emitDevtoolsEvent(event) {
|
|
1812
1812
|
var _window$__ZEUS_DEVTOO;
|
|
1813
1813
|
if (typeof window === "undefined") return;
|
|
1814
1814
|
(_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
|
|
1815
1815
|
}
|
|
1816
1816
|
//#endregion
|
|
1817
|
-
//#region packages/runtime-dom/src/render.ts
|
|
1817
|
+
//#region packages/core/runtime-dom/src/render.ts
|
|
1818
1818
|
function render(value, container, options = {}) {
|
|
1819
1819
|
var _options$owner;
|
|
1820
1820
|
const renderScope = effectScope();
|
|
@@ -1841,12 +1841,153 @@ var Zeus = (function(exports) {
|
|
|
1841
1841
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
1842
1842
|
}
|
|
1843
1843
|
//#endregion
|
|
1844
|
-
//#region packages/runtime-dom/src/
|
|
1844
|
+
//#region packages/core/runtime-dom/src/bindings.ts
|
|
1845
|
+
function setAttr(el, name, value) {
|
|
1846
|
+
const attrName = normalizeAttrName(name);
|
|
1847
|
+
const propName = getBooleanDomPropertyName(name);
|
|
1848
|
+
if (propName && el instanceof HTMLElement) {
|
|
1849
|
+
el[propName] = Boolean(value);
|
|
1850
|
+
if (value == null || value === false) el.removeAttribute(attrName);
|
|
1851
|
+
else if (value === true) el.setAttribute(attrName, "");
|
|
1852
|
+
else el.setAttribute(attrName, String(value));
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
if (value == null || value === false) {
|
|
1856
|
+
el.removeAttribute(attrName);
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
if (value === true) {
|
|
1860
|
+
el.setAttribute(attrName, "");
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
el.setAttribute(attrName, String(value));
|
|
1864
|
+
}
|
|
1865
|
+
function getBooleanDomPropertyName(name) {
|
|
1866
|
+
return BOOLEAN_DOM_PROPERTY_NAME[name];
|
|
1867
|
+
}
|
|
1868
|
+
const BOOLEAN_DOM_PROPERTY_NAME = {
|
|
1869
|
+
hidden: "hidden",
|
|
1870
|
+
disabled: "disabled",
|
|
1871
|
+
readonly: "readOnly",
|
|
1872
|
+
readOnly: "readOnly",
|
|
1873
|
+
multiple: "multiple",
|
|
1874
|
+
selected: "selected",
|
|
1875
|
+
checked: "checked",
|
|
1876
|
+
open: "open",
|
|
1877
|
+
autofocus: "autofocus",
|
|
1878
|
+
autoFocus: "autofocus",
|
|
1879
|
+
indeterminate: "indeterminate",
|
|
1880
|
+
noValidate: "noValidate",
|
|
1881
|
+
novalidate: "noValidate"
|
|
1882
|
+
};
|
|
1883
|
+
function normalizeAttrName(name) {
|
|
1884
|
+
return name === "className" ? "class" : name;
|
|
1885
|
+
}
|
|
1886
|
+
function bindAttr(el, name, value) {
|
|
1887
|
+
effect(() => {
|
|
1888
|
+
setAttr(el, name, value());
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
function bindProp(el, name, value) {
|
|
1892
|
+
effect(() => {
|
|
1893
|
+
el[name] = value();
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
function bindClass(el, value) {
|
|
1897
|
+
effect(() => {
|
|
1898
|
+
const next = normalizeClass(value());
|
|
1899
|
+
if (next) el.setAttribute("class", next);
|
|
1900
|
+
else el.removeAttribute("class");
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
function normalizeClass(value) {
|
|
1904
|
+
if (!value) return "";
|
|
1905
|
+
if (typeof value === "string") return value;
|
|
1906
|
+
if (Array.isArray(value)) return value.map(normalizeClass).filter(Boolean).join(" ");
|
|
1907
|
+
if (typeof value === "object") return Object.keys(value).filter((key) => value[key]).join(" ");
|
|
1908
|
+
return "";
|
|
1909
|
+
}
|
|
1910
|
+
function bindStyle(el, value) {
|
|
1911
|
+
let prev;
|
|
1912
|
+
effect(() => {
|
|
1913
|
+
const next = value();
|
|
1914
|
+
if (next == null) {
|
|
1915
|
+
el.removeAttribute("style");
|
|
1916
|
+
prev = void 0;
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
if (typeof next === "string") {
|
|
1920
|
+
el.setAttribute("style", next);
|
|
1921
|
+
prev = void 0;
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1924
|
+
patchStyle(el, prev, next);
|
|
1925
|
+
prev = next;
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
function patchStyle(el, prev, next) {
|
|
1929
|
+
const style = el.style;
|
|
1930
|
+
if (prev) {
|
|
1931
|
+
for (const key in prev) if (!(key in next)) style.setProperty(toKebabCase$1(key), "");
|
|
1932
|
+
}
|
|
1933
|
+
for (const key in next) {
|
|
1934
|
+
const value = next[key];
|
|
1935
|
+
const name = toKebabCase$1(key);
|
|
1936
|
+
if (value == null) style.setProperty(name, "");
|
|
1937
|
+
else style.setProperty(name, normalizeStyleValue(key, value));
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
function normalizeStyleValue(key, value) {
|
|
1941
|
+
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(key)) return `${value}px`;
|
|
1942
|
+
return String(value);
|
|
1943
|
+
}
|
|
1944
|
+
const unitlessNumbers = new Set([
|
|
1945
|
+
"opacity",
|
|
1946
|
+
"zIndex",
|
|
1947
|
+
"fontWeight",
|
|
1948
|
+
"lineHeight",
|
|
1949
|
+
"flex",
|
|
1950
|
+
"flexGrow",
|
|
1951
|
+
"flexShrink",
|
|
1952
|
+
"order"
|
|
1953
|
+
]);
|
|
1954
|
+
function isUnitlessNumber(key) {
|
|
1955
|
+
return unitlessNumbers.has(key);
|
|
1956
|
+
}
|
|
1957
|
+
function toKebabCase$1(value) {
|
|
1958
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1959
|
+
}
|
|
1960
|
+
//#endregion
|
|
1961
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
1962
|
+
function setRef(target, value) {
|
|
1963
|
+
if (target == null) return;
|
|
1964
|
+
if (typeof target === "function") {
|
|
1965
|
+
target(value);
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1968
|
+
if ("value" in target) {
|
|
1969
|
+
target.value = value;
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
if ("current" in target) {
|
|
1973
|
+
target.current = value;
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
console.warn("[Zeus runtime] Invalid ref target:", target);
|
|
1977
|
+
}
|
|
1978
|
+
function bindRef(el, target) {
|
|
1979
|
+
setRef(target, el);
|
|
1980
|
+
if (getCurrentScope()) onScopeDispose(() => {
|
|
1981
|
+
setRef(target, null);
|
|
1982
|
+
}, true);
|
|
1983
|
+
}
|
|
1984
|
+
//#endregion
|
|
1985
|
+
//#region packages/core/runtime-dom/src/component.ts
|
|
1845
1986
|
function createComponent(component, props) {
|
|
1846
1987
|
return runWithOwner(createOwner(), () => component(props));
|
|
1847
1988
|
}
|
|
1848
1989
|
//#endregion
|
|
1849
|
-
//#region packages/runtime-dom/src/controlFlow.ts
|
|
1990
|
+
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
1850
1991
|
function Show(props) {
|
|
1851
1992
|
return resolveValue$1(props.when ? props.children : props.fallback);
|
|
1852
1993
|
}
|
|
@@ -1920,7 +2061,43 @@ var Zeus = (function(exports) {
|
|
|
1920
2061
|
return e;
|
|
1921
2062
|
}
|
|
1922
2063
|
//#endregion
|
|
1923
|
-
//#region packages/runtime-dom/src/defineElement.ts
|
|
2064
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
2065
|
+
function createPropStore(defs) {
|
|
2066
|
+
const slots = /* @__PURE__ */ new Map();
|
|
2067
|
+
const props = {};
|
|
2068
|
+
for (const def of defs) {
|
|
2069
|
+
const slot = state();
|
|
2070
|
+
slots.set(def.key, slot);
|
|
2071
|
+
Object.defineProperty(props, def.key, {
|
|
2072
|
+
configurable: false,
|
|
2073
|
+
enumerable: true,
|
|
2074
|
+
get() {
|
|
2075
|
+
return slot.value;
|
|
2076
|
+
},
|
|
2077
|
+
set(value) {
|
|
2078
|
+
slot.value = value;
|
|
2079
|
+
}
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
return {
|
|
2083
|
+
props,
|
|
2084
|
+
get(key) {
|
|
2085
|
+
var _slots$get;
|
|
2086
|
+
return (_slots$get = slots.get(key)) === null || _slots$get === void 0 ? void 0 : _slots$get.value;
|
|
2087
|
+
},
|
|
2088
|
+
set(key, value) {
|
|
2089
|
+
const slot = slots.get(key);
|
|
2090
|
+
if (!slot) {
|
|
2091
|
+
console.warn(`[Zeus custom-element] Unknown prop "${key}" was written.`);
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
slot.value = value;
|
|
2095
|
+
},
|
|
2096
|
+
has(key) {
|
|
2097
|
+
return slots.has(key);
|
|
2098
|
+
}
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
1924
2101
|
function defineElement(tagName, options, setup) {
|
|
1925
2102
|
var _options$props;
|
|
1926
2103
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
@@ -1931,12 +2108,13 @@ var Zeus = (function(exports) {
|
|
|
1931
2108
|
}
|
|
1932
2109
|
constructor() {
|
|
1933
2110
|
super();
|
|
1934
|
-
this.props = state({});
|
|
1935
2111
|
this.lightChildren = [];
|
|
1936
2112
|
this.capturedLightChildren = false;
|
|
1937
2113
|
this.reflecting = false;
|
|
1938
|
-
|
|
1939
|
-
|
|
2114
|
+
this.propStore = createPropStore(propDefs);
|
|
2115
|
+
this.props = this.propStore.props;
|
|
2116
|
+
applyPropDefaults(this.propStore, propDefs);
|
|
2117
|
+
definePropAccessors(this, this.propStore, propDefs);
|
|
1940
2118
|
}
|
|
1941
2119
|
connectedCallback() {
|
|
1942
2120
|
var _options$shadow, _options$consumes;
|
|
@@ -1972,22 +2150,17 @@ var Zeus = (function(exports) {
|
|
|
1972
2150
|
};
|
|
1973
2151
|
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
1974
2152
|
mountStyles(target, options.styles);
|
|
1975
|
-
onScopeDispose(() => {
|
|
1976
|
-
var _this$dispose;
|
|
1977
|
-
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
1978
|
-
this.dispose = void 0;
|
|
1979
|
-
}, true);
|
|
1980
2153
|
}
|
|
1981
2154
|
disconnectedCallback() {
|
|
1982
|
-
var _this$
|
|
1983
|
-
(_this$
|
|
2155
|
+
var _this$dispose;
|
|
2156
|
+
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
1984
2157
|
this.dispose = void 0;
|
|
1985
2158
|
}
|
|
1986
2159
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
1987
2160
|
if (oldValue === newValue || this.reflecting) return;
|
|
1988
2161
|
const def = propDefs.find((item) => item.attr === name);
|
|
1989
2162
|
if (!def) return;
|
|
1990
|
-
this.
|
|
2163
|
+
this.propStore.set(def.key, castAttributeValue(newValue, def));
|
|
1991
2164
|
}
|
|
1992
2165
|
resolveRenderTarget(shadow) {
|
|
1993
2166
|
if (this.target) return this.target;
|
|
@@ -2002,12 +2175,12 @@ var Zeus = (function(exports) {
|
|
|
2002
2175
|
for (const def of defs) {
|
|
2003
2176
|
if (def.attr === false) continue;
|
|
2004
2177
|
const value = this.getAttribute(def.attr);
|
|
2005
|
-
if (value !== null || def.type === Boolean) this.
|
|
2178
|
+
if (value !== null || def.type === Boolean) this.propStore.set(def.key, castAttributeValue(value, def));
|
|
2006
2179
|
}
|
|
2007
2180
|
}
|
|
2008
2181
|
_writePropFromProperty(key, value) {
|
|
2009
2182
|
const def = propDefs.find((item) => item.key === key);
|
|
2010
|
-
this.
|
|
2183
|
+
this.propStore.set(key, value);
|
|
2011
2184
|
if ((def === null || def === void 0 ? void 0 : def.reflect) && def.attr !== false) {
|
|
2012
2185
|
this.reflecting = true;
|
|
2013
2186
|
try {
|
|
@@ -2039,26 +2212,35 @@ var Zeus = (function(exports) {
|
|
|
2039
2212
|
};
|
|
2040
2213
|
});
|
|
2041
2214
|
}
|
|
2042
|
-
function applyPropDefaults(
|
|
2215
|
+
function applyPropDefaults(store, defs) {
|
|
2043
2216
|
for (const def of defs) {
|
|
2044
2217
|
if (!("default" in def)) continue;
|
|
2045
2218
|
const value = typeof def.default === "function" ? def.default() : def.default;
|
|
2046
|
-
|
|
2219
|
+
store.set(def.key, value);
|
|
2047
2220
|
}
|
|
2048
2221
|
}
|
|
2049
|
-
function definePropAccessors(element,
|
|
2222
|
+
function definePropAccessors(element, store, defs) {
|
|
2050
2223
|
for (const def of defs) {
|
|
2051
|
-
|
|
2052
|
-
Object.
|
|
2224
|
+
const key = def.key;
|
|
2225
|
+
const hadOwnValue = Object.prototype.hasOwnProperty.call(element, key);
|
|
2226
|
+
const ownValue = hadOwnValue ? element[key] : void 0;
|
|
2227
|
+
if (hadOwnValue) delete element[key];
|
|
2228
|
+
const existing = Object.getOwnPropertyDescriptor(element, key);
|
|
2229
|
+
if (existing && existing.configurable === false) {
|
|
2230
|
+
console.warn(`[Zeus custom-element] Cannot define prop "${key}" because an own non-configurable property already exists.`);
|
|
2231
|
+
continue;
|
|
2232
|
+
}
|
|
2233
|
+
Object.defineProperty(element, key, {
|
|
2053
2234
|
configurable: true,
|
|
2054
2235
|
enumerable: true,
|
|
2055
2236
|
get() {
|
|
2056
|
-
return
|
|
2237
|
+
return store.get(key);
|
|
2057
2238
|
},
|
|
2058
2239
|
set(value) {
|
|
2059
|
-
element._writePropFromProperty(
|
|
2240
|
+
element._writePropFromProperty(key, value);
|
|
2060
2241
|
}
|
|
2061
2242
|
});
|
|
2243
|
+
if (hadOwnValue) element._writePropFromProperty(key, ownValue);
|
|
2062
2244
|
}
|
|
2063
2245
|
}
|
|
2064
2246
|
function castAttributeValue(value, def) {
|
|
@@ -2103,7 +2285,7 @@ var Zeus = (function(exports) {
|
|
|
2103
2285
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
2104
2286
|
}
|
|
2105
2287
|
//#endregion
|
|
2106
|
-
//#region packages/runtime-dom/src/slot.ts
|
|
2288
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
2107
2289
|
function createSlot(name, fallback) {
|
|
2108
2290
|
const context = getCurrentHostContext();
|
|
2109
2291
|
if (!context) return createNativeSlot(name, fallback);
|
|
@@ -2135,18 +2317,98 @@ var Zeus = (function(exports) {
|
|
|
2135
2317
|
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
2136
2318
|
}
|
|
2137
2319
|
//#endregion
|
|
2138
|
-
//#region packages/runtime-dom/src/webComponents.ts
|
|
2320
|
+
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
2321
|
+
const HOST_RESERVED_KEYS = new Set([
|
|
2322
|
+
"children",
|
|
2323
|
+
"ref",
|
|
2324
|
+
"class",
|
|
2325
|
+
"className",
|
|
2326
|
+
"style",
|
|
2327
|
+
"_elements"
|
|
2328
|
+
]);
|
|
2139
2329
|
function Host(props) {
|
|
2330
|
+
const context = getCurrentHostContext();
|
|
2331
|
+
if (context) bindHostProps(context.host, props);
|
|
2140
2332
|
return resolveValue(props.children);
|
|
2141
2333
|
}
|
|
2142
2334
|
function Slot(props) {
|
|
2143
2335
|
return createSlot(props.name, () => resolveValue(props.children));
|
|
2144
2336
|
}
|
|
2337
|
+
function bindHostProps(host, props) {
|
|
2338
|
+
bindHostRef(host, props);
|
|
2339
|
+
bindHostClass(host, props);
|
|
2340
|
+
bindHostStyle(host, props);
|
|
2341
|
+
bindHostAttributes(host, props);
|
|
2342
|
+
if ("_elements" in props) bindHostElementBindings(host, props);
|
|
2343
|
+
}
|
|
2344
|
+
function bindHostRef(host, props) {
|
|
2345
|
+
if (!("ref" in props)) return;
|
|
2346
|
+
bindRef(host, props.ref);
|
|
2347
|
+
}
|
|
2348
|
+
function bindHostClass(host, props) {
|
|
2349
|
+
if (!("class" in props) && !("className" in props)) return;
|
|
2350
|
+
const value = props.className !== void 0 ? props.className : props.class;
|
|
2351
|
+
bindClass(host, () => {
|
|
2352
|
+
return resolveHostValue(value);
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
function bindHostStyle(host, props) {
|
|
2356
|
+
if (!("style" in props)) return;
|
|
2357
|
+
bindStyle(host, () => {
|
|
2358
|
+
return resolveHostValue(props.style);
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
function bindHostAttributes(host, props) {
|
|
2362
|
+
for (const key of Object.keys(props)) {
|
|
2363
|
+
if (HOST_RESERVED_KEYS.has(key)) continue;
|
|
2364
|
+
if (isEventLikeProp(key)) continue;
|
|
2365
|
+
const value = props[key];
|
|
2366
|
+
bindAttr(host, normalizeHostAttrName(key), () => {
|
|
2367
|
+
return resolveHostValue(value);
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
function bindHostElementBindings(host, props) {
|
|
2372
|
+
const elements = props._elements;
|
|
2373
|
+
for (const _key of Object.keys(elements)) {
|
|
2374
|
+
const getEl = elements[_key];
|
|
2375
|
+
const el = getEl();
|
|
2376
|
+
if (!el) continue;
|
|
2377
|
+
for (const attrKey of Object.keys(props)) {
|
|
2378
|
+
if (HOST_RESERVED_KEYS.has(attrKey)) continue;
|
|
2379
|
+
if (isEventLikeProp(attrKey)) continue;
|
|
2380
|
+
const value = props[attrKey];
|
|
2381
|
+
bindAttr(el, normalizeHostAttrName(attrKey), () => {
|
|
2382
|
+
return resolveHostValue(value);
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
function resolveHostValue(value) {
|
|
2388
|
+
if (typeof value === "function") return value();
|
|
2389
|
+
return value;
|
|
2390
|
+
}
|
|
2145
2391
|
function resolveValue(value) {
|
|
2146
2392
|
return typeof value === "function" ? value() : value;
|
|
2147
2393
|
}
|
|
2394
|
+
function isEventLikeProp(key) {
|
|
2395
|
+
/**
|
|
2396
|
+
* Host Phase 1 does not bind event listeners.
|
|
2397
|
+
* Keep event handling inside component template + emit().
|
|
2398
|
+
*/
|
|
2399
|
+
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
2400
|
+
}
|
|
2401
|
+
function normalizeHostAttrName(name) {
|
|
2402
|
+
switch (name) {
|
|
2403
|
+
case "className": return "class";
|
|
2404
|
+
case "htmlFor": return "for";
|
|
2405
|
+
case "tabIndex": return "tabindex";
|
|
2406
|
+
case "readOnly": return "readonly";
|
|
2407
|
+
default: return name;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2148
2410
|
//#endregion
|
|
2149
|
-
//#region packages/zeus/src/jsx-runtime.ts
|
|
2411
|
+
//#region packages/core/zeus/src/jsx-runtime.ts
|
|
2150
2412
|
const Fragment = Symbol.for("zeus.fragment");
|
|
2151
2413
|
function jsx(type, props) {
|
|
2152
2414
|
return createJSXNode(type, props);
|
|
@@ -2158,6 +2420,7 @@ var Zeus = (function(exports) {
|
|
|
2158
2420
|
return createJSXNode(type, props);
|
|
2159
2421
|
}
|
|
2160
2422
|
function createJSXNode(type, props) {
|
|
2423
|
+
if (type === Fragment) return props === null || props === void 0 ? void 0 : props.children;
|
|
2161
2424
|
if (typeof type === "function") return createComponent(type, props !== null && props !== void 0 ? props : {});
|
|
2162
2425
|
if (typeof type !== "string") return null;
|
|
2163
2426
|
const el = document.createElement(type);
|
|
@@ -2168,6 +2431,11 @@ var Zeus = (function(exports) {
|
|
|
2168
2431
|
const value = props[key];
|
|
2169
2432
|
if (key.startsWith("on") && typeof value === "function") el.addEventListener(key.slice(2).toLowerCase(), value);
|
|
2170
2433
|
else if (key === "ref") setFallbackRef(value, el);
|
|
2434
|
+
else if (key.startsWith("prop:")) {
|
|
2435
|
+
const propName = key.slice(5);
|
|
2436
|
+
if (typeof value === "function") bindProp(el, propName, value);
|
|
2437
|
+
else el[propName] = value;
|
|
2438
|
+
} else if (typeof value === "function") bindAttr(el, key, value);
|
|
2171
2439
|
else if (value != null && value !== false) el.setAttribute(key === "className" ? "class" : key, String(value));
|
|
2172
2440
|
}
|
|
2173
2441
|
if (children !== void 0) insert(el, children);
|