lwc 2.28.1 → 2.30.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 (37) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +319 -683
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +319 -683
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +201 -624
  5. package/dist/engine-dom/iife/es5/engine-dom.js +1138 -2843
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +892 -2428
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +319 -683
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +201 -624
  11. package/dist/engine-dom/umd/es5/engine-dom.js +1138 -2843
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +892 -2428
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +204 -584
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +204 -584
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +99 -323
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +99 -323
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +98 -316
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +483 -1220
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +470 -1187
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +99 -323
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +98 -316
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +483 -1220
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +470 -1187
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service.min.js +1 -1
  29. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service.js +13 -68
  31. package/dist/wire-service/iife/es5/wire-service_debug.js +13 -68
  32. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  33. package/dist/wire-service/umd/es2017/wire-service.min.js +1 -1
  34. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es5/wire-service.js +13 -68
  36. package/dist/wire-service/umd/es5/wire-service_debug.js +13 -68
  37. package/package.json +7 -7
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.28.1";
302
+ const LWC_VERSION = "2.30.0";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.28.1 */
304
+ /** version: 2.30.0 */
305
305
 
306
306
  /**
307
307
  * Copyright (C) 2018 salesforce.com, inc.
@@ -383,7 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
383
383
  patch$1(propName);
384
384
  }
385
385
  }
386
- /** version: 2.28.1 */
386
+ /** version: 2.30.0 */
387
387
 
388
388
  /**
389
389
  * Copyright (C) 2018 salesforce.com, inc.
@@ -463,7 +463,7 @@ function setFeatureFlagForTest(name, value) {
463
463
  setFeatureFlag(name, value);
464
464
  }
465
465
  }
466
- /** version: 2.28.1 */
466
+ /** version: 2.30.0 */
467
467
 
468
468
  /*
469
469
  * Copyright (c) 2018, salesforce.com, inc.
@@ -471,16 +471,14 @@ function setFeatureFlagForTest(name, value) {
471
471
  * SPDX-License-Identifier: MIT
472
472
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
473
473
  */
474
+ // Only used in LWC's Karma tests
474
475
  // @ts-ignore
475
-
476
476
  if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
477
477
  window.addEventListener('test-dummy-flag', () => {
478
478
  let hasFlag = false;
479
-
480
479
  if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
481
480
  hasFlag = true;
482
481
  }
483
-
484
482
  window.dispatchEvent(new CustomEvent('has-dummy-flag', {
485
483
  detail: {
486
484
  package: '@lwc/engine-dom',
@@ -498,16 +496,14 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
498
496
  * SPDX-License-Identifier: MIT
499
497
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
500
498
  */
499
+ // Only used in LWC's Karma tests
501
500
  // @ts-ignore
502
-
503
501
  if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
504
502
  window.addEventListener('test-dummy-flag', () => {
505
503
  let hasFlag = false;
506
-
507
504
  if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
508
505
  hasFlag = true;
509
506
  }
510
-
511
507
  window.dispatchEvent(new CustomEvent('has-dummy-flag', {
512
508
  detail: {
513
509
  package: '@lwc/engine-core',
@@ -1733,7 +1729,7 @@ function getGlobal() {
1733
1729
  // Gracefully degrade if not able to locate the global object
1734
1730
  return {};
1735
1731
  }
1736
- function init() {
1732
+ function init$1() {
1737
1733
  /* istanbul ignore if */
1738
1734
  if (process.env.NODE_ENV === 'production') {
1739
1735
  // this method should never leak to prod
@@ -1751,7 +1747,7 @@ function init() {
1751
1747
 
1752
1748
  /* istanbul ignore else */
1753
1749
  if (process.env.NODE_ENV !== 'production') {
1754
- init();
1750
+ init$1();
1755
1751
  }
1756
1752
  function defaultValueIsObservable(value) {
1757
1753
  // intentionally checking for null
@@ -2341,39 +2337,31 @@ function api$1() {
2341
2337
  if (process.env.NODE_ENV !== 'production') {
2342
2338
  assert.fail(`@api decorator can only be used as a decorator function.`);
2343
2339
  }
2344
-
2345
2340
  throw new Error();
2346
2341
  }
2347
2342
  function createPublicPropertyDescriptor(key) {
2348
2343
  return {
2349
2344
  get() {
2350
2345
  const vm = getAssociatedVM(this);
2351
-
2352
2346
  if (isBeingConstructed(vm)) {
2353
2347
  if (process.env.NODE_ENV !== 'production') {
2354
2348
  logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
2355
2349
  }
2356
-
2357
2350
  return;
2358
2351
  }
2359
-
2360
2352
  componentValueObserved(vm, key);
2361
2353
  return vm.cmpProps[key];
2362
2354
  },
2363
-
2364
2355
  set(newValue) {
2365
2356
  const vm = getAssociatedVM(this);
2366
-
2367
2357
  if (process.env.NODE_ENV !== 'production') {
2368
2358
  const vmBeingRendered = getVMBeingRendered();
2369
2359
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2370
2360
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2371
2361
  }
2372
-
2373
2362
  vm.cmpProps[key] = newValue;
2374
2363
  componentValueMutated(vm, key);
2375
2364
  },
2376
-
2377
2365
  enumerable: true,
2378
2366
  configurable: true
2379
2367
  };
@@ -2385,46 +2373,37 @@ function createPublicAccessorDescriptor(key, descriptor) {
2385
2373
  enumerable,
2386
2374
  configurable
2387
2375
  } = descriptor;
2388
-
2389
2376
  if (!isFunction$1(get)) {
2390
2377
  if (process.env.NODE_ENV !== 'production') {
2391
2378
  assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2392
2379
  }
2393
-
2394
2380
  throw new Error();
2395
2381
  }
2396
-
2397
2382
  return {
2398
2383
  get() {
2399
2384
  if (process.env.NODE_ENV !== 'production') {
2400
2385
  // Assert that the this value is an actual Component with an associated VM.
2401
2386
  getAssociatedVM(this);
2402
2387
  }
2403
-
2404
2388
  return get.call(this);
2405
2389
  },
2406
-
2407
2390
  set(newValue) {
2408
2391
  const vm = getAssociatedVM(this);
2409
-
2410
2392
  if (process.env.NODE_ENV !== 'production') {
2411
2393
  const vmBeingRendered = getVMBeingRendered();
2412
2394
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2413
2395
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2414
2396
  }
2415
-
2416
2397
  if (set) {
2417
2398
  if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2418
2399
  let ro = vm.oar[key];
2419
-
2420
2400
  if (isUndefined$1(ro)) {
2421
2401
  ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2422
- } // every time we invoke this setter from outside (through this wrapper setter)
2402
+ }
2403
+ // every time we invoke this setter from outside (through this wrapper setter)
2423
2404
  // we should reset the value and then debounce just in case there is a pending
2424
2405
  // invocation the next tick that is not longer relevant since the value is changing
2425
2406
  // from outside.
2426
-
2427
-
2428
2407
  ro.reset(newValue);
2429
2408
  ro.observe(() => {
2430
2409
  set.call(this, newValue);
@@ -2436,7 +2415,6 @@ function createPublicAccessorDescriptor(key, descriptor) {
2436
2415
  assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
2437
2416
  }
2438
2417
  },
2439
-
2440
2418
  enumerable,
2441
2419
  configurable
2442
2420
  };
@@ -3401,11 +3379,9 @@ function getComponentDef(Ctor) {
3401
3379
  * SPDX-License-Identifier: MIT
3402
3380
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3403
3381
  */
3404
-
3405
3382
  function makeHostToken(token) {
3406
3383
  return `${token}-host`;
3407
3384
  }
3408
-
3409
3385
  function createInlineStyleVNode(content) {
3410
3386
  return api.h('style', {
3411
3387
  key: 'style',
@@ -3414,7 +3390,6 @@ function createInlineStyleVNode(content) {
3414
3390
  }
3415
3391
  }, [api.t(content)]);
3416
3392
  }
3417
-
3418
3393
  function updateStylesheetToken(vm, template) {
3419
3394
  const {
3420
3395
  elm,
@@ -3431,112 +3406,81 @@ function updateStylesheetToken(vm, template) {
3431
3406
  stylesheets: newStylesheets,
3432
3407
  stylesheetToken: newStylesheetToken
3433
3408
  } = template;
3434
- const isSyntheticShadow = renderMode === 1
3435
- /* RenderMode.Shadow */
3436
- && shadowMode === 1
3437
- /* ShadowMode.Synthetic */
3438
- ;
3409
+ const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
3439
3410
  const {
3440
3411
  hasScopedStyles
3441
3412
  } = context;
3442
3413
  let newToken;
3443
3414
  let newHasTokenInClass;
3444
- let newHasTokenInAttribute; // Reset the styling token applied to the host element.
3445
-
3415
+ let newHasTokenInAttribute;
3416
+ // Reset the styling token applied to the host element.
3446
3417
  const {
3447
3418
  stylesheetToken: oldToken,
3448
3419
  hasTokenInClass: oldHasTokenInClass,
3449
3420
  hasTokenInAttribute: oldHasTokenInAttribute
3450
3421
  } = context;
3451
-
3452
3422
  if (!isUndefined$1(oldToken)) {
3453
3423
  if (oldHasTokenInClass) {
3454
3424
  getClassList(elm).remove(makeHostToken(oldToken));
3455
3425
  }
3456
-
3457
3426
  if (oldHasTokenInAttribute) {
3458
3427
  removeAttribute(elm, makeHostToken(oldToken));
3459
3428
  }
3460
- } // Apply the new template styling token to the host element, if the new template has any
3429
+ }
3430
+ // Apply the new template styling token to the host element, if the new template has any
3461
3431
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
3462
-
3463
-
3464
3432
  if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
3465
3433
  newToken = newStylesheetToken;
3466
- } // Set the new styling token on the host element
3467
-
3468
-
3434
+ }
3435
+ // Set the new styling token on the host element
3469
3436
  if (!isUndefined$1(newToken)) {
3470
3437
  if (hasScopedStyles) {
3471
3438
  getClassList(elm).add(makeHostToken(newToken));
3472
3439
  newHasTokenInClass = true;
3473
3440
  }
3474
-
3475
3441
  if (isSyntheticShadow) {
3476
3442
  setAttribute(elm, makeHostToken(newToken), '');
3477
3443
  newHasTokenInAttribute = true;
3478
3444
  }
3479
- } // Update the styling tokens present on the context object.
3480
-
3481
-
3445
+ }
3446
+ // Update the styling tokens present on the context object.
3482
3447
  context.stylesheetToken = newToken;
3483
3448
  context.hasTokenInClass = newHasTokenInClass;
3484
3449
  context.hasTokenInAttribute = newHasTokenInAttribute;
3485
3450
  }
3486
-
3487
3451
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3488
3452
  const content = [];
3489
3453
  let root;
3490
-
3491
3454
  for (let i = 0; i < stylesheets.length; i++) {
3492
3455
  let stylesheet = stylesheets[i];
3493
-
3494
3456
  if (isArray$1(stylesheet)) {
3495
3457
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
3496
3458
  } else {
3497
3459
  if (process.env.NODE_ENV !== 'production') {
3498
3460
  // Check for compiler version mismatch in dev mode only
3499
- checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
3461
+ checkVersionMismatch(stylesheet, 'stylesheet');
3462
+ // in dev-mode, we support hot swapping of stylesheet, which means that
3500
3463
  // the component instance might be attempting to use an old version of
3501
3464
  // the stylesheet, while internally, we have a replacement for it.
3502
-
3503
3465
  stylesheet = getStyleOrSwappedStyle(stylesheet);
3504
3466
  }
3505
-
3506
3467
  const isScopedCss = stylesheet[KEY__SCOPED_CSS];
3507
-
3508
3468
  if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
3509
- if (!isScopedCss && vm.renderMode === 0
3510
- /* RenderMode.Light */
3511
- ) {
3469
+ if (!isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
3512
3470
  logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
3513
3471
  continue;
3514
3472
  }
3515
- } // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
3516
-
3517
-
3518
- const scopeToken = isScopedCss || vm.shadowMode === 1
3519
- /* ShadowMode.Synthetic */
3520
- && vm.renderMode === 1
3521
- /* RenderMode.Shadow */
3522
- ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
3473
+ }
3474
+ // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
3475
+ const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
3476
+ // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
3523
3477
  // native shadow DOM. Synthetic shadow DOM never uses `:host`.
3524
-
3525
- const useActualHostSelector = vm.renderMode === 0
3526
- /* RenderMode.Light */
3527
- ? !isScopedCss : vm.shadowMode === 0
3528
- /* ShadowMode.Native */
3529
- ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
3478
+ const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
3479
+ // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
3530
3480
  // we use an attribute selector on the host to simulate :dir().
3531
-
3532
3481
  let useNativeDirPseudoclass;
3533
-
3534
- if (vm.renderMode === 1
3535
- /* RenderMode.Shadow */
3536
- ) {
3537
- useNativeDirPseudoclass = vm.shadowMode === 0
3538
- /* ShadowMode.Native */
3539
- ;
3482
+ if (vm.renderMode === 1 /* RenderMode.Shadow */) {
3483
+ useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
3540
3484
  } else {
3541
3485
  // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
3542
3486
  // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
@@ -3544,48 +3488,36 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3544
3488
  // Only calculate the root once as necessary
3545
3489
  root = getNearestShadowComponent(vm);
3546
3490
  }
3547
-
3548
- useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
3549
- /* ShadowMode.Native */
3550
- ;
3491
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
3551
3492
  }
3552
3493
 
3553
3494
  ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
3554
3495
  }
3555
3496
  }
3556
-
3557
3497
  return content;
3558
3498
  }
3559
-
3560
3499
  function getStylesheetsContent(vm, template) {
3561
3500
  const {
3562
3501
  stylesheets,
3563
3502
  stylesheetToken
3564
3503
  } = template;
3565
3504
  let content = [];
3566
-
3567
3505
  if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
3568
3506
  content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
3569
3507
  }
3570
-
3571
3508
  return content;
3572
- } // It might be worth caching this to avoid doing the lookup repeatedly, but
3509
+ }
3510
+ // It might be worth caching this to avoid doing the lookup repeatedly, but
3573
3511
  // perf testing has not shown it to be a huge improvement yet:
3574
3512
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
3575
-
3576
3513
  function getNearestShadowComponent(vm) {
3577
3514
  let owner = vm;
3578
-
3579
3515
  while (!isNull(owner)) {
3580
- if (owner.renderMode === 1
3581
- /* RenderMode.Shadow */
3582
- ) {
3516
+ if (owner.renderMode === 1 /* RenderMode.Shadow */) {
3583
3517
  return owner;
3584
3518
  }
3585
-
3586
3519
  owner = owner.owner;
3587
3520
  }
3588
-
3589
3521
  return owner;
3590
3522
  }
3591
3523
  /**
@@ -3593,8 +3525,6 @@ function getNearestShadowComponent(vm) {
3593
3525
  * this returns the unique token for that scoped stylesheet. Otherwise
3594
3526
  * it returns null.
3595
3527
  */
3596
-
3597
-
3598
3528
  function getScopeTokenClass(owner) {
3599
3529
  const {
3600
3530
  cmpTemplate,
@@ -3608,7 +3538,6 @@ function getScopeTokenClass(owner) {
3608
3538
  *
3609
3539
  * A host style token is applied to the component if scoped styles are used.
3610
3540
  */
3611
-
3612
3541
  function getStylesheetTokenHost(vnode) {
3613
3542
  const {
3614
3543
  template
@@ -3618,21 +3547,15 @@ function getStylesheetTokenHost(vnode) {
3618
3547
  } = template;
3619
3548
  return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
3620
3549
  }
3621
-
3622
3550
  function getNearestNativeShadowComponent(vm) {
3623
3551
  const owner = getNearestShadowComponent(vm);
3624
-
3625
- if (!isNull(owner) && owner.shadowMode === 1
3626
- /* ShadowMode.Synthetic */
3627
- ) {
3552
+ if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
3628
3553
  // Synthetic-within-native is impossible. So if the nearest shadow component is
3629
3554
  // synthetic, we know we won't find a native component if we go any further.
3630
3555
  return null;
3631
3556
  }
3632
-
3633
3557
  return owner;
3634
3558
  }
3635
-
3636
3559
  function createStylesheet(vm, stylesheets) {
3637
3560
  const {
3638
3561
  renderMode,
@@ -3641,12 +3564,7 @@ function createStylesheet(vm, stylesheets) {
3641
3564
  insertStylesheet
3642
3565
  }
3643
3566
  } = vm;
3644
-
3645
- if (renderMode === 1
3646
- /* RenderMode.Shadow */
3647
- && shadowMode === 1
3648
- /* ShadowMode.Synthetic */
3649
- ) {
3567
+ if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3650
3568
  for (let i = 0; i < stylesheets.length; i++) {
3651
3569
  insertStylesheet(stylesheets[i]);
3652
3570
  }
@@ -3658,15 +3576,13 @@ function createStylesheet(vm, stylesheets) {
3658
3576
  return ArrayMap.call(stylesheets, createInlineStyleVNode);
3659
3577
  } else {
3660
3578
  // native shadow or light DOM, DOM renderer
3661
- const root = getNearestNativeShadowComponent(vm); // null root means a global style
3662
-
3579
+ const root = getNearestNativeShadowComponent(vm);
3580
+ // null root means a global style
3663
3581
  const target = isNull(root) ? undefined : root.shadowRoot;
3664
-
3665
3582
  for (let i = 0; i < stylesheets.length; i++) {
3666
3583
  insertStylesheet(stylesheets[i], target);
3667
3584
  }
3668
3585
  }
3669
-
3670
3586
  return null;
3671
3587
  }
3672
3588
 
@@ -3952,14 +3868,11 @@ function patchChildren(c1, c2, parent, renderer) {
3952
3868
  updateStaticChildren(c1, c2, parent, renderer);
3953
3869
  }
3954
3870
  }
3955
-
3956
3871
  function patch(n1, n2, parent, renderer) {
3957
3872
  var _a, _b;
3958
-
3959
3873
  if (n1 === n2) {
3960
3874
  return;
3961
3875
  }
3962
-
3963
3876
  if (process.env.NODE_ENV !== 'production') {
3964
3877
  if (!isSameVnode(n1, n2)) {
3965
3878
  throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
@@ -3971,103 +3884,63 @@ function patch(n1, n2, parent, renderer) {
3971
3884
  }));
3972
3885
  }
3973
3886
  }
3974
-
3975
3887
  switch (n2.type) {
3976
- case 0
3977
- /* VNodeType.Text */
3978
- :
3888
+ case 0 /* VNodeType.Text */:
3979
3889
  // VText has no special capability, fallback to the owner's renderer
3980
3890
  patchText(n1, n2, renderer);
3981
3891
  break;
3982
-
3983
- case 1
3984
- /* VNodeType.Comment */
3985
- :
3892
+ case 1 /* VNodeType.Comment */:
3986
3893
  // VComment has no special capability, fallback to the owner's renderer
3987
3894
  patchComment(n1, n2, renderer);
3988
3895
  break;
3989
-
3990
- case 4
3991
- /* VNodeType.Static */
3992
- :
3896
+ case 4 /* VNodeType.Static */:
3993
3897
  n2.elm = n1.elm;
3994
3898
  break;
3995
-
3996
- case 5
3997
- /* VNodeType.Fragment */
3998
- :
3899
+ case 5 /* VNodeType.Fragment */:
3999
3900
  patchFragment(n1, n2, parent, renderer);
4000
3901
  break;
4001
-
4002
- case 2
4003
- /* VNodeType.Element */
4004
- :
3902
+ case 2 /* VNodeType.Element */:
4005
3903
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
4006
3904
  break;
4007
-
4008
- case 3
4009
- /* VNodeType.CustomElement */
4010
- :
3905
+ case 3 /* VNodeType.CustomElement */:
4011
3906
  patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
4012
3907
  break;
4013
3908
  }
4014
3909
  }
4015
-
4016
3910
  function mount(node, parent, renderer, anchor) {
4017
3911
  var _a, _b;
4018
-
4019
3912
  switch (node.type) {
4020
- case 0
4021
- /* VNodeType.Text */
4022
- :
3913
+ case 0 /* VNodeType.Text */:
4023
3914
  // VText has no special capability, fallback to the owner's renderer
4024
3915
  mountText(node, parent, anchor, renderer);
4025
3916
  break;
4026
-
4027
- case 1
4028
- /* VNodeType.Comment */
4029
- :
3917
+ case 1 /* VNodeType.Comment */:
4030
3918
  // VComment has no special capability, fallback to the owner's renderer
4031
3919
  mountComment(node, parent, anchor, renderer);
4032
3920
  break;
4033
-
4034
- case 4
4035
- /* VNodeType.Static */
4036
- :
3921
+ case 4 /* VNodeType.Static */:
4037
3922
  // VStatic cannot have a custom renderer associated to them, using owner's renderer
4038
3923
  mountStatic(node, parent, anchor, renderer);
4039
3924
  break;
4040
-
4041
- case 5
4042
- /* VNodeType.Fragment */
4043
- :
3925
+ case 5 /* VNodeType.Fragment */:
4044
3926
  mountFragment(node, parent, anchor, renderer);
4045
3927
  break;
4046
-
4047
- case 2
4048
- /* VNodeType.Element */
4049
- :
3928
+ case 2 /* VNodeType.Element */:
4050
3929
  // If the vnode data has a renderer override use it, else fallback to owner's renderer
4051
3930
  mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
4052
3931
  break;
4053
-
4054
- case 3
4055
- /* VNodeType.CustomElement */
4056
- :
3932
+ case 3 /* VNodeType.CustomElement */:
4057
3933
  // If the vnode data has a renderer override use it, else fallback to owner's renderer
4058
3934
  mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
4059
3935
  break;
4060
3936
  }
4061
3937
  }
4062
-
4063
3938
  function patchText(n1, n2, renderer) {
4064
3939
  n2.elm = n1.elm;
4065
-
4066
3940
  if (n2.text !== n1.text) {
4067
3941
  updateTextContent(n2, renderer);
4068
3942
  }
4069
3943
  }
4070
-
4071
3944
  function mountText(vnode, parent, anchor, renderer) {
4072
3945
  const {
4073
3946
  owner
@@ -4079,16 +3952,14 @@ function mountText(vnode, parent, anchor, renderer) {
4079
3952
  linkNodeToShadow(textNode, owner, renderer);
4080
3953
  insertNode(textNode, parent, anchor, renderer);
4081
3954
  }
4082
-
4083
3955
  function patchComment(n1, n2, renderer) {
4084
- n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3956
+ n2.elm = n1.elm;
3957
+ // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4085
3958
  // it is the case today.
4086
-
4087
3959
  if (n2.text !== n1.text) {
4088
3960
  updateTextContent(n2, renderer);
4089
3961
  }
4090
3962
  }
4091
-
4092
3963
  function mountComment(vnode, parent, anchor, renderer) {
4093
3964
  const {
4094
3965
  owner
@@ -4100,32 +3971,27 @@ function mountComment(vnode, parent, anchor, renderer) {
4100
3971
  linkNodeToShadow(commentNode, owner, renderer);
4101
3972
  insertNode(commentNode, parent, anchor, renderer);
4102
3973
  }
4103
-
4104
3974
  function mountFragment(vnode, parent, anchor, renderer) {
4105
3975
  const {
4106
3976
  children
4107
3977
  } = vnode;
4108
- mountVNodes(children, parent, renderer, anchor); // children of a fragment will always have at least the two delimiters.
4109
-
3978
+ mountVNodes(children, parent, renderer, anchor);
3979
+ // children of a fragment will always have at least the two delimiters.
4110
3980
  vnode.elm = children[children.length - 1].elm;
4111
3981
  }
4112
-
4113
3982
  function patchFragment(n1, n2, parent, renderer) {
4114
3983
  const {
4115
3984
  children,
4116
3985
  stable
4117
3986
  } = n2;
4118
-
4119
3987
  if (stable) {
4120
3988
  updateStaticChildren(n1.children, children, parent, renderer);
4121
3989
  } else {
4122
3990
  updateDynamicChildren(n1.children, children, parent, renderer);
4123
- } // Note: not reusing n1.elm, because during patching, it may be patched with another text node.
4124
-
4125
-
3991
+ }
3992
+ // Note: not reusing n1.elm, because during patching, it may be patched with another text node.
4126
3993
  n2.elm = children[children.length - 1].elm;
4127
3994
  }
4128
-
4129
3995
  function mountElement(vnode, parent, anchor, renderer) {
4130
3996
  const {
4131
3997
  sel,
@@ -4147,13 +4013,11 @@ function mountElement(vnode, parent, anchor, renderer) {
4147
4013
  insertNode(elm, parent, anchor, renderer);
4148
4014
  mountVNodes(vnode.children, elm, renderer, null);
4149
4015
  }
4150
-
4151
4016
  function patchElement(n1, n2, renderer) {
4152
4017
  const elm = n2.elm = n1.elm;
4153
4018
  patchElementPropsAndAttrs$1(n1, n2, renderer);
4154
4019
  patchChildren(n1.children, n2.children, elm, renderer);
4155
4020
  }
4156
-
4157
4021
  function mountStatic(vnode, parent, anchor, renderer) {
4158
4022
  const {
4159
4023
  owner
@@ -4164,26 +4028,19 @@ function mountStatic(vnode, parent, anchor, renderer) {
4164
4028
  } = renderer;
4165
4029
  const elm = vnode.elm = cloneNode(vnode.fragment, true);
4166
4030
  linkNodeToShadow(elm, owner, renderer);
4167
- applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
4168
-
4031
+ applyElementRestrictions(elm, vnode);
4032
+ // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
4169
4033
  const {
4170
4034
  renderMode,
4171
4035
  shadowMode
4172
4036
  } = owner;
4173
-
4174
4037
  if (isSyntheticShadowDefined) {
4175
- if (shadowMode === 1
4176
- /* ShadowMode.Synthetic */
4177
- || renderMode === 0
4178
- /* RenderMode.Light */
4179
- ) {
4038
+ if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
4180
4039
  elm[KEY__SHADOW_STATIC] = true;
4181
4040
  }
4182
4041
  }
4183
-
4184
4042
  insertNode(elm, parent, anchor, renderer);
4185
4043
  }
4186
-
4187
4044
  function mountCustomElement(vnode, parent, anchor, renderer) {
4188
4045
  const {
4189
4046
  sel,
@@ -4198,67 +4055,53 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4198
4055
  * mechanism that only passes that argument if the constructor is known to be
4199
4056
  * an upgradable custom element.
4200
4057
  */
4201
-
4202
4058
  let vm;
4203
-
4204
4059
  const upgradeCallback = elm => {
4205
4060
  // the custom element from the registry is expecting an upgrade callback
4206
4061
  vm = createViewModelHook(elm, vnode, renderer);
4207
4062
  };
4208
-
4209
4063
  const connectedCallback = elm => {
4210
4064
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4211
4065
  connectRootElement(elm);
4212
4066
  }
4213
4067
  };
4214
-
4215
4068
  const disconnectedCallback = elm => {
4216
4069
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4217
4070
  disconnectRootElement(elm);
4218
4071
  }
4219
- }; // Should never get a tag with upper case letter at this point; the compiler
4072
+ };
4073
+ // Should never get a tag with upper case letter at this point; the compiler
4220
4074
  // should produce only tags with lowercase letters. However, the Java
4221
4075
  // compiler may generate tagnames with uppercase letters so - for backwards
4222
4076
  // compatibility, we lower case the tagname here.
4223
-
4224
-
4225
4077
  const normalizedTagname = sel.toLowerCase();
4226
4078
  const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
4227
4079
  vnode.elm = elm;
4228
4080
  vnode.vm = vm;
4229
4081
  linkNodeToShadow(elm, owner, renderer);
4230
4082
  applyStyleScoping(elm, owner, renderer);
4231
-
4232
4083
  if (vm) {
4233
4084
  allocateChildren(vnode, vm);
4234
4085
  }
4235
-
4236
4086
  patchElementPropsAndAttrs$1(null, vnode, renderer);
4237
4087
  insertNode(elm, parent, anchor, renderer);
4238
-
4239
4088
  if (vm) {
4240
4089
  {
4241
4090
  if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4242
4091
  if (process.env.NODE_ENV !== 'production') {
4243
4092
  // With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
4244
4093
  // noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
4245
- assert.isTrue(vm.state === 0
4246
- /* VMState.created */
4247
- , `${vm} cannot be recycled.`);
4094
+ assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
4248
4095
  }
4249
-
4250
4096
  runConnectedCallback(vm);
4251
4097
  }
4252
4098
  }
4253
4099
  }
4254
-
4255
4100
  mountVNodes(vnode.children, elm, renderer, null);
4256
-
4257
4101
  if (vm) {
4258
4102
  appendVM(vm);
4259
4103
  }
4260
4104
  }
4261
-
4262
4105
  function patchCustomElement(n1, n2, parent, renderer) {
4263
4106
  if (n1.ctor !== n2.ctor) {
4264
4107
  // If the constructor, unmount the current component and mount a new one using the new
@@ -4271,17 +4114,14 @@ function patchCustomElement(n1, n2, parent, renderer) {
4271
4114
  const elm = n2.elm = n1.elm;
4272
4115
  const vm = n2.vm = n1.vm;
4273
4116
  patchElementPropsAndAttrs$1(n1, n2, renderer);
4274
-
4275
4117
  if (!isUndefined$1(vm)) {
4276
4118
  // in fallback mode, the allocation will always set children to
4277
4119
  // empty and delegate the real allocation to the slot elements
4278
4120
  allocateChildren(n2, vm);
4279
- } // in fallback mode, the children will be always empty, so, nothing
4121
+ }
4122
+ // in fallback mode, the children will be always empty, so, nothing
4280
4123
  // will happen, but in native, it does allocate the light dom
4281
-
4282
-
4283
4124
  patchChildren(n1.children, n2.children, elm, renderer);
4284
-
4285
4125
  if (!isUndefined$1(vm)) {
4286
4126
  // this will probably update the shadowRoot, but only if the vm is in a dirty state
4287
4127
  // this is important to preserve the top to bottom synchronous rendering phase.
@@ -4289,29 +4129,24 @@ function patchCustomElement(n1, n2, parent, renderer) {
4289
4129
  }
4290
4130
  }
4291
4131
  }
4292
-
4293
4132
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
4294
4133
  for (; start < end; ++start) {
4295
4134
  const vnode = vnodes[start];
4296
-
4297
4135
  if (isVNode(vnode)) {
4298
4136
  mount(vnode, parent, renderer, anchor);
4299
4137
  }
4300
4138
  }
4301
4139
  }
4302
-
4303
4140
  function unmount(vnode, parent, renderer, doRemove = false) {
4304
4141
  const {
4305
4142
  type,
4306
4143
  elm,
4307
4144
  sel
4308
- } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4145
+ } = vnode;
4146
+ // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4309
4147
  // subtree root, is the only element worth unmounting from the subtree.
4310
-
4311
4148
  if (doRemove) {
4312
- if (type === 5
4313
- /* VNodeType.Fragment */
4314
- ) {
4149
+ if (type === 5 /* VNodeType.Fragment */) {
4315
4150
  unmountVNodes(vnode.children, parent, renderer, doRemove);
4316
4151
  } else {
4317
4152
  // The vnode might or might not have a data.renderer associated to it
@@ -4319,51 +4154,39 @@ function unmount(vnode, parent, renderer, doRemove = false) {
4319
4154
  removeNode(elm, parent, renderer);
4320
4155
  }
4321
4156
  }
4322
-
4323
4157
  switch (type) {
4324
- case 2
4325
- /* VNodeType.Element */
4326
- :
4158
+ case 2 /* VNodeType.Element */:
4327
4159
  {
4328
4160
  // Slot content is removed to trigger slotchange event when removing slot.
4329
4161
  // Only required for synthetic shadow.
4330
- const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
4331
- /* ShadowMode.Synthetic */
4332
- ;
4162
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4333
4163
  unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
4334
4164
  break;
4335
4165
  }
4336
-
4337
- case 3
4338
- /* VNodeType.CustomElement */
4339
- :
4166
+ case 3 /* VNodeType.CustomElement */:
4340
4167
  {
4341
4168
  const {
4342
4169
  vm
4343
- } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
4170
+ } = vnode;
4171
+ // No need to unmount the children here, `removeVM` will take care of removing the
4344
4172
  // children.
4345
-
4346
4173
  if (!isUndefined$1(vm)) {
4347
4174
  removeVM(vm);
4348
4175
  }
4349
4176
  }
4350
4177
  }
4351
4178
  }
4352
-
4353
4179
  function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
4354
4180
  for (; start < end; ++start) {
4355
4181
  const ch = vnodes[start];
4356
-
4357
4182
  if (isVNode(ch)) {
4358
4183
  unmount(ch, parent, renderer, doRemove);
4359
4184
  }
4360
4185
  }
4361
4186
  }
4362
-
4363
4187
  function isVNode(vnode) {
4364
4188
  return vnode != null;
4365
4189
  }
4366
-
4367
4190
  function linkNodeToShadow(elm, owner, renderer) {
4368
4191
  const {
4369
4192
  renderRoot,
@@ -4372,19 +4195,14 @@ function linkNodeToShadow(elm, owner, renderer) {
4372
4195
  } = owner;
4373
4196
  const {
4374
4197
  isSyntheticShadowDefined
4375
- } = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
4376
-
4198
+ } = renderer;
4199
+ // TODO [#1164]: this should eventually be done by the polyfill directly
4377
4200
  if (isSyntheticShadowDefined) {
4378
- if (shadowMode === 1
4379
- /* ShadowMode.Synthetic */
4380
- || renderMode === 0
4381
- /* RenderMode.Light */
4382
- ) {
4201
+ if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
4383
4202
  elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
4384
4203
  }
4385
4204
  }
4386
4205
  }
4387
-
4388
4206
  function updateTextContent(vnode, renderer) {
4389
4207
  const {
4390
4208
  elm,
@@ -4393,120 +4211,87 @@ function updateTextContent(vnode, renderer) {
4393
4211
  const {
4394
4212
  setText
4395
4213
  } = renderer;
4396
-
4397
4214
  if (process.env.NODE_ENV !== 'production') {
4398
4215
  unlockDomMutation();
4399
4216
  }
4400
-
4401
4217
  setText(elm, text);
4402
-
4403
4218
  if (process.env.NODE_ENV !== 'production') {
4404
4219
  lockDomMutation();
4405
4220
  }
4406
4221
  }
4407
-
4408
4222
  function insertNode(node, parent, anchor, renderer) {
4409
4223
  if (process.env.NODE_ENV !== 'production') {
4410
4224
  unlockDomMutation();
4411
4225
  }
4412
-
4413
4226
  renderer.insert(node, parent, anchor);
4414
-
4415
4227
  if (process.env.NODE_ENV !== 'production') {
4416
4228
  lockDomMutation();
4417
4229
  }
4418
4230
  }
4419
-
4420
4231
  function removeNode(node, parent, renderer) {
4421
4232
  if (process.env.NODE_ENV !== 'production') {
4422
4233
  unlockDomMutation();
4423
4234
  }
4424
-
4425
4235
  renderer.remove(node, parent);
4426
-
4427
4236
  if (process.env.NODE_ENV !== 'production') {
4428
4237
  lockDomMutation();
4429
4238
  }
4430
4239
  }
4431
-
4432
4240
  function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
4433
4241
  if (isNull(oldVnode)) {
4434
4242
  applyEventListeners(vnode, renderer);
4435
4243
  applyStaticClassAttribute(vnode, renderer);
4436
4244
  applyStaticStyleAttribute(vnode, renderer);
4437
- } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4245
+ }
4246
+ // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4438
4247
  // value is set before type=radio.
4439
-
4440
-
4441
4248
  patchClassAttribute(oldVnode, vnode, renderer);
4442
4249
  patchStyleAttribute(oldVnode, vnode, renderer);
4443
4250
  patchAttributes(oldVnode, vnode, renderer);
4444
4251
  patchProps(oldVnode, vnode, renderer);
4445
4252
  }
4446
-
4447
4253
  function applyStyleScoping(elm, owner, renderer) {
4448
4254
  // Set the class name for `*.scoped.css` style scoping.
4449
4255
  const scopeToken = getScopeTokenClass(owner);
4450
-
4451
4256
  if (!isNull(scopeToken)) {
4452
4257
  const {
4453
4258
  getClassList
4454
- } = renderer; // TODO [#2762]: this dot notation with add is probably problematic
4259
+ } = renderer;
4260
+ // TODO [#2762]: this dot notation with add is probably problematic
4455
4261
  // probably we should have a renderer api for just the add operation
4456
-
4457
4262
  getClassList(elm).add(scopeToken);
4458
- } // Set property element for synthetic shadow DOM style scoping.
4459
-
4460
-
4263
+ }
4264
+ // Set property element for synthetic shadow DOM style scoping.
4461
4265
  const {
4462
4266
  stylesheetToken: syntheticToken
4463
4267
  } = owner.context;
4464
-
4465
- if (owner.shadowMode === 1
4466
- /* ShadowMode.Synthetic */
4467
- && !isUndefined$1(syntheticToken)) {
4268
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
4468
4269
  elm.$shadowToken$ = syntheticToken;
4469
4270
  }
4470
4271
  }
4471
-
4472
4272
  function applyDomManual(elm, vnode) {
4473
4273
  var _a;
4474
-
4475
4274
  const {
4476
4275
  owner,
4477
4276
  data: {
4478
4277
  context
4479
4278
  }
4480
4279
  } = vnode;
4481
-
4482
- if (owner.shadowMode === 1
4483
- /* ShadowMode.Synthetic */
4484
- && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
4485
- /* LwcDomMode.Manual */
4486
- ) {
4280
+ 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 */) {
4487
4281
  elm.$domManual$ = true;
4488
4282
  }
4489
4283
  }
4490
-
4491
4284
  function applyElementRestrictions(elm, vnode) {
4492
4285
  var _a, _b;
4493
-
4494
4286
  if (process.env.NODE_ENV !== 'production') {
4495
- const isPortal = vnode.type === 2
4496
- /* VNodeType.Element */
4497
- && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
4498
- /* LwcDomMode.Manual */
4499
- ;
4500
- const isLight = vnode.owner.renderMode === 0
4501
- /* RenderMode.Light */
4502
- ;
4287
+ 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 */;
4288
+ const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4503
4289
  patchElementWithRestrictions(elm, {
4504
4290
  isPortal,
4505
4291
  isLight
4506
4292
  });
4507
4293
  }
4508
4294
  }
4509
-
4510
4295
  function allocateChildren(vnode, vm) {
4511
4296
  // A component with slots will re-render because:
4512
4297
  // 1- There is a change of the internal state.
@@ -4524,41 +4309,31 @@ function allocateChildren(vnode, vm) {
4524
4309
  renderMode,
4525
4310
  shadowMode
4526
4311
  } = vm;
4527
-
4528
4312
  if (process.env.NODE_ENV !== 'production') {
4529
4313
  // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4530
4314
  // component is a light DOM component. This is mainly to validate light dom parent running
4531
4315
  // in native shadow mode.
4532
- if (renderMode !== 0
4533
- /* RenderMode.Light */
4534
- && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4316
+ if (renderMode !== 0 /* RenderMode.Light */ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4535
4317
  logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4536
4318
  }
4537
4319
  }
4538
-
4539
- if (shadowMode === 1
4540
- /* ShadowMode.Synthetic */
4541
- || renderMode === 0
4542
- /* RenderMode.Light */
4543
- ) {
4320
+ if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
4544
4321
  // slow path
4545
- allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4546
-
4547
- vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4548
-
4322
+ allocateInSlot(vm, children, vnode.owner);
4323
+ // save the allocated children in case this vnode is reused.
4324
+ vnode.aChildren = children;
4325
+ // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4549
4326
  vnode.children = EmptyArray;
4550
4327
  }
4551
4328
  }
4552
-
4553
4329
  function createViewModelHook(elm, vnode, renderer) {
4554
- let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
4330
+ let vm = getAssociatedVMIfPresent(elm);
4331
+ // There is a possibility that a custom element is registered under tagName, in which case, the
4555
4332
  // initialization is already carry on, and there is nothing else to do here since this hook is
4556
4333
  // called right after invoking `document.createElement`.
4557
-
4558
4334
  if (!isUndefined$1(vm)) {
4559
4335
  return vm;
4560
4336
  }
4561
-
4562
4337
  const {
4563
4338
  sel,
4564
4339
  mode,
@@ -4570,48 +4345,37 @@ function createViewModelHook(elm, vnode, renderer) {
4570
4345
  owner,
4571
4346
  tagName: sel
4572
4347
  });
4573
-
4574
4348
  if (process.env.NODE_ENV !== 'production') {
4575
4349
  assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4576
4350
  }
4577
-
4578
4351
  return vm;
4579
4352
  }
4580
4353
  /**
4581
4354
  * Collects all slots into a SlotSet, traversing through VFragment Nodes
4582
4355
  */
4583
-
4584
-
4585
4356
  function collectSlots(vm, children, cmpSlotsMapping) {
4586
4357
  var _a, _b;
4587
-
4588
4358
  for (let i = 0, len = children.length; i < len; i += 1) {
4589
4359
  const vnode = children[i];
4590
-
4591
4360
  if (isNull(vnode)) {
4592
4361
  continue;
4593
- } // Dive further iff the content is wrapped in a VFragment
4594
-
4595
-
4362
+ }
4363
+ // Dive further iff the content is wrapped in a VFragment
4596
4364
  if (isVFragment(vnode)) {
4597
4365
  // Remove the text delimiter nodes to avoid overriding default slot content
4598
4366
  collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
4599
4367
  continue;
4600
4368
  }
4601
-
4602
4369
  let slotName = '';
4603
-
4604
4370
  if (isVBaseElement(vnode)) {
4605
4371
  slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4606
4372
  } else if (isVScopedSlotFragment(vnode)) {
4607
4373
  slotName = vnode.slotName;
4608
4374
  }
4609
-
4610
4375
  const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4611
4376
  ArrayPush$1.call(vnodes, vnode);
4612
4377
  }
4613
4378
  }
4614
-
4615
4379
  function allocateInSlot(vm, children, owner) {
4616
4380
  const {
4617
4381
  cmpSlots: {
@@ -4624,28 +4388,22 @@ function allocateInSlot(vm, children, owner) {
4624
4388
  owner,
4625
4389
  slotAssignments: cmpSlotsMapping
4626
4390
  };
4627
-
4628
4391
  if (isFalse(vm.isDirty)) {
4629
4392
  // We need to determine if the old allocation is really different from the new one
4630
4393
  // and mark the vm as dirty
4631
4394
  const oldKeys = keys(oldSlotsMapping);
4632
-
4633
4395
  if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4634
4396
  markComponentAsDirty(vm);
4635
4397
  return;
4636
4398
  }
4637
-
4638
4399
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4639
4400
  const key = oldKeys[i];
4640
-
4641
4401
  if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4642
4402
  markComponentAsDirty(vm);
4643
4403
  return;
4644
4404
  }
4645
-
4646
4405
  const oldVNodes = oldSlotsMapping[key];
4647
4406
  const vnodes = cmpSlotsMapping[key];
4648
-
4649
4407
  for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4650
4408
  if (oldVNodes[j] !== vnodes[j]) {
4651
4409
  markComponentAsDirty(vm);
@@ -4654,40 +4412,33 @@ function allocateInSlot(vm, children, owner) {
4654
4412
  }
4655
4413
  }
4656
4414
  }
4657
- } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4658
-
4659
-
4660
- const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
4415
+ }
4416
+ // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4417
+ const FromIteration = new WeakMap();
4418
+ // dynamic children means it was generated by an iteration
4661
4419
  // in a template, and will require a more complex diffing algo.
4662
-
4663
4420
  function markAsDynamicChildren(children) {
4664
4421
  FromIteration.set(children, 1);
4665
4422
  }
4666
-
4667
4423
  function hasDynamicChildren(children) {
4668
4424
  return FromIteration.has(children);
4669
4425
  }
4670
-
4671
4426
  function createKeyToOldIdx(children, beginIdx, endIdx) {
4672
- const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
4673
-
4427
+ const map = {};
4428
+ // TODO [#1637]: simplify this by assuming that all vnodes has keys
4674
4429
  for (let j = beginIdx; j <= endIdx; ++j) {
4675
4430
  const ch = children[j];
4676
-
4677
4431
  if (isVNode(ch)) {
4678
4432
  const {
4679
4433
  key
4680
4434
  } = ch;
4681
-
4682
4435
  if (key !== undefined) {
4683
4436
  map[key] = j;
4684
4437
  }
4685
4438
  }
4686
4439
  }
4687
-
4688
4440
  return map;
4689
4441
  }
4690
-
4691
4442
  function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4692
4443
  let oldStartIdx = 0;
4693
4444
  let newStartIdx = 0;
@@ -4703,7 +4454,6 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4703
4454
  let elmToMove;
4704
4455
  let before;
4705
4456
  let clonedOldCh = false;
4706
-
4707
4457
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4708
4458
  if (!isVNode(oldStartVnode)) {
4709
4459
  oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
@@ -4737,54 +4487,46 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4737
4487
  if (oldKeyToIdx === undefined) {
4738
4488
  oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4739
4489
  }
4740
-
4741
4490
  idxInOld = oldKeyToIdx[newStartVnode.key];
4742
-
4743
4491
  if (isUndefined$1(idxInOld)) {
4744
4492
  // New element
4745
4493
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4746
4494
  newStartVnode = newCh[++newStartIdx];
4747
4495
  } else {
4748
4496
  elmToMove = oldCh[idxInOld];
4749
-
4750
4497
  if (isVNode(elmToMove)) {
4751
4498
  if (elmToMove.sel !== newStartVnode.sel) {
4752
4499
  // New element
4753
4500
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4754
4501
  } else {
4755
- patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
4502
+ patch(elmToMove, newStartVnode, parent, renderer);
4503
+ // Delete the old child, but copy the array since it is read-only.
4756
4504
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4757
4505
  // so we only care about the `oldCh` object inside this function.
4758
4506
  // To avoid cloning over and over again, we check `clonedOldCh`
4759
4507
  // and only clone once.
4760
-
4761
4508
  if (!clonedOldCh) {
4762
4509
  clonedOldCh = true;
4763
4510
  oldCh = [...oldCh];
4764
- } // We've already cloned at least once, so it's no longer read-only
4765
-
4766
-
4511
+ }
4512
+ // We've already cloned at least once, so it's no longer read-only
4767
4513
  oldCh[idxInOld] = undefined;
4768
4514
  insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4769
4515
  }
4770
4516
  }
4771
-
4772
4517
  newStartVnode = newCh[++newStartIdx];
4773
4518
  }
4774
4519
  }
4775
4520
  }
4776
-
4777
4521
  if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4778
4522
  if (oldStartIdx > oldEndIdx) {
4779
4523
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4780
4524
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4781
4525
  let i = newEndIdx;
4782
4526
  let n;
4783
-
4784
4527
  do {
4785
4528
  n = newCh[++i];
4786
4529
  } while (!isVNode(n) && i < newChEnd);
4787
-
4788
4530
  before = isVNode(n) ? n.elm : null;
4789
4531
  mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4790
4532
  } else {
@@ -4792,32 +4534,26 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4792
4534
  }
4793
4535
  }
4794
4536
  }
4795
-
4796
4537
  function updateStaticChildren(c1, c2, parent, renderer) {
4797
4538
  const c1Length = c1.length;
4798
4539
  const c2Length = c2.length;
4799
-
4800
4540
  if (c1Length === 0) {
4801
4541
  // the old list is empty, we can directly insert anything new
4802
4542
  mountVNodes(c2, parent, renderer, null);
4803
4543
  return;
4804
4544
  }
4805
-
4806
4545
  if (c2Length === 0) {
4807
4546
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4808
4547
  // this is the case in which the dynamic children of an if-directive should be removed
4809
4548
  unmountVNodes(c1, parent, renderer, true);
4810
4549
  return;
4811
- } // if the old list is not empty, the new list MUST have the same
4550
+ }
4551
+ // if the old list is not empty, the new list MUST have the same
4812
4552
  // amount of nodes, that's why we call this static children
4813
-
4814
-
4815
4553
  let anchor = null;
4816
-
4817
4554
  for (let i = c2Length - 1; i >= 0; i -= 1) {
4818
4555
  const n1 = c1[i];
4819
4556
  const n2 = c2[i];
4820
-
4821
4557
  if (n2 !== n1) {
4822
4558
  if (isVNode(n1)) {
4823
4559
  if (isVNode(n2)) {
@@ -5807,42 +5543,30 @@ function invokeServiceHook(vm, cbs) {
5807
5543
  */
5808
5544
  let idx = 0;
5809
5545
  /** The internal slot used to associate different objects the engine manipulates with the VM */
5810
-
5811
5546
  const ViewModelReflection = new WeakMap();
5812
-
5813
5547
  function callHook(cmp, fn, args = []) {
5814
5548
  return fn.apply(cmp, args);
5815
5549
  }
5816
-
5817
5550
  function setHook(cmp, prop, newValue) {
5818
5551
  cmp[prop] = newValue;
5819
5552
  }
5820
-
5821
5553
  function getHook(cmp, prop) {
5822
5554
  return cmp[prop];
5823
5555
  }
5824
-
5825
5556
  function rerenderVM(vm) {
5826
5557
  rehydrate(vm);
5827
5558
  }
5828
5559
  function connectRootElement(elm) {
5829
5560
  const vm = getAssociatedVM(elm);
5830
- logGlobalOperationStart(7
5831
- /* OperationId.GlobalHydrate */
5832
- , vm); // Usually means moving the element from one place to another, which is observable via
5561
+ logGlobalOperationStart(7 /* OperationId.GlobalHydrate */, vm);
5562
+ // Usually means moving the element from one place to another, which is observable via
5833
5563
  // life-cycle hooks.
5834
-
5835
- if (vm.state === 1
5836
- /* VMState.connected */
5837
- ) {
5564
+ if (vm.state === 1 /* VMState.connected */) {
5838
5565
  disconnectRootElement(elm);
5839
5566
  }
5840
-
5841
5567
  runConnectedCallback(vm);
5842
5568
  rehydrate(vm);
5843
- logGlobalOperationEnd(7
5844
- /* OperationId.GlobalHydrate */
5845
- , vm);
5569
+ logGlobalOperationEnd(7 /* OperationId.GlobalHydrate */, vm);
5846
5570
  }
5847
5571
  function disconnectRootElement(elm) {
5848
5572
  const vm = getAssociatedVM(elm);
@@ -5850,65 +5574,48 @@ function disconnectRootElement(elm) {
5850
5574
  }
5851
5575
  function appendVM(vm) {
5852
5576
  rehydrate(vm);
5853
- } // just in case the component comes back, with this we guarantee re-rendering it
5577
+ }
5578
+ // just in case the component comes back, with this we guarantee re-rendering it
5854
5579
  // while preventing any attempt to rehydration until after reinsertion.
5855
-
5856
5580
  function resetComponentStateWhenRemoved(vm) {
5857
5581
  const {
5858
5582
  state
5859
5583
  } = vm;
5860
-
5861
- if (state !== 2
5862
- /* VMState.disconnected */
5863
- ) {
5584
+ if (state !== 2 /* VMState.disconnected */) {
5864
5585
  const {
5865
5586
  oar,
5866
5587
  tro
5867
- } = vm; // Making sure that any observing record will not trigger the rehydrated on this vm
5868
-
5869
- tro.reset(); // Making sure that any observing accessor record will not trigger the setter to be reinvoked
5870
-
5588
+ } = vm;
5589
+ // Making sure that any observing record will not trigger the rehydrated on this vm
5590
+ tro.reset();
5591
+ // Making sure that any observing accessor record will not trigger the setter to be reinvoked
5871
5592
  for (const key in oar) {
5872
5593
  oar[key].reset();
5873
5594
  }
5874
-
5875
- runDisconnectedCallback(vm); // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
5876
-
5595
+ runDisconnectedCallback(vm);
5596
+ // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
5877
5597
  runChildNodesDisconnectedCallback(vm);
5878
5598
  runLightChildNodesDisconnectedCallback(vm);
5879
5599
  }
5880
-
5881
5600
  if (process.env.NODE_ENV !== 'production') {
5882
5601
  removeActiveVM(vm);
5883
5602
  }
5884
- } // this method is triggered by the diffing algo only when a vnode from the
5603
+ }
5604
+ // this method is triggered by the diffing algo only when a vnode from the
5885
5605
  // old vnode.children is removed from the DOM.
5886
-
5887
-
5888
5606
  function removeVM(vm) {
5889
5607
  if (process.env.NODE_ENV !== 'production') {
5890
- assert.isTrue(vm.state === 1
5891
- /* VMState.connected */
5892
- || vm.state === 2
5893
- /* VMState.disconnected */
5894
- , `${vm} must have been connected.`);
5608
+ assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
5895
5609
  }
5896
-
5897
5610
  resetComponentStateWhenRemoved(vm);
5898
5611
  }
5899
-
5900
5612
  function getNearestShadowAncestor(vm) {
5901
5613
  let ancestor = vm.owner;
5902
-
5903
- while (!isNull(ancestor) && ancestor.renderMode === 0
5904
- /* RenderMode.Light */
5905
- ) {
5614
+ while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
5906
5615
  ancestor = ancestor.owner;
5907
5616
  }
5908
-
5909
5617
  return ancestor;
5910
5618
  }
5911
-
5912
5619
  function createVM(elm, ctor, renderer, options) {
5913
5620
  const {
5914
5621
  mode,
@@ -5921,9 +5628,7 @@ function createVM(elm, ctor, renderer, options) {
5921
5628
  elm,
5922
5629
  def,
5923
5630
  idx: idx++,
5924
- state: 0
5925
- /* VMState.created */
5926
- ,
5631
+ state: 0 /* VMState.created */,
5927
5632
  isScheduled: false,
5928
5633
  isDirty: true,
5929
5634
  tagName,
@@ -5965,31 +5670,27 @@ function createVM(elm, ctor, renderer, options) {
5965
5670
  getHook,
5966
5671
  renderer
5967
5672
  };
5673
+ if (process.env.NODE_ENV !== 'production') {
5674
+ vm.debugInfo = create(null);
5675
+ }
5968
5676
  vm.shadowMode = computeShadowMode(vm, renderer);
5969
5677
  vm.tro = getTemplateReactiveObserver(vm);
5970
-
5971
5678
  if (process.env.NODE_ENV !== 'production') {
5972
5679
  vm.toString = () => {
5973
5680
  return `[object:vm ${def.name} (${vm.idx})]`;
5974
5681
  };
5975
-
5976
5682
  if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5977
- vm.shadowMode = 0
5978
- /* ShadowMode.Native */
5979
- ;
5683
+ vm.shadowMode = 0 /* ShadowMode.Native */;
5980
5684
  }
5981
- } // Create component instance associated to the vm and the element.
5982
-
5983
-
5984
- invokeComponentConstructor(vm, def.ctor); // Initializing the wire decorator per instance only when really needed
5985
-
5685
+ }
5686
+ // Create component instance associated to the vm and the element.
5687
+ invokeComponentConstructor(vm, def.ctor);
5688
+ // Initializing the wire decorator per instance only when really needed
5986
5689
  if (hasWireAdapters(vm)) {
5987
5690
  installWireAdapters(vm);
5988
5691
  }
5989
-
5990
5692
  return vm;
5991
5693
  }
5992
-
5993
5694
  function computeShadowMode(vm, renderer) {
5994
5695
  const {
5995
5696
  def
@@ -5999,136 +5700,98 @@ function computeShadowMode(vm, renderer) {
5999
5700
  isNativeShadowDefined
6000
5701
  } = renderer;
6001
5702
  let shadowMode;
6002
-
6003
5703
  if (isSyntheticShadowDefined) {
6004
- if (def.renderMode === 0
6005
- /* RenderMode.Light */
6006
- ) {
5704
+ if (def.renderMode === 0 /* RenderMode.Light */) {
6007
5705
  // ShadowMode.Native implies "not synthetic shadow" which is consistent with how
6008
5706
  // everything defaults to native when the synthetic shadow polyfill is unavailable.
6009
- shadowMode = 0
6010
- /* ShadowMode.Native */
6011
- ;
5707
+ shadowMode = 0 /* ShadowMode.Native */;
6012
5708
  } else if (isNativeShadowDefined) {
6013
5709
  // Not combined with above condition because @lwc/features only supports identifiers in
6014
5710
  // the if-condition.
6015
5711
  if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
6016
- if (def.shadowSupportMode === "any"
6017
- /* ShadowSupportMode.Any */
6018
- ) {
6019
- shadowMode = 0
6020
- /* ShadowMode.Native */
6021
- ;
5712
+ if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
5713
+ shadowMode = 0 /* ShadowMode.Native */;
6022
5714
  } else {
6023
5715
  const shadowAncestor = getNearestShadowAncestor(vm);
6024
-
6025
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
6026
- /* ShadowMode.Native */
6027
- ) {
5716
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
6028
5717
  // Transitive support for native Shadow DOM. A component in native mode
6029
5718
  // transitively opts all of its descendants into native.
6030
- shadowMode = 0
6031
- /* ShadowMode.Native */
6032
- ;
5719
+ shadowMode = 0 /* ShadowMode.Native */;
6033
5720
  } else {
6034
5721
  // Synthetic if neither this component nor any of its ancestors are configured
6035
5722
  // to be native.
6036
- shadowMode = 1
6037
- /* ShadowMode.Synthetic */
6038
- ;
5723
+ shadowMode = 1 /* ShadowMode.Synthetic */;
6039
5724
  }
6040
5725
  }
6041
5726
  } else {
6042
- shadowMode = 1
6043
- /* ShadowMode.Synthetic */
6044
- ;
5727
+ shadowMode = 1 /* ShadowMode.Synthetic */;
6045
5728
  }
6046
5729
  } else {
6047
5730
  // Synthetic if there is no native Shadow DOM support.
6048
- shadowMode = 1
6049
- /* ShadowMode.Synthetic */
6050
- ;
5731
+ shadowMode = 1 /* ShadowMode.Synthetic */;
6051
5732
  }
6052
5733
  } else {
6053
5734
  // Native if the synthetic shadow polyfill is unavailable.
6054
- shadowMode = 0
6055
- /* ShadowMode.Native */
6056
- ;
5735
+ shadowMode = 0 /* ShadowMode.Native */;
6057
5736
  }
6058
5737
 
6059
5738
  return shadowMode;
6060
5739
  }
6061
-
6062
5740
  function assertIsVM(obj) {
6063
5741
  if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
6064
5742
  throw new TypeError(`${obj} is not a VM.`);
6065
5743
  }
6066
5744
  }
6067
-
6068
5745
  function associateVM(obj, vm) {
6069
5746
  ViewModelReflection.set(obj, vm);
6070
5747
  }
6071
5748
  function getAssociatedVM(obj) {
6072
5749
  const vm = ViewModelReflection.get(obj);
6073
-
6074
5750
  if (process.env.NODE_ENV !== 'production') {
6075
5751
  assertIsVM(vm);
6076
5752
  }
6077
-
6078
5753
  return vm;
6079
5754
  }
6080
5755
  function getAssociatedVMIfPresent(obj) {
6081
5756
  const maybeVm = ViewModelReflection.get(obj);
6082
-
6083
5757
  if (process.env.NODE_ENV !== 'production') {
6084
5758
  if (!isUndefined$1(maybeVm)) {
6085
5759
  assertIsVM(maybeVm);
6086
5760
  }
6087
5761
  }
6088
-
6089
5762
  return maybeVm;
6090
5763
  }
6091
-
6092
5764
  function rehydrate(vm) {
6093
5765
  if (isTrue(vm.isDirty)) {
6094
5766
  const children = renderComponent(vm);
6095
5767
  patchShadowRoot(vm, children);
6096
5768
  }
6097
5769
  }
6098
-
6099
5770
  function patchShadowRoot(vm, newCh) {
6100
5771
  const {
6101
5772
  renderRoot,
6102
5773
  children: oldCh,
6103
5774
  renderer
6104
- } = vm; // caching the new children collection
6105
-
5775
+ } = vm;
5776
+ // caching the new children collection
6106
5777
  vm.children = newCh;
6107
-
6108
5778
  if (newCh.length > 0 || oldCh.length > 0) {
6109
5779
  // patch function mutates vnodes by adding the element reference,
6110
5780
  // however, if patching fails it contains partial changes.
6111
5781
  if (oldCh !== newCh) {
6112
5782
  runWithBoundaryProtection(vm, vm, () => {
6113
5783
  // pre
6114
- logOperationStart(2
6115
- /* OperationId.Patch */
6116
- , vm);
5784
+ logOperationStart(2 /* OperationId.Patch */, vm);
6117
5785
  }, () => {
6118
5786
  // job
6119
5787
  patchChildren(oldCh, newCh, renderRoot, renderer);
6120
5788
  }, () => {
6121
5789
  // post
6122
- logOperationEnd(2
6123
- /* OperationId.Patch */
6124
- , vm);
5790
+ logOperationEnd(2 /* OperationId.Patch */, vm);
6125
5791
  });
6126
5792
  }
6127
5793
  }
6128
-
6129
- if (vm.state === 1
6130
- /* VMState.connected */
6131
- ) {
5794
+ if (vm.state === 1 /* VMState.connected */) {
6132
5795
  // If the element is connected, that means connectedCallback was already issued, and
6133
5796
  // any successive rendering should finish with the call to renderedCallback, otherwise
6134
5797
  // the connectedCallback will take care of calling it in the right order at the end of
@@ -6136,49 +5799,34 @@ function patchShadowRoot(vm, newCh) {
6136
5799
  runRenderedCallback(vm);
6137
5800
  }
6138
5801
  }
6139
-
6140
5802
  function runRenderedCallback(vm) {
6141
5803
  const {
6142
5804
  def: {
6143
5805
  renderedCallback
6144
5806
  }
6145
5807
  } = vm;
6146
-
6147
5808
  const {
6148
5809
  rendered
6149
5810
  } = Services;
6150
-
6151
5811
  if (rendered) {
6152
5812
  invokeServiceHook(vm, rendered);
6153
5813
  }
6154
-
6155
5814
  if (!isUndefined$1(renderedCallback)) {
6156
- logOperationStart(4
6157
- /* OperationId.RenderedCallback */
6158
- , vm);
5815
+ logOperationStart(4 /* OperationId.RenderedCallback */, vm);
6159
5816
  invokeComponentCallback(vm, renderedCallback);
6160
- logOperationEnd(4
6161
- /* OperationId.RenderedCallback */
6162
- , vm);
5817
+ logOperationEnd(4 /* OperationId.RenderedCallback */, vm);
6163
5818
  }
6164
5819
  }
6165
5820
  let rehydrateQueue = [];
6166
-
6167
5821
  function flushRehydrationQueue() {
6168
- logGlobalOperationStart(8
6169
- /* OperationId.GlobalRehydrate */
6170
- );
6171
-
5822
+ logGlobalOperationStart(8 /* OperationId.GlobalRehydrate */);
6172
5823
  if (process.env.NODE_ENV !== 'production') {
6173
5824
  assert.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
6174
5825
  }
6175
-
6176
5826
  const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
6177
5827
  rehydrateQueue = []; // reset to a new queue
6178
-
6179
5828
  for (let i = 0, len = vms.length; i < len; i += 1) {
6180
5829
  const vm = vms[i];
6181
-
6182
5830
  try {
6183
5831
  rehydrate(vm);
6184
5832
  } catch (error) {
@@ -6187,78 +5835,54 @@ function flushRehydrationQueue() {
6187
5835
  if (rehydrateQueue.length === 0) {
6188
5836
  addCallbackToNextTick(flushRehydrationQueue);
6189
5837
  }
6190
-
6191
5838
  ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
6192
- } // we need to end the measure before throwing.
6193
-
6194
-
6195
- logGlobalOperationEnd(8
6196
- /* OperationId.GlobalRehydrate */
6197
- ); // re-throwing the original error will break the current tick, but since the next tick is
5839
+ }
5840
+ // we need to end the measure before throwing.
5841
+ logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
5842
+ // re-throwing the original error will break the current tick, but since the next tick is
6198
5843
  // already scheduled, it should continue patching the rest.
6199
-
6200
5844
  throw error; // eslint-disable-line no-unsafe-finally
6201
5845
  }
6202
5846
  }
6203
5847
 
6204
- logGlobalOperationEnd(8
6205
- /* OperationId.GlobalRehydrate */
6206
- );
5848
+ logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
6207
5849
  }
6208
5850
 
6209
5851
  function runConnectedCallback(vm) {
6210
5852
  const {
6211
5853
  state
6212
5854
  } = vm;
6213
-
6214
- if (state === 1
6215
- /* VMState.connected */
6216
- ) {
5855
+ if (state === 1 /* VMState.connected */) {
6217
5856
  return; // nothing to do since it was already connected
6218
5857
  }
6219
5858
 
6220
- vm.state = 1
6221
- /* VMState.connected */
6222
- ; // reporting connection
6223
-
5859
+ vm.state = 1 /* VMState.connected */;
5860
+ // reporting connection
6224
5861
  const {
6225
5862
  connected
6226
5863
  } = Services;
6227
-
6228
5864
  if (connected) {
6229
5865
  invokeServiceHook(vm, connected);
6230
5866
  }
6231
-
6232
5867
  if (hasWireAdapters(vm)) {
6233
5868
  connectWireAdapters(vm);
6234
5869
  }
6235
-
6236
5870
  const {
6237
5871
  connectedCallback
6238
5872
  } = vm.def;
6239
-
6240
5873
  if (!isUndefined$1(connectedCallback)) {
6241
- logOperationStart(3
6242
- /* OperationId.ConnectedCallback */
6243
- , vm);
5874
+ logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
6244
5875
  invokeComponentCallback(vm, connectedCallback);
6245
- logOperationEnd(3
6246
- /* OperationId.ConnectedCallback */
6247
- , vm);
5876
+ logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
6248
5877
  }
6249
5878
  }
6250
-
6251
5879
  function hasWireAdapters(vm) {
6252
5880
  return getOwnPropertyNames$1(vm.def.wire).length > 0;
6253
5881
  }
6254
-
6255
5882
  function runDisconnectedCallback(vm) {
6256
5883
  if (process.env.NODE_ENV !== 'production') {
6257
- assert.isTrue(vm.state !== 2
6258
- /* VMState.disconnected */
6259
- , `${vm} must be inserted.`);
5884
+ assert.isTrue(vm.state !== 2 /* VMState.disconnected */, `${vm} must be inserted.`);
6260
5885
  }
6261
-
6262
5886
  if (isFalse(vm.isDirty)) {
6263
5887
  // this guarantees that if the component is reused/reinserted,
6264
5888
  // it will be re-rendered because we are disconnecting the reactivity
@@ -6266,67 +5890,54 @@ function runDisconnectedCallback(vm) {
6266
5890
  // of disconnected components.
6267
5891
  vm.isDirty = true;
6268
5892
  }
6269
-
6270
- vm.state = 2
6271
- /* VMState.disconnected */
6272
- ; // reporting disconnection
6273
-
5893
+ vm.state = 2 /* VMState.disconnected */;
5894
+ // reporting disconnection
6274
5895
  const {
6275
5896
  disconnected
6276
5897
  } = Services;
6277
-
6278
5898
  if (disconnected) {
6279
5899
  invokeServiceHook(vm, disconnected);
6280
5900
  }
6281
-
6282
5901
  if (hasWireAdapters(vm)) {
6283
5902
  disconnectWireAdapters(vm);
6284
5903
  }
6285
-
6286
5904
  const {
6287
5905
  disconnectedCallback
6288
5906
  } = vm.def;
6289
-
6290
5907
  if (!isUndefined$1(disconnectedCallback)) {
6291
- logOperationStart(5
6292
- /* OperationId.DisconnectedCallback */
6293
- , vm);
5908
+ logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
6294
5909
  invokeComponentCallback(vm, disconnectedCallback);
6295
- logOperationEnd(5
6296
- /* OperationId.DisconnectedCallback */
6297
- , vm);
5910
+ logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
6298
5911
  }
6299
5912
  }
6300
-
6301
5913
  function runChildNodesDisconnectedCallback(vm) {
6302
5914
  const {
6303
5915
  velements: vCustomElementCollection
6304
- } = vm; // Reporting disconnection for every child in inverse order since they are
5916
+ } = vm;
5917
+ // Reporting disconnection for every child in inverse order since they are
6305
5918
  // inserted in reserved order.
6306
-
6307
5919
  for (let i = vCustomElementCollection.length - 1; i >= 0; i -= 1) {
6308
5920
  const {
6309
5921
  elm
6310
- } = vCustomElementCollection[i]; // There are two cases where the element could be undefined:
5922
+ } = vCustomElementCollection[i];
5923
+ // There are two cases where the element could be undefined:
6311
5924
  // * when there is an error during the construction phase, and an error
6312
5925
  // boundary picks it, there is a possibility that the VCustomElement
6313
5926
  // is not properly initialized, and therefore is should be ignored.
6314
5927
  // * when slotted custom element is not used by the element where it is
6315
5928
  // slotted into it, as a result, the custom element was never
6316
5929
  // initialized.
6317
-
6318
5930
  if (!isUndefined$1(elm)) {
6319
- const childVM = getAssociatedVMIfPresent(elm); // The VM associated with the element might be associated undefined
5931
+ const childVM = getAssociatedVMIfPresent(elm);
5932
+ // The VM associated with the element might be associated undefined
6320
5933
  // in the case where the VM failed in the middle of its creation,
6321
5934
  // eg: constructor throwing before invoking super().
6322
-
6323
5935
  if (!isUndefined$1(childVM)) {
6324
5936
  resetComponentStateWhenRemoved(childVM);
6325
5937
  }
6326
5938
  }
6327
5939
  }
6328
5940
  }
6329
-
6330
5941
  function runLightChildNodesDisconnectedCallback(vm) {
6331
5942
  const {
6332
5943
  aChildren: adoptedChildren
@@ -6340,23 +5951,15 @@ function runLightChildNodesDisconnectedCallback(vm) {
6340
5951
  * custom element itself will trigger the removal of anything slotted or anything
6341
5952
  * defined on its shadow.
6342
5953
  */
6343
-
6344
-
6345
5954
  function recursivelyDisconnectChildren(vnodes) {
6346
5955
  for (let i = 0, len = vnodes.length; i < len; i += 1) {
6347
5956
  const vnode = vnodes[i];
6348
-
6349
5957
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
6350
5958
  switch (vnode.type) {
6351
- case 2
6352
- /* VNodeType.Element */
6353
- :
5959
+ case 2 /* VNodeType.Element */:
6354
5960
  recursivelyDisconnectChildren(vnode.children);
6355
5961
  break;
6356
-
6357
- case 3
6358
- /* VNodeType.CustomElement */
6359
- :
5962
+ case 3 /* VNodeType.CustomElement */:
6360
5963
  {
6361
5964
  const vm = getAssociatedVM(vnode.elm);
6362
5965
  resetComponentStateWhenRemoved(vm);
@@ -6365,12 +5968,11 @@ function recursivelyDisconnectChildren(vnodes) {
6365
5968
  }
6366
5969
  }
6367
5970
  }
6368
- } // This is a super optimized mechanism to remove the content of the root node (shadow root
5971
+ }
5972
+ // This is a super optimized mechanism to remove the content of the root node (shadow root
6369
5973
  // for shadow DOM components and the root element itself for light DOM) without having to go
6370
5974
  // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
6371
5975
  // children VNodes might not be representing the current state of the DOM.
6372
-
6373
-
6374
5976
  function resetComponentRoot(vm) {
6375
5977
  const {
6376
5978
  children,
@@ -6379,15 +5981,12 @@ function resetComponentRoot(vm) {
6379
5981
  remove
6380
5982
  }
6381
5983
  } = vm;
6382
-
6383
5984
  for (let i = 0, len = children.length; i < len; i++) {
6384
5985
  const child = children[i];
6385
-
6386
5986
  if (!isNull(child) && !isUndefined$1(child.elm)) {
6387
5987
  remove(child.elm, renderRoot);
6388
5988
  }
6389
5989
  }
6390
-
6391
5990
  vm.children = EmptyArray;
6392
5991
  runChildNodesDisconnectedCallback(vm);
6393
5992
  vm.velements = EmptyArray;
@@ -6396,58 +5995,43 @@ function scheduleRehydration(vm) {
6396
5995
  if (isTrue(vm.isScheduled)) {
6397
5996
  return;
6398
5997
  }
6399
-
6400
5998
  vm.isScheduled = true;
6401
-
6402
5999
  if (rehydrateQueue.length === 0) {
6403
6000
  addCallbackToNextTick(flushRehydrationQueue);
6404
6001
  }
6405
-
6406
6002
  ArrayPush$1.call(rehydrateQueue, vm);
6407
6003
  }
6408
-
6409
6004
  function getErrorBoundaryVM(vm) {
6410
6005
  let currentVm = vm;
6411
-
6412
6006
  while (!isNull(currentVm)) {
6413
6007
  if (!isUndefined$1(currentVm.def.errorCallback)) {
6414
6008
  return currentVm;
6415
6009
  }
6416
-
6417
6010
  currentVm = currentVm.owner;
6418
6011
  }
6419
6012
  }
6420
-
6421
6013
  function runWithBoundaryProtection(vm, owner, pre, job, post) {
6422
6014
  let error;
6423
6015
  pre();
6424
-
6425
6016
  try {
6426
6017
  job();
6427
6018
  } catch (e) {
6428
6019
  error = Object(e);
6429
6020
  } finally {
6430
6021
  post();
6431
-
6432
6022
  if (!isUndefined$1(error)) {
6433
6023
  addErrorComponentStack(vm, error);
6434
6024
  const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
6435
-
6436
6025
  if (isUndefined$1(errorBoundaryVm)) {
6437
6026
  throw error; // eslint-disable-line no-unsafe-finally
6438
6027
  }
6439
6028
 
6440
6029
  resetComponentRoot(vm); // remove offenders
6441
-
6442
- logOperationStart(6
6443
- /* OperationId.ErrorCallback */
6444
- , vm); // error boundaries must have an ErrorCallback
6445
-
6030
+ logOperationStart(6 /* OperationId.ErrorCallback */, vm);
6031
+ // error boundaries must have an ErrorCallback
6446
6032
  const errorCallback = errorBoundaryVm.def.errorCallback;
6447
6033
  invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
6448
- logOperationEnd(6
6449
- /* OperationId.ErrorCallback */
6450
- , vm);
6034
+ logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
6451
6035
  }
6452
6036
  }
6453
6037
  }
@@ -6461,7 +6045,6 @@ function forceRehydration(vm) {
6461
6045
  // content of the shadowRoot, this way we can guarantee that all children
6462
6046
  // elements will be throw away, and new instances will be created.
6463
6047
  vm.cmpTemplate = () => [];
6464
-
6465
6048
  if (isFalse(vm.isDirty)) {
6466
6049
  // forcing the vm to rehydrate in the next tick
6467
6050
  markComponentAsDirty(vm);
@@ -6477,6 +6060,7 @@ function forceRehydration(vm) {
6477
6060
  */
6478
6061
  const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
6479
6062
  const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
6063
+ const WIRE_DEBUG_ENTRY = '@wire';
6480
6064
  const WireMetaMap = new Map();
6481
6065
  class WireContextRegistrationEvent extends CustomEvent {
6482
6066
  constructor(adapterToken, {
@@ -6496,15 +6080,12 @@ class WireContextRegistrationEvent extends CustomEvent {
6496
6080
  }
6497
6081
  });
6498
6082
  }
6499
-
6500
6083
  }
6501
-
6502
6084
  function createFieldDataCallback(vm, name) {
6503
6085
  return value => {
6504
6086
  updateComponentValue(vm, name, value);
6505
6087
  };
6506
6088
  }
6507
-
6508
6089
  function createMethodDataCallback(vm, method) {
6509
6090
  return value => {
6510
6091
  // dispatching new value into the wired method
@@ -6514,45 +6095,40 @@ function createMethodDataCallback(vm, method) {
6514
6095
  }, noop);
6515
6096
  };
6516
6097
  }
6517
-
6518
6098
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6519
- let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
6520
-
6099
+ let hasPendingConfig = false;
6100
+ // creating the reactive observer for reactive params when needed
6521
6101
  const ro = createReactiveObserver(() => {
6522
6102
  if (hasPendingConfig === false) {
6523
- hasPendingConfig = true; // collect new config in the micro-task
6524
-
6103
+ hasPendingConfig = true;
6104
+ // collect new config in the micro-task
6525
6105
  Promise.resolve().then(() => {
6526
- hasPendingConfig = false; // resetting current reactive params
6527
-
6528
- ro.reset(); // dispatching a new config due to a change in the configuration
6529
-
6106
+ hasPendingConfig = false;
6107
+ // resetting current reactive params
6108
+ ro.reset();
6109
+ // dispatching a new config due to a change in the configuration
6530
6110
  computeConfigAndUpdate();
6531
6111
  });
6532
6112
  }
6533
6113
  });
6534
-
6535
6114
  const computeConfigAndUpdate = () => {
6536
6115
  let config;
6537
- ro.observe(() => config = configCallback(component)); // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
6116
+ ro.observe(() => config = configCallback(component));
6117
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
6538
6118
  // TODO: dev-mode validation of config based on the adapter.configSchema
6539
6119
  // @ts-ignore it is assigned in the observe() callback
6540
-
6541
6120
  callbackWhenConfigIsReady(config);
6542
6121
  };
6543
-
6544
6122
  return {
6545
6123
  computeConfigAndUpdate,
6546
6124
  ro
6547
6125
  };
6548
6126
  }
6549
-
6550
6127
  function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6551
6128
  const {
6552
6129
  adapter
6553
6130
  } = wireDef;
6554
6131
  const adapterContextToken = getAdapterToken(adapter);
6555
-
6556
6132
  if (isUndefined$1(adapterContextToken)) {
6557
6133
  return; // no provider found, nothing to be done
6558
6134
  }
@@ -6566,8 +6142,8 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6566
6142
  renderer: {
6567
6143
  dispatchEvent
6568
6144
  }
6569
- } = vm; // waiting for the component to be connected to formally request the context via the token
6570
-
6145
+ } = vm;
6146
+ // waiting for the component to be connected to formally request the context via the token
6571
6147
  ArrayPush$1.call(wiredConnecting, () => {
6572
6148
  // This event is responsible for connecting the host element with another
6573
6149
  // element in the composed path that is providing contextual data. The provider
@@ -6580,18 +6156,15 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6580
6156
  // TODO: dev-mode validation of config based on the adapter.contextSchema
6581
6157
  callbackWhenContextIsReady(newContext);
6582
6158
  },
6583
-
6584
6159
  setDisconnectedCallback(disconnectCallback) {
6585
6160
  // adds this callback into the disconnect bucket so it gets disconnected from parent
6586
6161
  // the the element hosting the wire is disconnected
6587
6162
  ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
6588
6163
  }
6589
-
6590
6164
  });
6591
6165
  dispatchEvent(elm, contextRegistrationEvent);
6592
6166
  });
6593
6167
  }
6594
-
6595
6168
  function createConnector(vm, name, wireDef) {
6596
6169
  const {
6597
6170
  method,
@@ -6599,10 +6172,27 @@ function createConnector(vm, name, wireDef) {
6599
6172
  configCallback,
6600
6173
  dynamic
6601
6174
  } = wireDef;
6602
- const dataCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
6175
+ let debugInfo;
6176
+ if (process.env.NODE_ENV !== 'production') {
6177
+ const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
6178
+ debugInfo = create(null);
6179
+ debugInfo.wasDataProvisionedForConfig = false;
6180
+ vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
6181
+ }
6182
+ const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
6183
+ const dataCallback = value => {
6184
+ if (process.env.NODE_ENV !== 'production') {
6185
+ debugInfo.data = value;
6186
+ // Note: most of the time, the data provided is for the current config, but there may be
6187
+ // some conditions in which it does not, ex:
6188
+ // race conditions in a poor network while the adapter does not cancel a previous request.
6189
+ debugInfo.wasDataProvisionedForConfig = true;
6190
+ }
6191
+ fieldOrMethodCallback(value);
6192
+ };
6603
6193
  let context;
6604
- let connector; // Workaround to pass the component element associated to this wire adapter instance.
6605
-
6194
+ let connector;
6195
+ // Workaround to pass the component element associated to this wire adapter instance.
6606
6196
  defineProperty(dataCallback, DeprecatedWiredElementHost, {
6607
6197
  value: vm.elm
6608
6198
  });
@@ -6613,41 +6203,41 @@ function createConnector(vm, name, wireDef) {
6613
6203
  // job
6614
6204
  connector = new adapter(dataCallback);
6615
6205
  }, noop);
6616
-
6617
6206
  const updateConnectorConfig = config => {
6618
6207
  // every time the config is recomputed due to tracking,
6619
6208
  // this callback will be invoked with the new computed config
6620
6209
  runWithBoundaryProtection(vm, vm, noop, () => {
6621
6210
  // job
6211
+ if (process.env.NODE_ENV !== 'production') {
6212
+ debugInfo.config = config;
6213
+ debugInfo.context = context;
6214
+ debugInfo.wasDataProvisionedForConfig = false;
6215
+ }
6622
6216
  connector.update(config, context);
6623
6217
  }, noop);
6624
- }; // Computes the current wire config and calls the update method on the wire adapter.
6218
+ };
6219
+ // Computes the current wire config and calls the update method on the wire adapter.
6625
6220
  // If it has params, we will need to observe changes in the next tick.
6626
-
6627
-
6628
6221
  const {
6629
6222
  computeConfigAndUpdate,
6630
6223
  ro
6631
- } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig); // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
6632
-
6224
+ } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
6225
+ // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
6633
6226
  if (!isUndefined$1(adapter.contextSchema)) {
6634
6227
  createContextWatcher(vm, wireDef, newContext => {
6635
6228
  // every time the context is pushed into this component,
6636
6229
  // this callback will be invoked with the new computed context
6637
6230
  if (context !== newContext) {
6638
- context = newContext; // Note: when new context arrives, the config will be recomputed and pushed along side the new
6231
+ context = newContext;
6232
+ // Note: when new context arrives, the config will be recomputed and pushed along side the new
6639
6233
  // context, this is to preserve the identity characteristics, config should not have identity
6640
6234
  // (ever), while context can have identity
6641
-
6642
- if (vm.state === 1
6643
- /* VMState.connected */
6644
- ) {
6235
+ if (vm.state === 1 /* VMState.connected */) {
6645
6236
  computeConfigAndUpdate();
6646
6237
  }
6647
6238
  }
6648
6239
  });
6649
6240
  }
6650
-
6651
6241
  return {
6652
6242
  // @ts-ignore the boundary protection executes sync, connector is always defined
6653
6243
  connector,
@@ -6655,7 +6245,6 @@ function createConnector(vm, name, wireDef) {
6655
6245
  resetConfigWatcher: () => ro.reset()
6656
6246
  };
6657
6247
  }
6658
-
6659
6248
  const AdapterToTokenMap = new Map();
6660
6249
  function getAdapterToken(adapter) {
6661
6250
  return AdapterToTokenMap.get(adapter);
@@ -6668,7 +6257,6 @@ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
6668
6257
  if (adapter.adapter) {
6669
6258
  adapter = adapter.adapter;
6670
6259
  }
6671
-
6672
6260
  const method = descriptor.value;
6673
6261
  const def = {
6674
6262
  adapter,
@@ -6683,7 +6271,6 @@ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
6683
6271
  if (adapter.adapter) {
6684
6272
  adapter = adapter.adapter;
6685
6273
  }
6686
-
6687
6274
  const def = {
6688
6275
  adapter,
6689
6276
  configCallback,
@@ -6698,17 +6285,15 @@ function installWireAdapters(vm) {
6698
6285
  wire
6699
6286
  }
6700
6287
  } = vm;
6288
+ vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
6701
6289
  const wiredConnecting = context.wiredConnecting = [];
6702
6290
  const wiredDisconnecting = context.wiredDisconnecting = [];
6703
-
6704
6291
  for (const fieldNameOrMethod in wire) {
6705
6292
  const descriptor = wire[fieldNameOrMethod];
6706
6293
  const wireDef = WireMetaMap.get(descriptor);
6707
-
6708
6294
  if (process.env.NODE_ENV !== 'production') {
6709
6295
  assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
6710
6296
  }
6711
-
6712
6297
  if (!isUndefined$1(wireDef)) {
6713
6298
  const {
6714
6299
  connector,
@@ -6718,14 +6303,12 @@ function installWireAdapters(vm) {
6718
6303
  const hasDynamicParams = wireDef.dynamic.length > 0;
6719
6304
  ArrayPush$1.call(wiredConnecting, () => {
6720
6305
  connector.connect();
6721
-
6722
6306
  if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6723
6307
  if (hasDynamicParams) {
6724
6308
  Promise.resolve().then(computeConfigAndUpdate);
6725
6309
  return;
6726
6310
  }
6727
6311
  }
6728
-
6729
6312
  computeConfigAndUpdate();
6730
6313
  });
6731
6314
  ArrayPush$1.call(wiredDisconnecting, () => {
@@ -6739,7 +6322,6 @@ function connectWireAdapters(vm) {
6739
6322
  const {
6740
6323
  wiredConnecting
6741
6324
  } = vm.context;
6742
-
6743
6325
  for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
6744
6326
  wiredConnecting[i]();
6745
6327
  }
@@ -7353,7 +6935,87 @@ function getComponentConstructor(elm) {
7353
6935
  }
7354
6936
  return ctor;
7355
6937
  }
7356
- /* version: 2.28.1 */
6938
+ /* version: 2.30.0 */
6939
+
6940
+ /*
6941
+ * Copyright (c) 2018, salesforce.com, inc.
6942
+ * All rights reserved.
6943
+ * SPDX-License-Identifier: MIT
6944
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6945
+ */
6946
+ /**
6947
+ * Displays the header for a custom element.
6948
+ *
6949
+ * @param ce the custom element
6950
+ * @param componentInstance component instance associated with the custom element.
6951
+ */
6952
+ function getHeaderForCustomElement(ce, componentInstance) {
6953
+ // [element]
6954
+ // LWC component instance: [vm.component]
6955
+ return [
6956
+ 'div',
6957
+ {},
6958
+ ['object', { object: ce, config: { skip: true } }],
6959
+ [
6960
+ 'div',
6961
+ {},
6962
+ ['span', { style: 'margin: 0 5px; color: red' }, 'LWC:'],
6963
+ ['object', { object: componentInstance }],
6964
+ ],
6965
+ ];
6966
+ }
6967
+ function getHeaderForComponentInstance(componentInstance, debugInfo) {
6968
+ if (keys(debugInfo).length === 0) {
6969
+ // there is no debug information, no need to customize this component instance
6970
+ return null;
6971
+ }
6972
+ // [component]
6973
+ // Debug information: [vm.debugInfo]
6974
+ return [
6975
+ 'div',
6976
+ {},
6977
+ ['object', { object: componentInstance, config: { skip: true } }],
6978
+ [
6979
+ 'div',
6980
+ {},
6981
+ ['span', { style: 'margin: 0 5px; color: red' }, 'Debug:'],
6982
+ ['object', { object: debugInfo }],
6983
+ ],
6984
+ ];
6985
+ }
6986
+ const LightningElementFormatter = {
6987
+ name: 'LightningElementFormatter',
6988
+ header(obj, config) {
6989
+ const vm = getAssociatedVMIfPresent(obj);
6990
+ if (!isUndefined$1(vm) && (isUndefined$1(config) || !config.skip)) {
6991
+ if (obj instanceof HTMLElement) {
6992
+ return getHeaderForCustomElement(obj, vm.component);
6993
+ }
6994
+ else {
6995
+ return getHeaderForComponentInstance(obj, vm.debugInfo);
6996
+ }
6997
+ }
6998
+ return null;
6999
+ },
7000
+ hasBody() {
7001
+ return false;
7002
+ },
7003
+ };
7004
+
7005
+ /*
7006
+ * Copyright (c) 2018, salesforce.com, inc.
7007
+ * All rights reserved.
7008
+ * SPDX-License-Identifier: MIT
7009
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7010
+ */
7011
+ function init() {
7012
+ const devtoolsFormatters = _globalThis.devtoolsFormatters || [];
7013
+ ArrayPush$1.call(devtoolsFormatters, LightningElementFormatter);
7014
+ _globalThis.devtoolsFormatters = devtoolsFormatters;
7015
+ }
7016
+ if (process.env.NODE_ENV !== 'production') {
7017
+ init();
7018
+ }
7357
7019
 
7358
7020
  /*
7359
7021
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8052,10 +7714,10 @@ function createScopedRegistry() {
8052
7714
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8053
7715
  */
8054
7716
  let createScopedConstructor;
8055
- let CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
7717
+ let CachedHTMLElement;
7718
+ // We only call `createScopedRegistry()` if the browser supports custom elements and
8056
7719
  // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
8057
7720
  // or we're in a legacy browser.
8058
-
8059
7721
  if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
8060
7722
  if (hasCustomElements) {
8061
7723
  // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
@@ -8069,7 +7731,8 @@ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
8069
7731
  // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
8070
7732
  //
8071
7733
  // To reduce the risk of this, it's safer to patch the registry eagerly.
8072
- createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
7734
+ createScopedConstructor = createScopedRegistry();
7735
+ // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
8073
7736
  // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
8074
7737
  // because the HTMLElement prototypes are mixed up.
8075
7738
  //
@@ -8077,14 +7740,12 @@ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
8077
7740
  // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
8078
7741
  // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
8079
7742
  // Caching avoids this problem.
8080
-
8081
7743
  CachedHTMLElement = window.HTMLElement;
8082
7744
  }
8083
- } // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
7745
+ }
7746
+ // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
8084
7747
  // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
8085
7748
  // multiple times per tag name.
8086
-
8087
-
8088
7749
  const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
8089
7750
  // TODO [#2972]: this class should expose observedAttributes as necessary
8090
7751
  return class UserConstructor extends HTMLElementToExtend {
@@ -8092,24 +7753,19 @@ const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedC
8092
7753
  super();
8093
7754
  upgradeCallback(this);
8094
7755
  }
8095
-
8096
7756
  connectedCallback() {
8097
7757
  connectedCallback(this);
8098
7758
  }
8099
-
8100
7759
  disconnectedCallback() {
8101
7760
  disconnectedCallback(this);
8102
7761
  }
8103
-
8104
7762
  };
8105
7763
  };
8106
-
8107
7764
  function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
8108
7765
  if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
8109
7766
  // This error should be impossible to hit
8110
7767
  throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
8111
7768
  }
8112
-
8113
7769
  const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
8114
7770
  const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
8115
7771
  return new ScopedConstructor(UserConstructor);
@@ -8134,9 +7790,7 @@ function createCustomElementScoped(tagName, upgradeCallback, connectedCallback,
8134
7790
  * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
8135
7791
  * because it must patch the global `customElements` and `HTMLElement` objects.
8136
7792
  */
8137
-
8138
7793
  let createCustomElement;
8139
-
8140
7794
  if (hasCustomElements) {
8141
7795
  if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
8142
7796
  createCustomElement = createCustomElementScoped;
@@ -8209,7 +7863,7 @@ function rendererFactory(baseRenderer) {
8209
7863
  function isNull(obj) {
8210
7864
  return obj === null;
8211
7865
  }
8212
- /** version: 2.28.1 */
7866
+ /** version: 2.30.0 */
8213
7867
 
8214
7868
  /*
8215
7869
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8598,23 +8252,19 @@ function buildCustomElementConstructor(Ctor) {
8598
8252
  * SPDX-License-Identifier: MIT
8599
8253
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8600
8254
  */
8255
+ // TODO [#2472]: Remove this workaround when appropriate.
8601
8256
  // eslint-disable-next-line @lwc/lwc-internal/no-global-node
8602
-
8603
8257
  const _Node$1 = Node;
8604
8258
  const ConnectingSlot = new WeakMap();
8605
8259
  const DisconnectingSlot = new WeakMap();
8606
-
8607
8260
  function callNodeSlot(node, slot) {
8608
8261
  if (process.env.NODE_ENV !== 'production') {
8609
8262
  assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
8610
8263
  }
8611
-
8612
8264
  const fn = slot.get(node);
8613
-
8614
8265
  if (!isUndefined$1(fn)) {
8615
8266
  fn(node);
8616
8267
  }
8617
-
8618
8268
  return node; // for convenience
8619
8269
  }
8620
8270
 
@@ -8632,24 +8282,20 @@ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8632
8282
  const appendedNode = appendChild.call(this, newChild);
8633
8283
  return callNodeSlot(appendedNode, ConnectingSlot);
8634
8284
  },
8635
-
8636
8285
  insertBefore(newChild, referenceNode) {
8637
8286
  const insertedNode = insertBefore.call(this, newChild, referenceNode);
8638
8287
  return callNodeSlot(insertedNode, ConnectingSlot);
8639
8288
  },
8640
-
8641
8289
  removeChild(oldChild) {
8642
8290
  const removedNode = removeChild.call(this, oldChild);
8643
8291
  return callNodeSlot(removedNode, DisconnectingSlot);
8644
8292
  },
8645
-
8646
8293
  replaceChild(newChild, oldChild) {
8647
8294
  const replacedNode = replaceChild.call(this, newChild, oldChild);
8648
8295
  callNodeSlot(replacedNode, DisconnectingSlot);
8649
8296
  callNodeSlot(newChild, ConnectingSlot);
8650
8297
  return replacedNode;
8651
8298
  }
8652
-
8653
8299
  });
8654
8300
  }
8655
8301
  /**
@@ -8663,59 +8309,49 @@ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8663
8309
  * const el = createElement('x-foo', { is: FooCtor });
8664
8310
  * ```
8665
8311
  */
8666
-
8667
-
8668
8312
  function createElement(sel, options) {
8669
8313
  if (!isObject(options) || isNull(options)) {
8670
8314
  throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
8671
8315
  }
8672
-
8673
8316
  const Ctor = options.is;
8674
-
8675
8317
  if (!isFunction$1(Ctor)) {
8676
8318
  throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
8677
8319
  }
8678
-
8679
8320
  const {
8680
8321
  createCustomElement
8681
- } = renderer; // tagName must be all lowercase, unfortunately, we have legacy code that is
8322
+ } = renderer;
8323
+ // tagName must be all lowercase, unfortunately, we have legacy code that is
8682
8324
  // passing `sel` as a camel-case, which makes them invalid custom elements name
8683
8325
  // the following line guarantees that this does not leaks beyond this point.
8684
-
8685
- const tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
8686
-
8326
+ const tagName = StringToLowerCase.call(sel);
8327
+ // the custom element from the registry is expecting an upgrade callback
8687
8328
  /**
8688
8329
  * Note: if the upgradable constructor does not expect, or throw when we new it
8689
8330
  * with a callback as the first argument, we could implement a more advanced
8690
8331
  * mechanism that only passes that argument if the constructor is known to be
8691
8332
  * an upgradable custom element.
8692
8333
  */
8693
-
8694
8334
  const upgradeCallback = elm => {
8695
8335
  createVM(elm, Ctor, renderer, {
8696
8336
  tagName,
8697
8337
  mode: options.mode !== 'closed' ? 'open' : 'closed',
8698
8338
  owner: null
8699
8339
  });
8700
-
8701
8340
  if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8702
8341
  ConnectingSlot.set(elm, connectRootElement);
8703
8342
  DisconnectingSlot.set(elm, disconnectRootElement);
8704
8343
  }
8705
8344
  };
8706
-
8707
8345
  const connectedCallback = elm => {
8708
8346
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8709
8347
  connectRootElement(elm);
8710
8348
  }
8711
8349
  };
8712
-
8713
8350
  const disconnectedCallback = elm => {
8714
8351
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8715
8352
  disconnectRootElement(elm);
8716
8353
  }
8717
8354
  };
8718
-
8719
8355
  const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
8720
8356
  return element;
8721
8357
  }
@@ -8788,6 +8424,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
8788
8424
  });
8789
8425
  freeze(LightningElement);
8790
8426
  seal(LightningElement.prototype);
8791
- /* version: 2.28.1 */
8427
+ /* version: 2.30.0 */
8792
8428
 
8793
8429
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };