@lwc/engine-core 2.34.0 → 2.35.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.
@@ -12,8 +12,7 @@ var ariaReflection = require('@lwc/aria-reflection');
12
12
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
13
13
  */
14
14
  // Only used in LWC's Karma tests
15
- // @ts-ignore
16
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
15
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
17
16
  window.addEventListener('test-dummy-flag', () => {
18
17
  let hasFlag = false;
19
18
  if (features.lwcRuntimeFlags.DUMMY_TEST_FLAG) {
@@ -34,94 +33,167 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
34
33
  * SPDX-License-Identifier: MIT
35
34
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
36
35
  */
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.`);
36
+ /** Callbacks to invoke when reporting is enabled **/
37
+ const onReportingEnabledCallbacks = [];
38
+ /** The currently assigned reporting dispatcher. */
39
+ let currentDispatcher$1 = shared.noop;
40
+ /**
41
+ * Whether reporting is enabled.
42
+ *
43
+ * Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
44
+ * but it turns out that Terser only strips out unused code if we use this explicit boolean.
45
+ */
46
+ let enabled$1 = false;
47
+ const reportingControl = {
48
+ /**
49
+ * Attach a new reporting control (aka dispatcher).
50
+ *
51
+ * @param dispatcher - reporting control
52
+ */
53
+ attachDispatcher(dispatcher) {
54
+ enabled$1 = true;
55
+ currentDispatcher$1 = dispatcher;
56
+ for (const callback of onReportingEnabledCallbacks) {
57
+ try {
58
+ callback();
59
+ }
60
+ catch (err) {
61
+ // This should never happen. But if it does, we don't want one callback to cause another to fail
62
+ // eslint-disable-next-line no-console
63
+ console.error('Could not invoke callback', err);
64
+ }
45
65
  }
66
+ onReportingEnabledCallbacks.length = 0; // clear the array
67
+ },
68
+ /**
69
+ * Detach the current reporting control (aka dispatcher).
70
+ */
71
+ detachDispatcher() {
72
+ enabled$1 = false;
73
+ currentDispatcher$1 = shared.noop;
74
+ },
75
+ };
76
+ /**
77
+ * Call a callback when reporting is enabled, or immediately if reporting is already enabled.
78
+ * Will only ever be called once.
79
+ * @param callback
80
+ */
81
+ function onReportingEnabled(callback) {
82
+ if (enabled$1) {
83
+ // call immediately
84
+ callback();
46
85
  }
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]();
86
+ else {
87
+ // call later
88
+ onReportingEnabledCallbacks.push(callback);
51
89
  }
52
90
  }
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);
91
+ /**
92
+ * Report to the current dispatcher, if there is one.
93
+ * @param reportingEventId
94
+ * @param vm
95
+ */
96
+ function report(reportingEventId, vm) {
97
+ if (enabled$1) {
98
+ currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
61
99
  }
62
- shared.ArrayPush.call(nextTickCallbackQueue, callback);
63
100
  }
64
- function guid() {
65
- function s4() {
66
- return Math.floor((1 + Math.random()) * 0x10000)
67
- .toString(16)
68
- .substring(1);
101
+
102
+ /*
103
+ * Copyright (c) 2018, salesforce.com, inc.
104
+ * All rights reserved.
105
+ * SPDX-License-Identifier: MIT
106
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
107
+ */
108
+ function getComponentTag(vm) {
109
+ return `<${shared.StringToLowerCase.call(vm.tagName)}>`;
110
+ }
111
+ // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
112
+ function getComponentStack(vm) {
113
+ const stack = [];
114
+ let prefix = '';
115
+ while (!shared.isNull(vm.owner)) {
116
+ shared.ArrayPush.call(stack, prefix + getComponentTag(vm));
117
+ vm = vm.owner;
118
+ prefix += '\t';
69
119
  }
70
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
120
+ return shared.ArrayJoin.call(stack, '\n');
71
121
  }
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
- }
122
+ function getErrorComponentStack(vm) {
123
+ const wcStack = [];
124
+ let currentVm = vm;
125
+ while (!shared.isNull(currentVm)) {
126
+ shared.ArrayPush.call(wcStack, getComponentTag(currentVm));
127
+ currentVm = currentVm.owner;
86
128
  }
87
- return styleMap;
129
+ return wcStack.reverse().join('\n\t');
88
130
  }
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
- }
131
+
132
+ /*
133
+ * Copyright (c) 2018, salesforce.com, inc.
134
+ * All rights reserved.
135
+ * SPDX-License-Identifier: MIT
136
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
137
+ */
138
+ function addErrorComponentStack(vm, error) {
139
+ if (!shared.isFrozen(error) && shared.isUndefined(error.wcStack)) {
140
+ const wcStack = getErrorComponentStack(vm);
141
+ shared.defineProperty(error, 'wcStack', {
142
+ get() {
143
+ return wcStack;
144
+ },
145
+ });
96
146
  }
97
- return result;
98
147
  }
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));
148
+
149
+ /*
150
+ * Copyright (c) 2018, salesforce.com, inc.
151
+ * All rights reserved.
152
+ * SPDX-License-Identifier: MIT
153
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
154
+ */
155
+ const alreadyLoggedMessages = new Set();
156
+ // Only used in LWC's Karma tests
157
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
158
+ // @ts-ignore
159
+ window.__lwcResetAlreadyLoggedMessages = () => {
160
+ alreadyLoggedMessages.clear();
161
+ };
162
+ }
163
+ function log(method, message, vm, once) {
164
+ let msg = `[LWC ${method}]: ${message}`;
165
+ if (!shared.isUndefined(vm)) {
166
+ msg = `${msg}\n${getComponentStack(vm)}`;
167
+ }
168
+ if (once) {
169
+ if (alreadyLoggedMessages.has(msg)) {
170
+ return;
107
171
  }
172
+ alreadyLoggedMessages.add(msg);
108
173
  }
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');
174
+ // In Jest tests, reduce the warning and error verbosity by not printing the callstack
175
+ if (process.env.NODE_ENV === 'test') {
176
+ /* eslint-disable-next-line no-console */
177
+ console[method](msg);
178
+ return;
115
179
  }
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;
180
+ try {
181
+ throw new Error(msg);
182
+ }
183
+ catch (e) {
184
+ /* eslint-disable-next-line no-console */
185
+ console[method](e);
123
186
  }
124
187
  }
188
+ function logError(message, vm) {
189
+ log('error', message, vm, false);
190
+ }
191
+ function logWarn(message, vm) {
192
+ log('warn', message, vm, false);
193
+ }
194
+ function logWarnOnce(message, vm) {
195
+ log('warn', message, vm, true);
196
+ }
125
197
 
126
198
  /*
127
199
  * Copyright (c) 2019, salesforce.com, inc.
@@ -257,80 +329,104 @@ function createReactiveObserver(callback) {
257
329
  * SPDX-License-Identifier: MIT
258
330
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
259
331
  */
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;
332
+ let nextTickCallbackQueue = [];
333
+ const SPACE_CHAR = 32;
334
+ const EmptyObject = shared.seal(shared.create(null));
335
+ const EmptyArray = shared.seal([]);
336
+ function flushCallbackQueue() {
337
+ if (process.env.NODE_ENV !== 'production') {
338
+ if (nextTickCallbackQueue.length === 0) {
339
+ throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
340
+ }
280
341
  }
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
- });
342
+ const callbacks = nextTickCallbackQueue;
343
+ nextTickCallbackQueue = []; // reset to a new queue
344
+ for (let i = 0, len = callbacks.length; i < len; i += 1) {
345
+ callbacks[i]();
298
346
  }
299
347
  }
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
- // In Jest tests, reduce the warning and error verbosity by not printing the callstack
313
- if (process.env.NODE_ENV === 'test') {
314
- /* eslint-disable-next-line no-console */
315
- console[method](msg);
316
- return;
317
- }
318
- try {
319
- throw new Error(msg);
348
+ function addCallbackToNextTick(callback) {
349
+ if (process.env.NODE_ENV !== 'production') {
350
+ if (!shared.isFunction(callback)) {
351
+ throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
352
+ }
320
353
  }
321
- catch (e) {
322
- /* eslint-disable-next-line no-console */
323
- console[method](e);
354
+ if (nextTickCallbackQueue.length === 0) {
355
+ Promise.resolve().then(flushCallbackQueue);
324
356
  }
357
+ shared.ArrayPush.call(nextTickCallbackQueue, callback);
325
358
  }
326
- function logError(message, vm) {
327
- log('error', message, vm);
328
- }
329
- function logWarn(message, vm) {
330
- log('warn', message, vm);
359
+ function guid() {
360
+ function s4() {
361
+ return Math.floor((1 + Math.random()) * 0x10000)
362
+ .toString(16)
363
+ .substring(1);
364
+ }
365
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
331
366
  }
332
-
333
- /*
367
+ // Borrowed from Vue template compiler.
368
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
369
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
370
+ const PROPERTY_DELIMITER = /:(.+)/;
371
+ function parseStyleText(cssText) {
372
+ const styleMap = {};
373
+ const declarations = cssText.split(DECLARATION_DELIMITER);
374
+ for (const declaration of declarations) {
375
+ if (declaration) {
376
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
377
+ if (prop !== undefined && value !== undefined) {
378
+ styleMap[prop.trim()] = value.trim();
379
+ }
380
+ }
381
+ }
382
+ return styleMap;
383
+ }
384
+ // Make a shallow copy of an object but omit the given key
385
+ function cloneAndOmitKey(object, keyToOmit) {
386
+ const result = {};
387
+ for (const key of Object.keys(object)) {
388
+ if (key !== keyToOmit) {
389
+ result[key] = object[key];
390
+ }
391
+ }
392
+ return result;
393
+ }
394
+ function flattenStylesheets(stylesheets) {
395
+ const list = [];
396
+ for (const stylesheet of stylesheets) {
397
+ if (!Array.isArray(stylesheet)) {
398
+ list.push(stylesheet);
399
+ }
400
+ else {
401
+ list.push(...flattenStylesheets(stylesheet));
402
+ }
403
+ }
404
+ return list;
405
+ }
406
+ // Set a ref (lwc:ref) on a VM, from a template API
407
+ function setRefVNode(vm, ref, vnode) {
408
+ if (process.env.NODE_ENV !== 'production' && shared.isUndefined(vm.refVNodes)) {
409
+ throw new Error('refVNodes must be defined when setting a ref');
410
+ }
411
+ // If this method is called, then vm.refVNodes is set as the template has refs.
412
+ // If not, then something went wrong and we threw an error above.
413
+ const refVNodes = vm.refVNodes;
414
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
415
+ // in depth-first traversal order.
416
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
417
+ refVNodes[ref] = vnode;
418
+ }
419
+ }
420
+ // Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
421
+ function assertNotProd() {
422
+ /* istanbul ignore if */
423
+ if (process.env.NODE_ENV === 'production') {
424
+ // this method should never leak to prod
425
+ throw new ReferenceError();
426
+ }
427
+ }
428
+
429
+ /*
334
430
  * Copyright (c) 2020, salesforce.com, inc.
335
431
  * All rights reserved.
336
432
  * SPDX-License-Identifier: MIT
@@ -382,7 +478,7 @@ function offsetPropertyErrorMessage(name) {
382
478
  //
383
479
  // If you update this list, check for test files that recapitulate the same list. Searching the codebase
384
480
  // for e.g. "dropzone" should suffice.
385
- const globalHTMLProperties = shared.assign(shared.create(null), {
481
+ const globalHTMLProperties = {
386
482
  accessKey: {
387
483
  attribute: 'accesskey',
388
484
  },
@@ -467,7 +563,7 @@ const globalHTMLProperties = shared.assign(shared.create(null), {
467
563
  role: {
468
564
  attribute: 'role',
469
565
  },
470
- });
566
+ };
471
567
  let controlledElement = null;
472
568
  let controlledAttributeName;
473
569
  function isAttributeLocked(elm, attrName) {
@@ -534,27 +630,18 @@ function generateAccessorDescriptor(options) {
534
630
  }
535
631
  let isDomMutationAllowed = false;
536
632
  function unlockDomMutation() {
537
- if (process.env.NODE_ENV === 'production') {
538
- // this method should never leak to prod
539
- throw new ReferenceError();
540
- }
633
+ assertNotProd(); // this method should never leak to prod
541
634
  isDomMutationAllowed = true;
542
635
  }
543
636
  function lockDomMutation() {
544
- if (process.env.NODE_ENV === 'production') {
545
- // this method should never leak to prod
546
- throw new ReferenceError();
547
- }
637
+ assertNotProd(); // this method should never leak to prod
548
638
  isDomMutationAllowed = false;
549
639
  }
550
640
  function logMissingPortalError(name, type) {
551
641
  return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
552
642
  }
553
643
  function patchElementWithRestrictions(elm, options) {
554
- if (process.env.NODE_ENV === 'production') {
555
- // this method should never leak to prod
556
- throw new ReferenceError();
557
- }
644
+ assertNotProd(); // this method should never leak to prod
558
645
  const originalOuterHTMLDescriptor = shared.getPropertyDescriptor(elm, 'outerHTML');
559
646
  const descriptors = {
560
647
  outerHTML: generateAccessorDescriptor({
@@ -635,10 +722,7 @@ function patchElementWithRestrictions(elm, options) {
635
722
  shared.defineProperties(elm, descriptors);
636
723
  }
637
724
  function getShadowRootRestrictionsDescriptors(sr) {
638
- if (process.env.NODE_ENV === 'production') {
639
- // this method should never leak to prod
640
- throw new ReferenceError();
641
- }
725
+ assertNotProd(); // this method should never leak to prod
642
726
  // Disallowing properties in dev mode only to avoid people doing the wrong
643
727
  // thing when using the real shadow root, because if that's the case,
644
728
  // the component will not work when running with synthetic shadow.
@@ -679,10 +763,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
679
763
  // Custom Elements Restrictions:
680
764
  // -----------------------------
681
765
  function getCustomElementRestrictionsDescriptors(elm) {
682
- if (process.env.NODE_ENV === 'production') {
683
- // this method should never leak to prod
684
- throw new ReferenceError();
685
- }
766
+ assertNotProd(); // this method should never leak to prod
686
767
  const originalAddEventListener = elm.addEventListener;
687
768
  const originalInnerHTMLDescriptor = shared.getPropertyDescriptor(elm, 'innerHTML');
688
769
  const originalOuterHTMLDescriptor = shared.getPropertyDescriptor(elm, 'outerHTML');
@@ -727,10 +808,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
727
808
  };
728
809
  }
729
810
  function getComponentRestrictionsDescriptors() {
730
- if (process.env.NODE_ENV === 'production') {
731
- // this method should never leak to prod
732
- throw new ReferenceError();
733
- }
811
+ assertNotProd(); // this method should never leak to prod
734
812
  return {
735
813
  tagName: generateAccessorDescriptor({
736
814
  get() {
@@ -744,10 +822,7 @@ function getComponentRestrictionsDescriptors() {
744
822
  };
745
823
  }
746
824
  function getLightningElementPrototypeRestrictionsDescriptors(proto) {
747
- if (process.env.NODE_ENV === 'production') {
748
- // this method should never leak to prod
749
- throw new ReferenceError();
750
- }
825
+ assertNotProd(); // this method should never leak to prod
751
826
  const originalDispatchEvent = proto.dispatchEvent;
752
827
  const descriptors = {
753
828
  dispatchEvent: generateDataDescriptor({
@@ -1461,7 +1536,6 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1461
1536
  }
1462
1537
  };
1463
1538
  }
1464
- const EMPTY_REFS = shared.freeze(shared.create(null));
1465
1539
  const refsCache = new WeakMap();
1466
1540
  /**
1467
1541
  * This class is the base class for any LWC element.
@@ -1749,7 +1823,6 @@ LightningElement.prototype = {
1749
1823
  }
1750
1824
  const {
1751
1825
  refVNodes,
1752
- hasRefVNodes,
1753
1826
  cmpTemplate
1754
1827
  } = vm;
1755
1828
  // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
@@ -1763,15 +1836,9 @@ LightningElement.prototype = {
1763
1836
  // were introduced, we return undefined if the template has no refs defined
1764
1837
  // anywhere. This fixes components that may want to add an expando called `refs`
1765
1838
  // and are checking if it exists with `if (this.refs)` before adding it.
1766
- // Note it is not sufficient to just check if `refVNodes` is null or empty,
1767
- // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1768
- if (!hasRefVNodes) {
1769
- return;
1770
- }
1771
- // For templates that are using `lwc:ref`, if there are no refs currently available
1772
- // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1839
+ // Note we use a null refVNodes to indicate that the template has no refs defined.
1773
1840
  if (shared.isNull(refVNodes)) {
1774
- return EMPTY_REFS;
1841
+ return;
1775
1842
  }
1776
1843
  // The refNodes can be cached based on the refVNodes, since the refVNodes
1777
1844
  // are recreated from scratch every time the template is rendered.
@@ -1931,109 +1998,286 @@ function createObservedFieldPropertyDescriptor(key) {
1931
1998
  * SPDX-License-Identifier: MIT
1932
1999
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1933
2000
  */
1934
- function api$1() {
1935
- if (process.env.NODE_ENV !== 'production') {
1936
- shared.assert.fail(`@api decorator can only be used as a decorator function.`);
1937
- }
1938
- throw new Error();
2001
+ const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
2002
+ const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
2003
+ const WIRE_DEBUG_ENTRY = '@wire';
2004
+ const WireMetaMap = new Map();
2005
+ class WireContextRegistrationEvent extends CustomEvent {
2006
+ constructor(adapterToken, {
2007
+ setNewContext,
2008
+ setDisconnectedCallback
2009
+ }) {
2010
+ super(adapterToken, {
2011
+ bubbles: true,
2012
+ composed: true
2013
+ });
2014
+ shared.defineProperties(this, {
2015
+ setNewContext: {
2016
+ value: setNewContext
2017
+ },
2018
+ setDisconnectedCallback: {
2019
+ value: setDisconnectedCallback
2020
+ }
2021
+ });
2022
+ }
1939
2023
  }
1940
- function createPublicPropertyDescriptor(key) {
1941
- return {
1942
- get() {
1943
- const vm = getAssociatedVM(this);
1944
- if (isBeingConstructed(vm)) {
1945
- if (process.env.NODE_ENV !== 'production') {
1946
- 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);
1947
- }
1948
- return;
1949
- }
1950
- componentValueObserved(vm, key);
1951
- return vm.cmpProps[key];
1952
- },
1953
- set(newValue) {
1954
- const vm = getAssociatedVM(this);
1955
- if (process.env.NODE_ENV !== 'production') {
1956
- const vmBeingRendered = getVMBeingRendered();
1957
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1958
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1959
- }
1960
- vm.cmpProps[key] = newValue;
1961
- componentValueMutated(vm, key);
1962
- },
1963
- enumerable: true,
1964
- configurable: true,
1965
- };
2024
+ function createFieldDataCallback(vm, name) {
2025
+ return value => {
2026
+ updateComponentValue(vm, name, value);
2027
+ };
1966
2028
  }
1967
- function createPublicAccessorDescriptor(key, descriptor) {
1968
- const { get, set, enumerable, configurable } = descriptor;
1969
- if (!shared.isFunction(get)) {
1970
- if (process.env.NODE_ENV !== 'production') {
1971
- shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
1972
- }
1973
- throw new Error();
2029
+ function createMethodDataCallback(vm, method) {
2030
+ return value => {
2031
+ // dispatching new value into the wired method
2032
+ runWithBoundaryProtection(vm, vm.owner, shared.noop, () => {
2033
+ // job
2034
+ method.call(vm.component, value);
2035
+ }, shared.noop);
2036
+ };
2037
+ }
2038
+ function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
2039
+ let hasPendingConfig = false;
2040
+ // creating the reactive observer for reactive params when needed
2041
+ const ro = createReactiveObserver(() => {
2042
+ if (hasPendingConfig === false) {
2043
+ hasPendingConfig = true;
2044
+ // collect new config in the micro-task
2045
+ Promise.resolve().then(() => {
2046
+ hasPendingConfig = false;
2047
+ // resetting current reactive params
2048
+ ro.reset();
2049
+ // dispatching a new config due to a change in the configuration
2050
+ computeConfigAndUpdate();
2051
+ });
1974
2052
  }
1975
- return {
1976
- get() {
1977
- if (process.env.NODE_ENV !== 'production') {
1978
- // Assert that the this value is an actual Component with an associated VM.
1979
- getAssociatedVM(this);
1980
- }
1981
- return get.call(this);
1982
- },
1983
- set(newValue) {
1984
- const vm = getAssociatedVM(this);
1985
- if (process.env.NODE_ENV !== 'production') {
1986
- const vmBeingRendered = getVMBeingRendered();
1987
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1988
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1989
- }
1990
- if (set) {
1991
- set.call(this, newValue);
1992
- }
1993
- else if (process.env.NODE_ENV !== 'production') {
1994
- 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.`);
1995
- }
1996
- },
1997
- enumerable,
1998
- configurable,
1999
- };
2053
+ });
2054
+ const computeConfigAndUpdate = () => {
2055
+ let config;
2056
+ ro.observe(() => config = configCallback(component));
2057
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2058
+ // TODO: dev-mode validation of config based on the adapter.configSchema
2059
+ // @ts-ignore it is assigned in the observe() callback
2060
+ callbackWhenConfigIsReady(config);
2061
+ };
2062
+ return {
2063
+ computeConfigAndUpdate,
2064
+ ro
2065
+ };
2000
2066
  }
2067
+ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
2068
+ const {
2069
+ adapter
2070
+ } = wireDef;
2071
+ const adapterContextToken = getAdapterToken(adapter);
2072
+ if (shared.isUndefined(adapterContextToken)) {
2073
+ return; // no provider found, nothing to be done
2074
+ }
2001
2075
 
2002
- /*
2003
- * Copyright (c) 2018, salesforce.com, inc.
2004
- * All rights reserved.
2005
- * SPDX-License-Identifier: MIT
2006
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2007
- */
2008
- function track(target) {
2009
- if (arguments.length === 1) {
2010
- return getReactiveProxy(target);
2011
- }
2012
- if (process.env.NODE_ENV !== 'production') {
2013
- shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2076
+ const {
2077
+ elm,
2078
+ context: {
2079
+ wiredConnecting,
2080
+ wiredDisconnecting
2081
+ },
2082
+ renderer: {
2083
+ dispatchEvent
2014
2084
  }
2015
- throw new Error();
2016
- }
2017
- function internalTrackDecorator(key) {
2018
- return {
2019
- get() {
2020
- const vm = getAssociatedVM(this);
2021
- componentValueObserved(vm, key);
2022
- return vm.cmpFields[key];
2023
- },
2024
- set(newValue) {
2025
- const vm = getAssociatedVM(this);
2026
- if (process.env.NODE_ENV !== 'production') {
2027
- const vmBeingRendered = getVMBeingRendered();
2028
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2029
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2030
- }
2031
- const reactiveOrAnyValue = getReactiveProxy(newValue);
2032
- updateComponentValue(vm, key, reactiveOrAnyValue);
2033
- },
2034
- enumerable: true,
2035
- configurable: true,
2036
- };
2085
+ } = vm;
2086
+ // waiting for the component to be connected to formally request the context via the token
2087
+ shared.ArrayPush.call(wiredConnecting, () => {
2088
+ // This event is responsible for connecting the host element with another
2089
+ // element in the composed path that is providing contextual data. The provider
2090
+ // must be listening for a special dom event with the name corresponding to the value of
2091
+ // `adapterContextToken`, which will remain secret and internal to this file only to
2092
+ // guarantee that the linkage can be forged.
2093
+ const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
2094
+ setNewContext(newContext) {
2095
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2096
+ // TODO: dev-mode validation of config based on the adapter.contextSchema
2097
+ callbackWhenContextIsReady(newContext);
2098
+ },
2099
+ setDisconnectedCallback(disconnectCallback) {
2100
+ // adds this callback into the disconnect bucket so it gets disconnected from parent
2101
+ // the the element hosting the wire is disconnected
2102
+ shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
2103
+ }
2104
+ });
2105
+ dispatchEvent(elm, contextRegistrationEvent);
2106
+ });
2107
+ }
2108
+ function createConnector(vm, name, wireDef) {
2109
+ const {
2110
+ method,
2111
+ adapter,
2112
+ configCallback,
2113
+ dynamic
2114
+ } = wireDef;
2115
+ let debugInfo;
2116
+ if (process.env.NODE_ENV !== 'production') {
2117
+ const wiredPropOrMethod = shared.isUndefined(method) ? name : method.name;
2118
+ debugInfo = shared.create(null);
2119
+ debugInfo.wasDataProvisionedForConfig = false;
2120
+ vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
2121
+ }
2122
+ const fieldOrMethodCallback = shared.isUndefined(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
2123
+ const dataCallback = value => {
2124
+ if (process.env.NODE_ENV !== 'production') {
2125
+ debugInfo.data = value;
2126
+ // Note: most of the time, the data provided is for the current config, but there may be
2127
+ // some conditions in which it does not, ex:
2128
+ // race conditions in a poor network while the adapter does not cancel a previous request.
2129
+ debugInfo.wasDataProvisionedForConfig = true;
2130
+ }
2131
+ fieldOrMethodCallback(value);
2132
+ };
2133
+ let context;
2134
+ let connector;
2135
+ // Workaround to pass the component element associated to this wire adapter instance.
2136
+ shared.defineProperty(dataCallback, DeprecatedWiredElementHost, {
2137
+ value: vm.elm
2138
+ });
2139
+ shared.defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
2140
+ value: dynamic
2141
+ });
2142
+ runWithBoundaryProtection(vm, vm, shared.noop, () => {
2143
+ // job
2144
+ connector = new adapter(dataCallback);
2145
+ }, shared.noop);
2146
+ const updateConnectorConfig = config => {
2147
+ // every time the config is recomputed due to tracking,
2148
+ // this callback will be invoked with the new computed config
2149
+ runWithBoundaryProtection(vm, vm, shared.noop, () => {
2150
+ // job
2151
+ if (process.env.NODE_ENV !== 'production') {
2152
+ debugInfo.config = config;
2153
+ debugInfo.context = context;
2154
+ debugInfo.wasDataProvisionedForConfig = false;
2155
+ }
2156
+ connector.update(config, context);
2157
+ }, shared.noop);
2158
+ };
2159
+ // Computes the current wire config and calls the update method on the wire adapter.
2160
+ // If it has params, we will need to observe changes in the next tick.
2161
+ const {
2162
+ computeConfigAndUpdate,
2163
+ ro
2164
+ } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
2165
+ // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
2166
+ if (!shared.isUndefined(adapter.contextSchema)) {
2167
+ createContextWatcher(vm, wireDef, newContext => {
2168
+ // every time the context is pushed into this component,
2169
+ // this callback will be invoked with the new computed context
2170
+ if (context !== newContext) {
2171
+ context = newContext;
2172
+ // Note: when new context arrives, the config will be recomputed and pushed along side the new
2173
+ // context, this is to preserve the identity characteristics, config should not have identity
2174
+ // (ever), while context can have identity
2175
+ if (vm.state === 1 /* VMState.connected */) {
2176
+ computeConfigAndUpdate();
2177
+ }
2178
+ }
2179
+ });
2180
+ }
2181
+ return {
2182
+ // @ts-ignore the boundary protection executes sync, connector is always defined
2183
+ connector,
2184
+ computeConfigAndUpdate,
2185
+ resetConfigWatcher: () => ro.reset()
2186
+ };
2187
+ }
2188
+ const AdapterToTokenMap = new Map();
2189
+ function getAdapterToken(adapter) {
2190
+ return AdapterToTokenMap.get(adapter);
2191
+ }
2192
+ function setAdapterToken(adapter, token) {
2193
+ AdapterToTokenMap.set(adapter, token);
2194
+ }
2195
+ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
2196
+ // support for callable adapters
2197
+ if (adapter.adapter) {
2198
+ adapter = adapter.adapter;
2199
+ }
2200
+ const method = descriptor.value;
2201
+ const def = {
2202
+ adapter,
2203
+ method,
2204
+ configCallback,
2205
+ dynamic
2206
+ };
2207
+ WireMetaMap.set(descriptor, def);
2208
+ }
2209
+ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
2210
+ // support for callable adapters
2211
+ if (adapter.adapter) {
2212
+ adapter = adapter.adapter;
2213
+ }
2214
+ const def = {
2215
+ adapter,
2216
+ configCallback,
2217
+ dynamic
2218
+ };
2219
+ WireMetaMap.set(descriptor, def);
2220
+ }
2221
+ function installWireAdapters(vm) {
2222
+ const {
2223
+ context,
2224
+ def: {
2225
+ wire
2226
+ }
2227
+ } = vm;
2228
+ if (process.env.NODE_ENV !== 'production') {
2229
+ vm.debugInfo[WIRE_DEBUG_ENTRY] = shared.create(null);
2230
+ }
2231
+ const wiredConnecting = context.wiredConnecting = [];
2232
+ const wiredDisconnecting = context.wiredDisconnecting = [];
2233
+ for (const fieldNameOrMethod in wire) {
2234
+ const descriptor = wire[fieldNameOrMethod];
2235
+ const wireDef = WireMetaMap.get(descriptor);
2236
+ if (process.env.NODE_ENV !== 'production') {
2237
+ shared.assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
2238
+ }
2239
+ if (!shared.isUndefined(wireDef)) {
2240
+ const {
2241
+ connector,
2242
+ computeConfigAndUpdate,
2243
+ resetConfigWatcher
2244
+ } = createConnector(vm, fieldNameOrMethod, wireDef);
2245
+ const hasDynamicParams = wireDef.dynamic.length > 0;
2246
+ shared.ArrayPush.call(wiredConnecting, () => {
2247
+ connector.connect();
2248
+ if (!features.lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
2249
+ if (hasDynamicParams) {
2250
+ Promise.resolve().then(computeConfigAndUpdate);
2251
+ return;
2252
+ }
2253
+ }
2254
+ computeConfigAndUpdate();
2255
+ });
2256
+ shared.ArrayPush.call(wiredDisconnecting, () => {
2257
+ connector.disconnect();
2258
+ resetConfigWatcher();
2259
+ });
2260
+ }
2261
+ }
2262
+ }
2263
+ function connectWireAdapters(vm) {
2264
+ const {
2265
+ wiredConnecting
2266
+ } = vm.context;
2267
+ for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
2268
+ wiredConnecting[i]();
2269
+ }
2270
+ }
2271
+ function disconnectWireAdapters(vm) {
2272
+ const {
2273
+ wiredDisconnecting
2274
+ } = vm.context;
2275
+ runWithBoundaryProtection(vm, vm, shared.noop, () => {
2276
+ // job
2277
+ for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
2278
+ wiredDisconnecting[i]();
2279
+ }
2280
+ }, shared.noop);
2037
2281
  }
2038
2282
 
2039
2283
  /*
@@ -2042,50 +2286,161 @@ function internalTrackDecorator(key) {
2042
2286
  * SPDX-License-Identifier: MIT
2043
2287
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2044
2288
  */
2045
- /**
2046
- * @wire decorator to wire fields and methods to a wire adapter in
2047
- * LWC Components. This function implements the internals of this
2048
- * decorator.
2049
- */
2050
- function wire(_adapter, _config) {
2289
+ function api$1() {
2051
2290
  if (process.env.NODE_ENV !== 'production') {
2052
- shared.assert.fail('@wire(adapter, config?) may only be used as a decorator.');
2291
+ shared.assert.fail(`@api decorator can only be used as a decorator function.`);
2053
2292
  }
2054
2293
  throw new Error();
2055
2294
  }
2056
- function internalWireFieldDecorator(key) {
2295
+ function createPublicPropertyDescriptor(key) {
2057
2296
  return {
2058
2297
  get() {
2059
2298
  const vm = getAssociatedVM(this);
2299
+ if (isBeingConstructed(vm)) {
2300
+ if (process.env.NODE_ENV !== 'production') {
2301
+ 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);
2302
+ }
2303
+ return;
2304
+ }
2060
2305
  componentValueObserved(vm, key);
2061
- return vm.cmpFields[key];
2306
+ return vm.cmpProps[key];
2062
2307
  },
2063
- set(value) {
2308
+ set(newValue) {
2064
2309
  const vm = getAssociatedVM(this);
2065
- /**
2066
- * Reactivity for wired fields is provided in wiring.
2067
- * We intentionally add reactivity here since this is just
2068
- * letting the author to do the wrong thing, but it will keep our
2069
- * system to be backward compatible.
2070
- */
2071
- updateComponentValue(vm, key, value);
2310
+ if (process.env.NODE_ENV !== 'production') {
2311
+ const vmBeingRendered = getVMBeingRendered();
2312
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2313
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2314
+ }
2315
+ vm.cmpProps[key] = newValue;
2316
+ componentValueMutated(vm, key);
2072
2317
  },
2073
2318
  enumerable: true,
2074
2319
  configurable: true,
2075
2320
  };
2076
2321
  }
2077
-
2078
- /*
2079
- * Copyright (c) 2018, salesforce.com, inc.
2080
- * All rights reserved.
2081
- * SPDX-License-Identifier: MIT
2082
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2083
- */
2084
- function getClassDescriptorType(descriptor) {
2085
- if (shared.isFunction(descriptor.value)) {
2086
- return "method" /* DescriptorType.Method */;
2087
- }
2088
- else if (shared.isFunction(descriptor.set) || shared.isFunction(descriptor.get)) {
2322
+ function createPublicAccessorDescriptor(key, descriptor) {
2323
+ const { get, set, enumerable, configurable } = descriptor;
2324
+ if (!shared.isFunction(get)) {
2325
+ if (process.env.NODE_ENV !== 'production') {
2326
+ shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
2327
+ }
2328
+ throw new Error();
2329
+ }
2330
+ return {
2331
+ get() {
2332
+ if (process.env.NODE_ENV !== 'production') {
2333
+ // Assert that the this value is an actual Component with an associated VM.
2334
+ getAssociatedVM(this);
2335
+ }
2336
+ return get.call(this);
2337
+ },
2338
+ set(newValue) {
2339
+ const vm = getAssociatedVM(this);
2340
+ if (process.env.NODE_ENV !== 'production') {
2341
+ const vmBeingRendered = getVMBeingRendered();
2342
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2343
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2344
+ }
2345
+ if (set) {
2346
+ set.call(this, newValue);
2347
+ }
2348
+ else if (process.env.NODE_ENV !== 'production') {
2349
+ 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.`);
2350
+ }
2351
+ },
2352
+ enumerable,
2353
+ configurable,
2354
+ };
2355
+ }
2356
+
2357
+ /*
2358
+ * Copyright (c) 2018, salesforce.com, inc.
2359
+ * All rights reserved.
2360
+ * SPDX-License-Identifier: MIT
2361
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2362
+ */
2363
+ function track(target) {
2364
+ if (arguments.length === 1) {
2365
+ return getReactiveProxy(target);
2366
+ }
2367
+ if (process.env.NODE_ENV !== 'production') {
2368
+ shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2369
+ }
2370
+ throw new Error();
2371
+ }
2372
+ function internalTrackDecorator(key) {
2373
+ return {
2374
+ get() {
2375
+ const vm = getAssociatedVM(this);
2376
+ componentValueObserved(vm, key);
2377
+ return vm.cmpFields[key];
2378
+ },
2379
+ set(newValue) {
2380
+ const vm = getAssociatedVM(this);
2381
+ if (process.env.NODE_ENV !== 'production') {
2382
+ const vmBeingRendered = getVMBeingRendered();
2383
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2384
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2385
+ }
2386
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2387
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2388
+ },
2389
+ enumerable: true,
2390
+ configurable: true,
2391
+ };
2392
+ }
2393
+
2394
+ /*
2395
+ * Copyright (c) 2018, salesforce.com, inc.
2396
+ * All rights reserved.
2397
+ * SPDX-License-Identifier: MIT
2398
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2399
+ */
2400
+ /**
2401
+ * @wire decorator to wire fields and methods to a wire adapter in
2402
+ * LWC Components. This function implements the internals of this
2403
+ * decorator.
2404
+ */
2405
+ function wire(_adapter, _config) {
2406
+ if (process.env.NODE_ENV !== 'production') {
2407
+ shared.assert.fail('@wire(adapter, config?) may only be used as a decorator.');
2408
+ }
2409
+ throw new Error();
2410
+ }
2411
+ function internalWireFieldDecorator(key) {
2412
+ return {
2413
+ get() {
2414
+ const vm = getAssociatedVM(this);
2415
+ componentValueObserved(vm, key);
2416
+ return vm.cmpFields[key];
2417
+ },
2418
+ set(value) {
2419
+ const vm = getAssociatedVM(this);
2420
+ /**
2421
+ * Reactivity for wired fields is provided in wiring.
2422
+ * We intentionally add reactivity here since this is just
2423
+ * letting the author to do the wrong thing, but it will keep our
2424
+ * system to be backward compatible.
2425
+ */
2426
+ updateComponentValue(vm, key, value);
2427
+ },
2428
+ enumerable: true,
2429
+ configurable: true,
2430
+ };
2431
+ }
2432
+
2433
+ /*
2434
+ * Copyright (c) 2018, salesforce.com, inc.
2435
+ * All rights reserved.
2436
+ * SPDX-License-Identifier: MIT
2437
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2438
+ */
2439
+ function getClassDescriptorType(descriptor) {
2440
+ if (shared.isFunction(descriptor.value)) {
2441
+ return "method" /* DescriptorType.Method */;
2442
+ }
2443
+ else if (shared.isFunction(descriptor.set) || shared.isFunction(descriptor.get)) {
2089
2444
  return "accessor" /* DescriptorType.Accessor */;
2090
2445
  }
2091
2446
  else {
@@ -2300,8 +2655,8 @@ function getDecoratorsMeta(Ctor) {
2300
2655
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2301
2656
  */
2302
2657
  let warned = false;
2303
- // @ts-ignore
2304
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
2658
+ // Only used in LWC's Karma tests
2659
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
2305
2660
  // @ts-ignore
2306
2661
  window.__lwcResetWarnedOnVersionMismatch = () => {
2307
2662
  warned = false;
@@ -2597,10 +2952,7 @@ function rehydrateHotComponent(Ctor) {
2597
2952
  return canRefreshAllInstances;
2598
2953
  }
2599
2954
  function getTemplateOrSwappedTemplate(tpl) {
2600
- if (process.env.NODE_ENV === 'production') {
2601
- // this method should never leak to prod
2602
- throw new ReferenceError();
2603
- }
2955
+ assertNotProd(); // this method should never leak to prod
2604
2956
  const visited = new Set();
2605
2957
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
2606
2958
  visited.add(tpl);
@@ -2609,10 +2961,7 @@ function getTemplateOrSwappedTemplate(tpl) {
2609
2961
  return tpl;
2610
2962
  }
2611
2963
  function getComponentOrSwappedComponent(Ctor) {
2612
- if (process.env.NODE_ENV === 'production') {
2613
- // this method should never leak to prod
2614
- throw new ReferenceError();
2615
- }
2964
+ assertNotProd(); // this method should never leak to prod
2616
2965
  const visited = new Set();
2617
2966
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
2618
2967
  visited.add(Ctor);
@@ -2621,10 +2970,7 @@ function getComponentOrSwappedComponent(Ctor) {
2621
2970
  return Ctor;
2622
2971
  }
2623
2972
  function getStyleOrSwappedStyle(style) {
2624
- if (process.env.NODE_ENV === 'production') {
2625
- // this method should never leak to prod
2626
- throw new ReferenceError();
2627
- }
2973
+ assertNotProd(); // this method should never leak to prod
2628
2974
  const visited = new Set();
2629
2975
  while (swappedStyleMap.has(style) && !visited.has(style)) {
2630
2976
  visited.add(style);
@@ -2633,10 +2979,7 @@ function getStyleOrSwappedStyle(style) {
2633
2979
  return style;
2634
2980
  }
2635
2981
  function setActiveVM(vm) {
2636
- if (process.env.NODE_ENV === 'production') {
2637
- // this method should never leak to prod
2638
- throw new ReferenceError();
2639
- }
2982
+ assertNotProd(); // this method should never leak to prod
2640
2983
  // tracking active component
2641
2984
  const Ctor = vm.def.ctor;
2642
2985
  let componentVMs = activeComponents.get(Ctor);
@@ -2679,10 +3022,7 @@ function setActiveVM(vm) {
2679
3022
  }
2680
3023
  }
2681
3024
  function removeActiveVM(vm) {
2682
- if (process.env.NODE_ENV === 'production') {
2683
- // this method should never leak to prod
2684
- throw new ReferenceError();
2685
- }
3025
+ assertNotProd(); // this method should never leak to prod
2686
3026
  // tracking inactive component
2687
3027
  const Ctor = vm.def.ctor;
2688
3028
  let list = activeComponents.get(Ctor);
@@ -4859,10 +5199,7 @@ function setVMBeingRendered(vm) {
4859
5199
  vmBeingRendered = vm;
4860
5200
  }
4861
5201
  function validateSlots(vm, html) {
4862
- if (process.env.NODE_ENV === 'production') {
4863
- // this method should never leak to prod
4864
- throw new ReferenceError();
4865
- }
5202
+ assertNotProd(); // this method should never leak to prod
4866
5203
  const { cmpSlots } = vm;
4867
5204
  const { slots = EmptyArray } = html;
4868
5205
  for (const slotName in cmpSlots.slotAssignments) {
@@ -4996,9 +5333,7 @@ function evaluateTemplate(vm, html) {
4996
5333
  setActiveVM(vm);
4997
5334
  }
4998
5335
  // reset the refs; they will be set during the tmpl() instantiation
4999
- const hasRefVNodes = Boolean(html.hasRefs);
5000
- vm.hasRefVNodes = hasRefVNodes;
5001
- vm.refVNodes = hasRefVNodes ? shared.create(null) : null;
5336
+ vm.refVNodes = html.hasRefs ? shared.create(null) : null;
5002
5337
  // right before producing the vnodes, we clear up all internal references
5003
5338
  // to custom elements from the template.
5004
5339
  vm.velements = [];
@@ -5185,7 +5520,7 @@ function markComponentAsDirty(vm) {
5185
5520
  const cmpEventListenerMap = new WeakMap();
5186
5521
  function getWrappedComponentsListener(vm, listener) {
5187
5522
  if (!shared.isFunction(listener)) {
5188
- throw new TypeError(); // avoiding problems with non-valid listeners
5523
+ throw new TypeError('Expected an EventListener but received ' + typeof listener); // avoiding problems with non-valid listeners
5189
5524
  }
5190
5525
  let wrappedListener = cmpEventListenerMap.get(listener);
5191
5526
  if (shared.isUndefined(wrappedListener)) {
@@ -5330,7 +5665,6 @@ function createVM(elm, ctor, renderer, options) {
5330
5665
  mode,
5331
5666
  owner,
5332
5667
  refVNodes: null,
5333
- hasRefVNodes: false,
5334
5668
  children: EmptyArray,
5335
5669
  aChildren: EmptyArray,
5336
5670
  velements: EmptyArray,
@@ -5793,286 +6127,143 @@ function forceRehydration(vm) {
5793
6127
  * SPDX-License-Identifier: MIT
5794
6128
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5795
6129
  */
5796
- const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
5797
- const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
5798
- const WIRE_DEBUG_ENTRY = '@wire';
5799
- const WireMetaMap = new Map();
5800
- class WireContextRegistrationEvent extends CustomEvent {
5801
- constructor(adapterToken, {
5802
- setNewContext,
5803
- setDisconnectedCallback
5804
- }) {
5805
- super(adapterToken, {
5806
- bubbles: true,
5807
- composed: true
5808
- });
5809
- shared.defineProperties(this, {
5810
- setNewContext: {
5811
- value: setNewContext
5812
- },
5813
- setDisconnectedCallback: {
5814
- value: setDisconnectedCallback
5815
- }
5816
- });
5817
- }
5818
- }
5819
- function createFieldDataCallback(vm, name) {
5820
- return value => {
5821
- updateComponentValue(vm, name, value);
5822
- };
6130
+ //
6131
+ // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
6132
+ // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
6133
+ // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
6134
+ // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
6135
+ //
6136
+ // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
6137
+ const getElementById = shared.globalThis[shared.KEY__NATIVE_GET_ELEMENT_BY_ID];
6138
+ const querySelectorAll = shared.globalThis[shared.KEY__NATIVE_QUERY_SELECTOR_ALL];
6139
+ function isSyntheticShadowRootInstance(rootNode) {
6140
+ return rootNode !== document && shared.isTrue(rootNode.synthetic);
6141
+ }
6142
+ function reportViolation(source, target, attrName) {
6143
+ // The vm is either for the source, the target, or both. Either one or both must be using synthetic
6144
+ // shadow for a violation to be detected.
6145
+ let vm = getAssociatedVMIfPresent(source.getRootNode().host);
6146
+ if (shared.isUndefined(vm)) {
6147
+ vm = getAssociatedVMIfPresent(target.getRootNode().host);
6148
+ }
6149
+ if (shared.isUndefined(vm)) {
6150
+ // vm should never be undefined here, but just to be safe, bail out and don't report
6151
+ return;
6152
+ }
6153
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
6154
+ if (process.env.NODE_ENV !== 'production') {
6155
+ // Avoid excessively logging to the console in the case of duplicates.
6156
+ logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
6157
+ `<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
6158
+ `For details, see: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates`, vm);
6159
+ }
5823
6160
  }
5824
- function createMethodDataCallback(vm, method) {
5825
- return value => {
5826
- // dispatching new value into the wired method
5827
- runWithBoundaryProtection(vm, vm.owner, shared.noop, () => {
5828
- // job
5829
- method.call(vm.component, value);
5830
- }, shared.noop);
5831
- };
6161
+ function parseIdRefAttributeValue(attrValue) {
6162
+ // split on whitespace and skip empty strings after splitting
6163
+ return shared.isString(attrValue) ? shared.ArrayFilter.call(shared.StringSplit.call(attrValue, /\s+/), Boolean) : [];
5832
6164
  }
5833
- function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
5834
- let hasPendingConfig = false;
5835
- // creating the reactive observer for reactive params when needed
5836
- const ro = createReactiveObserver(() => {
5837
- if (hasPendingConfig === false) {
5838
- hasPendingConfig = true;
5839
- // collect new config in the micro-task
5840
- Promise.resolve().then(() => {
5841
- hasPendingConfig = false;
5842
- // resetting current reactive params
5843
- ro.reset();
5844
- // dispatching a new config due to a change in the configuration
5845
- computeConfigAndUpdate();
5846
- });
6165
+ function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
6166
+ const root = elm.getRootNode();
6167
+ if (!isSyntheticShadowRootInstance(root)) {
6168
+ return;
5847
6169
  }
5848
- });
5849
- const computeConfigAndUpdate = () => {
5850
- let config;
5851
- ro.observe(() => config = configCallback(component));
5852
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
5853
- // TODO: dev-mode validation of config based on the adapter.configSchema
5854
- // @ts-ignore it is assigned in the observe() callback
5855
- callbackWhenConfigIsReady(config);
5856
- };
5857
- return {
5858
- computeConfigAndUpdate,
5859
- ro
5860
- };
5861
- }
5862
- function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
5863
- const {
5864
- adapter
5865
- } = wireDef;
5866
- const adapterContextToken = getAdapterToken(adapter);
5867
- if (shared.isUndefined(adapterContextToken)) {
5868
- return; // no provider found, nothing to be done
5869
- }
5870
-
5871
- const {
5872
- elm,
5873
- context: {
5874
- wiredConnecting,
5875
- wiredDisconnecting
5876
- },
5877
- renderer: {
5878
- dispatchEvent
6170
+ if (attrName === 'id') {
6171
+ // elm is the target, find the source
6172
+ if (!shared.isString(attrValue) || attrValue.length === 0) {
6173
+ // if our id is null or empty, nobody can reference us
6174
+ return;
6175
+ }
6176
+ for (const idRefAttrName of shared.ID_REFERENCING_ATTRIBUTES_SET) {
6177
+ // Query all global elements with this attribute. The attribute selector syntax `~=` is for values
6178
+ // that reference multiple IDs, separated by whitespace.
6179
+ const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
6180
+ const sourceElements = querySelectorAll.call(document, query);
6181
+ for (let i = 0; i < sourceElements.length; i++) {
6182
+ const sourceElement = sourceElements[i];
6183
+ const sourceRoot = sourceElement.getRootNode();
6184
+ if (sourceRoot !== root) {
6185
+ reportViolation(sourceElement, elm, idRefAttrName);
6186
+ break;
6187
+ }
6188
+ }
6189
+ }
6190
+ }
6191
+ else {
6192
+ // elm is the source, find the target
6193
+ const ids = parseIdRefAttributeValue(attrValue);
6194
+ for (const id of ids) {
6195
+ const target = getElementById.call(document, id);
6196
+ if (!shared.isNull(target)) {
6197
+ const targetRoot = target.getRootNode();
6198
+ if (targetRoot !== root) {
6199
+ // target element's shadow root is not the same as ours
6200
+ reportViolation(elm, target, attrName);
6201
+ }
6202
+ }
6203
+ }
5879
6204
  }
5880
- } = vm;
5881
- // waiting for the component to be connected to formally request the context via the token
5882
- shared.ArrayPush.call(wiredConnecting, () => {
5883
- // This event is responsible for connecting the host element with another
5884
- // element in the composed path that is providing contextual data. The provider
5885
- // must be listening for a special dom event with the name corresponding to the value of
5886
- // `adapterContextToken`, which will remain secret and internal to this file only to
5887
- // guarantee that the linkage can be forged.
5888
- const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
5889
- setNewContext(newContext) {
5890
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
5891
- // TODO: dev-mode validation of config based on the adapter.contextSchema
5892
- callbackWhenContextIsReady(newContext);
5893
- },
5894
- setDisconnectedCallback(disconnectCallback) {
5895
- // adds this callback into the disconnect bucket so it gets disconnected from parent
5896
- // the the element hosting the wire is disconnected
5897
- shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
5898
- }
5899
- });
5900
- dispatchEvent(elm, contextRegistrationEvent);
5901
- });
5902
6205
  }
5903
- function createConnector(vm, name, wireDef) {
5904
- const {
5905
- method,
5906
- adapter,
5907
- configCallback,
5908
- dynamic
5909
- } = wireDef;
5910
- let debugInfo;
5911
- if (process.env.NODE_ENV !== 'production') {
5912
- const wiredPropOrMethod = shared.isUndefined(method) ? name : method.name;
5913
- debugInfo = shared.create(null);
5914
- debugInfo.wasDataProvisionedForConfig = false;
5915
- vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
5916
- }
5917
- const fieldOrMethodCallback = shared.isUndefined(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
5918
- const dataCallback = value => {
5919
- if (process.env.NODE_ENV !== 'production') {
5920
- debugInfo.data = value;
5921
- // Note: most of the time, the data provided is for the current config, but there may be
5922
- // some conditions in which it does not, ex:
5923
- // race conditions in a poor network while the adapter does not cancel a previous request.
5924
- debugInfo.wasDataProvisionedForConfig = true;
6206
+ let enabled = false;
6207
+ // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
6208
+ // reporting is not enabled. It should also only run once
6209
+ function enableDetection() {
6210
+ if (enabled) {
6211
+ return; // don't double-apply the patches
5925
6212
  }
5926
- fieldOrMethodCallback(value);
5927
- };
5928
- let context;
5929
- let connector;
5930
- // Workaround to pass the component element associated to this wire adapter instance.
5931
- shared.defineProperty(dataCallback, DeprecatedWiredElementHost, {
5932
- value: vm.elm
5933
- });
5934
- shared.defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
5935
- value: dynamic
5936
- });
5937
- runWithBoundaryProtection(vm, vm, shared.noop, () => {
5938
- // job
5939
- connector = new adapter(dataCallback);
5940
- }, shared.noop);
5941
- const updateConnectorConfig = config => {
5942
- // every time the config is recomputed due to tracking,
5943
- // this callback will be invoked with the new computed config
5944
- runWithBoundaryProtection(vm, vm, shared.noop, () => {
5945
- // job
5946
- if (process.env.NODE_ENV !== 'production') {
5947
- debugInfo.config = config;
5948
- debugInfo.context = context;
5949
- debugInfo.wasDataProvisionedForConfig = false;
5950
- }
5951
- connector.update(config, context);
5952
- }, shared.noop);
5953
- };
5954
- // Computes the current wire config and calls the update method on the wire adapter.
5955
- // If it has params, we will need to observe changes in the next tick.
5956
- const {
5957
- computeConfigAndUpdate,
5958
- ro
5959
- } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
5960
- // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
5961
- if (!shared.isUndefined(adapter.contextSchema)) {
5962
- createContextWatcher(vm, wireDef, newContext => {
5963
- // every time the context is pushed into this component,
5964
- // this callback will be invoked with the new computed context
5965
- if (context !== newContext) {
5966
- context = newContext;
5967
- // Note: when new context arrives, the config will be recomputed and pushed along side the new
5968
- // context, this is to preserve the identity characteristics, config should not have identity
5969
- // (ever), while context can have identity
5970
- if (vm.state === 1 /* VMState.connected */) {
5971
- computeConfigAndUpdate();
5972
- }
5973
- }
6213
+ enabled = true;
6214
+ const { setAttribute } = Element.prototype;
6215
+ // Detect calling `setAttribute` to set an idref or an id
6216
+ shared.assign(Element.prototype, {
6217
+ setAttribute(attrName, attrValue) {
6218
+ setAttribute.call(this, attrName, attrValue);
6219
+ if (attrName === 'id' || shared.ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
6220
+ detectSyntheticCrossRootAria(this, attrName, attrValue);
6221
+ }
6222
+ },
5974
6223
  });
5975
- }
5976
- return {
5977
- // @ts-ignore the boundary protection executes sync, connector is always defined
5978
- connector,
5979
- computeConfigAndUpdate,
5980
- resetConfigWatcher: () => ro.reset()
5981
- };
6224
+ // Detect `elm.id = 'foo'`
6225
+ const idDescriptor = shared.getOwnPropertyDescriptor(Element.prototype, 'id');
6226
+ if (!shared.isUndefined(idDescriptor)) {
6227
+ const { get, set } = idDescriptor;
6228
+ // These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
6229
+ if (shared.isFunction(get) && shared.isFunction(set)) {
6230
+ shared.defineProperty(Element.prototype, 'id', {
6231
+ get() {
6232
+ return get.call(this);
6233
+ },
6234
+ set(value) {
6235
+ set.call(this, value);
6236
+ detectSyntheticCrossRootAria(this, 'id', value);
6237
+ },
6238
+ // On the default descriptor for 'id', enumerable and configurable are true
6239
+ enumerable: true,
6240
+ configurable: true,
6241
+ });
6242
+ }
6243
+ }
5982
6244
  }
5983
- const AdapterToTokenMap = new Map();
5984
- function getAdapterToken(adapter) {
5985
- return AdapterToTokenMap.get(adapter);
6245
+ // Our detection logic relies on some modern browser features. We can just skip reporting the data
6246
+ // for unsupported browsers
6247
+ function supportsCssEscape() {
6248
+ return typeof CSS !== 'undefined' && shared.isFunction(CSS.escape);
5986
6249
  }
5987
- function setAdapterToken(adapter, token) {
5988
- AdapterToTokenMap.set(adapter, token);
6250
+ // If this page is not using synthetic shadow, then we don't need to install detection. Note
6251
+ // that we are assuming synthetic shadow is loaded before LWC.
6252
+ function isSyntheticShadowLoaded() {
6253
+ // We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
6254
+ // and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
6255
+ return shared.hasOwnProperty.call(Element.prototype, shared.KEY__SHADOW_TOKEN);
5989
6256
  }
5990
- function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
5991
- // support for callable adapters
5992
- if (adapter.adapter) {
5993
- adapter = adapter.adapter;
5994
- }
5995
- const method = descriptor.value;
5996
- const def = {
5997
- adapter,
5998
- method,
5999
- configCallback,
6000
- dynamic
6001
- };
6002
- WireMetaMap.set(descriptor, def);
6003
- }
6004
- function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
6005
- // support for callable adapters
6006
- if (adapter.adapter) {
6007
- adapter = adapter.adapter;
6008
- }
6009
- const def = {
6010
- adapter,
6011
- configCallback,
6012
- dynamic
6013
- };
6014
- WireMetaMap.set(descriptor, def);
6015
- }
6016
- function installWireAdapters(vm) {
6017
- const {
6018
- context,
6019
- def: {
6020
- wire
6021
- }
6022
- } = vm;
6023
- if (process.env.NODE_ENV !== 'production') {
6024
- vm.debugInfo[WIRE_DEBUG_ENTRY] = shared.create(null);
6025
- }
6026
- const wiredConnecting = context.wiredConnecting = [];
6027
- const wiredDisconnecting = context.wiredDisconnecting = [];
6028
- for (const fieldNameOrMethod in wire) {
6029
- const descriptor = wire[fieldNameOrMethod];
6030
- const wireDef = WireMetaMap.get(descriptor);
6257
+ // Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
6258
+ if (process.env.IS_BROWSER && supportsCssEscape() && isSyntheticShadowLoaded()) {
6259
+ // Always run detection in dev mode, so we can at least print to the console
6031
6260
  if (process.env.NODE_ENV !== 'production') {
6032
- shared.assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
6261
+ enableDetection();
6033
6262
  }
6034
- if (!shared.isUndefined(wireDef)) {
6035
- const {
6036
- connector,
6037
- computeConfigAndUpdate,
6038
- resetConfigWatcher
6039
- } = createConnector(vm, fieldNameOrMethod, wireDef);
6040
- const hasDynamicParams = wireDef.dynamic.length > 0;
6041
- shared.ArrayPush.call(wiredConnecting, () => {
6042
- connector.connect();
6043
- if (!features.lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6044
- if (hasDynamicParams) {
6045
- Promise.resolve().then(computeConfigAndUpdate);
6046
- return;
6047
- }
6048
- }
6049
- computeConfigAndUpdate();
6050
- });
6051
- shared.ArrayPush.call(wiredDisconnecting, () => {
6052
- connector.disconnect();
6053
- resetConfigWatcher();
6054
- });
6055
- }
6056
- }
6057
- }
6058
- function connectWireAdapters(vm) {
6059
- const {
6060
- wiredConnecting
6061
- } = vm.context;
6062
- for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
6063
- wiredConnecting[i]();
6064
- }
6065
- }
6066
- function disconnectWireAdapters(vm) {
6067
- const {
6068
- wiredDisconnecting
6069
- } = vm.context;
6070
- runWithBoundaryProtection(vm, vm, shared.noop, () => {
6071
- // job
6072
- for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
6073
- wiredDisconnecting[i]();
6263
+ else {
6264
+ // In prod mode, only enable detection if reporting is enabled
6265
+ onReportingEnabled(enableDetection);
6074
6266
  }
6075
- }, shared.noop);
6076
6267
  }
6077
6268
 
6078
6269
  /*
@@ -6755,6 +6946,7 @@ Object.defineProperty(exports, 'setFeatureFlagForTest', {
6755
6946
  });
6756
6947
  exports.LightningElement = LightningElement;
6757
6948
  exports.__unstable__ProfilerControl = profilerControl;
6949
+ exports.__unstable__ReportingControl = reportingControl;
6758
6950
  exports.api = api$1;
6759
6951
  exports.connectRootElement = connectRootElement;
6760
6952
  exports.createContextProvider = createContextProvider;
@@ -6782,4 +6974,4 @@ exports.swapTemplate = swapTemplate;
6782
6974
  exports.track = track;
6783
6975
  exports.unwrap = unwrap;
6784
6976
  exports.wire = wire;
6785
- /* version: 2.34.0 */
6977
+ /* version: 2.35.1 */