@lwc/engine-core 2.33.0 → 2.35.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.
@@ -34,94 +34,167 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
34
34
  * SPDX-License-Identifier: MIT
35
35
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
36
36
  */
37
- let nextTickCallbackQueue = [];
38
- const SPACE_CHAR = 32;
39
- const EmptyObject = shared.seal(shared.create(null));
40
- const EmptyArray = shared.seal([]);
41
- function flushCallbackQueue() {
42
- if (process.env.NODE_ENV !== 'production') {
43
- if (nextTickCallbackQueue.length === 0) {
44
- throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
37
+ /** Callbacks to invoke when reporting is enabled **/
38
+ const onReportingEnabledCallbacks = [];
39
+ /** The currently assigned reporting dispatcher. */
40
+ let currentDispatcher$1 = shared.noop;
41
+ /**
42
+ * Whether reporting is enabled.
43
+ *
44
+ * Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
45
+ * but it turns out that Terser only strips out unused code if we use this explicit boolean.
46
+ */
47
+ let enabled$1 = false;
48
+ const reportingControl = {
49
+ /**
50
+ * Attach a new reporting control (aka dispatcher).
51
+ *
52
+ * @param dispatcher - reporting control
53
+ */
54
+ attachDispatcher(dispatcher) {
55
+ enabled$1 = true;
56
+ currentDispatcher$1 = dispatcher;
57
+ for (const callback of onReportingEnabledCallbacks) {
58
+ try {
59
+ callback();
60
+ }
61
+ catch (err) {
62
+ // This should never happen. But if it does, we don't want one callback to cause another to fail
63
+ // eslint-disable-next-line no-console
64
+ console.error('Could not invoke callback', err);
65
+ }
45
66
  }
67
+ onReportingEnabledCallbacks.length = 0; // clear the array
68
+ },
69
+ /**
70
+ * Detach the current reporting control (aka dispatcher).
71
+ */
72
+ detachDispatcher() {
73
+ enabled$1 = false;
74
+ currentDispatcher$1 = shared.noop;
75
+ },
76
+ };
77
+ /**
78
+ * Call a callback when reporting is enabled, or immediately if reporting is already enabled.
79
+ * Will only ever be called once.
80
+ * @param callback
81
+ */
82
+ function onReportingEnabled(callback) {
83
+ if (enabled$1) {
84
+ // call immediately
85
+ callback();
46
86
  }
47
- const callbacks = nextTickCallbackQueue;
48
- nextTickCallbackQueue = []; // reset to a new queue
49
- for (let i = 0, len = callbacks.length; i < len; i += 1) {
50
- callbacks[i]();
87
+ else {
88
+ // call later
89
+ onReportingEnabledCallbacks.push(callback);
51
90
  }
52
91
  }
53
- function addCallbackToNextTick(callback) {
54
- if (process.env.NODE_ENV !== 'production') {
55
- if (!shared.isFunction(callback)) {
56
- throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
57
- }
58
- }
59
- if (nextTickCallbackQueue.length === 0) {
60
- Promise.resolve().then(flushCallbackQueue);
92
+ /**
93
+ * Report to the current dispatcher, if there is one.
94
+ * @param reportingEventId
95
+ * @param vm
96
+ */
97
+ function report(reportingEventId, vm) {
98
+ if (enabled$1) {
99
+ currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
61
100
  }
62
- shared.ArrayPush.call(nextTickCallbackQueue, callback);
63
101
  }
64
- function guid() {
65
- function s4() {
66
- return Math.floor((1 + Math.random()) * 0x10000)
67
- .toString(16)
68
- .substring(1);
102
+
103
+ /*
104
+ * Copyright (c) 2018, salesforce.com, inc.
105
+ * All rights reserved.
106
+ * SPDX-License-Identifier: MIT
107
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
108
+ */
109
+ function getComponentTag(vm) {
110
+ return `<${shared.StringToLowerCase.call(vm.tagName)}>`;
111
+ }
112
+ // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
113
+ function getComponentStack(vm) {
114
+ const stack = [];
115
+ let prefix = '';
116
+ while (!shared.isNull(vm.owner)) {
117
+ shared.ArrayPush.call(stack, prefix + getComponentTag(vm));
118
+ vm = vm.owner;
119
+ prefix += '\t';
69
120
  }
70
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
121
+ return shared.ArrayJoin.call(stack, '\n');
71
122
  }
72
- // Borrowed from Vue template compiler.
73
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
74
- const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
75
- const PROPERTY_DELIMITER = /:(.+)/;
76
- function parseStyleText(cssText) {
77
- const styleMap = {};
78
- const declarations = cssText.split(DECLARATION_DELIMITER);
79
- for (const declaration of declarations) {
80
- if (declaration) {
81
- const [prop, value] = declaration.split(PROPERTY_DELIMITER);
82
- if (prop !== undefined && value !== undefined) {
83
- styleMap[prop.trim()] = value.trim();
84
- }
85
- }
123
+ function getErrorComponentStack(vm) {
124
+ const wcStack = [];
125
+ let currentVm = vm;
126
+ while (!shared.isNull(currentVm)) {
127
+ shared.ArrayPush.call(wcStack, getComponentTag(currentVm));
128
+ currentVm = currentVm.owner;
86
129
  }
87
- return styleMap;
130
+ return wcStack.reverse().join('\n\t');
88
131
  }
89
- // Make a shallow copy of an object but omit the given key
90
- function cloneAndOmitKey(object, keyToOmit) {
91
- const result = {};
92
- for (const key of Object.keys(object)) {
93
- if (key !== keyToOmit) {
94
- result[key] = object[key];
95
- }
132
+
133
+ /*
134
+ * Copyright (c) 2018, salesforce.com, inc.
135
+ * All rights reserved.
136
+ * SPDX-License-Identifier: MIT
137
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
138
+ */
139
+ function addErrorComponentStack(vm, error) {
140
+ if (!shared.isFrozen(error) && shared.isUndefined(error.wcStack)) {
141
+ const wcStack = getErrorComponentStack(vm);
142
+ shared.defineProperty(error, 'wcStack', {
143
+ get() {
144
+ return wcStack;
145
+ },
146
+ });
96
147
  }
97
- return result;
98
148
  }
99
- function flattenStylesheets(stylesheets) {
100
- const list = [];
101
- for (const stylesheet of stylesheets) {
102
- if (!Array.isArray(stylesheet)) {
103
- list.push(stylesheet);
104
- }
105
- else {
106
- list.push(...flattenStylesheets(stylesheet));
149
+
150
+ /*
151
+ * Copyright (c) 2018, salesforce.com, inc.
152
+ * All rights reserved.
153
+ * SPDX-License-Identifier: MIT
154
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
155
+ */
156
+ const alreadyLoggedMessages = new Set();
157
+ // @ts-ignore
158
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
159
+ // @ts-ignore
160
+ window.__lwcResetAlreadyLoggedMessages = () => {
161
+ alreadyLoggedMessages.clear();
162
+ };
163
+ }
164
+ function log(method, message, vm, once) {
165
+ let msg = `[LWC ${method}]: ${message}`;
166
+ if (!shared.isUndefined(vm)) {
167
+ msg = `${msg}\n${getComponentStack(vm)}`;
168
+ }
169
+ if (once) {
170
+ if (alreadyLoggedMessages.has(msg)) {
171
+ return;
107
172
  }
173
+ alreadyLoggedMessages.add(msg);
108
174
  }
109
- return list;
110
- }
111
- // Set a ref (lwc:ref) on a VM, from a template API
112
- function setRefVNode(vm, ref, vnode) {
113
- if (process.env.NODE_ENV !== 'production' && shared.isUndefined(vm.refVNodes)) {
114
- throw new Error('refVNodes must be defined when setting a ref');
175
+ // In Jest tests, reduce the warning and error verbosity by not printing the callstack
176
+ if (process.env.NODE_ENV === 'test') {
177
+ /* eslint-disable-next-line no-console */
178
+ console[method](msg);
179
+ return;
115
180
  }
116
- // If this method is called, then vm.refVNodes is set as the template has refs.
117
- // If not, then something went wrong and we threw an error above.
118
- const refVNodes = vm.refVNodes;
119
- // In cases of conflict (two elements with the same ref), prefer, the last one,
120
- // in depth-first traversal order.
121
- if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
122
- refVNodes[ref] = vnode;
181
+ try {
182
+ throw new Error(msg);
183
+ }
184
+ catch (e) {
185
+ /* eslint-disable-next-line no-console */
186
+ console[method](e);
123
187
  }
124
188
  }
189
+ function logError(message, vm) {
190
+ log('error', message, vm, false);
191
+ }
192
+ function logWarn(message, vm) {
193
+ log('warn', message, vm, false);
194
+ }
195
+ function logWarnOnce(message, vm) {
196
+ log('warn', message, vm, true);
197
+ }
125
198
 
126
199
  /*
127
200
  * Copyright (c) 2019, salesforce.com, inc.
@@ -257,81 +330,98 @@ function createReactiveObserver(callback) {
257
330
  * SPDX-License-Identifier: MIT
258
331
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
259
332
  */
260
- function getComponentTag(vm) {
261
- return `<${shared.StringToLowerCase.call(vm.tagName)}>`;
262
- }
263
- // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
264
- function getComponentStack(vm) {
265
- const stack = [];
266
- let prefix = '';
267
- while (!shared.isNull(vm.owner)) {
268
- shared.ArrayPush.call(stack, prefix + getComponentTag(vm));
269
- vm = vm.owner;
270
- prefix += '\t';
271
- }
272
- return shared.ArrayJoin.call(stack, '\n');
273
- }
274
- function getErrorComponentStack(vm) {
275
- const wcStack = [];
276
- let currentVm = vm;
277
- while (!shared.isNull(currentVm)) {
278
- shared.ArrayPush.call(wcStack, getComponentTag(currentVm));
279
- currentVm = currentVm.owner;
333
+ let nextTickCallbackQueue = [];
334
+ const SPACE_CHAR = 32;
335
+ const EmptyObject = shared.seal(shared.create(null));
336
+ const EmptyArray = shared.seal([]);
337
+ function flushCallbackQueue() {
338
+ if (process.env.NODE_ENV !== 'production') {
339
+ if (nextTickCallbackQueue.length === 0) {
340
+ throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
341
+ }
280
342
  }
281
- return wcStack.reverse().join('\n\t');
282
- }
283
-
284
- /*
285
- * Copyright (c) 2018, salesforce.com, inc.
286
- * All rights reserved.
287
- * SPDX-License-Identifier: MIT
288
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
289
- */
290
- function addErrorComponentStack(vm, error) {
291
- if (!shared.isFrozen(error) && shared.isUndefined(error.wcStack)) {
292
- const wcStack = getErrorComponentStack(vm);
293
- shared.defineProperty(error, 'wcStack', {
294
- get() {
295
- return wcStack;
296
- },
297
- });
343
+ const callbacks = nextTickCallbackQueue;
344
+ nextTickCallbackQueue = []; // reset to a new queue
345
+ for (let i = 0, len = callbacks.length; i < len; i += 1) {
346
+ callbacks[i]();
298
347
  }
299
348
  }
300
-
301
- /*
302
- * Copyright (c) 2018, salesforce.com, inc.
303
- * All rights reserved.
304
- * SPDX-License-Identifier: MIT
305
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
306
- */
307
- function log(method, message, vm) {
308
- let msg = `[LWC ${method}]: ${message}`;
309
- if (!shared.isUndefined(vm)) {
310
- msg = `${msg}\n${getComponentStack(vm)}`;
311
- }
312
- if (process.env.NODE_ENV === 'test') {
313
- /* eslint-disable-next-line no-console */
314
- console[method](msg);
315
- return;
316
- }
317
- try {
318
- throw new Error(msg);
349
+ function addCallbackToNextTick(callback) {
350
+ if (process.env.NODE_ENV !== 'production') {
351
+ if (!shared.isFunction(callback)) {
352
+ throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
353
+ }
319
354
  }
320
- catch (e) {
321
- /* eslint-disable-next-line no-console */
322
- console[method](e);
355
+ if (nextTickCallbackQueue.length === 0) {
356
+ Promise.resolve().then(flushCallbackQueue);
323
357
  }
358
+ shared.ArrayPush.call(nextTickCallbackQueue, callback);
324
359
  }
325
- function logError(message, vm) {
326
- log('error', message, vm);
327
- }
328
- function logWarn(message, vm) {
329
- log('warn', message, vm);
360
+ function guid() {
361
+ function s4() {
362
+ return Math.floor((1 + Math.random()) * 0x10000)
363
+ .toString(16)
364
+ .substring(1);
365
+ }
366
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
330
367
  }
331
-
332
- /*
333
- * Copyright (c) 2020, salesforce.com, inc.
334
- * All rights reserved.
368
+ // Borrowed from Vue template compiler.
369
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
370
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
371
+ const PROPERTY_DELIMITER = /:(.+)/;
372
+ function parseStyleText(cssText) {
373
+ const styleMap = {};
374
+ const declarations = cssText.split(DECLARATION_DELIMITER);
375
+ for (const declaration of declarations) {
376
+ if (declaration) {
377
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
378
+ if (prop !== undefined && value !== undefined) {
379
+ styleMap[prop.trim()] = value.trim();
380
+ }
381
+ }
382
+ }
383
+ return styleMap;
384
+ }
385
+ // Make a shallow copy of an object but omit the given key
386
+ function cloneAndOmitKey(object, keyToOmit) {
387
+ const result = {};
388
+ for (const key of Object.keys(object)) {
389
+ if (key !== keyToOmit) {
390
+ result[key] = object[key];
391
+ }
392
+ }
393
+ return result;
394
+ }
395
+ function flattenStylesheets(stylesheets) {
396
+ const list = [];
397
+ for (const stylesheet of stylesheets) {
398
+ if (!Array.isArray(stylesheet)) {
399
+ list.push(stylesheet);
400
+ }
401
+ else {
402
+ list.push(...flattenStylesheets(stylesheet));
403
+ }
404
+ }
405
+ return list;
406
+ }
407
+ // Set a ref (lwc:ref) on a VM, from a template API
408
+ function setRefVNode(vm, ref, vnode) {
409
+ if (process.env.NODE_ENV !== 'production' && shared.isUndefined(vm.refVNodes)) {
410
+ throw new Error('refVNodes must be defined when setting a ref');
411
+ }
412
+ // If this method is called, then vm.refVNodes is set as the template has refs.
413
+ // If not, then something went wrong and we threw an error above.
414
+ const refVNodes = vm.refVNodes;
415
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
416
+ // in depth-first traversal order.
417
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
418
+ refVNodes[ref] = vnode;
419
+ }
420
+ }
421
+
422
+ /*
423
+ * Copyright (c) 2020, salesforce.com, inc.
424
+ * All rights reserved.
335
425
  * SPDX-License-Identifier: MIT
336
426
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
337
427
  */
@@ -378,7 +468,10 @@ function offsetPropertyErrorMessage(name) {
378
468
  // Global HTML Attributes & Properties
379
469
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
380
470
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
381
- const globalHTMLProperties = shared.assign(shared.create(null), {
471
+ //
472
+ // If you update this list, check for test files that recapitulate the same list. Searching the codebase
473
+ // for e.g. "dropzone" should suffice.
474
+ const globalHTMLProperties = {
382
475
  accessKey: {
383
476
  attribute: 'accesskey',
384
477
  },
@@ -463,7 +556,7 @@ const globalHTMLProperties = shared.assign(shared.create(null), {
463
556
  role: {
464
557
  attribute: 'role',
465
558
  },
466
- });
559
+ };
467
560
  let controlledElement = null;
468
561
  let controlledAttributeName;
469
562
  function isAttributeLocked(elm, attrName) {
@@ -1927,89 +2020,377 @@ function createObservedFieldPropertyDescriptor(key) {
1927
2020
  * SPDX-License-Identifier: MIT
1928
2021
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1929
2022
  */
1930
- function api$1() {
1931
- if (process.env.NODE_ENV !== 'production') {
1932
- shared.assert.fail(`@api decorator can only be used as a decorator function.`);
1933
- }
1934
- throw new Error();
2023
+ const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
2024
+ const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
2025
+ const WIRE_DEBUG_ENTRY = '@wire';
2026
+ const WireMetaMap = new Map();
2027
+ class WireContextRegistrationEvent extends CustomEvent {
2028
+ constructor(adapterToken, {
2029
+ setNewContext,
2030
+ setDisconnectedCallback
2031
+ }) {
2032
+ super(adapterToken, {
2033
+ bubbles: true,
2034
+ composed: true
2035
+ });
2036
+ shared.defineProperties(this, {
2037
+ setNewContext: {
2038
+ value: setNewContext
2039
+ },
2040
+ setDisconnectedCallback: {
2041
+ value: setDisconnectedCallback
2042
+ }
2043
+ });
2044
+ }
1935
2045
  }
1936
- function createPublicPropertyDescriptor(key) {
1937
- return {
1938
- get() {
1939
- const vm = getAssociatedVM(this);
1940
- if (isBeingConstructed(vm)) {
1941
- if (process.env.NODE_ENV !== 'production') {
1942
- logError(`Can’t read the value of property \`${shared.toString(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
1943
- }
1944
- return;
1945
- }
1946
- componentValueObserved(vm, key);
1947
- return vm.cmpProps[key];
1948
- },
1949
- set(newValue) {
1950
- const vm = getAssociatedVM(this);
1951
- if (process.env.NODE_ENV !== 'production') {
1952
- const vmBeingRendered = getVMBeingRendered();
1953
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1954
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1955
- }
1956
- vm.cmpProps[key] = newValue;
1957
- componentValueMutated(vm, key);
1958
- },
1959
- enumerable: true,
1960
- configurable: true,
1961
- };
2046
+ function createFieldDataCallback(vm, name) {
2047
+ return value => {
2048
+ updateComponentValue(vm, name, value);
2049
+ };
1962
2050
  }
1963
- function createPublicAccessorDescriptor(key, descriptor) {
1964
- const { get, set, enumerable, configurable } = descriptor;
1965
- if (!shared.isFunction(get)) {
1966
- if (process.env.NODE_ENV !== 'production') {
1967
- shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
1968
- }
1969
- throw new Error();
2051
+ function createMethodDataCallback(vm, method) {
2052
+ return value => {
2053
+ // dispatching new value into the wired method
2054
+ runWithBoundaryProtection(vm, vm.owner, shared.noop, () => {
2055
+ // job
2056
+ method.call(vm.component, value);
2057
+ }, shared.noop);
2058
+ };
2059
+ }
2060
+ function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
2061
+ let hasPendingConfig = false;
2062
+ // creating the reactive observer for reactive params when needed
2063
+ const ro = createReactiveObserver(() => {
2064
+ if (hasPendingConfig === false) {
2065
+ hasPendingConfig = true;
2066
+ // collect new config in the micro-task
2067
+ Promise.resolve().then(() => {
2068
+ hasPendingConfig = false;
2069
+ // resetting current reactive params
2070
+ ro.reset();
2071
+ // dispatching a new config due to a change in the configuration
2072
+ computeConfigAndUpdate();
2073
+ });
1970
2074
  }
1971
- return {
1972
- get() {
1973
- if (process.env.NODE_ENV !== 'production') {
1974
- // Assert that the this value is an actual Component with an associated VM.
1975
- getAssociatedVM(this);
1976
- }
1977
- return get.call(this);
1978
- },
1979
- set(newValue) {
1980
- const vm = getAssociatedVM(this);
1981
- if (process.env.NODE_ENV !== 'production') {
1982
- const vmBeingRendered = getVMBeingRendered();
1983
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1984
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1985
- }
1986
- if (set) {
1987
- set.call(this, newValue);
1988
- }
1989
- else if (process.env.NODE_ENV !== 'production') {
1990
- shared.assert.fail(`Invalid attempt to set a new value for property ${shared.toString(key)} of ${vm} that does not has a setter decorated with @api.`);
1991
- }
1992
- },
1993
- enumerable,
1994
- configurable,
1995
- };
2075
+ });
2076
+ const computeConfigAndUpdate = () => {
2077
+ let config;
2078
+ ro.observe(() => config = configCallback(component));
2079
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2080
+ // TODO: dev-mode validation of config based on the adapter.configSchema
2081
+ // @ts-ignore it is assigned in the observe() callback
2082
+ callbackWhenConfigIsReady(config);
2083
+ };
2084
+ return {
2085
+ computeConfigAndUpdate,
2086
+ ro
2087
+ };
1996
2088
  }
2089
+ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
2090
+ const {
2091
+ adapter
2092
+ } = wireDef;
2093
+ const adapterContextToken = getAdapterToken(adapter);
2094
+ if (shared.isUndefined(adapterContextToken)) {
2095
+ return; // no provider found, nothing to be done
2096
+ }
1997
2097
 
1998
- /*
1999
- * Copyright (c) 2018, salesforce.com, inc.
2000
- * All rights reserved.
2001
- * SPDX-License-Identifier: MIT
2002
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2003
- */
2004
- function track(target) {
2005
- if (arguments.length === 1) {
2006
- return getReactiveProxy(target);
2098
+ const {
2099
+ elm,
2100
+ context: {
2101
+ wiredConnecting,
2102
+ wiredDisconnecting
2103
+ },
2104
+ renderer: {
2105
+ dispatchEvent
2007
2106
  }
2107
+ } = vm;
2108
+ // waiting for the component to be connected to formally request the context via the token
2109
+ shared.ArrayPush.call(wiredConnecting, () => {
2110
+ // This event is responsible for connecting the host element with another
2111
+ // element in the composed path that is providing contextual data. The provider
2112
+ // must be listening for a special dom event with the name corresponding to the value of
2113
+ // `adapterContextToken`, which will remain secret and internal to this file only to
2114
+ // guarantee that the linkage can be forged.
2115
+ const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
2116
+ setNewContext(newContext) {
2117
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2118
+ // TODO: dev-mode validation of config based on the adapter.contextSchema
2119
+ callbackWhenContextIsReady(newContext);
2120
+ },
2121
+ setDisconnectedCallback(disconnectCallback) {
2122
+ // adds this callback into the disconnect bucket so it gets disconnected from parent
2123
+ // the the element hosting the wire is disconnected
2124
+ shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
2125
+ }
2126
+ });
2127
+ dispatchEvent(elm, contextRegistrationEvent);
2128
+ });
2129
+ }
2130
+ function createConnector(vm, name, wireDef) {
2131
+ const {
2132
+ method,
2133
+ adapter,
2134
+ configCallback,
2135
+ dynamic
2136
+ } = wireDef;
2137
+ let debugInfo;
2138
+ if (process.env.NODE_ENV !== 'production') {
2139
+ const wiredPropOrMethod = shared.isUndefined(method) ? name : method.name;
2140
+ debugInfo = shared.create(null);
2141
+ debugInfo.wasDataProvisionedForConfig = false;
2142
+ vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
2143
+ }
2144
+ const fieldOrMethodCallback = shared.isUndefined(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
2145
+ const dataCallback = value => {
2008
2146
  if (process.env.NODE_ENV !== 'production') {
2009
- shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2147
+ debugInfo.data = value;
2148
+ // Note: most of the time, the data provided is for the current config, but there may be
2149
+ // some conditions in which it does not, ex:
2150
+ // race conditions in a poor network while the adapter does not cancel a previous request.
2151
+ debugInfo.wasDataProvisionedForConfig = true;
2010
2152
  }
2011
- throw new Error();
2012
- }
2153
+ fieldOrMethodCallback(value);
2154
+ };
2155
+ let context;
2156
+ let connector;
2157
+ // Workaround to pass the component element associated to this wire adapter instance.
2158
+ shared.defineProperty(dataCallback, DeprecatedWiredElementHost, {
2159
+ value: vm.elm
2160
+ });
2161
+ shared.defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
2162
+ value: dynamic
2163
+ });
2164
+ runWithBoundaryProtection(vm, vm, shared.noop, () => {
2165
+ // job
2166
+ connector = new adapter(dataCallback);
2167
+ }, shared.noop);
2168
+ const updateConnectorConfig = config => {
2169
+ // every time the config is recomputed due to tracking,
2170
+ // this callback will be invoked with the new computed config
2171
+ runWithBoundaryProtection(vm, vm, shared.noop, () => {
2172
+ // job
2173
+ if (process.env.NODE_ENV !== 'production') {
2174
+ debugInfo.config = config;
2175
+ debugInfo.context = context;
2176
+ debugInfo.wasDataProvisionedForConfig = false;
2177
+ }
2178
+ connector.update(config, context);
2179
+ }, shared.noop);
2180
+ };
2181
+ // Computes the current wire config and calls the update method on the wire adapter.
2182
+ // If it has params, we will need to observe changes in the next tick.
2183
+ const {
2184
+ computeConfigAndUpdate,
2185
+ ro
2186
+ } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
2187
+ // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
2188
+ if (!shared.isUndefined(adapter.contextSchema)) {
2189
+ createContextWatcher(vm, wireDef, newContext => {
2190
+ // every time the context is pushed into this component,
2191
+ // this callback will be invoked with the new computed context
2192
+ if (context !== newContext) {
2193
+ context = newContext;
2194
+ // Note: when new context arrives, the config will be recomputed and pushed along side the new
2195
+ // context, this is to preserve the identity characteristics, config should not have identity
2196
+ // (ever), while context can have identity
2197
+ if (vm.state === 1 /* VMState.connected */) {
2198
+ computeConfigAndUpdate();
2199
+ }
2200
+ }
2201
+ });
2202
+ }
2203
+ return {
2204
+ // @ts-ignore the boundary protection executes sync, connector is always defined
2205
+ connector,
2206
+ computeConfigAndUpdate,
2207
+ resetConfigWatcher: () => ro.reset()
2208
+ };
2209
+ }
2210
+ const AdapterToTokenMap = new Map();
2211
+ function getAdapterToken(adapter) {
2212
+ return AdapterToTokenMap.get(adapter);
2213
+ }
2214
+ function setAdapterToken(adapter, token) {
2215
+ AdapterToTokenMap.set(adapter, token);
2216
+ }
2217
+ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
2218
+ // support for callable adapters
2219
+ if (adapter.adapter) {
2220
+ adapter = adapter.adapter;
2221
+ }
2222
+ const method = descriptor.value;
2223
+ const def = {
2224
+ adapter,
2225
+ method,
2226
+ configCallback,
2227
+ dynamic
2228
+ };
2229
+ WireMetaMap.set(descriptor, def);
2230
+ }
2231
+ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
2232
+ // support for callable adapters
2233
+ if (adapter.adapter) {
2234
+ adapter = adapter.adapter;
2235
+ }
2236
+ const def = {
2237
+ adapter,
2238
+ configCallback,
2239
+ dynamic
2240
+ };
2241
+ WireMetaMap.set(descriptor, def);
2242
+ }
2243
+ function installWireAdapters(vm) {
2244
+ const {
2245
+ context,
2246
+ def: {
2247
+ wire
2248
+ }
2249
+ } = vm;
2250
+ if (process.env.NODE_ENV !== 'production') {
2251
+ vm.debugInfo[WIRE_DEBUG_ENTRY] = shared.create(null);
2252
+ }
2253
+ const wiredConnecting = context.wiredConnecting = [];
2254
+ const wiredDisconnecting = context.wiredDisconnecting = [];
2255
+ for (const fieldNameOrMethod in wire) {
2256
+ const descriptor = wire[fieldNameOrMethod];
2257
+ const wireDef = WireMetaMap.get(descriptor);
2258
+ if (process.env.NODE_ENV !== 'production') {
2259
+ shared.assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
2260
+ }
2261
+ if (!shared.isUndefined(wireDef)) {
2262
+ const {
2263
+ connector,
2264
+ computeConfigAndUpdate,
2265
+ resetConfigWatcher
2266
+ } = createConnector(vm, fieldNameOrMethod, wireDef);
2267
+ const hasDynamicParams = wireDef.dynamic.length > 0;
2268
+ shared.ArrayPush.call(wiredConnecting, () => {
2269
+ connector.connect();
2270
+ if (!features.lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
2271
+ if (hasDynamicParams) {
2272
+ Promise.resolve().then(computeConfigAndUpdate);
2273
+ return;
2274
+ }
2275
+ }
2276
+ computeConfigAndUpdate();
2277
+ });
2278
+ shared.ArrayPush.call(wiredDisconnecting, () => {
2279
+ connector.disconnect();
2280
+ resetConfigWatcher();
2281
+ });
2282
+ }
2283
+ }
2284
+ }
2285
+ function connectWireAdapters(vm) {
2286
+ const {
2287
+ wiredConnecting
2288
+ } = vm.context;
2289
+ for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
2290
+ wiredConnecting[i]();
2291
+ }
2292
+ }
2293
+ function disconnectWireAdapters(vm) {
2294
+ const {
2295
+ wiredDisconnecting
2296
+ } = vm.context;
2297
+ runWithBoundaryProtection(vm, vm, shared.noop, () => {
2298
+ // job
2299
+ for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
2300
+ wiredDisconnecting[i]();
2301
+ }
2302
+ }, shared.noop);
2303
+ }
2304
+
2305
+ /*
2306
+ * Copyright (c) 2018, salesforce.com, inc.
2307
+ * All rights reserved.
2308
+ * SPDX-License-Identifier: MIT
2309
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2310
+ */
2311
+ function api$1() {
2312
+ if (process.env.NODE_ENV !== 'production') {
2313
+ shared.assert.fail(`@api decorator can only be used as a decorator function.`);
2314
+ }
2315
+ throw new Error();
2316
+ }
2317
+ function createPublicPropertyDescriptor(key) {
2318
+ return {
2319
+ get() {
2320
+ const vm = getAssociatedVM(this);
2321
+ if (isBeingConstructed(vm)) {
2322
+ if (process.env.NODE_ENV !== 'production') {
2323
+ logError(`Can’t read the value of property \`${shared.toString(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
2324
+ }
2325
+ return;
2326
+ }
2327
+ componentValueObserved(vm, key);
2328
+ return vm.cmpProps[key];
2329
+ },
2330
+ set(newValue) {
2331
+ const vm = getAssociatedVM(this);
2332
+ if (process.env.NODE_ENV !== 'production') {
2333
+ const vmBeingRendered = getVMBeingRendered();
2334
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2335
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2336
+ }
2337
+ vm.cmpProps[key] = newValue;
2338
+ componentValueMutated(vm, key);
2339
+ },
2340
+ enumerable: true,
2341
+ configurable: true,
2342
+ };
2343
+ }
2344
+ function createPublicAccessorDescriptor(key, descriptor) {
2345
+ const { get, set, enumerable, configurable } = descriptor;
2346
+ if (!shared.isFunction(get)) {
2347
+ if (process.env.NODE_ENV !== 'production') {
2348
+ shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
2349
+ }
2350
+ throw new Error();
2351
+ }
2352
+ return {
2353
+ get() {
2354
+ if (process.env.NODE_ENV !== 'production') {
2355
+ // Assert that the this value is an actual Component with an associated VM.
2356
+ getAssociatedVM(this);
2357
+ }
2358
+ return get.call(this);
2359
+ },
2360
+ set(newValue) {
2361
+ const vm = getAssociatedVM(this);
2362
+ if (process.env.NODE_ENV !== 'production') {
2363
+ const vmBeingRendered = getVMBeingRendered();
2364
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2365
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2366
+ }
2367
+ if (set) {
2368
+ set.call(this, newValue);
2369
+ }
2370
+ else if (process.env.NODE_ENV !== 'production') {
2371
+ shared.assert.fail(`Invalid attempt to set a new value for property ${shared.toString(key)} of ${vm} that does not has a setter decorated with @api.`);
2372
+ }
2373
+ },
2374
+ enumerable,
2375
+ configurable,
2376
+ };
2377
+ }
2378
+
2379
+ /*
2380
+ * Copyright (c) 2018, salesforce.com, inc.
2381
+ * All rights reserved.
2382
+ * SPDX-License-Identifier: MIT
2383
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2384
+ */
2385
+ function track(target) {
2386
+ if (arguments.length === 1) {
2387
+ return getReactiveProxy(target);
2388
+ }
2389
+ if (process.env.NODE_ENV !== 'production') {
2390
+ shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2391
+ }
2392
+ throw new Error();
2393
+ }
2013
2394
  function internalTrackDecorator(key) {
2014
2395
  return {
2015
2396
  get() {
@@ -2972,6 +3353,9 @@ function updateStylesheetToken(vm, template) {
2972
3353
  stylesheets: newStylesheets,
2973
3354
  stylesheetToken: newStylesheetToken
2974
3355
  } = template;
3356
+ const {
3357
+ stylesheets: newVmStylesheets
3358
+ } = vm;
2975
3359
  const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
2976
3360
  const {
2977
3361
  hasScopedStyles
@@ -2995,7 +3379,9 @@ function updateStylesheetToken(vm, template) {
2995
3379
  }
2996
3380
  // Apply the new template styling token to the host element, if the new template has any
2997
3381
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
2998
- if (!shared.isUndefined(newStylesheets) && newStylesheets.length !== 0) {
3382
+ const hasNewStylesheets = hasStyles(newStylesheets);
3383
+ const hasNewVmStylesheets = hasStyles(newVmStylesheets);
3384
+ if (hasNewStylesheets || hasNewVmStylesheets) {
2999
3385
  newToken = newStylesheetToken;
3000
3386
  }
3001
3387
  // Set the new styling token on the host element
@@ -3067,10 +3453,17 @@ function getStylesheetsContent(vm, template) {
3067
3453
  stylesheets,
3068
3454
  stylesheetToken
3069
3455
  } = template;
3456
+ const {
3457
+ stylesheets: vmStylesheets
3458
+ } = vm;
3070
3459
  let content = [];
3071
- if (!shared.isUndefined(stylesheets) && stylesheets.length !== 0) {
3460
+ if (hasStyles(stylesheets)) {
3072
3461
  content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
3073
3462
  }
3463
+ // VM (component) stylesheets apply after template stylesheets
3464
+ if (hasStyles(vmStylesheets)) {
3465
+ shared.ArrayPush.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
3466
+ }
3074
3467
  return content;
3075
3468
  }
3076
3469
  // It might be worth caching this to avoid doing the lookup repeatedly, but
@@ -3108,10 +3501,13 @@ function getStylesheetTokenHost(vnode) {
3108
3501
  const {
3109
3502
  template
3110
3503
  } = getComponentInternalDef(vnode.ctor);
3504
+ const {
3505
+ vm
3506
+ } = vnode;
3111
3507
  const {
3112
3508
  stylesheetToken
3113
3509
  } = template;
3114
- return !shared.isUndefined(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
3510
+ return !shared.isUndefined(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
3115
3511
  }
3116
3512
  function getNearestNativeShadowComponent(vm) {
3117
3513
  const owner = getNearestShadowComponent(vm);
@@ -3728,6 +4124,28 @@ function patchCustomElement(n1, n2, parent, renderer) {
3728
4124
  // in fallback mode, the allocation will always set children to
3729
4125
  // empty and delegate the real allocation to the slot elements
3730
4126
  allocateChildren(n2, vm);
4127
+ // Solves an edge case with slotted VFragments in native shadow mode.
4128
+ //
4129
+ // During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
4130
+ // to avoid interfering with native slot behavior. When this happens, if any of the fragments
4131
+ // were not stable, the children must go through the dynamic diffing algo.
4132
+ //
4133
+ // If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
4134
+ // the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
4135
+ // nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
4136
+ // mark the new children dynamic.
4137
+ //
4138
+ // Example:
4139
+ // n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
4140
+ // n2.children: [div, null, div] => [div, null, div] // marked ???
4141
+ const {
4142
+ shadowMode,
4143
+ renderMode
4144
+ } = vm;
4145
+ if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
4146
+ // No-op if children has already been marked dynamic by 'allocateChildren()'.
4147
+ markAsDynamicChildren(n2.children);
4148
+ }
3731
4149
  }
3732
4150
  // in fallback mode, the children will be always empty, so, nothing
3733
4151
  // will happen, but in native, it does allocate the light dom
@@ -3920,7 +4338,6 @@ function allocateChildren(vnode, vm) {
3920
4338
  //
3921
4339
  // In case #2, we will always get a fresh VCustomElement.
3922
4340
  const children = vnode.aChildren || vnode.children;
3923
- vm.aChildren = children;
3924
4341
  const {
3925
4342
  renderMode,
3926
4343
  shadowMode
@@ -3933,20 +4350,66 @@ function allocateChildren(vnode, vm) {
3933
4350
  logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
3934
4351
  }
3935
4352
  }
4353
+ // If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
4354
+ // children VFragments to avoid them interfering with default slot behavior.
4355
+ const allocatedChildren = flattenFragmentsInChildren(children);
4356
+ vnode.children = allocatedChildren;
4357
+ vm.aChildren = allocatedChildren;
3936
4358
  if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3937
4359
  // slow path
3938
- allocateInSlot(vm, children, vnode.owner);
4360
+ allocateInSlot(vm, allocatedChildren, vnode.owner);
3939
4361
  // save the allocated children in case this vnode is reused.
3940
- vnode.aChildren = children;
4362
+ vnode.aChildren = allocatedChildren;
3941
4363
  // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3942
4364
  vnode.children = EmptyArray;
3943
4365
  }
3944
4366
  }
3945
- function createViewModelHook(elm, vnode, renderer) {
3946
- let vm = getAssociatedVMIfPresent(elm);
3947
- // There is a possibility that a custom element is registered under tagName, in which case, the
3948
- // initialization is already carry on, and there is nothing else to do here since this hook is
3949
- // called right after invoking `document.createElement`.
4367
+ /**
4368
+ * Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
4369
+ * marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
4370
+ * and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
4371
+ *
4372
+ * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
4373
+ *
4374
+ * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
4375
+ */
4376
+ function flattenFragmentsInChildren(children) {
4377
+ const flattenedChildren = [];
4378
+ // Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
4379
+ // If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
4380
+ const nodeStack = [];
4381
+ let fragmentFound = false;
4382
+ for (let i = children.length - 1; i > -1; i -= 1) {
4383
+ const child = children[i];
4384
+ shared.ArrayPush.call(nodeStack, child);
4385
+ fragmentFound = fragmentFound || !!(child && isVFragment(child));
4386
+ }
4387
+ if (!fragmentFound) {
4388
+ return children;
4389
+ }
4390
+ let currentNode;
4391
+ while (!shared.isUndefined(currentNode = shared.ArrayPop.call(nodeStack))) {
4392
+ if (!shared.isNull(currentNode) && isVFragment(currentNode)) {
4393
+ const fChildren = currentNode.children;
4394
+ // Ignore the start and end text node delimiters
4395
+ for (let i = fChildren.length - 2; i > 0; i -= 1) {
4396
+ shared.ArrayPush.call(nodeStack, fChildren[i]);
4397
+ }
4398
+ } else {
4399
+ shared.ArrayPush.call(flattenedChildren, currentNode);
4400
+ }
4401
+ }
4402
+ // We always mark the children as dynamic because nothing generates stable VFragments yet.
4403
+ // If/when stable VFragments are generated by the compiler, this code should be updated to
4404
+ // not mark dynamic if all flattened VFragments were stable.
4405
+ markAsDynamicChildren(flattenedChildren);
4406
+ return flattenedChildren;
4407
+ }
4408
+ function createViewModelHook(elm, vnode, renderer) {
4409
+ let vm = getAssociatedVMIfPresent(elm);
4410
+ // There is a possibility that a custom element is registered under tagName, in which case, the
4411
+ // initialization is already carry on, and there is nothing else to do here since this hook is
4412
+ // called right after invoking `document.createElement`.
3950
4413
  if (!shared.isUndefined(vm)) {
3951
4414
  return vm;
3952
4415
  }
@@ -3966,22 +4429,20 @@ function createViewModelHook(elm, vnode, renderer) {
3966
4429
  }
3967
4430
  return vm;
3968
4431
  }
3969
- /**
3970
- * Collects all slots into a SlotSet, traversing through VFragment Nodes
3971
- */
3972
- function collectSlots(vm, children, cmpSlotsMapping) {
4432
+ function allocateInSlot(vm, children, owner) {
3973
4433
  var _a, _b;
4434
+ const {
4435
+ cmpSlots: {
4436
+ slotAssignments: oldSlotsMapping
4437
+ }
4438
+ } = vm;
4439
+ const cmpSlotsMapping = shared.create(null);
4440
+ // Collect all slots into cmpSlotsMapping
3974
4441
  for (let i = 0, len = children.length; i < len; i += 1) {
3975
4442
  const vnode = children[i];
3976
4443
  if (shared.isNull(vnode)) {
3977
4444
  continue;
3978
4445
  }
3979
- // Dive further iff the content is wrapped in a VFragment
3980
- if (isVFragment(vnode)) {
3981
- // Remove the text delimiter nodes to avoid overriding default slot content
3982
- collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
3983
- continue;
3984
- }
3985
4446
  let slotName = '';
3986
4447
  if (isVBaseElement(vnode)) {
3987
4448
  slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
@@ -3991,15 +4452,6 @@ function collectSlots(vm, children, cmpSlotsMapping) {
3991
4452
  const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3992
4453
  shared.ArrayPush.call(vnodes, vnode);
3993
4454
  }
3994
- }
3995
- function allocateInSlot(vm, children, owner) {
3996
- const {
3997
- cmpSlots: {
3998
- slotAssignments: oldSlotsMapping
3999
- }
4000
- } = vm;
4001
- const cmpSlotsMapping = shared.create(null);
4002
- collectSlots(vm, children, cmpSlotsMapping);
4003
4455
  vm.cmpSlots = {
4004
4456
  owner,
4005
4457
  slotAssignments: cmpSlotsMapping
@@ -4030,14 +4482,14 @@ function allocateInSlot(vm, children, owner) {
4030
4482
  }
4031
4483
  }
4032
4484
  // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4033
- const FromIteration = new WeakMap();
4034
- // dynamic children means it was generated by an iteration
4035
- // in a template, and will require a more complex diffing algo.
4485
+ const DynamicChildren = new WeakMap();
4486
+ // dynamic children means it was either generated by an iteration in a template
4487
+ // or part of an unstable fragment, and will require a more complex diffing algo.
4036
4488
  function markAsDynamicChildren(children) {
4037
- FromIteration.set(children, 1);
4489
+ DynamicChildren.set(children, 1);
4038
4490
  }
4039
4491
  function hasDynamicChildren(children) {
4040
- return FromIteration.has(children);
4492
+ return DynamicChildren.has(children);
4041
4493
  }
4042
4494
  function createKeyToOldIdx(children, beginIdx, endIdx) {
4043
4495
  const map = {};
@@ -4903,7 +5355,7 @@ function evaluateTemplate(vm, html) {
4903
5355
  // Create a brand new template cache for the swapped templated.
4904
5356
  context.tplCache = shared.create(null);
4905
5357
  // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
4906
- context.hasScopedStyles = computeHasScopedStyles(html);
5358
+ context.hasScopedStyles = computeHasScopedStyles(html, vm);
4907
5359
  // Update the scoping token on the host element.
4908
5360
  updateStylesheetToken(vm, html);
4909
5361
  // Evaluate, create stylesheet and cache the produced VNode for future
@@ -4946,9 +5398,8 @@ function evaluateTemplate(vm, html) {
4946
5398
  }
4947
5399
  return vnodes;
4948
5400
  }
4949
- function computeHasScopedStyles(template) {
4950
- const { stylesheets } = template;
4951
- if (!shared.isUndefined(stylesheets)) {
5401
+ function computeHasScopedStylesInStylesheets(stylesheets) {
5402
+ if (hasStyles(stylesheets)) {
4952
5403
  for (let i = 0; i < stylesheets.length; i++) {
4953
5404
  if (shared.isTrue(stylesheets[i][shared.KEY__SCOPED_CSS])) {
4954
5405
  return true;
@@ -4957,6 +5408,15 @@ function computeHasScopedStyles(template) {
4957
5408
  }
4958
5409
  return false;
4959
5410
  }
5411
+ function computeHasScopedStyles(template, vm) {
5412
+ const { stylesheets } = template;
5413
+ const vmStylesheets = !shared.isUndefined(vm) ? vm.stylesheets : null;
5414
+ return (computeHasScopedStylesInStylesheets(stylesheets) ||
5415
+ computeHasScopedStylesInStylesheets(vmStylesheets));
5416
+ }
5417
+ function hasStyles(stylesheets) {
5418
+ return !shared.isUndefined(stylesheets) && !shared.isNull(stylesheets) && stylesheets.length > 0;
5419
+ }
4960
5420
 
4961
5421
  /*
4962
5422
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5272,6 +5732,7 @@ function createVM(elm, ctor, renderer, options) {
5272
5732
  // Properties set right after VM creation.
5273
5733
  tro: null,
5274
5734
  shadowMode: null,
5735
+ stylesheets: null,
5275
5736
  // Properties set by the LightningElement constructor.
5276
5737
  component: null,
5277
5738
  shadowRoot: null,
@@ -5284,6 +5745,7 @@ function createVM(elm, ctor, renderer, options) {
5284
5745
  if (process.env.NODE_ENV !== 'production') {
5285
5746
  vm.debugInfo = shared.create(null);
5286
5747
  }
5748
+ vm.stylesheets = computeStylesheets(vm, def.ctor);
5287
5749
  vm.shadowMode = computeShadowMode(vm, renderer);
5288
5750
  vm.tro = getTemplateReactiveObserver(vm);
5289
5751
  if (process.env.NODE_ENV !== 'production') {
@@ -5302,6 +5764,42 @@ function createVM(elm, ctor, renderer, options) {
5302
5764
  }
5303
5765
  return vm;
5304
5766
  }
5767
+ function validateComponentStylesheets(vm, stylesheets) {
5768
+ let valid = true;
5769
+ const validate = arrayOrStylesheet => {
5770
+ if (shared.isArray(arrayOrStylesheet)) {
5771
+ for (let i = 0; i < arrayOrStylesheet.length; i++) {
5772
+ validate(arrayOrStylesheet[i]);
5773
+ }
5774
+ } else if (!shared.isFunction(arrayOrStylesheet)) {
5775
+ // function assumed to be a stylesheet factory
5776
+ valid = false;
5777
+ }
5778
+ };
5779
+ if (!shared.isArray(stylesheets)) {
5780
+ valid = false;
5781
+ } else {
5782
+ validate(stylesheets);
5783
+ }
5784
+ return valid;
5785
+ }
5786
+ // Validate and flatten any stylesheets defined as `static stylesheets`
5787
+ function computeStylesheets(vm, ctor) {
5788
+ if (features.lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
5789
+ const {
5790
+ stylesheets
5791
+ } = ctor;
5792
+ if (!shared.isUndefined(stylesheets)) {
5793
+ const valid = validateComponentStylesheets(vm, stylesheets);
5794
+ if (valid) {
5795
+ return flattenStylesheets(stylesheets);
5796
+ } else if (process.env.NODE_ENV !== 'production') {
5797
+ logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
5798
+ }
5799
+ }
5800
+ }
5801
+ return null;
5802
+ }
5305
5803
  function computeShadowMode(vm, renderer) {
5306
5804
  const {
5307
5805
  def
@@ -5672,286 +6170,143 @@ function forceRehydration(vm) {
5672
6170
  * SPDX-License-Identifier: MIT
5673
6171
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5674
6172
  */
5675
- const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
5676
- const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
5677
- const WIRE_DEBUG_ENTRY = '@wire';
5678
- const WireMetaMap = new Map();
5679
- class WireContextRegistrationEvent extends CustomEvent {
5680
- constructor(adapterToken, {
5681
- setNewContext,
5682
- setDisconnectedCallback
5683
- }) {
5684
- super(adapterToken, {
5685
- bubbles: true,
5686
- composed: true
5687
- });
5688
- shared.defineProperties(this, {
5689
- setNewContext: {
5690
- value: setNewContext
5691
- },
5692
- setDisconnectedCallback: {
5693
- value: setDisconnectedCallback
5694
- }
5695
- });
5696
- }
6173
+ //
6174
+ // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
6175
+ // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
6176
+ // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
6177
+ // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
6178
+ //
6179
+ // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
6180
+ const getElementById = shared.globalThis[shared.KEY__NATIVE_GET_ELEMENT_BY_ID];
6181
+ const querySelectorAll = shared.globalThis[shared.KEY__NATIVE_QUERY_SELECTOR_ALL];
6182
+ function isSyntheticShadowRootInstance(rootNode) {
6183
+ return rootNode !== document && shared.isTrue(rootNode.synthetic);
6184
+ }
6185
+ function reportViolation(source, target, attrName) {
6186
+ // The vm is either for the source, the target, or both. Either one or both must be using synthetic
6187
+ // shadow for a violation to be detected.
6188
+ let vm = getAssociatedVMIfPresent(source.getRootNode().host);
6189
+ if (shared.isUndefined(vm)) {
6190
+ vm = getAssociatedVMIfPresent(target.getRootNode().host);
6191
+ }
6192
+ if (shared.isUndefined(vm)) {
6193
+ // vm should never be undefined here, but just to be safe, bail out and don't report
6194
+ return;
6195
+ }
6196
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
6197
+ if (process.env.NODE_ENV !== 'production') {
6198
+ // Avoid excessively logging to the console in the case of duplicates.
6199
+ logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
6200
+ `<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
6201
+ `For details, see: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates`, vm);
6202
+ }
5697
6203
  }
5698
- function createFieldDataCallback(vm, name) {
5699
- return value => {
5700
- updateComponentValue(vm, name, value);
5701
- };
6204
+ function parseIdRefAttributeValue(attrValue) {
6205
+ // split on whitespace and skip empty strings after splitting
6206
+ return shared.isString(attrValue) ? shared.ArrayFilter.call(shared.StringSplit.call(attrValue, /\s+/), Boolean) : [];
5702
6207
  }
5703
- function createMethodDataCallback(vm, method) {
5704
- return value => {
5705
- // dispatching new value into the wired method
5706
- runWithBoundaryProtection(vm, vm.owner, shared.noop, () => {
5707
- // job
5708
- method.call(vm.component, value);
5709
- }, shared.noop);
5710
- };
5711
- }
5712
- function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
5713
- let hasPendingConfig = false;
5714
- // creating the reactive observer for reactive params when needed
5715
- const ro = createReactiveObserver(() => {
5716
- if (hasPendingConfig === false) {
5717
- hasPendingConfig = true;
5718
- // collect new config in the micro-task
5719
- Promise.resolve().then(() => {
5720
- hasPendingConfig = false;
5721
- // resetting current reactive params
5722
- ro.reset();
5723
- // dispatching a new config due to a change in the configuration
5724
- computeConfigAndUpdate();
5725
- });
6208
+ function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
6209
+ const root = elm.getRootNode();
6210
+ if (!isSyntheticShadowRootInstance(root)) {
6211
+ return;
5726
6212
  }
5727
- });
5728
- const computeConfigAndUpdate = () => {
5729
- let config;
5730
- ro.observe(() => config = configCallback(component));
5731
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
5732
- // TODO: dev-mode validation of config based on the adapter.configSchema
5733
- // @ts-ignore it is assigned in the observe() callback
5734
- callbackWhenConfigIsReady(config);
5735
- };
5736
- return {
5737
- computeConfigAndUpdate,
5738
- ro
5739
- };
5740
- }
5741
- function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
5742
- const {
5743
- adapter
5744
- } = wireDef;
5745
- const adapterContextToken = getAdapterToken(adapter);
5746
- if (shared.isUndefined(adapterContextToken)) {
5747
- return; // no provider found, nothing to be done
5748
- }
5749
-
5750
- const {
5751
- elm,
5752
- context: {
5753
- wiredConnecting,
5754
- wiredDisconnecting
5755
- },
5756
- renderer: {
5757
- dispatchEvent
6213
+ if (attrName === 'id') {
6214
+ // elm is the target, find the source
6215
+ if (!shared.isString(attrValue) || attrValue.length === 0) {
6216
+ // if our id is null or empty, nobody can reference us
6217
+ return;
6218
+ }
6219
+ for (const idRefAttrName of shared.ID_REFERENCING_ATTRIBUTES_SET) {
6220
+ // Query all global elements with this attribute. The attribute selector syntax `~=` is for values
6221
+ // that reference multiple IDs, separated by whitespace.
6222
+ const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
6223
+ const sourceElements = querySelectorAll.call(document, query);
6224
+ for (let i = 0; i < sourceElements.length; i++) {
6225
+ const sourceElement = sourceElements[i];
6226
+ const sourceRoot = sourceElement.getRootNode();
6227
+ if (sourceRoot !== root) {
6228
+ reportViolation(sourceElement, elm, idRefAttrName);
6229
+ break;
6230
+ }
6231
+ }
6232
+ }
6233
+ }
6234
+ else {
6235
+ // elm is the source, find the target
6236
+ const ids = parseIdRefAttributeValue(attrValue);
6237
+ for (const id of ids) {
6238
+ const target = getElementById.call(document, id);
6239
+ if (!shared.isNull(target)) {
6240
+ const targetRoot = target.getRootNode();
6241
+ if (targetRoot !== root) {
6242
+ // target element's shadow root is not the same as ours
6243
+ reportViolation(elm, target, attrName);
6244
+ }
6245
+ }
6246
+ }
5758
6247
  }
5759
- } = vm;
5760
- // waiting for the component to be connected to formally request the context via the token
5761
- shared.ArrayPush.call(wiredConnecting, () => {
5762
- // This event is responsible for connecting the host element with another
5763
- // element in the composed path that is providing contextual data. The provider
5764
- // must be listening for a special dom event with the name corresponding to the value of
5765
- // `adapterContextToken`, which will remain secret and internal to this file only to
5766
- // guarantee that the linkage can be forged.
5767
- const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
5768
- setNewContext(newContext) {
5769
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
5770
- // TODO: dev-mode validation of config based on the adapter.contextSchema
5771
- callbackWhenContextIsReady(newContext);
5772
- },
5773
- setDisconnectedCallback(disconnectCallback) {
5774
- // adds this callback into the disconnect bucket so it gets disconnected from parent
5775
- // the the element hosting the wire is disconnected
5776
- shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
5777
- }
5778
- });
5779
- dispatchEvent(elm, contextRegistrationEvent);
5780
- });
5781
6248
  }
5782
- function createConnector(vm, name, wireDef) {
5783
- const {
5784
- method,
5785
- adapter,
5786
- configCallback,
5787
- dynamic
5788
- } = wireDef;
5789
- let debugInfo;
5790
- if (process.env.NODE_ENV !== 'production') {
5791
- const wiredPropOrMethod = shared.isUndefined(method) ? name : method.name;
5792
- debugInfo = shared.create(null);
5793
- debugInfo.wasDataProvisionedForConfig = false;
5794
- vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
5795
- }
5796
- const fieldOrMethodCallback = shared.isUndefined(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
5797
- const dataCallback = value => {
5798
- if (process.env.NODE_ENV !== 'production') {
5799
- debugInfo.data = value;
5800
- // Note: most of the time, the data provided is for the current config, but there may be
5801
- // some conditions in which it does not, ex:
5802
- // race conditions in a poor network while the adapter does not cancel a previous request.
5803
- debugInfo.wasDataProvisionedForConfig = true;
6249
+ let enabled = false;
6250
+ // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
6251
+ // reporting is not enabled. It should also only run once
6252
+ function enableDetection() {
6253
+ if (enabled) {
6254
+ return; // don't double-apply the patches
5804
6255
  }
5805
- fieldOrMethodCallback(value);
5806
- };
5807
- let context;
5808
- let connector;
5809
- // Workaround to pass the component element associated to this wire adapter instance.
5810
- shared.defineProperty(dataCallback, DeprecatedWiredElementHost, {
5811
- value: vm.elm
5812
- });
5813
- shared.defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
5814
- value: dynamic
5815
- });
5816
- runWithBoundaryProtection(vm, vm, shared.noop, () => {
5817
- // job
5818
- connector = new adapter(dataCallback);
5819
- }, shared.noop);
5820
- const updateConnectorConfig = config => {
5821
- // every time the config is recomputed due to tracking,
5822
- // this callback will be invoked with the new computed config
5823
- runWithBoundaryProtection(vm, vm, shared.noop, () => {
5824
- // job
5825
- if (process.env.NODE_ENV !== 'production') {
5826
- debugInfo.config = config;
5827
- debugInfo.context = context;
5828
- debugInfo.wasDataProvisionedForConfig = false;
5829
- }
5830
- connector.update(config, context);
5831
- }, shared.noop);
5832
- };
5833
- // Computes the current wire config and calls the update method on the wire adapter.
5834
- // If it has params, we will need to observe changes in the next tick.
5835
- const {
5836
- computeConfigAndUpdate,
5837
- ro
5838
- } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
5839
- // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
5840
- if (!shared.isUndefined(adapter.contextSchema)) {
5841
- createContextWatcher(vm, wireDef, newContext => {
5842
- // every time the context is pushed into this component,
5843
- // this callback will be invoked with the new computed context
5844
- if (context !== newContext) {
5845
- context = newContext;
5846
- // Note: when new context arrives, the config will be recomputed and pushed along side the new
5847
- // context, this is to preserve the identity characteristics, config should not have identity
5848
- // (ever), while context can have identity
5849
- if (vm.state === 1 /* VMState.connected */) {
5850
- computeConfigAndUpdate();
5851
- }
5852
- }
6256
+ enabled = true;
6257
+ const { setAttribute } = Element.prototype;
6258
+ // Detect calling `setAttribute` to set an idref or an id
6259
+ shared.assign(Element.prototype, {
6260
+ setAttribute(attrName, attrValue) {
6261
+ setAttribute.call(this, attrName, attrValue);
6262
+ if (attrName === 'id' || shared.ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
6263
+ detectSyntheticCrossRootAria(this, attrName, attrValue);
6264
+ }
6265
+ },
5853
6266
  });
5854
- }
5855
- return {
5856
- // @ts-ignore the boundary protection executes sync, connector is always defined
5857
- connector,
5858
- computeConfigAndUpdate,
5859
- resetConfigWatcher: () => ro.reset()
5860
- };
5861
- }
5862
- const AdapterToTokenMap = new Map();
5863
- function getAdapterToken(adapter) {
5864
- return AdapterToTokenMap.get(adapter);
5865
- }
5866
- function setAdapterToken(adapter, token) {
5867
- AdapterToTokenMap.set(adapter, token);
6267
+ // Detect `elm.id = 'foo'`
6268
+ const idDescriptor = shared.getOwnPropertyDescriptor(Element.prototype, 'id');
6269
+ if (!shared.isUndefined(idDescriptor)) {
6270
+ const { get, set } = idDescriptor;
6271
+ // These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
6272
+ if (shared.isFunction(get) && shared.isFunction(set)) {
6273
+ shared.defineProperty(Element.prototype, 'id', {
6274
+ get() {
6275
+ return get.call(this);
6276
+ },
6277
+ set(value) {
6278
+ set.call(this, value);
6279
+ detectSyntheticCrossRootAria(this, 'id', value);
6280
+ },
6281
+ // On the default descriptor for 'id', enumerable and configurable are true
6282
+ enumerable: true,
6283
+ configurable: true,
6284
+ });
6285
+ }
6286
+ }
5868
6287
  }
5869
- function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
5870
- // support for callable adapters
5871
- if (adapter.adapter) {
5872
- adapter = adapter.adapter;
5873
- }
5874
- const method = descriptor.value;
5875
- const def = {
5876
- adapter,
5877
- method,
5878
- configCallback,
5879
- dynamic
5880
- };
5881
- WireMetaMap.set(descriptor, def);
6288
+ // Our detection logic relies on some modern browser features. We can just skip reporting the data
6289
+ // for unsupported browsers
6290
+ function supportsCssEscape() {
6291
+ return typeof CSS !== 'undefined' && shared.isFunction(CSS.escape);
5882
6292
  }
5883
- function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
5884
- // support for callable adapters
5885
- if (adapter.adapter) {
5886
- adapter = adapter.adapter;
5887
- }
5888
- const def = {
5889
- adapter,
5890
- configCallback,
5891
- dynamic
5892
- };
5893
- WireMetaMap.set(descriptor, def);
6293
+ // If this page is not using synthetic shadow, then we don't need to install detection. Note
6294
+ // that we are assuming synthetic shadow is loaded before LWC.
6295
+ function isSyntheticShadowLoaded() {
6296
+ // We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
6297
+ // and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
6298
+ return shared.hasOwnProperty.call(Element.prototype, shared.KEY__SHADOW_TOKEN);
5894
6299
  }
5895
- function installWireAdapters(vm) {
5896
- const {
5897
- context,
5898
- def: {
5899
- wire
5900
- }
5901
- } = vm;
5902
- if (process.env.NODE_ENV !== 'production') {
5903
- vm.debugInfo[WIRE_DEBUG_ENTRY] = shared.create(null);
5904
- }
5905
- const wiredConnecting = context.wiredConnecting = [];
5906
- const wiredDisconnecting = context.wiredDisconnecting = [];
5907
- for (const fieldNameOrMethod in wire) {
5908
- const descriptor = wire[fieldNameOrMethod];
5909
- const wireDef = WireMetaMap.get(descriptor);
6300
+ // Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
6301
+ if (process.env.IS_BROWSER && supportsCssEscape() && isSyntheticShadowLoaded()) {
6302
+ // Always run detection in dev mode, so we can at least print to the console
5910
6303
  if (process.env.NODE_ENV !== 'production') {
5911
- shared.assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
6304
+ enableDetection();
5912
6305
  }
5913
- if (!shared.isUndefined(wireDef)) {
5914
- const {
5915
- connector,
5916
- computeConfigAndUpdate,
5917
- resetConfigWatcher
5918
- } = createConnector(vm, fieldNameOrMethod, wireDef);
5919
- const hasDynamicParams = wireDef.dynamic.length > 0;
5920
- shared.ArrayPush.call(wiredConnecting, () => {
5921
- connector.connect();
5922
- if (!features.lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5923
- if (hasDynamicParams) {
5924
- Promise.resolve().then(computeConfigAndUpdate);
5925
- return;
5926
- }
5927
- }
5928
- computeConfigAndUpdate();
5929
- });
5930
- shared.ArrayPush.call(wiredDisconnecting, () => {
5931
- connector.disconnect();
5932
- resetConfigWatcher();
5933
- });
5934
- }
5935
- }
5936
- }
5937
- function connectWireAdapters(vm) {
5938
- const {
5939
- wiredConnecting
5940
- } = vm.context;
5941
- for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
5942
- wiredConnecting[i]();
5943
- }
5944
- }
5945
- function disconnectWireAdapters(vm) {
5946
- const {
5947
- wiredDisconnecting
5948
- } = vm.context;
5949
- runWithBoundaryProtection(vm, vm, shared.noop, () => {
5950
- // job
5951
- for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
5952
- wiredDisconnecting[i]();
6306
+ else {
6307
+ // In prod mode, only enable detection if reporting is enabled
6308
+ onReportingEnabled(enableDetection);
5953
6309
  }
5954
- }, shared.noop);
5955
6310
  }
5956
6311
 
5957
6312
  /*
@@ -6634,6 +6989,7 @@ Object.defineProperty(exports, 'setFeatureFlagForTest', {
6634
6989
  });
6635
6990
  exports.LightningElement = LightningElement;
6636
6991
  exports.__unstable__ProfilerControl = profilerControl;
6992
+ exports.__unstable__ReportingControl = reportingControl;
6637
6993
  exports.api = api$1;
6638
6994
  exports.connectRootElement = connectRootElement;
6639
6995
  exports.createContextProvider = createContextProvider;
@@ -6661,4 +7017,4 @@ exports.swapTemplate = swapTemplate;
6661
7017
  exports.track = track;
6662
7018
  exports.unwrap = unwrap;
6663
7019
  exports.wire = wire;
6664
- /* version: 2.33.0 */
7020
+ /* version: 2.35.0 */