@lwc/ssr-compiler 8.12.0 → 8.12.2

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.
@@ -0,0 +1,4 @@
1
+ import { type LWCErrorInfo } from '@lwc/errors';
2
+ type ExtractArguments<T extends string, Numbers extends number = never, Args extends string[] = []> = T extends `${string}{${infer N extends number}}${infer R}` ? N extends Numbers ? ExtractArguments<R, Numbers, Args> : ExtractArguments<R, N | Numbers, [string, ...Args]> : Args;
3
+ export declare function generateError<const T extends LWCErrorInfo>(error: T, ...args: ExtractArguments<T['message']>): Error;
4
+ export {};
@@ -1,4 +1,5 @@
1
+ import type { ComponentTransformOptions } from '../shared';
1
2
  import type { CompilationMode } from '@lwc/shared';
2
- export default function compileJS(src: string, filename: string, tagName: string, compilationMode: CompilationMode): {
3
+ export default function compileJS(src: string, filename: string, tagName: string, options: ComponentTransformOptions, compilationMode: CompilationMode): {
3
4
  code: string;
4
5
  };
@@ -1,4 +1,4 @@
1
- import type { ImportDeclaration } from 'estree';
1
+ import type { ImportDeclaration, ExportNamedDeclaration, ExportAllDeclaration } from 'estree';
2
2
  import type { NodePath } from 'estree-toolkit';
3
3
  import type { ComponentMetaState } from './types';
4
4
  /**
@@ -8,3 +8,11 @@ import type { ComponentMetaState } from './types';
8
8
  * 2. it makes note of the local var name associated with the `LightningElement` import
9
9
  */
10
10
  export declare function replaceLwcImport(path: NodePath<ImportDeclaration>, state: ComponentMetaState): void;
11
+ /**
12
+ * This handles lwc barrel exports by replacing "lwc" with "@lwc/ssr-runtime"
13
+ */
14
+ export declare function replaceNamedLwcExport(path: NodePath<ExportNamedDeclaration>): void;
15
+ /**
16
+ * This handles all lwc barrel exports by replacing "lwc" with "@lwc/ssr-runtime"
17
+ */
18
+ export declare function replaceAllLwcExport(path: NodePath<ExportAllDeclaration>): void;
@@ -1,3 +1,5 @@
1
+ import type { ImportManager } from '../imports';
2
+ import type { ComponentTransformOptions } from '../shared';
1
3
  import type { traverse } from 'estree-toolkit';
2
4
  import type { Identifier, MemberExpression, MethodDefinition, Node, ObjectExpression, PropertyDefinition } from 'estree';
3
5
  export type Visitors = Parameters<typeof traverse<Node, ComponentMetaState>>[1];
@@ -10,7 +12,6 @@ export interface ComponentMetaState {
10
12
  isLWC: boolean;
11
13
  hasConstructor: boolean;
12
14
  hasConnectedCallback: boolean;
13
- hasRenderMethod: boolean;
14
15
  hadRenderedCallback: boolean;
15
16
  hadDisconnectedCallback: boolean;
16
17
  hadErrorCallback: boolean;
@@ -22,4 +23,6 @@ export interface ComponentMetaState {
22
23
  publicFields: Array<string>;
23
24
  privateFields: Array<string>;
24
25
  wireAdapters: WireAdapter[];
26
+ experimentalDynamicComponent: ComponentTransformOptions['experimentalDynamicComponent'];
27
+ importManager: ImportManager;
25
28
  }
@@ -1,7 +1,7 @@
1
1
  import type { ChildNode as IrChildNode, Node as IrNode } from '@lwc/template-compiler';
2
2
  import type { Statement as EsStatement } from 'estree';
3
3
  import type { TemplateOpts, TransformerContext } from './types';
4
- export declare function irChildrenToEs(children: IrChildNode[], cxt: TransformerContext): EsStatement[];
4
+ export declare function irChildrenToEs(children: IrChildNode[], cxt: TransformerContext, cb?: (child: IrChildNode) => (() => void) | void): EsStatement[];
5
5
  export declare function irToEs<T extends IrNode>(node: T, cxt: TransformerContext): EsStatement[];
6
6
  export declare function templateIrToEsTree(node: IrNode, contextOpts: TemplateOpts): {
7
7
  addImport: (imports: string | string[] | Record<string, string | undefined>, source?: string | undefined) => void;
@@ -1,6 +1,7 @@
1
1
  import type { TransformerContext } from './types';
2
2
  import type { Attribute as IrAttribute, Node as IrNode, Property as IrProperty } from '@lwc/template-compiler';
3
3
  import type { Expression as EsExpression, ObjectExpression as EsObjectExpression, Statement as EsStatement } from 'estree';
4
+ import type { ComplexExpression as IrComplexExpression, Expression as IrExpression, Literal as IrLiteral } from '@lwc/template-compiler';
4
5
  export declare function optimizeAdjacentYieldStmts(statements: EsStatement[]): EsStatement[];
5
6
  export declare function bAttributeValue(node: IrNode, attrName: string): EsExpression;
6
7
  /**
@@ -14,3 +15,8 @@ export declare function bAttributeValue(node: IrNode, attrName: string): EsExpre
14
15
  export declare function getScopedExpression(expression: EsExpression, cxt: TransformerContext): EsExpression;
15
16
  export declare function normalizeClassAttributeValue(value: string): string;
16
17
  export declare function getChildAttrsOrProps(attrs: (IrAttribute | IrProperty)[], cxt: TransformerContext): EsObjectExpression;
18
+ /**
19
+ * Determine if the provided node is of type Literal
20
+ * @param node
21
+ */
22
+ export declare function isLiteral(node: IrLiteral | IrExpression | IrComplexExpression): node is IrLiteral;
@@ -0,0 +1,3 @@
1
+ import type { If as IrIf } from '@lwc/template-compiler';
2
+ import type { Transformer } from '../types';
3
+ export declare const LegacyIf: Transformer<IrIf>;
@@ -0,0 +1,3 @@
1
+ import type { ElseifBlock as IrElseifBlock, IfBlock as IrIfBlock } from '@lwc/template-compiler';
2
+ import type { Transformer } from '../types';
3
+ export declare const IfBlock: Transformer<IrIfBlock | IrElseifBlock>;
@@ -8,6 +8,7 @@ export interface TransformerContext {
8
8
  templateOptions: TemplateOpts;
9
9
  prevSibling?: IrNode;
10
10
  nextSibling?: IrNode;
11
+ isSlotted?: boolean;
11
12
  import: (imports: string | string[] | Record<string, string | undefined>, source?: string) => void;
12
13
  }
13
14
  export interface TemplateOpts {
@@ -1,23 +1,5 @@
1
- import type { CallExpression, Identifier, MemberExpression } from 'estree';
2
1
  import type { Checker } from 'estree-toolkit/dist/generated/is-type';
3
2
  import type { Node } from 'estree-toolkit/dist/helpers';
4
- /** Node representing an identifier named "render". */
5
- type RenderIdentifier = Identifier & {
6
- name: 'render';
7
- };
8
- /** Node representing a member expression `<something>.render`. */
9
- type RenderMemberExpression = MemberExpression & {
10
- property: RenderIdentifier;
11
- };
12
- /** Node representing a method call `<something>.render()`. */
13
- type RenderCall = CallExpression & {
14
- callee: RenderMemberExpression;
15
- };
16
- /** Returns `true` if the node is an identifier or `<something>.render()`. */
17
- export declare const isIdentOrRenderCall: {
18
- (node: Node | null | undefined): node is Identifier | RenderCall;
19
- __debugName: string;
20
- };
21
3
  /** A validator that returns `true` if the node is `null`. */
22
4
  type NullableChecker<T extends Node> = (node: Node | null | undefined) => node is T | null;
23
5
  /** Extends a validator to return `true` if the node is `null`. */
@@ -0,0 +1,8 @@
1
+ import type { ImportDeclaration } from 'estree';
2
+ export declare class ImportManager {
3
+ #private;
4
+ /** Add an import to a collection of imports, probably for adding to the AST later. */
5
+ add(imports: string | string[] | Record<string, string | undefined>, source?: string): void;
6
+ /** Get the collection of imports for adding to the AST, probably soon! */
7
+ getImportDeclarations(): ImportDeclaration[];
8
+ }