@jasonshimmy/custom-elements-runtime 2.5.2 → 2.5.6
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/README.md +115 -40
- package/dist/css/colors.d.ts +14 -0
- package/dist/custom-elements-runtime.cjs.js +6 -1
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.cjs.js +2 -0
- package/dist/custom-elements-runtime.colors.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.colors.es.js +279 -0
- package/dist/custom-elements-runtime.colors.es.js.map +1 -0
- package/dist/custom-elements-runtime.directive-enhancements.es.js +1 -1
- package/dist/custom-elements-runtime.es.js +258 -166
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.es.js +28 -25
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
- package/dist/custom-elements-runtime.router.cjs.js +20 -20
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +549 -531
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
- package/dist/custom-elements-runtime.ssr.es.js +12 -8
- package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
- package/dist/custom-elements-runtime.store.cjs.js +1 -1
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.store.es.js +5 -5
- package/dist/custom-elements-runtime.store.es.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
- package/dist/custom-elements-runtime.transitions.es.js +1 -1
- package/dist/event-bus.d.ts +17 -4
- package/dist/index.d.ts +13 -5
- package/dist/keep-alive.d.ts +50 -0
- package/dist/{logger-BuUYv7C_.js → logger-BvkEbVM4.js} +15 -11
- package/dist/logger-BvkEbVM4.js.map +1 -0
- package/dist/logger-CSALKaYm.cjs +2 -0
- package/dist/logger-CSALKaYm.cjs.map +1 -0
- package/dist/namespace-helpers-4qeKVqQw.cjs +5 -0
- package/dist/namespace-helpers-4qeKVqQw.cjs.map +1 -0
- package/dist/namespace-helpers-DcD_6_K1.js +989 -0
- package/dist/namespace-helpers-DcD_6_K1.js.map +1 -0
- package/dist/router/active-proxy.d.ts +5 -0
- package/dist/router/component-loader.d.ts +11 -0
- package/dist/router/instance.d.ts +11 -0
- package/dist/router/matcher.d.ts +14 -0
- package/dist/router/path-utils.d.ts +48 -0
- package/dist/router/types.d.ts +134 -0
- package/dist/router.d.ts +6 -208
- package/dist/runtime/builtin-components.d.ts +78 -0
- package/dist/runtime/component/element-class.d.ts +4 -0
- package/dist/runtime/component/factory.d.ts +39 -0
- package/dist/runtime/component/registry.d.ts +16 -0
- package/dist/runtime/component.d.ts +3 -50
- package/dist/runtime/discovery-state.d.ts +30 -0
- package/dist/runtime/hooks.d.ts +115 -0
- package/dist/runtime/logger.d.ts +19 -1
- package/dist/runtime/monitoring/health-monitor.d.ts +22 -65
- package/dist/runtime/reactive.d.ts +39 -7
- package/dist/runtime/render.d.ts +20 -4
- package/dist/runtime/scheduler.d.ts +69 -2
- package/dist/runtime/template-compiler/impl.d.ts +14 -0
- package/dist/runtime/template-compiler/lru-cache.d.ts +20 -0
- package/dist/runtime/template-compiler/props-parser.d.ts +15 -0
- package/dist/runtime/template-compiler/vnode-utils.d.ts +5 -0
- package/dist/runtime/template-compiler.d.ts +5 -28
- package/dist/runtime/types.d.ts +10 -0
- package/dist/runtime/vdom-directives.d.ts +71 -0
- package/dist/runtime/vdom-helpers.d.ts +126 -0
- package/dist/runtime/vdom-patch.d.ts +67 -0
- package/dist/runtime/vdom.d.ts +16 -140
- package/dist/ssr.d.ts +2 -1
- package/dist/teleport.d.ts +68 -0
- package/dist/template-compiler-BO8UEEDA.js +3984 -0
- package/dist/template-compiler-BO8UEEDA.js.map +1 -0
- package/dist/template-compiler-C4L8vT-6.cjs +23 -0
- package/dist/template-compiler-C4L8vT-6.cjs.map +1 -0
- package/dist/transitions-DPZiuXb9.cjs +330 -0
- package/dist/transitions-DPZiuXb9.cjs.map +1 -0
- package/dist/{transitions-Bx0Nc9zR.js → transitions-Di5wW9yc.js} +1072 -632
- package/dist/transitions-Di5wW9yc.js.map +1 -0
- package/dist/transitions.d.ts +1 -1
- package/package.json +18 -11
- package/dist/logger-BuUYv7C_.js.map +0 -1
- package/dist/logger-DiXdWaF-.cjs +0 -2
- package/dist/logger-DiXdWaF-.cjs.map +0 -1
- package/dist/namespace-helpers-BCVTzhAO.cjs +0 -5
- package/dist/namespace-helpers-BCVTzhAO.cjs.map +0 -1
- package/dist/namespace-helpers-CF28TyaG.js +0 -786
- package/dist/namespace-helpers-CF28TyaG.js.map +0 -1
- package/dist/template-compiler-CXHEnaBh.cjs +0 -17
- package/dist/template-compiler-CXHEnaBh.cjs.map +0 -1
- package/dist/template-compiler-DD_VZrte.js +0 -3729
- package/dist/template-compiler-DD_VZrte.js.map +0 -1
- package/dist/transitions-Bx0Nc9zR.js.map +0 -1
- package/dist/transitions-DfcqL-X4.cjs +0 -302
- package/dist/transitions-DfcqL-X4.cjs.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom-patch.ts
|
|
3
|
+
*
|
|
4
|
+
* Core virtual DOM patching and rendering engine. Provides:
|
|
5
|
+
* - `cleanupRefs` — recursively remove event listeners and clear ref entries
|
|
6
|
+
* - `assignKeysDeep` — recursively assign stable keys to VNode trees
|
|
7
|
+
* - `patchProps` — diff and apply prop/attr/directive changes to a DOM element
|
|
8
|
+
* - `createElement` — create a new DOM element from a VNode descriptor
|
|
9
|
+
* - `patchChildren` — reconcile a list of child VNodes against real DOM children
|
|
10
|
+
* - `patch` — top-level diff/patch driver for a single VNode
|
|
11
|
+
* - `vdomRenderer` — entry-point renderer for a shadow root or container
|
|
12
|
+
*/
|
|
13
|
+
import type { VNode, VDomRefs } from './types';
|
|
14
|
+
import { type VNodePropBag } from './vdom-helpers';
|
|
15
|
+
export declare function cleanupRefs(node: Node, refs?: VDomRefs): void;
|
|
16
|
+
/**
|
|
17
|
+
* Assign unique keys to VNodes for efficient rendering
|
|
18
|
+
* @param nodeOrNodes
|
|
19
|
+
* @param baseKey
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function assignKeysDeep(nodeOrNodes: VNode | VNode[], baseKey: string): VNode | VNode[];
|
|
23
|
+
/**
|
|
24
|
+
* Patch props on an element.
|
|
25
|
+
* Only update changed props, remove old, add new.
|
|
26
|
+
* @param el
|
|
27
|
+
* @param oldProps
|
|
28
|
+
* @param newProps
|
|
29
|
+
* @param context
|
|
30
|
+
*/
|
|
31
|
+
export declare function patchProps(el: HTMLElement, oldProps: VNodePropBag, newProps: VNodePropBag, context?: Record<string, unknown>): void;
|
|
32
|
+
/**
|
|
33
|
+
* Create a DOM element from a VNode.
|
|
34
|
+
* @param vnode
|
|
35
|
+
* @param context
|
|
36
|
+
* @param refs
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
export declare function createElement(vnode: VNode | string, context?: Record<string, unknown>, refs?: VDomRefs, parentNamespace?: string | null): Node;
|
|
40
|
+
/**
|
|
41
|
+
* Patch children using keys for node matching.
|
|
42
|
+
* @param parent
|
|
43
|
+
* @param oldChildren
|
|
44
|
+
* @param newChildren
|
|
45
|
+
* @param context
|
|
46
|
+
* @param refs
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export declare function patchChildren(parent: HTMLElement, oldChildren: VNode[] | string | undefined, newChildren: VNode[] | string | undefined, context?: Record<string, unknown>, refs?: VDomRefs): void;
|
|
50
|
+
/**
|
|
51
|
+
* Patch a node using keys for node matching.
|
|
52
|
+
* @param dom
|
|
53
|
+
* @param oldVNode
|
|
54
|
+
* @param newVNode
|
|
55
|
+
* @param context
|
|
56
|
+
* @param refs
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
export declare function patch(dom: Node, oldVNode: VNode | string | null, newVNode: VNode | string | null, context?: Record<string, unknown>, refs?: VDomRefs): Node;
|
|
60
|
+
/**
|
|
61
|
+
* Virtual DOM renderer.
|
|
62
|
+
* @param root The root element to render into.
|
|
63
|
+
* @param vnodeOrArray The virtual node or array of virtual nodes to render.
|
|
64
|
+
* @param context The context to use for rendering.
|
|
65
|
+
* @param refs The refs to use for rendering.
|
|
66
|
+
*/
|
|
67
|
+
export declare function vdomRenderer(root: ShadowRoot, vnodeOrArray: VNode | VNode[], context?: Record<string, unknown>, refs?: VDomRefs): void;
|
package/dist/runtime/vdom.d.ts
CHANGED
|
@@ -1,142 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* vdom.ts
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Recursively clean up refs and event listeners for all descendants of a node
|
|
22
|
-
* @param node The node to clean up.
|
|
23
|
-
* @param refs The refs to clean up.
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
export declare function cleanupRefs(node: Node, refs?: VDomRefs): void;
|
|
27
|
-
/**
|
|
28
|
-
* Process :model directive for two-way data binding
|
|
29
|
-
* @param value
|
|
30
|
-
* @param modifiers
|
|
31
|
-
* @param props
|
|
32
|
-
* @param attrs
|
|
33
|
-
* @param listeners
|
|
34
|
-
* @param context
|
|
35
|
-
* @param el
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
export declare function processModelDirective(value: string | unknown, modifiers: string[], props: Record<string, unknown>, attrs: Record<string, unknown>, listeners: Record<string, EventListener>, context?: Record<string, unknown>, el?: Element, arg?: string): void;
|
|
39
|
-
/**
|
|
40
|
-
* Process :bind directive for attribute/property binding
|
|
41
|
-
* @param value
|
|
42
|
-
* @param props
|
|
43
|
-
* @param attrs
|
|
44
|
-
* @param context
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
export declare function processBindDirective(value: unknown, props: PropsMap, attrs: PropsMap, context?: Record<string, unknown>, el?: Element): void;
|
|
48
|
-
/**
|
|
49
|
-
* Process :show directive for conditional display
|
|
50
|
-
* @param value
|
|
51
|
-
* @param attrs
|
|
52
|
-
* @param context
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
export declare function processShowDirective(value: unknown, attrs: Record<string, unknown>, context?: Record<string, unknown>): void;
|
|
56
|
-
export declare function processClassDirective(value: unknown, attrs: Record<string, unknown>, context?: Record<string, unknown>, originalVnodeAttrs?: Record<string, unknown>): void;
|
|
57
|
-
/**
|
|
58
|
-
* Process :style directive for dynamic inline styles
|
|
59
|
-
* @param value
|
|
60
|
-
* @param attrs
|
|
61
|
-
* @param context
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
export declare function processStyleDirective(value: unknown, attrs: Record<string, unknown>, context?: Record<string, unknown>): void;
|
|
65
|
-
/**
|
|
66
|
-
* Process :ref directive for element references
|
|
67
|
-
* @param value
|
|
68
|
-
* @param props
|
|
69
|
-
* @param context
|
|
70
|
-
* @returns
|
|
71
|
-
*/
|
|
72
|
-
export declare function processRefDirective(value: unknown, props: Record<string, unknown>, context?: Record<string, unknown>): void;
|
|
73
|
-
/**
|
|
74
|
-
* Process directives and return merged props, attrs, and event listeners
|
|
75
|
-
* @param directives
|
|
76
|
-
* @param context
|
|
77
|
-
* @param el
|
|
78
|
-
* @param vnodeAttrs
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
export declare function processDirectives(directives: Record<string, {
|
|
82
|
-
value: unknown;
|
|
83
|
-
modifiers: string[];
|
|
84
|
-
arg?: string;
|
|
85
|
-
}>, context?: Record<string, unknown>, el?: Element, vnodeAttrs?: PropsMap): {
|
|
86
|
-
props: Record<string, unknown>;
|
|
87
|
-
attrs: Record<string, unknown>;
|
|
88
|
-
listeners: Record<string, EventListener>;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Assign unique keys to VNodes for efficient rendering
|
|
92
|
-
* @param nodeOrNodes
|
|
93
|
-
* @param baseKey
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
export declare function assignKeysDeep(nodeOrNodes: VNode | VNode[], baseKey: string): VNode | VNode[];
|
|
97
|
-
/**
|
|
98
|
-
* Patch props on an element.
|
|
99
|
-
* Only update changed props, remove old, add new.
|
|
100
|
-
* @param el
|
|
101
|
-
* @param oldProps
|
|
102
|
-
* @param newProps
|
|
103
|
-
* @param context
|
|
104
|
-
*/
|
|
105
|
-
export declare function patchProps(el: HTMLElement, oldProps: VNodePropBag, newProps: VNodePropBag, context?: Record<string, unknown>): void;
|
|
106
|
-
/**
|
|
107
|
-
* Create a DOM element from a VNode.
|
|
108
|
-
* @param vnode
|
|
109
|
-
* @param context
|
|
110
|
-
* @param refs
|
|
111
|
-
* @returns
|
|
112
|
-
*/
|
|
113
|
-
export declare function createElement(vnode: VNode | string, context?: Record<string, unknown>, refs?: VDomRefs, parentNamespace?: string | null): Node;
|
|
114
|
-
/**
|
|
115
|
-
* Patch children using keys for node matching.
|
|
116
|
-
* @param parent
|
|
117
|
-
* @param oldChildren
|
|
118
|
-
* @param newChildren
|
|
119
|
-
* @param context
|
|
120
|
-
* @param refs
|
|
121
|
-
* @returns
|
|
122
|
-
*/
|
|
123
|
-
export declare function patchChildren(parent: HTMLElement, oldChildren: VNode[] | string | undefined, newChildren: VNode[] | string | undefined, context?: Record<string, unknown>, refs?: VDomRefs): void;
|
|
124
|
-
/**
|
|
125
|
-
* Patch a node using keys for node matching.
|
|
126
|
-
* @param dom
|
|
127
|
-
* @param oldVNode
|
|
128
|
-
* @param newVNode
|
|
129
|
-
* @param context
|
|
130
|
-
* @param refs
|
|
131
|
-
* @returns
|
|
132
|
-
*/
|
|
133
|
-
export declare function patch(dom: Node, oldVNode: VNode | string | null, newVNode: VNode | string | null, context?: Record<string, unknown>, refs?: VDomRefs): Node;
|
|
134
|
-
/**
|
|
135
|
-
* Virtual DOM renderer.
|
|
136
|
-
* @param root The root element to render into.
|
|
137
|
-
* @param vnodeOrArray The virtual node or array of virtual nodes to render.
|
|
138
|
-
* @param context The context to use for rendering.
|
|
139
|
-
* @param refs The refs to use for rendering.
|
|
140
|
-
*/
|
|
141
|
-
export declare function vdomRenderer(root: ShadowRoot, vnodeOrArray: VNode | VNode[], context?: Record<string, unknown>, refs?: VDomRefs): void;
|
|
142
|
-
export {};
|
|
3
|
+
*
|
|
4
|
+
* Barrel re-export module for the virtual DOM implementation.
|
|
5
|
+
* The actual code lives in the focused sub-modules:
|
|
6
|
+
*
|
|
7
|
+
* | Module | Responsibilities |
|
|
8
|
+
* |----------------------|--------------------------------------------------------|
|
|
9
|
+
* | vdom-helpers.ts | Private utilities and shared internal types |
|
|
10
|
+
* | vdom-directives.ts | processModelDirective and all process*Directive funcs |
|
|
11
|
+
* | vdom-patch.ts | assignKeysDeep, patchProps, createElement, patch, etc. |
|
|
12
|
+
* | vdom-ssr.ts | renderToString (server-side rendering) |
|
|
13
|
+
*
|
|
14
|
+
* Import directly from these focused modules for tree-shaking.
|
|
15
|
+
* This file is kept for backwards compatibility.
|
|
16
|
+
*/
|
|
17
|
+
export { processModelDirective, processBindDirective, processShowDirective, processClassDirective, processStyleDirective, processRefDirective, processDirectives, } from "./vdom-directives";
|
|
18
|
+
export { cleanupRefs, assignKeysDeep, patchProps, createElement, patchChildren, patch, vdomRenderer, } from "./vdom-patch";
|
package/dist/ssr.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* Examples
|
|
17
17
|
*
|
|
18
18
|
* // Default (injects xmlns for <svg> if missing)
|
|
19
|
-
* import { renderToString } from '@custom-elements/ssr';
|
|
19
|
+
* import { renderToString } from '@jasonshimmy/custom-elements-runtime/ssr';
|
|
20
20
|
* const html = renderToString(vnodeTree);
|
|
21
21
|
*
|
|
22
22
|
* // Opt-out
|
|
@@ -25,3 +25,4 @@
|
|
|
25
25
|
export { renderToString } from './runtime/vdom-ssr';
|
|
26
26
|
export type { VNode } from './runtime/types';
|
|
27
27
|
export type { RenderOptions } from './runtime/vdom-ssr';
|
|
28
|
+
export { registerEntityMap, loadEntityMap, clearRegisteredEntityMap, } from './runtime/helpers';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* teleport.ts
|
|
3
|
+
*
|
|
4
|
+
* Renders virtual DOM content into an arbitrary DOM target located outside
|
|
5
|
+
* the current component's Shadow Root. Useful for modals, tooltips, popovers,
|
|
6
|
+
* and any UI that must visually escape the component boundary.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { component, html, ref, useOnDisconnected, useTeleport } from '@jasonshimmy/custom-elements-runtime';
|
|
11
|
+
*
|
|
12
|
+
* component('modal-trigger', () => {
|
|
13
|
+
* const isOpen = ref(false);
|
|
14
|
+
*
|
|
15
|
+
* // Render modal content into <body> outside the shadow root
|
|
16
|
+
* const { portal, destroy } = useTeleport('#modal-root');
|
|
17
|
+
* useOnDisconnected(destroy);
|
|
18
|
+
*
|
|
19
|
+
* // Call portal() to update the teleported content on each render
|
|
20
|
+
* if (isOpen.value) {
|
|
21
|
+
* portal(html`<div class="modal">
|
|
22
|
+
* <h2>Hello</h2>
|
|
23
|
+
* <button @click="${() => (isOpen.value = false)}">Close</button>
|
|
24
|
+
* </div>`);
|
|
25
|
+
* } else {
|
|
26
|
+
* portal(null);
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* return html`
|
|
30
|
+
* <button @click="${() => (isOpen.value = true)}">Open modal</button>
|
|
31
|
+
* `;
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import type { VNode } from './runtime/types';
|
|
36
|
+
/** Handle returned by {@link useTeleport} for managing a portal. */
|
|
37
|
+
export interface TeleportHandle {
|
|
38
|
+
/**
|
|
39
|
+
* Render (or clear) content at the teleport target.
|
|
40
|
+
* Pass `null` or `undefined` to remove previously rendered content.
|
|
41
|
+
*/
|
|
42
|
+
portal(content: VNode | VNode[] | null | undefined): void;
|
|
43
|
+
/**
|
|
44
|
+
* Destroy the teleport container and clean up all rendered content.
|
|
45
|
+
* Call this in `useOnDisconnected` to prevent memory leaks.
|
|
46
|
+
*/
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a teleport portal that renders content outside the current Shadow Root.
|
|
51
|
+
*
|
|
52
|
+
* @param target - A CSS selector string or an `Element` reference to render into.
|
|
53
|
+
* @returns A {@link TeleportHandle} with `portal()` (update content) and `destroy()` (cleanup).
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { component, html, useOnDisconnected, useTeleport } from '@jasonshimmy/custom-elements-runtime';
|
|
58
|
+
*
|
|
59
|
+
* component('my-tooltip', () => {
|
|
60
|
+
* const { portal, destroy } = useTeleport('body');
|
|
61
|
+
* useOnDisconnected(destroy);
|
|
62
|
+
*
|
|
63
|
+
* portal(html`<div class="tooltip">Tooltip content</div>`);
|
|
64
|
+
* return html`<span>Hover me</span>`;
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function useTeleport(target: string | Element): TeleportHandle;
|