@zeus-js/runtime-dom 0.0.2 → 0.1.0-beta.0
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 +93 -28
- package/dist/runtime-dom.cjs.prod.js +93 -28
- package/dist/runtime-dom.d.ts +54 -39
- package/dist/runtime-dom.esm-browser.js +104 -40
- package/dist/runtime-dom.esm-browser.prod.js +1 -1
- package/dist/runtime-dom.esm-bundler.js +93 -29
- package/dist/runtime-dom.global.js +104 -39
- package/dist/runtime-dom.global.prod.js +1 -1
- package/package.json +4 -4
package/dist/runtime-dom.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* runtime-dom v0.0.
|
|
2
|
+
* runtime-dom v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -8,7 +8,7 @@ Object.defineProperties(exports, {
|
|
|
8
8
|
[Symbol.toStringTag]: { value: "Module" }
|
|
9
9
|
});
|
|
10
10
|
let _zeus_js_signal = require("@zeus-js/signal");
|
|
11
|
-
//#region packages/runtime-dom/src/template.ts
|
|
11
|
+
//#region packages/core/runtime-dom/src/template.ts
|
|
12
12
|
function template(html, _isImportNode = false, _isSVG = false, _isMathML = false) {
|
|
13
13
|
const t = document.createElement("template");
|
|
14
14
|
t.innerHTML = html;
|
|
@@ -17,7 +17,7 @@ function template(html, _isImportNode = false, _isSVG = false, _isMathML = false
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region packages/runtime-dom/src/hostContext.ts
|
|
20
|
+
//#region packages/core/runtime-dom/src/hostContext.ts
|
|
21
21
|
let currentHostContext;
|
|
22
22
|
function getCurrentHostContext() {
|
|
23
23
|
return currentHostContext;
|
|
@@ -41,7 +41,7 @@ function withCapturedHostContext(fn) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region packages/runtime-dom/src/range.ts
|
|
44
|
+
//#region packages/core/runtime-dom/src/range.ts
|
|
45
45
|
var DynamicRange = class {
|
|
46
46
|
constructor(parent, marker) {
|
|
47
47
|
this.parent = parent;
|
|
@@ -63,7 +63,7 @@ var DynamicRange = class {
|
|
|
63
63
|
return this.nodes;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
function insertTracked(parent, value, marker) {
|
|
66
|
+
function insertTracked(parent, value, marker = null) {
|
|
67
67
|
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
68
68
|
if (Array.isArray(value)) {
|
|
69
69
|
const nodes = [];
|
|
@@ -80,11 +80,11 @@ function removeNodes$1(nodes) {
|
|
|
80
80
|
(_node$parentNode2 = node.parentNode) === null || _node$parentNode2 === void 0 || _node$parentNode2.removeChild(node);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function moveRangeBefore(nodes, parent, marker) {
|
|
83
|
+
function moveRangeBefore(nodes, parent, marker = null) {
|
|
84
84
|
for (const node of nodes) parent.insertBefore(node, marker);
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
|
-
//#region packages/runtime-dom/src/insert.ts
|
|
87
|
+
//#region packages/core/runtime-dom/src/insert.ts
|
|
88
88
|
function insert(parent, value, marker = null) {
|
|
89
89
|
if (value === void 0) {
|
|
90
90
|
console.warn("[Zeus runtime] insert received `undefined`, which is ignored. Use `null` or a fallback value explicitly if you want to suppress this warning.");
|
|
@@ -106,7 +106,7 @@ function mountDynamic(parent, marker, value) {
|
|
|
106
106
|
}, true);
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
|
-
//#region packages/runtime-dom/src/context.ts
|
|
109
|
+
//#region packages/core/runtime-dom/src/context.ts
|
|
110
110
|
let currentOwner;
|
|
111
111
|
function getCurrentOwner() {
|
|
112
112
|
return currentOwner;
|
|
@@ -245,14 +245,14 @@ function resolveValue$3(value) {
|
|
|
245
245
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
|
-
//#region packages/runtime-dom/src/devtools.ts
|
|
248
|
+
//#region packages/core/runtime-dom/src/devtools.ts
|
|
249
249
|
function emitDevtoolsEvent(event) {
|
|
250
250
|
var _window$__ZEUS_DEVTOO;
|
|
251
251
|
if (typeof window === "undefined") return;
|
|
252
252
|
(_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
|
|
253
253
|
}
|
|
254
254
|
//#endregion
|
|
255
|
-
//#region packages/runtime-dom/src/render.ts
|
|
255
|
+
//#region packages/core/runtime-dom/src/render.ts
|
|
256
256
|
function render(value, container, options = {}) {
|
|
257
257
|
var _options$owner;
|
|
258
258
|
const renderScope = (0, _zeus_js_signal.scope)();
|
|
@@ -279,7 +279,7 @@ function resolveValue$2(value) {
|
|
|
279
279
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
|
-
//#region packages/runtime-dom/src/dom.ts
|
|
282
|
+
//#region packages/core/runtime-dom/src/dom.ts
|
|
283
283
|
function marker(parent, index) {
|
|
284
284
|
let seen = 0;
|
|
285
285
|
for (const node of parent.childNodes) {
|
|
@@ -303,7 +303,7 @@ function removeNodes(nodes) {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
//#endregion
|
|
306
|
-
//#region packages/runtime-dom/src/bindings.ts
|
|
306
|
+
//#region packages/core/runtime-dom/src/bindings.ts
|
|
307
307
|
function bindText(node, value) {
|
|
308
308
|
(0, _zeus_js_signal.effect)(() => {
|
|
309
309
|
node.data = stringifyText(value());
|
|
@@ -413,7 +413,7 @@ function toKebabCase$1(value) {
|
|
|
413
413
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
414
414
|
}
|
|
415
415
|
//#endregion
|
|
416
|
-
//#region packages/runtime-dom/src/events.ts
|
|
416
|
+
//#region packages/core/runtime-dom/src/events.ts
|
|
417
417
|
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
418
418
|
const delegatedListeners = [];
|
|
419
419
|
const nonBubblingEventMap = {
|
|
@@ -488,7 +488,7 @@ function callDelegatedHandler(el, handler, event) {
|
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
//#endregion
|
|
491
|
-
//#region packages/runtime-dom/src/refs.ts
|
|
491
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
492
492
|
function setRef(target, value) {
|
|
493
493
|
if (target == null) return;
|
|
494
494
|
if (typeof target === "function") {
|
|
@@ -512,12 +512,12 @@ function bindRef(el, target) {
|
|
|
512
512
|
}, true);
|
|
513
513
|
}
|
|
514
514
|
//#endregion
|
|
515
|
-
//#region packages/runtime-dom/src/component.ts
|
|
515
|
+
//#region packages/core/runtime-dom/src/component.ts
|
|
516
516
|
function createComponent(component, props) {
|
|
517
517
|
return runWithOwner(createOwner(), () => component(props));
|
|
518
518
|
}
|
|
519
519
|
//#endregion
|
|
520
|
-
//#region packages/runtime-dom/src/list.ts
|
|
520
|
+
//#region packages/core/runtime-dom/src/list.ts
|
|
521
521
|
function mountFor$1(parent, marker, each, key, render) {
|
|
522
522
|
if (!key) {
|
|
523
523
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -575,7 +575,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
575
575
|
}
|
|
576
576
|
emitDevtoolsEvent({
|
|
577
577
|
type: "mount-for",
|
|
578
|
-
length:
|
|
578
|
+
length: nextRecords.length
|
|
579
579
|
});
|
|
580
580
|
records = nextRecords;
|
|
581
581
|
});
|
|
@@ -586,7 +586,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
586
586
|
}, true);
|
|
587
587
|
}
|
|
588
588
|
//#endregion
|
|
589
|
-
//#region packages/runtime-dom/src/controlFlow.ts
|
|
589
|
+
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
590
590
|
function Show(props) {
|
|
591
591
|
return resolveValue(props.when ? props.children : props.fallback);
|
|
592
592
|
}
|
|
@@ -605,7 +605,7 @@ function mountFor(parent, marker, each, key, render) {
|
|
|
605
605
|
mountFor$1(parent, marker, each, key, render);
|
|
606
606
|
}
|
|
607
607
|
//#endregion
|
|
608
|
-
//#region packages/runtime-dom/src/defineElement.ts
|
|
608
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
609
609
|
function defineElement(tagName, options, setup) {
|
|
610
610
|
var _options$props;
|
|
611
611
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
@@ -659,15 +659,10 @@ function defineElement(tagName, options, setup) {
|
|
|
659
659
|
};
|
|
660
660
|
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
661
661
|
mountStyles(target, options.styles);
|
|
662
|
-
(0, _zeus_js_signal.onScopeDispose)(() => {
|
|
663
|
-
var _this$dispose;
|
|
664
|
-
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
665
|
-
this.dispose = void 0;
|
|
666
|
-
}, true);
|
|
667
662
|
}
|
|
668
663
|
disconnectedCallback() {
|
|
669
|
-
var _this$
|
|
670
|
-
(_this$
|
|
664
|
+
var _this$dispose;
|
|
665
|
+
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
671
666
|
this.dispose = void 0;
|
|
672
667
|
}
|
|
673
668
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -790,7 +785,7 @@ function toKebabCase(value) {
|
|
|
790
785
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
791
786
|
}
|
|
792
787
|
//#endregion
|
|
793
|
-
//#region packages/runtime-dom/src/slot.ts
|
|
788
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
794
789
|
function createSlot(name, fallback) {
|
|
795
790
|
const context = getCurrentHostContext();
|
|
796
791
|
if (!context) return createNativeSlot(name, fallback);
|
|
@@ -822,16 +817,85 @@ function isMeaningfulTextNode(node) {
|
|
|
822
817
|
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
823
818
|
}
|
|
824
819
|
//#endregion
|
|
825
|
-
//#region packages/runtime-dom/src/webComponents.ts
|
|
820
|
+
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
821
|
+
const HOST_RESERVED_KEYS = new Set([
|
|
822
|
+
"children",
|
|
823
|
+
"ref",
|
|
824
|
+
"class",
|
|
825
|
+
"className",
|
|
826
|
+
"style"
|
|
827
|
+
]);
|
|
826
828
|
function Host(props) {
|
|
829
|
+
const context = getCurrentHostContext();
|
|
830
|
+
if (context) bindHostProps(context.host, props);
|
|
827
831
|
return resolveValue$1(props.children);
|
|
828
832
|
}
|
|
829
833
|
function Slot(props) {
|
|
830
834
|
return createSlot(props.name, () => resolveValue$1(props.children));
|
|
831
835
|
}
|
|
836
|
+
function bindHostProps(host, props) {
|
|
837
|
+
bindHostRef(host, props);
|
|
838
|
+
bindHostClass(host, props);
|
|
839
|
+
bindHostStyle(host, props);
|
|
840
|
+
bindHostAttributes(host, props);
|
|
841
|
+
}
|
|
842
|
+
function bindHostRef(host, props) {
|
|
843
|
+
if (!("ref" in props)) return;
|
|
844
|
+
bindRef(host, props.ref);
|
|
845
|
+
}
|
|
846
|
+
function bindHostClass(host, props) {
|
|
847
|
+
if (!("class" in props) && !("className" in props)) return;
|
|
848
|
+
/**
|
|
849
|
+
* className has higher priority than class when both exist.
|
|
850
|
+
*/
|
|
851
|
+
const value = props.className !== void 0 ? props.className : props.class;
|
|
852
|
+
bindClass(host, () => {
|
|
853
|
+
return resolveHostValue(value);
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
function bindHostStyle(host, props) {
|
|
857
|
+
if (!("style" in props)) return;
|
|
858
|
+
bindStyle(host, () => {
|
|
859
|
+
return resolveHostValue(props.style);
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
function bindHostAttributes(host, props) {
|
|
863
|
+
for (const key of Object.keys(props)) {
|
|
864
|
+
if (HOST_RESERVED_KEYS.has(key)) continue;
|
|
865
|
+
if (isEventLikeProp(key)) continue;
|
|
866
|
+
const value = props[key];
|
|
867
|
+
bindAttr(host, normalizeHostAttrName(key), () => {
|
|
868
|
+
return resolveHostValue(value);
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function resolveHostValue(value) {
|
|
873
|
+
/**
|
|
874
|
+
* JSX component props may be direct values or lazy getters.
|
|
875
|
+
* Function values are treated as getters except event-like props,
|
|
876
|
+
* which are filtered before this function is called.
|
|
877
|
+
*/
|
|
878
|
+
return typeof value === "function" ? value() : value;
|
|
879
|
+
}
|
|
832
880
|
function resolveValue$1(value) {
|
|
833
881
|
return typeof value === "function" ? value() : value;
|
|
834
882
|
}
|
|
883
|
+
function isEventLikeProp(key) {
|
|
884
|
+
/**
|
|
885
|
+
* Host Phase 1 does not bind event listeners.
|
|
886
|
+
* Keep event handling inside component template + emit().
|
|
887
|
+
*/
|
|
888
|
+
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
889
|
+
}
|
|
890
|
+
function normalizeHostAttrName(name) {
|
|
891
|
+
switch (name) {
|
|
892
|
+
case "className": return "class";
|
|
893
|
+
case "htmlFor": return "for";
|
|
894
|
+
case "tabIndex": return "tabindex";
|
|
895
|
+
case "readOnly": return "readonly";
|
|
896
|
+
default: return name;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
835
899
|
//#endregion
|
|
836
900
|
exports.For = For;
|
|
837
901
|
exports.Host = Host;
|
|
@@ -859,6 +923,7 @@ exports.getCurrentHostContext = getCurrentHostContext;
|
|
|
859
923
|
exports.getCurrentOwner = getCurrentOwner;
|
|
860
924
|
exports.inject = inject;
|
|
861
925
|
exports.insert = insert;
|
|
926
|
+
exports.insertTracked = insertTracked;
|
|
862
927
|
exports.marker = marker;
|
|
863
928
|
exports.mountDynamic = mountDynamic;
|
|
864
929
|
exports.mountFor = mountFor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* runtime-dom v0.0.
|
|
2
|
+
* runtime-dom v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -8,7 +8,7 @@ Object.defineProperties(exports, {
|
|
|
8
8
|
[Symbol.toStringTag]: { value: "Module" }
|
|
9
9
|
});
|
|
10
10
|
let _zeus_js_signal = require("@zeus-js/signal");
|
|
11
|
-
//#region packages/runtime-dom/src/template.ts
|
|
11
|
+
//#region packages/core/runtime-dom/src/template.ts
|
|
12
12
|
function template(html, _isImportNode = false, _isSVG = false, _isMathML = false) {
|
|
13
13
|
const t = document.createElement("template");
|
|
14
14
|
t.innerHTML = html;
|
|
@@ -17,7 +17,7 @@ function template(html, _isImportNode = false, _isSVG = false, _isMathML = false
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region packages/runtime-dom/src/hostContext.ts
|
|
20
|
+
//#region packages/core/runtime-dom/src/hostContext.ts
|
|
21
21
|
let currentHostContext;
|
|
22
22
|
function getCurrentHostContext() {
|
|
23
23
|
return currentHostContext;
|
|
@@ -41,7 +41,7 @@ function withCapturedHostContext(fn) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region packages/runtime-dom/src/range.ts
|
|
44
|
+
//#region packages/core/runtime-dom/src/range.ts
|
|
45
45
|
var DynamicRange = class {
|
|
46
46
|
constructor(parent, marker) {
|
|
47
47
|
this.parent = parent;
|
|
@@ -63,7 +63,7 @@ var DynamicRange = class {
|
|
|
63
63
|
return this.nodes;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
function insertTracked(parent, value, marker) {
|
|
66
|
+
function insertTracked(parent, value, marker = null) {
|
|
67
67
|
if (value === void 0 || value == null || value === false || value === true) return [];
|
|
68
68
|
if (Array.isArray(value)) {
|
|
69
69
|
const nodes = [];
|
|
@@ -80,11 +80,11 @@ function removeNodes$1(nodes) {
|
|
|
80
80
|
(_node$parentNode2 = node.parentNode) === null || _node$parentNode2 === void 0 || _node$parentNode2.removeChild(node);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function moveRangeBefore(nodes, parent, marker) {
|
|
83
|
+
function moveRangeBefore(nodes, parent, marker = null) {
|
|
84
84
|
for (const node of nodes) parent.insertBefore(node, marker);
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
|
-
//#region packages/runtime-dom/src/insert.ts
|
|
87
|
+
//#region packages/core/runtime-dom/src/insert.ts
|
|
88
88
|
function insert(parent, value, marker = null) {
|
|
89
89
|
if (value === void 0) return;
|
|
90
90
|
insertTracked(parent, value, marker);
|
|
@@ -103,7 +103,7 @@ function mountDynamic(parent, marker, value) {
|
|
|
103
103
|
}, true);
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
|
-
//#region packages/runtime-dom/src/context.ts
|
|
106
|
+
//#region packages/core/runtime-dom/src/context.ts
|
|
107
107
|
let currentOwner;
|
|
108
108
|
function getCurrentOwner() {
|
|
109
109
|
return currentOwner;
|
|
@@ -239,14 +239,14 @@ function resolveValue$3(value) {
|
|
|
239
239
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
240
240
|
}
|
|
241
241
|
//#endregion
|
|
242
|
-
//#region packages/runtime-dom/src/devtools.ts
|
|
242
|
+
//#region packages/core/runtime-dom/src/devtools.ts
|
|
243
243
|
function emitDevtoolsEvent(event) {
|
|
244
244
|
var _window$__ZEUS_DEVTOO;
|
|
245
245
|
if (typeof window === "undefined") return;
|
|
246
246
|
(_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
|
|
247
247
|
}
|
|
248
248
|
//#endregion
|
|
249
|
-
//#region packages/runtime-dom/src/render.ts
|
|
249
|
+
//#region packages/core/runtime-dom/src/render.ts
|
|
250
250
|
function render(value, container, options = {}) {
|
|
251
251
|
var _options$owner;
|
|
252
252
|
const renderScope = (0, _zeus_js_signal.scope)();
|
|
@@ -273,7 +273,7 @@ function resolveValue$2(value) {
|
|
|
273
273
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
274
274
|
}
|
|
275
275
|
//#endregion
|
|
276
|
-
//#region packages/runtime-dom/src/dom.ts
|
|
276
|
+
//#region packages/core/runtime-dom/src/dom.ts
|
|
277
277
|
function marker(parent, index) {
|
|
278
278
|
let seen = 0;
|
|
279
279
|
for (const node of parent.childNodes) {
|
|
@@ -297,7 +297,7 @@ function removeNodes(nodes) {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
//#endregion
|
|
300
|
-
//#region packages/runtime-dom/src/bindings.ts
|
|
300
|
+
//#region packages/core/runtime-dom/src/bindings.ts
|
|
301
301
|
function bindText(node, value) {
|
|
302
302
|
(0, _zeus_js_signal.effect)(() => {
|
|
303
303
|
node.data = stringifyText(value());
|
|
@@ -407,7 +407,7 @@ function toKebabCase$1(value) {
|
|
|
407
407
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
408
408
|
}
|
|
409
409
|
//#endregion
|
|
410
|
-
//#region packages/runtime-dom/src/events.ts
|
|
410
|
+
//#region packages/core/runtime-dom/src/events.ts
|
|
411
411
|
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
412
412
|
const delegatedListeners = [];
|
|
413
413
|
const nonBubblingEventMap = {
|
|
@@ -482,7 +482,7 @@ function callDelegatedHandler(el, handler, event) {
|
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
//#endregion
|
|
485
|
-
//#region packages/runtime-dom/src/refs.ts
|
|
485
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
486
486
|
function setRef(target, value) {
|
|
487
487
|
if (target == null) return;
|
|
488
488
|
if (typeof target === "function") {
|
|
@@ -505,12 +505,12 @@ function bindRef(el, target) {
|
|
|
505
505
|
}, true);
|
|
506
506
|
}
|
|
507
507
|
//#endregion
|
|
508
|
-
//#region packages/runtime-dom/src/component.ts
|
|
508
|
+
//#region packages/core/runtime-dom/src/component.ts
|
|
509
509
|
function createComponent(component, props) {
|
|
510
510
|
return runWithOwner(createOwner(), () => component(props));
|
|
511
511
|
}
|
|
512
512
|
//#endregion
|
|
513
|
-
//#region packages/runtime-dom/src/list.ts
|
|
513
|
+
//#region packages/core/runtime-dom/src/list.ts
|
|
514
514
|
function mountFor$1(parent, marker, each, key, render) {
|
|
515
515
|
if (!key) {
|
|
516
516
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -568,7 +568,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
568
568
|
}
|
|
569
569
|
emitDevtoolsEvent({
|
|
570
570
|
type: "mount-for",
|
|
571
|
-
length:
|
|
571
|
+
length: nextRecords.length
|
|
572
572
|
});
|
|
573
573
|
records = nextRecords;
|
|
574
574
|
});
|
|
@@ -579,7 +579,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
579
579
|
}, true);
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
|
-
//#region packages/runtime-dom/src/controlFlow.ts
|
|
582
|
+
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
583
583
|
function Show(props) {
|
|
584
584
|
return resolveValue(props.when ? props.children : props.fallback);
|
|
585
585
|
}
|
|
@@ -598,7 +598,7 @@ function mountFor(parent, marker, each, key, render) {
|
|
|
598
598
|
mountFor$1(parent, marker, each, key, render);
|
|
599
599
|
}
|
|
600
600
|
//#endregion
|
|
601
|
-
//#region packages/runtime-dom/src/defineElement.ts
|
|
601
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
602
602
|
function defineElement(tagName, options, setup) {
|
|
603
603
|
var _options$props;
|
|
604
604
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
@@ -652,15 +652,10 @@ function defineElement(tagName, options, setup) {
|
|
|
652
652
|
};
|
|
653
653
|
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
654
654
|
mountStyles(target, options.styles);
|
|
655
|
-
(0, _zeus_js_signal.onScopeDispose)(() => {
|
|
656
|
-
var _this$dispose;
|
|
657
|
-
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
658
|
-
this.dispose = void 0;
|
|
659
|
-
}, true);
|
|
660
655
|
}
|
|
661
656
|
disconnectedCallback() {
|
|
662
|
-
var _this$
|
|
663
|
-
(_this$
|
|
657
|
+
var _this$dispose;
|
|
658
|
+
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
664
659
|
this.dispose = void 0;
|
|
665
660
|
}
|
|
666
661
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -782,7 +777,7 @@ function toKebabCase(value) {
|
|
|
782
777
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
783
778
|
}
|
|
784
779
|
//#endregion
|
|
785
|
-
//#region packages/runtime-dom/src/slot.ts
|
|
780
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
786
781
|
function createSlot(name, fallback) {
|
|
787
782
|
const context = getCurrentHostContext();
|
|
788
783
|
if (!context) return createNativeSlot(name, fallback);
|
|
@@ -814,16 +809,85 @@ function isMeaningfulTextNode(node) {
|
|
|
814
809
|
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
815
810
|
}
|
|
816
811
|
//#endregion
|
|
817
|
-
//#region packages/runtime-dom/src/webComponents.ts
|
|
812
|
+
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
813
|
+
const HOST_RESERVED_KEYS = new Set([
|
|
814
|
+
"children",
|
|
815
|
+
"ref",
|
|
816
|
+
"class",
|
|
817
|
+
"className",
|
|
818
|
+
"style"
|
|
819
|
+
]);
|
|
818
820
|
function Host(props) {
|
|
821
|
+
const context = getCurrentHostContext();
|
|
822
|
+
if (context) bindHostProps(context.host, props);
|
|
819
823
|
return resolveValue$1(props.children);
|
|
820
824
|
}
|
|
821
825
|
function Slot(props) {
|
|
822
826
|
return createSlot(props.name, () => resolveValue$1(props.children));
|
|
823
827
|
}
|
|
828
|
+
function bindHostProps(host, props) {
|
|
829
|
+
bindHostRef(host, props);
|
|
830
|
+
bindHostClass(host, props);
|
|
831
|
+
bindHostStyle(host, props);
|
|
832
|
+
bindHostAttributes(host, props);
|
|
833
|
+
}
|
|
834
|
+
function bindHostRef(host, props) {
|
|
835
|
+
if (!("ref" in props)) return;
|
|
836
|
+
bindRef(host, props.ref);
|
|
837
|
+
}
|
|
838
|
+
function bindHostClass(host, props) {
|
|
839
|
+
if (!("class" in props) && !("className" in props)) return;
|
|
840
|
+
/**
|
|
841
|
+
* className has higher priority than class when both exist.
|
|
842
|
+
*/
|
|
843
|
+
const value = props.className !== void 0 ? props.className : props.class;
|
|
844
|
+
bindClass(host, () => {
|
|
845
|
+
return resolveHostValue(value);
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function bindHostStyle(host, props) {
|
|
849
|
+
if (!("style" in props)) return;
|
|
850
|
+
bindStyle(host, () => {
|
|
851
|
+
return resolveHostValue(props.style);
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
function bindHostAttributes(host, props) {
|
|
855
|
+
for (const key of Object.keys(props)) {
|
|
856
|
+
if (HOST_RESERVED_KEYS.has(key)) continue;
|
|
857
|
+
if (isEventLikeProp(key)) continue;
|
|
858
|
+
const value = props[key];
|
|
859
|
+
bindAttr(host, normalizeHostAttrName(key), () => {
|
|
860
|
+
return resolveHostValue(value);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function resolveHostValue(value) {
|
|
865
|
+
/**
|
|
866
|
+
* JSX component props may be direct values or lazy getters.
|
|
867
|
+
* Function values are treated as getters except event-like props,
|
|
868
|
+
* which are filtered before this function is called.
|
|
869
|
+
*/
|
|
870
|
+
return typeof value === "function" ? value() : value;
|
|
871
|
+
}
|
|
824
872
|
function resolveValue$1(value) {
|
|
825
873
|
return typeof value === "function" ? value() : value;
|
|
826
874
|
}
|
|
875
|
+
function isEventLikeProp(key) {
|
|
876
|
+
/**
|
|
877
|
+
* Host Phase 1 does not bind event listeners.
|
|
878
|
+
* Keep event handling inside component template + emit().
|
|
879
|
+
*/
|
|
880
|
+
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
881
|
+
}
|
|
882
|
+
function normalizeHostAttrName(name) {
|
|
883
|
+
switch (name) {
|
|
884
|
+
case "className": return "class";
|
|
885
|
+
case "htmlFor": return "for";
|
|
886
|
+
case "tabIndex": return "tabindex";
|
|
887
|
+
case "readOnly": return "readonly";
|
|
888
|
+
default: return name;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
827
891
|
//#endregion
|
|
828
892
|
exports.For = For;
|
|
829
893
|
exports.Host = Host;
|
|
@@ -851,6 +915,7 @@ exports.getCurrentHostContext = getCurrentHostContext;
|
|
|
851
915
|
exports.getCurrentOwner = getCurrentOwner;
|
|
852
916
|
exports.inject = inject;
|
|
853
917
|
exports.insert = insert;
|
|
918
|
+
exports.insertTracked = insertTracked;
|
|
854
919
|
exports.marker = marker;
|
|
855
920
|
exports.mountDynamic = mountDynamic;
|
|
856
921
|
exports.mountFor = mountFor;
|