@lwc/engine-core 2.37.3 → 2.38.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/engine-core.cjs.js +125 -122
- package/dist/engine-core.cjs.js.map +1 -0
- package/dist/engine-core.js +125 -122
- package/dist/engine-core.js.map +1 -0
- package/package.json +4 -4
- package/types/framework/base-lightning-element.d.ts +1 -1
- package/types/framework/main.d.ts +9 -9
- package/types/framework/renderer.d.ts +3 -0
- package/types/framework/wiring/context.d.ts +4 -0
- package/types/framework/wiring/index.d.ts +3 -0
- package/types/framework/wiring/types.d.ts +49 -0
- package/types/framework/wiring/wiring.d.ts +7 -0
- package/types/framework/context-provider.d.ts +0 -10
- package/types/framework/wiring.d.ts +0 -34
package/dist/engine-core.cjs.js
CHANGED
|
@@ -1801,6 +1801,14 @@ LightningElement.prototype = {
|
|
|
1801
1801
|
}
|
|
1802
1802
|
return renderer.getLastElementChild(vm.elm);
|
|
1803
1803
|
},
|
|
1804
|
+
get ownerDocument() {
|
|
1805
|
+
const vm = getAssociatedVM(this);
|
|
1806
|
+
const renderer = vm.renderer;
|
|
1807
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1808
|
+
warnIfInvokedDuringConstruction(vm, 'ownerDocument');
|
|
1809
|
+
}
|
|
1810
|
+
return renderer.ownerDocument(vm.elm);
|
|
1811
|
+
},
|
|
1804
1812
|
render() {
|
|
1805
1813
|
const vm = getAssociatedVM(this);
|
|
1806
1814
|
return vm.def.template;
|
|
@@ -1876,31 +1884,84 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1876
1884
|
}
|
|
1877
1885
|
|
|
1878
1886
|
/*
|
|
1879
|
-
* Copyright (c)
|
|
1887
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
1880
1888
|
* All rights reserved.
|
|
1881
1889
|
* SPDX-License-Identifier: MIT
|
|
1882
1890
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1883
1891
|
*/
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1892
|
+
const AdapterToTokenMap = new Map();
|
|
1893
|
+
function createContextProviderWithRegister(adapter, registerContextProvider) {
|
|
1894
|
+
let adapterContextToken = AdapterToTokenMap.get(adapter);
|
|
1895
|
+
if (!shared.isUndefined(adapterContextToken)) {
|
|
1896
|
+
throw new Error(`Adapter already has a context provider.`);
|
|
1897
|
+
}
|
|
1898
|
+
adapterContextToken = guid();
|
|
1899
|
+
AdapterToTokenMap.set(adapter, adapterContextToken);
|
|
1900
|
+
const providers = new WeakSet();
|
|
1901
|
+
return (elmOrComponent, options) => {
|
|
1902
|
+
if (providers.has(elmOrComponent)) {
|
|
1903
|
+
throw new Error(`Adapter was already installed on ${elmOrComponent}.`);
|
|
1904
|
+
}
|
|
1905
|
+
providers.add(elmOrComponent);
|
|
1906
|
+
const { consumerConnectedCallback, consumerDisconnectedCallback } = options;
|
|
1907
|
+
registerContextProvider(elmOrComponent, adapterContextToken, (subscriptionPayload) => {
|
|
1908
|
+
const { setNewContext, setDisconnectedCallback } = subscriptionPayload;
|
|
1909
|
+
const consumer = {
|
|
1910
|
+
provide(newContext) {
|
|
1911
|
+
setNewContext(newContext);
|
|
1912
|
+
},
|
|
1913
|
+
};
|
|
1914
|
+
const disconnectCallback = () => {
|
|
1915
|
+
if (!shared.isUndefined(consumerDisconnectedCallback)) {
|
|
1916
|
+
consumerDisconnectedCallback(consumer);
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
setDisconnectedCallback(disconnectCallback);
|
|
1920
|
+
consumerConnectedCallback(consumer);
|
|
1893
1921
|
});
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
1925
|
+
const { adapter } = wireDef;
|
|
1926
|
+
const adapterContextToken = AdapterToTokenMap.get(adapter);
|
|
1927
|
+
if (shared.isUndefined(adapterContextToken)) {
|
|
1928
|
+
return; // no provider found, nothing to be done
|
|
1929
|
+
}
|
|
1930
|
+
const { elm, context: { wiredConnecting, wiredDisconnecting }, renderer: { registerContextConsumer }, } = vm;
|
|
1931
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
1932
|
+
shared.ArrayPush.call(wiredConnecting, () => {
|
|
1933
|
+
// This will attempt to connect the current element with one of its anscestors
|
|
1934
|
+
// that can provide context for the given wire adapter. This relationship is
|
|
1935
|
+
// keyed on the secret & internal value of `adapterContextToken`, which is unique
|
|
1936
|
+
// to a given wire adapter.
|
|
1937
|
+
//
|
|
1938
|
+
// Depending on the runtime environment, this connection is made using either DOM
|
|
1939
|
+
// events (in the browser) or a custom traversal (on the server).
|
|
1940
|
+
registerContextConsumer(elm, adapterContextToken, {
|
|
1941
|
+
setNewContext(newContext) {
|
|
1942
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
1943
|
+
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
1944
|
+
callbackWhenContextIsReady(newContext);
|
|
1897
1945
|
},
|
|
1898
|
-
setDisconnectedCallback
|
|
1899
|
-
|
|
1946
|
+
setDisconnectedCallback(disconnectCallback) {
|
|
1947
|
+
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
1948
|
+
// the the element hosting the wire is disconnected
|
|
1949
|
+
shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
|
|
1900
1950
|
},
|
|
1901
1951
|
});
|
|
1902
|
-
}
|
|
1952
|
+
});
|
|
1903
1953
|
}
|
|
1954
|
+
|
|
1955
|
+
/*
|
|
1956
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
1957
|
+
* All rights reserved.
|
|
1958
|
+
* SPDX-License-Identifier: MIT
|
|
1959
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1960
|
+
*/
|
|
1961
|
+
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
1962
|
+
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
1963
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
1964
|
+
const WireMetaMap = new Map();
|
|
1904
1965
|
function createFieldDataCallback(vm, name) {
|
|
1905
1966
|
return (value) => {
|
|
1906
1967
|
updateComponentValue(vm, name, value);
|
|
@@ -1944,35 +2005,6 @@ function createConfigWatcher(component, configCallback, callbackWhenConfigIsRead
|
|
|
1944
2005
|
ro,
|
|
1945
2006
|
};
|
|
1946
2007
|
}
|
|
1947
|
-
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
1948
|
-
const { adapter } = wireDef;
|
|
1949
|
-
const adapterContextToken = getAdapterToken(adapter);
|
|
1950
|
-
if (shared.isUndefined(adapterContextToken)) {
|
|
1951
|
-
return; // no provider found, nothing to be done
|
|
1952
|
-
}
|
|
1953
|
-
const { elm, context: { wiredConnecting, wiredDisconnecting }, renderer: { dispatchEvent }, } = vm;
|
|
1954
|
-
// waiting for the component to be connected to formally request the context via the token
|
|
1955
|
-
shared.ArrayPush.call(wiredConnecting, () => {
|
|
1956
|
-
// This event is responsible for connecting the host element with another
|
|
1957
|
-
// element in the composed path that is providing contextual data. The provider
|
|
1958
|
-
// must be listening for a special dom event with the name corresponding to the value of
|
|
1959
|
-
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
1960
|
-
// guarantee that the linkage can be forged.
|
|
1961
|
-
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
1962
|
-
setNewContext(newContext) {
|
|
1963
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
1964
|
-
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
1965
|
-
callbackWhenContextIsReady(newContext);
|
|
1966
|
-
},
|
|
1967
|
-
setDisconnectedCallback(disconnectCallback) {
|
|
1968
|
-
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
1969
|
-
// the the element hosting the wire is disconnected
|
|
1970
|
-
shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
|
|
1971
|
-
},
|
|
1972
|
-
});
|
|
1973
|
-
dispatchEvent(elm, contextRegistrationEvent);
|
|
1974
|
-
});
|
|
1975
|
-
}
|
|
1976
2008
|
function createConnector(vm, name, wireDef) {
|
|
1977
2009
|
const { method, adapter, configCallback, dynamic } = wireDef;
|
|
1978
2010
|
let debugInfo;
|
|
@@ -2047,13 +2079,6 @@ function createConnector(vm, name, wireDef) {
|
|
|
2047
2079
|
resetConfigWatcher: () => ro.reset(),
|
|
2048
2080
|
};
|
|
2049
2081
|
}
|
|
2050
|
-
const AdapterToTokenMap = new Map();
|
|
2051
|
-
function getAdapterToken(adapter) {
|
|
2052
|
-
return AdapterToTokenMap.get(adapter);
|
|
2053
|
-
}
|
|
2054
|
-
function setAdapterToken(adapter, token) {
|
|
2055
|
-
AdapterToTokenMap.set(adapter, token);
|
|
2056
|
-
}
|
|
2057
2082
|
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2058
2083
|
// support for callable adapters
|
|
2059
2084
|
if (adapter.adapter) {
|
|
@@ -5782,17 +5807,30 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5782
5807
|
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
5783
5808
|
// children VNodes might not be representing the current state of the DOM.
|
|
5784
5809
|
function resetComponentRoot(vm) {
|
|
5785
|
-
|
|
5786
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
5787
|
-
const child = children[i];
|
|
5788
|
-
if (!shared.isNull(child) && !shared.isUndefined(child.elm)) {
|
|
5789
|
-
remove(child.elm, renderRoot);
|
|
5790
|
-
}
|
|
5791
|
-
}
|
|
5810
|
+
recursivelyRemoveChildren(vm.children, vm);
|
|
5792
5811
|
vm.children = EmptyArray;
|
|
5793
5812
|
runChildNodesDisconnectedCallback(vm);
|
|
5794
5813
|
vm.velements = EmptyArray;
|
|
5795
5814
|
}
|
|
5815
|
+
// Helper function to remove all children of the root node.
|
|
5816
|
+
// If the set of children includes VFragment nodes, we need to remove the children of those nodes too.
|
|
5817
|
+
// Since VFragments can contain other VFragments, we need to traverse the entire of tree of VFragments.
|
|
5818
|
+
// If the set contains no VFragment nodes, no traversal is needed.
|
|
5819
|
+
function recursivelyRemoveChildren(vnodes, vm) {
|
|
5820
|
+
const { renderRoot, renderer: { remove }, } = vm;
|
|
5821
|
+
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
5822
|
+
const vnode = vnodes[i];
|
|
5823
|
+
if (!shared.isNull(vnode)) {
|
|
5824
|
+
// VFragments are special; their .elm property does not point to the root element since they have no single root.
|
|
5825
|
+
if (isVFragment(vnode)) {
|
|
5826
|
+
recursivelyRemoveChildren(vnode.children, vm);
|
|
5827
|
+
}
|
|
5828
|
+
else if (!shared.isUndefined(vnode.elm)) {
|
|
5829
|
+
remove(vnode.elm, renderRoot);
|
|
5830
|
+
}
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5796
5834
|
function scheduleRehydration(vm) {
|
|
5797
5835
|
if (!process.env.IS_BROWSER || shared.isTrue(vm.isScheduled)) {
|
|
5798
5836
|
return;
|
|
@@ -5870,6 +5908,10 @@ function forceRehydration(vm) {
|
|
|
5870
5908
|
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
5871
5909
|
const getElementById = shared.globalThis[shared.KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
5872
5910
|
const querySelectorAll = shared.globalThis[shared.KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
5911
|
+
// This is a "handoff" from synthetic-shadow to engine-core – we want to clean up after ourselves
|
|
5912
|
+
// so nobody else can misuse these global APIs.
|
|
5913
|
+
delete shared.globalThis[shared.KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
5914
|
+
delete shared.globalThis[shared.KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
5873
5915
|
function isSyntheticShadowRootInstance(rootNode) {
|
|
5874
5916
|
return rootNode !== document && shared.isTrue(rootNode.synthetic);
|
|
5875
5917
|
}
|
|
@@ -6117,67 +6159,6 @@ if (process.env.IS_BROWSER) {
|
|
|
6117
6159
|
}
|
|
6118
6160
|
}
|
|
6119
6161
|
|
|
6120
|
-
/*
|
|
6121
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6122
|
-
* All rights reserved.
|
|
6123
|
-
* SPDX-License-Identifier: MIT
|
|
6124
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6125
|
-
*/
|
|
6126
|
-
// this is lwc internal implementation
|
|
6127
|
-
function createContextProvider(adapter) {
|
|
6128
|
-
let adapterContextToken = getAdapterToken(adapter);
|
|
6129
|
-
if (!shared.isUndefined(adapterContextToken)) {
|
|
6130
|
-
throw new Error(`Adapter already has a context provider.`);
|
|
6131
|
-
}
|
|
6132
|
-
adapterContextToken = guid();
|
|
6133
|
-
setAdapterToken(adapter, adapterContextToken);
|
|
6134
|
-
const providers = new WeakSet();
|
|
6135
|
-
return (elm, options) => {
|
|
6136
|
-
if (providers.has(elm)) {
|
|
6137
|
-
throw new Error(`Adapter was already installed on ${elm}.`);
|
|
6138
|
-
}
|
|
6139
|
-
providers.add(elm);
|
|
6140
|
-
const { consumerConnectedCallback, consumerDisconnectedCallback } = options;
|
|
6141
|
-
elm.addEventListener(adapterContextToken, ((evt) => {
|
|
6142
|
-
const { setNewContext, setDisconnectedCallback } = evt;
|
|
6143
|
-
const consumer = {
|
|
6144
|
-
provide(newContext) {
|
|
6145
|
-
setNewContext(newContext);
|
|
6146
|
-
},
|
|
6147
|
-
};
|
|
6148
|
-
const disconnectCallback = () => {
|
|
6149
|
-
if (!shared.isUndefined(consumerDisconnectedCallback)) {
|
|
6150
|
-
consumerDisconnectedCallback(consumer);
|
|
6151
|
-
}
|
|
6152
|
-
};
|
|
6153
|
-
setDisconnectedCallback(disconnectCallback);
|
|
6154
|
-
consumerConnectedCallback(consumer);
|
|
6155
|
-
evt.stopImmediatePropagation();
|
|
6156
|
-
}));
|
|
6157
|
-
};
|
|
6158
|
-
}
|
|
6159
|
-
|
|
6160
|
-
/*
|
|
6161
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6162
|
-
* All rights reserved.
|
|
6163
|
-
* SPDX-License-Identifier: MIT
|
|
6164
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6165
|
-
*/
|
|
6166
|
-
/**
|
|
6167
|
-
* EXPERIMENTAL: This function allows you to create a reactive readonly
|
|
6168
|
-
* membrane around any object value. This API is subject to change or
|
|
6169
|
-
* being removed.
|
|
6170
|
-
*/
|
|
6171
|
-
function readonly(obj) {
|
|
6172
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6173
|
-
// TODO [#1292]: Remove the readonly decorator
|
|
6174
|
-
if (arguments.length !== 1) {
|
|
6175
|
-
shared.assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
|
6176
|
-
}
|
|
6177
|
-
}
|
|
6178
|
-
return getReadOnlyProxy(obj);
|
|
6179
|
-
}
|
|
6180
|
-
|
|
6181
6162
|
/*
|
|
6182
6163
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
6183
6164
|
* All rights reserved.
|
|
@@ -6868,6 +6849,27 @@ function getComponentConstructor(elm) {
|
|
|
6868
6849
|
return ctor;
|
|
6869
6850
|
}
|
|
6870
6851
|
|
|
6852
|
+
/*
|
|
6853
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6854
|
+
* All rights reserved.
|
|
6855
|
+
* SPDX-License-Identifier: MIT
|
|
6856
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6857
|
+
*/
|
|
6858
|
+
/**
|
|
6859
|
+
* EXPERIMENTAL: This function allows you to create a reactive readonly
|
|
6860
|
+
* membrane around any object value. This API is subject to change or
|
|
6861
|
+
* being removed.
|
|
6862
|
+
*/
|
|
6863
|
+
function readonly(obj) {
|
|
6864
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6865
|
+
// TODO [#1292]: Remove the readonly decorator
|
|
6866
|
+
if (arguments.length !== 1) {
|
|
6867
|
+
shared.assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
|
6868
|
+
}
|
|
6869
|
+
}
|
|
6870
|
+
return getReadOnlyProxy(obj);
|
|
6871
|
+
}
|
|
6872
|
+
|
|
6871
6873
|
Object.defineProperty(exports, 'setFeatureFlag', {
|
|
6872
6874
|
enumerable: true,
|
|
6873
6875
|
get: function () { return features.setFeatureFlag; }
|
|
@@ -6881,7 +6883,7 @@ exports.__unstable__ProfilerControl = profilerControl;
|
|
|
6881
6883
|
exports.__unstable__ReportingControl = reportingControl;
|
|
6882
6884
|
exports.api = api$1;
|
|
6883
6885
|
exports.connectRootElement = connectRootElement;
|
|
6884
|
-
exports.
|
|
6886
|
+
exports.createContextProviderWithRegister = createContextProviderWithRegister;
|
|
6885
6887
|
exports.createVM = createVM;
|
|
6886
6888
|
exports.disconnectRootElement = disconnectRootElement;
|
|
6887
6889
|
exports.freezeTemplate = freezeTemplate;
|
|
@@ -6906,4 +6908,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
6906
6908
|
exports.track = track;
|
|
6907
6909
|
exports.unwrap = unwrap;
|
|
6908
6910
|
exports.wire = wire;
|
|
6909
|
-
/* version: 2.
|
|
6911
|
+
/* version: 2.38.1 */
|
|
6912
|
+
//# sourceMappingURL=engine-core.cjs.js.map
|