@lwc/template-compiler 6.5.0 → 6.5.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.
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.
package/dist/index.cjs.js CHANGED
@@ -8,7 +8,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
8
8
  var errors = require('@lwc/errors');
9
9
  var shared = require('@lwc/shared');
10
10
  var he = require('he');
11
- var estreeWalker = require('estree-walker');
12
11
  var acorn = require('acorn');
13
12
  var astring = require('astring');
14
13
 
@@ -10486,6 +10485,238 @@ const errorCodesToWarnOnInOlderAPIVersions = new Set([
10486
10485
  'eof-in-element-that-can-contain-only-text',
10487
10486
  ]);
10488
10487
 
10488
+ /**
10489
+ * @typedef { import('estree').Node} Node
10490
+ * @typedef {{
10491
+ * skip: () => void;
10492
+ * remove: () => void;
10493
+ * replace: (node: Node) => void;
10494
+ * }} WalkerContext
10495
+ */
10496
+
10497
+ class WalkerBase {
10498
+ constructor() {
10499
+ /** @type {boolean} */
10500
+ this.should_skip = false;
10501
+
10502
+ /** @type {boolean} */
10503
+ this.should_remove = false;
10504
+
10505
+ /** @type {Node | null} */
10506
+ this.replacement = null;
10507
+
10508
+ /** @type {WalkerContext} */
10509
+ this.context = {
10510
+ skip: () => (this.should_skip = true),
10511
+ remove: () => (this.should_remove = true),
10512
+ replace: (node) => (this.replacement = node)
10513
+ };
10514
+ }
10515
+
10516
+ /**
10517
+ * @template {Node} Parent
10518
+ * @param {Parent | null | undefined} parent
10519
+ * @param {keyof Parent | null | undefined} prop
10520
+ * @param {number | null | undefined} index
10521
+ * @param {Node} node
10522
+ */
10523
+ replace(parent, prop, index, node) {
10524
+ if (parent && prop) {
10525
+ if (index != null) {
10526
+ /** @type {Array<Node>} */ (parent[prop])[index] = node;
10527
+ } else {
10528
+ /** @type {Node} */ (parent[prop]) = node;
10529
+ }
10530
+ }
10531
+ }
10532
+
10533
+ /**
10534
+ * @template {Node} Parent
10535
+ * @param {Parent | null | undefined} parent
10536
+ * @param {keyof Parent | null | undefined} prop
10537
+ * @param {number | null | undefined} index
10538
+ */
10539
+ remove(parent, prop, index) {
10540
+ if (parent && prop) {
10541
+ if (index !== null && index !== undefined) {
10542
+ /** @type {Array<Node>} */ (parent[prop]).splice(index, 1);
10543
+ } else {
10544
+ delete parent[prop];
10545
+ }
10546
+ }
10547
+ }
10548
+ }
10549
+
10550
+ /**
10551
+ * @typedef { import('estree').Node} Node
10552
+ * @typedef { import('./walker.js').WalkerContext} WalkerContext
10553
+ * @typedef {(
10554
+ * this: WalkerContext,
10555
+ * node: Node,
10556
+ * parent: Node | null,
10557
+ * key: string | number | symbol | null | undefined,
10558
+ * index: number | null | undefined
10559
+ * ) => void} SyncHandler
10560
+ */
10561
+
10562
+ class SyncWalker extends WalkerBase {
10563
+ /**
10564
+ *
10565
+ * @param {SyncHandler} [enter]
10566
+ * @param {SyncHandler} [leave]
10567
+ */
10568
+ constructor(enter, leave) {
10569
+ super();
10570
+
10571
+ /** @type {boolean} */
10572
+ this.should_skip = false;
10573
+
10574
+ /** @type {boolean} */
10575
+ this.should_remove = false;
10576
+
10577
+ /** @type {Node | null} */
10578
+ this.replacement = null;
10579
+
10580
+ /** @type {WalkerContext} */
10581
+ this.context = {
10582
+ skip: () => (this.should_skip = true),
10583
+ remove: () => (this.should_remove = true),
10584
+ replace: (node) => (this.replacement = node)
10585
+ };
10586
+
10587
+ /** @type {SyncHandler | undefined} */
10588
+ this.enter = enter;
10589
+
10590
+ /** @type {SyncHandler | undefined} */
10591
+ this.leave = leave;
10592
+ }
10593
+
10594
+ /**
10595
+ * @template {Node} Parent
10596
+ * @param {Node} node
10597
+ * @param {Parent | null} parent
10598
+ * @param {keyof Parent} [prop]
10599
+ * @param {number | null} [index]
10600
+ * @returns {Node | null}
10601
+ */
10602
+ visit(node, parent, prop, index) {
10603
+ if (node) {
10604
+ if (this.enter) {
10605
+ const _should_skip = this.should_skip;
10606
+ const _should_remove = this.should_remove;
10607
+ const _replacement = this.replacement;
10608
+ this.should_skip = false;
10609
+ this.should_remove = false;
10610
+ this.replacement = null;
10611
+
10612
+ this.enter.call(this.context, node, parent, prop, index);
10613
+
10614
+ if (this.replacement) {
10615
+ node = this.replacement;
10616
+ this.replace(parent, prop, index, node);
10617
+ }
10618
+
10619
+ if (this.should_remove) {
10620
+ this.remove(parent, prop, index);
10621
+ }
10622
+
10623
+ const skipped = this.should_skip;
10624
+ const removed = this.should_remove;
10625
+
10626
+ this.should_skip = _should_skip;
10627
+ this.should_remove = _should_remove;
10628
+ this.replacement = _replacement;
10629
+
10630
+ if (skipped) return node;
10631
+ if (removed) return null;
10632
+ }
10633
+
10634
+ /** @type {keyof Node} */
10635
+ let key;
10636
+
10637
+ for (key in node) {
10638
+ /** @type {unknown} */
10639
+ const value = node[key];
10640
+
10641
+ if (value && typeof value === 'object') {
10642
+ if (Array.isArray(value)) {
10643
+ const nodes = /** @type {Array<unknown>} */ (value);
10644
+ for (let i = 0; i < nodes.length; i += 1) {
10645
+ const item = nodes[i];
10646
+ if (isNode(item)) {
10647
+ if (!this.visit(item, node, key, i)) {
10648
+ // removed
10649
+ i--;
10650
+ }
10651
+ }
10652
+ }
10653
+ } else if (isNode(value)) {
10654
+ this.visit(value, node, key, null);
10655
+ }
10656
+ }
10657
+ }
10658
+
10659
+ if (this.leave) {
10660
+ const _replacement = this.replacement;
10661
+ const _should_remove = this.should_remove;
10662
+ this.replacement = null;
10663
+ this.should_remove = false;
10664
+
10665
+ this.leave.call(this.context, node, parent, prop, index);
10666
+
10667
+ if (this.replacement) {
10668
+ node = this.replacement;
10669
+ this.replace(parent, prop, index, node);
10670
+ }
10671
+
10672
+ if (this.should_remove) {
10673
+ this.remove(parent, prop, index);
10674
+ }
10675
+
10676
+ const removed = this.should_remove;
10677
+
10678
+ this.replacement = _replacement;
10679
+ this.should_remove = _should_remove;
10680
+
10681
+ if (removed) return null;
10682
+ }
10683
+ }
10684
+
10685
+ return node;
10686
+ }
10687
+ }
10688
+
10689
+ /**
10690
+ * Ducktype a node.
10691
+ *
10692
+ * @param {unknown} value
10693
+ * @returns {value is Node}
10694
+ */
10695
+ function isNode(value) {
10696
+ return (
10697
+ value !== null && typeof value === 'object' && 'type' in value && typeof value.type === 'string'
10698
+ );
10699
+ }
10700
+
10701
+ /**
10702
+ * @typedef {import('estree').Node} Node
10703
+ * @typedef {import('./sync.js').SyncHandler} SyncHandler
10704
+ * @typedef {import('./async.js').AsyncHandler} AsyncHandler
10705
+ */
10706
+
10707
+ /**
10708
+ * @param {Node} ast
10709
+ * @param {{
10710
+ * enter?: SyncHandler
10711
+ * leave?: SyncHandler
10712
+ * }} walker
10713
+ * @returns {Node | null}
10714
+ */
10715
+ function walk(ast, { enter, leave }) {
10716
+ const instance = new SyncWalker(enter, leave);
10717
+ return instance.visit(ast, null);
10718
+ }
10719
+
10489
10720
  /*
10490
10721
  * Copyright (c) 2023, salesforce.com, inc.
10491
10722
  * All rights reserved.
@@ -10581,7 +10812,11 @@ function validateNode(node, _parent, isWithinArrowFn) {
10581
10812
  }
10582
10813
  function validateExpressionAst(rootNode) {
10583
10814
  let arrowFnScopeDepth = 0;
10584
- estreeWalker.walk(rootNode, {
10815
+ // TODO [#3370]: when the template expression flag is removed, the
10816
+ // ComplexExpression type should be redefined as an ESTree Node. Doing
10817
+ // so when the flag is still in place results in a cascade of required
10818
+ // type changes across the codebase.
10819
+ walk(rootNode, {
10585
10820
  enter(node, parent) {
10586
10821
  validateNode(node, parent, !!arrowFnScopeDepth);
10587
10822
  if (isArrowFunctionExpression(node)) {
@@ -12930,7 +13165,11 @@ function serializeStaticElement(element, codeGen) {
12930
13165
  */
12931
13166
  function bindComplexExpression(expression, codeGen) {
12932
13167
  const expressionScopes = new ExpressionScopes();
12933
- estreeWalker.walk(expression, {
13168
+ // TODO [#3370]: when the template expression flag is removed, the
13169
+ // ComplexExpression type should be redefined as an ESTree Node. Doing
13170
+ // so when the flag is still in place results in a cascade of required
13171
+ // type changes across the codebase.
13172
+ walk(expression, {
12934
13173
  enter(node, _parent) {
12935
13174
  // Function and class expressions are not permitted in template expressions,
12936
13175
  // only arrow function expressions.
@@ -13390,7 +13629,11 @@ class CodeGen {
13390
13629
  // Cloning here is necessary because `this.replace()` is destructive, and we might use the
13391
13630
  // node later during static content optimization
13392
13631
  expression = doStructuredClone(expression);
13393
- estreeWalker.walk(expression, {
13632
+ // TODO [#3370]: when the template expression flag is removed, the
13633
+ // ComplexExpression type should be redefined as an ESTree Node. Doing
13634
+ // so when the flag is still in place results in a cascade of required
13635
+ // type changes across the codebase.
13636
+ walk(expression, {
13394
13637
  leave(node, parent) {
13395
13638
  if (parent !== null &&
13396
13639
  isIdentifier(node) &&
@@ -13649,7 +13892,7 @@ function optimizeStaticExpressions(templateFn) {
13649
13892
  }
13650
13893
  return identifier(keysToVariableNames.get(key));
13651
13894
  }
13652
- estreeWalker.walk(templateFn, {
13895
+ walk(templateFn, {
13653
13896
  enter(node) {
13654
13897
  // For deeply-nested static object, we only want to extract the top-level node
13655
13898
  if (isStaticObjectOrArray(node)) {
@@ -14245,5 +14488,5 @@ function compile(source, config) {
14245
14488
  exports.compile = compile;
14246
14489
  exports.default = compile;
14247
14490
  exports.parse = parse;
14248
- /** version: 6.5.0 */
14491
+ /** version: 6.5.2 */
14249
14492
  //# sourceMappingURL=index.cjs.js.map