@lwc/engine-core 6.0.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/framework/utils.d.ts +20 -0
- package/dist/index.cjs.js +60 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +61 -36
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StylesheetFactory, TemplateStylesheetFactories } from './stylesheet';
|
|
2
2
|
import { LightningElementConstructor } from './base-lightning-element';
|
|
3
|
+
import { VElementData } from './vnodes';
|
|
3
4
|
type Callback = () => void;
|
|
4
5
|
export declare const SPACE_CHAR = 32;
|
|
5
6
|
export declare const EmptyObject: any;
|
|
@@ -17,4 +18,23 @@ export declare function cloneAndOmitKey(object: {
|
|
|
17
18
|
};
|
|
18
19
|
export declare function flattenStylesheets(stylesheets: TemplateStylesheetFactories): StylesheetFactory[];
|
|
19
20
|
export declare function assertNotProd(): void;
|
|
21
|
+
export declare function applyTemporaryCompilerV5SlotFix(data: VElementData): VElementData | {
|
|
22
|
+
attrs: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
slotAssignment: string;
|
|
26
|
+
key: import("./vnodes").Key;
|
|
27
|
+
external?: boolean | undefined;
|
|
28
|
+
ref?: string | undefined;
|
|
29
|
+
slotData?: any;
|
|
30
|
+
props?: Readonly<Record<string, any>> | undefined;
|
|
31
|
+
className?: string | undefined;
|
|
32
|
+
style?: string | undefined;
|
|
33
|
+
classMap?: Readonly<Record<string, boolean>> | undefined;
|
|
34
|
+
styleDecls?: readonly [string, string, boolean][] | undefined;
|
|
35
|
+
context?: Readonly<Record<string, Readonly<Record<string, any>>>> | undefined;
|
|
36
|
+
on?: Readonly<Record<string, (event: Event) => any>> | undefined;
|
|
37
|
+
svg?: boolean | undefined;
|
|
38
|
+
renderer?: import("./renderer").RendererAPI | undefined;
|
|
39
|
+
};
|
|
20
40
|
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (
|
|
2
|
+
* Copyright (c) 2024 Salesforce, Inc.
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -413,6 +413,25 @@ function assertNotProd() {
|
|
|
413
413
|
throw new ReferenceError();
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
+
// Temporary fix for when the LWC v5 compiler is used in conjunction with a v6+ engine
|
|
417
|
+
// The old compiler format used the "slot" attribute in the `data` bag, whereas the new
|
|
418
|
+
// format uses the special `slotAssignment` key.
|
|
419
|
+
// This should be removed when the LWC v5 compiler is not used anywhere where it could be mismatched
|
|
420
|
+
// with another LWC engine version.
|
|
421
|
+
// TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
|
|
422
|
+
function applyTemporaryCompilerV5SlotFix(data) {
|
|
423
|
+
if (lwcRuntimeFlags.DISABLE_TEMPORARY_V5_COMPILER_SUPPORT) {
|
|
424
|
+
return data;
|
|
425
|
+
}
|
|
426
|
+
const { attrs } = data;
|
|
427
|
+
if (!shared.isUndefined(attrs)) {
|
|
428
|
+
const { slot } = attrs;
|
|
429
|
+
if (!shared.isUndefined(slot) && !shared.isNull(slot)) {
|
|
430
|
+
return Object.assign(Object.assign({}, data), { attrs: cloneAndOmitKey(attrs, 'slot'), slotAssignment: String(slot) });
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return data;
|
|
434
|
+
}
|
|
416
435
|
|
|
417
436
|
/*
|
|
418
437
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -429,8 +448,8 @@ function isCircularModuleDependency(obj) {
|
|
|
429
448
|
}
|
|
430
449
|
|
|
431
450
|
var _a, _b;
|
|
432
|
-
const instrumentDef = (_a =
|
|
433
|
-
const instrumentInstance = (_b =
|
|
451
|
+
const instrumentDef = (_a = globalThis.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : shared.noop;
|
|
452
|
+
const instrumentInstance = (_b = globalThis.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : shared.noop;
|
|
434
453
|
|
|
435
454
|
/*
|
|
436
455
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3152,6 +3171,10 @@ function createComponentDef(Ctor) {
|
|
|
3152
3171
|
ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
|
|
3153
3172
|
logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
3154
3173
|
}
|
|
3174
|
+
// TODO [#3971]: Completely remove shadowSupportMode "any"
|
|
3175
|
+
if (ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
3176
|
+
logWarn(`Invalid value 'any' for static property shadowSupportMode. 'any' is deprecated and will be removed in a future release--use 'native' instead.`);
|
|
3177
|
+
}
|
|
3155
3178
|
if (!shared.isUndefined(ctorRenderMode) &&
|
|
3156
3179
|
ctorRenderMode !== 'light' &&
|
|
3157
3180
|
ctorRenderMode !== 'shadow') {
|
|
@@ -4820,6 +4843,8 @@ function h(sel, data, children = EmptyArray) {
|
|
|
4820
4843
|
}
|
|
4821
4844
|
});
|
|
4822
4845
|
}
|
|
4846
|
+
// TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
|
|
4847
|
+
data = applyTemporaryCompilerV5SlotFix(data);
|
|
4823
4848
|
const { key, slotAssignment } = data;
|
|
4824
4849
|
const vnode = {
|
|
4825
4850
|
type: 2 /* VNodeType.Element */,
|
|
@@ -4856,6 +4881,8 @@ function s(slotName, data, children, slotset) {
|
|
|
4856
4881
|
}
|
|
4857
4882
|
const vmBeingRendered = getVMBeingRendered();
|
|
4858
4883
|
const { renderMode, apiVersion } = vmBeingRendered;
|
|
4884
|
+
// TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
|
|
4885
|
+
data = applyTemporaryCompilerV5SlotFix(data);
|
|
4859
4886
|
if (!shared.isUndefined(slotset) &&
|
|
4860
4887
|
!shared.isUndefined(slotset.slotAssignments) &&
|
|
4861
4888
|
!shared.isUndefined(slotset.slotAssignments[slotName]) &&
|
|
@@ -4959,6 +4986,8 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4959
4986
|
});
|
|
4960
4987
|
}
|
|
4961
4988
|
}
|
|
4989
|
+
// TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
|
|
4990
|
+
data = applyTemporaryCompilerV5SlotFix(data);
|
|
4962
4991
|
const { key, slotAssignment } = data;
|
|
4963
4992
|
let elm, aChildren, vm;
|
|
4964
4993
|
const vnode = {
|
|
@@ -5483,7 +5512,6 @@ const parseSVGFragment = buildParseFragmentFn((html, renderer) => {
|
|
|
5483
5512
|
});
|
|
5484
5513
|
function evaluateTemplate(vm, html) {
|
|
5485
5514
|
if (process.env.NODE_ENV !== 'production') {
|
|
5486
|
-
shared.assert.isTrue(shared.isFunction(html), `evaluateTemplate() second argument must be an imported template instead of ${shared.toString(html)}`);
|
|
5487
5515
|
// in dev-mode, we support hot swapping of templates, which means that
|
|
5488
5516
|
// the component instance might be attempting to use an old version of
|
|
5489
5517
|
// the template, while internally, we have a replacement for it.
|
|
@@ -5502,6 +5530,10 @@ function evaluateTemplate(vm, html) {
|
|
|
5502
5530
|
tro.observe(() => {
|
|
5503
5531
|
// Reset the cache memoizer for template when needed.
|
|
5504
5532
|
if (html !== cmpTemplate) {
|
|
5533
|
+
// Check that the template was built by the compiler.
|
|
5534
|
+
if (!isTemplateRegistered(html)) {
|
|
5535
|
+
throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${shared.toString(html)}.`);
|
|
5536
|
+
}
|
|
5505
5537
|
if (process.env.NODE_ENV !== 'production') {
|
|
5506
5538
|
validateLightDomTemplate(html, vm);
|
|
5507
5539
|
}
|
|
@@ -5513,10 +5545,6 @@ function evaluateTemplate(vm, html) {
|
|
|
5513
5545
|
// and snabbdom just rely on the IDs.
|
|
5514
5546
|
resetComponentRoot(vm);
|
|
5515
5547
|
}
|
|
5516
|
-
// Check that the template was built by the compiler.
|
|
5517
|
-
if (!isTemplateRegistered(html)) {
|
|
5518
|
-
throw new TypeError(`Invalid template returned by the render() method on ${vm}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${shared.toString(html)}.`);
|
|
5519
|
-
}
|
|
5520
5548
|
vm.cmpTemplate = html;
|
|
5521
5549
|
// Create a brand new template cache for the swapped templated.
|
|
5522
5550
|
context.tplCache = shared.create(null);
|
|
@@ -5891,7 +5919,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5891
5919
|
vm.debugInfo = shared.create(null);
|
|
5892
5920
|
}
|
|
5893
5921
|
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5894
|
-
const computedShadowMode = computeShadowMode(def, vm.owner, renderer);
|
|
5922
|
+
const computedShadowMode = computeShadowMode(def, vm.owner, renderer, hydrated);
|
|
5895
5923
|
if (lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
|
|
5896
5924
|
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5897
5925
|
vm.shadowMigrateMode = computedShadowMode === 1 /* ShadowMode.Synthetic */;
|
|
@@ -5978,48 +6006,45 @@ function computeShadowAndRenderMode(Ctor, renderer) {
|
|
|
5978
6006
|
const def = getComponentInternalDef(Ctor);
|
|
5979
6007
|
const { renderMode } = def;
|
|
5980
6008
|
// Assume null `owner` - this is what happens in hydration cases anyway
|
|
5981
|
-
|
|
6009
|
+
// Also assume we are not in hydration mode for this exported API
|
|
6010
|
+
const shadowMode = computeShadowMode(def, /* owner */ null, renderer, false);
|
|
5982
6011
|
return { renderMode, shadowMode };
|
|
5983
6012
|
}
|
|
5984
|
-
function computeShadowMode(def, owner, renderer) {
|
|
6013
|
+
function computeShadowMode(def, owner, renderer, hydrated) {
|
|
5985
6014
|
// Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
|
|
5986
6015
|
// on, but components running in actual native shadow mode
|
|
5987
6016
|
if (process.env.NODE_ENV !== 'production' &&
|
|
5988
6017
|
lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5989
6018
|
return 0 /* ShadowMode.Native */;
|
|
5990
6019
|
}
|
|
6020
|
+
if (shared.isTrue(hydrated)) {
|
|
6021
|
+
// hydration only supports native shadow
|
|
6022
|
+
return 0 /* ShadowMode.Native */;
|
|
6023
|
+
}
|
|
5991
6024
|
const { isSyntheticShadowDefined } = renderer;
|
|
5992
6025
|
let shadowMode;
|
|
5993
|
-
// If ENABLE_FORCE_SHADOW_MIGRATE_MODE is true, then ShadowMode.Synthetic here will mean "force-migrate" mode.
|
|
5994
6026
|
if (isSyntheticShadowDefined || lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
|
|
5995
6027
|
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
5996
6028
|
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
5997
6029
|
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
5998
6030
|
shadowMode = 0 /* ShadowMode.Native */;
|
|
5999
6031
|
}
|
|
6000
|
-
else if (
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6032
|
+
else if (def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
|
|
6033
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
6034
|
+
}
|
|
6035
|
+
else {
|
|
6036
|
+
const shadowAncestor = getNearestShadowAncestor(owner);
|
|
6037
|
+
if (!shared.isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
6038
|
+
// Transitive support for native Shadow DOM. A component in native mode
|
|
6039
|
+
// transitively opts all of its descendants into native.
|
|
6004
6040
|
shadowMode = 0 /* ShadowMode.Native */;
|
|
6005
6041
|
}
|
|
6006
6042
|
else {
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
// transitively opts all of its descendants into native.
|
|
6011
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
6012
|
-
}
|
|
6013
|
-
else {
|
|
6014
|
-
// Synthetic if neither this component nor any of its ancestors are configured
|
|
6015
|
-
// to be native.
|
|
6016
|
-
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
6017
|
-
}
|
|
6043
|
+
// Synthetic if neither this component nor any of its ancestors are configured
|
|
6044
|
+
// to be native.
|
|
6045
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
6018
6046
|
}
|
|
6019
6047
|
}
|
|
6020
|
-
else {
|
|
6021
|
-
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
6022
|
-
}
|
|
6023
6048
|
}
|
|
6024
6049
|
else {
|
|
6025
6050
|
// Native if the synthetic shadow polyfill is unavailable.
|
|
@@ -6394,12 +6419,12 @@ function resetRefVNodes(vm) {
|
|
|
6394
6419
|
// See: https://sfdc.co/synthetic-aria
|
|
6395
6420
|
//
|
|
6396
6421
|
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
6397
|
-
const getElementById =
|
|
6398
|
-
const querySelectorAll =
|
|
6422
|
+
const getElementById = globalThis[shared.KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
6423
|
+
const querySelectorAll = globalThis[shared.KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
6399
6424
|
// This is a "handoff" from synthetic-shadow to engine-core – we want to clean up after ourselves
|
|
6400
6425
|
// so nobody else can misuse these global APIs.
|
|
6401
|
-
delete
|
|
6402
|
-
delete
|
|
6426
|
+
delete globalThis[shared.KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
6427
|
+
delete globalThis[shared.KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
6403
6428
|
function isSyntheticShadowRootInstance(rootNode) {
|
|
6404
6429
|
return rootNode !== document && shared.isTrue(rootNode.synthetic);
|
|
6405
6430
|
}
|
|
@@ -7450,5 +7475,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
7450
7475
|
exports.track = track;
|
|
7451
7476
|
exports.unwrap = unwrap;
|
|
7452
7477
|
exports.wire = wire;
|
|
7453
|
-
/** version: 6.
|
|
7478
|
+
/** version: 6.1.1 */
|
|
7454
7479
|
//# sourceMappingURL=index.cjs.js.map
|