@lwc/ssr-compiler 0.0.1 → 6.6.1
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/LICENSE.md +88 -0
- package/dist/compile-js/catalog-tmpls.d.ts +8 -0
- package/dist/compile-js/generate-markup.d.ts +15 -0
- package/dist/compile-js/index.d.ts +3 -0
- package/dist/compile-js/lwc-import.d.ts +10 -0
- package/dist/compile-js/stylesheets.d.ts +9 -0
- package/dist/compile-js/types.d.ts +18 -0
- package/dist/compile-template/comment.d.ts +3 -0
- package/dist/compile-template/component.d.ts +3 -0
- package/dist/compile-template/context.d.ts +6 -0
- package/dist/compile-template/element.d.ts +3 -0
- package/dist/compile-template/expression.d.ts +4 -0
- package/dist/compile-template/for-each.d.ts +3 -0
- package/dist/compile-template/if.d.ts +4 -0
- package/dist/compile-template/index.d.ts +3 -0
- package/dist/compile-template/ir-to-es.d.ts +9 -0
- package/dist/compile-template/shared.d.ts +6 -0
- package/dist/compile-template/text.d.ts +3 -0
- package/dist/compile-template/types.d.ts +16 -0
- package/dist/estemplate.d.ts +8 -0
- package/dist/estree/builders.d.ts +2 -0
- package/dist/estree/validators.d.ts +5 -0
- package/dist/index.cjs.js +1199 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1194 -0
- package/dist/index.js.map +1 -0
- package/dist/optimizer.d.ts +2 -0
- package/dist/shared.d.ts +31 -0
- package/package.json +59 -7
- package/README.md +0 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# LWC core license
|
|
2
|
+
|
|
3
|
+
MIT LICENSE
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2024, Salesforce, Inc.
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
13
|
+
|
|
14
|
+
# Licenses of bundled dependencies
|
|
15
|
+
|
|
16
|
+
## @parse5/tools
|
|
17
|
+
|
|
18
|
+
MIT license defined in package.json in v0.4.0.
|
|
19
|
+
|
|
20
|
+
## entities
|
|
21
|
+
|
|
22
|
+
Copyright (c) Felix Böhm
|
|
23
|
+
All rights reserved.
|
|
24
|
+
|
|
25
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
26
|
+
|
|
27
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
28
|
+
|
|
29
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
30
|
+
|
|
31
|
+
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
|
32
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
|
|
34
|
+
## estree-walker
|
|
35
|
+
|
|
36
|
+
Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/contributors)
|
|
37
|
+
|
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
39
|
+
|
|
40
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
43
|
+
|
|
44
|
+
## observable-membrane
|
|
45
|
+
|
|
46
|
+
MIT License
|
|
47
|
+
|
|
48
|
+
Copyright (c) 2017 Salesforce
|
|
49
|
+
|
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
51
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
52
|
+
in the Software without restriction, including without limitation the rights
|
|
53
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
54
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
55
|
+
furnished to do so, subject to the following conditions:
|
|
56
|
+
|
|
57
|
+
The above copyright notice and this permission notice shall be included in all
|
|
58
|
+
copies or substantial portions of the Software.
|
|
59
|
+
|
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
61
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
62
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
63
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
64
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
65
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
66
|
+
SOFTWARE.
|
|
67
|
+
|
|
68
|
+
## parse5
|
|
69
|
+
|
|
70
|
+
Copyright (c) 2013-2019 Ivan Nikulin (ifaaan@gmail.com, https://github.com/inikulin)
|
|
71
|
+
|
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
73
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
74
|
+
in the Software without restriction, including without limitation the rights
|
|
75
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
77
|
+
furnished to do so, subject to the following conditions:
|
|
78
|
+
|
|
79
|
+
The above copyright notice and this permission notice shall be included in
|
|
80
|
+
all copies or substantial portions of the Software.
|
|
81
|
+
|
|
82
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
83
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
84
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
85
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
86
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
87
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
88
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NodePath } from 'estree-toolkit';
|
|
2
|
+
import type { ImportDeclaration } from 'estree';
|
|
3
|
+
import type { ComponentMetaState } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* While traversing the component JS, this takes note of any .html files that are
|
|
6
|
+
* explicitly imported..
|
|
7
|
+
*/
|
|
8
|
+
export declare function catalogTmplImport(path: NodePath<ImportDeclaration>, state: ComponentMetaState): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Program } from 'estree';
|
|
2
|
+
import type { ComponentMetaState } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* This builds a generator function `generateMarkup` and adds it to the component JS's
|
|
5
|
+
* compilation output. `generateMarkup` acts as the glue between component JS and its
|
|
6
|
+
* template(s), including:
|
|
7
|
+
*
|
|
8
|
+
* - managing reflection of attrs & props
|
|
9
|
+
* - instantiating the component instance
|
|
10
|
+
* - setting the internal state of that component instance
|
|
11
|
+
* - invoking component lifecycle methods
|
|
12
|
+
* - yielding the tag name & attributes
|
|
13
|
+
* - deferring to the template function for yielding child content
|
|
14
|
+
*/
|
|
15
|
+
export declare function addGenerateMarkupExport(program: Program, state: ComponentMetaState, filename: string): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ImportDeclaration } from 'estree';
|
|
2
|
+
import type { NodePath } from 'estree-toolkit';
|
|
3
|
+
import type { ComponentMetaState } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* This accomplishes two things:
|
|
6
|
+
*
|
|
7
|
+
* 1. it replaces "lwc" with "@lwc/ssr-runtime" in an import specifier
|
|
8
|
+
* 2. it makes note of the local var name associated with the `LightningElement` import
|
|
9
|
+
*/
|
|
10
|
+
export declare function replaceLwcImport(path: NodePath<ImportDeclaration>, state: ComponentMetaState): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodePath } from 'estree-toolkit';
|
|
2
|
+
import type { Program, ImportDeclaration } from 'estree';
|
|
3
|
+
import type { ComponentMetaState } from './types';
|
|
4
|
+
export declare function catalogStyleImport(path: NodePath<ImportDeclaration>, state: ComponentMetaState): void;
|
|
5
|
+
/**
|
|
6
|
+
* This adds implicit style imports to the compiled component artifact.
|
|
7
|
+
*/
|
|
8
|
+
export declare function addStylesheetImports(ast: Program, state: ComponentMetaState, filepath: string): void;
|
|
9
|
+
export declare function catalogStaticStylesheets(ids: string[], state: ComponentMetaState): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { traverse } from 'estree-toolkit';
|
|
2
|
+
import type { Node } from 'estree';
|
|
3
|
+
export type Visitors = Parameters<typeof traverse<Node, ComponentMetaState>>[1];
|
|
4
|
+
export interface ComponentMetaState {
|
|
5
|
+
isLWC: boolean;
|
|
6
|
+
hasConstructor: boolean;
|
|
7
|
+
hasConnectedCallback: boolean;
|
|
8
|
+
hasRenderMethod: boolean;
|
|
9
|
+
hadRenderedCallback: boolean;
|
|
10
|
+
hadDisconnectedCallback: boolean;
|
|
11
|
+
hadErrorCallback: boolean;
|
|
12
|
+
lightningElementIdentifier: string | null;
|
|
13
|
+
lwcClassName: string | null;
|
|
14
|
+
tmplExplicitImports: Map<string, string> | null;
|
|
15
|
+
cssExplicitImports: Map<string, string> | null;
|
|
16
|
+
staticStylesheetIds: Set<string> | null;
|
|
17
|
+
reflectedPropsInPlay: Set<string>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleDeclaration as EsModuleDeclaration, Statement as EsStatement } from 'estree';
|
|
2
|
+
import type { TemplateOpts, TransformerContext } from './types';
|
|
3
|
+
export declare function createNewContext(templateOptions: TemplateOpts): {
|
|
4
|
+
hoisted: Map<string, EsStatement | EsModuleDeclaration>;
|
|
5
|
+
cxt: TransformerContext;
|
|
6
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComplexExpression as IrComplexExpression, Expression as IrExpression } from '@lwc/template-compiler';
|
|
2
|
+
import type { Expression as EsExpression } from 'estree';
|
|
3
|
+
import type { TransformerContext } from './types';
|
|
4
|
+
export declare function expressionIrToEs(node: IrExpression | IrComplexExpression, cxt: TransformerContext): EsExpression;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChildNode as IrChildNode, Node as IrNode } from '@lwc/template-compiler';
|
|
2
|
+
import type { Statement as EsStatement } from 'estree';
|
|
3
|
+
import type { TemplateOpts, TransformerContext } from './types';
|
|
4
|
+
export declare function irChildrenToEs(children: IrChildNode[], cxt: TransformerContext): EsStatement[];
|
|
5
|
+
export declare function irToEs(node: IrNode, cxt: TransformerContext): EsStatement[];
|
|
6
|
+
export declare function templateIrToEsTree(node: IrNode, contextOpts: TemplateOpts): {
|
|
7
|
+
hoisted: IterableIterator<import("estree").ModuleDeclaration | EsStatement>;
|
|
8
|
+
statements: EsStatement[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ImportDeclaration as EsImportDeclaration, Statement as EsStatement } from 'estree';
|
|
2
|
+
export declare const bImportHtmlEscape: (...replacementNodes: (import("estree").Node | import("estree").Node[] | null)[]) => EsImportDeclaration;
|
|
3
|
+
export declare const importHtmlEscapeKey = "import:htmlEscape";
|
|
4
|
+
export declare function cleanStyleAttrVal(styleAttrVal: string): string;
|
|
5
|
+
export declare const isValidIdentifier: (str: string) => boolean;
|
|
6
|
+
export declare function optimizeAdjacentYieldStmts(statements: EsStatement[]): EsStatement[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Node as IrNode } from '@lwc/template-compiler';
|
|
2
|
+
import type { ModuleDeclaration as EsModuleDeclaration, Statement as EsStatement } from 'estree';
|
|
3
|
+
export type Transformer<T extends IrNode = IrNode> = (node: T, cxt: TransformerContext) => EsStatement[];
|
|
4
|
+
export interface TransformerContext {
|
|
5
|
+
hoist: (stmt: EsStatement | EsModuleDeclaration, dedupeKey: string) => void;
|
|
6
|
+
pushLocalVars: (vars: string[]) => void;
|
|
7
|
+
popLocalVars: () => void;
|
|
8
|
+
isLocalVar: (varName: string | null | undefined) => boolean;
|
|
9
|
+
getUniqueVar: () => string;
|
|
10
|
+
templateOptions: TemplateOpts;
|
|
11
|
+
prevSibling?: IrNode;
|
|
12
|
+
nextSibling?: IrNode;
|
|
13
|
+
}
|
|
14
|
+
export interface TemplateOpts {
|
|
15
|
+
preserveComments: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Node as EsNode } from 'estree';
|
|
2
|
+
export declare const placeholder = false;
|
|
3
|
+
type ReplacementNode = EsNode | EsNode[] | null;
|
|
4
|
+
type ReturnsBool = (node: EsNode | null) => boolean;
|
|
5
|
+
export type Validator = ReturnsBool | typeof placeholder;
|
|
6
|
+
export declare function esTemplate<RetType = EsNode, ArgTypes extends ReplacementNode[] = ReplacementNode[]>(javascriptSegments: TemplateStringsArray, ...validatorFns: Validator[]): (...replacementNodes: ArgTypes) => RetType;
|
|
7
|
+
export declare function esTemplateWithYield<RetType = EsNode, ArgTypes extends ReplacementNode[] = ReplacementNode[]>(javascriptSegments: TemplateStringsArray, ...validatorFns: Validator[]): (...replacementNodes: ArgTypes) => RetType;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Node } from 'estree';
|
|
2
|
+
import type { Validator } from '../estemplate';
|
|
3
|
+
export declare const isStringLiteral: (node: Node | null) => boolean;
|
|
4
|
+
export declare const isIdentOrRenderCall: (node: Node | null) => boolean;
|
|
5
|
+
export declare function isNullableOf(validator: Validator): (node: Node | null) => boolean;
|