@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.js CHANGED
@@ -23,8 +23,7 @@ let enabled$1 = false;
23
23
  const reportingControl = {
24
24
  /**
25
25
  * Attach a new reporting control (aka dispatcher).
26
- *
27
- * @param dispatcher - reporting control
26
+ * @param dispatcher reporting control
28
27
  */
29
28
  attachDispatcher(dispatcher) {
30
29
  enabled$1 = true;
@@ -67,7 +66,7 @@ function onReportingEnabled(callback) {
67
66
  /**
68
67
  * Report to the current dispatcher, if there is one.
69
68
  * @param reportingEventId
70
- * @param payload - data to report
69
+ * @param payload data to report
71
70
  */
72
71
  function report(reportingEventId, payload) {
73
72
  if (enabled$1) {
@@ -129,7 +128,7 @@ function addErrorComponentStack(vm, error) {
129
128
  }
130
129
 
131
130
  /*
132
- * Copyright (c) 2018, salesforce.com, inc.
131
+ * Copyright (c) 2024, Salesforce, Inc.
133
132
  * All rights reserved.
134
133
  * SPDX-License-Identifier: MIT
135
134
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -137,7 +136,6 @@ function addErrorComponentStack(vm, error) {
137
136
  const alreadyLoggedMessages = new Set();
138
137
  // Only used in LWC's Karma tests
139
138
  if (process.env.NODE_ENV === 'test-karma-lwc') {
140
- // @ts-ignore
141
139
  window.__lwcResetAlreadyLoggedMessages = () => {
142
140
  alreadyLoggedMessages.clear();
143
141
  };
@@ -795,7 +793,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
795
793
  logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
796
794
  }
797
795
  // Typescript does not like it when you treat the `arguments` object as an array
798
- // @ts-ignore type-mismatch
796
+ // @ts-expect-error type-mismatch
799
797
  return originalAddEventListener.apply(this, arguments);
800
798
  },
801
799
  }),
@@ -844,7 +842,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
844
842
  logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
845
843
  }
846
844
  // Typescript does not like it when you treat the `arguments` object as an array
847
- // @ts-ignore type-mismatch
845
+ // @ts-expect-error type-mismatch
848
846
  return originalAddEventListener.apply(this, arguments);
849
847
  },
850
848
  }),
@@ -1430,6 +1428,7 @@ const reactiveMembrane = new ObservableMembrane({
1430
1428
  * EXPERIMENTAL: This function implements an unwrap mechanism that
1431
1429
  * works for observable membrane objects. This API is subject to
1432
1430
  * change or being removed.
1431
+ * @param value
1433
1432
  */
1434
1433
  function unwrap(value) {
1435
1434
  // On the server side, we don't need mutation tracking. Skipping it improves performance.
@@ -1543,6 +1542,8 @@ function applyShadowMigrateMode(shadowRoot) {
1543
1542
  * that a Custom Element can support (including AOM properties), which
1544
1543
  * determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
1545
1544
  * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
1545
+ * @param propName
1546
+ * @param descriptor
1546
1547
  */
1547
1548
  function createBridgeToElementDescriptor(propName, descriptor) {
1548
1549
  const { get, set, enumerable, configurable } = descriptor;
@@ -1592,8 +1593,8 @@ const refsCache = new WeakMap();
1592
1593
  /**
1593
1594
  * This class is the base class for any LWC element.
1594
1595
  * Some elements directly extends this class, others implement it via inheritance.
1595
- **/
1596
- // @ts-ignore
1596
+ */
1597
+ // @ts-expect-error When exported, it will conform, but we need to build it first!
1597
1598
  const LightningElement = function () {
1598
1599
  // This should be as performant as possible, while any initialization should be done lazily
1599
1600
  if (isNull(vmBeingConstructed)) {
@@ -1735,7 +1736,7 @@ function createElementInternalsProxy(elementInternals, isFormAssociated) {
1735
1736
  });
1736
1737
  return elementInternalsProxy;
1737
1738
  }
1738
- // @ts-ignore
1739
+ // Type assertion because we need to build the prototype before it satisfies the interface.
1739
1740
  LightningElement.prototype = {
1740
1741
  constructor: LightningElement,
1741
1742
  dispatchEvent(event) {
@@ -1937,6 +1938,9 @@ LightningElement.prototype = {
1937
1938
  if (process.env.NODE_ENV !== 'production') {
1938
1939
  warnIfInvokedDuringConstruction(vm, 'childNodes');
1939
1940
  }
1941
+ // getChildNodes returns a NodeList, which has `item(index: number): Node | null`.
1942
+ // NodeListOf<T> extends NodeList, but claims to not return null. That seems inaccurate,
1943
+ // but these are built-in types, so ultimately not our problem.
1940
1944
  return renderer.getChildNodes(vm.elm);
1941
1945
  },
1942
1946
  get firstChild() {
@@ -2176,7 +2180,7 @@ function createConfigWatcher(component, configCallback, callbackWhenConfigIsRead
2176
2180
  ro.observe(() => (config = configCallback(component)));
2177
2181
  // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2178
2182
  // TODO: dev-mode validation of config based on the adapter.configSchema
2179
- // @ts-ignore it is assigned in the observe() callback
2183
+ // @ts-expect-error it is assigned in the observe() callback
2180
2184
  callbackWhenConfigIsReady(config);
2181
2185
  };
2182
2186
  return {
@@ -2252,7 +2256,7 @@ function createConnector(vm, name, wireDef) {
2252
2256
  });
2253
2257
  }
2254
2258
  return {
2255
- // @ts-ignore the boundary protection executes sync, connector is always defined
2259
+ // @ts-expect-error the boundary protection executes sync, connector is always defined
2256
2260
  connector,
2257
2261
  computeConfigAndUpdate,
2258
2262
  resetConfigWatcher: () => ro.reset(),
@@ -2461,9 +2465,11 @@ function internalTrackDecorator(key) {
2461
2465
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2462
2466
  */
2463
2467
  /**
2464
- * @wire decorator to wire fields and methods to a wire adapter in
2468
+ * The @wire decorator wires fields and methods to a wire adapter in
2465
2469
  * LWC Components. This function implements the internals of this
2466
2470
  * decorator.
2471
+ * @param _adapter
2472
+ * @param _config
2467
2473
  */
2468
2474
  function wire(_adapter, _config) {
2469
2475
  if (process.env.NODE_ENV !== 'production') {
@@ -2574,6 +2580,8 @@ function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
2574
2580
  /**
2575
2581
  * INTERNAL: This function can only be invoked by compiled code. The compiler
2576
2582
  * will prevent this function from being imported by user-land code.
2583
+ * @param Ctor
2584
+ * @param meta
2577
2585
  */
2578
2586
  function registerDecorators(Ctor, meta) {
2579
2587
  const proto = Ctor.prototype;
@@ -2727,7 +2735,6 @@ function getDecoratorsMeta(Ctor) {
2727
2735
  let warned = false;
2728
2736
  // Only used in LWC's Karma tests
2729
2737
  if (process.env.NODE_ENV === 'test-karma-lwc') {
2730
- // @ts-ignore
2731
2738
  window.__lwcResetWarnedOnVersionMismatch = () => {
2732
2739
  warned = false;
2733
2740
  };
@@ -2762,6 +2769,7 @@ function isTemplateRegistered(tpl) {
2762
2769
  /**
2763
2770
  * INTERNAL: This function can only be invoked by compiled code. The compiler
2764
2771
  * will prevent this function from being imported by userland code.
2772
+ * @param tpl
2765
2773
  */
2766
2774
  function registerTemplate(tpl) {
2767
2775
  if (process.env.NODE_ENV !== 'production') {
@@ -2775,6 +2783,10 @@ function registerTemplate(tpl) {
2775
2783
  /**
2776
2784
  * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
2777
2785
  * libraries to sanitize vulnerable attributes.
2786
+ * @param tagName
2787
+ * @param namespaceUri
2788
+ * @param attrName
2789
+ * @param attrValue
2778
2790
  */
2779
2791
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
2780
2792
  // locker-service patches this function during runtime to sanitize vulnerable attributes. When
@@ -2840,7 +2852,7 @@ function createAttributeChangedCallback(attributeToPropMap, superAttributeChange
2840
2852
  if (!isUndefined$1(superAttributeChangedCallback)) {
2841
2853
  // delegate unknown attributes to the super.
2842
2854
  // Typescript does not like it when you treat the `arguments` object as an array
2843
- // @ts-ignore type-mismatch
2855
+ // @ts-expect-error type-mismatch
2844
2856
  superAttributeChangedCallback.apply(this, arguments);
2845
2857
  }
2846
2858
  return;
@@ -3360,6 +3372,7 @@ function createComponentDef(Ctor) {
3360
3372
  /**
3361
3373
  * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
3362
3374
  * subject to change or being removed.
3375
+ * @param ctor
3363
3376
  */
3364
3377
  function isComponentConstructor(ctor) {
3365
3378
  if (!isFunction$1(ctor)) {
@@ -3433,6 +3446,7 @@ const lightingElementDef = {
3433
3446
  /**
3434
3447
  * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
3435
3448
  * subject to change or being removed.
3449
+ * @param Ctor
3436
3450
  */
3437
3451
  function getComponentDef(Ctor) {
3438
3452
  const def = getComponentInternalDef(Ctor);
@@ -3629,6 +3643,8 @@ function getNearestShadowComponent(vm) {
3629
3643
  * If the component that is currently being rendered uses scoped styles,
3630
3644
  * this returns the unique token for that scoped stylesheet. Otherwise
3631
3645
  * it returns null.
3646
+ * @param owner
3647
+ * @param legacy
3632
3648
  */
3633
3649
  // TODO [#3733]: remove support for legacy scope tokens
3634
3650
  function getScopeTokenClass(owner, legacy) {
@@ -3642,6 +3658,7 @@ function getScopeTokenClass(owner, legacy) {
3642
3658
  * exists. Otherwise it returns null.
3643
3659
  *
3644
3660
  * A host style token is applied to the component if scoped styles are used.
3661
+ * @param vnode
3645
3662
  */
3646
3663
  function getStylesheetTokenHost(vnode) {
3647
3664
  const { template } = getComponentInternalDef(vnode.ctor);
@@ -4050,11 +4067,9 @@ function traverseAndSetElements(root, parts, renderer) {
4050
4067
  }
4051
4068
  /**
4052
4069
  * Given an array of static parts, do all the mounting required for these parts.
4053
- *
4054
- * @param root - the root element
4055
- * @param vnode - the parent VStatic
4056
- * @param renderer - the renderer to use
4057
- * @param mount - true this is a first (mount) render as opposed to a subsequent (patch) render
4070
+ * @param root the root element
4071
+ * @param vnode the parent VStatic
4072
+ * @param renderer the renderer to use
4058
4073
  */
4059
4074
  function mountStaticParts(root, vnode, renderer) {
4060
4075
  // On the server, we don't support ref (because it relies on renderedCallback), nor do we
@@ -4079,9 +4094,8 @@ function mountStaticParts(root, vnode, renderer) {
4079
4094
  }
4080
4095
  /**
4081
4096
  * Mounts elements to the newly generated VStatic node
4082
- *
4083
- * @param n1 - the previous VStatic vnode
4084
- * @param n2 - the current VStatic vnode
4097
+ * @param n1 the previous VStatic vnode
4098
+ * @param n2 the current VStatic vnode
4085
4099
  */
4086
4100
  function patchStaticParts(n1, n2) {
4087
4101
  // On the server, we don't support ref (because it relies on renderedCallback), nor do we
@@ -4596,6 +4610,7 @@ function allocateChildren(vnode, vm) {
4596
4610
  * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
4597
4611
  *
4598
4612
  * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
4613
+ * @param children
4599
4614
  */
4600
4615
  function flattenFragmentsInChildren(children) {
4601
4616
  const flattenedChildren = [];
@@ -5209,6 +5224,7 @@ function i(iterable, factory) {
5209
5224
  }
5210
5225
  /**
5211
5226
  * [f]lattening
5227
+ * @param items
5212
5228
  */
5213
5229
  function f(items) {
5214
5230
  if (process.env.NODE_ENV !== 'production') {
@@ -5325,6 +5341,10 @@ function fid(url) {
5325
5341
  * [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5326
5342
  *
5327
5343
  * TODO [#3331]: remove usage of lwc:dynamic in 246
5344
+ * @param sel
5345
+ * @param Ctor
5346
+ * @param data
5347
+ * @param children
5328
5348
  */
5329
5349
  function ddc(sel, Ctor, data, children = EmptyArray) {
5330
5350
  if (process.env.NODE_ENV !== 'production') {
@@ -5343,6 +5363,9 @@ function ddc(sel, Ctor, data, children = EmptyArray) {
5343
5363
  }
5344
5364
  /**
5345
5365
  * [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
5366
+ * @param Ctor
5367
+ * @param data
5368
+ * @param children
5346
5369
  */
5347
5370
  function dc(Ctor, data, children = EmptyArray) {
5348
5371
  if (process.env.NODE_ENV !== 'production') {
@@ -5370,13 +5393,13 @@ function dc(Ctor, data, children = EmptyArray) {
5370
5393
  * to the engine that a particular collection of children must be diffed using the slow
5371
5394
  * algo based on keys due to the nature of the list. E.g.:
5372
5395
  *
5373
- * - slot element's children: the content of the slot has to be dynamic when in synthetic
5374
- * shadow mode because the `vnode.children` might be the slotted
5375
- * content vs default content, in which case the size and the
5376
- * keys are not matching.
5377
- * - children that contain dynamic components
5378
- * - children that are produced by iteration
5379
- *
5396
+ * - slot element's children: the content of the slot has to be dynamic when in synthetic
5397
+ * shadow mode because the `vnode.children` might be the slotted
5398
+ * content vs default content, in which case the size and the
5399
+ * keys are not matching.
5400
+ * - children that contain dynamic components
5401
+ * - children that are produced by iteration
5402
+ * @param vnodes
5380
5403
  */
5381
5404
  function sc(vnodes) {
5382
5405
  if (process.env.NODE_ENV !== 'production') {
@@ -5400,6 +5423,7 @@ let sanitizeHtmlContentHook = () => {
5400
5423
  };
5401
5424
  /**
5402
5425
  * Sets the sanitizeHtmlContentHook.
5426
+ * @param newHookImpl
5403
5427
  */
5404
5428
  function setSanitizeHtmlContentHook(newHookImpl) {
5405
5429
  sanitizeHtmlContentHook = newHookImpl;
@@ -5581,9 +5605,27 @@ function validateLightDomTemplate(template, vm) {
5581
5605
  }
5582
5606
  }
5583
5607
  }
5608
+ // This should be a no-op outside of LWC's Karma tests, where it's not needed
5609
+ let registerFragmentCache = noop;
5610
+ // Only used in LWC's Karma tests
5611
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
5612
+ // Keep track of fragmentCaches, so we can clear them in LWC's Karma tests
5613
+ const fragmentCaches = [];
5614
+ registerFragmentCache = (fragmentCache) => {
5615
+ fragmentCaches.push(fragmentCache);
5616
+ };
5617
+ window.__lwcResetFragmentCaches = () => {
5618
+ for (const fragmentCache of fragmentCaches) {
5619
+ for (const key of keys(fragmentCache)) {
5620
+ delete fragmentCache[key];
5621
+ }
5622
+ }
5623
+ };
5624
+ }
5584
5625
  function buildParseFragmentFn(createFragmentFn) {
5585
5626
  return (strings, ...keys) => {
5586
5627
  const cache = create(null);
5628
+ registerFragmentCache(cache);
5587
5629
  return function () {
5588
5630
  const { context: { hasScopedStyles, stylesheetToken, legacyStylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
5589
5631
  const hasStyleToken = !isUndefined$1(stylesheetToken);
@@ -5596,11 +5638,6 @@ function buildParseFragmentFn(createFragmentFn) {
5596
5638
  if (hasStyleToken && isSyntheticShadow) {
5597
5639
  cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
5598
5640
  }
5599
- if (hasLegacyToken) {
5600
- // This isn't strictly required for prod, but it's required for our karma tests
5601
- // since the lwcRuntimeFlag may change over time
5602
- cacheKey |= 4 /* FragmentCache.HAS_LEGACY_SCOPE_TOKEN */;
5603
- }
5604
5641
  if (!isUndefined$1(cache[cacheKey])) {
5605
5642
  return cache[cacheKey];
5606
5643
  }
@@ -5841,6 +5878,8 @@ const registeredComponentMap = new Map();
5841
5878
  /**
5842
5879
  * INTERNAL: This function can only be invoked by compiled code. The compiler
5843
5880
  * will prevent this function from being imported by userland code.
5881
+ * @param Ctor
5882
+ * @param metadata
5844
5883
  */
5845
5884
  function registerComponent(
5846
5885
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
@@ -6198,7 +6237,7 @@ function computeShadowMode(def, owner, renderer, hydrated) {
6198
6237
  return shadowMode;
6199
6238
  }
6200
6239
  function assertIsVM(obj) {
6201
- if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
6240
+ if (!isObject(obj) || isNull(obj) || !('renderRoot' in obj)) {
6202
6241
  throw new TypeError(`${obj} is not a VM.`);
6203
6242
  }
6204
6243
  }
@@ -6391,6 +6430,7 @@ function runLightChildNodesDisconnectedCallback(vm) {
6391
6430
  * need to continue into its children because by attempting to disconnect the
6392
6431
  * custom element itself will trigger the removal of anything slotted or anything
6393
6432
  * defined on its shadow.
6433
+ * @param vnodes
6394
6434
  */
6395
6435
  function recursivelyDisconnectChildren(vnodes) {
6396
6436
  for (let i = 0, len = vnodes.length; i < len; i += 1) {
@@ -6787,7 +6827,6 @@ function enableDetection() {
6787
6827
  throw new Error('detect-non-standard-aria.ts loaded before @lwc/aria-reflection');
6788
6828
  }
6789
6829
  }
6790
- // @ts-ignore
6791
6830
  const { get, set } = descriptor;
6792
6831
  // It's important for this defineProperty call to happen _after_ ARIA accessors are applied to the
6793
6832
  // BaseBridgeElement and LightningElement prototypes. Otherwise, we will log/report for access of non-standard
@@ -7398,7 +7437,7 @@ function warnOnArrayMutation(stylesheets) {
7398
7437
  const originalArrayMethod = getOriginalArrayMethod(prop);
7399
7438
  stylesheets[prop] = function arrayMutationWarningWrapper() {
7400
7439
  reportTemplateViolation('stylesheets');
7401
- // @ts-ignore
7440
+ // @ts-expect-error can't properly determine the right `this`
7402
7441
  return originalArrayMethod.apply(this, arguments);
7403
7442
  };
7404
7443
  }
@@ -7546,6 +7585,7 @@ function freezeTemplate(tmpl) {
7546
7585
  /**
7547
7586
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7548
7587
  * This API is subject to change or being removed.
7588
+ * @param elm
7549
7589
  */
7550
7590
  function getComponentConstructor(elm) {
7551
7591
  let ctor = null;
@@ -7570,6 +7610,7 @@ function getComponentConstructor(elm) {
7570
7610
  * EXPERIMENTAL: This function allows you to create a reactive readonly
7571
7611
  * membrane around any object value. This API is subject to change or
7572
7612
  * being removed.
7613
+ * @param obj
7573
7614
  */
7574
7615
  function readonly(obj) {
7575
7616
  if (process.env.NODE_ENV !== 'production') {
@@ -7582,5 +7623,5 @@ function readonly(obj) {
7582
7623
  }
7583
7624
 
7584
7625
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7585
- /** version: 6.2.0 */
7626
+ /** version: 6.3.0 */
7586
7627
  //# sourceMappingURL=index.js.map