@lwc/template-compiler 2.25.1 → 2.26.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/dist/commonjs/codegen/formatters/function.js +73 -0
- package/dist/commonjs/codegen/formatters/function.js.map +1 -0
- package/dist/commonjs/codegen/scope.js +61 -0
- package/dist/commonjs/codegen/scope.js.map +1 -0
- package/dist/commonjs/parser/tag.js +15 -0
- package/dist/commonjs/parser/tag.js.map +1 -0
- package/dist/commonjs/shared/ir.js +80 -0
- package/dist/commonjs/shared/ir.js.map +1 -0
- package/dist/types/codegen/formatters/function.d.ts +22 -0
- package/dist/types/codegen/scope.d.ts +8 -0
- package/dist/types/parser/tag.d.ts +2 -0
- package/dist/types/shared/ir.d.ts +11 -0
- package/package.json +4 -4
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.format = void 0;
|
|
29
|
+
const t = __importStar(require("../../shared/estree"));
|
|
30
|
+
const constants_1 = require("../../shared/constants");
|
|
31
|
+
const helpers_1 = require("../helpers");
|
|
32
|
+
const optimize_1 = require("../optimize");
|
|
33
|
+
/**
|
|
34
|
+
* Generate a function body AST from a template ESTree AST. This function can then be instantiated
|
|
35
|
+
* via `new Function(code, modules)` The generated function retrieves receives the dependent LWC
|
|
36
|
+
* components as arguments and returns the template function.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```js
|
|
40
|
+
* const {
|
|
41
|
+
* // Components names
|
|
42
|
+
* } = modules;
|
|
43
|
+
*
|
|
44
|
+
* function tmpl() {
|
|
45
|
+
* // Template generated code
|
|
46
|
+
* }
|
|
47
|
+
* // Template metadata
|
|
48
|
+
*
|
|
49
|
+
* return tmpl;
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
function format(templateFn, codeGen) {
|
|
53
|
+
const lookups = Array.from(codeGen.referencedComponents)
|
|
54
|
+
.sort()
|
|
55
|
+
.map((name) => {
|
|
56
|
+
const localIdentifier = (0, helpers_1.identifierFromComponentName)(name);
|
|
57
|
+
return t.variableDeclaration('const', [
|
|
58
|
+
t.variableDeclarator(localIdentifier, t.memberExpression(t.identifier(constants_1.TEMPLATE_MODULES_PARAMETER), t.literal(name), {
|
|
59
|
+
computed: true,
|
|
60
|
+
})),
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
const optimizedTemplateDeclarations = (0, optimize_1.optimizeStaticExpressions)(templateFn);
|
|
64
|
+
const metadata = (0, helpers_1.generateTemplateMetadata)(codeGen);
|
|
65
|
+
return t.program([
|
|
66
|
+
...lookups,
|
|
67
|
+
...optimizedTemplateDeclarations,
|
|
68
|
+
...metadata,
|
|
69
|
+
t.returnStatement(t.identifier(constants_1.TEMPLATE_FUNCTION_NAME)),
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
exports.format = format;
|
|
73
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../src/codegen/formatters/function.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;AAEH,uDAAyC;AACzC,sDAA4F;AAG5F,wCAAmF;AACnF,0CAAwD;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,MAAM,CAAC,UAAiC,EAAE,OAAgB;IACtE,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;SACnD,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACV,MAAM,eAAe,GAAG,IAAA,qCAA2B,EAAC,IAAI,CAAC,CAAC;QAE1D,OAAO,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE;YAClC,CAAC,CAAC,kBAAkB,CAChB,eAAe,EACf,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,sCAA0B,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAC1E,QAAQ,EAAE,IAAI;aACjB,CAAC,CACL;SACJ,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEP,MAAM,6BAA6B,GAAG,IAAA,oCAAyB,EAAC,UAAU,CAAC,CAAC;IAE5E,MAAM,QAAQ,GAAG,IAAA,kCAAwB,EAAC,OAAO,CAAC,CAAC;IAEnD,OAAO,CAAC,CAAC,OAAO,CAAC;QACb,GAAG,OAAO;QACV,GAAG,6BAA6B;QAChC,GAAG,QAAQ;QACX,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,kCAAsB,CAAC,CAAC;KAC1D,CAAC,CAAC;AACP,CAAC;AA1BD,wBA0BC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.bindExpression = void 0;
|
|
23
|
+
/*
|
|
24
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
25
|
+
* All rights reserved.
|
|
26
|
+
* SPDX-License-Identifier: MIT
|
|
27
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
28
|
+
*/
|
|
29
|
+
const estree_walker_1 = require("estree-walker");
|
|
30
|
+
const t = __importStar(require("../shared/estree"));
|
|
31
|
+
const constants_1 = require("../shared/constants");
|
|
32
|
+
const ir_1 = require("../shared/ir");
|
|
33
|
+
/**
|
|
34
|
+
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
35
|
+
* - {value} --> {$cmp.value}
|
|
36
|
+
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
37
|
+
*/
|
|
38
|
+
function bindExpression(expression, irNode) {
|
|
39
|
+
if (t.isIdentifier(expression)) {
|
|
40
|
+
if (ir_1.isComponentProp(expression, irNode)) {
|
|
41
|
+
return t.memberExpression(t.identifier(constants_1.TEMPLATE_PARAMS.INSTANCE), expression);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return expression;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
estree_walker_1.walk(expression, {
|
|
48
|
+
leave(node, parent) {
|
|
49
|
+
if (parent !== null &&
|
|
50
|
+
t.isIdentifier(node) &&
|
|
51
|
+
t.isMemberExpression(parent) &&
|
|
52
|
+
parent.object === node &&
|
|
53
|
+
ir_1.isComponentProp(node, irNode)) {
|
|
54
|
+
this.replace(t.memberExpression(t.identifier(constants_1.TEMPLATE_PARAMS.INSTANCE), node));
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
return expression;
|
|
59
|
+
}
|
|
60
|
+
exports.bindExpression = bindExpression;
|
|
61
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/codegen/scope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,iDAAqC;AAErC,oDAAsC;AACtC,mDAAsD;AACtD,qCAA+C;AAG/C;;;;GAIG;AACH,SAAgB,cAAc,CAAC,UAA8B,EAAE,MAAc;IACzE,IAAI,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;QAC5B,IAAI,oBAAe,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE;YACrC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,2BAAe,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;SACjF;aAAM;YACH,OAAO,UAAU,CAAC;SACrB;KACJ;IAED,oBAAI,CAAC,UAAU,EAAE;QACb,KAAK,CAAC,IAAI,EAAE,MAAM;YACd,IACI,MAAM,KAAK,IAAI;gBACf,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;gBACpB,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;gBAC5B,MAAM,CAAC,MAAM,KAAK,IAAI;gBACtB,oBAAe,CAAC,IAAI,EAAE,MAAM,CAAC,EAC/B;gBACE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,2BAAe,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;aAClF;QACL,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACtB,CAAC;AAxBD,wCAwBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isUnsafeTopLevelSerializableElement = void 0;
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
function isUnsafeTopLevelSerializableElement(element) {
|
|
12
|
+
return constants_1.TAGS_THAT_CANNOT_BE_PARSED_AS_TOP_LEVEL.has(element.name);
|
|
13
|
+
}
|
|
14
|
+
exports.isUnsafeTopLevelSerializableElement = isUnsafeTopLevelSerializableElement;
|
|
15
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../../src/parser/tag.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2CAAsE;AAEtE,SAAgB,mCAAmC,CAAC,OAAoB;IACpE,OAAO,mDAAuC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACrE,CAAC;AAFD,kFAEC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isComponentProp = exports.isSlot = exports.isTemplate = exports.isCustomElement = exports.isCommentNode = exports.isTextNode = exports.isElement = exports.createComment = exports.createText = exports.createElement = void 0;
|
|
4
|
+
function createElement(original, parent) {
|
|
5
|
+
return {
|
|
6
|
+
type: 'element',
|
|
7
|
+
tag: original.tagName,
|
|
8
|
+
namespace: original.namespaceURI,
|
|
9
|
+
attrsList: original.attrs,
|
|
10
|
+
parent,
|
|
11
|
+
children: [],
|
|
12
|
+
__original: original,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.createElement = createElement;
|
|
16
|
+
function createText(original, parent, value) {
|
|
17
|
+
return {
|
|
18
|
+
type: 'text',
|
|
19
|
+
parent,
|
|
20
|
+
value,
|
|
21
|
+
__original: original,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.createText = createText;
|
|
25
|
+
function createComment(original, parent, value) {
|
|
26
|
+
return {
|
|
27
|
+
type: 'comment',
|
|
28
|
+
parent,
|
|
29
|
+
value,
|
|
30
|
+
__original: original,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.createComment = createComment;
|
|
34
|
+
function isElement(node) {
|
|
35
|
+
return node.type === 'element';
|
|
36
|
+
}
|
|
37
|
+
exports.isElement = isElement;
|
|
38
|
+
function isTextNode(node) {
|
|
39
|
+
return node.type === 'text';
|
|
40
|
+
}
|
|
41
|
+
exports.isTextNode = isTextNode;
|
|
42
|
+
function isCommentNode(node) {
|
|
43
|
+
return node.type === 'comment';
|
|
44
|
+
}
|
|
45
|
+
exports.isCommentNode = isCommentNode;
|
|
46
|
+
function isCustomElement(node) {
|
|
47
|
+
return isElement(node) && node.component !== undefined;
|
|
48
|
+
}
|
|
49
|
+
exports.isCustomElement = isCustomElement;
|
|
50
|
+
function isTemplate(element) {
|
|
51
|
+
return element.tag === 'template';
|
|
52
|
+
}
|
|
53
|
+
exports.isTemplate = isTemplate;
|
|
54
|
+
function isSlot(element) {
|
|
55
|
+
return element.tag === 'slot';
|
|
56
|
+
}
|
|
57
|
+
exports.isSlot = isSlot;
|
|
58
|
+
function isComponentProp(identifier, root) {
|
|
59
|
+
var _a;
|
|
60
|
+
const { name } = identifier;
|
|
61
|
+
let current = root;
|
|
62
|
+
// Walking up the AST and checking for each node to find if the identifer name is identical to
|
|
63
|
+
// an iteration variable.
|
|
64
|
+
while (current !== undefined) {
|
|
65
|
+
if (isElement(current)) {
|
|
66
|
+
const { forEach, forOf } = current;
|
|
67
|
+
if ((forEach === null || forEach === void 0 ? void 0 : forEach.item.name) === name ||
|
|
68
|
+
((_a = forEach === null || forEach === void 0 ? void 0 : forEach.index) === null || _a === void 0 ? void 0 : _a.name) === name ||
|
|
69
|
+
(forOf === null || forOf === void 0 ? void 0 : forOf.iterator.name) === name) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
current = current.parent;
|
|
74
|
+
}
|
|
75
|
+
// The identifier is bound to a component property if no match is found after reaching to AST
|
|
76
|
+
// root.
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
exports.isComponentProp = isComponentProp;
|
|
80
|
+
//# sourceMappingURL=ir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.js","sourceRoot":"","sources":["../../../src/shared/ir.ts"],"names":[],"mappings":";;;AAkBA,SAAgB,aAAa,CAAC,QAAqB,EAAE,MAAkB;IACnE,OAAO;QACH,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,QAAQ,CAAC,OAAO;QACrB,SAAS,EAAE,QAAQ,CAAC,YAAY;QAChC,SAAS,EAAE,QAAQ,CAAC,KAAK;QACzB,MAAM;QACN,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ;KACvB,CAAC;AACN,CAAC;AAVD,sCAUC;AAED,SAAgB,UAAU,CACtB,QAAkB,EAClB,MAAiB,EACjB,KAAkC;IAElC,OAAO;QACH,IAAI,EAAE,MAAM;QACZ,MAAM;QACN,KAAK;QACL,UAAU,EAAE,QAAQ;KACvB,CAAC;AACN,CAAC;AAXD,gCAWC;AAED,SAAgB,aAAa,CAAC,QAAqB,EAAE,MAAiB,EAAE,KAAa;IACjF,OAAO;QACH,IAAI,EAAE,SAAS;QACf,MAAM;QACN,KAAK;QACL,UAAU,EAAE,QAAQ;KACvB,CAAC;AACN,CAAC;AAPD,sCAOC;AAED,SAAgB,SAAS,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC;AAFD,8BAEC;AAED,SAAgB,UAAU,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAChC,CAAC;AAFD,gCAEC;AAED,SAAgB,aAAa,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAC,IAAY;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC;AAC3D,CAAC;AAFD,0CAEC;AAED,SAAgB,UAAU,CAAC,OAAkB;IACzC,OAAO,OAAO,CAAC,GAAG,KAAK,UAAU,CAAC;AACtC,CAAC;AAFD,gCAEC;AAED,SAAgB,MAAM,CAAC,OAAkB;IACrC,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM,CAAC;AAClC,CAAC;AAFD,wBAEC;AAED,SAAgB,eAAe,CAAC,UAA8B,EAAE,IAAY;;IACxE,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;IAC5B,IAAI,OAAO,GAAuB,IAAI,CAAC;IAEvC,8FAA8F;IAC9F,yBAAyB;IACzB,OAAO,OAAO,KAAK,SAAS,EAAE;QAC1B,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE;YACpB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;YAEnC,IACI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,IAAI,MAAK,IAAI;gBAC3B,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,IAAI,MAAK,IAAI;gBAC7B,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,IAAI,MAAK,IAAI,EAC/B;gBACE,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;KAC5B;IAED,6FAA6F;IAC7F,QAAQ;IACR,OAAO,IAAI,CAAC;AAChB,CAAC;AAzBD,0CAyBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as t from '../../shared/estree';
|
|
2
|
+
import CodeGen from '../codegen';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a function body AST from a template ESTree AST. This function can then be instantiated
|
|
5
|
+
* via `new Function(code, modules)` The generated function retrieves receives the dependent LWC
|
|
6
|
+
* components as arguments and returns the template function.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* const {
|
|
11
|
+
* // Components names
|
|
12
|
+
* } = modules;
|
|
13
|
+
*
|
|
14
|
+
* function tmpl() {
|
|
15
|
+
* // Template generated code
|
|
16
|
+
* }
|
|
17
|
+
* // Template metadata
|
|
18
|
+
*
|
|
19
|
+
* return tmpl;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function format(templateFn: t.FunctionDeclaration, codeGen: CodeGen): t.Program;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as t from '../shared/estree';
|
|
2
|
+
import { IRNode, TemplateExpression } from '../shared/types';
|
|
3
|
+
/**
|
|
4
|
+
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
5
|
+
* - {value} --> {$cmp.value}
|
|
6
|
+
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
7
|
+
*/
|
|
8
|
+
export declare function bindExpression(expression: TemplateExpression, irNode: IRNode): t.Expression;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TemplateIdentifier, TemplateExpression, IRNode, IRText, IRElement, HTMLElement, HTMLText, HTMLComment, IRComment } from './types';
|
|
2
|
+
export declare function createElement(original: HTMLElement, parent?: IRElement): IRElement;
|
|
3
|
+
export declare function createText(original: HTMLText, parent: IRElement, value: string | TemplateExpression): IRText;
|
|
4
|
+
export declare function createComment(original: HTMLComment, parent: IRElement, value: string): IRComment;
|
|
5
|
+
export declare function isElement(node: IRNode): node is IRElement;
|
|
6
|
+
export declare function isTextNode(node: IRNode): node is IRText;
|
|
7
|
+
export declare function isCommentNode(node: IRNode): node is IRComment;
|
|
8
|
+
export declare function isCustomElement(node: IRNode): boolean;
|
|
9
|
+
export declare function isTemplate(element: IRElement): boolean;
|
|
10
|
+
export declare function isSlot(element: IRElement): boolean;
|
|
11
|
+
export declare function isComponentProp(identifier: TemplateIdentifier, root: IRNode): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/template-compiler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.1",
|
|
4
4
|
"description": "Template compiler package",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"//": "Currently can't upgrade: estree-walker to v3.0.0 because it dropped CommonJS support: https://git.io/JXguS, parse5 dropped cjs support in v7.0.0 https://github.com/inikulin/parse5/releases/tag/v7.0.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lwc/errors": "2.
|
|
29
|
-
"@lwc/shared": "2.
|
|
28
|
+
"@lwc/errors": "2.26.1",
|
|
29
|
+
"@lwc/shared": "2.26.1",
|
|
30
30
|
"acorn": "~8.8.0",
|
|
31
31
|
"astring": "~1.8.3",
|
|
32
32
|
"estree-walker": "~2.0.2",
|
|
@@ -48,4 +48,4 @@
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|