lwc 2.38.0 → 2.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +223 -129
  2. package/dist/engine-dom/esm/es2017/engine-dom.js.map +1 -1
  3. package/dist/engine-dom/iife/es2017/engine-dom.js +223 -129
  4. package/dist/engine-dom/iife/es2017/engine-dom.js.map +1 -1
  5. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  6. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +174 -47
  7. package/dist/engine-dom/iife/es2017/engine-dom_debug.js.map +1 -1
  8. package/dist/engine-dom/iife/es5/engine-dom.js +371 -214
  9. package/dist/engine-dom/iife/es5/engine-dom.js.map +1 -1
  10. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  11. package/dist/engine-dom/iife/es5/engine-dom_debug.js +323 -160
  12. package/dist/engine-dom/iife/es5/engine-dom_debug.js.map +1 -1
  13. package/dist/engine-dom/umd/es2017/engine-dom.js +223 -129
  14. package/dist/engine-dom/umd/es2017/engine-dom.js.map +1 -1
  15. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  16. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +174 -47
  17. package/dist/engine-dom/umd/es2017/engine-dom_debug.js.map +1 -1
  18. package/dist/engine-dom/umd/es5/engine-dom.js +371 -214
  19. package/dist/engine-dom/umd/es5/engine-dom.js.map +1 -1
  20. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  21. package/dist/engine-dom/umd/es5/engine-dom_debug.js +323 -160
  22. package/dist/engine-dom/umd/es5/engine-dom_debug.js.map +1 -1
  23. package/dist/engine-server/commonjs/es2017/engine-server.js +188 -82
  24. package/dist/engine-server/commonjs/es2017/engine-server.js.map +1 -1
  25. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  26. package/dist/engine-server/esm/es2017/engine-server.js +188 -82
  27. package/dist/engine-server/esm/es2017/engine-server.js.map +1 -1
  28. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  29. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js.map +1 -1
  30. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  31. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js.map +1 -1
  32. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  33. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js.map +1 -1
  34. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  35. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js.map +1 -1
  36. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  37. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js.map +1 -1
  38. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  39. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js.map +1 -1
  40. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  41. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js.map +1 -1
  42. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  43. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js.map +1 -1
  44. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  45. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js.map +1 -1
  46. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  47. package/dist/wire-service/esm/es2017/wire-service.js.map +1 -1
  48. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  49. package/dist/wire-service/iife/es2017/wire-service.js.map +1 -1
  50. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  51. package/dist/wire-service/iife/es2017/wire-service_debug.js.map +1 -1
  52. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  53. package/dist/wire-service/iife/es5/wire-service.js.map +1 -1
  54. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  55. package/dist/wire-service/iife/es5/wire-service_debug.js.map +1 -1
  56. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  57. package/dist/wire-service/umd/es2017/wire-service.js.map +1 -1
  58. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  59. package/dist/wire-service/umd/es2017/wire-service_debug.js.map +1 -1
  60. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  61. package/dist/wire-service/umd/es5/wire-service.js.map +1 -1
  62. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  63. package/dist/wire-service/umd/es5/wire-service_debug.js.map +1 -1
  64. package/package.json +7 -7
@@ -324,7 +324,7 @@
324
324
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
325
325
  return propertyName;
326
326
  }
327
- /** version: 2.38.0 */
327
+ /** version: 2.39.0 */
328
328
 
329
329
  /**
330
330
  * Copyright (C) 2018 salesforce.com, inc.
@@ -392,7 +392,7 @@
392
392
  */
393
393
  function setFeatureFlagForTest(name, value) {
394
394
  }
395
- /** version: 2.38.0 */
395
+ /** version: 2.39.0 */
396
396
 
397
397
  /**
398
398
  * Copyright (C) 2018 salesforce.com, inc.
@@ -456,7 +456,7 @@
456
456
  }
457
457
  }
458
458
  }
459
- /** version: 2.38.0 */
459
+ /** version: 2.39.0 */
460
460
 
461
461
  /*
462
462
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2360,10 +2360,101 @@
2360
2360
  }
2361
2361
  freeze(BaseBridgeElement);
2362
2362
  seal(BaseBridgeElement.prototype);
2363
+
2364
+ /*
2365
+ * Copyright (c) 2023, salesforce.com, inc.
2366
+ * All rights reserved.
2367
+ * SPDX-License-Identifier: MIT
2368
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2369
+ */
2370
+ const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
2371
+ // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
2372
+ class LegacyWeakMultiMap {
2373
+ constructor() {
2374
+ this._map = new WeakMap();
2375
+ }
2376
+ _getValues(key) {
2377
+ let values = this._map.get(key);
2378
+ if (isUndefined$1(values)) {
2379
+ values = new Set();
2380
+ this._map.set(key, values);
2381
+ }
2382
+ return values;
2383
+ }
2384
+ get(key) {
2385
+ return this._getValues(key);
2386
+ }
2387
+ add(key, vm) {
2388
+ const set = this._getValues(key);
2389
+ set.add(vm);
2390
+ }
2391
+ delete(key) {
2392
+ this._map.delete(key);
2393
+ }
2394
+ }
2395
+ // This implementation relies on the WeakRef/FinalizationRegistry proposal.
2396
+ // For some background, see: https://github.com/tc39/proposal-weakrefs
2397
+ class ModernWeakMultiMap {
2398
+ constructor() {
2399
+ this._map = new WeakMap();
2400
+ this._registry = new FinalizationRegistry((weakRefs) => {
2401
+ // This should be considered an optional cleanup method to remove GC'ed values from their respective arrays.
2402
+ // JS VMs are not obligated to call FinalizationRegistry callbacks.
2403
+ // Work backwards, removing stale VMs
2404
+ for (let i = weakRefs.length - 1; i >= 0; i--) {
2405
+ const vm = weakRefs[i].deref();
2406
+ if (isUndefined$1(vm)) {
2407
+ ArraySplice.call(weakRefs, i, 1); // remove
2408
+ }
2409
+ }
2410
+ });
2411
+ }
2412
+ _getWeakRefs(key) {
2413
+ let weakRefs = this._map.get(key);
2414
+ if (isUndefined$1(weakRefs)) {
2415
+ weakRefs = [];
2416
+ this._map.set(key, weakRefs);
2417
+ }
2418
+ return weakRefs;
2419
+ }
2420
+ get(key) {
2421
+ const weakRefs = this._getWeakRefs(key);
2422
+ const result = new Set();
2423
+ for (const weakRef of weakRefs) {
2424
+ const vm = weakRef.deref();
2425
+ if (!isUndefined$1(vm)) {
2426
+ result.add(vm);
2427
+ }
2428
+ }
2429
+ return result;
2430
+ }
2431
+ add(key, value) {
2432
+ const weakRefs = this._getWeakRefs(key);
2433
+ // We could check for duplicate values here, but it doesn't seem worth it.
2434
+ // We transform the output into a Set anyway
2435
+ ArrayPush$1.call(weakRefs, new WeakRef(value));
2436
+ // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
2437
+ // effectively creates a strong reference between the first argument (the "target") and the held value. When
2438
+ // the target is GC'ed, the callback is called, and then the held value is GC'ed.
2439
+ // Putting the key here would mean the key is not GC'ed until the value is GC'ed, which defeats the purpose
2440
+ // of the WeakMap. Whereas putting the weakRefs array here is fine, because it doesn't have a strong reference
2441
+ // to anything. See also this example:
2442
+ // https://gist.github.com/nolanlawson/79a3d36e8e6cc25c5048bb17c1795aea
2443
+ this._registry.register(value, weakRefs);
2444
+ }
2445
+ delete(key) {
2446
+ this._map.delete(key);
2447
+ }
2448
+ }
2449
+ const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
2363
2450
  const swappedStyleMap = new WeakMap();
2364
- const activeTemplates = new WeakMap();
2365
- const activeComponents = new WeakMap();
2366
- const activeStyles = new WeakMap();
2451
+ // The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
2452
+ // so we don't want to create strong references to them.
2453
+ // The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
2454
+ // never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
2455
+ const activeTemplates = new WeakMultiMap();
2456
+ const activeComponents = new WeakMultiMap();
2457
+ const activeStyles = new WeakMultiMap();
2367
2458
  function getStyleOrSwappedStyle(style) {
2368
2459
  assertNotProd(); // this method should never leak to prod
2369
2460
  const visited = new Set();
@@ -2377,42 +2468,27 @@
2377
2468
  assertNotProd(); // this method should never leak to prod
2378
2469
  // tracking active component
2379
2470
  const Ctor = vm.def.ctor;
2380
- let componentVMs = activeComponents.get(Ctor);
2381
- if (isUndefined$1(componentVMs)) {
2382
- componentVMs = new Set();
2383
- activeComponents.set(Ctor, componentVMs);
2384
- }
2385
2471
  // this will allow us to keep track of the hot components
2386
- componentVMs.add(vm);
2472
+ activeComponents.add(Ctor, vm);
2387
2473
  // tracking active template
2388
2474
  const tpl = vm.cmpTemplate;
2389
2475
  if (tpl) {
2390
- let templateVMs = activeTemplates.get(tpl);
2391
- if (isUndefined$1(templateVMs)) {
2392
- templateVMs = new Set();
2393
- activeTemplates.set(tpl, templateVMs);
2394
- }
2395
2476
  // this will allow us to keep track of the templates that are
2396
2477
  // being used by a hot component
2397
- templateVMs.add(vm);
2478
+ activeTemplates.add(tpl, vm);
2398
2479
  // tracking active styles associated to template
2399
2480
  const stylesheets = tpl.stylesheets;
2400
2481
  if (!isUndefined$1(stylesheets)) {
2401
- flattenStylesheets(stylesheets).forEach((stylesheet) => {
2482
+ for (const stylesheet of flattenStylesheets(stylesheets)) {
2402
2483
  // this is necessary because we don't hold the list of styles
2403
2484
  // in the vm, we only hold the selected (already swapped template)
2404
2485
  // but the styles attached to the template might not be the actual
2405
2486
  // active ones, but the swapped versions of those.
2406
- stylesheet = getStyleOrSwappedStyle(stylesheet);
2407
- let stylesheetVMs = activeStyles.get(stylesheet);
2408
- if (isUndefined$1(stylesheetVMs)) {
2409
- stylesheetVMs = new Set();
2410
- activeStyles.set(stylesheet, stylesheetVMs);
2411
- }
2487
+ const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
2412
2488
  // this will allow us to keep track of the stylesheet that are
2413
2489
  // being used by a hot component
2414
- stylesheetVMs.add(vm);
2415
- });
2490
+ activeStyles.add(swappedStylesheet, vm);
2491
+ }
2416
2492
  }
2417
2493
  }
2418
2494
  }
@@ -3284,8 +3360,9 @@
3284
3360
  }
3285
3361
  }
3286
3362
  function patchCustomElement(n1, n2, parent, renderer) {
3363
+ // TODO [#3331]: This if branch should be removed in 246 with lwc:dynamic
3287
3364
  if (n1.ctor !== n2.ctor) {
3288
- // If the constructor, unmount the current component and mount a new one using the new
3365
+ // If the constructor differs, unmount the current component and mount a new one using the new
3289
3366
  // constructor.
3290
3367
  const anchor = renderer.nextSibling(n1.elm);
3291
3368
  unmount(n1, parent, renderer, true);
@@ -3735,9 +3812,17 @@
3735
3812
  if (n2 !== n1) {
3736
3813
  if (isVNode(n1)) {
3737
3814
  if (isVNode(n2)) {
3738
- // both vnodes are equivalent, and we just need to patch them
3739
- patch(n1, n2, parent, renderer);
3740
- anchor = n2.elm;
3815
+ if (isSameVnode(n1, n2)) {
3816
+ // both vnodes are equivalent, and we just need to patch them
3817
+ patch(n1, n2, parent, renderer);
3818
+ anchor = n2.elm;
3819
+ }
3820
+ else {
3821
+ // removing the old vnode since the new one is different
3822
+ unmount(n1, parent, renderer, true);
3823
+ mount(n2, parent, renderer, anchor);
3824
+ anchor = n2.elm;
3825
+ }
3741
3826
  }
3742
3827
  else {
3743
3828
  // removing the old vnode since the new one is null
@@ -4031,11 +4116,13 @@
4031
4116
  return url;
4032
4117
  }
4033
4118
  /**
4034
- * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4119
+ * [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4120
+ *
4121
+ * TODO [#3331]: remove usage of lwc:dynamic in 246
4035
4122
  */
4036
- function dc(sel, Ctor, data, children = EmptyArray) {
4123
+ function ddc(sel, Ctor, data, children = EmptyArray) {
4037
4124
  // null or undefined values should produce a null value in the VNodes
4038
- if (Ctor == null) {
4125
+ if (isNull(Ctor) || isUndefined$1(Ctor)) {
4039
4126
  return null;
4040
4127
  }
4041
4128
  if (!isComponentConstructor(Ctor)) {
@@ -4043,6 +4130,26 @@
4043
4130
  }
4044
4131
  return c(sel, Ctor, data, children);
4045
4132
  }
4133
+ /**
4134
+ * [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
4135
+ */
4136
+ function dc(Ctor, data, children = EmptyArray) {
4137
+ // Null or undefined values should produce a null value in the VNodes.
4138
+ // This is the only value at compile time as the constructor will not be known.
4139
+ if (isNull(Ctor) || isUndefined$1(Ctor)) {
4140
+ return null;
4141
+ }
4142
+ if (!isComponentConstructor(Ctor)) {
4143
+ throw new Error(`Invalid constructor ${toString$1(Ctor)} is not a LightningElement constructor.`);
4144
+ }
4145
+ // Look up the dynamic component's name at runtime once the constructor is available.
4146
+ // This information is only known at runtime and is stored as part of registerComponent.
4147
+ const sel = getComponentRegisteredName(Ctor);
4148
+ if (isUndefined$1(sel) || sel === '') {
4149
+ throw new Error(`Invalid LWC constructor ${toString$1(Ctor)} does not have a registered name`);
4150
+ }
4151
+ return c(sel, Ctor, data, children);
4152
+ }
4046
4153
  /**
4047
4154
  * slow children collection marking mechanism. this API allows the compiler to signal
4048
4155
  * to the engine that a particular collection of children must be diffed using the slow
@@ -4102,6 +4209,7 @@
4102
4209
  fid,
4103
4210
  shc,
4104
4211
  ssf,
4212
+ ddc,
4105
4213
  });
4106
4214
  /** Indicates if operations should be logged by the profiler. */
4107
4215
  let isProfilerEnabled = false;
@@ -4398,23 +4506,29 @@
4398
4506
  * SPDX-License-Identifier: MIT
4399
4507
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4400
4508
  */
4401
- const signedTemplateMap = new Map();
4509
+ const registeredComponentMap = new Map();
4402
4510
  /**
4403
4511
  * INTERNAL: This function can only be invoked by compiled code. The compiler
4404
4512
  * will prevent this function from being imported by userland code.
4405
4513
  */
4406
4514
  function registerComponent(
4407
4515
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
4408
- Ctor, { tmpl }) {
4516
+ Ctor, metadata) {
4409
4517
  if (isFunction$1(Ctor)) {
4410
- signedTemplateMap.set(Ctor, tmpl);
4518
+ // TODO [#3331]: add validation to check the value of metadata.sel is not an empty string.
4519
+ registeredComponentMap.set(Ctor, metadata);
4411
4520
  }
4412
4521
  // chaining this method as a way to wrap existing assignment of component constructor easily,
4413
4522
  // without too much transformation
4414
4523
  return Ctor;
4415
4524
  }
4416
4525
  function getComponentRegisteredTemplate(Ctor) {
4417
- return signedTemplateMap.get(Ctor);
4526
+ var _a;
4527
+ return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.tmpl;
4528
+ }
4529
+ function getComponentRegisteredName(Ctor) {
4530
+ var _a;
4531
+ return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
4418
4532
  }
4419
4533
  function getTemplateReactiveObserver(vm) {
4420
4534
  return createReactiveObserver(() => {
@@ -4873,17 +4987,30 @@
4873
4987
  // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
4874
4988
  // children VNodes might not be representing the current state of the DOM.
4875
4989
  function resetComponentRoot(vm) {
4876
- const { children, renderRoot, renderer: { remove }, } = vm;
4877
- for (let i = 0, len = children.length; i < len; i++) {
4878
- const child = children[i];
4879
- if (!isNull(child) && !isUndefined$1(child.elm)) {
4880
- remove(child.elm, renderRoot);
4881
- }
4882
- }
4990
+ recursivelyRemoveChildren(vm.children, vm);
4883
4991
  vm.children = EmptyArray;
4884
4992
  runChildNodesDisconnectedCallback(vm);
4885
4993
  vm.velements = EmptyArray;
4886
4994
  }
4995
+ // Helper function to remove all children of the root node.
4996
+ // If the set of children includes VFragment nodes, we need to remove the children of those nodes too.
4997
+ // Since VFragments can contain other VFragments, we need to traverse the entire of tree of VFragments.
4998
+ // If the set contains no VFragment nodes, no traversal is needed.
4999
+ function recursivelyRemoveChildren(vnodes, vm) {
5000
+ const { renderRoot, renderer: { remove }, } = vm;
5001
+ for (let i = 0, len = vnodes.length; i < len; i += 1) {
5002
+ const vnode = vnodes[i];
5003
+ if (!isNull(vnode)) {
5004
+ // VFragments are special; their .elm property does not point to the root element since they have no single root.
5005
+ if (isVFragment(vnode)) {
5006
+ recursivelyRemoveChildren(vnode.children, vm);
5007
+ }
5008
+ else if (!isUndefined$1(vnode.elm)) {
5009
+ remove(vnode.elm, renderRoot);
5010
+ }
5011
+ }
5012
+ }
5013
+ }
4887
5014
  function scheduleRehydration(vm) {
4888
5015
  if (isTrue(vm.isScheduled)) {
4889
5016
  return;
@@ -6106,7 +6233,7 @@
6106
6233
  function isNull(obj) {
6107
6234
  return obj === null;
6108
6235
  }
6109
- /** version: 2.38.0 */
6236
+ /** version: 2.39.0 */
6110
6237
 
6111
6238
  /*
6112
6239
  * Copyright (c) 2023, salesforce.com, inc.
@@ -6717,7 +6844,7 @@
6717
6844
  });
6718
6845
  }));
6719
6846
  }
6720
- /* version: 2.38.0 */
6847
+ /* version: 2.39.0 */
6721
6848
 
6722
6849
  exports.LightningElement = LightningElement;
6723
6850
  exports.__unstable__ProfilerControl = profilerControl;