@lwrjs/everywhere 0.13.0-alpha.1 → 0.13.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/86e5b35c91b01b4b7df42aded40a3e5d/config.js +12 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_13_0-alpha_2/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +14 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{6_5_2/s/b04b0848c889e153c4119373afa73a21 → 6_6_1/s/eeee3bb1f188f86a6a28e9d5c983706c}/lwc.js +698 -558
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js +3 -3
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/s/f30361ad8ff7af505bf4d465c8499181/lwr_init.js +21 -21
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_13_0-alpha_1/s/db873ff051952f601e5b94afcd12a640 → 0_13_0-alpha_2/s/e307ee0231427b79178dc8789d2591fc}/lwr_loader.js +4 -4
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/s/274c8343f810353bbad085a79709395f/lwr_metrics.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/s/ec0fad0e38a96bb0b88c9f4553460347/lwr_preInit.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/lwr-error-shim.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_13_0-alpha_1 → 0_13_0-alpha_2}/lwr-loader-shim.bundle.js +7 -7
- package/build/assets/amd/lwr-everywhere-debug.js +9 -9
- package/build/assets/amd/lwr-everywhere-min.js +2 -2
- package/build/assets/amd/lwr-everywhere.js +9 -9
- package/build/assets/core/lwr-everywhere-debug.js +5 -5
- package/build/assets/core/lwr-everywhere-min.js +1 -1
- package/build/assets/core/lwr-everywhere.js +5 -5
- package/build/assets/esm/lwr-everywhere-debug.js +1 -1
- package/build/assets/esm/lwr-everywhere-min.js +1 -1
- package/build/assets/esm/lwr-everywhere.js +1 -1
- package/package.json +9 -9
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/06bb09054e5c6120da9cf13b2ec7653a/config.js +0 -12
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_13_0-alpha_1/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
LWR.define('lwc/v/
|
1
|
+
LWR.define('lwc/v/6_6_1', ['exports'], (function (exports) { 'use strict';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -442,9 +442,9 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
442
442
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
443
443
|
*/
|
444
444
|
// Increment whenever the LWC template compiler changes
|
445
|
-
const LWC_VERSION = "6.
|
445
|
+
const LWC_VERSION = "6.6.1";
|
446
446
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
447
|
-
/** version: 6.
|
447
|
+
/** version: 6.6.1 */
|
448
448
|
|
449
449
|
/**
|
450
450
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -530,7 +530,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
530
530
|
setFeatureFlag(name, value);
|
531
531
|
}
|
532
532
|
}
|
533
|
-
/** version: 6.
|
533
|
+
/** version: 6.6.1 */
|
534
534
|
|
535
535
|
/**
|
536
536
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -1722,7 +1722,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
1722
1722
|
valueMutated(originalTarget, key);
|
1723
1723
|
return true;
|
1724
1724
|
}
|
1725
|
-
/*LWC compiler v6.
|
1725
|
+
/*LWC compiler v6.6.1*/
|
1726
1726
|
}
|
1727
1727
|
const getterMap = new WeakMap();
|
1728
1728
|
const setterMap = new WeakMap();
|
@@ -1815,7 +1815,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
1815
1815
|
/* istanbul ignore next */
|
1816
1816
|
return false;
|
1817
1817
|
}
|
1818
|
-
/*LWC compiler v6.
|
1818
|
+
/*LWC compiler v6.6.1*/
|
1819
1819
|
}
|
1820
1820
|
function extract(objectOrArray) {
|
1821
1821
|
if (isArray(objectOrArray)) {
|
@@ -3522,7 +3522,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3522
3522
|
}
|
3523
3523
|
function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
|
3524
3524
|
const HTMLBridgeElement = class extends SuperClass {
|
3525
|
-
/*LWC compiler v6.
|
3525
|
+
/*LWC compiler v6.6.1*/
|
3526
3526
|
};
|
3527
3527
|
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
3528
3528
|
// and false positives in case of inheritance.
|
@@ -3634,130 +3634,453 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3634
3634
|
seal(BaseBridgeElement.prototype);
|
3635
3635
|
|
3636
3636
|
/*
|
3637
|
-
* Copyright (c)
|
3637
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
3638
3638
|
* All rights reserved.
|
3639
3639
|
* SPDX-License-Identifier: MIT
|
3640
3640
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3641
3641
|
*/
|
3642
|
-
|
3643
|
-
//
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3642
|
+
// These are only used for HMR in dev mode
|
3643
|
+
// The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
|
3644
|
+
let stylesheetsToCssContent = /*@__PURE__@*/new WeakMap();
|
3645
|
+
let cssContentToAbortControllers = /*@__PURE__@*/new Map();
|
3646
|
+
// Only used in LWC's Karma tests
|
3647
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
3648
|
+
// Used to reset the global state between test runs
|
3649
|
+
window.__lwcResetStylesheetCache = () => {
|
3650
|
+
stylesheetsToCssContent = new WeakMap();
|
3651
|
+
cssContentToAbortControllers = new Map();
|
3652
|
+
};
|
3653
|
+
}
|
3654
|
+
function linkStylesheetToCssContentInDevMode(stylesheet, cssContent) {
|
3655
|
+
// Should never leak to prod; only used for HMR
|
3656
|
+
assertNotProd();
|
3657
|
+
let cssContents = stylesheetsToCssContent.get(stylesheet);
|
3658
|
+
if (isUndefined$1(cssContents)) {
|
3659
|
+
cssContents = new Set();
|
3660
|
+
stylesheetsToCssContent.set(stylesheet, cssContents);
|
3647
3661
|
}
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3662
|
+
cssContents.add(cssContent);
|
3663
|
+
}
|
3664
|
+
function getOrCreateAbortControllerInDevMode(cssContent) {
|
3665
|
+
// Should never leak to prod; only used for HMR
|
3666
|
+
assertNotProd();
|
3667
|
+
let abortController = cssContentToAbortControllers.get(cssContent);
|
3668
|
+
if (isUndefined$1(abortController)) {
|
3669
|
+
abortController = new AbortController();
|
3670
|
+
cssContentToAbortControllers.set(cssContent, abortController);
|
3671
|
+
}
|
3672
|
+
return abortController;
|
3673
|
+
}
|
3674
|
+
function getOrCreateAbortSignal(cssContent) {
|
3675
|
+
// abort controller/signal is only used for HMR in development
|
3676
|
+
if (process.env.NODE_ENV !== 'production') {
|
3677
|
+
return getOrCreateAbortControllerInDevMode(cssContent).signal;
|
3678
|
+
}
|
3679
|
+
return undefined;
|
3680
|
+
}
|
3681
|
+
function makeHostToken(token) {
|
3682
|
+
// Note: if this ever changes, update the `cssScopeTokens` returned by `@lwc/compiler`
|
3683
|
+
return `${token}-host`;
|
3684
|
+
}
|
3685
|
+
function createInlineStyleVNode(content) {
|
3686
|
+
return api.h('style', {
|
3687
|
+
key: 'style',
|
3688
|
+
// special key
|
3689
|
+
attrs: {
|
3690
|
+
type: 'text/css'
|
3653
3691
|
}
|
3654
|
-
|
3692
|
+
}, [api.t(content)]);
|
3693
|
+
}
|
3694
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
3695
|
+
function updateStylesheetToken(vm, template, legacy) {
|
3696
|
+
const {
|
3697
|
+
elm,
|
3698
|
+
context,
|
3699
|
+
renderMode,
|
3700
|
+
shadowMode,
|
3701
|
+
renderer: {
|
3702
|
+
getClassList,
|
3703
|
+
removeAttribute,
|
3704
|
+
setAttribute
|
3705
|
+
}
|
3706
|
+
} = vm;
|
3707
|
+
const {
|
3708
|
+
stylesheets: newStylesheets
|
3709
|
+
} = template;
|
3710
|
+
const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
|
3711
|
+
const {
|
3712
|
+
stylesheets: newVmStylesheets
|
3713
|
+
} = vm;
|
3714
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
3715
|
+
const {
|
3716
|
+
hasScopedStyles
|
3717
|
+
} = context;
|
3718
|
+
let newToken;
|
3719
|
+
let newHasTokenInClass;
|
3720
|
+
let newHasTokenInAttribute;
|
3721
|
+
// Reset the styling token applied to the host element.
|
3722
|
+
let oldToken;
|
3723
|
+
let oldHasTokenInClass;
|
3724
|
+
let oldHasTokenInAttribute;
|
3725
|
+
if (legacy) {
|
3726
|
+
oldToken = context.legacyStylesheetToken;
|
3727
|
+
oldHasTokenInClass = context.hasLegacyTokenInClass;
|
3728
|
+
oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
|
3729
|
+
} else {
|
3730
|
+
oldToken = context.stylesheetToken;
|
3731
|
+
oldHasTokenInClass = context.hasTokenInClass;
|
3732
|
+
oldHasTokenInAttribute = context.hasTokenInAttribute;
|
3655
3733
|
}
|
3656
|
-
|
3657
|
-
|
3734
|
+
if (!isUndefined$1(oldToken)) {
|
3735
|
+
if (oldHasTokenInClass) {
|
3736
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
3737
|
+
}
|
3738
|
+
if (oldHasTokenInAttribute) {
|
3739
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
3740
|
+
}
|
3658
3741
|
}
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3742
|
+
// Apply the new template styling token to the host element, if the new template has any
|
3743
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
3744
|
+
const hasNewStylesheets = hasStyles(newStylesheets);
|
3745
|
+
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
3746
|
+
if (hasNewStylesheets || hasNewVmStylesheets) {
|
3747
|
+
newToken = newStylesheetToken;
|
3662
3748
|
}
|
3663
|
-
|
3664
|
-
|
3749
|
+
// Set the new styling token on the host element
|
3750
|
+
if (!isUndefined$1(newToken)) {
|
3751
|
+
if (hasScopedStyles) {
|
3752
|
+
getClassList(elm).add(makeHostToken(newToken));
|
3753
|
+
newHasTokenInClass = true;
|
3754
|
+
}
|
3755
|
+
if (isSyntheticShadow) {
|
3756
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
3757
|
+
newHasTokenInAttribute = true;
|
3758
|
+
}
|
3759
|
+
}
|
3760
|
+
// Update the styling tokens present on the context object.
|
3761
|
+
if (legacy) {
|
3762
|
+
context.legacyStylesheetToken = newToken;
|
3763
|
+
context.hasLegacyTokenInClass = newHasTokenInClass;
|
3764
|
+
context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
|
3765
|
+
} else {
|
3766
|
+
context.stylesheetToken = newToken;
|
3767
|
+
context.hasTokenInClass = newHasTokenInClass;
|
3768
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
3665
3769
|
}
|
3666
3770
|
}
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3771
|
+
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
3772
|
+
const content = [];
|
3773
|
+
let root;
|
3774
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
3775
|
+
let stylesheet = stylesheets[i];
|
3776
|
+
if (isArray$1(stylesheet)) {
|
3777
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
3778
|
+
} else {
|
3779
|
+
if (process.env.NODE_ENV !== 'production') {
|
3780
|
+
// Check for compiler version mismatch in dev mode only
|
3781
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
3782
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
3783
|
+
// the component instance might be attempting to use an old version of
|
3784
|
+
// the stylesheet, while internally, we have a replacement for it.
|
3785
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
3786
|
+
}
|
3787
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
3788
|
+
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS && !isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
3789
|
+
logError('Unscoped CSS is not supported in Light DOM in this environment. Please use scoped CSS ' + '(*.scoped.css) instead of unscoped CSS (*.css). See also: https://sfdc.co/scoped-styles-light-dom');
|
3790
|
+
continue;
|
3791
|
+
}
|
3792
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
3793
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
3794
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
3795
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
3796
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
3797
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
3798
|
+
// we use an attribute selector on the host to simulate :dir().
|
3799
|
+
let useNativeDirPseudoclass;
|
3800
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
3801
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
3802
|
+
} else {
|
3803
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
3804
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
3805
|
+
if (isUndefined$1(root)) {
|
3806
|
+
// Only calculate the root once as necessary
|
3807
|
+
root = getNearestShadowComponent(vm);
|
3680
3808
|
}
|
3809
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
3681
3810
|
}
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3685
|
-
let weakRefs = this._map.get(key);
|
3686
|
-
if (isUndefined$1(weakRefs)) {
|
3687
|
-
weakRefs = [];
|
3688
|
-
this._map.set(key, weakRefs);
|
3689
|
-
}
|
3690
|
-
return weakRefs;
|
3691
|
-
}
|
3692
|
-
get(key) {
|
3693
|
-
const weakRefs = this._getWeakRefs(key);
|
3694
|
-
const result = new Set();
|
3695
|
-
for (const weakRef of weakRefs) {
|
3696
|
-
const vm = weakRef.deref();
|
3697
|
-
if (!isUndefined$1(vm)) {
|
3698
|
-
result.add(vm);
|
3811
|
+
const cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
|
3812
|
+
if (process.env.NODE_ENV !== 'production') {
|
3813
|
+
linkStylesheetToCssContentInDevMode(stylesheet, cssContent);
|
3699
3814
|
}
|
3815
|
+
ArrayPush$1.call(content, cssContent);
|
3700
3816
|
}
|
3701
|
-
return result;
|
3702
3817
|
}
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3818
|
+
return content;
|
3819
|
+
}
|
3820
|
+
function getStylesheetsContent(vm, template) {
|
3821
|
+
const {
|
3822
|
+
stylesheets,
|
3823
|
+
stylesheetToken
|
3824
|
+
} = template;
|
3825
|
+
const {
|
3826
|
+
stylesheets: vmStylesheets
|
3827
|
+
} = vm;
|
3828
|
+
let content = [];
|
3829
|
+
if (hasStyles(stylesheets)) {
|
3830
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
3716
3831
|
}
|
3717
|
-
|
3718
|
-
|
3832
|
+
// VM (component) stylesheets apply after template stylesheets
|
3833
|
+
if (hasStyles(vmStylesheets)) {
|
3834
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
3719
3835
|
}
|
3836
|
+
return content;
|
3720
3837
|
}
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
3726
|
-
|
3727
|
-
|
3728
|
-
|
3729
|
-
const swappedTemplateMap = new WeakMap();
|
3730
|
-
const swappedComponentMap = new WeakMap();
|
3731
|
-
const swappedStyleMap = new WeakMap();
|
3732
|
-
// The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
|
3733
|
-
// so we don't want to create strong references to them.
|
3734
|
-
// The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
|
3735
|
-
// never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
|
3736
|
-
const activeTemplates = new WeakMultiMap();
|
3737
|
-
const activeComponents = new WeakMultiMap();
|
3738
|
-
const activeStyles = new WeakMultiMap();
|
3739
|
-
function rehydrateHotTemplate(tpl) {
|
3740
|
-
const list = activeTemplates.get(tpl);
|
3741
|
-
for (const vm of list) {
|
3742
|
-
if (isFalse(vm.isDirty)) {
|
3743
|
-
// forcing the vm to rehydrate in the micro-task:
|
3744
|
-
markComponentAsDirty(vm);
|
3745
|
-
scheduleRehydration(vm);
|
3838
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
3839
|
+
// perf testing has not shown it to be a huge improvement yet:
|
3840
|
+
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
3841
|
+
function getNearestShadowComponent(vm) {
|
3842
|
+
let owner = vm;
|
3843
|
+
while (!isNull(owner)) {
|
3844
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
3845
|
+
return owner;
|
3746
3846
|
}
|
3847
|
+
owner = owner.owner;
|
3747
3848
|
}
|
3748
|
-
|
3749
|
-
// they will get re-associated once these instances are rehydrated.
|
3750
|
-
activeTemplates.delete(tpl);
|
3751
|
-
return true;
|
3849
|
+
return owner;
|
3752
3850
|
}
|
3753
|
-
|
3754
|
-
|
3755
|
-
|
3756
|
-
|
3757
|
-
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3851
|
+
/**
|
3852
|
+
* If the component that is currently being rendered uses scoped styles,
|
3853
|
+
* this returns the unique token for that scoped stylesheet. Otherwise
|
3854
|
+
* it returns null.
|
3855
|
+
* @param owner
|
3856
|
+
* @param legacy
|
3857
|
+
*/
|
3858
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
3859
|
+
function getScopeTokenClass(owner, legacy) {
|
3860
|
+
const {
|
3861
|
+
cmpTemplate,
|
3862
|
+
context
|
3863
|
+
} = owner;
|
3864
|
+
return context.hasScopedStyles && (legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken) || null;
|
3865
|
+
}
|
3866
|
+
/**
|
3867
|
+
* This function returns the host style token for a custom element if it
|
3868
|
+
* exists. Otherwise it returns null.
|
3869
|
+
*
|
3870
|
+
* A host style token is applied to the component if scoped styles are used.
|
3871
|
+
* @param vnode
|
3872
|
+
*/
|
3873
|
+
function getStylesheetTokenHost(vnode) {
|
3874
|
+
const {
|
3875
|
+
template
|
3876
|
+
} = getComponentInternalDef(vnode.ctor);
|
3877
|
+
const {
|
3878
|
+
vm
|
3879
|
+
} = vnode;
|
3880
|
+
const {
|
3881
|
+
stylesheetToken
|
3882
|
+
} = template;
|
3883
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
3884
|
+
}
|
3885
|
+
function getNearestNativeShadowComponent(vm) {
|
3886
|
+
const owner = getNearestShadowComponent(vm);
|
3887
|
+
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
3888
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
3889
|
+
// synthetic, we know we won't find a native component if we go any further.
|
3890
|
+
return null;
|
3891
|
+
}
|
3892
|
+
return owner;
|
3893
|
+
}
|
3894
|
+
function createStylesheet(vm, stylesheets) {
|
3895
|
+
const {
|
3896
|
+
renderMode,
|
3897
|
+
shadowMode,
|
3898
|
+
renderer: {
|
3899
|
+
insertStylesheet
|
3900
|
+
}
|
3901
|
+
} = vm;
|
3902
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
3903
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
3904
|
+
const stylesheet = stylesheets[i];
|
3905
|
+
insertStylesheet(stylesheet, undefined, getOrCreateAbortSignal(stylesheet));
|
3906
|
+
}
|
3907
|
+
} else if (vm.hydrated) {
|
3908
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
3909
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
3910
|
+
// the first time the VM renders.
|
3911
|
+
// native shadow or light DOM, SSR
|
3912
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
3913
|
+
} else {
|
3914
|
+
// native shadow or light DOM, DOM renderer
|
3915
|
+
const root = getNearestNativeShadowComponent(vm);
|
3916
|
+
// null root means a global style
|
3917
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
3918
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
3919
|
+
const stylesheet = stylesheets[i];
|
3920
|
+
insertStylesheet(stylesheet, target, getOrCreateAbortSignal(stylesheet));
|
3921
|
+
}
|
3922
|
+
}
|
3923
|
+
return null;
|
3924
|
+
}
|
3925
|
+
function unrenderStylesheet(stylesheet) {
|
3926
|
+
// should never leak to prod; only used for HMR
|
3927
|
+
assertNotProd();
|
3928
|
+
const cssContents = stylesheetsToCssContent.get(stylesheet);
|
3929
|
+
/* istanbul ignore if */
|
3930
|
+
if (isUndefined$1(cssContents)) {
|
3931
|
+
throw new Error('Cannot unrender stylesheet which was never rendered');
|
3932
|
+
}
|
3933
|
+
for (const cssContent of cssContents) {
|
3934
|
+
const abortController = cssContentToAbortControllers.get(cssContent);
|
3935
|
+
/* istanbul ignore if */
|
3936
|
+
if (isUndefined$1(abortController)) {
|
3937
|
+
throw new Error('Cannot find AbortController for CSS content');
|
3938
|
+
}
|
3939
|
+
abortController.abort();
|
3940
|
+
// remove association with AbortController in case stylesheet is rendered again
|
3941
|
+
cssContentToAbortControllers.delete(cssContent);
|
3942
|
+
}
|
3943
|
+
}
|
3944
|
+
|
3945
|
+
/*
|
3946
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
3947
|
+
* All rights reserved.
|
3948
|
+
* SPDX-License-Identifier: MIT
|
3949
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3950
|
+
*/
|
3951
|
+
const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
|
3952
|
+
// In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
|
3953
|
+
class LegacyWeakMultiMap {
|
3954
|
+
constructor() {
|
3955
|
+
this._map = new WeakMap();
|
3956
|
+
}
|
3957
|
+
_getValues(key) {
|
3958
|
+
let values = this._map.get(key);
|
3959
|
+
if (isUndefined$1(values)) {
|
3960
|
+
values = new Set();
|
3961
|
+
this._map.set(key, values);
|
3962
|
+
}
|
3963
|
+
return values;
|
3964
|
+
}
|
3965
|
+
get(key) {
|
3966
|
+
return this._getValues(key);
|
3967
|
+
}
|
3968
|
+
add(key, vm) {
|
3969
|
+
const set = this._getValues(key);
|
3970
|
+
set.add(vm);
|
3971
|
+
}
|
3972
|
+
delete(key) {
|
3973
|
+
this._map.delete(key);
|
3974
|
+
}
|
3975
|
+
}
|
3976
|
+
// This implementation relies on the WeakRef/FinalizationRegistry proposal.
|
3977
|
+
// For some background, see: https://github.com/tc39/proposal-weakrefs
|
3978
|
+
class ModernWeakMultiMap {
|
3979
|
+
constructor() {
|
3980
|
+
this._map = new WeakMap();
|
3981
|
+
this._registry = new FinalizationRegistry(weakRefs => {
|
3982
|
+
// This should be considered an optional cleanup method to remove GC'ed values from their respective arrays.
|
3983
|
+
// JS VMs are not obligated to call FinalizationRegistry callbacks.
|
3984
|
+
// Work backwards, removing stale VMs
|
3985
|
+
for (let i = weakRefs.length - 1; i >= 0; i--) {
|
3986
|
+
const vm = weakRefs[i].deref();
|
3987
|
+
if (isUndefined$1(vm)) {
|
3988
|
+
ArraySplice.call(weakRefs, i, 1); // remove
|
3989
|
+
}
|
3990
|
+
}
|
3991
|
+
});
|
3992
|
+
}
|
3993
|
+
_getWeakRefs(key) {
|
3994
|
+
let weakRefs = this._map.get(key);
|
3995
|
+
if (isUndefined$1(weakRefs)) {
|
3996
|
+
weakRefs = [];
|
3997
|
+
this._map.set(key, weakRefs);
|
3998
|
+
}
|
3999
|
+
return weakRefs;
|
4000
|
+
}
|
4001
|
+
get(key) {
|
4002
|
+
const weakRefs = this._getWeakRefs(key);
|
4003
|
+
const result = new Set();
|
4004
|
+
for (const weakRef of weakRefs) {
|
4005
|
+
const vm = weakRef.deref();
|
4006
|
+
if (!isUndefined$1(vm)) {
|
4007
|
+
result.add(vm);
|
4008
|
+
}
|
4009
|
+
}
|
4010
|
+
return result;
|
4011
|
+
}
|
4012
|
+
add(key, value) {
|
4013
|
+
const weakRefs = this._getWeakRefs(key);
|
4014
|
+
// We could check for duplicate values here, but it doesn't seem worth it.
|
4015
|
+
// We transform the output into a Set anyway
|
4016
|
+
ArrayPush$1.call(weakRefs, new WeakRef(value));
|
4017
|
+
// It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
|
4018
|
+
// effectively creates a strong reference between the first argument (the "target") and the held value. When
|
4019
|
+
// the target is GC'ed, the callback is called, and then the held value is GC'ed.
|
4020
|
+
// Putting the key here would mean the key is not GC'ed until the value is GC'ed, which defeats the purpose
|
4021
|
+
// of the WeakMap. Whereas putting the weakRefs array here is fine, because it doesn't have a strong reference
|
4022
|
+
// to anything. See also this example:
|
4023
|
+
// https://gist.github.com/nolanlawson/79a3d36e8e6cc25c5048bb17c1795aea
|
4024
|
+
this._registry.register(value, weakRefs);
|
4025
|
+
}
|
4026
|
+
delete(key) {
|
4027
|
+
this._map.delete(key);
|
4028
|
+
}
|
4029
|
+
}
|
4030
|
+
const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
|
4031
|
+
|
4032
|
+
/*
|
4033
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
4034
|
+
* All rights reserved.
|
4035
|
+
* SPDX-License-Identifier: MIT
|
4036
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4037
|
+
*/
|
4038
|
+
let swappedTemplateMap = /*@__PURE__@*/new WeakMap();
|
4039
|
+
let swappedComponentMap = /*@__PURE__@*/new WeakMap();
|
4040
|
+
let swappedStyleMap = /*@__PURE__@*/new WeakMap();
|
4041
|
+
// The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
|
4042
|
+
// so we don't want to create strong references to them.
|
4043
|
+
// The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
|
4044
|
+
// never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
|
4045
|
+
// The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
|
4046
|
+
let activeTemplates = /*@__PURE__@*/new WeakMultiMap();
|
4047
|
+
let activeComponents = /*@__PURE__@*/new WeakMultiMap();
|
4048
|
+
let activeStyles = /*@__PURE__@*/new WeakMultiMap();
|
4049
|
+
// Only used in LWC's Karma tests
|
4050
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
4051
|
+
// Used to reset the global state between test runs
|
4052
|
+
window.__lwcResetHotSwaps = () => {
|
4053
|
+
swappedTemplateMap = new WeakMap();
|
4054
|
+
swappedComponentMap = new WeakMap();
|
4055
|
+
swappedStyleMap = new WeakMap();
|
4056
|
+
activeTemplates = new WeakMultiMap();
|
4057
|
+
activeComponents = new WeakMultiMap();
|
4058
|
+
activeStyles = new WeakMultiMap();
|
4059
|
+
};
|
4060
|
+
}
|
4061
|
+
function rehydrateHotTemplate(tpl) {
|
4062
|
+
const list = activeTemplates.get(tpl);
|
4063
|
+
for (const vm of list) {
|
4064
|
+
if (isFalse(vm.isDirty)) {
|
4065
|
+
// forcing the vm to rehydrate in the micro-task:
|
4066
|
+
markComponentAsDirty(vm);
|
4067
|
+
scheduleRehydration(vm);
|
4068
|
+
}
|
4069
|
+
}
|
4070
|
+
// Resetting the Set since these VMs are no longer related to this template, instead
|
4071
|
+
// they will get re-associated once these instances are rehydrated.
|
4072
|
+
activeTemplates.delete(tpl);
|
4073
|
+
return true;
|
4074
|
+
}
|
4075
|
+
function rehydrateHotStyle(style) {
|
4076
|
+
const activeVMs = activeStyles.get(style);
|
4077
|
+
unrenderStylesheet(style);
|
4078
|
+
for (const vm of activeVMs) {
|
4079
|
+
// if a style definition is swapped, we must reset
|
4080
|
+
// vm's template content in the next micro-task:
|
4081
|
+
forceRehydration(vm);
|
4082
|
+
}
|
4083
|
+
// Resetting the Set since these VMs are no longer related to this style, instead
|
3761
4084
|
// they will get re-associated once these instances are rehydrated.
|
3762
4085
|
activeStyles.delete(style);
|
3763
4086
|
return true;
|
@@ -3790,6 +4113,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3790
4113
|
}
|
3791
4114
|
function getTemplateOrSwappedTemplate(tpl) {
|
3792
4115
|
assertNotProd(); // this method should never leak to prod
|
4116
|
+
// TODO [#4154]: shows stale content when swapping content back and forth multiple times
|
3793
4117
|
const visited = new Set();
|
3794
4118
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
3795
4119
|
visited.add(tpl);
|
@@ -3799,6 +4123,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3799
4123
|
}
|
3800
4124
|
function getComponentOrSwappedComponent(Ctor) {
|
3801
4125
|
assertNotProd(); // this method should never leak to prod
|
4126
|
+
// TODO [#4154]: shows stale content when swapping content back and forth multiple times
|
3802
4127
|
const visited = new Set();
|
3803
4128
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
3804
4129
|
visited.add(Ctor);
|
@@ -3808,6 +4133,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3808
4133
|
}
|
3809
4134
|
function getStyleOrSwappedStyle(style) {
|
3810
4135
|
assertNotProd(); // this method should never leak to prod
|
4136
|
+
// TODO [#4154]: shows stale content when swapping content back and forth multiple times
|
3811
4137
|
const visited = new Set();
|
3812
4138
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
3813
4139
|
visited.add(style);
|
@@ -3815,6 +4141,22 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3815
4141
|
}
|
3816
4142
|
return style;
|
3817
4143
|
}
|
4144
|
+
function addActiveStylesheets(stylesheets, vm) {
|
4145
|
+
if (isUndefined$1(stylesheets) || isNull(stylesheets)) {
|
4146
|
+
// Ignore non-existent stylesheets
|
4147
|
+
return;
|
4148
|
+
}
|
4149
|
+
for (const stylesheet of flattenStylesheets(stylesheets)) {
|
4150
|
+
// this is necessary because we don't hold the list of styles
|
4151
|
+
// in the vm, we only hold the selected (already swapped template)
|
4152
|
+
// but the styles attached to the template might not be the actual
|
4153
|
+
// active ones, but the swapped versions of those.
|
4154
|
+
const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
|
4155
|
+
// this will allow us to keep track of the stylesheet that are
|
4156
|
+
// being used by a hot component
|
4157
|
+
activeStyles.add(swappedStylesheet, vm);
|
4158
|
+
}
|
4159
|
+
}
|
3818
4160
|
function setActiveVM(vm) {
|
3819
4161
|
assertNotProd(); // this method should never leak to prod
|
3820
4162
|
// tracking active component
|
@@ -3822,25 +4164,15 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3822
4164
|
// this will allow us to keep track of the hot components
|
3823
4165
|
activeComponents.add(Ctor, vm);
|
3824
4166
|
// tracking active template
|
3825
|
-
const
|
3826
|
-
if (
|
4167
|
+
const template = vm.cmpTemplate;
|
4168
|
+
if (!isNull(template)) {
|
3827
4169
|
// this will allow us to keep track of the templates that are
|
3828
4170
|
// being used by a hot component
|
3829
|
-
activeTemplates.add(
|
3830
|
-
//
|
3831
|
-
|
3832
|
-
|
3833
|
-
|
3834
|
-
// this is necessary because we don't hold the list of styles
|
3835
|
-
// in the vm, we only hold the selected (already swapped template)
|
3836
|
-
// but the styles attached to the template might not be the actual
|
3837
|
-
// active ones, but the swapped versions of those.
|
3838
|
-
const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
|
3839
|
-
// this will allow us to keep track of the stylesheet that are
|
3840
|
-
// being used by a hot component
|
3841
|
-
activeStyles.add(swappedStylesheet, vm);
|
3842
|
-
}
|
3843
|
-
}
|
4171
|
+
activeTemplates.add(template, vm);
|
4172
|
+
// Tracking active styles from the template or the VM. `template.stylesheets` are implicitly associated
|
4173
|
+
// (e.g. `foo.css` associated with `foo.html`), whereas `vm.stylesheets` are from `static stylesheets`.
|
4174
|
+
addActiveStylesheets(template.stylesheets, vm);
|
4175
|
+
addActiveStylesheets(vm.stylesheets, vm);
|
3844
4176
|
}
|
3845
4177
|
}
|
3846
4178
|
function swapTemplate(oldTpl, newTpl) {
|
@@ -3977,414 +4309,169 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
3977
4309
|
render = render || superDef.render;
|
3978
4310
|
let shadowSupportMode = superDef.shadowSupportMode;
|
3979
4311
|
if (!isUndefined$1(ctorShadowSupportMode)) {
|
3980
|
-
shadowSupportMode = ctorShadowSupportMode;
|
3981
|
-
if (isReportingEnabled() && (shadowSupportMode === "any" /* ShadowSupportMode.Any */ || shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
|
3982
|
-
report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
|
3983
|
-
tagName: Ctor.name,
|
3984
|
-
mode: shadowSupportMode
|
3985
|
-
});
|
3986
|
-
}
|
3987
|
-
}
|
3988
|
-
let renderMode = superDef.renderMode;
|
3989
|
-
if (!isUndefined$1(ctorRenderMode)) {
|
3990
|
-
renderMode = ctorRenderMode === 'light' ? 0 /* RenderMode.Light */ : 1 /* RenderMode.Shadow */;
|
3991
|
-
}
|
3992
|
-
let formAssociated = superDef.formAssociated;
|
3993
|
-
if (!isUndefined$1(ctorFormAssociated)) {
|
3994
|
-
formAssociated = ctorFormAssociated;
|
3995
|
-
}
|
3996
|
-
const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
|
3997
|
-
const name = Ctor.name || superDef.name;
|
3998
|
-
// installing observed fields into the prototype.
|
3999
|
-
defineProperties(proto, observedFields);
|
4000
|
-
const def = {
|
4001
|
-
ctor: Ctor,
|
4002
|
-
name,
|
4003
|
-
wire,
|
4004
|
-
props,
|
4005
|
-
propsConfig,
|
4006
|
-
methods,
|
4007
|
-
bridge,
|
4008
|
-
template,
|
4009
|
-
renderMode,
|
4010
|
-
shadowSupportMode,
|
4011
|
-
formAssociated,
|
4012
|
-
connectedCallback,
|
4013
|
-
disconnectedCallback,
|
4014
|
-
errorCallback,
|
4015
|
-
formAssociatedCallback,
|
4016
|
-
formDisabledCallback,
|
4017
|
-
formResetCallback,
|
4018
|
-
formStateRestoreCallback,
|
4019
|
-
renderedCallback,
|
4020
|
-
render
|
4021
|
-
};
|
4022
|
-
// This is a no-op unless Lightning DevTools are enabled.
|
4023
|
-
instrumentDef(def);
|
4024
|
-
if (process.env.NODE_ENV !== 'production') {
|
4025
|
-
freeze(Ctor.prototype);
|
4026
|
-
}
|
4027
|
-
return def;
|
4028
|
-
}
|
4029
|
-
/**
|
4030
|
-
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
4031
|
-
* subject to change or being removed.
|
4032
|
-
* @param ctor
|
4033
|
-
*/
|
4034
|
-
function isComponentConstructor(ctor) {
|
4035
|
-
if (!isFunction$1(ctor)) {
|
4036
|
-
return false;
|
4037
|
-
}
|
4038
|
-
// Fast path: LightningElement is part of the prototype chain of the constructor.
|
4039
|
-
if (ctor.prototype instanceof LightningElement) {
|
4040
|
-
return true;
|
4041
|
-
}
|
4042
|
-
// Slow path: LightningElement is not part of the prototype chain of the constructor, we need
|
4043
|
-
// climb up the constructor prototype chain to check in case there are circular dependencies
|
4044
|
-
// to resolve.
|
4045
|
-
let current = ctor;
|
4046
|
-
do {
|
4047
|
-
if (isCircularModuleDependency(current)) {
|
4048
|
-
const circularResolved = resolveCircularModuleDependency(current);
|
4049
|
-
// If the circular function returns itself, that's the signal that we have hit the end
|
4050
|
-
// of the proto chain, which must always be a valid base constructor.
|
4051
|
-
if (circularResolved === current) {
|
4052
|
-
return true;
|
4053
|
-
}
|
4054
|
-
current = circularResolved;
|
4055
|
-
}
|
4056
|
-
if (current === LightningElement) {
|
4057
|
-
return true;
|
4058
|
-
}
|
4059
|
-
} while (!isNull(current) && (current = getPrototypeOf$1(current)));
|
4060
|
-
// Finally return false if the LightningElement is not part of the prototype chain.
|
4061
|
-
return false;
|
4062
|
-
}
|
4063
|
-
function getComponentInternalDef(Ctor) {
|
4064
|
-
if (process.env.NODE_ENV !== 'production') {
|
4065
|
-
Ctor = getComponentOrSwappedComponent(Ctor);
|
4066
|
-
}
|
4067
|
-
let def = CtorToDefMap.get(Ctor);
|
4068
|
-
if (isUndefined$1(def)) {
|
4069
|
-
if (isCircularModuleDependency(Ctor)) {
|
4070
|
-
const resolvedCtor = resolveCircularModuleDependency(Ctor);
|
4071
|
-
def = getComponentInternalDef(resolvedCtor);
|
4072
|
-
// Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
|
4073
|
-
// look up the definition in cache instead of re-resolving and recreating the def.
|
4074
|
-
CtorToDefMap.set(Ctor, def);
|
4075
|
-
return def;
|
4076
|
-
}
|
4077
|
-
if (!isComponentConstructor(Ctor)) {
|
4078
|
-
throw new TypeError(`${Ctor} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.`);
|
4079
|
-
}
|
4080
|
-
def = createComponentDef(Ctor);
|
4081
|
-
CtorToDefMap.set(Ctor, def);
|
4082
|
-
}
|
4083
|
-
return def;
|
4084
|
-
}
|
4085
|
-
function getComponentHtmlPrototype(Ctor) {
|
4086
|
-
const def = getComponentInternalDef(Ctor);
|
4087
|
-
return def.bridge;
|
4088
|
-
}
|
4089
|
-
const lightingElementDef = {
|
4090
|
-
ctor: LightningElement,
|
4091
|
-
name: LightningElement.name,
|
4092
|
-
props: lightningBasedDescriptors,
|
4093
|
-
propsConfig: EmptyObject,
|
4094
|
-
methods: EmptyObject,
|
4095
|
-
renderMode: 1 /* RenderMode.Shadow */,
|
4096
|
-
shadowSupportMode: "reset" /* ShadowSupportMode.Default */,
|
4097
|
-
formAssociated: undefined,
|
4098
|
-
wire: EmptyObject,
|
4099
|
-
bridge: BaseBridgeElement,
|
4100
|
-
template: defaultEmptyTemplate,
|
4101
|
-
render: LightningElement.prototype.render
|
4102
|
-
};
|
4103
|
-
/**
|
4104
|
-
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
4105
|
-
* subject to change or being removed.
|
4106
|
-
* @param Ctor
|
4107
|
-
*/
|
4108
|
-
function getComponentDef(Ctor) {
|
4109
|
-
const def = getComponentInternalDef(Ctor);
|
4110
|
-
// From the internal def object, we need to extract the info that is useful
|
4111
|
-
// for some external services, e.g.: Locker Service, usually, all they care
|
4112
|
-
// is about the shape of the constructor, the internals of it are not relevant
|
4113
|
-
// because they don't have a way to mess with that.
|
4114
|
-
const {
|
4115
|
-
ctor,
|
4116
|
-
name,
|
4117
|
-
props,
|
4118
|
-
propsConfig,
|
4119
|
-
methods
|
4120
|
-
} = def;
|
4121
|
-
const publicProps = {};
|
4122
|
-
for (const key in props) {
|
4123
|
-
// avoid leaking the reference to the public props descriptors
|
4124
|
-
publicProps[key] = {
|
4125
|
-
config: propsConfig[key] || 0,
|
4126
|
-
// a property by default
|
4127
|
-
type: "any" /* PropDefType.any */,
|
4128
|
-
// no type inference for public services
|
4129
|
-
attr: htmlPropertyToAttribute(key)
|
4130
|
-
};
|
4131
|
-
}
|
4132
|
-
const publicMethods = {};
|
4133
|
-
for (const key in methods) {
|
4134
|
-
// avoid leaking the reference to the public method descriptors
|
4135
|
-
publicMethods[key] = methods[key].value;
|
4136
|
-
}
|
4137
|
-
return {
|
4138
|
-
ctor,
|
4139
|
-
name,
|
4140
|
-
props: publicProps,
|
4141
|
-
methods: publicMethods
|
4142
|
-
};
|
4143
|
-
}
|
4144
|
-
|
4145
|
-
/*
|
4146
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
4147
|
-
* All rights reserved.
|
4148
|
-
* SPDX-License-Identifier: MIT
|
4149
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4150
|
-
*/
|
4151
|
-
function makeHostToken(token) {
|
4152
|
-
// Note: if this ever changes, update the `cssScopeTokens` returned by `@lwc/compiler`
|
4153
|
-
return `${token}-host`;
|
4154
|
-
}
|
4155
|
-
function createInlineStyleVNode(content) {
|
4156
|
-
return api.h('style', {
|
4157
|
-
key: 'style',
|
4158
|
-
// special key
|
4159
|
-
attrs: {
|
4160
|
-
type: 'text/css'
|
4161
|
-
}
|
4162
|
-
}, [api.t(content)]);
|
4163
|
-
}
|
4164
|
-
// TODO [#3733]: remove support for legacy scope tokens
|
4165
|
-
function updateStylesheetToken(vm, template, legacy) {
|
4166
|
-
const {
|
4167
|
-
elm,
|
4168
|
-
context,
|
4169
|
-
renderMode,
|
4170
|
-
shadowMode,
|
4171
|
-
renderer: {
|
4172
|
-
getClassList,
|
4173
|
-
removeAttribute,
|
4174
|
-
setAttribute
|
4175
|
-
}
|
4176
|
-
} = vm;
|
4177
|
-
const {
|
4178
|
-
stylesheets: newStylesheets
|
4179
|
-
} = template;
|
4180
|
-
const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
|
4181
|
-
const {
|
4182
|
-
stylesheets: newVmStylesheets
|
4183
|
-
} = vm;
|
4184
|
-
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
4185
|
-
const {
|
4186
|
-
hasScopedStyles
|
4187
|
-
} = context;
|
4188
|
-
let newToken;
|
4189
|
-
let newHasTokenInClass;
|
4190
|
-
let newHasTokenInAttribute;
|
4191
|
-
// Reset the styling token applied to the host element.
|
4192
|
-
let oldToken;
|
4193
|
-
let oldHasTokenInClass;
|
4194
|
-
let oldHasTokenInAttribute;
|
4195
|
-
if (legacy) {
|
4196
|
-
oldToken = context.legacyStylesheetToken;
|
4197
|
-
oldHasTokenInClass = context.hasLegacyTokenInClass;
|
4198
|
-
oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
|
4199
|
-
} else {
|
4200
|
-
oldToken = context.stylesheetToken;
|
4201
|
-
oldHasTokenInClass = context.hasTokenInClass;
|
4202
|
-
oldHasTokenInAttribute = context.hasTokenInAttribute;
|
4203
|
-
}
|
4204
|
-
if (!isUndefined$1(oldToken)) {
|
4205
|
-
if (oldHasTokenInClass) {
|
4206
|
-
getClassList(elm).remove(makeHostToken(oldToken));
|
4207
|
-
}
|
4208
|
-
if (oldHasTokenInAttribute) {
|
4209
|
-
removeAttribute(elm, makeHostToken(oldToken));
|
4210
|
-
}
|
4211
|
-
}
|
4212
|
-
// Apply the new template styling token to the host element, if the new template has any
|
4213
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
4214
|
-
const hasNewStylesheets = hasStyles(newStylesheets);
|
4215
|
-
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
4216
|
-
if (hasNewStylesheets || hasNewVmStylesheets) {
|
4217
|
-
newToken = newStylesheetToken;
|
4218
|
-
}
|
4219
|
-
// Set the new styling token on the host element
|
4220
|
-
if (!isUndefined$1(newToken)) {
|
4221
|
-
if (hasScopedStyles) {
|
4222
|
-
getClassList(elm).add(makeHostToken(newToken));
|
4223
|
-
newHasTokenInClass = true;
|
4224
|
-
}
|
4225
|
-
if (isSyntheticShadow) {
|
4226
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
4227
|
-
newHasTokenInAttribute = true;
|
4228
|
-
}
|
4229
|
-
}
|
4230
|
-
// Update the styling tokens present on the context object.
|
4231
|
-
if (legacy) {
|
4232
|
-
context.legacyStylesheetToken = newToken;
|
4233
|
-
context.hasLegacyTokenInClass = newHasTokenInClass;
|
4234
|
-
context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
|
4235
|
-
} else {
|
4236
|
-
context.stylesheetToken = newToken;
|
4237
|
-
context.hasTokenInClass = newHasTokenInClass;
|
4238
|
-
context.hasTokenInAttribute = newHasTokenInAttribute;
|
4239
|
-
}
|
4240
|
-
}
|
4241
|
-
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
4242
|
-
const content = [];
|
4243
|
-
let root;
|
4244
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
4245
|
-
let stylesheet = stylesheets[i];
|
4246
|
-
if (isArray$1(stylesheet)) {
|
4247
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
4248
|
-
} else {
|
4249
|
-
if (process.env.NODE_ENV !== 'production') {
|
4250
|
-
// Check for compiler version mismatch in dev mode only
|
4251
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
4252
|
-
// in dev-mode, we support hot swapping of stylesheet, which means that
|
4253
|
-
// the component instance might be attempting to use an old version of
|
4254
|
-
// the stylesheet, while internally, we have a replacement for it.
|
4255
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
4256
|
-
}
|
4257
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
4258
|
-
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS && !isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
4259
|
-
logError('Unscoped CSS is not supported in Light DOM in this environment. Please use scoped CSS ' + '(*.scoped.css) instead of unscoped CSS (*.css). See also: https://sfdc.co/scoped-styles-light-dom');
|
4260
|
-
continue;
|
4261
|
-
}
|
4262
|
-
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
4263
|
-
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
4264
|
-
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
4265
|
-
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
4266
|
-
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
4267
|
-
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
4268
|
-
// we use an attribute selector on the host to simulate :dir().
|
4269
|
-
let useNativeDirPseudoclass;
|
4270
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
4271
|
-
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
4272
|
-
} else {
|
4273
|
-
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
4274
|
-
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
4275
|
-
if (isUndefined$1(root)) {
|
4276
|
-
// Only calculate the root once as necessary
|
4277
|
-
root = getNearestShadowComponent(vm);
|
4278
|
-
}
|
4279
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
4280
|
-
}
|
4281
|
-
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
4312
|
+
shadowSupportMode = ctorShadowSupportMode;
|
4313
|
+
if (isReportingEnabled() && (shadowSupportMode === "any" /* ShadowSupportMode.Any */ || shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
|
4314
|
+
report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
|
4315
|
+
tagName: Ctor.name,
|
4316
|
+
mode: shadowSupportMode
|
4317
|
+
});
|
4282
4318
|
}
|
4283
4319
|
}
|
4284
|
-
|
4320
|
+
let renderMode = superDef.renderMode;
|
4321
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
4322
|
+
renderMode = ctorRenderMode === 'light' ? 0 /* RenderMode.Light */ : 1 /* RenderMode.Shadow */;
|
4323
|
+
}
|
4324
|
+
let formAssociated = superDef.formAssociated;
|
4325
|
+
if (!isUndefined$1(ctorFormAssociated)) {
|
4326
|
+
formAssociated = ctorFormAssociated;
|
4327
|
+
}
|
4328
|
+
const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
|
4329
|
+
const name = Ctor.name || superDef.name;
|
4330
|
+
// installing observed fields into the prototype.
|
4331
|
+
defineProperties(proto, observedFields);
|
4332
|
+
const def = {
|
4333
|
+
ctor: Ctor,
|
4334
|
+
name,
|
4335
|
+
wire,
|
4336
|
+
props,
|
4337
|
+
propsConfig,
|
4338
|
+
methods,
|
4339
|
+
bridge,
|
4340
|
+
template,
|
4341
|
+
renderMode,
|
4342
|
+
shadowSupportMode,
|
4343
|
+
formAssociated,
|
4344
|
+
connectedCallback,
|
4345
|
+
disconnectedCallback,
|
4346
|
+
errorCallback,
|
4347
|
+
formAssociatedCallback,
|
4348
|
+
formDisabledCallback,
|
4349
|
+
formResetCallback,
|
4350
|
+
formStateRestoreCallback,
|
4351
|
+
renderedCallback,
|
4352
|
+
render
|
4353
|
+
};
|
4354
|
+
// This is a no-op unless Lightning DevTools are enabled.
|
4355
|
+
instrumentDef(def);
|
4356
|
+
if (process.env.NODE_ENV !== 'production') {
|
4357
|
+
freeze(Ctor.prototype);
|
4358
|
+
}
|
4359
|
+
return def;
|
4285
4360
|
}
|
4286
|
-
|
4287
|
-
|
4288
|
-
|
4289
|
-
|
4290
|
-
|
4291
|
-
|
4292
|
-
|
4293
|
-
|
4294
|
-
let content = [];
|
4295
|
-
if (hasStyles(stylesheets)) {
|
4296
|
-
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
4361
|
+
/**
|
4362
|
+
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
4363
|
+
* subject to change or being removed.
|
4364
|
+
* @param ctor
|
4365
|
+
*/
|
4366
|
+
function isComponentConstructor(ctor) {
|
4367
|
+
if (!isFunction$1(ctor)) {
|
4368
|
+
return false;
|
4297
4369
|
}
|
4298
|
-
//
|
4299
|
-
if (
|
4300
|
-
|
4370
|
+
// Fast path: LightningElement is part of the prototype chain of the constructor.
|
4371
|
+
if (ctor.prototype instanceof LightningElement) {
|
4372
|
+
return true;
|
4301
4373
|
}
|
4302
|
-
|
4374
|
+
// Slow path: LightningElement is not part of the prototype chain of the constructor, we need
|
4375
|
+
// climb up the constructor prototype chain to check in case there are circular dependencies
|
4376
|
+
// to resolve.
|
4377
|
+
let current = ctor;
|
4378
|
+
do {
|
4379
|
+
if (isCircularModuleDependency(current)) {
|
4380
|
+
const circularResolved = resolveCircularModuleDependency(current);
|
4381
|
+
// If the circular function returns itself, that's the signal that we have hit the end
|
4382
|
+
// of the proto chain, which must always be a valid base constructor.
|
4383
|
+
if (circularResolved === current) {
|
4384
|
+
return true;
|
4385
|
+
}
|
4386
|
+
current = circularResolved;
|
4387
|
+
}
|
4388
|
+
if (current === LightningElement) {
|
4389
|
+
return true;
|
4390
|
+
}
|
4391
|
+
} while (!isNull(current) && (current = getPrototypeOf$1(current)));
|
4392
|
+
// Finally return false if the LightningElement is not part of the prototype chain.
|
4393
|
+
return false;
|
4303
4394
|
}
|
4304
|
-
|
4305
|
-
|
4306
|
-
|
4307
|
-
|
4308
|
-
let
|
4309
|
-
|
4310
|
-
if (
|
4311
|
-
|
4395
|
+
function getComponentInternalDef(Ctor) {
|
4396
|
+
if (process.env.NODE_ENV !== 'production') {
|
4397
|
+
Ctor = getComponentOrSwappedComponent(Ctor);
|
4398
|
+
}
|
4399
|
+
let def = CtorToDefMap.get(Ctor);
|
4400
|
+
if (isUndefined$1(def)) {
|
4401
|
+
if (isCircularModuleDependency(Ctor)) {
|
4402
|
+
const resolvedCtor = resolveCircularModuleDependency(Ctor);
|
4403
|
+
def = getComponentInternalDef(resolvedCtor);
|
4404
|
+
// Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
|
4405
|
+
// look up the definition in cache instead of re-resolving and recreating the def.
|
4406
|
+
CtorToDefMap.set(Ctor, def);
|
4407
|
+
return def;
|
4312
4408
|
}
|
4313
|
-
|
4409
|
+
if (!isComponentConstructor(Ctor)) {
|
4410
|
+
throw new TypeError(`${Ctor} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.`);
|
4411
|
+
}
|
4412
|
+
def = createComponentDef(Ctor);
|
4413
|
+
CtorToDefMap.set(Ctor, def);
|
4314
4414
|
}
|
4315
|
-
return
|
4415
|
+
return def;
|
4316
4416
|
}
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
* it returns null.
|
4321
|
-
* @param owner
|
4322
|
-
* @param legacy
|
4323
|
-
*/
|
4324
|
-
// TODO [#3733]: remove support for legacy scope tokens
|
4325
|
-
function getScopeTokenClass(owner, legacy) {
|
4326
|
-
const {
|
4327
|
-
cmpTemplate,
|
4328
|
-
context
|
4329
|
-
} = owner;
|
4330
|
-
return context.hasScopedStyles && (legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken) || null;
|
4417
|
+
function getComponentHtmlPrototype(Ctor) {
|
4418
|
+
const def = getComponentInternalDef(Ctor);
|
4419
|
+
return def.bridge;
|
4331
4420
|
}
|
4421
|
+
const lightingElementDef = {
|
4422
|
+
ctor: LightningElement,
|
4423
|
+
name: LightningElement.name,
|
4424
|
+
props: lightningBasedDescriptors,
|
4425
|
+
propsConfig: EmptyObject,
|
4426
|
+
methods: EmptyObject,
|
4427
|
+
renderMode: 1 /* RenderMode.Shadow */,
|
4428
|
+
shadowSupportMode: "reset" /* ShadowSupportMode.Default */,
|
4429
|
+
formAssociated: undefined,
|
4430
|
+
wire: EmptyObject,
|
4431
|
+
bridge: BaseBridgeElement,
|
4432
|
+
template: defaultEmptyTemplate,
|
4433
|
+
render: LightningElement.prototype.render
|
4434
|
+
};
|
4332
4435
|
/**
|
4333
|
-
* This function
|
4334
|
-
*
|
4335
|
-
*
|
4336
|
-
* A host style token is applied to the component if scoped styles are used.
|
4337
|
-
* @param vnode
|
4436
|
+
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
4437
|
+
* subject to change or being removed.
|
4438
|
+
* @param Ctor
|
4338
4439
|
*/
|
4339
|
-
function
|
4340
|
-
const
|
4341
|
-
|
4342
|
-
|
4343
|
-
|
4344
|
-
|
4345
|
-
} = vnode;
|
4440
|
+
function getComponentDef(Ctor) {
|
4441
|
+
const def = getComponentInternalDef(Ctor);
|
4442
|
+
// From the internal def object, we need to extract the info that is useful
|
4443
|
+
// for some external services, e.g.: Locker Service, usually, all they care
|
4444
|
+
// is about the shape of the constructor, the internals of it are not relevant
|
4445
|
+
// because they don't have a way to mess with that.
|
4346
4446
|
const {
|
4347
|
-
|
4348
|
-
|
4349
|
-
|
4350
|
-
|
4351
|
-
|
4352
|
-
|
4353
|
-
|
4354
|
-
|
4355
|
-
//
|
4356
|
-
|
4447
|
+
ctor,
|
4448
|
+
name,
|
4449
|
+
props,
|
4450
|
+
propsConfig,
|
4451
|
+
methods
|
4452
|
+
} = def;
|
4453
|
+
const publicProps = {};
|
4454
|
+
for (const key in props) {
|
4455
|
+
// avoid leaking the reference to the public props descriptors
|
4456
|
+
publicProps[key] = {
|
4457
|
+
config: propsConfig[key] || 0,
|
4458
|
+
// a property by default
|
4459
|
+
type: "any" /* PropDefType.any */,
|
4460
|
+
// no type inference for public services
|
4461
|
+
attr: htmlPropertyToAttribute(key)
|
4462
|
+
};
|
4357
4463
|
}
|
4358
|
-
|
4359
|
-
|
4360
|
-
|
4361
|
-
|
4362
|
-
renderMode,
|
4363
|
-
shadowMode,
|
4364
|
-
renderer: {
|
4365
|
-
insertStylesheet
|
4366
|
-
}
|
4367
|
-
} = vm;
|
4368
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
4369
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
4370
|
-
insertStylesheet(stylesheets[i]);
|
4371
|
-
}
|
4372
|
-
} else if (vm.hydrated) {
|
4373
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
4374
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
4375
|
-
// the first time the VM renders.
|
4376
|
-
// native shadow or light DOM, SSR
|
4377
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
4378
|
-
} else {
|
4379
|
-
// native shadow or light DOM, DOM renderer
|
4380
|
-
const root = getNearestNativeShadowComponent(vm);
|
4381
|
-
// null root means a global style
|
4382
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
4383
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
4384
|
-
insertStylesheet(stylesheets[i], target);
|
4385
|
-
}
|
4464
|
+
const publicMethods = {};
|
4465
|
+
for (const key in methods) {
|
4466
|
+
// avoid leaking the reference to the public method descriptors
|
4467
|
+
publicMethods[key] = methods[key].value;
|
4386
4468
|
}
|
4387
|
-
return
|
4469
|
+
return {
|
4470
|
+
ctor,
|
4471
|
+
name,
|
4472
|
+
props: publicProps,
|
4473
|
+
methods: publicMethods
|
4474
|
+
};
|
4388
4475
|
}
|
4389
4476
|
|
4390
4477
|
/*
|
@@ -4810,7 +4897,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
4810
4897
|
}
|
4811
4898
|
|
4812
4899
|
/*
|
4813
|
-
* Copyright (c)
|
4900
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
4814
4901
|
* All rights reserved.
|
4815
4902
|
* SPDX-License-Identifier: MIT
|
4816
4903
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -4836,34 +4923,59 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
4836
4923
|
for (const staticPart of parts) {
|
4837
4924
|
partIdsToParts.set(staticPart.partId, staticPart);
|
4838
4925
|
}
|
4839
|
-
|
4926
|
+
// Note that we traverse using `*Child`/`*Sibling` rather than `children` because the browser uses a linked
|
4927
|
+
// list under the hood to represent the DOM tree, so it's faster to do this than to create an underlying array
|
4928
|
+
// by calling `children`.
|
4840
4929
|
const {
|
4841
|
-
|
4842
|
-
|
4930
|
+
nextSibling,
|
4931
|
+
getFirstChild,
|
4932
|
+
getParentNode
|
4843
4933
|
} = renderer;
|
4844
|
-
|
4934
|
+
let numFoundParts = 0;
|
4845
4935
|
let partId = -1;
|
4936
|
+
// We should never traverse up to the root. We should exit early due to numFoundParts === numParts.
|
4937
|
+
// This is just a sanity check, in case the static parts generated by @lwc/template-compiler are wrong.
|
4938
|
+
function assertNotRoot(node) {
|
4939
|
+
if (process.env.NODE_ENV !== 'production') {
|
4940
|
+
assert.isFalse(node === root, `Reached the root without finding all parts. Found ${numFoundParts}, needed ${numParts}.`);
|
4941
|
+
}
|
4942
|
+
}
|
4846
4943
|
// Depth-first traversal. We assign a partId to each element, which is an integer based on traversal order.
|
4847
|
-
|
4848
|
-
|
4944
|
+
// This function is very hot, which is why it's micro-optimized. Note we don't use a stack at all; we traverse
|
4945
|
+
// using an algorithm that relies on the parentNode getter: https://stackoverflow.com/a/5285417
|
4946
|
+
// This is very slightly faster than a TreeWalker (~0.5% on js-framework-benchmark create-10k), but basically
|
4947
|
+
// the same idea.
|
4948
|
+
let node = root;
|
4949
|
+
while (!isNull(node)) {
|
4950
|
+
// visit node
|
4849
4951
|
partId++;
|
4850
4952
|
const part = partIdsToParts.get(partId);
|
4851
4953
|
if (!isUndefined$1(part)) {
|
4852
|
-
part.elm =
|
4853
|
-
|
4954
|
+
part.elm = node;
|
4955
|
+
numFoundParts++;
|
4956
|
+
if (numFoundParts === numParts) {
|
4854
4957
|
return; // perf optimization - stop traversing once we've found everything we need
|
4855
4958
|
}
|
4856
4959
|
}
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
4860
|
-
|
4861
|
-
|
4862
|
-
|
4863
|
-
|
4864
|
-
|
4960
|
+
const child = getFirstChild(node);
|
4961
|
+
if (!isNull(child)) {
|
4962
|
+
// walk down
|
4963
|
+
node = child;
|
4964
|
+
} else {
|
4965
|
+
let sibling;
|
4966
|
+
while (isNull(sibling = nextSibling(node))) {
|
4967
|
+
// we never want to walk up from the root
|
4968
|
+
assertNotRoot(node);
|
4969
|
+
// walk up
|
4970
|
+
node = getParentNode(node);
|
4971
|
+
}
|
4972
|
+
// we never want to walk right from the root
|
4973
|
+
assertNotRoot(node);
|
4974
|
+
// walk right
|
4975
|
+
node = sibling;
|
4865
4976
|
}
|
4866
4977
|
}
|
4978
|
+
/* istanbul ignore next */
|
4867
4979
|
if (process.env.NODE_ENV !== 'production') {
|
4868
4980
|
assert.isTrue(numFoundParts === numParts, `Should have found all parts by now. Found ${numFoundParts}, needed ${numParts}.`);
|
4869
4981
|
}
|
@@ -8726,7 +8838,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8726
8838
|
}
|
8727
8839
|
return getReadOnlyProxy(obj);
|
8728
8840
|
}
|
8729
|
-
/** version: 6.
|
8841
|
+
/** version: 6.6.1 */
|
8730
8842
|
|
8731
8843
|
/*
|
8732
8844
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -8856,7 +8968,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8856
8968
|
stylesheet.replaceSync(content);
|
8857
8969
|
return stylesheet;
|
8858
8970
|
}
|
8859
|
-
function insertConstructableStylesheet(content, target, cacheData) {
|
8971
|
+
function insertConstructableStylesheet(content, target, cacheData, signal) {
|
8860
8972
|
const {
|
8861
8973
|
adoptedStyleSheets
|
8862
8974
|
} = target;
|
@@ -8865,10 +8977,32 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8865
8977
|
} = cacheData;
|
8866
8978
|
// The reason we prefer .push() rather than reassignment is for perf: https://github.com/salesforce/lwc/pull/2683
|
8867
8979
|
adoptedStyleSheets.push(stylesheet);
|
8980
|
+
if (process.env.NODE_ENV !== 'production') {
|
8981
|
+
/* istanbul ignore if */
|
8982
|
+
if (isUndefined$1(signal)) {
|
8983
|
+
throw new Error('Expected AbortSignal to be defined in dev mode');
|
8984
|
+
}
|
8985
|
+
// TODO [#4155]: unrendering should account for stylesheet content collisions
|
8986
|
+
signal.addEventListener('abort', () => {
|
8987
|
+
adoptedStyleSheets.splice(adoptedStyleSheets.indexOf(stylesheet), 1);
|
8988
|
+
stylesheetCache.delete(content);
|
8989
|
+
});
|
8990
|
+
}
|
8868
8991
|
}
|
8869
|
-
function insertStyleElement(content, target, cacheData) {
|
8992
|
+
function insertStyleElement(content, target, cacheData, signal) {
|
8870
8993
|
const elm = createStyleElement(content, cacheData);
|
8871
8994
|
target.appendChild(elm);
|
8995
|
+
if (process.env.NODE_ENV !== 'production') {
|
8996
|
+
/* istanbul ignore if */
|
8997
|
+
if (isUndefined$1(signal)) {
|
8998
|
+
throw new Error('Expected AbortSignal to be defined in dev mode');
|
8999
|
+
}
|
9000
|
+
// TODO [#4155]: unrendering should account for stylesheet content collisions
|
9001
|
+
signal.addEventListener('abort', () => {
|
9002
|
+
target.removeChild(elm);
|
9003
|
+
stylesheetCache.delete(content);
|
9004
|
+
});
|
9005
|
+
}
|
8872
9006
|
}
|
8873
9007
|
function getCacheData(content, useConstructableStylesheet) {
|
8874
9008
|
let cacheData = stylesheetCache.get(content);
|
@@ -8890,7 +9024,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8890
9024
|
}
|
8891
9025
|
return cacheData;
|
8892
9026
|
}
|
8893
|
-
function insertGlobalStylesheet(content) {
|
9027
|
+
function insertGlobalStylesheet(content, signal) {
|
8894
9028
|
// Force a <style> element for global stylesheets. See comment below.
|
8895
9029
|
const cacheData = getCacheData(content, false);
|
8896
9030
|
if (cacheData.global) {
|
@@ -8899,9 +9033,9 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8899
9033
|
}
|
8900
9034
|
cacheData.global = true; // mark inserted
|
8901
9035
|
// TODO [#2922]: use document.adoptedStyleSheets in supported browsers. Currently we can't, due to backwards compat.
|
8902
|
-
insertStyleElement(content, document.head, cacheData);
|
9036
|
+
insertStyleElement(content, document.head, cacheData, signal);
|
8903
9037
|
}
|
8904
|
-
function insertLocalStylesheet(content, target) {
|
9038
|
+
function insertLocalStylesheet(content, target, signal) {
|
8905
9039
|
const cacheData = getCacheData(content, supportsConstructableStylesheets);
|
8906
9040
|
let {
|
8907
9041
|
roots
|
@@ -8917,19 +9051,25 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8917
9051
|
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
8918
9052
|
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
8919
9053
|
if (supportsConstructableStylesheets) {
|
8920
|
-
insertConstructableStylesheet(content, target, cacheData);
|
9054
|
+
insertConstructableStylesheet(content, target, cacheData, signal);
|
8921
9055
|
} else {
|
8922
9056
|
// Fall back to <style> element
|
8923
|
-
insertStyleElement(content, target, cacheData);
|
9057
|
+
insertStyleElement(content, target, cacheData, signal);
|
8924
9058
|
}
|
8925
9059
|
}
|
8926
|
-
|
9060
|
+
/**
|
9061
|
+
* Injects a stylesheet into the global (document) level or inside a shadow root.
|
9062
|
+
* @param content CSS content to insert
|
9063
|
+
* @param target ShadowRoot to insert into, or undefined if global (document) level
|
9064
|
+
* @param signal AbortSignal for aborting the stylesheet render. Used in dev mode for HMR to unrender stylesheets.
|
9065
|
+
*/
|
9066
|
+
function insertStylesheet(content, target, signal) {
|
8927
9067
|
if (isUndefined$1(target)) {
|
8928
9068
|
// global
|
8929
|
-
insertGlobalStylesheet(content);
|
9069
|
+
insertGlobalStylesheet(content, signal);
|
8930
9070
|
} else {
|
8931
9071
|
// local
|
8932
|
-
insertLocalStylesheet(content, target);
|
9072
|
+
insertLocalStylesheet(content, target, signal);
|
8933
9073
|
}
|
8934
9074
|
}
|
8935
9075
|
|
@@ -8998,7 +9138,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
8998
9138
|
runFormStateRestoreCallback(this, state, reason);
|
8999
9139
|
}
|
9000
9140
|
}
|
9001
|
-
/*LWC compiler v6.
|
9141
|
+
/*LWC compiler v6.6.1*/
|
9002
9142
|
};
|
9003
9143
|
BaseHTMLElement = HTMLElement; // cache to track if it changes
|
9004
9144
|
}
|
@@ -9013,7 +9153,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9013
9153
|
// Using a BaseUpgradableConstructor superclass here is a perf optimization to avoid
|
9014
9154
|
// re-defining the same logic (connectedCallback, disconnectedCallback, etc.) over and over.
|
9015
9155
|
class UpgradableConstructor extends BaseUpgradableConstructor {
|
9016
|
-
/*LWC compiler v6.
|
9156
|
+
/*LWC compiler v6.6.1*/
|
9017
9157
|
}
|
9018
9158
|
if (isFormAssociated) {
|
9019
9159
|
// Perf optimization - the vast majority of components have formAssociated=false,
|
@@ -9136,7 +9276,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9136
9276
|
function isNull(obj) {
|
9137
9277
|
return obj === null;
|
9138
9278
|
}
|
9139
|
-
/** version: 6.
|
9279
|
+
/** version: 6.6.1 */
|
9140
9280
|
|
9141
9281
|
/*
|
9142
9282
|
* Copyright (c) 2023, salesforce.com, inc.
|
@@ -9156,7 +9296,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9156
9296
|
this.setNewContext = setNewContext;
|
9157
9297
|
this.setDisconnectedCallback = setDisconnectedCallback;
|
9158
9298
|
}
|
9159
|
-
/*LWC compiler v6.
|
9299
|
+
/*LWC compiler v6.6.1*/
|
9160
9300
|
}
|
9161
9301
|
function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
|
9162
9302
|
dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
|
@@ -9211,6 +9351,9 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9211
9351
|
function previousSibling(node) {
|
9212
9352
|
return node.previousSibling;
|
9213
9353
|
}
|
9354
|
+
function getParentNode(node) {
|
9355
|
+
return node.parentNode;
|
9356
|
+
}
|
9214
9357
|
function attachShadow(element, options) {
|
9215
9358
|
// `shadowRoot` will be non-null in two cases:
|
9216
9359
|
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
@@ -9335,6 +9478,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9335
9478
|
exports.getFirstElementChild = getFirstElementChild;
|
9336
9479
|
exports.getLastChild = getLastChild;
|
9337
9480
|
exports.getLastElementChild = getLastElementChild;
|
9481
|
+
exports.getParentNode = getParentNode;
|
9338
9482
|
exports.getProperty = getProperty;
|
9339
9483
|
exports.getTagName = getTagName;
|
9340
9484
|
exports.insert = insert;
|
@@ -9566,7 +9710,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9566
9710
|
formStateRestoreCallback(state, reason) {
|
9567
9711
|
runFormStateRestoreCallback(this, state, reason);
|
9568
9712
|
}
|
9569
|
-
/*LWC compiler v6.
|
9713
|
+
/*LWC compiler v6.6.1*/
|
9570
9714
|
}, _a.observedAttributes = observedAttributes,
|
9571
9715
|
// Note CustomElementConstructor is not upgraded by LWC and inherits directly from HTMLElement which means it calls the native
|
9572
9716
|
// attachInternals API.
|
@@ -9630,9 +9774,6 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9630
9774
|
}
|
9631
9775
|
});
|
9632
9776
|
}
|
9633
|
-
// For some reason, JSDOC says "options.is" is a syntax error. And we can't disable the rule using
|
9634
|
-
// `eslint-disable-next-line` because that gets included in the JSDOC, so we need this workaround.
|
9635
|
-
/* eslint-disable jsdoc/valid-types */
|
9636
9777
|
/**
|
9637
9778
|
* EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
|
9638
9779
|
* difference that in the options, you can pass the `is` property set to a Constructor instead of
|
@@ -9647,8 +9788,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9647
9788
|
* @example
|
9648
9789
|
* const el = createElement('x-foo', { is: FooCtor });
|
9649
9790
|
*/
|
9650
|
-
function createElement(
|
9651
|
-
sel, options) {
|
9791
|
+
function createElement(sel, options) {
|
9652
9792
|
if (!isObject(options) || isNull(options)) {
|
9653
9793
|
throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
|
9654
9794
|
}
|
@@ -9799,7 +9939,7 @@ LWR.define('lwc/v/6_5_2', ['exports'], (function (exports) { 'use strict';
|
|
9799
9939
|
});
|
9800
9940
|
});
|
9801
9941
|
}
|
9802
|
-
/** version: 6.
|
9942
|
+
/** version: 6.6.1 */
|
9803
9943
|
|
9804
9944
|
exports.LightningElement = LightningElement;
|
9805
9945
|
exports.__unstable__ProfilerControl = profilerControl;
|