@lwc/engine-core 8.1.0-alpha.5 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
- import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, ArrayFilter, isObject, toString as toString$1, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, isString, ArrayIndexOf, ArrayPop, isFalse, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, assert, freeze, KEY__SYNTHETIC_MODE, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArrayReverse, ArrayShift } from '@lwc/shared';
4
+ import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, ArrayFilter, isObject, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString as toString$1, isString, ArrayIndexOf, ArrayPop, isFalse, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, assert, freeze, KEY__SYNTHETIC_MODE, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArrayReverse, ArrayShift } from '@lwc/shared';
5
5
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
6
6
 
7
7
  /*
@@ -289,6 +289,26 @@ function shouldBeFormAssociated(Ctor) {
289
289
  const reactiveObserversToVMs = new WeakMap();
290
290
  const targetsToPropertyKeys = new WeakMap();
291
291
  let mutationLogs = [];
292
+ // Create a human-readable member access notation like `obj.foo` or `arr[1]`,
293
+ // handling edge cases like `obj[Symbol("bar")]` and `obj["spaces here"]`
294
+ function toPrettyMemberNotation(parent, child) {
295
+ if (isUndefined$1(parent)) {
296
+ // Bare prop, just stringify the child
297
+ return toString$1(child);
298
+ }
299
+ else if (!isString(child)) {
300
+ // Symbol/number, e.g. `obj[Symbol("foo")]` or `obj[1234]`
301
+ return `${toString$1(parent)}[${toString$1(child)}]`;
302
+ }
303
+ else if (/^\w+$/.test(child)) {
304
+ // Dot-notation-safe string, e.g. `obj.foo`
305
+ return `${toString$1(parent)}.${child}`;
306
+ }
307
+ else {
308
+ // Bracket-notation-requiring string, e.g. `obj["prop with spaces"]`
309
+ return `${toString$1(parent)}[${JSON.stringify(child)}]`;
310
+ }
311
+ }
292
312
  /**
293
313
  * Flush all the logs we've written so far and return the current logs.
294
314
  */
@@ -319,23 +339,7 @@ function logMutation(reactiveObserver, target, key) {
319
339
  }
320
340
  }
321
341
  else {
322
- const stringKey = toString$1(key);
323
- let prop;
324
- if (isUndefined$1(parentKey)) {
325
- prop = stringKey;
326
- }
327
- else if (!isString(key)) {
328
- // symbol/number, e.g. `obj[Symbol("foo")]` or `obj[1234]`
329
- prop = `${toString$1(parentKey)}[${stringKey}]`;
330
- }
331
- else if (/^\w+$/.test(stringKey)) {
332
- // Human-readable prop like `items[0].name` on a deep object/array
333
- prop = `${toString$1(parentKey)}.${stringKey}`;
334
- }
335
- else {
336
- // e.g. `obj["prop with spaces"]`
337
- prop = `${toString$1(parentKey)}[${JSON.stringify(stringKey)}]`;
338
- }
342
+ const prop = toPrettyMemberNotation(parentKey, key);
339
343
  ArrayPush$1.call(mutationLogs, { vm, prop });
340
344
  }
341
345
  }
@@ -373,7 +377,7 @@ function trackTargetForMutationLogging(key, target) {
373
377
  // Deeply traverse arrays and objects to track every object within
374
378
  if (isArray$1(target)) {
375
379
  for (let i = 0; i < target.length; i++) {
376
- trackTargetForMutationLogging(`${toString$1(key)}[${i}]`, target[i]);
380
+ trackTargetForMutationLogging(toPrettyMemberNotation(key, i), target[i]);
377
381
  }
378
382
  }
379
383
  else {
@@ -382,10 +386,10 @@ function trackTargetForMutationLogging(key, target) {
382
386
  // https://github.com/salesforce/observable-membrane/blob/b85417f/src/base-handler.ts#L142-L143
383
387
  // Note this code path is very hot, hence doing two separate for-loops rather than creating a new array.
384
388
  for (const prop of getOwnPropertyNames$1(target)) {
385
- trackTargetForMutationLogging(`${toString$1(key)}.${toString$1(prop)}`, target[prop]);
389
+ trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target[prop]);
386
390
  }
387
391
  for (const prop of getOwnPropertySymbols$1(target)) {
388
- trackTargetForMutationLogging(`${toString$1(key)}[${toString$1(prop)}]`, target[prop]);
392
+ trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target[prop]);
389
393
  }
390
394
  }
391
395
  }
@@ -8365,5 +8369,5 @@ function readonly(obj) {
8365
8369
  }
8366
8370
 
8367
8371
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8368
- /** version: 8.1.0-alpha.5 */
8372
+ /** version: 8.1.1 */
8369
8373
  //# sourceMappingURL=index.js.map