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
@@ -321,7 +321,7 @@ var LWC = (function (exports) {
321
321
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
322
322
  return propertyName;
323
323
  }
324
- /** version: 2.38.0 */
324
+ /** version: 2.39.0 */
325
325
 
326
326
  /**
327
327
  * Copyright (C) 2018 salesforce.com, inc.
@@ -389,7 +389,7 @@ var LWC = (function (exports) {
389
389
  */
390
390
  function setFeatureFlagForTest(name, value) {
391
391
  }
392
- /** version: 2.38.0 */
392
+ /** version: 2.39.0 */
393
393
 
394
394
  /**
395
395
  * Copyright (C) 2018 salesforce.com, inc.
@@ -453,7 +453,7 @@ var LWC = (function (exports) {
453
453
  }
454
454
  }
455
455
  }
456
- /** version: 2.38.0 */
456
+ /** version: 2.39.0 */
457
457
 
458
458
  /*
459
459
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2357,10 +2357,101 @@ var LWC = (function (exports) {
2357
2357
  }
2358
2358
  freeze(BaseBridgeElement);
2359
2359
  seal(BaseBridgeElement.prototype);
2360
+
2361
+ /*
2362
+ * Copyright (c) 2023, salesforce.com, inc.
2363
+ * All rights reserved.
2364
+ * SPDX-License-Identifier: MIT
2365
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2366
+ */
2367
+ const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
2368
+ // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
2369
+ class LegacyWeakMultiMap {
2370
+ constructor() {
2371
+ this._map = new WeakMap();
2372
+ }
2373
+ _getValues(key) {
2374
+ let values = this._map.get(key);
2375
+ if (isUndefined$1(values)) {
2376
+ values = new Set();
2377
+ this._map.set(key, values);
2378
+ }
2379
+ return values;
2380
+ }
2381
+ get(key) {
2382
+ return this._getValues(key);
2383
+ }
2384
+ add(key, vm) {
2385
+ const set = this._getValues(key);
2386
+ set.add(vm);
2387
+ }
2388
+ delete(key) {
2389
+ this._map.delete(key);
2390
+ }
2391
+ }
2392
+ // This implementation relies on the WeakRef/FinalizationRegistry proposal.
2393
+ // For some background, see: https://github.com/tc39/proposal-weakrefs
2394
+ class ModernWeakMultiMap {
2395
+ constructor() {
2396
+ this._map = new WeakMap();
2397
+ this._registry = new FinalizationRegistry((weakRefs) => {
2398
+ // This should be considered an optional cleanup method to remove GC'ed values from their respective arrays.
2399
+ // JS VMs are not obligated to call FinalizationRegistry callbacks.
2400
+ // Work backwards, removing stale VMs
2401
+ for (let i = weakRefs.length - 1; i >= 0; i--) {
2402
+ const vm = weakRefs[i].deref();
2403
+ if (isUndefined$1(vm)) {
2404
+ ArraySplice.call(weakRefs, i, 1); // remove
2405
+ }
2406
+ }
2407
+ });
2408
+ }
2409
+ _getWeakRefs(key) {
2410
+ let weakRefs = this._map.get(key);
2411
+ if (isUndefined$1(weakRefs)) {
2412
+ weakRefs = [];
2413
+ this._map.set(key, weakRefs);
2414
+ }
2415
+ return weakRefs;
2416
+ }
2417
+ get(key) {
2418
+ const weakRefs = this._getWeakRefs(key);
2419
+ const result = new Set();
2420
+ for (const weakRef of weakRefs) {
2421
+ const vm = weakRef.deref();
2422
+ if (!isUndefined$1(vm)) {
2423
+ result.add(vm);
2424
+ }
2425
+ }
2426
+ return result;
2427
+ }
2428
+ add(key, value) {
2429
+ const weakRefs = this._getWeakRefs(key);
2430
+ // We could check for duplicate values here, but it doesn't seem worth it.
2431
+ // We transform the output into a Set anyway
2432
+ ArrayPush$1.call(weakRefs, new WeakRef(value));
2433
+ // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
2434
+ // effectively creates a strong reference between the first argument (the "target") and the held value. When
2435
+ // the target is GC'ed, the callback is called, and then the held value is GC'ed.
2436
+ // Putting the key here would mean the key is not GC'ed until the value is GC'ed, which defeats the purpose
2437
+ // of the WeakMap. Whereas putting the weakRefs array here is fine, because it doesn't have a strong reference
2438
+ // to anything. See also this example:
2439
+ // https://gist.github.com/nolanlawson/79a3d36e8e6cc25c5048bb17c1795aea
2440
+ this._registry.register(value, weakRefs);
2441
+ }
2442
+ delete(key) {
2443
+ this._map.delete(key);
2444
+ }
2445
+ }
2446
+ const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
2360
2447
  const swappedStyleMap = new WeakMap();
2361
- const activeTemplates = new WeakMap();
2362
- const activeComponents = new WeakMap();
2363
- const activeStyles = new WeakMap();
2448
+ // The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
2449
+ // so we don't want to create strong references to them.
2450
+ // The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
2451
+ // never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
2452
+ const activeTemplates = new WeakMultiMap();
2453
+ const activeComponents = new WeakMultiMap();
2454
+ const activeStyles = new WeakMultiMap();
2364
2455
  function getStyleOrSwappedStyle(style) {
2365
2456
  assertNotProd(); // this method should never leak to prod
2366
2457
  const visited = new Set();
@@ -2374,42 +2465,27 @@ var LWC = (function (exports) {
2374
2465
  assertNotProd(); // this method should never leak to prod
2375
2466
  // tracking active component
2376
2467
  const Ctor = vm.def.ctor;
2377
- let componentVMs = activeComponents.get(Ctor);
2378
- if (isUndefined$1(componentVMs)) {
2379
- componentVMs = new Set();
2380
- activeComponents.set(Ctor, componentVMs);
2381
- }
2382
2468
  // this will allow us to keep track of the hot components
2383
- componentVMs.add(vm);
2469
+ activeComponents.add(Ctor, vm);
2384
2470
  // tracking active template
2385
2471
  const tpl = vm.cmpTemplate;
2386
2472
  if (tpl) {
2387
- let templateVMs = activeTemplates.get(tpl);
2388
- if (isUndefined$1(templateVMs)) {
2389
- templateVMs = new Set();
2390
- activeTemplates.set(tpl, templateVMs);
2391
- }
2392
2473
  // this will allow us to keep track of the templates that are
2393
2474
  // being used by a hot component
2394
- templateVMs.add(vm);
2475
+ activeTemplates.add(tpl, vm);
2395
2476
  // tracking active styles associated to template
2396
2477
  const stylesheets = tpl.stylesheets;
2397
2478
  if (!isUndefined$1(stylesheets)) {
2398
- flattenStylesheets(stylesheets).forEach((stylesheet) => {
2479
+ for (const stylesheet of flattenStylesheets(stylesheets)) {
2399
2480
  // this is necessary because we don't hold the list of styles
2400
2481
  // in the vm, we only hold the selected (already swapped template)
2401
2482
  // but the styles attached to the template might not be the actual
2402
2483
  // active ones, but the swapped versions of those.
2403
- stylesheet = getStyleOrSwappedStyle(stylesheet);
2404
- let stylesheetVMs = activeStyles.get(stylesheet);
2405
- if (isUndefined$1(stylesheetVMs)) {
2406
- stylesheetVMs = new Set();
2407
- activeStyles.set(stylesheet, stylesheetVMs);
2408
- }
2484
+ const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
2409
2485
  // this will allow us to keep track of the stylesheet that are
2410
2486
  // being used by a hot component
2411
- stylesheetVMs.add(vm);
2412
- });
2487
+ activeStyles.add(swappedStylesheet, vm);
2488
+ }
2413
2489
  }
2414
2490
  }
2415
2491
  }
@@ -3281,8 +3357,9 @@ var LWC = (function (exports) {
3281
3357
  }
3282
3358
  }
3283
3359
  function patchCustomElement(n1, n2, parent, renderer) {
3360
+ // TODO [#3331]: This if branch should be removed in 246 with lwc:dynamic
3284
3361
  if (n1.ctor !== n2.ctor) {
3285
- // If the constructor, unmount the current component and mount a new one using the new
3362
+ // If the constructor differs, unmount the current component and mount a new one using the new
3286
3363
  // constructor.
3287
3364
  const anchor = renderer.nextSibling(n1.elm);
3288
3365
  unmount(n1, parent, renderer, true);
@@ -3732,9 +3809,17 @@ var LWC = (function (exports) {
3732
3809
  if (n2 !== n1) {
3733
3810
  if (isVNode(n1)) {
3734
3811
  if (isVNode(n2)) {
3735
- // both vnodes are equivalent, and we just need to patch them
3736
- patch(n1, n2, parent, renderer);
3737
- anchor = n2.elm;
3812
+ if (isSameVnode(n1, n2)) {
3813
+ // both vnodes are equivalent, and we just need to patch them
3814
+ patch(n1, n2, parent, renderer);
3815
+ anchor = n2.elm;
3816
+ }
3817
+ else {
3818
+ // removing the old vnode since the new one is different
3819
+ unmount(n1, parent, renderer, true);
3820
+ mount(n2, parent, renderer, anchor);
3821
+ anchor = n2.elm;
3822
+ }
3738
3823
  }
3739
3824
  else {
3740
3825
  // removing the old vnode since the new one is null
@@ -4028,11 +4113,13 @@ var LWC = (function (exports) {
4028
4113
  return url;
4029
4114
  }
4030
4115
  /**
4031
- * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4116
+ * [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4117
+ *
4118
+ * TODO [#3331]: remove usage of lwc:dynamic in 246
4032
4119
  */
4033
- function dc(sel, Ctor, data, children = EmptyArray) {
4120
+ function ddc(sel, Ctor, data, children = EmptyArray) {
4034
4121
  // null or undefined values should produce a null value in the VNodes
4035
- if (Ctor == null) {
4122
+ if (isNull(Ctor) || isUndefined$1(Ctor)) {
4036
4123
  return null;
4037
4124
  }
4038
4125
  if (!isComponentConstructor(Ctor)) {
@@ -4040,6 +4127,26 @@ var LWC = (function (exports) {
4040
4127
  }
4041
4128
  return c(sel, Ctor, data, children);
4042
4129
  }
4130
+ /**
4131
+ * [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
4132
+ */
4133
+ function dc(Ctor, data, children = EmptyArray) {
4134
+ // Null or undefined values should produce a null value in the VNodes.
4135
+ // This is the only value at compile time as the constructor will not be known.
4136
+ if (isNull(Ctor) || isUndefined$1(Ctor)) {
4137
+ return null;
4138
+ }
4139
+ if (!isComponentConstructor(Ctor)) {
4140
+ throw new Error(`Invalid constructor ${toString$1(Ctor)} is not a LightningElement constructor.`);
4141
+ }
4142
+ // Look up the dynamic component's name at runtime once the constructor is available.
4143
+ // This information is only known at runtime and is stored as part of registerComponent.
4144
+ const sel = getComponentRegisteredName(Ctor);
4145
+ if (isUndefined$1(sel) || sel === '') {
4146
+ throw new Error(`Invalid LWC constructor ${toString$1(Ctor)} does not have a registered name`);
4147
+ }
4148
+ return c(sel, Ctor, data, children);
4149
+ }
4043
4150
  /**
4044
4151
  * slow children collection marking mechanism. this API allows the compiler to signal
4045
4152
  * to the engine that a particular collection of children must be diffed using the slow
@@ -4099,6 +4206,7 @@ var LWC = (function (exports) {
4099
4206
  fid,
4100
4207
  shc,
4101
4208
  ssf,
4209
+ ddc,
4102
4210
  });
4103
4211
  /** Indicates if operations should be logged by the profiler. */
4104
4212
  let isProfilerEnabled = false;
@@ -4395,23 +4503,29 @@ var LWC = (function (exports) {
4395
4503
  * SPDX-License-Identifier: MIT
4396
4504
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4397
4505
  */
4398
- const signedTemplateMap = new Map();
4506
+ const registeredComponentMap = new Map();
4399
4507
  /**
4400
4508
  * INTERNAL: This function can only be invoked by compiled code. The compiler
4401
4509
  * will prevent this function from being imported by userland code.
4402
4510
  */
4403
4511
  function registerComponent(
4404
4512
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
4405
- Ctor, { tmpl }) {
4513
+ Ctor, metadata) {
4406
4514
  if (isFunction$1(Ctor)) {
4407
- signedTemplateMap.set(Ctor, tmpl);
4515
+ // TODO [#3331]: add validation to check the value of metadata.sel is not an empty string.
4516
+ registeredComponentMap.set(Ctor, metadata);
4408
4517
  }
4409
4518
  // chaining this method as a way to wrap existing assignment of component constructor easily,
4410
4519
  // without too much transformation
4411
4520
  return Ctor;
4412
4521
  }
4413
4522
  function getComponentRegisteredTemplate(Ctor) {
4414
- return signedTemplateMap.get(Ctor);
4523
+ var _a;
4524
+ return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.tmpl;
4525
+ }
4526
+ function getComponentRegisteredName(Ctor) {
4527
+ var _a;
4528
+ return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
4415
4529
  }
4416
4530
  function getTemplateReactiveObserver(vm) {
4417
4531
  return createReactiveObserver(() => {
@@ -4870,17 +4984,30 @@ var LWC = (function (exports) {
4870
4984
  // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
4871
4985
  // children VNodes might not be representing the current state of the DOM.
4872
4986
  function resetComponentRoot(vm) {
4873
- const { children, renderRoot, renderer: { remove }, } = vm;
4874
- for (let i = 0, len = children.length; i < len; i++) {
4875
- const child = children[i];
4876
- if (!isNull(child) && !isUndefined$1(child.elm)) {
4877
- remove(child.elm, renderRoot);
4878
- }
4879
- }
4987
+ recursivelyRemoveChildren(vm.children, vm);
4880
4988
  vm.children = EmptyArray;
4881
4989
  runChildNodesDisconnectedCallback(vm);
4882
4990
  vm.velements = EmptyArray;
4883
4991
  }
4992
+ // Helper function to remove all children of the root node.
4993
+ // If the set of children includes VFragment nodes, we need to remove the children of those nodes too.
4994
+ // Since VFragments can contain other VFragments, we need to traverse the entire of tree of VFragments.
4995
+ // If the set contains no VFragment nodes, no traversal is needed.
4996
+ function recursivelyRemoveChildren(vnodes, vm) {
4997
+ const { renderRoot, renderer: { remove }, } = vm;
4998
+ for (let i = 0, len = vnodes.length; i < len; i += 1) {
4999
+ const vnode = vnodes[i];
5000
+ if (!isNull(vnode)) {
5001
+ // VFragments are special; their .elm property does not point to the root element since they have no single root.
5002
+ if (isVFragment(vnode)) {
5003
+ recursivelyRemoveChildren(vnode.children, vm);
5004
+ }
5005
+ else if (!isUndefined$1(vnode.elm)) {
5006
+ remove(vnode.elm, renderRoot);
5007
+ }
5008
+ }
5009
+ }
5010
+ }
4884
5011
  function scheduleRehydration(vm) {
4885
5012
  if (isTrue(vm.isScheduled)) {
4886
5013
  return;
@@ -6103,7 +6230,7 @@ var LWC = (function (exports) {
6103
6230
  function isNull(obj) {
6104
6231
  return obj === null;
6105
6232
  }
6106
- /** version: 2.38.0 */
6233
+ /** version: 2.39.0 */
6107
6234
 
6108
6235
  /*
6109
6236
  * Copyright (c) 2023, salesforce.com, inc.
@@ -6714,7 +6841,7 @@ var LWC = (function (exports) {
6714
6841
  });
6715
6842
  }));
6716
6843
  }
6717
- /* version: 2.38.0 */
6844
+ /* version: 2.39.0 */
6718
6845
 
6719
6846
  exports.LightningElement = LightningElement;
6720
6847
  exports.__unstable__ProfilerControl = profilerControl;