@estjs/template 0.0.14-beta.1 → 0.0.14-beta.12
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 +70 -21
- package/dist/template.d.ts +70 -21
- package/dist/template.dev.cjs.js +82 -131
- package/dist/template.dev.esm.js +84 -133
- 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,70 @@ 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 | undefined;
|
|
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 | undefined, 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
2262
|
props?: Props | undefined;
|
|
2218
2263
|
key?: string | undefined;
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
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>;
|
|
2223
2268
|
constructor(template: EssorComponent, props?: Props | undefined, key?: string | undefined);
|
|
2224
|
-
|
|
2269
|
+
protected createProxyProps(props?: Props): Record<string, Signal$1<unknown>>;
|
|
2225
2270
|
get firstChild(): Node | null;
|
|
2226
2271
|
get isConnected(): boolean;
|
|
2227
2272
|
mount(parent: Node, before?: Node | null): Node[];
|
|
2228
2273
|
unmount(): void;
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2274
|
+
protected callMountHooks(): void;
|
|
2275
|
+
protected callDestroyHooks(): void;
|
|
2276
|
+
protected clearEmitter(): void;
|
|
2232
2277
|
inheritNode(node: ComponentNode$1): void;
|
|
2233
|
-
|
|
2278
|
+
protected getNodeTrack(trackKey: string): NodeTrack;
|
|
2234
2279
|
patchProps(props: Record<string, any> | undefined): void;
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2280
|
+
protected patchEventListener(key: string, prop: any): void;
|
|
2281
|
+
protected patchRef(prop: {
|
|
2282
|
+
value: Node | null;
|
|
2283
|
+
}): void;
|
|
2284
|
+
protected patchUpdateHandler(key: string, prop: any): void;
|
|
2285
|
+
protected patchNormalProp(key: string, prop: any): void;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
declare class FragmentNode extends TemplateNode$1 {
|
|
2289
|
+
unmount(): void;
|
|
2239
2290
|
}
|
|
2240
2291
|
|
|
2241
2292
|
/**
|
|
@@ -2270,15 +2321,13 @@ declare function isJsxElement(node: unknown): node is EssorNode;
|
|
|
2270
2321
|
* @returns A new HTML template element.
|
|
2271
2322
|
*/
|
|
2272
2323
|
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: {
|
|
2324
|
+
declare function Fragment<T extends JSX.JSXElement | string | number | boolean | (JSX.JSXElement | string | number | boolean)[]>(template: any, props: {
|
|
2280
2325
|
children: T;
|
|
2281
|
-
}
|
|
2326
|
+
} | {
|
|
2327
|
+
[key in string]: {
|
|
2328
|
+
children: T;
|
|
2329
|
+
};
|
|
2330
|
+
}): FragmentNode;
|
|
2282
2331
|
|
|
2283
2332
|
/**
|
|
2284
2333
|
* Registers a hook to be called when the component is mounted.
|
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,70 @@ 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 | undefined;
|
|
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 | undefined, 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
2262
|
props?: Props | undefined;
|
|
2218
2263
|
key?: string | undefined;
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
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>;
|
|
2223
2268
|
constructor(template: EssorComponent, props?: Props | undefined, key?: string | undefined);
|
|
2224
|
-
|
|
2269
|
+
protected createProxyProps(props?: Props): Record<string, Signal$1<unknown>>;
|
|
2225
2270
|
get firstChild(): Node | null;
|
|
2226
2271
|
get isConnected(): boolean;
|
|
2227
2272
|
mount(parent: Node, before?: Node | null): Node[];
|
|
2228
2273
|
unmount(): void;
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2274
|
+
protected callMountHooks(): void;
|
|
2275
|
+
protected callDestroyHooks(): void;
|
|
2276
|
+
protected clearEmitter(): void;
|
|
2232
2277
|
inheritNode(node: ComponentNode$1): void;
|
|
2233
|
-
|
|
2278
|
+
protected getNodeTrack(trackKey: string): NodeTrack;
|
|
2234
2279
|
patchProps(props: Record<string, any> | undefined): void;
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2280
|
+
protected patchEventListener(key: string, prop: any): void;
|
|
2281
|
+
protected patchRef(prop: {
|
|
2282
|
+
value: Node | null;
|
|
2283
|
+
}): void;
|
|
2284
|
+
protected patchUpdateHandler(key: string, prop: any): void;
|
|
2285
|
+
protected patchNormalProp(key: string, prop: any): void;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
declare class FragmentNode extends TemplateNode$1 {
|
|
2289
|
+
unmount(): void;
|
|
2239
2290
|
}
|
|
2240
2291
|
|
|
2241
2292
|
/**
|
|
@@ -2270,15 +2321,13 @@ declare function isJsxElement(node: unknown): node is EssorNode;
|
|
|
2270
2321
|
* @returns A new HTML template element.
|
|
2271
2322
|
*/
|
|
2272
2323
|
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: {
|
|
2324
|
+
declare function Fragment<T extends JSX.JSXElement | string | number | boolean | (JSX.JSXElement | string | number | boolean)[]>(template: any, props: {
|
|
2280
2325
|
children: T;
|
|
2281
|
-
}
|
|
2326
|
+
} | {
|
|
2327
|
+
[key in string]: {
|
|
2328
|
+
children: T;
|
|
2329
|
+
};
|
|
2330
|
+
}): FragmentNode;
|
|
2282
2331
|
|
|
2283
2332
|
/**
|
|
2284
2333
|
* Registers a hook to be called when the component is mounted.
|