@lwc/engine-core 6.2.0 → 6.3.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.
package/dist/index.cjs.js CHANGED
@@ -27,8 +27,7 @@ let enabled$1 = false;
27
27
  const reportingControl = {
28
28
  /**
29
29
  * Attach a new reporting control (aka dispatcher).
30
- *
31
- * @param dispatcher - reporting control
30
+ * @param dispatcher reporting control
32
31
  */
33
32
  attachDispatcher(dispatcher) {
34
33
  enabled$1 = true;
@@ -71,7 +70,7 @@ function onReportingEnabled(callback) {
71
70
  /**
72
71
  * Report to the current dispatcher, if there is one.
73
72
  * @param reportingEventId
74
- * @param payload - data to report
73
+ * @param payload data to report
75
74
  */
76
75
  function report(reportingEventId, payload) {
77
76
  if (enabled$1) {
@@ -133,7 +132,7 @@ function addErrorComponentStack(vm, error) {
133
132
  }
134
133
 
135
134
  /*
136
- * Copyright (c) 2018, salesforce.com, inc.
135
+ * Copyright (c) 2024, Salesforce, Inc.
137
136
  * All rights reserved.
138
137
  * SPDX-License-Identifier: MIT
139
138
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -141,7 +140,6 @@ function addErrorComponentStack(vm, error) {
141
140
  const alreadyLoggedMessages = new Set();
142
141
  // Only used in LWC's Karma tests
143
142
  if (process.env.NODE_ENV === 'test-karma-lwc') {
144
- // @ts-ignore
145
143
  window.__lwcResetAlreadyLoggedMessages = () => {
146
144
  alreadyLoggedMessages.clear();
147
145
  };
@@ -799,7 +797,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
799
797
  logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
800
798
  }
801
799
  // Typescript does not like it when you treat the `arguments` object as an array
802
- // @ts-ignore type-mismatch
800
+ // @ts-expect-error type-mismatch
803
801
  return originalAddEventListener.apply(this, arguments);
804
802
  },
805
803
  }),
@@ -848,7 +846,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
848
846
  logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
849
847
  }
850
848
  // Typescript does not like it when you treat the `arguments` object as an array
851
- // @ts-ignore type-mismatch
849
+ // @ts-expect-error type-mismatch
852
850
  return originalAddEventListener.apply(this, arguments);
853
851
  },
854
852
  }),
@@ -1434,6 +1432,7 @@ const reactiveMembrane = new ObservableMembrane({
1434
1432
  * EXPERIMENTAL: This function implements an unwrap mechanism that
1435
1433
  * works for observable membrane objects. This API is subject to
1436
1434
  * change or being removed.
1435
+ * @param value
1437
1436
  */
1438
1437
  function unwrap(value) {
1439
1438
  // On the server side, we don't need mutation tracking. Skipping it improves performance.
@@ -1547,6 +1546,8 @@ function applyShadowMigrateMode(shadowRoot) {
1547
1546
  * that a Custom Element can support (including AOM properties), which
1548
1547
  * determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
1549
1548
  * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
1549
+ * @param propName
1550
+ * @param descriptor
1550
1551
  */
1551
1552
  function createBridgeToElementDescriptor(propName, descriptor) {
1552
1553
  const { get, set, enumerable, configurable } = descriptor;
@@ -1596,8 +1597,8 @@ const refsCache = new WeakMap();
1596
1597
  /**
1597
1598
  * This class is the base class for any LWC element.
1598
1599
  * Some elements directly extends this class, others implement it via inheritance.
1599
- **/
1600
- // @ts-ignore
1600
+ */
1601
+ // @ts-expect-error When exported, it will conform, but we need to build it first!
1601
1602
  const LightningElement = function () {
1602
1603
  // This should be as performant as possible, while any initialization should be done lazily
1603
1604
  if (shared.isNull(vmBeingConstructed)) {
@@ -1739,7 +1740,7 @@ function createElementInternalsProxy(elementInternals, isFormAssociated) {
1739
1740
  });
1740
1741
  return elementInternalsProxy;
1741
1742
  }
1742
- // @ts-ignore
1743
+ // Type assertion because we need to build the prototype before it satisfies the interface.
1743
1744
  LightningElement.prototype = {
1744
1745
  constructor: LightningElement,
1745
1746
  dispatchEvent(event) {
@@ -1941,6 +1942,9 @@ LightningElement.prototype = {
1941
1942
  if (process.env.NODE_ENV !== 'production') {
1942
1943
  warnIfInvokedDuringConstruction(vm, 'childNodes');
1943
1944
  }
1945
+ // getChildNodes returns a NodeList, which has `item(index: number): Node | null`.
1946
+ // NodeListOf<T> extends NodeList, but claims to not return null. That seems inaccurate,
1947
+ // but these are built-in types, so ultimately not our problem.
1944
1948
  return renderer.getChildNodes(vm.elm);
1945
1949
  },
1946
1950
  get firstChild() {
@@ -2180,7 +2184,7 @@ function createConfigWatcher(component, configCallback, callbackWhenConfigIsRead
2180
2184
  ro.observe(() => (config = configCallback(component)));
2181
2185
  // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2182
2186
  // TODO: dev-mode validation of config based on the adapter.configSchema
2183
- // @ts-ignore it is assigned in the observe() callback
2187
+ // @ts-expect-error it is assigned in the observe() callback
2184
2188
  callbackWhenConfigIsReady(config);
2185
2189
  };
2186
2190
  return {
@@ -2256,7 +2260,7 @@ function createConnector(vm, name, wireDef) {
2256
2260
  });
2257
2261
  }
2258
2262
  return {
2259
- // @ts-ignore the boundary protection executes sync, connector is always defined
2263
+ // @ts-expect-error the boundary protection executes sync, connector is always defined
2260
2264
  connector,
2261
2265
  computeConfigAndUpdate,
2262
2266
  resetConfigWatcher: () => ro.reset(),
@@ -2465,9 +2469,11 @@ function internalTrackDecorator(key) {
2465
2469
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2466
2470
  */
2467
2471
  /**
2468
- * @wire decorator to wire fields and methods to a wire adapter in
2472
+ * The @wire decorator wires fields and methods to a wire adapter in
2469
2473
  * LWC Components. This function implements the internals of this
2470
2474
  * decorator.
2475
+ * @param _adapter
2476
+ * @param _config
2471
2477
  */
2472
2478
  function wire(_adapter, _config) {
2473
2479
  if (process.env.NODE_ENV !== 'production') {
@@ -2578,6 +2584,8 @@ function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
2578
2584
  /**
2579
2585
  * INTERNAL: This function can only be invoked by compiled code. The compiler
2580
2586
  * will prevent this function from being imported by user-land code.
2587
+ * @param Ctor
2588
+ * @param meta
2581
2589
  */
2582
2590
  function registerDecorators(Ctor, meta) {
2583
2591
  const proto = Ctor.prototype;
@@ -2731,7 +2739,6 @@ function getDecoratorsMeta(Ctor) {
2731
2739
  let warned = false;
2732
2740
  // Only used in LWC's Karma tests
2733
2741
  if (process.env.NODE_ENV === 'test-karma-lwc') {
2734
- // @ts-ignore
2735
2742
  window.__lwcResetWarnedOnVersionMismatch = () => {
2736
2743
  warned = false;
2737
2744
  };
@@ -2766,6 +2773,7 @@ function isTemplateRegistered(tpl) {
2766
2773
  /**
2767
2774
  * INTERNAL: This function can only be invoked by compiled code. The compiler
2768
2775
  * will prevent this function from being imported by userland code.
2776
+ * @param tpl
2769
2777
  */
2770
2778
  function registerTemplate(tpl) {
2771
2779
  if (process.env.NODE_ENV !== 'production') {
@@ -2779,6 +2787,10 @@ function registerTemplate(tpl) {
2779
2787
  /**
2780
2788
  * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
2781
2789
  * libraries to sanitize vulnerable attributes.
2790
+ * @param tagName
2791
+ * @param namespaceUri
2792
+ * @param attrName
2793
+ * @param attrValue
2782
2794
  */
2783
2795
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
2784
2796
  // locker-service patches this function during runtime to sanitize vulnerable attributes. When
@@ -2844,7 +2856,7 @@ function createAttributeChangedCallback(attributeToPropMap, superAttributeChange
2844
2856
  if (!shared.isUndefined(superAttributeChangedCallback)) {
2845
2857
  // delegate unknown attributes to the super.
2846
2858
  // Typescript does not like it when you treat the `arguments` object as an array
2847
- // @ts-ignore type-mismatch
2859
+ // @ts-expect-error type-mismatch
2848
2860
  superAttributeChangedCallback.apply(this, arguments);
2849
2861
  }
2850
2862
  return;
@@ -3364,6 +3376,7 @@ function createComponentDef(Ctor) {
3364
3376
  /**
3365
3377
  * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
3366
3378
  * subject to change or being removed.
3379
+ * @param ctor
3367
3380
  */
3368
3381
  function isComponentConstructor(ctor) {
3369
3382
  if (!shared.isFunction(ctor)) {
@@ -3437,6 +3450,7 @@ const lightingElementDef = {
3437
3450
  /**
3438
3451
  * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
3439
3452
  * subject to change or being removed.
3453
+ * @param Ctor
3440
3454
  */
3441
3455
  function getComponentDef(Ctor) {
3442
3456
  const def = getComponentInternalDef(Ctor);
@@ -3633,6 +3647,8 @@ function getNearestShadowComponent(vm) {
3633
3647
  * If the component that is currently being rendered uses scoped styles,
3634
3648
  * this returns the unique token for that scoped stylesheet. Otherwise
3635
3649
  * it returns null.
3650
+ * @param owner
3651
+ * @param legacy
3636
3652
  */
3637
3653
  // TODO [#3733]: remove support for legacy scope tokens
3638
3654
  function getScopeTokenClass(owner, legacy) {
@@ -3646,6 +3662,7 @@ function getScopeTokenClass(owner, legacy) {
3646
3662
  * exists. Otherwise it returns null.
3647
3663
  *
3648
3664
  * A host style token is applied to the component if scoped styles are used.
3665
+ * @param vnode
3649
3666
  */
3650
3667
  function getStylesheetTokenHost(vnode) {
3651
3668
  const { template } = getComponentInternalDef(vnode.ctor);
@@ -4054,11 +4071,9 @@ function traverseAndSetElements(root, parts, renderer) {
4054
4071
  }
4055
4072
  /**
4056
4073
  * Given an array of static parts, do all the mounting required for these parts.
4057
- *
4058
- * @param root - the root element
4059
- * @param vnode - the parent VStatic
4060
- * @param renderer - the renderer to use
4061
- * @param mount - true this is a first (mount) render as opposed to a subsequent (patch) render
4074
+ * @param root the root element
4075
+ * @param vnode the parent VStatic
4076
+ * @param renderer the renderer to use
4062
4077
  */
4063
4078
  function mountStaticParts(root, vnode, renderer) {
4064
4079
  // On the server, we don't support ref (because it relies on renderedCallback), nor do we
@@ -4083,9 +4098,8 @@ function mountStaticParts(root, vnode, renderer) {
4083
4098
  }
4084
4099
  /**
4085
4100
  * Mounts elements to the newly generated VStatic node
4086
- *
4087
- * @param n1 - the previous VStatic vnode
4088
- * @param n2 - the current VStatic vnode
4101
+ * @param n1 the previous VStatic vnode
4102
+ * @param n2 the current VStatic vnode
4089
4103
  */
4090
4104
  function patchStaticParts(n1, n2) {
4091
4105
  // On the server, we don't support ref (because it relies on renderedCallback), nor do we
@@ -4600,6 +4614,7 @@ function allocateChildren(vnode, vm) {
4600
4614
  * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
4601
4615
  *
4602
4616
  * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
4617
+ * @param children
4603
4618
  */
4604
4619
  function flattenFragmentsInChildren(children) {
4605
4620
  const flattenedChildren = [];
@@ -5213,6 +5228,7 @@ function i(iterable, factory) {
5213
5228
  }
5214
5229
  /**
5215
5230
  * [f]lattening
5231
+ * @param items
5216
5232
  */
5217
5233
  function f(items) {
5218
5234
  if (process.env.NODE_ENV !== 'production') {
@@ -5329,6 +5345,10 @@ function fid(url) {
5329
5345
  * [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5330
5346
  *
5331
5347
  * TODO [#3331]: remove usage of lwc:dynamic in 246
5348
+ * @param sel
5349
+ * @param Ctor
5350
+ * @param data
5351
+ * @param children
5332
5352
  */
5333
5353
  function ddc(sel, Ctor, data, children = EmptyArray) {
5334
5354
  if (process.env.NODE_ENV !== 'production') {
@@ -5347,6 +5367,9 @@ function ddc(sel, Ctor, data, children = EmptyArray) {
5347
5367
  }
5348
5368
  /**
5349
5369
  * [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
5370
+ * @param Ctor
5371
+ * @param data
5372
+ * @param children
5350
5373
  */
5351
5374
  function dc(Ctor, data, children = EmptyArray) {
5352
5375
  if (process.env.NODE_ENV !== 'production') {
@@ -5374,13 +5397,13 @@ function dc(Ctor, data, children = EmptyArray) {
5374
5397
  * to the engine that a particular collection of children must be diffed using the slow
5375
5398
  * algo based on keys due to the nature of the list. E.g.:
5376
5399
  *
5377
- * - slot element's children: the content of the slot has to be dynamic when in synthetic
5378
- * shadow mode because the `vnode.children` might be the slotted
5379
- * content vs default content, in which case the size and the
5380
- * keys are not matching.
5381
- * - children that contain dynamic components
5382
- * - children that are produced by iteration
5383
- *
5400
+ * - slot element's children: the content of the slot has to be dynamic when in synthetic
5401
+ * shadow mode because the `vnode.children` might be the slotted
5402
+ * content vs default content, in which case the size and the
5403
+ * keys are not matching.
5404
+ * - children that contain dynamic components
5405
+ * - children that are produced by iteration
5406
+ * @param vnodes
5384
5407
  */
5385
5408
  function sc(vnodes) {
5386
5409
  if (process.env.NODE_ENV !== 'production') {
@@ -5404,6 +5427,7 @@ let sanitizeHtmlContentHook = () => {
5404
5427
  };
5405
5428
  /**
5406
5429
  * Sets the sanitizeHtmlContentHook.
5430
+ * @param newHookImpl
5407
5431
  */
5408
5432
  function setSanitizeHtmlContentHook(newHookImpl) {
5409
5433
  sanitizeHtmlContentHook = newHookImpl;
@@ -5585,9 +5609,27 @@ function validateLightDomTemplate(template, vm) {
5585
5609
  }
5586
5610
  }
5587
5611
  }
5612
+ // This should be a no-op outside of LWC's Karma tests, where it's not needed
5613
+ let registerFragmentCache = shared.noop;
5614
+ // Only used in LWC's Karma tests
5615
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
5616
+ // Keep track of fragmentCaches, so we can clear them in LWC's Karma tests
5617
+ const fragmentCaches = [];
5618
+ registerFragmentCache = (fragmentCache) => {
5619
+ fragmentCaches.push(fragmentCache);
5620
+ };
5621
+ window.__lwcResetFragmentCaches = () => {
5622
+ for (const fragmentCache of fragmentCaches) {
5623
+ for (const key of shared.keys(fragmentCache)) {
5624
+ delete fragmentCache[key];
5625
+ }
5626
+ }
5627
+ };
5628
+ }
5588
5629
  function buildParseFragmentFn(createFragmentFn) {
5589
5630
  return (strings, ...keys) => {
5590
5631
  const cache = shared.create(null);
5632
+ registerFragmentCache(cache);
5591
5633
  return function () {
5592
5634
  const { context: { hasScopedStyles, stylesheetToken, legacyStylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
5593
5635
  const hasStyleToken = !shared.isUndefined(stylesheetToken);
@@ -5600,11 +5642,6 @@ function buildParseFragmentFn(createFragmentFn) {
5600
5642
  if (hasStyleToken && isSyntheticShadow) {
5601
5643
  cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
5602
5644
  }
5603
- if (hasLegacyToken) {
5604
- // This isn't strictly required for prod, but it's required for our karma tests
5605
- // since the lwcRuntimeFlag may change over time
5606
- cacheKey |= 4 /* FragmentCache.HAS_LEGACY_SCOPE_TOKEN */;
5607
- }
5608
5645
  if (!shared.isUndefined(cache[cacheKey])) {
5609
5646
  return cache[cacheKey];
5610
5647
  }
@@ -5845,6 +5882,8 @@ const registeredComponentMap = new Map();
5845
5882
  /**
5846
5883
  * INTERNAL: This function can only be invoked by compiled code. The compiler
5847
5884
  * will prevent this function from being imported by userland code.
5885
+ * @param Ctor
5886
+ * @param metadata
5848
5887
  */
5849
5888
  function registerComponent(
5850
5889
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
@@ -6202,7 +6241,7 @@ function computeShadowMode(def, owner, renderer, hydrated) {
6202
6241
  return shadowMode;
6203
6242
  }
6204
6243
  function assertIsVM(obj) {
6205
- if (shared.isNull(obj) || !shared.isObject(obj) || !('renderRoot' in obj)) {
6244
+ if (!shared.isObject(obj) || shared.isNull(obj) || !('renderRoot' in obj)) {
6206
6245
  throw new TypeError(`${obj} is not a VM.`);
6207
6246
  }
6208
6247
  }
@@ -6395,6 +6434,7 @@ function runLightChildNodesDisconnectedCallback(vm) {
6395
6434
  * need to continue into its children because by attempting to disconnect the
6396
6435
  * custom element itself will trigger the removal of anything slotted or anything
6397
6436
  * defined on its shadow.
6437
+ * @param vnodes
6398
6438
  */
6399
6439
  function recursivelyDisconnectChildren(vnodes) {
6400
6440
  for (let i = 0, len = vnodes.length; i < len; i += 1) {
@@ -6791,7 +6831,6 @@ function enableDetection() {
6791
6831
  throw new Error('detect-non-standard-aria.ts loaded before @lwc/aria-reflection');
6792
6832
  }
6793
6833
  }
6794
- // @ts-ignore
6795
6834
  const { get, set } = descriptor;
6796
6835
  // It's important for this defineProperty call to happen _after_ ARIA accessors are applied to the
6797
6836
  // BaseBridgeElement and LightningElement prototypes. Otherwise, we will log/report for access of non-standard
@@ -7402,7 +7441,7 @@ function warnOnArrayMutation(stylesheets) {
7402
7441
  const originalArrayMethod = getOriginalArrayMethod(prop);
7403
7442
  stylesheets[prop] = function arrayMutationWarningWrapper() {
7404
7443
  reportTemplateViolation('stylesheets');
7405
- // @ts-ignore
7444
+ // @ts-expect-error can't properly determine the right `this`
7406
7445
  return originalArrayMethod.apply(this, arguments);
7407
7446
  };
7408
7447
  }
@@ -7550,6 +7589,7 @@ function freezeTemplate(tmpl) {
7550
7589
  /**
7551
7590
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7552
7591
  * This API is subject to change or being removed.
7592
+ * @param elm
7553
7593
  */
7554
7594
  function getComponentConstructor(elm) {
7555
7595
  let ctor = null;
@@ -7574,6 +7614,7 @@ function getComponentConstructor(elm) {
7574
7614
  * EXPERIMENTAL: This function allows you to create a reactive readonly
7575
7615
  * membrane around any object value. This API is subject to change or
7576
7616
  * being removed.
7617
+ * @param obj
7577
7618
  */
7578
7619
  function readonly(obj) {
7579
7620
  if (process.env.NODE_ENV !== 'production') {
@@ -7628,5 +7669,5 @@ exports.swapTemplate = swapTemplate;
7628
7669
  exports.track = track;
7629
7670
  exports.unwrap = unwrap;
7630
7671
  exports.wire = wire;
7631
- /** version: 6.2.0 */
7672
+ /** version: 6.3.0 */
7632
7673
  //# sourceMappingURL=index.cjs.js.map