@estjs/template 0.0.13-beta.6 → 0.0.13

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.
@@ -2221,38 +2221,21 @@ declare class ComponentNode$1 extends LifecycleContext implements JSX.Element {
2221
2221
  private rootNode;
2222
2222
  private trackMap;
2223
2223
  constructor(template: EssorComponent, props?: Props | undefined, key?: string | undefined);
2224
+ private createProxyProps;
2224
2225
  get firstChild(): Node | null;
2225
2226
  get isConnected(): boolean;
2226
2227
  mount(parent: Node, before?: Node | null): Node[];
2227
2228
  unmount(): void;
2228
- /**
2229
- * Inherit props and state from another ComponentNode.
2230
- * It will:
2231
- * 1. Copy props from the node to this proxyProps.
2232
- * 2. Copy the rootNode, trackMap and hooks from the node.
2233
- * 3. Copy the props from the node to this.
2234
- * 4. Patch props from the props passed in the constructor.
2235
- * @param node The node to inherit from.
2236
- */
2229
+ private callMountHooks;
2230
+ private callDestroyHooks;
2231
+ private clearEmitter;
2237
2232
  inheritNode(node: ComponentNode$1): void;
2238
- /**
2239
- * Get a NodeTrack from the trackMap. If the track is not in the trackMap, create a new one.
2240
- * Then, call the cleanup function to remove any previously registered hooks.
2241
- * @param trackKey the key of the node track to get.
2242
- * @returns the NodeTrack, cleaned up and ready to use.
2243
- */
2244
2233
  private getNodeTrack;
2245
- /**
2246
- * Patch the props of this node.
2247
- * It will:
2248
- * 1. Iterate the props and patch it.
2249
- * 2. If the prop is a event handler, add a event listener to the first child of the node.
2250
- * 3. If the prop is a ref, set the first child of the node to the ref.
2251
- * 4. If the prop is a update handler, update the prop in the node's props.
2252
- * 5. If the prop is a normal prop, create a signal for it and then patch it.
2253
- * @param props The props to patch.
2254
- */
2255
2234
  patchProps(props: Record<string, any> | undefined): void;
2235
+ private patchEventListener;
2236
+ private patchRef;
2237
+ private patchUpdateHandler;
2238
+ private patchNormalProp;
2256
2239
  }
2257
2240
 
2258
2241
  /**
@@ -2287,7 +2270,13 @@ declare function isJsxElement(node: unknown): node is EssorNode;
2287
2270
  * @returns A new HTML template element.
2288
2271
  */
2289
2272
  declare function createTemplate(html: string): HTMLTemplateElement;
2290
- declare function Fragment<T extends JSX.JSXElement | (JSX.JSXElement | string | number | boolean)[]>(props: {
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: {
2291
2280
  children: T;
2292
2281
  }): JSX.Element;
2293
2282
 
@@ -2341,7 +2330,7 @@ declare function useInject<T, K = InjectionKey<T> | string | number>(key: K, def
2341
2330
  * @returns a reactive ref signal
2342
2331
  *
2343
2332
  * @example
2344
- * const inputRef = useRef(')
2333
+ * const inputRef = useRef<HTMLInputElement>()
2345
2334
  *
2346
2335
  * <input ref={inputRef} />
2347
2336
  *
@@ -2353,10 +2342,17 @@ declare class SSGNode extends LifecycleContext {
2353
2342
  private template;
2354
2343
  private props;
2355
2344
  key?: string | undefined;
2356
- templates: string;
2345
+ private templates;
2357
2346
  constructor(template: string[] | SSGNode | ((props: Props) => SSGNode), props?: Props, key?: string | undefined);
2347
+ private processTemplate;
2348
+ private processHtmlString;
2358
2349
  mount(): string;
2359
2350
  render(): string;
2351
+ private renderTemplate;
2352
+ private normalizeProps;
2353
+ private generateAttributes;
2354
+ private renderChildren;
2355
+ private renderChild;
2360
2356
  }
2361
2357
 
2362
2358
  /**
@@ -2368,7 +2364,7 @@ declare class SSGNode extends LifecycleContext {
2368
2364
  * @param props Optional props to pass to the component.
2369
2365
  * @returns The rendered HTML string.
2370
2366
  */
2371
- declare function renderToString(component: EssorComponent, props?: Record<string, unknown>): string;
2367
+ declare function renderToString(component: EssorComponent, props?: Props): string;
2372
2368
  /**
2373
2369
  * Hydrate a component in a container.
2374
2370
  *
@@ -2376,6 +2372,7 @@ declare function renderToString(component: EssorComponent, props?: Record<string
2376
2372
  *
2377
2373
  * @param component The component to hydrate.
2378
2374
  * @param container The container element to hydrate in. Can be a string selector or an Element.
2375
+ * @throws Error if the container is not found.
2379
2376
  */
2380
2377
  declare function hydrate(component: EssorComponent, container: string | Element): void;
2381
2378
  /**
@@ -2387,6 +2384,6 @@ declare function hydrate(component: EssorComponent, container: string | Element)
2387
2384
  * @param props Optional props to pass to the component.
2388
2385
  * @returns The SSGNode or JSX element.
2389
2386
  */
2390
- declare function ssg(component: any, props?: Props): SSGNode | JSX.Element;
2387
+ declare function ssg(component: EssorComponent, props?: Props): SSGNode | JSX.Element;
2391
2388
 
2392
2389
  export { Fragment, type InjectionKey, h, hydrate, isComponent, isJsxElement, onDestroy, onMount, renderToString, ssg, createTemplate as template, useInject, useProvide, useRef };