@lwc/template-compiler 2.10.0 → 2.11.3-238prod.0

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 ADDED
@@ -0,0 +1,10 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2018, Salesforce.com, Inc.
4
+ All rights reserved.
5
+
6
+ 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:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ 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.
@@ -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,41 @@
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.parseClassNames = exports.parseStyleText = void 0;
10
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
11
+ const PROPERTY_DELIMITER = /:(.+)/;
12
+ // Borrowed from Vue template compiler.
13
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
14
+ function parseStyleText(cssText) {
15
+ const styleMap = {};
16
+ const declarations = cssText.split(DECLARATION_DELIMITER);
17
+ for (const declaration of declarations) {
18
+ if (declaration) {
19
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
20
+ if (prop !== undefined && value !== undefined) {
21
+ styleMap[prop.trim()] = value.trim();
22
+ }
23
+ }
24
+ }
25
+ return styleMap;
26
+ }
27
+ exports.parseStyleText = parseStyleText;
28
+ const CLASSNAME_DELIMITER = /\s+/;
29
+ function parseClassNames(classNames) {
30
+ const classMap = {};
31
+ const classList = classNames.split(CLASSNAME_DELIMITER);
32
+ for (const className of classList) {
33
+ const normalizedClassName = className.trim();
34
+ if (normalizedClassName.length > 0) {
35
+ classMap[className] = true;
36
+ }
37
+ }
38
+ return classMap;
39
+ }
40
+ exports.parseClassNames = parseClassNames;
41
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/parser/style.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAUH,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAC9C,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,uCAAuC;AACvC,oHAAoH;AACpH,SAAgB,cAAc,CAAC,OAAe;IAC1C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC1D,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;QACpC,IAAI,WAAW,EAAE;YACb,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAE5D,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;gBAC3C,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;aACxC;SACJ;KACJ;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAfD,wCAeC;AAED,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAElC,SAAgB,eAAe,CAAC,UAAkB;IAC9C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACxD,KAAK,MAAM,SAAS,IAAI,SAAS,EAAE;QAC/B,MAAM,mBAAmB,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAE7C,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;SAC9B;KACJ;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAZD,0CAYC"}
@@ -0,0 +1,76 @@
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(tag, original) {
5
+ return {
6
+ type: 'element',
7
+ __original: original,
8
+ tag,
9
+ attrsList: [],
10
+ children: [],
11
+ };
12
+ }
13
+ exports.createElement = createElement;
14
+ function createText(original, value) {
15
+ return {
16
+ type: 'text',
17
+ __original: original,
18
+ value,
19
+ };
20
+ }
21
+ exports.createText = createText;
22
+ function createComment(original, value) {
23
+ return {
24
+ type: 'comment',
25
+ __original: original,
26
+ value,
27
+ };
28
+ }
29
+ exports.createComment = createComment;
30
+ function isElement(node) {
31
+ return node.type === 'element';
32
+ }
33
+ exports.isElement = isElement;
34
+ function isTextNode(node) {
35
+ return node.type === 'text';
36
+ }
37
+ exports.isTextNode = isTextNode;
38
+ function isCommentNode(node) {
39
+ return node.type === 'comment';
40
+ }
41
+ exports.isCommentNode = isCommentNode;
42
+ function isCustomElement(node) {
43
+ return isElement(node) && node.component !== undefined;
44
+ }
45
+ exports.isCustomElement = isCustomElement;
46
+ function isTemplate(element) {
47
+ return element.tag === 'template';
48
+ }
49
+ exports.isTemplate = isTemplate;
50
+ function isSlot(element) {
51
+ return element.tag === 'slot';
52
+ }
53
+ exports.isSlot = isSlot;
54
+ function isComponentProp(identifier, root) {
55
+ var _a;
56
+ const { name } = identifier;
57
+ let current = root;
58
+ // Walking up the AST and checking for each node to find if the identifer name is identical to
59
+ // an iteration variable.
60
+ while (current !== undefined) {
61
+ if (isElement(current)) {
62
+ const { forEach, forOf } = current;
63
+ if ((forEach === null || forEach === void 0 ? void 0 : forEach.item.name) === name ||
64
+ ((_a = forEach === null || forEach === void 0 ? void 0 : forEach.index) === null || _a === void 0 ? void 0 : _a.name) === name ||
65
+ (forOf === null || forOf === void 0 ? void 0 : forOf.iterator.name) === name) {
66
+ return false;
67
+ }
68
+ }
69
+ current = current.parent;
70
+ }
71
+ // The identifier is bound to a component property if no match is found after reaching to AST
72
+ // root.
73
+ return true;
74
+ }
75
+ exports.isComponentProp = isComponentProp;
76
+ //# 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,GAAW,EAAE,QAAqB;IAC5D,OAAO;QACH,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,QAAQ;QAEpB,GAAG;QACH,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,EAAE;KACf,CAAC;AACN,CAAC;AATD,sCASC;AAED,SAAgB,UAAU,CAAC,QAAkB,EAAE,KAAkC;IAC7E,OAAO;QACH,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,QAAQ;QACpB,KAAK;KACR,CAAC;AACN,CAAC;AAND,gCAMC;AAED,SAAgB,aAAa,CAAC,QAAqB,EAAE,KAAa;IAC9D,OAAO;QACH,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,QAAQ;QACpB,KAAK;KACR,CAAC;AACN,C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AC/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,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,8 @@
1
+ export interface StyleMap {
2
+ [name: string]: string;
3
+ }
4
+ export interface ClassMap {
5
+ [name: string]: true;
6
+ }
7
+ export declare function parseStyleText(cssText: string): StyleMap;
8
+ export declare function parseClassNames(classNames: string): ClassMap;
@@ -0,0 +1,11 @@
1
+ import { TemplateIdentifier, TemplateExpression, IRNode, IRText, IRElement, HTMLElement, HTMLText, HTMLComment, IRComment } from './types';
2
+ export declare function createElement(tag: string, original: HTMLElement): IRElement;
3
+ export declare function createText(original: HTMLText, value: string | TemplateExpression): IRText;
4
+ export declare function createComment(original: HTMLComment, 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.10.0",
3
+ "version": "2.11.3-238prod.0",
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",
27
27
  "dependencies": {
28
- "@lwc/errors": "2.10.0",
29
- "@lwc/shared": "2.10.0",
28
+ "@lwc/errors": "2.11.3-238prod.0",
29
+ "@lwc/shared": "2.11.3-238prod.0",
30
30
  "acorn": "~8.7.0",
31
31
  "astring": "~1.8.1",
32
32
  "estree-walker": "~2.0.2",
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "94040389ab8fc717b8753e503f659489480a327d"
42
+ "gitHead": "60b8fbcbc31063f87d206edf104f843455a5abd9"
43
43
  }