@estjs/template 0.0.14-beta.6 → 0.0.14
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/template.cjs.js +3 -23
- package/dist/template.cjs.js.map +1 -1
- package/dist/template.d.cts +76 -40
- package/dist/template.d.ts +76 -40
- package/dist/template.dev.cjs.js +100 -145
- package/dist/template.dev.esm.js +101 -145
- package/dist/template.esm.js +3 -9
- package/dist/template.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/template.d.cts
CHANGED
|
@@ -4,6 +4,17 @@ import * as csstype from 'csstype';
|
|
|
4
4
|
type EssorComponent = (props: Record<string, unknown>) => JSX.Element | TemplateNode;
|
|
5
5
|
type Hook = 'mounted' | 'destroy';
|
|
6
6
|
|
|
7
|
+
interface NodeTrack {
|
|
8
|
+
cleanup: () => void;
|
|
9
|
+
isRoot?: boolean;
|
|
10
|
+
lastNodes?: Map<string, Node | JSX.Element>;
|
|
11
|
+
}
|
|
12
|
+
interface NodeTrack {
|
|
13
|
+
cleanup: () => void;
|
|
14
|
+
isRoot?: boolean;
|
|
15
|
+
lastNodes?: Map<string, Node | JSX.Element>;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
type Props = Record<string, any>;
|
|
8
19
|
|
|
9
20
|
interface EssorNode<T = Record<string, any>> {
|
|
@@ -2212,30 +2223,71 @@ declare class LifecycleContext {
|
|
|
2212
2223
|
clearHooks(): void;
|
|
2213
2224
|
}
|
|
2214
2225
|
|
|
2226
|
+
declare class TemplateNode$1 implements JSX.Element {
|
|
2227
|
+
template: HTMLTemplateElement;
|
|
2228
|
+
props: Props;
|
|
2229
|
+
key?: string | undefined;
|
|
2230
|
+
protected treeMap: Map<number, Node>;
|
|
2231
|
+
protected mounted: boolean;
|
|
2232
|
+
protected nodes: Node[];
|
|
2233
|
+
protected trackMap: Map<string, NodeTrack>;
|
|
2234
|
+
protected bindValueKeys: string[];
|
|
2235
|
+
protected componentIndex: number;
|
|
2236
|
+
protected parent: Node | null;
|
|
2237
|
+
constructor(template: HTMLTemplateElement, props: Props, key?: string | undefined);
|
|
2238
|
+
get firstChild(): Node | null;
|
|
2239
|
+
get isConnected(): boolean;
|
|
2240
|
+
addEventListener(): void;
|
|
2241
|
+
removeEventListener(): void;
|
|
2242
|
+
mount(parent: Node, before?: Node | null): Node[];
|
|
2243
|
+
unmount(): void;
|
|
2244
|
+
inheritNode(node: TemplateNode$1): void;
|
|
2245
|
+
protected mapSSGNodeTree(parent: Node): void;
|
|
2246
|
+
protected mapNodeTree(parent: Node, tree: Node): void;
|
|
2247
|
+
protected walkNodeTree(node: Node, handler: (node: Node) => void): void;
|
|
2248
|
+
protected handleSSGNode(node: Node): void;
|
|
2249
|
+
protected patchProps(props: Record<string, Record<string, unknown>> | undefined): void;
|
|
2250
|
+
protected patchProp(key: string, node: Node, props: Record<string, unknown>, isRoot: boolean): void;
|
|
2251
|
+
protected getBindUpdateValue(props: Record<string, any>, key: string, attr: string): any;
|
|
2252
|
+
protected patchChildren(key: string, node: Node, children: unknown, isRoot: boolean): void;
|
|
2253
|
+
protected patchEventListener(key: string, node: Node, attr: string, listener: EventListener): void;
|
|
2254
|
+
protected patchAttribute(key: string, element: HTMLElement, attr: string, value: unknown, updateFn?: Function): void;
|
|
2255
|
+
protected getNodeTrack(trackKey: string, trackLastNodes?: boolean, isRoot?: boolean): NodeTrack;
|
|
2256
|
+
protected patchChild(track: NodeTrack, parent: Node, child: unknown, before: Node | null): void;
|
|
2257
|
+
protected reconcileChildren(parent: Node, nextNodes: Node[], before: Node | null): Map<string, Node>;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2215
2260
|
declare class ComponentNode$1 extends LifecycleContext implements JSX.Element {
|
|
2216
2261
|
template: EssorComponent;
|
|
2217
|
-
props
|
|
2262
|
+
props: Props;
|
|
2218
2263
|
key?: string | undefined;
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2264
|
+
protected proxyProps: Record<string, Signal$1<unknown>>;
|
|
2265
|
+
protected emitter: Set<() => void>;
|
|
2266
|
+
protected rootNode: TemplateNode$1 | null;
|
|
2267
|
+
protected trackMap: Map<string, NodeTrack>;
|
|
2268
|
+
protected nodes: Node[];
|
|
2269
|
+
protected parent: Node | null;
|
|
2270
|
+
protected before: Node | null;
|
|
2271
|
+
constructor(template: EssorComponent, props: Props, key?: string | undefined);
|
|
2225
2272
|
get firstChild(): Node | null;
|
|
2226
2273
|
get isConnected(): boolean;
|
|
2227
|
-
mount(parent: Node, before
|
|
2274
|
+
mount(parent: Node, before: Node | null): Node[];
|
|
2228
2275
|
unmount(): void;
|
|
2229
|
-
private
|
|
2230
|
-
|
|
2231
|
-
|
|
2276
|
+
private resetState;
|
|
2277
|
+
protected callLifecycleHooks(type: 'mounted' | 'destroy'): void;
|
|
2278
|
+
protected callMountHooks(): void;
|
|
2279
|
+
protected callDestroyHooks(): void;
|
|
2280
|
+
protected clearEmitter(): void;
|
|
2232
2281
|
inheritNode(node: ComponentNode$1): void;
|
|
2233
|
-
|
|
2282
|
+
protected getNodeTrack(trackKey: string): NodeTrack;
|
|
2234
2283
|
patchProps(props: Record<string, any> | undefined): void;
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2284
|
+
protected patchEventListener(key: string, prop: any): void;
|
|
2285
|
+
protected patchRef(prop: {
|
|
2286
|
+
value: Node | null;
|
|
2287
|
+
}): void;
|
|
2288
|
+
protected patchUpdateHandler(key: string, prop: any): void;
|
|
2289
|
+
protected patchNormalProp(key: string, prop: any): void;
|
|
2290
|
+
protected cleanup(): void;
|
|
2239
2291
|
}
|
|
2240
2292
|
|
|
2241
2293
|
/**
|
|
@@ -2270,14 +2322,12 @@ declare function isJsxElement(node: unknown): node is EssorNode;
|
|
|
2270
2322
|
* @returns A new HTML template element.
|
|
2271
2323
|
*/
|
|
2272
2324
|
declare function createTemplate(html: string): HTMLTemplateElement;
|
|
2273
|
-
|
|
2274
|
-
* @param props - An object containing the `children` prop.
|
|
2275
|
-
* @param props.children - The children to be rendered. Can be a single JSX element, string, number, boolean,
|
|
2276
|
-
* or an array of these. Falsy values in arrays will be filtered out.
|
|
2277
|
-
* @returns A JSX element representing the fragment, wrapping the filtered children.
|
|
2278
|
-
*/
|
|
2279
|
-
declare function Fragment<T extends JSX.JSXElement | string | number | boolean | (JSX.JSXElement | string | number | boolean)[]>(props: {
|
|
2325
|
+
declare function Fragment<T extends JSX.JSXElement | string | number | boolean | Array<JSX.JSXElement | string | number | boolean>>(template: HTMLTemplateElement | '', props: {
|
|
2280
2326
|
children: T;
|
|
2327
|
+
} | {
|
|
2328
|
+
[key: string]: {
|
|
2329
|
+
children: T;
|
|
2330
|
+
};
|
|
2281
2331
|
}): JSX.Element;
|
|
2282
2332
|
|
|
2283
2333
|
/**
|
|
@@ -2309,7 +2359,7 @@ interface InjectionKey<T> extends Symbol {
|
|
|
2309
2359
|
* @param key - The key to store the value in the LifecycleContext with.
|
|
2310
2360
|
* @param value - The value to store in the LifecycleContext with the given key.
|
|
2311
2361
|
*/
|
|
2312
|
-
declare function
|
|
2362
|
+
declare function provide<T, K = InjectionKey<T> | string | number>(key: K, value: K extends InjectionKey<infer V> ? V : T): void;
|
|
2313
2363
|
/**
|
|
2314
2364
|
* Injects a value from the current component LifecycleContext.
|
|
2315
2365
|
*
|
|
@@ -2322,21 +2372,7 @@ declare function useProvide<T, K = InjectionKey<T> | string | number>(key: K, va
|
|
|
2322
2372
|
* @returns The value stored in the LifecycleContext with the given key, or the default
|
|
2323
2373
|
* value if the key is not present in the LifecycleContext.
|
|
2324
2374
|
*/
|
|
2325
|
-
declare function
|
|
2326
|
-
/**
|
|
2327
|
-
* Creates a reactive ref that can be used to reference a DOM node
|
|
2328
|
-
* or a component instance within the component function body.
|
|
2329
|
-
*
|
|
2330
|
-
* @returns a reactive ref signal
|
|
2331
|
-
*
|
|
2332
|
-
* @example
|
|
2333
|
-
* const inputRef = useRef<HTMLInputElement>()
|
|
2334
|
-
*
|
|
2335
|
-
* <input ref={inputRef} />
|
|
2336
|
-
*
|
|
2337
|
-
* inputRef.value // input element
|
|
2338
|
-
*/
|
|
2339
|
-
declare function useRef<T>(): Signal$1<T | null>;
|
|
2375
|
+
declare function inject<T, K = InjectionKey<T> | string | number>(key: K, defaultValue?: K extends InjectionKey<infer V> ? V : T): (K extends InjectionKey<infer V> ? V : T) | undefined;
|
|
2340
2376
|
|
|
2341
2377
|
declare class SSGNode extends LifecycleContext {
|
|
2342
2378
|
private template;
|
|
@@ -2386,4 +2422,4 @@ declare function hydrate(component: EssorComponent, container: string | Element)
|
|
|
2386
2422
|
*/
|
|
2387
2423
|
declare function ssg(component: EssorComponent, props?: Props): SSGNode | JSX.Element;
|
|
2388
2424
|
|
|
2389
|
-
export { Fragment, type InjectionKey, h, hydrate, isComponent, isJsxElement, onDestroy, onMount, renderToString, ssg, createTemplate as template
|
|
2425
|
+
export { Fragment, type InjectionKey, h, hydrate, inject, isComponent, isJsxElement, onDestroy, onMount, provide, renderToString, ssg, createTemplate as template };
|
package/dist/template.d.ts
CHANGED
|
@@ -4,6 +4,17 @@ import * as csstype from 'csstype';
|
|
|
4
4
|
type EssorComponent = (props: Record<string, unknown>) => JSX.Element | TemplateNode;
|
|
5
5
|
type Hook = 'mounted' | 'destroy';
|
|
6
6
|
|
|
7
|
+
interface NodeTrack {
|
|
8
|
+
cleanup: () => void;
|
|
9
|
+
isRoot?: boolean;
|
|
10
|
+
lastNodes?: Map<string, Node | JSX.Element>;
|
|
11
|
+
}
|
|
12
|
+
interface NodeTrack {
|
|
13
|
+
cleanup: () => void;
|
|
14
|
+
isRoot?: boolean;
|
|
15
|
+
lastNodes?: Map<string, Node | JSX.Element>;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
type Props = Record<string, any>;
|
|
8
19
|
|
|
9
20
|
interface EssorNode<T = Record<string, any>> {
|
|
@@ -2212,30 +2223,71 @@ declare class LifecycleContext {
|
|
|
2212
2223
|
clearHooks(): void;
|
|
2213
2224
|
}
|
|
2214
2225
|
|
|
2226
|
+
declare class TemplateNode$1 implements JSX.Element {
|
|
2227
|
+
template: HTMLTemplateElement;
|
|
2228
|
+
props: Props;
|
|
2229
|
+
key?: string | undefined;
|
|
2230
|
+
protected treeMap: Map<number, Node>;
|
|
2231
|
+
protected mounted: boolean;
|
|
2232
|
+
protected nodes: Node[];
|
|
2233
|
+
protected trackMap: Map<string, NodeTrack>;
|
|
2234
|
+
protected bindValueKeys: string[];
|
|
2235
|
+
protected componentIndex: number;
|
|
2236
|
+
protected parent: Node | null;
|
|
2237
|
+
constructor(template: HTMLTemplateElement, props: Props, key?: string | undefined);
|
|
2238
|
+
get firstChild(): Node | null;
|
|
2239
|
+
get isConnected(): boolean;
|
|
2240
|
+
addEventListener(): void;
|
|
2241
|
+
removeEventListener(): void;
|
|
2242
|
+
mount(parent: Node, before?: Node | null): Node[];
|
|
2243
|
+
unmount(): void;
|
|
2244
|
+
inheritNode(node: TemplateNode$1): void;
|
|
2245
|
+
protected mapSSGNodeTree(parent: Node): void;
|
|
2246
|
+
protected mapNodeTree(parent: Node, tree: Node): void;
|
|
2247
|
+
protected walkNodeTree(node: Node, handler: (node: Node) => void): void;
|
|
2248
|
+
protected handleSSGNode(node: Node): void;
|
|
2249
|
+
protected patchProps(props: Record<string, Record<string, unknown>> | undefined): void;
|
|
2250
|
+
protected patchProp(key: string, node: Node, props: Record<string, unknown>, isRoot: boolean): void;
|
|
2251
|
+
protected getBindUpdateValue(props: Record<string, any>, key: string, attr: string): any;
|
|
2252
|
+
protected patchChildren(key: string, node: Node, children: unknown, isRoot: boolean): void;
|
|
2253
|
+
protected patchEventListener(key: string, node: Node, attr: string, listener: EventListener): void;
|
|
2254
|
+
protected patchAttribute(key: string, element: HTMLElement, attr: string, value: unknown, updateFn?: Function): void;
|
|
2255
|
+
protected getNodeTrack(trackKey: string, trackLastNodes?: boolean, isRoot?: boolean): NodeTrack;
|
|
2256
|
+
protected patchChild(track: NodeTrack, parent: Node, child: unknown, before: Node | null): void;
|
|
2257
|
+
protected reconcileChildren(parent: Node, nextNodes: Node[], before: Node | null): Map<string, Node>;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2215
2260
|
declare class ComponentNode$1 extends LifecycleContext implements JSX.Element {
|
|
2216
2261
|
template: EssorComponent;
|
|
2217
|
-
props
|
|
2262
|
+
props: Props;
|
|
2218
2263
|
key?: string | undefined;
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2264
|
+
protected proxyProps: Record<string, Signal$1<unknown>>;
|
|
2265
|
+
protected emitter: Set<() => void>;
|
|
2266
|
+
protected rootNode: TemplateNode$1 | null;
|
|
2267
|
+
protected trackMap: Map<string, NodeTrack>;
|
|
2268
|
+
protected nodes: Node[];
|
|
2269
|
+
protected parent: Node | null;
|
|
2270
|
+
protected before: Node | null;
|
|
2271
|
+
constructor(template: EssorComponent, props: Props, key?: string | undefined);
|
|
2225
2272
|
get firstChild(): Node | null;
|
|
2226
2273
|
get isConnected(): boolean;
|
|
2227
|
-
mount(parent: Node, before
|
|
2274
|
+
mount(parent: Node, before: Node | null): Node[];
|
|
2228
2275
|
unmount(): void;
|
|
2229
|
-
private
|
|
2230
|
-
|
|
2231
|
-
|
|
2276
|
+
private resetState;
|
|
2277
|
+
protected callLifecycleHooks(type: 'mounted' | 'destroy'): void;
|
|
2278
|
+
protected callMountHooks(): void;
|
|
2279
|
+
protected callDestroyHooks(): void;
|
|
2280
|
+
protected clearEmitter(): void;
|
|
2232
2281
|
inheritNode(node: ComponentNode$1): void;
|
|
2233
|
-
|
|
2282
|
+
protected getNodeTrack(trackKey: string): NodeTrack;
|
|
2234
2283
|
patchProps(props: Record<string, any> | undefined): void;
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2284
|
+
protected patchEventListener(key: string, prop: any): void;
|
|
2285
|
+
protected patchRef(prop: {
|
|
2286
|
+
value: Node | null;
|
|
2287
|
+
}): void;
|
|
2288
|
+
protected patchUpdateHandler(key: string, prop: any): void;
|
|
2289
|
+
protected patchNormalProp(key: string, prop: any): void;
|
|
2290
|
+
protected cleanup(): void;
|
|
2239
2291
|
}
|
|
2240
2292
|
|
|
2241
2293
|
/**
|
|
@@ -2270,14 +2322,12 @@ declare function isJsxElement(node: unknown): node is EssorNode;
|
|
|
2270
2322
|
* @returns A new HTML template element.
|
|
2271
2323
|
*/
|
|
2272
2324
|
declare function createTemplate(html: string): HTMLTemplateElement;
|
|
2273
|
-
|
|
2274
|
-
* @param props - An object containing the `children` prop.
|
|
2275
|
-
* @param props.children - The children to be rendered. Can be a single JSX element, string, number, boolean,
|
|
2276
|
-
* or an array of these. Falsy values in arrays will be filtered out.
|
|
2277
|
-
* @returns A JSX element representing the fragment, wrapping the filtered children.
|
|
2278
|
-
*/
|
|
2279
|
-
declare function Fragment<T extends JSX.JSXElement | string | number | boolean | (JSX.JSXElement | string | number | boolean)[]>(props: {
|
|
2325
|
+
declare function Fragment<T extends JSX.JSXElement | string | number | boolean | Array<JSX.JSXElement | string | number | boolean>>(template: HTMLTemplateElement | '', props: {
|
|
2280
2326
|
children: T;
|
|
2327
|
+
} | {
|
|
2328
|
+
[key: string]: {
|
|
2329
|
+
children: T;
|
|
2330
|
+
};
|
|
2281
2331
|
}): JSX.Element;
|
|
2282
2332
|
|
|
2283
2333
|
/**
|
|
@@ -2309,7 +2359,7 @@ interface InjectionKey<T> extends Symbol {
|
|
|
2309
2359
|
* @param key - The key to store the value in the LifecycleContext with.
|
|
2310
2360
|
* @param value - The value to store in the LifecycleContext with the given key.
|
|
2311
2361
|
*/
|
|
2312
|
-
declare function
|
|
2362
|
+
declare function provide<T, K = InjectionKey<T> | string | number>(key: K, value: K extends InjectionKey<infer V> ? V : T): void;
|
|
2313
2363
|
/**
|
|
2314
2364
|
* Injects a value from the current component LifecycleContext.
|
|
2315
2365
|
*
|
|
@@ -2322,21 +2372,7 @@ declare function useProvide<T, K = InjectionKey<T> | string | number>(key: K, va
|
|
|
2322
2372
|
* @returns The value stored in the LifecycleContext with the given key, or the default
|
|
2323
2373
|
* value if the key is not present in the LifecycleContext.
|
|
2324
2374
|
*/
|
|
2325
|
-
declare function
|
|
2326
|
-
/**
|
|
2327
|
-
* Creates a reactive ref that can be used to reference a DOM node
|
|
2328
|
-
* or a component instance within the component function body.
|
|
2329
|
-
*
|
|
2330
|
-
* @returns a reactive ref signal
|
|
2331
|
-
*
|
|
2332
|
-
* @example
|
|
2333
|
-
* const inputRef = useRef<HTMLInputElement>()
|
|
2334
|
-
*
|
|
2335
|
-
* <input ref={inputRef} />
|
|
2336
|
-
*
|
|
2337
|
-
* inputRef.value // input element
|
|
2338
|
-
*/
|
|
2339
|
-
declare function useRef<T>(): Signal$1<T | null>;
|
|
2375
|
+
declare function inject<T, K = InjectionKey<T> | string | number>(key: K, defaultValue?: K extends InjectionKey<infer V> ? V : T): (K extends InjectionKey<infer V> ? V : T) | undefined;
|
|
2340
2376
|
|
|
2341
2377
|
declare class SSGNode extends LifecycleContext {
|
|
2342
2378
|
private template;
|
|
@@ -2386,4 +2422,4 @@ declare function hydrate(component: EssorComponent, container: string | Element)
|
|
|
2386
2422
|
*/
|
|
2387
2423
|
declare function ssg(component: EssorComponent, props?: Props): SSGNode | JSX.Element;
|
|
2388
2424
|
|
|
2389
|
-
export { Fragment, type InjectionKey, h, hydrate, isComponent, isJsxElement, onDestroy, onMount, renderToString, ssg, createTemplate as template
|
|
2425
|
+
export { Fragment, type InjectionKey, h, hydrate, inject, isComponent, isJsxElement, onDestroy, onMount, provide, renderToString, ssg, createTemplate as template };
|