@lwrjs/everywhere 0.10.0-alpha.7 → 0.10.0-alpha.8

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.
Files changed (28) hide show
  1. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/02b9b4ac7ae3860b355955245154923a/config.js +10 -0
  2. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +4 -4
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{2_38_1/s/8cf6b94d9c0b398c70c97fdca2759caa → 2_45_2/s/97b809a5745ddedba3acd0433f339b58}/lwc.js +456 -435
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js +3 -3
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_10_0-alpha_7/s/d26177a61a766e129dee91ebcadb74d7 → 0_10_0-alpha_8/s/8199fbc1a33dffe14973c3ee0a3f6aa3}/lwr_init.js +14 -30
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_10_0-alpha_7/s/554e119a3f34b1362ff4ceb3a97b0d25 → 0_10_0-alpha_8/s/7c38605af6fc9549feac455828d00bdd}/lwr_loader.js +3 -3
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/s/3426e42c3e22ce07ab2adc62c4c523a0/lwr_metrics.js +1 -1
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/s/4e65d4b97b3cc3d2f06a4cc284f3dd68/lwr_profiler.js +1 -1
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
  10. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/lwr-error-shim.js +1 -1
  11. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_10_0-alpha_7 → 0_10_0-alpha_8}/lwr-loader-shim.bundle.js +6 -6
  12. package/build/assets/amd/lwr-everywhere-debug.js +8 -8
  13. package/build/assets/amd/lwr-everywhere-min.js +1 -1
  14. package/build/assets/amd/lwr-everywhere.js +8 -8
  15. package/build/assets/core/lwr-everywhere-debug.js +4 -4
  16. package/build/assets/core/lwr-everywhere.js +4 -4
  17. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  18. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  19. package/build/assets/esm/lwr-everywhere.js +1 -1
  20. package/build/modules/lwr/setupLDS/setupLDS.js +8 -5
  21. package/package.json +12 -12
  22. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/7b0c61d0b2d8909f14cb1696902a019c/config.js +0 -10
  23. package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.d.ts +0 -24
  24. package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.js +0 -60
  25. package/build/modules/lwr/setupNodeLDS/network.d.ts +0 -3
  26. package/build/modules/lwr/setupNodeLDS/network.js +0 -88
  27. package/build/modules/lwr/setupNodeLDS/setupNodeLDS.d.ts +0 -2
  28. package/build/modules/lwr/setupNodeLDS/setupNodeLDS.js +0 -14
@@ -1,4 +1,4 @@
1
- LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwc/v/2_45_2', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /* proxy-compat-disable */
4
4
  /**
@@ -63,9 +63,12 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
63
63
  const {
64
64
  concat: ArrayConcat$1,
65
65
  copyWithin: ArrayCopyWithin,
66
+ every: ArrayEvery,
66
67
  fill: ArrayFill,
67
68
  filter: ArrayFilter,
68
69
  find: ArrayFind,
70
+ findIndex: ArrayFindIndex,
71
+ includes: ArrayIncludes,
69
72
  indexOf: ArrayIndexOf,
70
73
  join: ArrayJoin,
71
74
  map: ArrayMap,
@@ -81,6 +84,15 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
81
84
  unshift: ArrayUnshift,
82
85
  forEach
83
86
  } = Array.prototype;
87
+ // The type of the return value of Array.prototype.every is `this is T[]`. However, once this
88
+ // Array method is pulled out of the prototype, the function is now referencing `this` where
89
+ // `this` is meaningless, resulting in a TypeScript compilation error.
90
+ //
91
+ // Exposing this helper function is the closest we can get to preserving the usage patterns
92
+ // of Array.prototype methods used elsewhere in the codebase.
93
+ function arrayEvery(arr, predicate) {
94
+ return ArrayEvery.call(arr, predicate);
95
+ }
84
96
  const {
85
97
  fromCharCode: StringFromCharCode
86
98
  } = String;
@@ -298,24 +310,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
298
310
  return propertyName;
299
311
  }
300
312
 
301
- /*
302
- * Copyright (c) 2020, salesforce.com, inc.
303
- * All rights reserved.
304
- * SPDX-License-Identifier: MIT
305
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
306
- */
307
- const ESCAPED_CHARS = {
308
- '"': '"',
309
- "'": ''',
310
- '<': '&lt;',
311
- '>': '&gt;',
312
- '&': '&amp;'
313
- };
314
- function htmlEscape(str, attrMode = false) {
315
- const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
316
- return str.replace(searchValue, char => ESCAPED_CHARS[char]);
317
- }
318
-
319
313
  /*
320
314
  * Copyright (c) 2018, salesforce.com, inc.
321
315
  * All rights reserved.
@@ -323,9 +317,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
323
317
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
324
318
  */
325
319
  // Increment whenever the LWC template compiler changes
326
- const LWC_VERSION = "2.38.1";
320
+ const LWC_VERSION = "2.45.2";
327
321
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
328
- /** version: 2.38.1 */
322
+ /** version: 2.45.2 */
329
323
 
330
324
  /**
331
325
  * Copyright (C) 2018 salesforce.com, inc.
@@ -343,7 +337,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
343
337
  ENABLE_MIXED_SHADOW_MODE: null,
344
338
  ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
345
339
  ENABLE_WIRE_SYNC_EMIT: null,
346
- ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
347
340
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
348
341
  ENABLE_FROZEN_TEMPLATE: null,
349
342
  DISABLE_ARIA_REFLECTION_POLYFILL: null
@@ -404,7 +397,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
404
397
  setFeatureFlag(name, value);
405
398
  }
406
399
  }
407
- /** version: 2.38.1 */
400
+ /** version: 2.45.2 */
408
401
 
409
402
  /**
410
403
  * Copyright (C) 2018 salesforce.com, inc.
@@ -467,7 +460,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
467
460
  }
468
461
  }
469
462
  }
470
- /** version: 2.38.1 */
463
+ /** version: 2.45.2 */
471
464
 
472
465
  /*
473
466
  * Copyright (c) 2018, salesforce.com, inc.
@@ -895,101 +888,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
895
888
  */
896
889
  // These properties get added to LWCElement.prototype publicProps automatically
897
890
  const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
898
- function offsetPropertyErrorMessage(name) {
899
- return `Using the \`${name}\` property is an anti-pattern because it rounds the value to an integer. Instead, use the \`getBoundingClientRect\` method to obtain fractional values for the size of an element and its position relative to the viewport.`;
900
- }
901
- // Global HTML Attributes & Properties
902
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
903
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
904
- //
905
- // If you update this list, check for test files that recapitulate the same list. Searching the codebase
906
- // for e.g. "dropzone" should suffice.
907
- const globalHTMLProperties = {
908
- accessKey: {
909
- attribute: 'accesskey'
910
- },
911
- accessKeyLabel: {
912
- readOnly: true
913
- },
914
- className: {
915
- attribute: 'class',
916
- error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.'
917
- },
918
- contentEditable: {
919
- attribute: 'contenteditable'
920
- },
921
- dataset: {
922
- readOnly: true,
923
- error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead."
924
- },
925
- dir: {
926
- attribute: 'dir'
927
- },
928
- draggable: {
929
- attribute: 'draggable'
930
- },
931
- dropzone: {
932
- attribute: 'dropzone',
933
- readOnly: true
934
- },
935
- hidden: {
936
- attribute: 'hidden'
937
- },
938
- id: {
939
- attribute: 'id'
940
- },
941
- inputMode: {
942
- attribute: 'inputmode'
943
- },
944
- lang: {
945
- attribute: 'lang'
946
- },
947
- slot: {
948
- attribute: 'slot',
949
- error: 'Using the `slot` property is an anti-pattern.'
950
- },
951
- spellcheck: {
952
- attribute: 'spellcheck'
953
- },
954
- style: {
955
- attribute: 'style'
956
- },
957
- tabIndex: {
958
- attribute: 'tabindex'
959
- },
960
- title: {
961
- attribute: 'title'
962
- },
963
- translate: {
964
- attribute: 'translate'
965
- },
966
- // additional "global attributes" that are not present in the link above.
967
- isContentEditable: {
968
- readOnly: true
969
- },
970
- offsetHeight: {
971
- readOnly: true,
972
- error: offsetPropertyErrorMessage('offsetHeight')
973
- },
974
- offsetLeft: {
975
- readOnly: true,
976
- error: offsetPropertyErrorMessage('offsetLeft')
977
- },
978
- offsetParent: {
979
- readOnly: true
980
- },
981
- offsetTop: {
982
- readOnly: true,
983
- error: offsetPropertyErrorMessage('offsetTop')
984
- },
985
- offsetWidth: {
986
- readOnly: true,
987
- error: offsetPropertyErrorMessage('offsetWidth')
988
- },
989
- role: {
990
- attribute: 'role'
991
- }
992
- };
993
891
  let controlledElement = null;
994
892
  let controlledAttributeName;
995
893
  function isAttributeLocked(elm, attrName) {
@@ -1074,8 +972,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1074
972
  get() {
1075
973
  return originalOuterHTMLDescriptor.get.call(this);
1076
974
  },
1077
- set(_value) {
1078
- throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
975
+ set(value) {
976
+ logError(`Invalid attempt to set outerHTML on Element.`);
977
+ return originalOuterHTMLDescriptor.set.call(this, value);
1079
978
  }
1080
979
  })
1081
980
  };
@@ -1165,22 +1064,23 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1165
1064
  get() {
1166
1065
  return originalInnerHTMLDescriptor.get.call(this);
1167
1066
  },
1168
- set(_value) {
1169
- throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
1067
+ set(value) {
1068
+ logError(`Invalid attempt to set innerHTML on ShadowRoot.`);
1069
+ return originalInnerHTMLDescriptor.set.call(this, value);
1170
1070
  }
1171
1071
  }),
1172
1072
  textContent: generateAccessorDescriptor({
1173
1073
  get() {
1174
1074
  return originalTextContentDescriptor.get.call(this);
1175
1075
  },
1176
- set(_value) {
1177
- throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
1076
+ set(value) {
1077
+ logError(`Invalid attempt to set textContent on ShadowRoot.`);
1078
+ return originalTextContentDescriptor.set.call(this, value);
1178
1079
  }
1179
1080
  }),
1180
1081
  addEventListener: generateDataDescriptor({
1181
1082
  value(type, listener, options) {
1182
- // TODO [#420]: this is triggered when the component author attempts to add a listener
1183
- // programmatically into its Component's shadow root
1083
+ // TODO [#1824]: Potentially relax this restriction
1184
1084
  if (!isUndefined$1(options)) {
1185
1085
  logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
1186
1086
  }
@@ -1204,30 +1104,32 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1204
1104
  get() {
1205
1105
  return originalInnerHTMLDescriptor.get.call(this);
1206
1106
  },
1207
- set(_value) {
1208
- throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
1107
+ set(value) {
1108
+ logError(`Invalid attempt to set innerHTML on HTMLElement.`);
1109
+ return originalInnerHTMLDescriptor.set.call(this, value);
1209
1110
  }
1210
1111
  }),
1211
1112
  outerHTML: generateAccessorDescriptor({
1212
1113
  get() {
1213
1114
  return originalOuterHTMLDescriptor.get.call(this);
1214
1115
  },
1215
- set(_value) {
1216
- throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
1116
+ set(value) {
1117
+ logError(`Invalid attempt to set outerHTML on HTMLElement.`);
1118
+ return originalOuterHTMLDescriptor.set.call(this, value);
1217
1119
  }
1218
1120
  }),
1219
1121
  textContent: generateAccessorDescriptor({
1220
1122
  get() {
1221
1123
  return originalTextContentDescriptor.get.call(this);
1222
1124
  },
1223
- set(_value) {
1224
- throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
1125
+ set(value) {
1126
+ logError(`Invalid attempt to set textContent on HTMLElement.`);
1127
+ return originalTextContentDescriptor.set.call(this, value);
1225
1128
  }
1226
1129
  }),
1227
1130
  addEventListener: generateDataDescriptor({
1228
1131
  value(type, listener, options) {
1229
- // TODO [#420]: this is triggered when the component author attempts to add a listener
1230
- // programmatically into a lighting element node
1132
+ // TODO [#1824]: Potentially relax this restriction
1231
1133
  if (!isUndefined$1(options)) {
1232
1134
  logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
1233
1135
  }
@@ -1238,23 +1140,10 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1238
1140
  })
1239
1141
  };
1240
1142
  }
1241
- function getComponentRestrictionsDescriptors() {
1242
- assertNotProd(); // this method should never leak to prod
1243
- return {
1244
- tagName: generateAccessorDescriptor({
1245
- get() {
1246
- throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` + ` not know which tagName will be used to create the element, therefore writing` + ` code that check for that value is error prone.`);
1247
- },
1248
- configurable: true,
1249
- enumerable: false // no enumerable properties on component
1250
- })
1251
- };
1252
- }
1253
-
1254
1143
  function getLightningElementPrototypeRestrictionsDescriptors(proto) {
1255
1144
  assertNotProd(); // this method should never leak to prod
1256
1145
  const originalDispatchEvent = proto.dispatchEvent;
1257
- const descriptors = {
1146
+ return {
1258
1147
  dispatchEvent: generateDataDescriptor({
1259
1148
  value(event) {
1260
1149
  const vm = getAssociatedVM(this);
@@ -1272,37 +1161,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1272
1161
  }
1273
1162
  })
1274
1163
  };
1275
- forEach.call(getOwnPropertyNames$1(globalHTMLProperties), propName => {
1276
- if (propName in proto) {
1277
- return; // no need to redefine something that we are already exposing
1278
- }
1279
-
1280
- descriptors[propName] = generateAccessorDescriptor({
1281
- get() {
1282
- const {
1283
- error,
1284
- attribute
1285
- } = globalHTMLProperties[propName];
1286
- const msg = [];
1287
- msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
1288
- if (error) {
1289
- msg.push(error);
1290
- } else if (attribute) {
1291
- msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
1292
- }
1293
- logError(msg.join('\n'), getAssociatedVM(this));
1294
- },
1295
- set() {
1296
- const {
1297
- readOnly
1298
- } = globalHTMLProperties[propName];
1299
- if (readOnly) {
1300
- logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
1301
- }
1302
- }
1303
- });
1304
- });
1305
- return descriptors;
1306
1164
  }
1307
1165
  // This routine will prevent access to certain properties on a shadow root instance to guarantee
1308
1166
  // that all components will work fine in IE11 and other browsers without shadow dom support.
@@ -1314,9 +1172,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1314
1172
  const elmProto = getPrototypeOf$1(elm);
1315
1173
  setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
1316
1174
  }
1317
- function patchComponentWithRestrictions(cmp) {
1318
- defineProperties(cmp, getComponentRestrictionsDescriptors());
1319
- }
1320
1175
  function patchLightningElementPrototypeWithRestrictions(proto) {
1321
1176
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1322
1177
  }
@@ -1697,7 +1552,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1697
1552
  valueMutated(originalTarget, key);
1698
1553
  return true;
1699
1554
  }
1700
- /*LWC compiler v2.38.1*/
1555
+ /*LWC compiler v2.45.2*/
1701
1556
  }
1702
1557
  const getterMap = new WeakMap();
1703
1558
  const setterMap = new WeakMap();
@@ -1790,7 +1645,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
1790
1645
  /* istanbul ignore next */
1791
1646
  return false;
1792
1647
  }
1793
- /*LWC compiler v2.38.1*/
1648
+ /*LWC compiler v2.45.2*/
1794
1649
  }
1795
1650
  function extract(objectOrArray) {
1796
1651
  if (isArray(objectOrArray)) {
@@ -2018,16 +1873,10 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2018
1873
  configurable
2019
1874
  } = descriptor;
2020
1875
  if (!isFunction$1(get)) {
2021
- if (process.env.NODE_ENV !== 'production') {
2022
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
2023
- }
2024
- throw new TypeError();
1876
+ throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
2025
1877
  }
2026
1878
  if (!isFunction$1(set)) {
2027
- if (process.env.NODE_ENV !== 'production') {
2028
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
2029
- }
2030
- throw new TypeError();
1879
+ throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
2031
1880
  }
2032
1881
  return {
2033
1882
  enumerable,
@@ -2047,10 +1896,18 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2047
1896
  const vm = getAssociatedVM(this);
2048
1897
  if (process.env.NODE_ENV !== 'production') {
2049
1898
  const vmBeingRendered = getVMBeingRendered();
2050
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
2051
- assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
2052
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2053
- assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1899
+ if (isInvokingRender) {
1900
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1901
+ }
1902
+ if (isUpdatingTemplate) {
1903
+ logError(`When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
1904
+ }
1905
+ if (isBeingConstructed(vm)) {
1906
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1907
+ }
1908
+ if (isObject(newValue) && !isNull(newValue)) {
1909
+ logError(`Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1910
+ }
2054
1911
  }
2055
1912
  updateComponentValue(vm, propName, newValue);
2056
1913
  return set.call(vm.elm, newValue);
@@ -2113,7 +1970,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2113
1970
  // Adding extra guard rails in DEV mode.
2114
1971
  if (process.env.NODE_ENV !== 'production') {
2115
1972
  patchCustomElementWithRestrictions(elm);
2116
- patchComponentWithRestrictions(component);
2117
1973
  }
2118
1974
  return this;
2119
1975
  };
@@ -2169,9 +2025,15 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2169
2025
  } = vm;
2170
2026
  if (process.env.NODE_ENV !== 'production') {
2171
2027
  const vmBeingRendered = getVMBeingRendered();
2172
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2173
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2174
- assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
2028
+ if (isInvokingRender) {
2029
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2030
+ }
2031
+ if (isUpdatingTemplate) {
2032
+ logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2033
+ }
2034
+ if (!isFunction$1(listener)) {
2035
+ logError(`Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
2036
+ }
2175
2037
  }
2176
2038
  const wrappedListener = getWrappedComponentsListener(vm, listener);
2177
2039
  addEventListener(elm, type, wrappedListener, options);
@@ -2259,7 +2121,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2259
2121
  }
2260
2122
  } = vm;
2261
2123
  if (process.env.NODE_ENV !== 'production') {
2262
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2124
+ if (isBeingConstructed(vm)) {
2125
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2126
+ }
2263
2127
  }
2264
2128
  unlockAttribute(elm, name);
2265
2129
  setAttribute(elm, name, value);
@@ -2274,7 +2138,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2274
2138
  }
2275
2139
  } = vm;
2276
2140
  if (process.env.NODE_ENV !== 'production') {
2277
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2141
+ if (isBeingConstructed(vm)) {
2142
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2143
+ }
2278
2144
  }
2279
2145
  unlockAttribute(elm, name);
2280
2146
  setAttribute(elm, name, value, namespace);
@@ -2312,9 +2178,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2312
2178
  }
2313
2179
  } = vm;
2314
2180
  if (process.env.NODE_ENV !== 'production') {
2315
- // TODO [#1290]: this still fails in dev but works in production, eventually, we should
2316
- // just throw in all modes
2317
- assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
2181
+ if (isBeingConstructed(vm)) {
2182
+ logError(`Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
2183
+ }
2318
2184
  }
2319
2185
  return getClassList(elm);
2320
2186
  },
@@ -2853,8 +2719,12 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2853
2719
  const vm = getAssociatedVM(this);
2854
2720
  if (process.env.NODE_ENV !== 'production') {
2855
2721
  const vmBeingRendered = getVMBeingRendered();
2856
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2857
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2722
+ if (isInvokingRender) {
2723
+ logError(`render() method has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2724
+ }
2725
+ if (isUpdatingTemplate) {
2726
+ logError(`Updating the template has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2727
+ }
2858
2728
  }
2859
2729
  vm.cmpProps[key] = newValue;
2860
2730
  componentValueMutated(vm, key);
@@ -2870,12 +2740,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2870
2740
  enumerable,
2871
2741
  configurable
2872
2742
  } = descriptor;
2873
- if (!isFunction$1(get)) {
2874
- if (process.env.NODE_ENV !== 'production') {
2875
- assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2876
- }
2877
- throw new Error();
2878
- }
2743
+ assert.invariant(isFunction$1(get), `Invalid public accessor ${toString$1(key)} decorated with @api. The property is missing a getter.`);
2879
2744
  return {
2880
2745
  get() {
2881
2746
  if (process.env.NODE_ENV !== 'production') {
@@ -2888,13 +2753,17 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2888
2753
  const vm = getAssociatedVM(this);
2889
2754
  if (process.env.NODE_ENV !== 'production') {
2890
2755
  const vmBeingRendered = getVMBeingRendered();
2891
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2892
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2756
+ if (isInvokingRender) {
2757
+ logError(`render() method has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2758
+ }
2759
+ if (isUpdatingTemplate) {
2760
+ logError(`Updating the template has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2761
+ }
2893
2762
  }
2894
2763
  if (set) {
2895
2764
  set.call(this, newValue);
2896
2765
  } else if (process.env.NODE_ENV !== 'production') {
2897
- assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
2766
+ logError(`Invalid attempt to set a new value for property "${toString$1(key)}" that does not has a setter decorated with @api.`, vm);
2898
2767
  }
2899
2768
  },
2900
2769
  enumerable,
@@ -2928,8 +2797,12 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2928
2797
  const vm = getAssociatedVM(this);
2929
2798
  if (process.env.NODE_ENV !== 'production') {
2930
2799
  const vmBeingRendered = getVMBeingRendered();
2931
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2932
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2800
+ if (isInvokingRender) {
2801
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2802
+ }
2803
+ if (isUpdatingTemplate) {
2804
+ logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2805
+ }
2933
2806
  }
2934
2807
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2935
2808
  updateComponentValue(vm, key, reactiveOrAnyValue);
@@ -2995,60 +2868,63 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
2995
2868
  }
2996
2869
 
2997
2870
  function validateObservedField(Ctor, fieldName, descriptor) {
2871
+ assertNotProd(); // this method should never leak to prod
2998
2872
  if (!isUndefined$1(descriptor)) {
2999
2873
  const type = getClassDescriptorType(descriptor);
3000
2874
  const message = `Invalid observed ${fieldName} field. Found a duplicate ${type} with the same name.`;
3001
- // [W-9927596] Ideally we always throw an error when detecting duplicate observed field.
3002
- // This branch is only here for backward compatibility reasons.
3003
- if (type === "accessor" /* DescriptorType.Accessor */) {
3004
- logError(message);
3005
- } else {
3006
- assert.fail(message);
3007
- }
2875
+ // TODO [#3408]: this should throw, not log
2876
+ logError(message);
3008
2877
  }
3009
2878
  }
3010
2879
  function validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor) {
2880
+ assertNotProd(); // this method should never leak to prod
3011
2881
  if (!isUndefined$1(descriptor)) {
3012
2882
  const type = getClassDescriptorType(descriptor);
3013
- assert.fail(`Invalid @track ${fieldName} field. Found a duplicate ${type} with the same name.`);
2883
+ // TODO [#3408]: this should throw, not log
2884
+ logError(`Invalid @track ${fieldName} field. Found a duplicate ${type} with the same name.`);
3014
2885
  }
3015
2886
  }
3016
2887
  function validateFieldDecoratedWithWire(Ctor, fieldName, descriptor) {
2888
+ assertNotProd(); // this method should never leak to prod
3017
2889
  if (!isUndefined$1(descriptor)) {
3018
2890
  const type = getClassDescriptorType(descriptor);
3019
- assert.fail(`Invalid @wire ${fieldName} field. Found a duplicate ${type} with the same name.`);
2891
+ // TODO [#3408]: this should throw, not log
2892
+ logError(`Invalid @wire ${fieldName} field. Found a duplicate ${type} with the same name.`);
3020
2893
  }
3021
2894
  }
3022
2895
  function validateMethodDecoratedWithWire(Ctor, methodName, descriptor) {
2896
+ assertNotProd(); // this method should never leak to prod
3023
2897
  if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
3024
- assert.fail(`Invalid @wire ${methodName} method.`);
2898
+ // TODO [#3441]: This line of code does not seem possible to reach.
2899
+ logError(`Invalid @wire ${methodName} field. The field should have a valid writable descriptor.`);
3025
2900
  }
3026
2901
  }
3027
2902
  function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
2903
+ assertNotProd(); // this method should never leak to prod
3028
2904
  if (!isUndefined$1(descriptor)) {
3029
2905
  const type = getClassDescriptorType(descriptor);
3030
2906
  const message = `Invalid @api ${fieldName} field. Found a duplicate ${type} with the same name.`;
3031
- // [W-9927596] Ideally we always throw an error when detecting duplicate public properties.
3032
- // This branch is only here for backward compatibility reasons.
3033
- if (type === "accessor" /* DescriptorType.Accessor */) {
3034
- logError(message);
3035
- } else {
3036
- assert.fail(message);
3037
- }
2907
+ // TODO [#3408]: this should throw, not log
2908
+ logError(message);
3038
2909
  }
3039
2910
  }
3040
2911
  function validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor) {
3041
- if (isUndefined$1(descriptor)) {
3042
- assert.fail(`Invalid @api get ${fieldName} accessor.`);
3043
- } else if (isFunction$1(descriptor.set)) {
3044
- assert.isTrue(isFunction$1(descriptor.get), `Missing getter for property ${fieldName} decorated with @api in ${Ctor}. You cannot have a setter without the corresponding getter.`);
2912
+ assertNotProd(); // this method should never leak to prod
2913
+ if (isFunction$1(descriptor.set)) {
2914
+ if (!isFunction$1(descriptor.get)) {
2915
+ // TODO [#3441]: This line of code does not seem possible to reach.
2916
+ logError(`Missing getter for property ${fieldName} decorated with @api in ${Ctor}. You cannot have a setter without the corresponding getter.`);
2917
+ }
3045
2918
  } else if (!isFunction$1(descriptor.get)) {
3046
- assert.fail(`Missing @api get ${fieldName} accessor.`);
2919
+ // TODO [#3441]: This line of code does not seem possible to reach.
2920
+ logError(`Missing @api get ${fieldName} accessor.`);
3047
2921
  }
3048
2922
  }
3049
2923
  function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
2924
+ assertNotProd(); // this method should never leak to prod
3050
2925
  if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
3051
- assert.fail(`Invalid @api ${methodName} method.`);
2926
+ // TODO [#3441]: This line of code does not seem possible to reach.
2927
+ logError(`Invalid @api ${methodName} method.`);
3052
2928
  }
3053
2929
  }
3054
2930
  /**
@@ -3077,13 +2953,14 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3077
2953
  apiFieldsConfig[fieldName] = propConfig.config;
3078
2954
  descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
3079
2955
  if (propConfig.config > 0) {
2956
+ if (isUndefined$1(descriptor)) {
2957
+ // TODO [#3441]: This line of code does not seem possible to reach.
2958
+ throw new Error();
2959
+ }
3080
2960
  // accessor declaration
3081
2961
  if (process.env.NODE_ENV !== 'production') {
3082
2962
  validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
3083
2963
  }
3084
- if (isUndefined$1(descriptor)) {
3085
- throw new Error();
3086
- }
3087
2964
  descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
3088
2965
  } else {
3089
2966
  // field declaration
@@ -3126,7 +3003,10 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3126
3003
  descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
3127
3004
  if (method === 1) {
3128
3005
  if (process.env.NODE_ENV !== 'production') {
3129
- assert.isTrue(adapter, `@wire on method "${fieldOrMethodName}": adapter id must be truthy.`);
3006
+ if (!adapter) {
3007
+ // TODO [#3408]: this should throw, not log
3008
+ logError(`@wire on method "${fieldOrMethodName}": adapter id must be truthy.`);
3009
+ }
3130
3010
  validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
3131
3011
  }
3132
3012
  if (isUndefined$1(descriptor)) {
@@ -3136,7 +3016,10 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3136
3016
  storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
3137
3017
  } else {
3138
3018
  if (process.env.NODE_ENV !== 'production') {
3139
- assert.isTrue(adapter, `@wire on field "${fieldOrMethodName}": adapter id must be truthy.`);
3019
+ if (!adapter) {
3020
+ // TODO [#3408]: this should throw, not log
3021
+ logError(`@wire on field "${fieldOrMethodName}": adapter id must be truthy.`);
3022
+ }
3140
3023
  validateFieldDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
3141
3024
  }
3142
3025
  descriptor = internalWireFieldDecorator(fieldOrMethodName);
@@ -3353,7 +3236,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3353
3236
  */
3354
3237
  if (isFunction$1(SuperClass)) {
3355
3238
  HTMLBridgeElement = class extends SuperClass {
3356
- /*LWC compiler v2.38.1*/
3239
+ /*LWC compiler v2.45.2*/
3357
3240
  };
3358
3241
  } else {
3359
3242
  HTMLBridgeElement = function () {
@@ -3435,6 +3318,94 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3435
3318
  freeze(BaseBridgeElement);
3436
3319
  seal(BaseBridgeElement.prototype);
3437
3320
 
3321
+ /*
3322
+ * Copyright (c) 2023, salesforce.com, inc.
3323
+ * All rights reserved.
3324
+ * SPDX-License-Identifier: MIT
3325
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3326
+ */
3327
+ const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
3328
+ // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
3329
+ class LegacyWeakMultiMap {
3330
+ constructor() {
3331
+ this._map = new WeakMap();
3332
+ }
3333
+ _getValues(key) {
3334
+ let values = this._map.get(key);
3335
+ if (isUndefined$1(values)) {
3336
+ values = new Set();
3337
+ this._map.set(key, values);
3338
+ }
3339
+ return values;
3340
+ }
3341
+ get(key) {
3342
+ return this._getValues(key);
3343
+ }
3344
+ add(key, vm) {
3345
+ const set = this._getValues(key);
3346
+ set.add(vm);
3347
+ }
3348
+ delete(key) {
3349
+ this._map.delete(key);
3350
+ }
3351
+ }
3352
+ // This implementation relies on the WeakRef/FinalizationRegistry proposal.
3353
+ // For some background, see: https://github.com/tc39/proposal-weakrefs
3354
+ class ModernWeakMultiMap {
3355
+ constructor() {
3356
+ this._map = new WeakMap();
3357
+ this._registry = new FinalizationRegistry(weakRefs => {
3358
+ // This should be considered an optional cleanup method to remove GC'ed values from their respective arrays.
3359
+ // JS VMs are not obligated to call FinalizationRegistry callbacks.
3360
+ // Work backwards, removing stale VMs
3361
+ for (let i = weakRefs.length - 1; i >= 0; i--) {
3362
+ const vm = weakRefs[i].deref();
3363
+ if (isUndefined$1(vm)) {
3364
+ ArraySplice.call(weakRefs, i, 1); // remove
3365
+ }
3366
+ }
3367
+ });
3368
+ }
3369
+
3370
+ _getWeakRefs(key) {
3371
+ let weakRefs = this._map.get(key);
3372
+ if (isUndefined$1(weakRefs)) {
3373
+ weakRefs = [];
3374
+ this._map.set(key, weakRefs);
3375
+ }
3376
+ return weakRefs;
3377
+ }
3378
+ get(key) {
3379
+ const weakRefs = this._getWeakRefs(key);
3380
+ const result = new Set();
3381
+ for (const weakRef of weakRefs) {
3382
+ const vm = weakRef.deref();
3383
+ if (!isUndefined$1(vm)) {
3384
+ result.add(vm);
3385
+ }
3386
+ }
3387
+ return result;
3388
+ }
3389
+ add(key, value) {
3390
+ const weakRefs = this._getWeakRefs(key);
3391
+ // We could check for duplicate values here, but it doesn't seem worth it.
3392
+ // We transform the output into a Set anyway
3393
+ ArrayPush$1.call(weakRefs, new WeakRef(value));
3394
+ // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
3395
+ // effectively creates a strong reference between the first argument (the "target") and the held value. When
3396
+ // the target is GC'ed, the callback is called, and then the held value is GC'ed.
3397
+ // Putting the key here would mean the key is not GC'ed until the value is GC'ed, which defeats the purpose
3398
+ // of the WeakMap. Whereas putting the weakRefs array here is fine, because it doesn't have a strong reference
3399
+ // to anything. See also this example:
3400
+ // https://gist.github.com/nolanlawson/79a3d36e8e6cc25c5048bb17c1795aea
3401
+ this._registry.register(value, weakRefs);
3402
+ }
3403
+ delete(key) {
3404
+ this._map.delete(key);
3405
+ }
3406
+ }
3407
+ const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
3408
+
3438
3409
  /*
3439
3410
  * Copyright (c) 2020, salesforce.com, inc.
3440
3411
  * All rights reserved.
@@ -3444,68 +3415,63 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3444
3415
  const swappedTemplateMap = new WeakMap();
3445
3416
  const swappedComponentMap = new WeakMap();
3446
3417
  const swappedStyleMap = new WeakMap();
3447
- const activeTemplates = new WeakMap();
3448
- const activeComponents = new WeakMap();
3449
- const activeStyles = new WeakMap();
3418
+ // The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
3419
+ // so we don't want to create strong references to them.
3420
+ // The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
3421
+ // never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
3422
+ const activeTemplates = new WeakMultiMap();
3423
+ const activeComponents = new WeakMultiMap();
3424
+ const activeStyles = new WeakMultiMap();
3450
3425
  function rehydrateHotTemplate(tpl) {
3451
3426
  const list = activeTemplates.get(tpl);
3452
- if (!isUndefined$1(list)) {
3453
- list.forEach(vm => {
3454
- if (isFalse(vm.isDirty)) {
3455
- // forcing the vm to rehydrate in the micro-task:
3456
- markComponentAsDirty(vm);
3457
- scheduleRehydration(vm);
3458
- }
3459
- });
3460
- // resetting the Set to release the memory of those vm references
3461
- // since they are not longer related to this template, instead
3462
- // they will get re-associated once these instances are rehydrated.
3463
- list.clear();
3427
+ for (const vm of list) {
3428
+ if (isFalse(vm.isDirty)) {
3429
+ // forcing the vm to rehydrate in the micro-task:
3430
+ markComponentAsDirty(vm);
3431
+ scheduleRehydration(vm);
3432
+ }
3464
3433
  }
3434
+ // Resetting the Set since these VMs are no longer related to this template, instead
3435
+ // they will get re-associated once these instances are rehydrated.
3436
+ activeTemplates.delete(tpl);
3465
3437
  return true;
3466
3438
  }
3467
3439
  function rehydrateHotStyle(style) {
3468
3440
  const list = activeStyles.get(style);
3469
- if (!isUndefined$1(list)) {
3470
- list.forEach(vm => {
3471
- // if a style definition is swapped, we must reset
3472
- // vm's template content in the next micro-task:
3473
- forceRehydration(vm);
3474
- });
3475
- // resetting the Set to release the memory of those vm references
3476
- // since they are not longer related to this style, instead
3477
- // they will get re-associated once these instances are rehydrated.
3478
- list.clear();
3479
- }
3441
+ for (const vm of list) {
3442
+ // if a style definition is swapped, we must reset
3443
+ // vm's template content in the next micro-task:
3444
+ forceRehydration(vm);
3445
+ }
3446
+ // Resetting the Set since these VMs are no longer related to this style, instead
3447
+ // they will get re-associated once these instances are rehydrated.
3448
+ activeStyles.delete(style);
3480
3449
  return true;
3481
3450
  }
3482
3451
  function rehydrateHotComponent(Ctor) {
3483
3452
  const list = activeComponents.get(Ctor);
3484
3453
  let canRefreshAllInstances = true;
3485
- if (!isUndefined$1(list)) {
3486
- list.forEach(vm => {
3487
- const {
3488
- owner
3489
- } = vm;
3490
- if (!isNull(owner)) {
3491
- // if a component class definition is swapped, we must reset
3492
- // owner's template content in the next micro-task:
3493
- forceRehydration(owner);
3494
- } else {
3495
- // the hot swapping for components only work for instances of components
3496
- // created from a template, root elements can't be swapped because we
3497
- // don't have a way to force the creation of the element with the same state
3498
- // of the current element.
3499
- // Instead, we can report the problem to the caller so it can take action,
3500
- // for example: reload the entire page.
3501
- canRefreshAllInstances = false;
3502
- }
3503
- });
3504
- // resetting the Set to release the memory of those vm references
3505
- // since they are not longer related to this constructor, instead
3506
- // they will get re-associated once these instances are rehydrated.
3507
- list.clear();
3508
- }
3454
+ for (const vm of list) {
3455
+ const {
3456
+ owner
3457
+ } = vm;
3458
+ if (!isNull(owner)) {
3459
+ // if a component class definition is swapped, we must reset
3460
+ // owner's template content in the next micro-task:
3461
+ forceRehydration(owner);
3462
+ } else {
3463
+ // the hot swapping for components only work for instances of components
3464
+ // created from a template, root elements can't be swapped because we
3465
+ // don't have a way to force the creation of the element with the same state
3466
+ // of the current element.
3467
+ // Instead, we can report the problem to the caller so it can take action,
3468
+ // for example: reload the entire page.
3469
+ canRefreshAllInstances = false;
3470
+ }
3471
+ }
3472
+ // resetting the Set since these VMs are no longer related to this constructor, instead
3473
+ // they will get re-associated once these instances are rehydrated.
3474
+ activeComponents.delete(Ctor);
3509
3475
  return canRefreshAllInstances;
3510
3476
  }
3511
3477
  function getTemplateOrSwappedTemplate(tpl) {
@@ -3539,72 +3505,27 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3539
3505
  assertNotProd(); // this method should never leak to prod
3540
3506
  // tracking active component
3541
3507
  const Ctor = vm.def.ctor;
3542
- let componentVMs = activeComponents.get(Ctor);
3543
- if (isUndefined$1(componentVMs)) {
3544
- componentVMs = new Set();
3545
- activeComponents.set(Ctor, componentVMs);
3546
- }
3547
3508
  // this will allow us to keep track of the hot components
3548
- componentVMs.add(vm);
3509
+ activeComponents.add(Ctor, vm);
3549
3510
  // tracking active template
3550
3511
  const tpl = vm.cmpTemplate;
3551
3512
  if (tpl) {
3552
- let templateVMs = activeTemplates.get(tpl);
3553
- if (isUndefined$1(templateVMs)) {
3554
- templateVMs = new Set();
3555
- activeTemplates.set(tpl, templateVMs);
3556
- }
3557
3513
  // this will allow us to keep track of the templates that are
3558
3514
  // being used by a hot component
3559
- templateVMs.add(vm);
3515
+ activeTemplates.add(tpl, vm);
3560
3516
  // tracking active styles associated to template
3561
3517
  const stylesheets = tpl.stylesheets;
3562
3518
  if (!isUndefined$1(stylesheets)) {
3563
- flattenStylesheets(stylesheets).forEach(stylesheet => {
3519
+ for (const stylesheet of flattenStylesheets(stylesheets)) {
3564
3520
  // this is necessary because we don't hold the list of styles
3565
3521
  // in the vm, we only hold the selected (already swapped template)
3566
3522
  // but the styles attached to the template might not be the actual
3567
3523
  // active ones, but the swapped versions of those.
3568
- stylesheet = getStyleOrSwappedStyle(stylesheet);
3569
- let stylesheetVMs = activeStyles.get(stylesheet);
3570
- if (isUndefined$1(stylesheetVMs)) {
3571
- stylesheetVMs = new Set();
3572
- activeStyles.set(stylesheet, stylesheetVMs);
3573
- }
3524
+ const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
3574
3525
  // this will allow us to keep track of the stylesheet that are
3575
3526
  // being used by a hot component
3576
- stylesheetVMs.add(vm);
3577
- });
3578
- }
3579
- }
3580
- }
3581
- function removeActiveVM(vm) {
3582
- assertNotProd(); // this method should never leak to prod
3583
- // tracking inactive component
3584
- const Ctor = vm.def.ctor;
3585
- let list = activeComponents.get(Ctor);
3586
- if (!isUndefined$1(list)) {
3587
- // deleting the vm from the set to avoid leaking memory
3588
- list.delete(vm);
3589
- }
3590
- // removing inactive template
3591
- const tpl = vm.cmpTemplate;
3592
- if (tpl) {
3593
- list = activeTemplates.get(tpl);
3594
- if (!isUndefined$1(list)) {
3595
- // deleting the vm from the set to avoid leaking memory
3596
- list.delete(vm);
3597
- }
3598
- // removing active styles associated to template
3599
- const styles = tpl.stylesheets;
3600
- if (!isUndefined$1(styles)) {
3601
- flattenStylesheets(styles).forEach(style => {
3602
- list = activeStyles.get(style);
3603
- if (!isUndefined$1(list)) {
3604
- // deleting the vm from the set to avoid leaking memory
3605
- list.delete(vm);
3606
- }
3607
- });
3527
+ activeStyles.add(swappedStylesheet, vm);
3528
+ }
3608
3529
  }
3609
3530
  }
3610
3531
  }
@@ -3677,12 +3598,16 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
3677
3598
  const ctorName = Ctor.name;
3678
3599
  // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
3679
3600
  // assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
3680
- assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3681
- if (!isUndefined$1(ctorShadowSupportMode)) {
3682
- assert.invariant(ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */ || ctorShadowSupportMode === "reset" /* ShadowSupportMode.Default */, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3601
+ if (!Ctor.constructor) {
3602
+ // This error seems impossible to hit, due to an earlier check in `isComponentConstructor()`.
3603
+ // But we keep it here just in case.
3604
+ logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3683
3605
  }
3684
- if (!isUndefined$1(ctorRenderMode)) {
3685
- assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
3606
+ if (!isUndefined$1(ctorShadowSupportMode) && ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ && ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */) {
3607
+ logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3608
+ }
3609
+ if (!isUndefined$1(ctorRenderMode) && ctorRenderMode !== 'light' && ctorRenderMode !== 'shadow') {
3610
+ logError(`Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
3686
3611
  }
3687
3612
  }
3688
3613
  const decoratorsMeta = getDecoratorsMeta(Ctor);
@@ -4471,7 +4396,12 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
4471
4396
  return;
4472
4397
  }
4473
4398
  if (process.env.NODE_ENV !== 'production') {
4474
- if (!isSameVnode(n1, n2)) {
4399
+ if (!isSameVnode(n1, n2) &&
4400
+ // Currently the only scenario when patch does not receive the same vnodes are for
4401
+ // dynamic components. When a dynamic component's constructor changes, the value of its
4402
+ // tag name (sel) will be different. The engine will unmount the previous element
4403
+ // and mount the new one using the new constructor in patchCustomElement.
4404
+ !(isVCustomElement(n1) && isVCustomElement(n2))) {
4475
4405
  throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4476
4406
  sel: n1.sel,
4477
4407
  key: n1.key
@@ -4573,8 +4503,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
4573
4503
  children
4574
4504
  } = vnode;
4575
4505
  mountVNodes(children, parent, renderer, anchor);
4576
- // children of a fragment will always have at least the two delimiters.
4577
- vnode.elm = children[children.length - 1].elm;
4506
+ vnode.elm = vnode.leading.elm;
4578
4507
  }
4579
4508
  function patchFragment(n1, n2, parent, renderer) {
4580
4509
  const {
@@ -4587,7 +4516,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
4587
4516
  updateDynamicChildren(n1.children, children, parent, renderer);
4588
4517
  }
4589
4518
  // Note: not reusing n1.elm, because during patching, it may be patched with another text node.
4590
- n2.elm = children[children.length - 1].elm;
4519
+ n2.elm = n2.leading.elm;
4591
4520
  }
4592
4521
  function mountElement(vnode, parent, anchor, renderer) {
4593
4522
  const {
@@ -4700,8 +4629,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
4700
4629
  }
4701
4630
  }
4702
4631
  function patchCustomElement(n1, n2, parent, renderer) {
4632
+ // TODO [#3331]: This if branch should be removed in 246 with lwc:dynamic
4703
4633
  if (n1.ctor !== n2.ctor) {
4704
- // If the constructor, unmount the current component and mount a new one using the new
4634
+ // If the constructor differs, unmount the current component and mount a new one using the new
4705
4635
  // constructor.
4706
4636
  const anchor = renderer.nextSibling(n1.elm);
4707
4637
  unmount(n1, parent, renderer, true);
@@ -4838,6 +4768,25 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
4838
4768
  lockDomMutation();
4839
4769
  }
4840
4770
  }
4771
+ function insertFragmentOrNode(vnode, parent, anchor, renderer) {
4772
+ if (process.env.NODE_ENV !== 'production') {
4773
+ unlockDomMutation();
4774
+ }
4775
+ if (isVFragment(vnode)) {
4776
+ const children = vnode.children;
4777
+ for (let i = 0; i < children.length; i += 1) {
4778
+ const child = children[i];
4779
+ if (!isNull(child)) {
4780
+ renderer.insert(child.elm, parent, anchor);
4781
+ }
4782
+ }
4783
+ } else {
4784
+ renderer.insert(vnode.elm, parent, anchor);
4785
+ }
4786
+ if (process.env.NODE_ENV !== 'production') {
4787
+ lockDomMutation();
4788
+ }
4789
+ }
4841
4790
  function insertNode(node, parent, anchor, renderer) {
4842
4791
  if (process.env.NODE_ENV !== 'production') {
4843
4792
  unlockDomMutation();
@@ -5138,13 +5087,23 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5138
5087
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5139
5088
  // Vnode moved right
5140
5089
  patch(oldStartVnode, newEndVnode, parent, renderer);
5141
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
5090
+ // In the case of fragments, the `elm` property of a vfragment points to the leading
5091
+ // anchor. To determine the next sibling of the whole fragment, we need to use the
5092
+ // trailing anchor as the argument to nextSibling():
5093
+ // [..., [leading, ...content, trailing], nextSibling, ...]
5094
+ let anchor;
5095
+ if (isVFragment(oldEndVnode)) {
5096
+ anchor = renderer.nextSibling(oldEndVnode.trailing.elm);
5097
+ } else {
5098
+ anchor = renderer.nextSibling(oldEndVnode.elm);
5099
+ }
5100
+ insertFragmentOrNode(oldStartVnode, parent, anchor, renderer);
5142
5101
  oldStartVnode = oldCh[++oldStartIdx];
5143
5102
  newEndVnode = newCh[--newEndIdx];
5144
5103
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5145
5104
  // Vnode moved left
5146
5105
  patch(oldEndVnode, newStartVnode, parent, renderer);
5147
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
5106
+ insertFragmentOrNode(newStartVnode, parent, oldStartVnode.elm, renderer);
5148
5107
  oldEndVnode = oldCh[--oldEndIdx];
5149
5108
  newStartVnode = newCh[++newStartIdx];
5150
5109
  } else {
@@ -5175,7 +5134,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5175
5134
  }
5176
5135
  // We've already cloned at least once, so it's no longer read-only
5177
5136
  oldCh[idxInOld] = undefined;
5178
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
5137
+ insertFragmentOrNode(elmToMove, parent, oldStartVnode.elm, renderer);
5179
5138
  }
5180
5139
  }
5181
5140
  newStartVnode = newCh[++newStartIdx];
@@ -5221,9 +5180,16 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5221
5180
  if (n2 !== n1) {
5222
5181
  if (isVNode(n1)) {
5223
5182
  if (isVNode(n2)) {
5224
- // both vnodes are equivalent, and we just need to patch them
5225
- patch(n1, n2, parent, renderer);
5226
- anchor = n2.elm;
5183
+ if (isSameVnode(n1, n2)) {
5184
+ // both vnodes are equivalent, and we just need to patch them
5185
+ patch(n1, n2, parent, renderer);
5186
+ anchor = n2.elm;
5187
+ } else {
5188
+ // removing the old vnode since the new one is different
5189
+ unmount(n1, parent, renderer, true);
5190
+ mount(n2, parent, renderer, anchor);
5191
+ anchor = n2.elm;
5192
+ }
5227
5193
  } else {
5228
5194
  // removing the old vnode since the new one is null
5229
5195
  unmount(n1, parent, renderer, true);
@@ -5271,14 +5237,18 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5271
5237
  }
5272
5238
  // [fr]agment node
5273
5239
  function fr(key, children, stable) {
5240
+ const leading = t('');
5241
+ const trailing = t('');
5274
5242
  return {
5275
5243
  type: 5 /* VNodeType.Fragment */,
5276
5244
  sel: undefined,
5277
5245
  key,
5278
5246
  elm: undefined,
5279
- children: [t(''), ...children, t('')],
5247
+ children: [leading, ...children, trailing],
5280
5248
  stable,
5281
- owner: getVMBeingRendered()
5249
+ owner: getVMBeingRendered(),
5250
+ leading,
5251
+ trailing
5282
5252
  };
5283
5253
  }
5284
5254
  // [h]tml node
@@ -5577,7 +5547,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5577
5547
  return compilerKey + ':' + obj;
5578
5548
  case 'object':
5579
5549
  if (process.env.NODE_ENV !== 'production') {
5580
- assert.fail(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
5550
+ logError(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
5581
5551
  }
5582
5552
  }
5583
5553
  }
@@ -5629,16 +5599,18 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5629
5599
  return url;
5630
5600
  }
5631
5601
  /**
5632
- * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5602
+ * [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5603
+ *
5604
+ * TODO [#3331]: remove usage of lwc:dynamic in 246
5633
5605
  */
5634
- function dc(sel, Ctor, data, children = EmptyArray) {
5606
+ function ddc(sel, Ctor, data, children = EmptyArray) {
5635
5607
  if (process.env.NODE_ENV !== 'production') {
5636
5608
  assert.isTrue(isString(sel), `dc() 1st argument sel must be a string.`);
5637
5609
  assert.isTrue(isObject(data), `dc() 3nd argument data must be an object.`);
5638
5610
  assert.isTrue(arguments.length === 3 || isArray$1(children), `dc() 4nd argument data must be an array.`);
5639
5611
  }
5640
5612
  // null or undefined values should produce a null value in the VNodes
5641
- if (Ctor == null) {
5613
+ if (isNull(Ctor) || isUndefined$1(Ctor)) {
5642
5614
  return null;
5643
5615
  }
5644
5616
  if (!isComponentConstructor(Ctor)) {
@@ -5646,6 +5618,30 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5646
5618
  }
5647
5619
  return c(sel, Ctor, data, children);
5648
5620
  }
5621
+ /**
5622
+ * [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
5623
+ */
5624
+ function dc(Ctor, data, children = EmptyArray) {
5625
+ if (process.env.NODE_ENV !== 'production') {
5626
+ assert.isTrue(isObject(data), `dc() 2nd argument data must be an object.`);
5627
+ assert.isTrue(arguments.length === 3 || isArray$1(children), `dc() 3rd argument data must be an array.`);
5628
+ }
5629
+ // Null or undefined values should produce a null value in the VNodes.
5630
+ // This is the only value at compile time as the constructor will not be known.
5631
+ if (isNull(Ctor) || isUndefined$1(Ctor)) {
5632
+ return null;
5633
+ }
5634
+ if (!isComponentConstructor(Ctor)) {
5635
+ throw new Error(`Invalid constructor ${toString$1(Ctor)} is not a LightningElement constructor.`);
5636
+ }
5637
+ // Look up the dynamic component's name at runtime once the constructor is available.
5638
+ // This information is only known at runtime and is stored as part of registerComponent.
5639
+ const sel = getComponentRegisteredName(Ctor);
5640
+ if (isUndefined$1(sel) || sel === '') {
5641
+ throw new Error(`Invalid LWC constructor ${toString$1(Ctor)} does not have a registered name`);
5642
+ }
5643
+ return c(sel, Ctor, data, children);
5644
+ }
5649
5645
  /**
5650
5646
  * slow children collection marking mechanism. this API allows the compiler to signal
5651
5647
  * to the engine that a particular collection of children must be diffed using the slow
@@ -5707,7 +5703,8 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5707
5703
  gid,
5708
5704
  fid,
5709
5705
  shc,
5710
- ssf
5706
+ ssf,
5707
+ ddc
5711
5708
  });
5712
5709
 
5713
5710
  /*
@@ -5819,30 +5816,29 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5819
5816
  function setVMBeingRendered(vm) {
5820
5817
  vmBeingRendered = vm;
5821
5818
  }
5822
- function validateSlots(vm, html) {
5819
+ function validateSlots(vm) {
5823
5820
  assertNotProd(); // this method should never leak to prod
5824
5821
  const {
5825
5822
  cmpSlots
5826
5823
  } = vm;
5827
- const {
5828
- slots = EmptyArray
5829
- } = html;
5830
5824
  for (const slotName in cmpSlots.slotAssignments) {
5831
5825
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
5832
5826
  assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
5833
- if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
5834
- // TODO [#1297]: this should never really happen because the compiler should always validate
5835
- // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
5836
- logError(`Ignoring unknown provided slot name "${slotName}" in ${vm}. Check for a typo on the slot attribute.`, vm);
5837
- }
5838
5827
  }
5839
5828
  }
5840
5829
  function validateLightDomTemplate(template, vm) {
5841
- if (template === defaultEmptyTemplate) return;
5830
+ assertNotProd(); // should never leak to prod mode
5831
+ if (template === defaultEmptyTemplate) {
5832
+ return;
5833
+ }
5842
5834
  if (vm.renderMode === 0 /* RenderMode.Light */) {
5843
- assert.isTrue(template.renderMode === 'light', `Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
5835
+ if (template.renderMode !== 'light') {
5836
+ logError(`Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
5837
+ }
5844
5838
  } else {
5845
- assert.isTrue(isUndefined$1(template.renderMode), `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5839
+ if (!isUndefined$1(template.renderMode)) {
5840
+ logError(`Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5841
+ }
5846
5842
  }
5847
5843
  }
5848
5844
  function buildParseFragmentFn(createFragmentFn) {
@@ -5972,7 +5968,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5972
5968
  }
5973
5969
  if (process.env.NODE_ENV !== 'production') {
5974
5970
  // validating slots in every rendering since the allocated content might change over time
5975
- validateSlots(vm, html);
5971
+ validateSlots(vm);
5976
5972
  // add the VM to the list of host VMs that can be re-rendered if html is swapped
5977
5973
  setActiveVM(vm);
5978
5974
  }
@@ -5998,7 +5994,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
5998
5994
  logOperationEnd(1 /* OperationId.Render */, vm);
5999
5995
  });
6000
5996
  if (process.env.NODE_ENV !== 'production') {
6001
- assert.invariant(isArray$1(vnodes), `Compiler should produce html functions that always return an array.`);
5997
+ if (!isArray$1(vnodes)) {
5998
+ logError(`Compiler should produce html functions that always return an array.`);
5999
+ }
6002
6000
  }
6003
6001
  return vnodes;
6004
6002
  }
@@ -6128,30 +6126,34 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
6128
6126
  * SPDX-License-Identifier: MIT
6129
6127
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6130
6128
  */
6131
- const signedTemplateMap = new Map();
6129
+ const registeredComponentMap = new Map();
6132
6130
  /**
6133
6131
  * INTERNAL: This function can only be invoked by compiled code. The compiler
6134
6132
  * will prevent this function from being imported by userland code.
6135
6133
  */
6136
6134
  function registerComponent(
6137
6135
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
6138
- Ctor, {
6139
- tmpl
6140
- }) {
6136
+ Ctor, metadata) {
6141
6137
  if (isFunction$1(Ctor)) {
6142
6138
  if (process.env.NODE_ENV !== 'production') {
6143
6139
  // There is no point in running this in production, because the version mismatch check relies
6144
6140
  // on code comments which are stripped out in production by minifiers
6145
6141
  checkVersionMismatch(Ctor, 'component');
6146
6142
  }
6147
- signedTemplateMap.set(Ctor, tmpl);
6143
+ // TODO [#3331]: add validation to check the value of metadata.sel is not an empty string.
6144
+ registeredComponentMap.set(Ctor, metadata);
6148
6145
  }
6149
6146
  // chaining this method as a way to wrap existing assignment of component constructor easily,
6150
6147
  // without too much transformation
6151
6148
  return Ctor;
6152
6149
  }
6153
6150
  function getComponentRegisteredTemplate(Ctor) {
6154
- return signedTemplateMap.get(Ctor);
6151
+ var _a;
6152
+ return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.tmpl;
6153
+ }
6154
+ function getComponentRegisteredName(Ctor) {
6155
+ var _a;
6156
+ return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
6155
6157
  }
6156
6158
  function getTemplateReactiveObserver(vm) {
6157
6159
  return createReactiveObserver(() => {
@@ -6298,9 +6300,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
6298
6300
  runChildNodesDisconnectedCallback(vm);
6299
6301
  runLightChildNodesDisconnectedCallback(vm);
6300
6302
  }
6301
- if (process.env.NODE_ENV !== 'production') {
6302
- removeActiveVM(vm);
6303
- }
6304
6303
  }
6305
6304
  // this method is triggered by the diffing algo only when a vnode from the
6306
6305
  // old vnode.children is removed from the DOM.
@@ -7136,8 +7135,6 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7136
7135
  return renderer.nextSibling(hydratedNode);
7137
7136
  }
7138
7137
  const NODE_VALUE_PROP = 'nodeValue';
7139
- const PARENT_NODE_PROP = 'parentNode';
7140
- const TAG_NAME_PROP = 'tagName';
7141
7138
  function textNodeContentsAreEqual(node, vnode, renderer) {
7142
7139
  const {
7143
7140
  getProperty
@@ -7151,24 +7148,29 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7151
7148
  if (nodeValue === '\u200D' && vnode.text === '') {
7152
7149
  return true;
7153
7150
  }
7154
- // Special case for text nodes inside `<style>` tags – these are escaped when rendered server-size,
7155
- // but not when generated by the engine client-side.
7156
- const parentNode = getProperty(node, PARENT_NODE_PROP);
7157
- // Should never be null, but just to be safe, we check.
7158
- /* istanbul ignore else */
7159
- if (!isNull(parentNode)) {
7160
- const tagName = getProperty(parentNode, TAG_NAME_PROP);
7161
- // If the tagName is STYLE, then the following condition should always be true.
7162
- // The LWC compiler blocks using `<style>`s inside of templates, so it should be impossible
7163
- // for component authors to render different `<style>` text content on the client and server.
7164
- // But just to be safe, we check.
7165
- /* istanbul ignore next */
7166
- if (tagName === 'STYLE' && htmlEscape(vnode.text) === nodeValue) {
7167
- return true;
7168
- }
7169
- }
7170
7151
  return false;
7171
7152
  }
7153
+ // The validationOptOut static property can be an array of attribute names.
7154
+ // Any attribute names specified in that array will not be validated, and the
7155
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
7156
+ function getValidationPredicate(optOutStaticProp) {
7157
+ if (isUndefined$1(optOutStaticProp)) {
7158
+ return _attrName => true;
7159
+ }
7160
+ // If validationOptOut is true, no attributes will be checked for correctness
7161
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
7162
+ if (isTrue(optOutStaticProp)) {
7163
+ return _attrName => false;
7164
+ }
7165
+ // If validationOptOut is an array of strings, attributes specified in the
7166
+ // array will be "opted out". Attributes not specified in the array will still
7167
+ // be validated.
7168
+ if (isArray$1(optOutStaticProp) && arrayEvery(optOutStaticProp, isString)) {
7169
+ return attrName => !ArrayIncludes.call(optOutStaticProp, attrName);
7170
+ }
7171
+ logWarn('Validation opt out must be `true` or an array of attributes that should not be validated.');
7172
+ return _attrName => true;
7173
+ }
7172
7174
  function hydrateText(node, vnode, renderer) {
7173
7175
  var _a;
7174
7176
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -7268,7 +7270,20 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7268
7270
  return elm;
7269
7271
  }
7270
7272
  function hydrateCustomElement(elm, vnode, renderer) {
7271
- if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !isMatchingElement(vnode, elm, renderer)) {
7273
+ const {
7274
+ validationOptOut
7275
+ } = vnode.ctor;
7276
+ const shouldValidateAttr = getValidationPredicate(validationOptOut);
7277
+ // The validationOptOut static property can be an array of attribute names.
7278
+ // Any attribute names specified in that array will not be validated, and the
7279
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
7280
+ //
7281
+ // If validationOptOut is true, no attributes will be checked for correctness
7282
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
7283
+ //
7284
+ // Therefore, if validationOptOut is falsey or an array of strings, we need to
7285
+ // examine some or all of the custom element's attributes.
7286
+ if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
7272
7287
  return handleMismatch(elm, vnode, renderer);
7273
7288
  }
7274
7289
  const {
@@ -7376,7 +7391,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7376
7391
  }
7377
7392
  return true;
7378
7393
  }
7379
- function isMatchingElement(vnode, elm, renderer) {
7394
+ function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
7380
7395
  const {
7381
7396
  getProperty
7382
7397
  } = renderer;
@@ -7386,10 +7401,10 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7386
7401
  }
7387
7402
  return false;
7388
7403
  }
7389
- const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
7390
- const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
7391
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
7392
- return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
7404
+ const hasCompatibleAttrs = validateAttrs(vnode, elm, renderer, shouldValidateAttr);
7405
+ const hasCompatibleClass = shouldValidateAttr('class') ? validateClassAttr(vnode, elm, renderer) : true;
7406
+ const hasCompatibleStyle = shouldValidateAttr('style') ? validateStyleAttr(vnode, elm, renderer) : true;
7407
+ return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
7393
7408
  }
7394
7409
  function attributeValuesAreEqual(vnodeValue, value) {
7395
7410
  const vnodeValueAsString = String(vnodeValue);
@@ -7404,7 +7419,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7404
7419
  // In all other cases, the two values are not considered equal
7405
7420
  return false;
7406
7421
  }
7407
- function validateAttrs(vnode, elm, renderer) {
7422
+ function validateAttrs(vnode, elm, renderer, shouldValidateAttr) {
7408
7423
  const {
7409
7424
  data: {
7410
7425
  attrs = {}
@@ -7414,6 +7429,9 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7414
7429
  // Validate attributes, though we could always recovery from those by running the update mods.
7415
7430
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
7416
7431
  for (const [attrName, attrValue] of Object.entries(attrs)) {
7432
+ if (!shouldValidateAttr(attrName)) {
7433
+ continue;
7434
+ }
7417
7435
  const {
7418
7436
  owner
7419
7437
  } = vnode;
@@ -7444,7 +7462,8 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7444
7462
  } = data;
7445
7463
  const {
7446
7464
  getProperty,
7447
- getClassList
7465
+ getClassList,
7466
+ getAttribute
7448
7467
  } = renderer;
7449
7468
  const scopedToken = getScopeTokenClass(owner);
7450
7469
  const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
@@ -7477,11 +7496,12 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7477
7496
  }
7478
7497
  let nodesAreCompatible = true;
7479
7498
  let readableVnodeClassname;
7480
- const elmClassName = getProperty(elm, 'className');
7499
+ const elmClassName = getAttribute(elm, 'class');
7481
7500
  if (!isUndefined$1(className) && String(className) !== elmClassName) {
7482
7501
  // className is used when class is bound to an expr.
7483
7502
  nodesAreCompatible = false;
7484
- readableVnodeClassname = className;
7503
+ // stringify for pretty-printing
7504
+ readableVnodeClassname = JSON.stringify(className);
7485
7505
  } else if (!isUndefined$1(classMap)) {
7486
7506
  // classMap is used when class is set to static value.
7487
7507
  const classList = getClassList(elm);
@@ -7493,18 +7513,19 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7493
7513
  nodesAreCompatible = false;
7494
7514
  }
7495
7515
  }
7496
- readableVnodeClassname = computedClassName.trim();
7516
+ // stringify for pretty-printing
7517
+ readableVnodeClassname = JSON.stringify(computedClassName.trim());
7497
7518
  if (classList.length > keys(classMap).length) {
7498
7519
  nodesAreCompatible = false;
7499
7520
  }
7500
- } else if (isUndefined$1(className) && elmClassName !== '') {
7521
+ } else if (isUndefined$1(className) && !isNull(elmClassName)) {
7501
7522
  // SSR contains a className but client-side VDOM does not
7502
7523
  nodesAreCompatible = false;
7503
- readableVnodeClassname = '';
7524
+ readableVnodeClassname = '""';
7504
7525
  }
7505
7526
  if (!nodesAreCompatible) {
7506
7527
  if (process.env.NODE_ENV !== 'production') {
7507
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${readableVnodeClassname}" but found "${elmClassName}"`, vnode.owner);
7528
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${readableVnodeClassname} but found ${JSON.stringify(elmClassName)}`, vnode.owner);
7508
7529
  }
7509
7530
  }
7510
7531
  return nodesAreCompatible;
@@ -7841,12 +7862,12 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
7841
7862
  if (process.env.NODE_ENV !== 'production') {
7842
7863
  // TODO [#1292]: Remove the readonly decorator
7843
7864
  if (arguments.length !== 1) {
7844
- assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
7865
+ logError('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
7845
7866
  }
7846
7867
  }
7847
7868
  return getReadOnlyProxy(obj);
7848
7869
  }
7849
- /* version: 2.38.1 */
7870
+ /* version: 2.45.2 */
7850
7871
 
7851
7872
  /*
7852
7873
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8091,7 +8112,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
8091
8112
  // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
8092
8113
  // which are not equipped to be initialized that way.
8093
8114
  class clazz extends HTMLElementAlias {
8094
- /*LWC compiler v2.38.1*/
8115
+ /*LWC compiler v2.45.2*/
8095
8116
  }
8096
8117
  customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
8097
8118
  new clazz();
@@ -8149,7 +8170,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
8149
8170
  // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8150
8171
  }
8151
8172
  }
8152
- /*LWC compiler v2.38.1*/
8173
+ /*LWC compiler v2.45.2*/
8153
8174
  }
8154
8175
  // Do not unnecessarily add a connectedCallback/disconnectedCallback, as it introduces perf overhead
8155
8176
  // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
@@ -8270,7 +8291,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
8270
8291
  function isNull(obj) {
8271
8292
  return obj === null;
8272
8293
  }
8273
- /** version: 2.38.1 */
8294
+ /** version: 2.45.2 */
8274
8295
 
8275
8296
  /*
8276
8297
  * Copyright (c) 2023, salesforce.com, inc.
@@ -8290,7 +8311,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
8290
8311
  this.setNewContext = setNewContext;
8291
8312
  this.setDisconnectedCallback = setDisconnectedCallback;
8292
8313
  }
8293
- /*LWC compiler v2.38.1*/
8314
+ /*LWC compiler v2.45.2*/
8294
8315
  }
8295
8316
  function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
8296
8317
  dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
@@ -8680,7 +8701,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
8680
8701
  attributeChangedCallback(name, oldValue, newValue) {
8681
8702
  attributeChangedCallback.call(this, name, oldValue, newValue);
8682
8703
  }
8683
- /*LWC compiler v2.38.1*/
8704
+ /*LWC compiler v2.45.2*/
8684
8705
  }, _a.observedAttributes = observedAttributes, _a;
8685
8706
  }
8686
8707
 
@@ -8894,7 +8915,7 @@ LWR.define('lwc/v/2_38_1', ['exports'], (function (exports) { 'use strict';
8894
8915
  });
8895
8916
  });
8896
8917
  }
8897
- /* version: 2.38.1 */
8918
+ /* version: 2.45.2 */
8898
8919
 
8899
8920
  exports.LightningElement = LightningElement;
8900
8921
  exports.__unstable__ProfilerControl = profilerControl;