@lwrjs/everywhere 0.12.0-alpha.3 → 0.12.0-alpha.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. package/README.md +2 -0
  2. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/e7acf7aa8a4d89182881b9589312920a/config.js +12 -0
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_12_0-alpha_30/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +14 -0
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{5_2_1/s/ccc2929f679182183c24024e0efea4c0 → 6_3_4/s/5c26ade60a97bb24c64d3829320b13f6}/lwc.js +799 -421
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js +3 -3
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/s/f30361ad8ff7af505bf4d465c8499181/lwr_init.js +21 -21
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_12_0-alpha_3/s/820b8b3d56c7a1873095e47ba8f33509 → 0_12_0-alpha_30/s/67f9bb88d83d22cfcfe0b4732341a25d}/lwr_loader.js +4 -4
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/s/274c8343f810353bbad085a79709395f/lwr_metrics.js +1 -1
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_12_0-alpha_3/s/f3a204ef43fb3057d910f80d7e9f9ba7 → 0_12_0-alpha_30/s/ec0fad0e38a96bb0b88c9f4553460347}/lwr_preInit.js +4 -3
  10. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +1 -1
  11. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
  12. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/lwr-error-shim.js +1 -1
  13. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_12_0-alpha_3 → 0_12_0-alpha_30}/lwr-loader-shim.bundle.js +10 -9
  14. package/build/assets/amd/lwr-everywhere-debug.js +11 -11
  15. package/build/assets/amd/lwr-everywhere-min.js +2 -2
  16. package/build/assets/amd/lwr-everywhere.js +11 -11
  17. package/build/assets/core/lwr-everywhere-debug.js +7 -7
  18. package/build/assets/core/lwr-everywhere-min.js +1 -1
  19. package/build/assets/core/lwr-everywhere.js +7 -7
  20. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  21. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  22. package/build/assets/esm/lwr-everywhere.js +1 -1
  23. package/package.json +9 -9
  24. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/22ba4f092a0ad5d5fd43174af54ec9bd/config.js +0 -11
  25. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_12_0-alpha_3/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
@@ -1,10 +1,10 @@
1
- LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /**
4
- * Copyright (C) 2023 salesforce.com, inc.
4
+ * Copyright (c) 2024 Salesforce, Inc.
5
5
  */
6
6
  /**
7
- * Copyright (C) 2023 salesforce.com, inc.
7
+ * Copyright (c) 2024 Salesforce, Inc.
8
8
  */
9
9
  /*
10
10
  * Copyright (c) 2018, salesforce.com, inc.
@@ -12,21 +12,40 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
12
12
  * SPDX-License-Identifier: MIT
13
13
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
14
14
  */
15
+ /**
16
+ *
17
+ * @param value
18
+ * @param msg
19
+ */
15
20
  function invariant(value, msg) {
16
21
  if (!value) {
17
22
  throw new Error(`Invariant Violation: ${msg}`);
18
23
  }
19
24
  }
25
+ /**
26
+ *
27
+ * @param value
28
+ * @param msg
29
+ */
20
30
  function isTrue$1(value, msg) {
21
31
  if (!value) {
22
32
  throw new Error(`Assert Violation: ${msg}`);
23
33
  }
24
34
  }
35
+ /**
36
+ *
37
+ * @param value
38
+ * @param msg
39
+ */
25
40
  function isFalse$1(value, msg) {
26
41
  if (value) {
27
42
  throw new Error(`Assert Violation: ${msg}`);
28
43
  }
29
44
  }
45
+ /**
46
+ *
47
+ * @param msg
48
+ */
30
49
  function fail(msg) {
31
50
  throw new Error(msg);
32
51
  }
@@ -39,31 +58,50 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
39
58
  });
40
59
 
41
60
  /*
42
- * Copyright (c) 2018, salesforce.com, inc.
61
+ * Copyright (c) 2024, Salesforce, Inc.
43
62
  * All rights reserved.
44
63
  * SPDX-License-Identifier: MIT
45
64
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
46
65
  */
47
66
  const {
67
+ /** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
48
68
  assign,
69
+ /** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
49
70
  create,
71
+ /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
50
72
  defineProperties,
73
+ /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
51
74
  defineProperty,
75
+ /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
52
76
  entries,
77
+ /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
53
78
  freeze,
79
+ /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
54
80
  getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
81
+ /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
55
82
  getOwnPropertyDescriptors,
83
+ /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
56
84
  getOwnPropertyNames: getOwnPropertyNames$1,
85
+ /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
57
86
  getPrototypeOf: getPrototypeOf$1,
87
+ /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
58
88
  hasOwnProperty: hasOwnProperty$1,
89
+ /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
59
90
  isFrozen,
91
+ /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
60
92
  keys,
93
+ /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
61
94
  seal,
95
+ /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
62
96
  setPrototypeOf
63
97
  } = Object;
98
+ /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
64
99
  const {
65
100
  isArray: isArray$1
66
101
  } = Array;
102
+ // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
103
+ // though it works fine for one, e.g. isArray), so comments for these are added to the export
104
+ // statement, rather than this declaration.
67
105
  const {
68
106
  concat: ArrayConcat$1,
69
107
  copyWithin: ArrayCopyWithin,
@@ -86,7 +124,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
86
124
  sort: ArraySort,
87
125
  splice: ArraySplice,
88
126
  unshift: ArrayUnshift,
89
- forEach
127
+ forEach // Weird anomaly!
90
128
  } = Array.prototype;
91
129
  // The type of the return value of Array.prototype.every is `this is T[]`. However, once this
92
130
  // Array method is pulled out of the prototype, the function is now referencing `this` where
@@ -94,12 +132,21 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
94
132
  //
95
133
  // Exposing this helper function is the closest we can get to preserving the usage patterns
96
134
  // of Array.prototype methods used elsewhere in the codebase.
135
+ /**
136
+ * Wrapper for {@linkcode Array.prototype.every} that correctly preserves the type predicate in the
137
+ * return value; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every MDN Reference}.
138
+ * @param arr Array to test.
139
+ * @param predicate A function to execute for each element of the array.
140
+ * @returns Whether all elements in the array pass the test provided by the predicate.
141
+ */
97
142
  function arrayEvery(arr, predicate) {
98
143
  return ArrayEvery.call(arr, predicate);
99
144
  }
145
+ /** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
100
146
  const {
101
147
  fromCharCode: StringFromCharCode
102
148
  } = String;
149
+ // No JSDocs here - see comment for Array.prototype
103
150
  const {
104
151
  charCodeAt: StringCharCodeAt,
105
152
  replace: StringReplace,
@@ -107,52 +154,124 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
107
154
  slice: StringSlice,
108
155
  toLowerCase: StringToLowerCase
109
156
  } = String.prototype;
157
+ /**
158
+ * Determines whether the argument is `undefined`.
159
+ * @param obj Value to test
160
+ * @returns `true` if the value is `undefined`.
161
+ */
110
162
  function isUndefined$1(obj) {
111
163
  return obj === undefined;
112
164
  }
165
+ /**
166
+ * Determines whether the argument is `null`.
167
+ * @param obj Value to test
168
+ * @returns `true` if the value is `null`.
169
+ */
113
170
  function isNull(obj) {
114
171
  return obj === null;
115
172
  }
173
+ /**
174
+ * Determines whether the argument is `true`.
175
+ * @param obj Value to test
176
+ * @returns `true` if the value is `true`.
177
+ */
116
178
  function isTrue(obj) {
117
179
  return obj === true;
118
180
  }
181
+ /**
182
+ * Determines whether the argument is `false`.
183
+ * @param obj Value to test
184
+ * @returns `true` if the value is `false`.
185
+ */
119
186
  function isFalse(obj) {
120
187
  return obj === false;
121
188
  }
189
+ /**
190
+ * Determines whether the argument is a boolean.
191
+ * @param obj Value to test
192
+ * @returns `true` if the value is a boolean.
193
+ */
122
194
  function isBoolean(obj) {
123
195
  return typeof obj === 'boolean';
124
196
  }
197
+ /**
198
+ * Determines whether the argument is a function.
199
+ * @param obj Value to test
200
+ * @returns `true` if the value is a function.
201
+ */
202
+ // Replacing `Function` with a narrower type that works for all our use cases is tricky...
203
+ // eslint-disable-next-line @typescript-eslint/ban-types
125
204
  function isFunction$1(obj) {
126
205
  return typeof obj === 'function';
127
206
  }
207
+ /**
208
+ * Determines whether the argument is an object or null.
209
+ * @param obj Value to test
210
+ * @returns `true` if the value is an object or null.
211
+ */
128
212
  function isObject(obj) {
129
213
  return typeof obj === 'object';
130
214
  }
215
+ /**
216
+ * Determines whether the argument is a string.
217
+ * @param obj Value to test
218
+ * @returns `true` if the value is a string.
219
+ */
131
220
  function isString(obj) {
132
221
  return typeof obj === 'string';
133
222
  }
223
+ /**
224
+ * Determines whether the argument is a number.
225
+ * @param obj Value to test
226
+ * @returns `true` if the value is a number.
227
+ */
134
228
  function isNumber(obj) {
135
229
  return typeof obj === 'number';
136
230
  }
231
+ /** Does nothing! 🚀 */
137
232
  function noop() {
138
233
  /* Do nothing */
139
234
  }
140
235
  const OtS$1 = {}.toString;
236
+ /**
237
+ * Converts the argument to a string, safely accounting for objects with "null" prototype.
238
+ * Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
239
+ * @param obj Value to convert to a string.
240
+ * @returns String representation of the value.
241
+ */
141
242
  function toString$1(obj) {
142
- if (obj && obj.toString) {
243
+ if (obj?.toString) {
143
244
  // Arrays might hold objects with "null" prototype So using
144
245
  // Array.prototype.toString directly will cause an error Iterate through
145
246
  // all the items and handle individually.
146
247
  if (isArray$1(obj)) {
248
+ // This behavior is slightly different from Array#toString:
249
+ // 1. Array#toString calls `this.join`, rather than Array#join
250
+ // Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
251
+ // 2. Array#toString delegates to Object#toString if `this.join` is not a function
252
+ // Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
253
+ // 3. Array#toString converts null/undefined to ''
254
+ // Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
255
+ // 4. Array#toString converts recursive references to arrays to ''
256
+ // Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
257
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
147
258
  return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
148
259
  }
149
260
  return obj.toString();
150
261
  } else if (typeof obj === 'object') {
262
+ // This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
151
263
  return OtS$1.call(obj);
152
264
  } else {
153
- return obj + '';
265
+ return String(obj);
154
266
  }
155
267
  }
268
+ /**
269
+ * Gets the property descriptor for the given object and property key. Similar to
270
+ * {@linkcode Object.getOwnPropertyDescriptor}, but looks up the prototype chain.
271
+ * @param o Value to get the property descriptor for
272
+ * @param p Property key to get the descriptor for
273
+ * @returns The property descriptor for the given object and property key.
274
+ */
156
275
  function getPropertyDescriptor(o, p) {
157
276
  do {
158
277
  const d = getOwnPropertyDescriptor$1(o, p);
@@ -173,16 +292,25 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
173
292
  // It's a bit annoying to do have to do this manually, but this makes the file tree-shakeable,
174
293
  // passing the `verify-treeshakeable.js` test.
175
294
  const LOWEST_API_VERSION = 58 /* APIVersion.V58_244_SUMMER_23 */;
295
+ /**
296
+ *
297
+ * @param apiVersionFeature
298
+ * @param apiVersion
299
+ */
176
300
  function isAPIFeatureEnabled(apiVersionFeature, apiVersion) {
177
301
  switch (apiVersionFeature) {
178
302
  case 0 /* APIFeature.LOWERCASE_SCOPE_TOKENS */:
179
303
  case 1 /* APIFeature.TREAT_ALL_PARSE5_ERRORS_AS_ERRORS */:
180
304
  return apiVersion >= 59 /* APIVersion.V59_246_WINTER_24 */;
181
- case 2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */:
182
305
  case 3 /* APIFeature.DISABLE_OBJECT_REST_SPREAD_TRANSFORMATION */:
183
306
  case 4 /* APIFeature.SKIP_UNNECESSARY_REGISTER_DECORATORS */:
184
307
  case 5 /* APIFeature.USE_COMMENTS_FOR_FRAGMENT_BOOKENDS */:
308
+ case 2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */:
185
309
  return apiVersion >= 60 /* APIVersion.V60_248_SPRING_24 */;
310
+ case 8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */:
311
+ case 7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */:
312
+ case 6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */:
313
+ return apiVersion >= 61 /* APIVersion.V61_250_SUMMER_24 */;
186
314
  }
187
315
  }
188
316
 
@@ -226,18 +354,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
226
354
  // This includes aria-* attributes as well as the special non-ARIA "for" attribute
227
355
  const ID_REFERENCING_ATTRIBUTES_SET = /*@__PURE__*/new Set(['aria-activedescendant', 'aria-controls', 'aria-describedby', 'aria-details', 'aria-errormessage', 'aria-flowto', 'aria-labelledby', 'aria-owns', 'for']);
228
356
 
229
- /*
230
- * Copyright (c) 2018, salesforce.com, inc.
231
- * All rights reserved.
232
- * SPDX-License-Identifier: MIT
233
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
234
- */
235
- // See browser support for globalThis:
236
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
237
- /* istanbul ignore next */
238
- // @ts-ignore
239
- const _globalThis = typeof globalThis === 'object' ? globalThis : window;
240
-
241
357
  /*
242
358
  * Copyright (c) 2023, Salesforce.com, inc.
243
359
  * All rights reserved.
@@ -268,6 +384,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
268
384
  * Map associating previously transformed HTML property into HTML attribute.
269
385
  */
270
386
  const CACHED_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/new Map();
387
+ /**
388
+ *
389
+ * @param propName
390
+ */
271
391
  function htmlPropertyToAttribute(propName) {
272
392
  const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
273
393
  if (!isUndefined$1(ariaAttributeName)) {
@@ -300,6 +420,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
300
420
  * Map associating previously transformed kabab-case attributes into camel-case props.
301
421
  */
302
422
  const CACHED_KEBAB_CAMEL_MAPPING = /*@__PURE__@*/new Map();
423
+ /**
424
+ *
425
+ * @param attrName
426
+ */
303
427
  function kebabCaseToCamelCase(attrName) {
304
428
  let result = CACHED_KEBAB_CAMEL_MAPPING.get(attrName);
305
429
  if (isUndefined$1(result)) {
@@ -316,44 +440,47 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
316
440
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
317
441
  */
318
442
  // Increment whenever the LWC template compiler changes
319
- const LWC_VERSION = "5.2.1";
443
+ const LWC_VERSION = "6.3.4";
320
444
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
321
- /** version: 5.2.1 */
445
+ /** version: 6.3.4 */
322
446
 
323
447
  /**
324
- * Copyright (C) 2023 salesforce.com, inc.
448
+ * Copyright (c) 2024 Salesforce, Inc.
325
449
  */
326
450
 
327
451
  /*
328
- * Copyright (c) 2018, salesforce.com, inc.
452
+ * Copyright (c) 2024, Salesforce, Inc.
329
453
  * All rights reserved.
330
454
  * SPDX-License-Identifier: MIT
331
455
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
332
456
  */
333
457
  // When deprecating a feature flag, ensure that it is also no longer set in the application. For
334
458
  // example, in core, the flag should be removed from LwcPermAndPrefUtilImpl.java
459
+ /** List of all feature flags available, with the default value `null`. */
335
460
  const features = {
336
461
  PLACEHOLDER_TEST_FLAG: null,
337
- ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
338
- ENABLE_MIXED_SHADOW_MODE: null,
339
- ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
462
+ DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
340
463
  ENABLE_WIRE_SYNC_EMIT: null,
341
464
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
342
465
  ENABLE_FROZEN_TEMPLATE: null,
343
466
  ENABLE_LEGACY_SCOPE_TOKENS: null,
344
- ENABLE_FORCE_SHADOW_MIGRATE_MODE: null
467
+ ENABLE_FORCE_SHADOW_MIGRATE_MODE: null,
468
+ ENABLE_EXPERIMENTAL_SIGNALS: null
345
469
  };
346
- // eslint-disable-next-line no-restricted-properties
347
- if (!_globalThis.lwcRuntimeFlags) {
348
- Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
470
+ if (!globalThis.lwcRuntimeFlags) {
471
+ Object.defineProperty(globalThis, 'lwcRuntimeFlags', {
349
472
  value: create(null)
350
473
  });
351
474
  }
352
- // eslint-disable-next-line no-restricted-properties
353
- const flags = _globalThis.lwcRuntimeFlags;
475
+ /** Feature flags that have been set. */
476
+ const flags = globalThis.lwcRuntimeFlags;
354
477
  /**
355
478
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
356
479
  * flag. It is meant to be used during the app initialization.
480
+ * @param name Name of the feature flag to set
481
+ * @param value Whether the feature flag should be enabled
482
+ * @throws Will throw if a non-boolean value is provided when running in production.
483
+ * @example setFeatureFlag("DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE", true)
357
484
  */
358
485
  function setFeatureFlag(name, value) {
359
486
  if (!isBoolean(value)) {
@@ -391,6 +518,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
391
518
  /**
392
519
  * Set the value at runtime of a given feature flag. This method should only be used for testing
393
520
  * purposes. It is a no-op when invoked in production mode.
521
+ * @param name Name of the feature flag to enable or disable
522
+ * @param value Whether the feature flag should be enabled
523
+ * @example setFeatureFlag("DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE", true)
394
524
  */
395
525
  function setFeatureFlagForTest(name, value) {
396
526
  // This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
@@ -398,10 +528,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
398
528
  setFeatureFlag(name, value);
399
529
  }
400
530
  }
401
- /** version: 5.2.1 */
531
+ /** version: 6.3.4 */
402
532
 
403
533
  /**
404
- * Copyright (C) 2023 salesforce.com, inc.
534
+ * Copyright (c) 2024 Salesforce, Inc.
405
535
  */
406
536
 
407
537
  /*
@@ -423,8 +553,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
423
553
  const reportingControl = {
424
554
  /**
425
555
  * Attach a new reporting control (aka dispatcher).
426
- *
427
- * @param dispatcher - reporting control
556
+ * @param dispatcher reporting control
428
557
  */
429
558
  attachDispatcher(dispatcher) {
430
559
  enabled$1 = true;
@@ -465,7 +594,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
465
594
  /**
466
595
  * Report to the current dispatcher, if there is one.
467
596
  * @param reportingEventId
468
- * @param payload - data to report
597
+ * @param payload data to report
469
598
  */
470
599
  function report(reportingEventId, payload) {
471
600
  if (enabled$1) {
@@ -527,7 +656,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
527
656
  }
528
657
 
529
658
  /*
530
- * Copyright (c) 2018, salesforce.com, inc.
659
+ * Copyright (c) 2024, Salesforce, Inc.
531
660
  * All rights reserved.
532
661
  * SPDX-License-Identifier: MIT
533
662
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -535,7 +664,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
535
664
  const alreadyLoggedMessages = new Set();
536
665
  // Only used in LWC's Karma tests
537
666
  if (process.env.NODE_ENV === 'test-karma-lwc') {
538
- // @ts-ignore
539
667
  window.__lwcResetAlreadyLoggedMessages = () => {
540
668
  alreadyLoggedMessages.clear();
541
669
  };
@@ -628,6 +756,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
628
756
  }
629
757
  observe(job) {
630
758
  const inceptionReactiveRecord = currentReactiveObserver;
759
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
631
760
  currentReactiveObserver = this;
632
761
  let error;
633
762
  try {
@@ -676,6 +805,78 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
676
805
  // we keep track of observing records where the observing record was added to so we can do some clean up later on
677
806
  ArrayPush$1.call(this.listeners, reactiveObservers);
678
807
  }
808
+ isObserving() {
809
+ return currentReactiveObserver === this;
810
+ }
811
+ }
812
+
813
+ /*
814
+ * Copyright (c) 2024, salesforce.com, inc.
815
+ * All rights reserved.
816
+ * SPDX-License-Identifier: MIT
817
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
818
+ */
819
+ /**
820
+ * This map keeps track of objects to signals. There is an assumption that the signal is strongly referenced
821
+ * on the object which allows the SignalTracker to be garbage collected along with the object.
822
+ */
823
+ const TargetToSignalTrackerMap = new WeakMap();
824
+ function getSignalTracker(target) {
825
+ let signalTracker = TargetToSignalTrackerMap.get(target);
826
+ if (isUndefined$1(signalTracker)) {
827
+ signalTracker = new SignalTracker();
828
+ TargetToSignalTrackerMap.set(target, signalTracker);
829
+ }
830
+ return signalTracker;
831
+ }
832
+ function subscribeToSignal(target, signal, update) {
833
+ const signalTracker = getSignalTracker(target);
834
+ if (isFalse(signalTracker.seen(signal))) {
835
+ signalTracker.subscribeToSignal(signal, update);
836
+ }
837
+ }
838
+ function unsubscribeFromSignals(target) {
839
+ if (TargetToSignalTrackerMap.has(target)) {
840
+ const signalTracker = getSignalTracker(target);
841
+ signalTracker.unsubscribeFromSignals();
842
+ signalTracker.reset();
843
+ }
844
+ }
845
+ /**
846
+ * This class is used to keep track of the signals associated to a given object.
847
+ * It is used to prevent the LWC engine from subscribing duplicate callbacks multiple times
848
+ * to the same signal. Additionally, it keeps track of all signal unsubscribe callbacks, handles invoking
849
+ * them when necessary and discarding them.
850
+ */
851
+ class SignalTracker {
852
+ constructor() {
853
+ this.signalToUnsubscribeMap = new Map();
854
+ }
855
+ seen(signal) {
856
+ return this.signalToUnsubscribeMap.has(signal);
857
+ }
858
+ subscribeToSignal(signal, update) {
859
+ try {
860
+ const unsubscribe = signal.subscribe(update);
861
+ if (isFunction$1(unsubscribe)) {
862
+ // TODO [#3978]: Evaluate how we should handle the case when unsubscribe is not a function.
863
+ // Long term we should throw an error or log a warning.
864
+ this.signalToUnsubscribeMap.set(signal, unsubscribe);
865
+ }
866
+ } catch (err) {
867
+ logWarnOnce(`Attempted to subscribe to an object that has the shape of a signal but received the following error: ${err?.stack ?? err}`);
868
+ }
869
+ }
870
+ unsubscribeFromSignals() {
871
+ try {
872
+ this.signalToUnsubscribeMap.forEach(unsubscribe => unsubscribe());
873
+ } catch (err) {
874
+ logWarnOnce(`Attempted to call a signal's unsubscribe callback but received the following error: ${err?.stack ?? err}`);
875
+ }
876
+ }
877
+ reset() {
878
+ this.signalToUnsubscribeMap.clear();
879
+ }
679
880
  }
680
881
  function componentValueMutated(vm, key) {
681
882
  // On the server side, we don't need mutation tracking. Skipping it improves performance.
@@ -683,10 +884,24 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
683
884
  valueMutated(vm.component, key);
684
885
  }
685
886
  }
686
- function componentValueObserved(vm, key) {
887
+ function componentValueObserved(vm, key, target = {}) {
888
+ const {
889
+ component,
890
+ tro
891
+ } = vm;
687
892
  // On the server side, we don't need mutation tracking. Skipping it improves performance.
688
893
  {
689
- valueObserved(vm.component, key);
894
+ valueObserved(component, key);
895
+ }
896
+ // The portion of reactivity that's exposed to signals is to subscribe a callback to re-render the VM (templates).
897
+ // We check check the following to ensure re-render is subscribed at the correct time.
898
+ // 1. The template is currently being rendered (there is a template reactive observer)
899
+ // 2. There was a call to a getter to access the signal (happens during vnode generation)
900
+ if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS && isObject(target) && !isNull(target) && 'value' in target && 'subscribe' in target && isFunction$1(target.subscribe) &&
901
+ // Only subscribe if a template is being rendered by the engine
902
+ tro.isObserving()) {
903
+ // Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
904
+ subscribeToSignal(component, target, tro.notify.bind(tro));
690
905
  }
691
906
  }
692
907
  function createReactiveObserver(callback) {
@@ -723,6 +938,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
723
938
  }
724
939
  }
725
940
  if (nextTickCallbackQueue.length === 0) {
941
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
726
942
  Promise.resolve().then(flushCallbackQueue);
727
943
  }
728
944
  ArrayPush$1.call(nextTickCallbackQueue, callback);
@@ -733,6 +949,14 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
733
949
  }
734
950
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
735
951
  }
952
+ function shouldUseNativeCustomElementLifecycle(ctor) {
953
+ if (lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
954
+ // temporary "kill switch"
955
+ return false;
956
+ }
957
+ const apiVersion = getComponentAPIVersion(ctor);
958
+ return isAPIFeatureEnabled(7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */, apiVersion);
959
+ }
736
960
  // Borrowed from Vue template compiler.
737
961
  // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
738
962
  const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
@@ -779,6 +1003,16 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
779
1003
  throw new ReferenceError();
780
1004
  }
781
1005
  }
1006
+ function shouldBeFormAssociated(Ctor) {
1007
+ const ctorFormAssociated = Boolean(Ctor.formAssociated);
1008
+ const apiVersion = getComponentAPIVersion(Ctor);
1009
+ const apiFeatureEnabled = isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
1010
+ if (process.env.NODE_ENV !== 'production' && ctorFormAssociated && !apiFeatureEnabled) {
1011
+ const tagName = getComponentRegisteredName(Ctor);
1012
+ logWarnOnce(`Component <${tagName}> set static formAssociated to true, but form ` + `association is not enabled because the API version is ${apiVersion}. To enable form association, ` + `update the LWC component API version to 61 or above. https://lwc.dev/guide/versioning`);
1013
+ }
1014
+ return ctorFormAssociated && apiFeatureEnabled;
1015
+ }
782
1016
 
783
1017
  /*
784
1018
  * Copyright (c) 2020, salesforce.com, inc.
@@ -788,14 +1022,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
788
1022
  */
789
1023
  function resolveCircularModuleDependency(fn) {
790
1024
  const module = fn();
791
- return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
1025
+ return module?.__esModule ? module.default : module;
792
1026
  }
793
1027
  function isCircularModuleDependency(obj) {
794
1028
  return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
795
1029
  }
796
- var _a, _b;
797
- const instrumentDef = (_a = _globalThis.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : noop;
798
- const instrumentInstance = (_b = _globalThis.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
799
1030
 
800
1031
  /*
801
1032
  * Copyright (c) 2023, salesforce.com, inc.
@@ -803,37 +1034,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
803
1034
  * SPDX-License-Identifier: MIT
804
1035
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
805
1036
  */
806
- // Apply ARIA string reflection behavior to a prototype.
807
- // This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
808
- // needed for backwards compatibility in LEX, whereas `applyAriaReflection` is designed to only apply to our own
809
- // LightningElement/BaseBridgeElement prototypes.
810
- function applyAriaReflection(prototype) {
811
- for (const propName of keys(AriaPropNameToAttrNameMap)) {
812
- const attrName = AriaPropNameToAttrNameMap[propName];
813
- if (isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName))) {
814
- // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
815
- // from Element.prototype, because these methods are overridden in LightningElement.
816
- defineProperty(prototype, propName, {
817
- get() {
818
- return this.getAttribute(attrName);
819
- },
820
- set(newValue) {
821
- // TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
822
- // Our historical behavior is to only treat null as removing the attribute
823
- // See also https://github.com/w3c/aria/issues/1858
824
- if (isNull(newValue)) {
825
- this.removeAttribute(attrName);
826
- } else {
827
- this.setAttribute(attrName, newValue);
828
- }
829
- },
830
- // configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
831
- configurable: true,
832
- enumerable: true
833
- });
834
- }
835
- }
836
- }
1037
+ const instrumentDef = globalThis.__lwc_instrument_cmp_def ?? noop;
1038
+ const instrumentInstance = globalThis.__lwc_instrument_cmp_instance ?? noop;
837
1039
 
838
1040
  /*
839
1041
  * Copyright (c) 2018, salesforce.com, inc.
@@ -846,6 +1048,43 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
846
1048
  const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
847
1049
  const HTMLElementPrototype = HTMLElementConstructor.prototype;
848
1050
 
1051
+ /*
1052
+ * Copyright (c) 2023, salesforce.com, inc.
1053
+ * All rights reserved.
1054
+ * SPDX-License-Identifier: MIT
1055
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1056
+ */
1057
+ // Apply ARIA string reflection behavior to a prototype.
1058
+ // This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
1059
+ // needed for backwards compatibility in LEX, whereas this is designed to only apply to our own
1060
+ // LightningElement/BaseBridgeElement prototypes.
1061
+ // Note we only need to handle ARIA reflections that aren't already in Element.prototype
1062
+ const ariaReflectionPolyfillDescriptors = create(null);
1063
+ for (const [propName, attrName] of entries(AriaPropNameToAttrNameMap)) {
1064
+ if (isUndefined$1(getPropertyDescriptor(HTMLElementPrototype, propName))) {
1065
+ // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
1066
+ // from Element.prototype, because these methods are overridden in LightningElement.
1067
+ ariaReflectionPolyfillDescriptors[propName] = {
1068
+ get() {
1069
+ return this.getAttribute(attrName);
1070
+ },
1071
+ set(newValue) {
1072
+ // TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
1073
+ // Our historical behavior is to only treat null as removing the attribute
1074
+ // See also https://github.com/w3c/aria/issues/1858
1075
+ if (isNull(newValue)) {
1076
+ this.removeAttribute(attrName);
1077
+ } else {
1078
+ this.setAttribute(attrName, newValue);
1079
+ }
1080
+ },
1081
+ // configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
1082
+ configurable: true,
1083
+ enumerable: true
1084
+ };
1085
+ }
1086
+ }
1087
+
849
1088
  /*
850
1089
  * Copyright (c) 2018, salesforce.com, inc.
851
1090
  * All rights reserved.
@@ -892,7 +1131,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
892
1131
  * SPDX-License-Identifier: MIT
893
1132
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
894
1133
  */
895
- /* eslint @lwc/lwc-internal/no-production-assert: "off" */
896
1134
  function generateDataDescriptor(options) {
897
1135
  return assign({
898
1136
  configurable: true,
@@ -1039,7 +1277,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1039
1277
  logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
1040
1278
  }
1041
1279
  // Typescript does not like it when you treat the `arguments` object as an array
1042
- // @ts-ignore type-mismatch
1280
+ // @ts-expect-error type-mismatch
1043
1281
  return originalAddEventListener.apply(this, arguments);
1044
1282
  }
1045
1283
  })
@@ -1088,34 +1326,12 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1088
1326
  logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
1089
1327
  }
1090
1328
  // Typescript does not like it when you treat the `arguments` object as an array
1091
- // @ts-ignore type-mismatch
1329
+ // @ts-expect-error type-mismatch
1092
1330
  return originalAddEventListener.apply(this, arguments);
1093
1331
  }
1094
1332
  })
1095
1333
  };
1096
1334
  }
1097
- function getLightningElementPrototypeRestrictionsDescriptors(proto) {
1098
- assertNotProd(); // this method should never leak to prod
1099
- const originalDispatchEvent = proto.dispatchEvent;
1100
- return {
1101
- dispatchEvent: generateDataDescriptor({
1102
- value(event) {
1103
- const vm = getAssociatedVM(this);
1104
- if (!isNull(event) && isObject(event)) {
1105
- const {
1106
- type
1107
- } = event;
1108
- if (!/^[a-z][a-z0-9_]*$/.test(type)) {
1109
- logError(`Invalid event type "${type}" dispatched in element ${getComponentTag(vm)}.` + ` Event name must start with a lowercase letter and followed only lowercase` + ` letters, numbers, and underscores`, vm);
1110
- }
1111
- }
1112
- // Typescript does not like it when you treat the `arguments` object as an array
1113
- // @ts-ignore type-mismatch
1114
- return originalDispatchEvent.apply(this, arguments);
1115
- }
1116
- })
1117
- };
1118
- }
1119
1335
  // This routine will prevent access to certain properties on a shadow root instance to guarantee
1120
1336
  // that all components will work fine in IE11 and other browsers without shadow dom support.
1121
1337
  function patchShadowRootWithRestrictions(sr) {
@@ -1126,9 +1342,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1126
1342
  const elmProto = getPrototypeOf$1(elm);
1127
1343
  setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
1128
1344
  }
1129
- function patchLightningElementPrototypeWithRestrictions(proto) {
1130
- defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1131
- }
1132
1345
  function updateComponentValue(vm, key, newValue) {
1133
1346
  const {
1134
1347
  cmpFields
@@ -1505,7 +1718,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1505
1718
  valueMutated(originalTarget, key);
1506
1719
  return true;
1507
1720
  }
1508
- /*LWC compiler v5.2.1*/
1721
+ /*LWC compiler v6.3.4*/
1509
1722
  }
1510
1723
  const getterMap = new WeakMap();
1511
1724
  const setterMap = new WeakMap();
@@ -1598,7 +1811,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1598
1811
  /* istanbul ignore next */
1599
1812
  return false;
1600
1813
  }
1601
- /*LWC compiler v5.2.1*/
1814
+ /*LWC compiler v6.3.4*/
1602
1815
  }
1603
1816
  function extract(objectOrArray) {
1604
1817
  if (isArray(objectOrArray)) {
@@ -1784,6 +1997,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1784
1997
  * EXPERIMENTAL: This function implements an unwrap mechanism that
1785
1998
  * works for observable membrane objects. This API is subject to
1786
1999
  * change or being removed.
2000
+ * @param value
1787
2001
  */
1788
2002
  function unwrap(value) {
1789
2003
  // On the server side, we don't need mutation tracking. Skipping it improves performance.
@@ -1852,6 +2066,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1852
2066
  }
1853
2067
  return promise;
1854
2068
  });
2069
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
1855
2070
  Promise.all(promises).then(stylesheetTexts => {
1856
2071
  // When replaceSync() is called, the entire contents of the constructable stylesheet are replaced
1857
2072
  // with the copied+concatenated styles. This means that any shadow root's adoptedStyleSheets that
@@ -1896,6 +2111,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1896
2111
  * that a Custom Element can support (including AOM properties), which
1897
2112
  * determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
1898
2113
  * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
2114
+ * @param propName
2115
+ * @param descriptor
1899
2116
  */
1900
2117
  function createBridgeToElementDescriptor(propName, descriptor) {
1901
2118
  const {
@@ -1950,8 +2167,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1950
2167
  /**
1951
2168
  * This class is the base class for any LWC element.
1952
2169
  * Some elements directly extends this class, others implement it via inheritance.
1953
- **/
1954
- // @ts-ignore
2170
+ */
2171
+ // @ts-expect-error When exported, it will conform, but we need to build it first!
1955
2172
  const LightningElement = function () {
1956
2173
  // This should be as performant as possible, while any initialization should be done lazily
1957
2174
  if (isNull(vmBeingConstructed)) {
@@ -1975,7 +2192,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1975
2192
  } = vm.renderer;
1976
2193
  assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
1977
2194
  }
1978
- const component = this;
1979
2195
  setPrototypeOf(elm, bridge.prototype);
1980
2196
  vm.component = this;
1981
2197
  // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
@@ -1994,7 +2210,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1994
2210
  }
1995
2211
  markLockerLiveObject(this);
1996
2212
  // Linking elm, shadow root and component with the VM.
1997
- associateVM(component, vm);
2213
+ associateVM(this, vm);
1998
2214
  associateVM(elm, vm);
1999
2215
  if (vm.renderMode === 1 /* RenderMode.Shadow */) {
2000
2216
  vm.renderRoot = doAttachShadow(vm);
@@ -2039,69 +2255,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2039
2255
  logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
2040
2256
  }
2041
2257
  }
2042
- // List of properties on ElementInternals that are formAssociated can be found in the spec:
2043
- // https://html.spec.whatwg.org/multipage/custom-elements.html#form-associated-custom-elements
2044
- const formAssociatedProps = new Set(['setFormValue', 'form', 'setValidity', 'willValidate', 'validity', 'validationMessage', 'checkValidity', 'reportValidity', 'labels']);
2045
- // Verify that access to a form-associated property of the ElementInternals proxy has formAssociated set in the LWC.
2046
- function verifyPropForFormAssociation(propertyKey, isFormAssociated) {
2047
- if (isString(propertyKey) && formAssociatedProps.has(propertyKey) && !isFormAssociated) {
2048
- //Note this error message mirrors Chrome and Firefox error messages, in Safari the error is slightly different.
2049
- throw new DOMException(`Failed to execute '${propertyKey}' on 'ElementInternals': The target element is not a form-associated custom element.`);
2050
- }
2051
- }
2052
- const elementInternalsAccessorAllowList = new Set(['shadowRoot', 'role', ...formAssociatedProps]);
2053
- // Prevent access to properties not defined in the HTML spec in case browsers decide to
2054
- // provide new APIs that provide access to form associated properties.
2055
- // This can be removed along with UpgradeableConstructor.
2056
- function isAllowedElementInternalAccessor(propertyKey) {
2057
- let isAllowedAccessor = false;
2058
- // As of this writing all ElementInternal property keys as described in the spec are implemented with strings
2059
- // in Chrome, Firefox, and Safari
2060
- if (isString(propertyKey)) {
2061
- // Allow list is based on HTML spec:
2062
- // https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface
2063
- isAllowedAccessor = elementInternalsAccessorAllowList.has(propertyKey) || /^aria/.test(propertyKey);
2064
- if (!isAllowedAccessor && process.env.NODE_ENV !== 'production') {
2065
- logWarn('Only properties defined in the ElementInternals HTML spec are available.');
2066
- }
2067
- }
2068
- return isAllowedAccessor;
2069
- }
2070
- // Wrap all ElementInternal objects in a proxy to prevent form association when `formAssociated` is not set on an LWC.
2071
- // This is needed because the 1UpgradeableConstructor1 always sets `formAssociated=true`, which means all
2072
- // ElementInternal objects will have form-associated properties set when an LWC is placed in a form.
2073
- // We are doing this to guard against customers taking a dependency on form elements being associated to ElementInternals
2074
- // when 'formAssociated' has not been set on the LWC.
2075
- function createElementInternalsProxy(elementInternals, isFormAssociated) {
2076
- const elementInternalsProxy = new Proxy(elementInternals, {
2077
- set(target, propertyKey, newValue) {
2078
- if (isAllowedElementInternalAccessor(propertyKey)) {
2079
- // Verify that formAssociated is set for form associated properties
2080
- verifyPropForFormAssociation(propertyKey, isFormAssociated);
2081
- return Reflect.set(target, propertyKey, newValue);
2082
- }
2083
- // As of this writing ElementInternals do not have non-string properties that can be set.
2084
- return false;
2085
- },
2086
- get(target, propertyKey) {
2087
- if (
2088
- // Pass through Object.prototype methods such as toString()
2089
- hasOwnProperty$1.call(Object.prototype, propertyKey) ||
2090
- // As of this writing, ElementInternals only uses Symbol.toStringTag which is called
2091
- // on Object.hasOwnProperty invocations
2092
- Symbol.for('Symbol.toStringTag') === propertyKey ||
2093
- // ElementInternals allow listed properties
2094
- isAllowedElementInternalAccessor(propertyKey)) {
2095
- // Verify that formAssociated is set for form associated properties
2096
- verifyPropForFormAssociation(propertyKey, isFormAssociated);
2097
- const propertyValue = Reflect.get(target, propertyKey);
2098
- return isFunction$1(propertyValue) ? propertyValue.bind(target) : propertyValue;
2099
- }
2100
- }
2101
- });
2102
- return elementInternalsProxy;
2103
- }
2104
- // @ts-ignore
2258
+ // Type assertion because we need to build the prototype before it satisfies the interface.
2105
2259
  LightningElement.prototype = {
2106
2260
  constructor: LightningElement,
2107
2261
  dispatchEvent(event) {
@@ -2254,19 +2408,18 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2254
2408
  const vm = getAssociatedVM(this);
2255
2409
  const {
2256
2410
  elm,
2257
- def: {
2258
- formAssociated
2259
- },
2411
+ apiVersion,
2260
2412
  renderer: {
2261
2413
  attachInternals
2262
2414
  }
2263
2415
  } = vm;
2416
+ if (!isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
2417
+ throw new Error(`The attachInternals API is only supported in API version 61 and above. ` + `The current version is ${apiVersion}. ` + `To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`);
2418
+ }
2264
2419
  if (vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
2265
- throw new Error('attachInternals API is not supported in light DOM or synthetic shadow.');
2420
+ throw new Error('attachInternals API is not supported in synthetic shadow.');
2266
2421
  }
2267
- const internals = attachInternals(elm);
2268
- // #TODO[2970]: remove proxy once `UpgradeableConstructor` has been removed
2269
- return createElementInternalsProxy(internals, Boolean(formAssociated));
2422
+ return attachInternals(elm);
2270
2423
  },
2271
2424
  get isConnected() {
2272
2425
  const vm = getAssociatedVM(this);
@@ -2378,6 +2531,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2378
2531
  if (process.env.NODE_ENV !== 'production') {
2379
2532
  warnIfInvokedDuringConstruction(vm, 'childNodes');
2380
2533
  }
2534
+ // getChildNodes returns a NodeList, which has `item(index: number): Node | null`.
2535
+ // NodeListOf<T> extends NodeList, but claims to not return null. That seems inaccurate,
2536
+ // but these are built-in types, so ultimately not our problem.
2381
2537
  return renderer.getChildNodes(vm.elm);
2382
2538
  },
2383
2539
  get firstChild() {
@@ -2462,11 +2618,17 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2462
2618
  for (const propName in HTMLElementOriginalDescriptors) {
2463
2619
  lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
2464
2620
  }
2465
- defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2466
2621
  // Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
2467
2622
  // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
2468
2623
  // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
2469
- applyAriaReflection(LightningElement.prototype);
2624
+ {
2625
+ // In the browser, we use createBridgeToElementDescriptor, so we can get the normal reactivity lifecycle for
2626
+ // aria* properties
2627
+ for (const [propName, descriptor] of entries(ariaReflectionPolyfillDescriptors)) {
2628
+ lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, descriptor);
2629
+ }
2630
+ }
2631
+ defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2470
2632
  defineProperty(LightningElement, 'CustomElementConstructor', {
2471
2633
  get() {
2472
2634
  // If required, a runtime-specific implementation must be defined.
@@ -2474,15 +2636,13 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2474
2636
  },
2475
2637
  configurable: true
2476
2638
  });
2477
- if (process.env.NODE_ENV !== 'production') {
2478
- patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
2479
- }
2480
2639
  function createObservedFieldPropertyDescriptor(key) {
2481
2640
  return {
2482
2641
  get() {
2483
2642
  const vm = getAssociatedVM(this);
2484
- componentValueObserved(vm, key);
2485
- return vm.cmpFields[key];
2643
+ const val = vm.cmpFields[key];
2644
+ componentValueObserved(vm, key, val);
2645
+ return val;
2486
2646
  },
2487
2647
  set(newValue) {
2488
2648
  const vm = getAssociatedVM(this);
@@ -2501,11 +2661,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2501
2661
  */
2502
2662
  const AdapterToTokenMap = new Map();
2503
2663
  function createContextProviderWithRegister(adapter, registerContextProvider) {
2504
- let adapterContextToken = AdapterToTokenMap.get(adapter);
2505
- if (!isUndefined$1(adapterContextToken)) {
2664
+ if (AdapterToTokenMap.has(adapter)) {
2506
2665
  throw new Error(`Adapter already has a context provider.`);
2507
2666
  }
2508
- adapterContextToken = guid();
2667
+ const adapterContextToken = guid();
2509
2668
  AdapterToTokenMap.set(adapter, adapterContextToken);
2510
2669
  const providers = new WeakSet();
2511
2670
  return (elmOrComponent, options) => {
@@ -2610,6 +2769,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2610
2769
  if (hasPendingConfig === false) {
2611
2770
  hasPendingConfig = true;
2612
2771
  // collect new config in the micro-task
2772
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
2613
2773
  Promise.resolve().then(() => {
2614
2774
  hasPendingConfig = false;
2615
2775
  // resetting current reactive params
@@ -2624,7 +2784,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2624
2784
  ro.observe(() => config = configCallback(component));
2625
2785
  // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2626
2786
  // TODO: dev-mode validation of config based on the adapter.configSchema
2627
- // @ts-ignore it is assigned in the observe() callback
2787
+ // @ts-expect-error it is assigned in the observe() callback
2628
2788
  callbackWhenConfigIsReady(config);
2629
2789
  };
2630
2790
  return {
@@ -2708,7 +2868,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2708
2868
  });
2709
2869
  }
2710
2870
  return {
2711
- // @ts-ignore the boundary protection executes sync, connector is always defined
2871
+ // @ts-expect-error the boundary protection executes sync, connector is always defined
2712
2872
  connector,
2713
2873
  computeConfigAndUpdate,
2714
2874
  resetConfigWatcher: () => ro.reset()
@@ -2769,6 +2929,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2769
2929
  connector.connect();
2770
2930
  if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
2771
2931
  if (hasDynamicParams) {
2932
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
2772
2933
  Promise.resolve().then(computeConfigAndUpdate);
2773
2934
  return;
2774
2935
  }
@@ -2824,8 +2985,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2824
2985
  }
2825
2986
  return;
2826
2987
  }
2827
- componentValueObserved(vm, key);
2828
- return vm.cmpProps[key];
2988
+ const val = vm.cmpProps[key];
2989
+ componentValueObserved(vm, key, val);
2990
+ return val;
2829
2991
  },
2830
2992
  set(newValue) {
2831
2993
  const vm = getAssociatedVM(this);
@@ -2902,8 +3064,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2902
3064
  return {
2903
3065
  get() {
2904
3066
  const vm = getAssociatedVM(this);
2905
- componentValueObserved(vm, key);
2906
- return vm.cmpFields[key];
3067
+ const val = vm.cmpFields[key];
3068
+ componentValueObserved(vm, key, val);
3069
+ return val;
2907
3070
  },
2908
3071
  set(newValue) {
2909
3072
  const vm = getAssociatedVM(this);
@@ -2931,9 +3094,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2931
3094
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2932
3095
  */
2933
3096
  /**
2934
- * @wire decorator to wire fields and methods to a wire adapter in
3097
+ * The @wire decorator wires fields and methods to a wire adapter in
2935
3098
  * LWC Components. This function implements the internals of this
2936
3099
  * decorator.
3100
+ * @param _adapter
3101
+ * @param _config
2937
3102
  */
2938
3103
  function wire(_adapter, _config) {
2939
3104
  if (process.env.NODE_ENV !== 'production') {
@@ -3041,6 +3206,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3041
3206
  /**
3042
3207
  * INTERNAL: This function can only be invoked by compiled code. The compiler
3043
3208
  * will prevent this function from being imported by user-land code.
3209
+ * @param Ctor
3210
+ * @param meta
3044
3211
  */
3045
3212
  function registerDecorators(Ctor, meta) {
3046
3213
  const proto = Ctor.prototype;
@@ -3202,7 +3369,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3202
3369
  let warned = false;
3203
3370
  // Only used in LWC's Karma tests
3204
3371
  if (process.env.NODE_ENV === 'test-karma-lwc') {
3205
- // @ts-ignore
3206
3372
  window.__lwcResetWarnedOnVersionMismatch = () => {
3207
3373
  warned = false;
3208
3374
  };
@@ -3236,6 +3402,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3236
3402
  /**
3237
3403
  * INTERNAL: This function can only be invoked by compiled code. The compiler
3238
3404
  * will prevent this function from being imported by userland code.
3405
+ * @param tpl
3239
3406
  */
3240
3407
  function registerTemplate(tpl) {
3241
3408
  if (process.env.NODE_ENV !== 'production') {
@@ -3249,6 +3416,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3249
3416
  /**
3250
3417
  * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3251
3418
  * libraries to sanitize vulnerable attributes.
3419
+ * @param tagName
3420
+ * @param namespaceUri
3421
+ * @param attrName
3422
+ * @param attrValue
3252
3423
  */
3253
3424
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3254
3425
  // locker-service patches this function during runtime to sanitize vulnerable attributes. When
@@ -3321,7 +3492,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3321
3492
  if (!isUndefined$1(superAttributeChangedCallback)) {
3322
3493
  // delegate unknown attributes to the super.
3323
3494
  // Typescript does not like it when you treat the `arguments` object as an array
3324
- // @ts-ignore type-mismatch
3495
+ // @ts-expect-error type-mismatch
3325
3496
  superAttributeChangedCallback.apply(this, arguments);
3326
3497
  }
3327
3498
  return;
@@ -3347,7 +3518,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3347
3518
  }
3348
3519
  function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
3349
3520
  const HTMLBridgeElement = class extends SuperClass {
3350
- /*LWC compiler v5.2.1*/
3521
+ /*LWC compiler v6.3.4*/
3351
3522
  };
3352
3523
  // generating the hash table for attributes to avoid duplicate fields and facilitate validation
3353
3524
  // and false positives in case of inheritance.
@@ -3372,7 +3543,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3372
3543
  // and can break tooling that expects it to be iterable or defined, e.g. Jest:
3373
3544
  // https://github.com/jestjs/jest/blob/b4c9587/packages/pretty-format/src/plugins/DOMElement.ts#L95
3374
3545
  // It also doesn't make sense to override e.g. "constructor".
3375
- .filter(propName => !(propName in HTMLElementPrototype)));
3546
+ .filter(propName => !(propName in HTMLElementPrototype) && !(propName in ariaReflectionPolyfillDescriptors)));
3376
3547
  for (const propName of nonPublicPropertiesToWarnOn) {
3377
3548
  if (ArrayIndexOf.call(publicProperties, propName) === -1) {
3378
3549
  descriptors[propName] = createAccessorThatWarns(propName);
@@ -3442,21 +3613,19 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3442
3613
  defineProperties(HTMLBridgeElement.prototype, descriptors);
3443
3614
  return HTMLBridgeElement;
3444
3615
  }
3445
- const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), [], [], null, false);
3446
- {
3447
- // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
3448
- // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
3449
- // ARIA props outside the LightningElement
3450
- //
3451
- // Apply ARIA reflection to HTMLBridgeElement.prototype. This allows `elm.aria*` property accessors to work from
3452
- // outside a component, and to reflect `aria-*` attrs. This is especially important because the template compiler
3453
- // compiles aria-* attrs on components to aria* props.
3454
- // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
3455
- //
3456
- // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
3457
- // accessors inside the HTMLBridgeElementFactory.
3458
- applyAriaReflection(BaseBridgeElement.prototype);
3459
- }
3616
+ // We do some special handling of non-standard ARIA props like ariaLabelledBy as well as props without (as of this
3617
+ // writing) broad cross-browser support like ariaBrailleLabel. This is so the reflection works correctly and preserves
3618
+ // backwards compatibility with the previous global polyfill approach.
3619
+ //
3620
+ // The goal here is to expose `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*`
3621
+ // attrs. This is especially important because the template compiler compiles aria-* attrs on components to aria* props.
3622
+ // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
3623
+ //
3624
+ // Also note this ARIA reflection only really makes sense in the browser. On the server, there is no
3625
+ // `renderedCallback()`, so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't
3626
+ // need to expose ARIA props outside the LightningElement
3627
+ const basePublicProperties = [...getOwnPropertyNames$1(HTMLElementOriginalDescriptors), ...getOwnPropertyNames$1(ariaReflectionPolyfillDescriptors)];
3628
+ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, basePublicProperties, [], [], null, false);
3460
3629
  freeze(BaseBridgeElement);
3461
3630
  seal(BaseBridgeElement.prototype);
3462
3631
 
@@ -3756,6 +3925,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3756
3925
  if (!isUndefined$1(ctorShadowSupportMode) && ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ && ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */ && ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
3757
3926
  logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3758
3927
  }
3928
+ // TODO [#3971]: Completely remove shadowSupportMode "any"
3929
+ if (ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */) {
3930
+ logWarn(`Invalid value 'any' for static property shadowSupportMode. 'any' is deprecated and will be removed in a future release--use 'native' instead.`);
3931
+ }
3759
3932
  if (!isUndefined$1(ctorRenderMode) && ctorRenderMode !== 'light' && ctorRenderMode !== 'shadow') {
3760
3933
  logError(`Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
3761
3934
  }
@@ -3801,6 +3974,12 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3801
3974
  let shadowSupportMode = superDef.shadowSupportMode;
3802
3975
  if (!isUndefined$1(ctorShadowSupportMode)) {
3803
3976
  shadowSupportMode = ctorShadowSupportMode;
3977
+ if (isReportingEnabled() && (shadowSupportMode === "any" /* ShadowSupportMode.Any */ || shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
3978
+ report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
3979
+ tagName: Ctor.name,
3980
+ mode: shadowSupportMode
3981
+ });
3982
+ }
3804
3983
  }
3805
3984
  let renderMode = superDef.renderMode;
3806
3985
  if (!isUndefined$1(ctorRenderMode)) {
@@ -3846,6 +4025,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3846
4025
  /**
3847
4026
  * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
3848
4027
  * subject to change or being removed.
4028
+ * @param ctor
3849
4029
  */
3850
4030
  function isComponentConstructor(ctor) {
3851
4031
  if (!isFunction$1(ctor)) {
@@ -3919,6 +4099,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3919
4099
  /**
3920
4100
  * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
3921
4101
  * subject to change or being removed.
4102
+ * @param Ctor
3922
4103
  */
3923
4104
  function getComponentDef(Ctor) {
3924
4105
  const def = getComponentInternalDef(Ctor);
@@ -4133,6 +4314,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4133
4314
  * If the component that is currently being rendered uses scoped styles,
4134
4315
  * this returns the unique token for that scoped stylesheet. Otherwise
4135
4316
  * it returns null.
4317
+ * @param owner
4318
+ * @param legacy
4136
4319
  */
4137
4320
  // TODO [#3733]: remove support for legacy scope tokens
4138
4321
  function getScopeTokenClass(owner, legacy) {
@@ -4140,13 +4323,14 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4140
4323
  cmpTemplate,
4141
4324
  context
4142
4325
  } = owner;
4143
- return context.hasScopedStyles && (legacy ? cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.legacyStylesheetToken : cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
4326
+ return context.hasScopedStyles && (legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken) || null;
4144
4327
  }
4145
4328
  /**
4146
4329
  * This function returns the host style token for a custom element if it
4147
4330
  * exists. Otherwise it returns null.
4148
4331
  *
4149
4332
  * A host style token is applied to the component if scoped styles are used.
4333
+ * @param vnode
4150
4334
  */
4151
4335
  function getStylesheetTokenHost(vnode) {
4152
4336
  const {
@@ -4223,6 +4407,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4223
4407
  function isVScopedSlotFragment(vnode) {
4224
4408
  return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
4225
4409
  }
4410
+ function isVStatic(vnode) {
4411
+ return vnode.type === 4 /* VNodeType.Static */;
4412
+ }
4226
4413
 
4227
4414
  /*
4228
4415
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4276,6 +4463,26 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4276
4463
  }
4277
4464
  }
4278
4465
  }
4466
+ function patchSlotAssignment(oldVnode, vnode, renderer) {
4467
+ const {
4468
+ slotAssignment
4469
+ } = vnode;
4470
+ if (oldVnode?.slotAssignment === slotAssignment) {
4471
+ return;
4472
+ }
4473
+ const {
4474
+ elm
4475
+ } = vnode;
4476
+ const {
4477
+ setAttribute,
4478
+ removeAttribute
4479
+ } = renderer;
4480
+ if (isUndefined$1(slotAssignment) || isNull(slotAssignment)) {
4481
+ removeAttribute(elm, 'slot');
4482
+ } else {
4483
+ setAttribute(elm, 'slot', slotAssignment);
4484
+ }
4485
+ }
4279
4486
 
4280
4487
  /*
4281
4488
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4347,6 +4554,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4347
4554
  return EmptyObject;
4348
4555
  }
4349
4556
  // computed class names must be string
4557
+ // This will throw if className is a symbol or null-prototype object
4558
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
4350
4559
  className = isString(className) ? className : className + '';
4351
4560
  let map = classNameToClassMap[className];
4352
4561
  if (map) {
@@ -4441,11 +4650,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4441
4650
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4442
4651
  */
4443
4652
  function applyEventListeners(vnode, renderer) {
4444
- var _a;
4445
4653
  const {
4446
4654
  elm
4447
4655
  } = vnode;
4448
- const on = (_a = vnode.data) === null || _a === void 0 ? void 0 : _a.on;
4656
+ const on = vnode.data?.on;
4449
4657
  if (isUndefined$1(on)) {
4450
4658
  return;
4451
4659
  }
@@ -4597,13 +4805,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4597
4805
  }
4598
4806
  /**
4599
4807
  * Given an array of static parts, do all the mounting required for these parts.
4600
- *
4601
- * @param root - the root element
4602
- * @param vnode - the parent VStatic
4603
- * @param renderer - the renderer to use
4604
- * @param mount - true this is a first (mount) render as opposed to a subsequent (patch) render
4808
+ * @param root the root element
4809
+ * @param vnode the parent VStatic
4810
+ * @param renderer the renderer to use
4605
4811
  */
4606
- function applyStaticParts(root, vnode, renderer, mount) {
4812
+ function mountStaticParts(root, vnode, renderer) {
4607
4813
  const {
4608
4814
  parts,
4609
4815
  owner
@@ -4611,20 +4817,45 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4611
4817
  if (isUndefined$1(parts)) {
4612
4818
  return;
4613
4819
  }
4614
- // This adds `part.elm` to each `part`. We have to do this on every mount/patch because the `parts`
4820
+ // This adds `part.elm` to each `part`. We have to do this on every mount because the `parts`
4615
4821
  // array is recreated from scratch every time, so each `part.elm` is now undefined.
4616
- // TODO [#3800]: avoid calling traverseAndSetElements on every re-render
4617
4822
  traverseAndSetElements(root, parts, renderer);
4618
4823
  // Currently only event listeners and refs are supported for static vnodes
4619
4824
  for (const part of parts) {
4620
- if (mount) {
4621
- // Event listeners only need to be applied once when mounting
4622
- applyEventListeners(part, renderer);
4623
- }
4825
+ // Event listeners only need to be applied once when mounting
4826
+ applyEventListeners(part, renderer);
4624
4827
  // Refs must be updated after every render due to refVNodes getting reset before every render
4625
4828
  applyRefs(part, owner);
4626
4829
  }
4627
4830
  }
4831
+ /**
4832
+ * Mounts elements to the newly generated VStatic node
4833
+ * @param n1 the previous VStatic vnode
4834
+ * @param n2 the current VStatic vnode
4835
+ */
4836
+ function patchStaticParts(n1, n2) {
4837
+ const {
4838
+ parts: currParts,
4839
+ owner: currPartsOwner
4840
+ } = n2;
4841
+ if (isUndefined$1(currParts)) {
4842
+ return;
4843
+ }
4844
+ const {
4845
+ parts: prevParts
4846
+ } = n1;
4847
+ if (process.env.NODE_ENV !== 'production') {
4848
+ assert.isTrue(currParts.length === prevParts?.length, 'Expected static parts to be the same for the same element. This is an error with the LWC framework itself.');
4849
+ }
4850
+ for (let i = 0; i < currParts.length; i++) {
4851
+ const part = currParts[i];
4852
+ // Patch only occurs if the vnode is newly generated, which means the part.elm is always undefined
4853
+ // Since the vnode and elements are the same we can safely assume that prevParts[i].elm is defined.
4854
+ part.elm = prevParts[i].elm;
4855
+ // Refs must be updated after every render due to refVNodes getting reset before every render
4856
+ applyRefs(part, currPartsOwner);
4857
+ }
4858
+ }
4628
4859
 
4629
4860
  /*
4630
4861
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4640,7 +4871,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4640
4871
  }
4641
4872
  }
4642
4873
  function patch(n1, n2, parent, renderer) {
4643
- var _a, _b;
4644
4874
  if (n1 === n2) {
4645
4875
  return;
4646
4876
  }
@@ -4676,15 +4906,14 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4676
4906
  patchFragment(n1, n2, parent, renderer);
4677
4907
  break;
4678
4908
  case 2 /* VNodeType.Element */:
4679
- patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
4909
+ patchElement(n1, n2, n2.data.renderer ?? renderer);
4680
4910
  break;
4681
4911
  case 3 /* VNodeType.CustomElement */:
4682
- patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
4912
+ patchCustomElement(n1, n2, parent, n2.data.renderer ?? renderer);
4683
4913
  break;
4684
4914
  }
4685
4915
  }
4686
4916
  function mount(node, parent, renderer, anchor) {
4687
- var _a, _b;
4688
4917
  switch (node.type) {
4689
4918
  case 0 /* VNodeType.Text */:
4690
4919
  // VText has no special capability, fallback to the owner's renderer
@@ -4703,11 +4932,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4703
4932
  break;
4704
4933
  case 2 /* VNodeType.Element */:
4705
4934
  // If the vnode data has a renderer override use it, else fallback to owner's renderer
4706
- mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
4935
+ mountElement(node, parent, anchor, node.data.renderer ?? renderer);
4707
4936
  break;
4708
4937
  case 3 /* VNodeType.CustomElement */:
4709
4938
  // If the vnode data has a renderer override use it, else fallback to owner's renderer
4710
- mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
4939
+ mountCustomElement(node, parent, anchor, node.data.renderer ?? renderer);
4711
4940
  break;
4712
4941
  }
4713
4942
  }
@@ -4789,9 +5018,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4789
5018
  mountVNodes(vnode.children, elm, renderer, null);
4790
5019
  }
4791
5020
  function patchStatic(n1, n2, renderer) {
4792
- const elm = n2.elm = n1.elm;
5021
+ n2.elm = n1.elm;
5022
+ // slotAssignments can only apply to the top level element, never to a static part.
5023
+ patchSlotAssignment(n1, n2, renderer);
4793
5024
  // The `refs` object is blown away in every re-render, so we always need to re-apply them
4794
- applyStaticParts(elm, n2, renderer, false);
5025
+ patchStaticParts(n1, n2);
4795
5026
  }
4796
5027
  function patchElement(n1, n2, renderer) {
4797
5028
  const elm = n2.elm = n1.elm;
@@ -4819,13 +5050,16 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4819
5050
  elm[KEY__SHADOW_STATIC] = true;
4820
5051
  }
4821
5052
  }
5053
+ // slotAssignments can only apply to the top level element, never to a static part.
5054
+ patchSlotAssignment(null, vnode, renderer);
4822
5055
  insertNode(elm, parent, anchor, renderer);
4823
- applyStaticParts(elm, vnode, renderer, true);
5056
+ mountStaticParts(elm, vnode, renderer);
4824
5057
  }
4825
5058
  function mountCustomElement(vnode, parent, anchor, renderer) {
4826
5059
  const {
4827
5060
  sel,
4828
- owner
5061
+ owner,
5062
+ ctor
4829
5063
  } = vnode;
4830
5064
  const {
4831
5065
  createCustomElement
@@ -4846,7 +5080,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4846
5080
  // compiler may generate tagnames with uppercase letters so - for backwards
4847
5081
  // compatibility, we lower case the tagname here.
4848
5082
  const normalizedTagname = sel.toLowerCase();
4849
- const elm = createCustomElement(normalizedTagname, upgradeCallback);
5083
+ const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
5084
+ const isFormAssociated = shouldBeFormAssociated(ctor);
5085
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle, isFormAssociated);
4850
5086
  vnode.elm = elm;
4851
5087
  vnode.vm = vm;
4852
5088
  linkNodeToShadow(elm, owner, renderer);
@@ -4858,7 +5094,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4858
5094
  insertNode(elm, parent, anchor, renderer);
4859
5095
  if (vm) {
4860
5096
  {
4861
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
5097
+ if (!useNativeLifecycle) {
4862
5098
  if (process.env.NODE_ENV !== 'production') {
4863
5099
  // With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
4864
5100
  // noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
@@ -5063,6 +5299,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5063
5299
  patchStyleAttribute(oldVnode, vnode, renderer);
5064
5300
  patchAttributes(oldVnode, vnode, renderer);
5065
5301
  patchProps(oldVnode, vnode, renderer);
5302
+ patchSlotAssignment(oldVnode, vnode, renderer);
5066
5303
  // The `refs` object is blown away in every re-render, so we always need to re-apply them
5067
5304
  applyRefs(vnode, vnode.owner);
5068
5305
  }
@@ -5103,22 +5340,20 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5103
5340
  }
5104
5341
  }
5105
5342
  function applyDomManual(elm, vnode) {
5106
- var _a;
5107
5343
  const {
5108
5344
  owner,
5109
5345
  data: {
5110
5346
  context
5111
5347
  }
5112
5348
  } = vnode;
5113
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
5349
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === "manual" /* LwcDomMode.Manual */) {
5114
5350
  elm.$domManual$ = true;
5115
5351
  }
5116
5352
  }
5117
5353
  function applyElementRestrictions(elm, vnode) {
5118
- var _a, _b;
5119
5354
  if (process.env.NODE_ENV !== 'production') {
5120
5355
  const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
5121
- const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
5356
+ const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === "manual" /* LwcDomMode.Manual */;
5122
5357
  const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
5123
5358
  patchElementWithRestrictions(elm, {
5124
5359
  isPortal,
@@ -5173,6 +5408,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5173
5408
  * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
5174
5409
  *
5175
5410
  * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
5411
+ * @param children
5176
5412
  */
5177
5413
  function flattenFragmentsInChildren(children) {
5178
5414
  const flattenedChildren = [];
@@ -5231,7 +5467,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5231
5467
  return vm;
5232
5468
  }
5233
5469
  function allocateInSlot(vm, children, owner) {
5234
- var _a, _b;
5235
5470
  const {
5236
5471
  cmpSlots: {
5237
5472
  slotAssignments: oldSlotsMapping
@@ -5245,8 +5480,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5245
5480
  continue;
5246
5481
  }
5247
5482
  let slotName = '';
5248
- if (isVBaseElement(vnode)) {
5249
- slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
5483
+ if (isVBaseElement(vnode) || isVStatic(vnode)) {
5484
+ slotName = vnode.slotAssignment ?? '';
5250
5485
  } else if (isVScopedSlotFragment(vnode)) {
5251
5486
  slotName = vnode.slotName;
5252
5487
  }
@@ -5254,6 +5489,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5254
5489
  // but elm.setAttribute('slot', Symbol(1)) is an error.
5255
5490
  // the following line also throws same error for symbols
5256
5491
  // Similar for Object.create(null)
5492
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
5257
5493
  const normalizedSlotName = '' + slotName;
5258
5494
  const vnodes = cmpSlotsMapping[normalizedSlotName] = cmpSlotsMapping[normalizedSlotName] || [];
5259
5495
  ArrayPush$1.call(vnodes, vnode);
@@ -5502,7 +5738,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5502
5738
  elm: undefined,
5503
5739
  fragment,
5504
5740
  owner,
5505
- parts
5741
+ parts,
5742
+ slotAssignment: undefined
5506
5743
  };
5507
5744
  return vnode;
5508
5745
  }
@@ -5545,7 +5782,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5545
5782
  });
5546
5783
  }
5547
5784
  const {
5548
- key
5785
+ key,
5786
+ slotAssignment
5549
5787
  } = data;
5550
5788
  const vnode = {
5551
5789
  type: 2 /* VNodeType.Element */,
@@ -5554,7 +5792,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5554
5792
  children,
5555
5793
  elm: undefined,
5556
5794
  key,
5557
- owner: vmBeingRendered
5795
+ owner: vmBeingRendered,
5796
+ slotAssignment
5558
5797
  };
5559
5798
  return vnode;
5560
5799
  }
@@ -5579,6 +5818,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5579
5818
  assert.isTrue(isObject(data), `s() 2nd argument data must be an object.`);
5580
5819
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
5581
5820
  }
5821
+ const vmBeingRendered = getVMBeingRendered();
5822
+ const {
5823
+ renderMode,
5824
+ apiVersion
5825
+ } = vmBeingRendered;
5582
5826
  if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
5583
5827
  const newChildren = [];
5584
5828
  const slotAssignments = slotset.slotAssignments[slotName];
@@ -5598,7 +5842,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5598
5842
  }
5599
5843
  // If the passed slot content is factory, evaluate it and add the produced vnodes
5600
5844
  if (assignedNodeIsScopedSlot) {
5601
- const vmBeingRenderedInception = getVMBeingRendered();
5602
5845
  // Evaluate in the scope of the slot content's owner
5603
5846
  // if a slotset is provided, there will always be an owner. The only case where owner is
5604
5847
  // undefined is for root components, but root components cannot accept slotted content
@@ -5613,22 +5856,34 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5613
5856
  ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
5614
5857
  });
5615
5858
  } finally {
5616
- setVMBeingRendered(vmBeingRenderedInception);
5859
+ setVMBeingRendered(vmBeingRendered);
5617
5860
  }
5618
5861
  } else {
5862
+ // This block is for standard slots (non-scoped slots)
5863
+ let clonedVNode;
5864
+ if (renderMode === 0 /* RenderMode.Light */ && isAPIFeatureEnabled(6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */, apiVersion) && (isVBaseElement(vnode) || isVStatic(vnode)) &&
5865
+ // We only need to copy the vnodes when the slot assignment changes, copying every time causes issues with
5866
+ // disconnected/connected callback firing.
5867
+ vnode.slotAssignment !== data.slotAssignment) {
5868
+ // When the light DOM slot assignment (slot attribute) changes we can't use the same reference
5869
+ // to the vnode because the current way the diffing algo works, it will replace the original reference
5870
+ // to the host element with a new one. This means the new element will be mounted and immediately unmounted.
5871
+ // Creating a copy of the vnode to preserve a reference to the previous host element.
5872
+ clonedVNode = {
5873
+ ...vnode,
5874
+ slotAssignment: data.slotAssignment
5875
+ };
5876
+ }
5619
5877
  // If the slot content is standard type, the content is static, no additional
5620
5878
  // processing needed on the vnode
5621
- ArrayPush$1.call(newChildren, vnode);
5879
+ ArrayPush$1.call(newChildren, clonedVNode ?? vnode);
5622
5880
  }
5623
5881
  }
5624
5882
  }
5625
5883
  children = newChildren;
5626
5884
  }
5627
- const vmBeingRendered = getVMBeingRendered();
5628
5885
  const {
5629
- renderMode,
5630
- shadowMode,
5631
- apiVersion
5886
+ shadowMode
5632
5887
  } = vmBeingRendered;
5633
5888
  if (renderMode === 0 /* RenderMode.Light */) {
5634
5889
  // light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
@@ -5668,7 +5923,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5668
5923
  }
5669
5924
  }
5670
5925
  const {
5671
- key
5926
+ key,
5927
+ slotAssignment
5672
5928
  } = data;
5673
5929
  let elm, aChildren, vm;
5674
5930
  const vnode = {
@@ -5678,6 +5934,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5678
5934
  children,
5679
5935
  elm,
5680
5936
  key,
5937
+ slotAssignment,
5681
5938
  ctor: Ctor,
5682
5939
  owner: vmBeingRendered,
5683
5940
  mode: 'open',
@@ -5760,6 +6017,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5760
6017
  }
5761
6018
  /**
5762
6019
  * [f]lattening
6020
+ * @param items
5763
6021
  */
5764
6022
  function f(items) {
5765
6023
  if (process.env.NODE_ENV !== 'production') {
@@ -5881,6 +6139,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5881
6139
  * [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5882
6140
  *
5883
6141
  * TODO [#3331]: remove usage of lwc:dynamic in 246
6142
+ * @param sel
6143
+ * @param Ctor
6144
+ * @param data
6145
+ * @param children
5884
6146
  */
5885
6147
  function ddc(sel, Ctor, data, children = EmptyArray) {
5886
6148
  if (process.env.NODE_ENV !== 'production') {
@@ -5899,6 +6161,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5899
6161
  }
5900
6162
  /**
5901
6163
  * [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
6164
+ * @param Ctor
6165
+ * @param data
6166
+ * @param children
5902
6167
  */
5903
6168
  function dc(Ctor, data, children = EmptyArray) {
5904
6169
  if (process.env.NODE_ENV !== 'production') {
@@ -5926,13 +6191,13 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5926
6191
  * to the engine that a particular collection of children must be diffed using the slow
5927
6192
  * algo based on keys due to the nature of the list. E.g.:
5928
6193
  *
5929
- * - slot element's children: the content of the slot has to be dynamic when in synthetic
5930
- * shadow mode because the `vnode.children` might be the slotted
5931
- * content vs default content, in which case the size and the
5932
- * keys are not matching.
5933
- * - children that contain dynamic components
5934
- * - children that are produced by iteration
5935
- *
6194
+ * - slot element's children: the content of the slot has to be dynamic when in synthetic
6195
+ * shadow mode because the `vnode.children` might be the slotted
6196
+ * content vs default content, in which case the size and the
6197
+ * keys are not matching.
6198
+ * - children that contain dynamic components
6199
+ * - children that are produced by iteration
6200
+ * @param vnodes
5936
6201
  */
5937
6202
  function sc(vnodes) {
5938
6203
  if (process.env.NODE_ENV !== 'production') {
@@ -5956,6 +6221,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5956
6221
  };
5957
6222
  /**
5958
6223
  * Sets the sanitizeHtmlContentHook.
6224
+ * @param newHookImpl
5959
6225
  */
5960
6226
  function setSanitizeHtmlContentHook(newHookImpl) {
5961
6227
  sanitizeHtmlContentHook = newHookImpl;
@@ -6068,7 +6334,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6068
6334
  start(markName);
6069
6335
  }
6070
6336
  if (isProfilerEnabled) {
6071
- currentDispatcher(opId, 0 /* Phase.Start */, vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
6337
+ currentDispatcher(opId, 0 /* Phase.Start */, vm?.tagName, vm?.idx, vm?.renderMode, vm?.shadowMode);
6072
6338
  }
6073
6339
  }
6074
6340
  function logGlobalOperationEnd(opId, vm) {
@@ -6078,7 +6344,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6078
6344
  end(opName, markName);
6079
6345
  }
6080
6346
  if (isProfilerEnabled) {
6081
- currentDispatcher(opId, 1 /* Phase.Stop */, vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
6347
+ currentDispatcher(opId, 1 /* Phase.Stop */, vm?.tagName, vm?.idx, vm?.renderMode, vm?.shadowMode);
6082
6348
  }
6083
6349
  }
6084
6350
 
@@ -6102,7 +6368,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6102
6368
  cmpSlots
6103
6369
  } = vm;
6104
6370
  for (const slotName in cmpSlots.slotAssignments) {
6105
- // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
6106
6371
  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}.`);
6107
6372
  }
6108
6373
  }
@@ -6121,9 +6386,27 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6121
6386
  }
6122
6387
  }
6123
6388
  }
6389
+ // This should be a no-op outside of LWC's Karma tests, where it's not needed
6390
+ let registerFragmentCache = noop;
6391
+ // Only used in LWC's Karma tests
6392
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
6393
+ // Keep track of fragmentCaches, so we can clear them in LWC's Karma tests
6394
+ const fragmentCaches = [];
6395
+ registerFragmentCache = fragmentCache => {
6396
+ fragmentCaches.push(fragmentCache);
6397
+ };
6398
+ window.__lwcResetFragmentCaches = () => {
6399
+ for (const fragmentCache of fragmentCaches) {
6400
+ for (const key of keys(fragmentCache)) {
6401
+ delete fragmentCache[key];
6402
+ }
6403
+ }
6404
+ };
6405
+ }
6124
6406
  function buildParseFragmentFn(createFragmentFn) {
6125
6407
  return (strings, ...keys) => {
6126
6408
  const cache = create(null);
6409
+ registerFragmentCache(cache);
6127
6410
  return function () {
6128
6411
  const {
6129
6412
  context: {
@@ -6144,11 +6427,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6144
6427
  if (hasStyleToken && isSyntheticShadow) {
6145
6428
  cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
6146
6429
  }
6147
- if (hasLegacyToken) {
6148
- // This isn't strictly required for prod, but it's required for our karma tests
6149
- // since the lwcRuntimeFlag may change over time
6150
- cacheKey |= 4 /* FragmentCache.HAS_LEGACY_SCOPE_TOKEN */;
6151
- }
6152
6430
  if (!isUndefined$1(cache[cacheKey])) {
6153
6431
  return cache[cacheKey];
6154
6432
  }
@@ -6201,7 +6479,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6201
6479
  });
6202
6480
  function evaluateTemplate(vm, html) {
6203
6481
  if (process.env.NODE_ENV !== 'production') {
6204
- assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
6205
6482
  // in dev-mode, we support hot swapping of templates, which means that
6206
6483
  // the component instance might be attempting to use an old version of
6207
6484
  // the template, while internally, we have a replacement for it.
@@ -6226,6 +6503,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6226
6503
  tro.observe(() => {
6227
6504
  // Reset the cache memoizer for template when needed.
6228
6505
  if (html !== cmpTemplate) {
6506
+ // Check that the template was built by the compiler.
6507
+ if (!isTemplateRegistered(html)) {
6508
+ throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
6509
+ }
6229
6510
  if (process.env.NODE_ENV !== 'production') {
6230
6511
  validateLightDomTemplate(html, vm);
6231
6512
  }
@@ -6237,10 +6518,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6237
6518
  // and snabbdom just rely on the IDs.
6238
6519
  resetComponentRoot(vm);
6239
6520
  }
6240
- // Check that the template was built by the compiler.
6241
- if (!isTemplateRegistered(html)) {
6242
- throw new TypeError(`Invalid template returned by the render() method on ${vm}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
6243
- }
6244
6521
  vm.cmpTemplate = html;
6245
6522
  // Create a brand new template cache for the swapped templated.
6246
6523
  context.tplCache = create(null);
@@ -6417,6 +6694,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6417
6694
  /**
6418
6695
  * INTERNAL: This function can only be invoked by compiled code. The compiler
6419
6696
  * will prevent this function from being imported by userland code.
6697
+ * @param Ctor
6698
+ * @param metadata
6420
6699
  */
6421
6700
  function registerComponent(
6422
6701
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
@@ -6435,16 +6714,14 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6435
6714
  return Ctor;
6436
6715
  }
6437
6716
  function getComponentRegisteredTemplate(Ctor) {
6438
- var _a;
6439
- return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.tmpl;
6717
+ return registeredComponentMap.get(Ctor)?.tmpl;
6440
6718
  }
6441
6719
  function getComponentRegisteredName(Ctor) {
6442
- var _a;
6443
- return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
6720
+ return registeredComponentMap.get(Ctor)?.sel;
6444
6721
  }
6445
6722
  function getComponentAPIVersion(Ctor) {
6446
6723
  const metadata = registeredComponentMap.get(Ctor);
6447
- const apiVersion = metadata === null || metadata === void 0 ? void 0 : metadata.apiVersion;
6724
+ const apiVersion = metadata?.apiVersion;
6448
6725
  if (isUndefined$1(apiVersion)) {
6449
6726
  // This should only occur in our Karma tests; in practice every component
6450
6727
  // is registered, and so this code path should not get hit. But to be safe,
@@ -6464,11 +6741,30 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6464
6741
  }
6465
6742
  });
6466
6743
  }
6744
+ function resetTemplateObserverAndUnsubscribe(vm) {
6745
+ const {
6746
+ tro,
6747
+ component
6748
+ } = vm;
6749
+ tro.reset();
6750
+ // Unsubscribe every time the template reactive observer is reset.
6751
+ if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS) {
6752
+ unsubscribeFromSignals(component);
6753
+ }
6754
+ }
6467
6755
  function renderComponent(vm) {
6468
6756
  if (process.env.NODE_ENV !== 'production') {
6469
6757
  assert.invariant(vm.isDirty, `${vm} is not dirty.`);
6470
6758
  }
6471
- vm.tro.reset();
6759
+ // The engine should only hold a subscription to a signal if it is rendered in the template.
6760
+ // Because of the potential presence of conditional rendering logic, we unsubscribe on each render
6761
+ // in the scenario where it is present in one condition but not the other.
6762
+ // For example:
6763
+ // 1. There is an lwc:if=true conditional where the signal is present on the template.
6764
+ // 2. The lwc:if changes to false and the signal is no longer present on the template.
6765
+ // If the signal is still subscribed to, the template will re-render when it receives a notification
6766
+ // from the signal, even though we won't be using the new value.
6767
+ resetTemplateObserverAndUnsubscribe(vm);
6472
6768
  const vnodes = invokeComponentRenderMethod(vm);
6473
6769
  vm.isDirty = false;
6474
6770
  vm.isScheduled = false;
@@ -6499,7 +6795,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6499
6795
  }
6500
6796
 
6501
6797
  /*
6502
- * Copyright (c) 2023, Salesforce.com, inc.
6798
+ * Copyright (c) 2024, Salesforce, Inc.
6503
6799
  * All rights reserved.
6504
6800
  * SPDX-License-Identifier: MIT
6505
6801
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -6545,11 +6841,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6545
6841
  state
6546
6842
  } = vm;
6547
6843
  if (state !== 2 /* VMState.disconnected */) {
6548
- const {
6549
- tro
6550
- } = vm;
6551
6844
  // Making sure that any observing record will not trigger the rehydrated on this vm
6552
- tro.reset();
6845
+ resetTemplateObserverAndUnsubscribe(vm);
6553
6846
  runDisconnectedCallback(vm);
6554
6847
  // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
6555
6848
  runChildNodesDisconnectedCallback(vm);
@@ -6560,7 +6853,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6560
6853
  // old vnode.children is removed from the DOM.
6561
6854
  function removeVM(vm) {
6562
6855
  if (process.env.NODE_ENV !== 'production') {
6563
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6856
+ if (!shouldUseNativeCustomElementLifecycle(vm.component.constructor)) {
6564
6857
  // With native lifecycle, we cannot be certain that connectedCallback was called before a component
6565
6858
  // was removed from the VDOM. If the component is disconnected, then connectedCallback will not fire
6566
6859
  // in native mode, although it will fire in synthetic mode due to appendChild triggering it.
@@ -6640,7 +6933,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6640
6933
  vm.debugInfo = create(null);
6641
6934
  }
6642
6935
  vm.stylesheets = computeStylesheets(vm, def.ctor);
6643
- const computedShadowMode = computeShadowMode(def, vm.owner, renderer);
6936
+ const computedShadowMode = computeShadowMode(def, vm.owner, renderer, hydrated);
6644
6937
  if (lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
6645
6938
  vm.shadowMode = 0 /* ShadowMode.Native */;
6646
6939
  vm.shadowMigrateMode = computedShadowMode === 1 /* ShadowMode.Synthetic */;
@@ -6728,45 +7021,44 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6728
7021
  renderMode
6729
7022
  } = def;
6730
7023
  // Assume null `owner` - this is what happens in hydration cases anyway
6731
- const shadowMode = computeShadowMode(def, /* owner */null, renderer);
7024
+ // Also assume we are not in hydration mode for this exported API
7025
+ const shadowMode = computeShadowMode(def, /* owner */null, renderer, false);
6732
7026
  return {
6733
7027
  renderMode,
6734
7028
  shadowMode
6735
7029
  };
6736
7030
  }
6737
- function computeShadowMode(def, owner, renderer) {
7031
+ function computeShadowMode(def, owner, renderer, hydrated) {
7032
+ if (
6738
7033
  // Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
6739
7034
  // on, but components running in actual native shadow mode
6740
- if (process.env.NODE_ENV !== 'production' && lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
7035
+ process.env.NODE_ENV === 'test-karma-lwc' && process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST ||
7036
+ // hydration only supports native shadow
7037
+ isTrue(hydrated)) {
6741
7038
  return 0 /* ShadowMode.Native */;
6742
7039
  }
6743
7040
  const {
6744
7041
  isSyntheticShadowDefined
6745
7042
  } = renderer;
6746
7043
  let shadowMode;
6747
- // If ENABLE_FORCE_SHADOW_MIGRATE_MODE is true, then ShadowMode.Synthetic here will mean "force-migrate" mode.
6748
7044
  if (isSyntheticShadowDefined || lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
6749
7045
  if (def.renderMode === 0 /* RenderMode.Light */) {
6750
7046
  // ShadowMode.Native implies "not synthetic shadow" which is consistent with how
6751
7047
  // everything defaults to native when the synthetic shadow polyfill is unavailable.
6752
7048
  shadowMode = 0 /* ShadowMode.Native */;
6753
- } else if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE || def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6754
- if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */ || def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
7049
+ } else if (def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
7050
+ shadowMode = 0 /* ShadowMode.Native */;
7051
+ } else {
7052
+ const shadowAncestor = getNearestShadowAncestor(owner);
7053
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
7054
+ // Transitive support for native Shadow DOM. A component in native mode
7055
+ // transitively opts all of its descendants into native.
6755
7056
  shadowMode = 0 /* ShadowMode.Native */;
6756
7057
  } else {
6757
- const shadowAncestor = getNearestShadowAncestor(owner);
6758
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
6759
- // Transitive support for native Shadow DOM. A component in native mode
6760
- // transitively opts all of its descendants into native.
6761
- shadowMode = 0 /* ShadowMode.Native */;
6762
- } else {
6763
- // Synthetic if neither this component nor any of its ancestors are configured
6764
- // to be native.
6765
- shadowMode = 1 /* ShadowMode.Synthetic */;
6766
- }
7058
+ // Synthetic if neither this component nor any of its ancestors are configured
7059
+ // to be native.
7060
+ shadowMode = 1 /* ShadowMode.Synthetic */;
6767
7061
  }
6768
- } else {
6769
- shadowMode = 1 /* ShadowMode.Synthetic */;
6770
7062
  }
6771
7063
  } else {
6772
7064
  // Native if the synthetic shadow polyfill is unavailable.
@@ -6775,7 +7067,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6775
7067
  return shadowMode;
6776
7068
  }
6777
7069
  function assertIsVM(obj) {
6778
- if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
7070
+ if (!isObject(obj) || isNull(obj) || !('renderRoot' in obj)) {
6779
7071
  throw new TypeError(`${obj} is not a VM.`);
6780
7072
  }
6781
7073
  }
@@ -6874,7 +7166,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6874
7166
  logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
6875
7167
  // re-throwing the original error will break the current tick, but since the next tick is
6876
7168
  // already scheduled, it should continue patching the rest.
6877
- throw error; // eslint-disable-line no-unsafe-finally
7169
+ throw error;
6878
7170
  }
6879
7171
  }
6880
7172
  logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
@@ -6900,7 +7192,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6900
7192
  }
6901
7193
  // This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
6902
7194
  // we're in dev mode. This is to detect a particular issue with synthetic lifecycle.
6903
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE && (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
7195
+ if (!shouldUseNativeCustomElementLifecycle(vm.component.constructor) && (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
6904
7196
  if (!vm.renderer.isConnected(vm.elm)) {
6905
7197
  if (process.env.NODE_ENV !== 'production') {
6906
7198
  logWarnOnce(`Element <${vm.tagName}> ` + `fired a \`connectedCallback\` and rendered, but was not connected to the DOM. ` + `Please ensure all components are actually connected to the DOM, e.g. using ` + `\`document.body.appendChild(element)\`. This will not be supported in future versions of ` + `LWC and could cause component errors. For details, see: https://sfdc.co/synthetic-lifecycle`);
@@ -6978,6 +7270,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6978
7270
  * need to continue into its children because by attempting to disconnect the
6979
7271
  * custom element itself will trigger the removal of anything slotted or anything
6980
7272
  * defined on its shadow.
7273
+ * @param vnodes
6981
7274
  */
6982
7275
  function recursivelyDisconnectChildren(vnodes) {
6983
7276
  for (let i = 0, len = vnodes.length; i < len; i += 1) {
@@ -7097,18 +7390,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7097
7390
  function runFormAssociatedCustomElementCallback(vm, faceCb) {
7098
7391
  const {
7099
7392
  renderMode,
7100
- shadowMode,
7101
- def: {
7102
- formAssociated
7103
- }
7393
+ shadowMode
7104
7394
  } = vm;
7105
- // Technically the UpgradableConstructor always sets `static formAssociated = true` but silently fail here to match browser behavior.
7106
- if (isUndefined$1(formAssociated) || isFalse(formAssociated)) {
7107
- if (process.env.NODE_ENV !== 'production') {
7108
- logWarn(`Form associated lifecycle methods must have the 'static formAssociated' value set in the component's prototype chain.`);
7109
- }
7110
- return;
7111
- }
7112
7395
  if (shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode !== 0 /* RenderMode.Light */) {
7113
7396
  throw new Error('Form associated lifecycle methods are not available in synthetic shadow. Please use native shadow or light DOM.');
7114
7397
  }
@@ -7170,12 +7453,12 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7170
7453
  // See: https://sfdc.co/synthetic-aria
7171
7454
  //
7172
7455
  // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
7173
- const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
7174
- const querySelectorAll = _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
7456
+ const getElementById = globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
7457
+ const querySelectorAll = globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
7175
7458
  // This is a "handoff" from synthetic-shadow to engine-core – we want to clean up after ourselves
7176
7459
  // so nobody else can misuse these global APIs.
7177
- delete _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
7178
- delete _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
7460
+ delete globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
7461
+ delete globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
7179
7462
  function isSyntheticShadowRootInstance(rootNode) {
7180
7463
  return rootNode !== document && isTrue(rootNode.synthetic);
7181
7464
  }
@@ -7363,7 +7646,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7363
7646
  setValueType = isNull(setValue) ? 'null' : typeof setValue;
7364
7647
  }
7365
7648
  report("NonStandardAriaReflection" /* ReportingEventId.NonStandardAriaReflection */, {
7366
- tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
7649
+ tagName: vm?.tagName,
7367
7650
  propertyName: prop,
7368
7651
  isSetter,
7369
7652
  setValueType
@@ -7384,7 +7667,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7384
7667
  throw new Error('detect-non-standard-aria.ts loaded before @lwc/aria-reflection');
7385
7668
  }
7386
7669
  }
7387
- // @ts-ignore
7388
7670
  const {
7389
7671
  get,
7390
7672
  set
@@ -7448,7 +7730,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7448
7730
  runRenderedCallback(vm);
7449
7731
  }
7450
7732
  function hydrateNode(node, vnode, renderer) {
7451
- var _a, _b;
7452
7733
  let hydratedNode;
7453
7734
  switch (vnode.type) {
7454
7735
  case 0 /* VNodeType.Text */:
@@ -7468,10 +7749,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7468
7749
  hydratedNode = hydrateFragment(node, vnode, renderer);
7469
7750
  break;
7470
7751
  case 2 /* VNodeType.Element */:
7471
- hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
7752
+ hydratedNode = hydrateElement(node, vnode, vnode.data.renderer ?? renderer);
7472
7753
  break;
7473
7754
  case 3 /* VNodeType.CustomElement */:
7474
- hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
7755
+ hydratedNode = hydrateCustomElement(node, vnode, vnode.data.renderer ?? renderer);
7475
7756
  break;
7476
7757
  }
7477
7758
  return renderer.nextSibling(hydratedNode);
@@ -7516,7 +7797,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7516
7797
  return _attrName => true;
7517
7798
  }
7518
7799
  function hydrateText(node, vnode, renderer) {
7519
- var _a;
7520
7800
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
7521
7801
  return handleMismatch(node, vnode, renderer);
7522
7802
  }
@@ -7528,12 +7808,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7528
7808
  const {
7529
7809
  setText
7530
7810
  } = renderer;
7531
- setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
7811
+ setText(node, vnode.text ?? null);
7532
7812
  vnode.elm = node;
7533
7813
  return node;
7534
7814
  }
7535
7815
  function hydrateComment(node, vnode, renderer) {
7536
- var _a;
7537
7816
  if (!hasCorrectNodeType(vnode, node, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
7538
7817
  return handleMismatch(node, vnode, renderer);
7539
7818
  }
@@ -7549,7 +7828,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7549
7828
  const {
7550
7829
  setProperty
7551
7830
  } = renderer;
7552
- setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
7831
+ setProperty(node, NODE_VALUE_PROP, vnode.text ?? null);
7553
7832
  vnode.elm = node;
7554
7833
  return node;
7555
7834
  }
@@ -7558,7 +7837,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7558
7837
  return handleMismatch(elm, vnode, renderer);
7559
7838
  }
7560
7839
  vnode.elm = elm;
7561
- applyStaticParts(elm, vnode, renderer, true);
7840
+ mountStaticParts(elm, vnode, renderer);
7562
7841
  return elm;
7563
7842
  }
7564
7843
  function hydrateFragment(elm, vnode, renderer) {
@@ -7595,9 +7874,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7595
7874
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
7596
7875
  if (getProperty(elm, 'innerHTML') === props.innerHTML) {
7597
7876
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
7598
- vnode.data = Object.assign(Object.assign({}, vnode.data), {
7877
+ vnode.data = {
7878
+ ...vnode.data,
7599
7879
  props: cloneAndOmitKey(props, 'innerHTML')
7600
- });
7880
+ };
7601
7881
  } else {
7602
7882
  if (process.env.NODE_ENV !== 'production') {
7603
7883
  logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
@@ -7641,7 +7921,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7641
7921
  defineCustomElement,
7642
7922
  getTagName
7643
7923
  } = renderer;
7644
- defineCustomElement(StringToLowerCase.call(getTagName(elm)));
7924
+ const isFormAssociated = shouldBeFormAssociated(ctor);
7925
+ defineCustomElement(StringToLowerCase.call(getTagName(elm)), isFormAssociated);
7645
7926
  const vm = createVM(elm, ctor, renderer, {
7646
7927
  mode,
7647
7928
  owner,
@@ -7844,11 +8125,15 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
7844
8125
  const classNames = ArrayFilter.call(classTokens, token => !isNull(token));
7845
8126
  className = ArrayJoin.call(classNames, ' ');
7846
8127
  } else if (!isUndefined$1(classMap)) {
7847
- classMap = Object.assign(Object.assign(Object.assign({}, classMap), !isNull(scopedToken) ? {
7848
- [scopedToken]: true
7849
- } : {}), !isNull(stylesheetTokenHost) ? {
7850
- [stylesheetTokenHost]: true
7851
- } : {});
8128
+ classMap = {
8129
+ ...classMap,
8130
+ ...(!isNull(scopedToken) ? {
8131
+ [scopedToken]: true
8132
+ } : {}),
8133
+ ...(!isNull(stylesheetTokenHost) ? {
8134
+ [stylesheetTokenHost]: true
8135
+ } : {})
8136
+ };
7852
8137
  } else {
7853
8138
  // The order of the className should be scopedToken stylesheetTokenHost
7854
8139
  const classTokens = [scopedToken, stylesheetTokenHost];
@@ -8053,7 +8338,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8053
8338
  const originalArrayMethod = getOriginalArrayMethod(prop);
8054
8339
  stylesheets[prop] = function arrayMutationWarningWrapper() {
8055
8340
  reportTemplateViolation('stylesheets');
8056
- // @ts-ignore
8341
+ // @ts-expect-error can't properly determine the right `this`
8057
8342
  return originalArrayMethod.apply(this, arguments);
8058
8343
  };
8059
8344
  }
@@ -8199,6 +8484,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8199
8484
  /**
8200
8485
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8201
8486
  * This API is subject to change or being removed.
8487
+ * @param elm
8202
8488
  */
8203
8489
  function getComponentConstructor(elm) {
8204
8490
  let ctor = null;
@@ -8223,6 +8509,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8223
8509
  * EXPERIMENTAL: This function allows you to create a reactive readonly
8224
8510
  * membrane around any object value. This API is subject to change or
8225
8511
  * being removed.
8512
+ * @param obj
8226
8513
  */
8227
8514
  function readonly(obj) {
8228
8515
  if (process.env.NODE_ENV !== 'production') {
@@ -8233,7 +8520,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8233
8520
  }
8234
8521
  return getReadOnlyProxy(obj);
8235
8522
  }
8236
- /** version: 5.2.1 */
8523
+ /** version: 6.3.4 */
8237
8524
 
8238
8525
  /*
8239
8526
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8243,8 +8530,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8243
8530
  */
8244
8531
  /**
8245
8532
  * Displays the header for a custom element.
8246
- *
8247
- * @param ce the custom element
8533
+ * @param ce The custom element to get the header for.
8248
8534
  * @param componentInstance component instance associated with the custom element.
8249
8535
  */
8250
8536
  function getHeaderForCustomElement(ce, componentInstance) {
@@ -8304,9 +8590,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8304
8590
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8305
8591
  */
8306
8592
  function init() {
8307
- const devtoolsFormatters = _globalThis.devtoolsFormatters || [];
8593
+ const devtoolsFormatters = globalThis.devtoolsFormatters || [];
8308
8594
  ArrayPush$1.call(devtoolsFormatters, LightningElementFormatter);
8309
- _globalThis.devtoolsFormatters = devtoolsFormatters;
8595
+ globalThis.devtoolsFormatters = devtoolsFormatters;
8310
8596
  }
8311
8597
  if (process.env.NODE_ENV !== 'production') {
8312
8598
  init();
@@ -8331,7 +8617,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8331
8617
  //
8332
8618
  // Only used in LWC's Karma tests
8333
8619
  if (process.env.NODE_ENV === 'test-karma-lwc') {
8334
- // @ts-ignore
8335
8620
  window.__lwcResetGlobalStylesheets = () => {
8336
8621
  stylesheetCache.clear();
8337
8622
  };
@@ -8448,80 +8733,82 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8448
8733
  * SPDX-License-Identifier: MIT
8449
8734
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8450
8735
  */
8451
- const cachedConstructors = new Map();
8452
- const elementsUpgradedOutsideLWC = new WeakSet();
8453
- let elementBeingUpgradedByLWC = false;
8454
- const lifecycleCallbacks = lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE ? {
8736
+ const LIFECYCLE_CALLBACKS = {
8455
8737
  connectedCallback: connectRootElement,
8456
8738
  disconnectedCallback: disconnectRootElement,
8457
8739
  formAssociatedCallback: runFormAssociatedCallback,
8458
8740
  formDisabledCallback: runFormDisabledCallback,
8459
8741
  formResetCallback: runFormResetCallback,
8460
8742
  formStateRestoreCallback: runFormStateRestoreCallback
8461
- } : undefined;
8743
+ };
8744
+ const cachedConstructors = new Map();
8745
+ const nativeLifecycleElementsToUpgradedByLWC = new WeakMap();
8746
+ let elementBeingUpgradedByLWC = false;
8462
8747
  // Creates a constructor that is intended to be used directly as a custom element, except that the upgradeCallback is
8463
8748
  // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
8464
8749
  // Another benefit is that only LWC can create components that actually do anything – if you do
8465
8750
  // `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
8466
8751
  // This class should be created once per tag name.
8467
- const createUpgradableConstructor = () => {
8752
+ const createUpgradableConstructor = isFormAssociated => {
8468
8753
  // TODO [#2972]: this class should expose observedAttributes as necessary
8469
8754
  class UpgradableConstructor extends HTMLElement {
8470
- constructor(upgradeCallback) {
8755
+ constructor(upgradeCallback, useNativeLifecycle) {
8471
8756
  super();
8757
+ if (useNativeLifecycle) {
8758
+ // When in native lifecycle mode, we need to keep track of instances that were created outside LWC
8759
+ // (i.e. not created by `lwc.createElement()`). If the element uses synthetic lifecycle, then we don't
8760
+ // need to track this.
8761
+ nativeLifecycleElementsToUpgradedByLWC.set(this, elementBeingUpgradedByLWC);
8762
+ }
8472
8763
  // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
8473
- // then elementBeingUpgraded will be false
8764
+ // then elementBeingUpgradedByLWC will be false
8474
8765
  if (elementBeingUpgradedByLWC) {
8475
8766
  upgradeCallback(this);
8476
- } else if (!isUndefined$1(lifecycleCallbacks)) {
8477
- // If this element has any lifecycle callbacks, then we need to keep track of
8478
- // instances that were created outside LWC (i.e. not created by `lwc.createElement()`).
8479
- // If the element has no connected or disconnected callbacks, then we don't need to track this.
8480
- elementsUpgradedOutsideLWC.add(this);
8481
- // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
8482
- // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8483
- }
8484
- }
8485
- /*LWC compiler v5.2.1*/
8486
- }
8487
- UpgradableConstructor.formAssociated = true;
8488
- // Do not unnecessarily add a connectedCallback/disconnectedCallback/etc., as it introduces perf overhead
8489
- // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
8490
- if (!isUndefined$1(lifecycleCallbacks)) {
8491
- for (const [propName, callback] of entries(lifecycleCallbacks)) {
8492
- UpgradableConstructor.prototype[propName] = function () {
8493
- if (!elementsUpgradedOutsideLWC.has(this)) {
8494
- callback(this);
8495
- }
8496
- };
8767
+ }
8768
+ // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
8769
+ // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8497
8770
  }
8771
+ /*LWC compiler v6.3.4*/
8772
+ }
8773
+ UpgradableConstructor.formAssociated = isFormAssociated;
8774
+ for (const [propName, callback] of entries(LIFECYCLE_CALLBACKS)) {
8775
+ UpgradableConstructor.prototype[propName] = function () {
8776
+ // If the element is in the WeakMap (i.e. it's marked as native lifecycle), and if it was upgraded by LWC,
8777
+ // then it can use native lifecycle
8778
+ if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
8779
+ callback(this);
8780
+ }
8781
+ };
8498
8782
  }
8499
8783
  return UpgradableConstructor;
8500
8784
  };
8501
- function getUpgradableConstructor(tagName) {
8785
+ function getUpgradableConstructor(tagName, isFormAssociated) {
8502
8786
  let UpgradableConstructor = cachedConstructors.get(tagName);
8503
8787
  if (isUndefined$1(UpgradableConstructor)) {
8504
8788
  if (!isUndefined$1(customElements.get(tagName))) {
8505
8789
  throw new Error(`Unexpected tag name "${tagName}". This name is a registered custom element, preventing LWC to upgrade the element.`);
8506
8790
  }
8507
- UpgradableConstructor = createUpgradableConstructor();
8791
+ UpgradableConstructor = createUpgradableConstructor(isFormAssociated);
8508
8792
  customElements.define(tagName, UpgradableConstructor);
8509
8793
  cachedConstructors.set(tagName, UpgradableConstructor);
8510
8794
  }
8511
8795
  return UpgradableConstructor;
8512
8796
  }
8513
- const createCustomElement = (tagName, upgradeCallback) => {
8514
- const UpgradableConstructor = getUpgradableConstructor(tagName);
8797
+ const createCustomElement = (tagName, upgradeCallback, useNativeLifecycle, isFormAssociated) => {
8798
+ const UpgradableConstructor = getUpgradableConstructor(tagName, isFormAssociated);
8515
8799
  elementBeingUpgradedByLWC = true;
8516
8800
  try {
8517
- return new UpgradableConstructor(upgradeCallback);
8801
+ if (UpgradableConstructor.formAssociated !== isFormAssociated) {
8802
+ throw new Error(`<${tagName}> was already registered with formAssociated=${UpgradableConstructor.formAssociated}. It cannot be re-registered with formAssociated=${isFormAssociated}. Please rename your component to have a different name than <${tagName}>`);
8803
+ }
8804
+ return new UpgradableConstructor(upgradeCallback, useNativeLifecycle);
8518
8805
  } finally {
8519
8806
  elementBeingUpgradedByLWC = false;
8520
8807
  }
8521
8808
  };
8522
8809
 
8523
8810
  /*
8524
- * Copyright (c) 2023, Salesforce.com, inc.
8811
+ * Copyright (c) 2024, Salesforce, Inc.
8525
8812
  * All rights reserved.
8526
8813
  * SPDX-License-Identifier: MIT
8527
8814
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -8530,16 +8817,18 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8530
8817
  * A factory function that produces a renderer.
8531
8818
  * Renderer encapsulates operations that are required to render an LWC component into the underlying
8532
8819
  * runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
8533
- * Example usage:
8820
+ * @param baseRenderer Either null or the base renderer imported from 'lwc'.
8821
+ * @returns The created renderer
8822
+ * @example
8534
8823
  * import { renderer, rendererFactory } from 'lwc';
8535
8824
  * const customRenderer = rendererFactory(renderer);
8536
- *
8537
- * @param baseRenderer Either null or the base renderer imported from 'lwc'.
8538
8825
  */
8539
8826
  function rendererFactory(baseRenderer) {
8827
+ // Type assertion because this is replaced by rollup with an object, not a string.
8828
+ // See `injectInlineRenderer` in /scripts/rollup/rollup.config.js
8540
8829
  const renderer = function (exports) {
8541
8830
  /**
8542
- * Copyright (C) 2023 salesforce.com, inc.
8831
+ * Copyright (c) 2024 Salesforce, Inc.
8543
8832
  */
8544
8833
  /*
8545
8834
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8547,21 +8836,40 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8547
8836
  * SPDX-License-Identifier: MIT
8548
8837
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8549
8838
  */
8839
+ /**
8840
+ *
8841
+ * @param value
8842
+ * @param msg
8843
+ */
8550
8844
  function invariant(value, msg) {
8551
8845
  if (!value) {
8552
8846
  throw new Error(`Invariant Violation: ${msg}`);
8553
8847
  }
8554
8848
  }
8849
+ /**
8850
+ *
8851
+ * @param value
8852
+ * @param msg
8853
+ */
8555
8854
  function isTrue$1(value, msg) {
8556
8855
  if (!value) {
8557
8856
  throw new Error(`Assert Violation: ${msg}`);
8558
8857
  }
8559
8858
  }
8859
+ /**
8860
+ *
8861
+ * @param value
8862
+ * @param msg
8863
+ */
8560
8864
  function isFalse$1(value, msg) {
8561
8865
  if (value) {
8562
8866
  throw new Error(`Assert Violation: ${msg}`);
8563
8867
  }
8564
8868
  }
8869
+ /**
8870
+ *
8871
+ * @param msg
8872
+ */
8565
8873
  function fail(msg) {
8566
8874
  throw new Error(msg);
8567
8875
  }
@@ -8572,13 +8880,23 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8572
8880
  isFalse: isFalse$1,
8573
8881
  isTrue: isTrue$1
8574
8882
  });
8883
+ /**
8884
+ * Determines whether the argument is `undefined`.
8885
+ * @param obj Value to test
8886
+ * @returns `true` if the value is `undefined`.
8887
+ */
8575
8888
  function isUndefined(obj) {
8576
8889
  return obj === undefined;
8577
8890
  }
8891
+ /**
8892
+ * Determines whether the argument is `null`.
8893
+ * @param obj Value to test
8894
+ * @returns `true` if the value is `null`.
8895
+ */
8578
8896
  function isNull(obj) {
8579
8897
  return obj === null;
8580
8898
  }
8581
- /** version: 5.2.1 */
8899
+ /** version: 6.3.4 */
8582
8900
 
8583
8901
  /*
8584
8902
  * Copyright (c) 2023, salesforce.com, inc.
@@ -8598,7 +8916,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8598
8916
  this.setNewContext = setNewContext;
8599
8917
  this.setDisconnectedCallback = setDisconnectedCallback;
8600
8918
  }
8601
- /*LWC compiler v5.2.1*/
8919
+ /*LWC compiler v6.3.4*/
8602
8920
  }
8603
8921
  function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
8604
8922
  dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
@@ -8857,6 +9175,18 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8857
9175
  }
8858
9176
  return vm;
8859
9177
  }
9178
+ /**
9179
+ * Replaces an existing DOM node with an LWC component.
9180
+ * @param element The existing node in the DOM that where the root component should be attached.
9181
+ * @param Ctor The LWC class to use as the root component.
9182
+ * @param props Any props for the root component as part of initial client-side rendering. The props must be identical to those passed to renderComponent during SSR.
9183
+ * @throws Throws when called with invalid parameters.
9184
+ * @example
9185
+ * import { hydrateComponent } from 'lwc';
9186
+ * import App from 'x/App';
9187
+ * const elm = document.querySelector('x-app');
9188
+ * hydrateComponent(elm, App, { name: 'Hello World' });
9189
+ */
8860
9190
  function hydrateComponent(element, Ctor, props = {}) {
8861
9191
  if (!(element instanceof Element)) {
8862
9192
  throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
@@ -8877,7 +9207,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8877
9207
  defineCustomElement,
8878
9208
  getTagName
8879
9209
  } = renderer;
8880
- defineCustomElement(StringToLowerCase.call(getTagName(element)));
9210
+ const isFormAssociated = shouldBeFormAssociated(Ctor);
9211
+ defineCustomElement(StringToLowerCase.call(getTagName(element)), isFormAssociated);
8881
9212
  const vm = createVMWithProps(element, Ctor, props);
8882
9213
  hydrateRoot(vm);
8883
9214
  } catch (e) {
@@ -8902,17 +9233,15 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8902
9233
  /**
8903
9234
  * This function builds a Web Component class from a LWC constructor so it can be
8904
9235
  * registered as a new element via customElements.define() at any given time.
8905
- *
8906
- * @deprecated since version 1.3.11
8907
- *
9236
+ * @param Ctor LWC constructor to build
9237
+ * @returns A Web Component class
8908
9238
  * @example
8909
- * ```
8910
9239
  * import { buildCustomElementConstructor } from 'lwc';
8911
9240
  * import Foo from 'ns/foo';
8912
9241
  * const WC = buildCustomElementConstructor(Foo);
8913
9242
  * customElements.define('x-foo', WC);
8914
9243
  * const elm = document.createElement('x-foo');
8915
- * ```
9244
+ * @deprecated since version 1.3.11
8916
9245
  */
8917
9246
  function deprecatedBuildCustomElementConstructor(Ctor) {
8918
9247
  if (process.env.NODE_ENV !== 'production') {
@@ -8927,6 +9256,13 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8927
9256
  renderer.remove(childNodes[i], node);
8928
9257
  }
8929
9258
  }
9259
+ /**
9260
+ * The real `buildCustomElementConstructor`. Should not be accessible to external users!
9261
+ * @internal
9262
+ * @param Ctor LWC constructor to build
9263
+ * @returns A Web Component class
9264
+ * @see {@linkcode deprecatedBuildCustomElementConstructor}
9265
+ */
8930
9266
  function buildCustomElementConstructor(Ctor) {
8931
9267
  var _a;
8932
9268
  const HtmlPrototype = getComponentHtmlPrototype(Ctor);
@@ -8978,8 +9314,23 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8978
9314
  attributeChangedCallback(name, oldValue, newValue) {
8979
9315
  attributeChangedCallback.call(this, name, oldValue, newValue);
8980
9316
  }
8981
- /*LWC compiler v5.2.1*/
8982
- }, _a.observedAttributes = observedAttributes, _a;
9317
+ formAssociatedCallback() {
9318
+ runFormAssociatedCallback(this);
9319
+ }
9320
+ formDisabledCallback() {
9321
+ runFormDisabledCallback(this);
9322
+ }
9323
+ formResetCallback() {
9324
+ runFormResetCallback(this);
9325
+ }
9326
+ formStateRestoreCallback() {
9327
+ runFormStateRestoreCallback(this);
9328
+ }
9329
+ /*LWC compiler v6.3.4*/
9330
+ }, _a.observedAttributes = observedAttributes,
9331
+ // Note CustomElementConstructor is not upgraded by LWC and inherits directly from HTMLElement which means it calls the native
9332
+ // attachInternals API.
9333
+ _a.formAssociated = Boolean(Ctor.formAssociated), _a;
8983
9334
  }
8984
9335
 
8985
9336
  /*
@@ -9003,7 +9354,13 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9003
9354
  }
9004
9355
  return node; // for convenience
9005
9356
  }
9006
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
9357
+ let monkeyPatched = false;
9358
+ function monkeyPatchDomAPIs() {
9359
+ if (monkeyPatched) {
9360
+ // don't double-patch
9361
+ return;
9362
+ }
9363
+ monkeyPatched = true;
9007
9364
  // Monkey patching Node methods to be able to detect the insertions and removal of root elements
9008
9365
  // created via createElement.
9009
9366
  const {
@@ -9033,18 +9390,25 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9033
9390
  }
9034
9391
  });
9035
9392
  }
9393
+ // For some reason, JSDOC says "options.is" is a syntax error. And we can't disable the rule using
9394
+ // `eslint-disable-next-line` because that gets included in the JSDOC, so we need this workaround.
9395
+ /* eslint-disable jsdoc/valid-types */
9036
9396
  /**
9037
9397
  * EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
9038
9398
  * difference that in the options, you can pass the `is` property set to a Constructor instead of
9039
9399
  * just a string value. The intent is to allow the creation of an element controlled by LWC without
9040
9400
  * having to register the element as a custom element.
9041
- *
9401
+ * @param sel The tagname of the element to create
9402
+ * @param options Control the behavior of the created element
9403
+ * @param options.is The LWC component that the element should be
9404
+ * @param options.mode What kind of shadow root to use
9405
+ * @returns The created HTML element
9406
+ * @throws Throws when called with invalid parameters.
9042
9407
  * @example
9043
- * ```
9044
9408
  * const el = createElement('x-foo', { is: FooCtor });
9045
- * ```
9046
9409
  */
9047
- function createElement(sel, options) {
9410
+ function createElement( /* eslint-enable jsdoc/valid-types */
9411
+ sel, options) {
9048
9412
  if (!isObject(options) || isNull(options)) {
9049
9413
  throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
9050
9414
  }
@@ -9059,8 +9423,13 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9059
9423
  // passing `sel` as a camel-case, which makes them invalid custom elements name
9060
9424
  // the following line guarantees that this does not leaks beyond this point.
9061
9425
  const tagName = StringToLowerCase.call(sel);
9426
+ const apiVersion = getComponentAPIVersion(Ctor);
9427
+ const useNativeCustomElementLifecycle =
9428
+ // temporary "kill switch"
9429
+ !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE && isAPIFeatureEnabled(7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */, apiVersion);
9430
+ const isFormAssociated = shouldBeFormAssociated(Ctor);
9062
9431
  // the custom element from the registry is expecting an upgrade callback
9063
- /**
9432
+ /*
9064
9433
  * Note: if the upgradable constructor does not expect, or throw when we new it
9065
9434
  * with a callback as the first argument, we could implement a more advanced
9066
9435
  * mechanism that only passes that argument if the constructor is known to be
@@ -9072,13 +9441,15 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9072
9441
  mode: options.mode !== 'closed' ? 'open' : 'closed',
9073
9442
  owner: null
9074
9443
  });
9075
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
9444
+ if (!useNativeCustomElementLifecycle) {
9445
+ // Monkey-patch on-demand, because if there are no components on the page using an old API
9446
+ // version, then we don't want to monkey patch at all
9447
+ monkeyPatchDomAPIs();
9076
9448
  ConnectingSlot.set(elm, connectRootElement);
9077
9449
  DisconnectingSlot.set(elm, disconnectRootElement);
9078
9450
  }
9079
9451
  };
9080
- const element = createCustomElement(tagName, upgradeCallback);
9081
- return element;
9452
+ return createCustomElement(tagName, upgradeCallback, useNativeCustomElementLifecycle, isFormAssociated);
9082
9453
  }
9083
9454
 
9084
9455
  /*
@@ -9093,6 +9464,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9093
9464
  /**
9094
9465
  * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
9095
9466
  * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
9467
+ * @param node Node to check
9468
+ * @returns `true` if the the node is shadowed
9469
+ * @example isNodeShadowed(document.querySelector('my-component'))
9096
9470
  */
9097
9471
  function isNodeShadowed(node) {
9098
9472
  if (isFalse(node instanceof _Node)) {
@@ -9134,12 +9508,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9134
9508
  }
9135
9509
  /**
9136
9510
  * This static getter builds a Web Component class from a LWC constructor so it can be registered
9137
- * as a new element via customElements.define() at any given time. E.g.:
9138
- *
9139
- * import Foo from 'ns/foo';
9140
- * customElements.define('x-foo', Foo.CustomElementConstructor);
9141
- * const elm = document.createElement('x-foo');
9142
- *
9511
+ * as a new element via customElements.define() at any given time.
9512
+ * @example
9513
+ * import Foo from 'ns/foo';
9514
+ * customElements.define('x-foo', Foo.CustomElementConstructor);
9515
+ * const elm = document.createElement('x-foo');
9143
9516
  */
9144
9517
  defineProperty(LightningElement, 'CustomElementConstructor', {
9145
9518
  get() {
@@ -9165,6 +9538,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9165
9538
  * SPDX-License-Identifier: MIT
9166
9539
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9167
9540
  */
9541
+ /**
9542
+ * Creates a context provider, given a wire adapter constructor.
9543
+ * @param adapter The wire adapter to create a context provider for.
9544
+ * @returns A new context provider.
9545
+ */
9168
9546
  function createContextProvider(adapter) {
9169
9547
  return createContextProviderWithRegister(adapter, registerContextProvider);
9170
9548
  }
@@ -9181,7 +9559,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9181
9559
  });
9182
9560
  });
9183
9561
  }
9184
- /** version: 5.2.1 */
9562
+ /** version: 6.3.4 */
9185
9563
 
9186
9564
  exports.LightningElement = LightningElement;
9187
9565
  exports.__unstable__ProfilerControl = profilerControl;