@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.d.ts
CHANGED
|
@@ -12,10 +12,8 @@ export type RefTarget<T> = ((value: T | null) => void) | {
|
|
|
12
12
|
current: T | null;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
import type { TemplateFactory } from './types';
|
|
16
15
|
export declare function template<T extends Node = Node>(html: string, _isImportNode?: boolean, _isSVG?: boolean, _isMathML?: boolean): TemplateFactory<T>;
|
|
17
16
|
|
|
18
|
-
import type { JSXValue } from './types';
|
|
19
17
|
export type ContextId = symbol;
|
|
20
18
|
export interface Context<T = unknown> {
|
|
21
19
|
readonly id: ContextId;
|
|
@@ -100,38 +98,20 @@ export declare function resolveDOMContext<T>(host: HTMLElement, context: Context
|
|
|
100
98
|
*/
|
|
101
99
|
export declare function requestDOMContext<T>(host: HTMLElement, context: Context<T>): T | undefined;
|
|
102
100
|
|
|
103
|
-
import { createOwner } from './context';
|
|
104
|
-
import type { JSXValue } from './types';
|
|
105
101
|
export interface RenderOptions {
|
|
106
102
|
owner?: ReturnType<typeof createOwner>;
|
|
107
103
|
}
|
|
108
104
|
export declare function render(value: JSXValue | (() => JSXValue), container: Element | DocumentFragment, options?: RenderOptions): () => void;
|
|
109
105
|
|
|
110
|
-
|
|
111
|
-
declare class DynamicRange {
|
|
112
|
-
private readonly parent;
|
|
113
|
-
private readonly marker;
|
|
114
|
-
private nodes;
|
|
115
|
-
constructor(parent: Node, marker: Node | null);
|
|
116
|
-
replace(value: JSXValue): void;
|
|
117
|
-
clear(): void;
|
|
118
|
-
current(): readonly Node[];
|
|
119
|
-
}
|
|
120
|
-
declare function insertTracked(parent: Node, value: JSXValue, marker: Node | null): Node[];
|
|
121
|
-
export declare function removeNodes(nodes: readonly Node[]): void;
|
|
122
|
-
declare function moveRangeBefore(nodes: readonly Node[], parent: Node, marker: Node | null): void;
|
|
123
|
-
declare function firstNode(nodes: readonly Node[]): Node | null;
|
|
124
|
-
declare function lastNode(nodes: readonly Node[]): Node | null;
|
|
106
|
+
export declare function insertTracked(parent: Node, value: JSXValue, marker?: Node | null): Node[];
|
|
125
107
|
|
|
126
|
-
|
|
127
|
-
import type { JSXValue } from './types';export declare function insert(parent: Node, value: JSXValue, marker?: Node | null): void;
|
|
108
|
+
export declare function insert(parent: Node, value: JSXValue, marker?: Node | null): void;
|
|
128
109
|
export declare function mountDynamic(parent: Node, marker: Node, value: () => JSXValue): void;
|
|
129
110
|
|
|
130
111
|
export declare function marker(parent: ParentNode, index: number): Comment;
|
|
131
112
|
export declare function child(parent: ParentNode, index: number): ChildNode;
|
|
132
|
-
declare function removeNodes
|
|
113
|
+
export declare function removeNodes(nodes: readonly Node[]): void;
|
|
133
114
|
|
|
134
|
-
import type { AttrValue, ClassValue, JSXValue, StyleValue } from './types';
|
|
135
115
|
export declare function bindText(node: Text, value: () => JSXValue): void;
|
|
136
116
|
export declare function bindTextContent(el: Node, value: () => JSXValue): void;
|
|
137
117
|
export declare function setAttr(el: Element, name: string, value: AttrValue): void;
|
|
@@ -143,16 +123,12 @@ export declare function bindStyle(el: HTMLElement | SVGElement, value: () => Sty
|
|
|
143
123
|
|
|
144
124
|
export declare function bindEvent(el: Element, name: string, handler: EventListener): void;
|
|
145
125
|
export declare function delegateEvents(events: readonly string[]): void;
|
|
146
|
-
declare function resetDelegatedEvents(): void;
|
|
147
126
|
|
|
148
|
-
import type { RefTarget } from './types';
|
|
149
127
|
export declare function setRef<T>(target: RefTarget<T> | null | undefined, value: T | null): void;
|
|
150
128
|
export declare function bindRef<T extends Element>(el: T, target: RefTarget<T> | null | undefined): void;
|
|
151
129
|
|
|
152
|
-
import type { JSXValue } from './types';
|
|
153
130
|
export declare function createComponent<P extends Record<string, unknown>, R extends JSXValue>(component: (props: P) => R, props: P): R;
|
|
154
131
|
|
|
155
|
-
import type { JSXValue } from './types';
|
|
156
132
|
export type ShowProps = {
|
|
157
133
|
when: unknown;
|
|
158
134
|
fallback?: JSXValue | (() => JSXValue);
|
|
@@ -169,8 +145,6 @@ export type ForProps<T, K = unknown> = {
|
|
|
169
145
|
export declare function For<T, K = unknown>(props: ForProps<T, K>): JSXValue;
|
|
170
146
|
export declare function mountFor<T, K = unknown>(parent: Node, marker: Node, each: () => readonly T[] | null | undefined, key: ((item: T, index: number) => K) | undefined, render: (item: T, index: number) => JSXValue): void;
|
|
171
147
|
|
|
172
|
-
import type { Context } from './context';
|
|
173
|
-
import type { JSXValue } from './types';
|
|
174
148
|
export type ElementPropConstructor = StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor;
|
|
175
149
|
export type PropDefinition<T = unknown> = ElementPropConstructor | {
|
|
176
150
|
type?: ElementPropConstructor;
|
|
@@ -178,25 +152,70 @@ export type PropDefinition<T = unknown> = ElementPropConstructor | {
|
|
|
178
152
|
reflect?: boolean;
|
|
179
153
|
default?: T | (() => T);
|
|
180
154
|
};
|
|
181
|
-
export type PropOptions<P extends
|
|
155
|
+
export type PropOptions<P extends object> = Partial<{
|
|
182
156
|
[K in keyof P]: PropDefinition<P[K]>;
|
|
183
157
|
}>;
|
|
184
|
-
export interface
|
|
158
|
+
export interface DefineElementMeta {
|
|
159
|
+
description?: string;
|
|
160
|
+
props?: Record<string, {
|
|
161
|
+
description?: string;
|
|
162
|
+
category?: string;
|
|
163
|
+
docs?: string;
|
|
164
|
+
}>;
|
|
165
|
+
events?: Record<string, {
|
|
166
|
+
description?: string;
|
|
167
|
+
detail?: Record<string, string>;
|
|
168
|
+
}>;
|
|
169
|
+
slots?: Record<string, {
|
|
170
|
+
description?: string;
|
|
171
|
+
}>;
|
|
172
|
+
cssVars?: string[];
|
|
173
|
+
cssParts?: string[];
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
}
|
|
176
|
+
export interface DefineElementOptions<P extends object> {
|
|
185
177
|
shadow?: boolean | ShadowRootInit;
|
|
186
178
|
props?: PropOptions<P>;
|
|
187
179
|
styles?: string | string[];
|
|
188
180
|
consumes?: Context<any>[];
|
|
181
|
+
/**
|
|
182
|
+
* Metadata only.
|
|
183
|
+
* Runtime does not consume this field.
|
|
184
|
+
*/
|
|
185
|
+
meta?: DefineElementMeta;
|
|
189
186
|
}
|
|
190
187
|
export interface DefineElementContext<E extends HTMLElement = HTMLElement> {
|
|
191
188
|
host: E;
|
|
192
189
|
emit: (name: string, detail?: unknown, options?: CustomEventInit) => boolean;
|
|
193
190
|
}
|
|
194
|
-
export type DefineElementSetup<P extends
|
|
195
|
-
export declare function defineElement<P extends
|
|
191
|
+
export type DefineElementSetup<P extends object, E extends HTMLElement = HTMLElement> = (props: Readonly<P>, context: DefineElementContext<E>) => JSXValue;
|
|
192
|
+
export declare function defineElement<P extends object = object, E extends HTMLElement = HTMLElement>(tagName: string, options: DefineElementOptions<P>, setup: DefineElementSetup<P, E>): CustomElementConstructor;
|
|
196
193
|
|
|
197
|
-
|
|
198
|
-
export interface HostProps {
|
|
194
|
+
type HostValue<T> = T | (() => T);
|
|
195
|
+
export interface HostProps extends Record<string, unknown> {
|
|
199
196
|
children?: JSXValue | (() => JSXValue);
|
|
197
|
+
/**
|
|
198
|
+
* Ref to current custom element host.
|
|
199
|
+
*/
|
|
200
|
+
ref?: RefTarget<HTMLElement>;
|
|
201
|
+
/**
|
|
202
|
+
* class and className both map to host class attribute.
|
|
203
|
+
*/
|
|
204
|
+
class?: HostValue<ClassValue>;
|
|
205
|
+
className?: HostValue<ClassValue>;
|
|
206
|
+
/**
|
|
207
|
+
* Inline style for host element.
|
|
208
|
+
*/
|
|
209
|
+
style?: HostValue<StyleValue>;
|
|
210
|
+
/**
|
|
211
|
+
* Common host attributes.
|
|
212
|
+
*/
|
|
213
|
+
id?: HostValue<AttrValue>;
|
|
214
|
+
role?: HostValue<AttrValue>;
|
|
215
|
+
part?: HostValue<AttrValue>;
|
|
216
|
+
title?: HostValue<AttrValue>;
|
|
217
|
+
slot?: HostValue<AttrValue>;
|
|
218
|
+
tabIndex?: HostValue<number | null | undefined | false>;
|
|
200
219
|
}
|
|
201
220
|
export interface SlotProps {
|
|
202
221
|
name?: string;
|
|
@@ -205,7 +224,6 @@ export interface SlotProps {
|
|
|
205
224
|
export declare function Host(props: HostProps): JSXValue;
|
|
206
225
|
export declare function Slot(props: SlotProps): JSXValue;
|
|
207
226
|
|
|
208
|
-
import type { JSXValue } from './types';
|
|
209
227
|
export declare function createSlot(name?: string, fallback?: () => JSXValue): JSXValue;
|
|
210
228
|
|
|
211
229
|
export type HostRenderMode = 'light' | 'shadow';
|
|
@@ -219,7 +237,4 @@ export declare function withHostContext<T>(context: HostRenderContext | undefine
|
|
|
219
237
|
export declare function captureCurrentHostContext(): HostRenderContext | undefined;
|
|
220
238
|
export declare function withCapturedHostContext<T extends (...args: never[]) => unknown>(fn: T): T;
|
|
221
239
|
|
|
222
|
-
import './types';
|
|
223
|
-
|
|
224
|
-
|
|
225
240
|
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
**/
|
|
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());
|
|
@@ -1761,7 +1761,7 @@ function toKebabCase$1(value) {
|
|
|
1761
1761
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1762
1762
|
}
|
|
1763
1763
|
//#endregion
|
|
1764
|
-
//#region packages/runtime-dom/src/events.ts
|
|
1764
|
+
//#region packages/core/runtime-dom/src/events.ts
|
|
1765
1765
|
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
1766
1766
|
const delegatedListeners = [];
|
|
1767
1767
|
const nonBubblingEventMap = {
|
|
@@ -1836,7 +1836,7 @@ function callDelegatedHandler(el, handler, event) {
|
|
|
1836
1836
|
}
|
|
1837
1837
|
}
|
|
1838
1838
|
//#endregion
|
|
1839
|
-
//#region packages/runtime-dom/src/refs.ts
|
|
1839
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
1840
1840
|
function setRef(target, value) {
|
|
1841
1841
|
if (target == null) return;
|
|
1842
1842
|
if (typeof target === "function") {
|
|
@@ -1860,12 +1860,12 @@ function bindRef(el, target) {
|
|
|
1860
1860
|
}, true);
|
|
1861
1861
|
}
|
|
1862
1862
|
//#endregion
|
|
1863
|
-
//#region packages/runtime-dom/src/component.ts
|
|
1863
|
+
//#region packages/core/runtime-dom/src/component.ts
|
|
1864
1864
|
function createComponent(component, props) {
|
|
1865
1865
|
return runWithOwner(createOwner(), () => component(props));
|
|
1866
1866
|
}
|
|
1867
1867
|
//#endregion
|
|
1868
|
-
//#region packages/runtime-dom/src/list.ts
|
|
1868
|
+
//#region packages/core/runtime-dom/src/list.ts
|
|
1869
1869
|
function mountFor$1(parent, marker, each, key, render) {
|
|
1870
1870
|
if (!key) {
|
|
1871
1871
|
mountIndexFor(parent, marker, each, render);
|
|
@@ -1923,7 +1923,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
emitDevtoolsEvent({
|
|
1925
1925
|
type: "mount-for",
|
|
1926
|
-
length:
|
|
1926
|
+
length: nextRecords.length
|
|
1927
1927
|
});
|
|
1928
1928
|
records = nextRecords;
|
|
1929
1929
|
});
|
|
@@ -1934,7 +1934,7 @@ function mountKeyedFor(parent, marker, each, key, render) {
|
|
|
1934
1934
|
}, true);
|
|
1935
1935
|
}
|
|
1936
1936
|
//#endregion
|
|
1937
|
-
//#region packages/runtime-dom/src/controlFlow.ts
|
|
1937
|
+
//#region packages/core/runtime-dom/src/controlFlow.ts
|
|
1938
1938
|
function Show(props) {
|
|
1939
1939
|
return resolveValue(props.when ? props.children : props.fallback);
|
|
1940
1940
|
}
|
|
@@ -2014,7 +2014,7 @@ function _objectSpread2(e) {
|
|
|
2014
2014
|
return e;
|
|
2015
2015
|
}
|
|
2016
2016
|
//#endregion
|
|
2017
|
-
//#region packages/runtime-dom/src/defineElement.ts
|
|
2017
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
2018
2018
|
function defineElement(tagName, options, setup) {
|
|
2019
2019
|
var _options$props;
|
|
2020
2020
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
@@ -2066,15 +2066,10 @@ function defineElement(tagName, options, setup) {
|
|
|
2066
2066
|
};
|
|
2067
2067
|
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
2068
2068
|
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
2069
|
}
|
|
2075
2070
|
disconnectedCallback() {
|
|
2076
|
-
var _this$
|
|
2077
|
-
(_this$
|
|
2071
|
+
var _this$dispose;
|
|
2072
|
+
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
2078
2073
|
this.dispose = void 0;
|
|
2079
2074
|
}
|
|
2080
2075
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -2197,7 +2192,7 @@ function toKebabCase(value) {
|
|
|
2197
2192
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
2198
2193
|
}
|
|
2199
2194
|
//#endregion
|
|
2200
|
-
//#region packages/runtime-dom/src/slot.ts
|
|
2195
|
+
//#region packages/core/runtime-dom/src/slot.ts
|
|
2201
2196
|
function createSlot(name, fallback) {
|
|
2202
2197
|
const context = getCurrentHostContext();
|
|
2203
2198
|
if (!context) return createNativeSlot(name, fallback);
|
|
@@ -2229,15 +2224,84 @@ function isMeaningfulTextNode(node) {
|
|
|
2229
2224
|
return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
|
|
2230
2225
|
}
|
|
2231
2226
|
//#endregion
|
|
2232
|
-
//#region packages/runtime-dom/src/webComponents.ts
|
|
2227
|
+
//#region packages/core/runtime-dom/src/webComponents.ts
|
|
2228
|
+
const HOST_RESERVED_KEYS = new Set([
|
|
2229
|
+
"children",
|
|
2230
|
+
"ref",
|
|
2231
|
+
"class",
|
|
2232
|
+
"className",
|
|
2233
|
+
"style"
|
|
2234
|
+
]);
|
|
2233
2235
|
function Host(props) {
|
|
2236
|
+
const context = getCurrentHostContext();
|
|
2237
|
+
if (context) bindHostProps(context.host, props);
|
|
2234
2238
|
return resolveValue$1(props.children);
|
|
2235
2239
|
}
|
|
2236
2240
|
function Slot(props) {
|
|
2237
2241
|
return createSlot(props.name, () => resolveValue$1(props.children));
|
|
2238
2242
|
}
|
|
2243
|
+
function bindHostProps(host, props) {
|
|
2244
|
+
bindHostRef(host, props);
|
|
2245
|
+
bindHostClass(host, props);
|
|
2246
|
+
bindHostStyle(host, props);
|
|
2247
|
+
bindHostAttributes(host, props);
|
|
2248
|
+
}
|
|
2249
|
+
function bindHostRef(host, props) {
|
|
2250
|
+
if (!("ref" in props)) return;
|
|
2251
|
+
bindRef(host, props.ref);
|
|
2252
|
+
}
|
|
2253
|
+
function bindHostClass(host, props) {
|
|
2254
|
+
if (!("class" in props) && !("className" in props)) return;
|
|
2255
|
+
/**
|
|
2256
|
+
* className has higher priority than class when both exist.
|
|
2257
|
+
*/
|
|
2258
|
+
const value = props.className !== void 0 ? props.className : props.class;
|
|
2259
|
+
bindClass(host, () => {
|
|
2260
|
+
return resolveHostValue(value);
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function bindHostStyle(host, props) {
|
|
2264
|
+
if (!("style" in props)) return;
|
|
2265
|
+
bindStyle(host, () => {
|
|
2266
|
+
return resolveHostValue(props.style);
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
function bindHostAttributes(host, props) {
|
|
2270
|
+
for (const key of Object.keys(props)) {
|
|
2271
|
+
if (HOST_RESERVED_KEYS.has(key)) continue;
|
|
2272
|
+
if (isEventLikeProp(key)) continue;
|
|
2273
|
+
const value = props[key];
|
|
2274
|
+
bindAttr(host, normalizeHostAttrName(key), () => {
|
|
2275
|
+
return resolveHostValue(value);
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
function resolveHostValue(value) {
|
|
2280
|
+
/**
|
|
2281
|
+
* JSX component props may be direct values or lazy getters.
|
|
2282
|
+
* Function values are treated as getters except event-like props,
|
|
2283
|
+
* which are filtered before this function is called.
|
|
2284
|
+
*/
|
|
2285
|
+
return typeof value === "function" ? value() : value;
|
|
2286
|
+
}
|
|
2239
2287
|
function resolveValue$1(value) {
|
|
2240
2288
|
return typeof value === "function" ? value() : value;
|
|
2241
2289
|
}
|
|
2290
|
+
function isEventLikeProp(key) {
|
|
2291
|
+
/**
|
|
2292
|
+
* Host Phase 1 does not bind event listeners.
|
|
2293
|
+
* Keep event handling inside component template + emit().
|
|
2294
|
+
*/
|
|
2295
|
+
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
2296
|
+
}
|
|
2297
|
+
function normalizeHostAttrName(name) {
|
|
2298
|
+
switch (name) {
|
|
2299
|
+
case "className": return "class";
|
|
2300
|
+
case "htmlFor": return "for";
|
|
2301
|
+
case "tabIndex": return "tabindex";
|
|
2302
|
+
case "readOnly": return "readonly";
|
|
2303
|
+
default: return name;
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2242
2306
|
//#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 };
|
|
2307
|
+
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 };
|