@lwc/engine-core 3.1.3 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -5
- package/dist/framework/base-lightning-element.d.ts +1 -1
- package/dist/framework/main.d.ts +1 -2
- package/dist/framework/renderer.d.ts +1 -0
- package/dist/framework/vm.d.ts +4 -0
- package/dist/index.cjs.js +49 -64
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +50 -65
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/framework/services.d.ts +0 -22
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
3
3
|
*/
|
|
4
|
-
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, globalThis as globalThis$1, forEach, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1,
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, globalThis as globalThis$1, forEach, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, isFalse, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, ArrayUnshift, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
|
|
5
5
|
import { applyAriaReflection } from '@lwc/aria-reflection';
|
|
6
6
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
7
7
|
|
|
@@ -1454,6 +1454,7 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
|
1454
1454
|
logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
|
+
const supportsElementInternals = typeof ElementInternals !== 'undefined';
|
|
1457
1458
|
// @ts-ignore
|
|
1458
1459
|
LightningElement.prototype = {
|
|
1459
1460
|
constructor: LightningElement,
|
|
@@ -1545,6 +1546,18 @@ LightningElement.prototype = {
|
|
|
1545
1546
|
}
|
|
1546
1547
|
return getBoundingClientRect(elm);
|
|
1547
1548
|
},
|
|
1549
|
+
attachInternals() {
|
|
1550
|
+
const vm = getAssociatedVM(this);
|
|
1551
|
+
const { elm, renderer: { attachInternals }, } = vm;
|
|
1552
|
+
if (isFalse(supportsElementInternals)) {
|
|
1553
|
+
// Browsers that don't support attachInternals will need to be polyfilled before LWC is loaded.
|
|
1554
|
+
throw new Error('attachInternals API is not supported in this browser environment.');
|
|
1555
|
+
}
|
|
1556
|
+
if (vm.renderMode === 0 /* RenderMode.Light */ || vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
1557
|
+
throw new Error('attachInternals API is not supported in light DOM or synthetic shadow.');
|
|
1558
|
+
}
|
|
1559
|
+
return attachInternals(elm);
|
|
1560
|
+
},
|
|
1548
1561
|
get isConnected() {
|
|
1549
1562
|
const vm = getAssociatedVM(this);
|
|
1550
1563
|
const { elm, renderer: { isConnected }, } = vm;
|
|
@@ -2586,6 +2599,14 @@ function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
|
2586
2599
|
descriptors.attributeChangedCallback = {
|
|
2587
2600
|
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback),
|
|
2588
2601
|
};
|
|
2602
|
+
// To avoid leaking private component details, accessing internals from outside a component is not allowed.
|
|
2603
|
+
descriptors.attachInternals = {
|
|
2604
|
+
get() {
|
|
2605
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2606
|
+
logError('attachInternals cannot be accessed outside of a component. Use this.attachInternals instead.');
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
};
|
|
2589
2610
|
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
2590
2611
|
// properties via attributeChangedCallback.
|
|
2591
2612
|
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
@@ -5311,44 +5332,6 @@ function getWrappedComponentsListener(vm, listener) {
|
|
|
5311
5332
|
return wrappedListener;
|
|
5312
5333
|
}
|
|
5313
5334
|
|
|
5314
|
-
/*
|
|
5315
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
5316
|
-
* All rights reserved.
|
|
5317
|
-
* SPDX-License-Identifier: MIT
|
|
5318
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5319
|
-
*/
|
|
5320
|
-
const Services = create(null);
|
|
5321
|
-
const hooks = ['rendered', 'connected', 'disconnected'];
|
|
5322
|
-
/**
|
|
5323
|
-
* EXPERIMENTAL: This function allows for the registration of "services"
|
|
5324
|
-
* in LWC by exposing hooks into the component life-cycle. This API is
|
|
5325
|
-
* subject to change or being removed.
|
|
5326
|
-
*/
|
|
5327
|
-
function register(service) {
|
|
5328
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5329
|
-
assert.isTrue(isObject(service), `Invalid service declaration, ${service}: service must be an object`);
|
|
5330
|
-
}
|
|
5331
|
-
for (let i = 0; i < hooks.length; ++i) {
|
|
5332
|
-
const hookName = hooks[i];
|
|
5333
|
-
if (hookName in service) {
|
|
5334
|
-
let l = Services[hookName];
|
|
5335
|
-
if (isUndefined$1(l)) {
|
|
5336
|
-
Services[hookName] = l = [];
|
|
5337
|
-
}
|
|
5338
|
-
ArrayPush$1.call(l, service[hookName]);
|
|
5339
|
-
}
|
|
5340
|
-
}
|
|
5341
|
-
}
|
|
5342
|
-
function invokeServiceHook(vm, cbs) {
|
|
5343
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5344
|
-
assert.isTrue(isArray$1(cbs) && cbs.length > 0, `Optimize invokeServiceHook() to be invoked only when needed`);
|
|
5345
|
-
}
|
|
5346
|
-
const { component, def, context } = vm;
|
|
5347
|
-
for (let i = 0, len = cbs.length; i < len; ++i) {
|
|
5348
|
-
cbs[i].call(undefined, component, {}, def, context);
|
|
5349
|
-
}
|
|
5350
|
-
}
|
|
5351
|
-
|
|
5352
5335
|
/*
|
|
5353
5336
|
* Copyright (c) 2023, Salesforce.com, inc.
|
|
5354
5337
|
* All rights reserved.
|
|
@@ -5407,12 +5390,18 @@ function resetComponentStateWhenRemoved(vm) {
|
|
|
5407
5390
|
// old vnode.children is removed from the DOM.
|
|
5408
5391
|
function removeVM(vm) {
|
|
5409
5392
|
if (process.env.NODE_ENV !== 'production') {
|
|
5410
|
-
|
|
5393
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
5394
|
+
// With native lifecycle, we cannot be certain that connectedCallback was called before a component
|
|
5395
|
+
// was removed from the VDOM. If the component is disconnected, then connectedCallback will not fire
|
|
5396
|
+
// in native mode, although it will fire in synthetic mode due to appendChild triggering it.
|
|
5397
|
+
// See: W-14037619 for details
|
|
5398
|
+
assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
|
|
5399
|
+
}
|
|
5411
5400
|
}
|
|
5412
5401
|
resetComponentStateWhenRemoved(vm);
|
|
5413
5402
|
}
|
|
5414
|
-
function getNearestShadowAncestor(
|
|
5415
|
-
let ancestor =
|
|
5403
|
+
function getNearestShadowAncestor(owner) {
|
|
5404
|
+
let ancestor = owner;
|
|
5416
5405
|
while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5417
5406
|
ancestor = ancestor.owner;
|
|
5418
5407
|
}
|
|
@@ -5468,15 +5457,12 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5468
5457
|
vm.debugInfo = create(null);
|
|
5469
5458
|
}
|
|
5470
5459
|
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5471
|
-
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5460
|
+
vm.shadowMode = computeShadowMode(def, vm.owner, renderer);
|
|
5472
5461
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5473
5462
|
if (process.env.NODE_ENV !== 'production') {
|
|
5474
5463
|
vm.toString = () => {
|
|
5475
5464
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5476
5465
|
};
|
|
5477
|
-
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5478
|
-
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5479
|
-
}
|
|
5480
5466
|
}
|
|
5481
5467
|
// Create component instance associated to the vm and the element.
|
|
5482
5468
|
invokeComponentConstructor(vm, def.ctor);
|
|
@@ -5539,8 +5525,21 @@ function warnOnStylesheetsMutation(ctor) {
|
|
|
5539
5525
|
});
|
|
5540
5526
|
}
|
|
5541
5527
|
}
|
|
5542
|
-
|
|
5543
|
-
|
|
5528
|
+
// Compute the shadowMode/renderMode without creating a VM. This is used in some scenarios like hydration.
|
|
5529
|
+
function computeShadowAndRenderMode(Ctor, renderer) {
|
|
5530
|
+
const def = getComponentInternalDef(Ctor);
|
|
5531
|
+
const { renderMode } = def;
|
|
5532
|
+
// Assume null `owner` - this is what happens in hydration cases anyway
|
|
5533
|
+
const shadowMode = computeShadowMode(def, /* owner */ null, renderer);
|
|
5534
|
+
return { renderMode, shadowMode };
|
|
5535
|
+
}
|
|
5536
|
+
function computeShadowMode(def, owner, renderer) {
|
|
5537
|
+
// Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
|
|
5538
|
+
// on, but components running in actual native shadow mode
|
|
5539
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
5540
|
+
lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5541
|
+
return 0 /* ShadowMode.Native */;
|
|
5542
|
+
}
|
|
5544
5543
|
const { isSyntheticShadowDefined } = renderer;
|
|
5545
5544
|
let shadowMode;
|
|
5546
5545
|
if (isSyntheticShadowDefined) {
|
|
@@ -5554,7 +5553,7 @@ function computeShadowMode(vm, renderer) {
|
|
|
5554
5553
|
shadowMode = 0 /* ShadowMode.Native */;
|
|
5555
5554
|
}
|
|
5556
5555
|
else {
|
|
5557
|
-
const shadowAncestor = getNearestShadowAncestor(
|
|
5556
|
+
const shadowAncestor = getNearestShadowAncestor(owner);
|
|
5558
5557
|
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5559
5558
|
// Transitive support for native Shadow DOM. A component in native mode
|
|
5560
5559
|
// transitively opts all of its descendants into native.
|
|
@@ -5640,10 +5639,6 @@ function runRenderedCallback(vm) {
|
|
|
5640
5639
|
if (!process.env.IS_BROWSER) {
|
|
5641
5640
|
return;
|
|
5642
5641
|
}
|
|
5643
|
-
const { rendered } = Services;
|
|
5644
|
-
if (rendered) {
|
|
5645
|
-
invokeServiceHook(vm, rendered);
|
|
5646
|
-
}
|
|
5647
5642
|
if (!isUndefined$1(renderedCallback)) {
|
|
5648
5643
|
logOperationStart(4 /* OperationId.RenderedCallback */, vm);
|
|
5649
5644
|
invokeComponentCallback(vm, renderedCallback);
|
|
@@ -5686,11 +5681,6 @@ function runConnectedCallback(vm) {
|
|
|
5686
5681
|
return; // nothing to do since it was already connected
|
|
5687
5682
|
}
|
|
5688
5683
|
vm.state = 1 /* VMState.connected */;
|
|
5689
|
-
// reporting connection
|
|
5690
|
-
const { connected } = Services;
|
|
5691
|
-
if (connected) {
|
|
5692
|
-
invokeServiceHook(vm, connected);
|
|
5693
|
-
}
|
|
5694
5684
|
if (hasWireAdapters(vm)) {
|
|
5695
5685
|
connectWireAdapters(vm);
|
|
5696
5686
|
}
|
|
@@ -5716,11 +5706,6 @@ function runDisconnectedCallback(vm) {
|
|
|
5716
5706
|
vm.isDirty = true;
|
|
5717
5707
|
}
|
|
5718
5708
|
vm.state = 2 /* VMState.disconnected */;
|
|
5719
|
-
// reporting disconnection
|
|
5720
|
-
const { disconnected } = Services;
|
|
5721
|
-
if (disconnected) {
|
|
5722
|
-
invokeServiceHook(vm, disconnected);
|
|
5723
|
-
}
|
|
5724
5709
|
if (hasWireAdapters(vm)) {
|
|
5725
5710
|
disconnectWireAdapters(vm);
|
|
5726
5711
|
}
|
|
@@ -6878,6 +6863,6 @@ function readonly(obj) {
|
|
|
6878
6863
|
return getReadOnlyProxy(obj);
|
|
6879
6864
|
}
|
|
6880
6865
|
|
|
6881
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly,
|
|
6882
|
-
/** version: 3.
|
|
6866
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6867
|
+
/** version: 3.3.0 */
|
|
6883
6868
|
//# sourceMappingURL=index.js.map
|