@lwc/engine-core 8.1.0-alpha.4 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +44 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +45 -25
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/advanced-mutation-tracker.d.ts +0 -7
- package/dist/framework/advanced-instrumentation.d.ts +0 -2
- package/dist/framework/advanced-mutation-tracker.d.ts +0 -7
- package/dist/framework/profiling/advanced-instrumentation.d.ts +0 -2
- package/dist/framework/profiling/advanced-mutation-tracker.d.ts +0 -7
package/dist/index.cjs.js
CHANGED
|
@@ -293,6 +293,26 @@ function shouldBeFormAssociated(Ctor) {
|
|
|
293
293
|
const reactiveObserversToVMs = new WeakMap();
|
|
294
294
|
const targetsToPropertyKeys = new WeakMap();
|
|
295
295
|
let mutationLogs = [];
|
|
296
|
+
// Create a human-readable member access notation like `obj.foo` or `arr[1]`,
|
|
297
|
+
// handling edge cases like `obj[Symbol("bar")]` and `obj["spaces here"]`
|
|
298
|
+
function toPrettyMemberNotation(parent, child) {
|
|
299
|
+
if (shared.isUndefined(parent)) {
|
|
300
|
+
// Bare prop, just stringify the child
|
|
301
|
+
return shared.toString(child);
|
|
302
|
+
}
|
|
303
|
+
else if (!shared.isString(child)) {
|
|
304
|
+
// Symbol/number, e.g. `obj[Symbol("foo")]` or `obj[1234]`
|
|
305
|
+
return `${shared.toString(parent)}[${shared.toString(child)}]`;
|
|
306
|
+
}
|
|
307
|
+
else if (/^\w+$/.test(child)) {
|
|
308
|
+
// Dot-notation-safe string, e.g. `obj.foo`
|
|
309
|
+
return `${shared.toString(parent)}.${child}`;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
// Bracket-notation-requiring string, e.g. `obj["prop with spaces"]`
|
|
313
|
+
return `${shared.toString(parent)}[${JSON.stringify(child)}]`;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
296
316
|
/**
|
|
297
317
|
* Flush all the logs we've written so far and return the current logs.
|
|
298
318
|
*/
|
|
@@ -323,23 +343,7 @@ function logMutation(reactiveObserver, target, key) {
|
|
|
323
343
|
}
|
|
324
344
|
}
|
|
325
345
|
else {
|
|
326
|
-
const
|
|
327
|
-
let prop;
|
|
328
|
-
if (shared.isUndefined(parentKey)) {
|
|
329
|
-
prop = stringKey;
|
|
330
|
-
}
|
|
331
|
-
else if (!shared.isString(key)) {
|
|
332
|
-
// symbol/number, e.g. `obj[Symbol("foo")]` or `obj[1234]`
|
|
333
|
-
prop = `${shared.toString(parentKey)}[${stringKey}]`;
|
|
334
|
-
}
|
|
335
|
-
else if (/^\w+$/.test(stringKey)) {
|
|
336
|
-
// Human-readable prop like `items[0].name` on a deep object/array
|
|
337
|
-
prop = `${shared.toString(parentKey)}.${stringKey}`;
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
// e.g. `obj["prop with spaces"]`
|
|
341
|
-
prop = `${shared.toString(parentKey)}[${JSON.stringify(stringKey)}]`;
|
|
342
|
-
}
|
|
346
|
+
const prop = toPrettyMemberNotation(parentKey, key);
|
|
343
347
|
shared.ArrayPush.call(mutationLogs, { vm, prop });
|
|
344
348
|
}
|
|
345
349
|
}
|
|
@@ -377,7 +381,7 @@ function trackTargetForMutationLogging(key, target) {
|
|
|
377
381
|
// Deeply traverse arrays and objects to track every object within
|
|
378
382
|
if (shared.isArray(target)) {
|
|
379
383
|
for (let i = 0; i < target.length; i++) {
|
|
380
|
-
trackTargetForMutationLogging(
|
|
384
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, i), target[i]);
|
|
381
385
|
}
|
|
382
386
|
}
|
|
383
387
|
else {
|
|
@@ -386,10 +390,10 @@ function trackTargetForMutationLogging(key, target) {
|
|
|
386
390
|
// https://github.com/salesforce/observable-membrane/blob/b85417f/src/base-handler.ts#L142-L143
|
|
387
391
|
// Note this code path is very hot, hence doing two separate for-loops rather than creating a new array.
|
|
388
392
|
for (const prop of shared.getOwnPropertyNames(target)) {
|
|
389
|
-
trackTargetForMutationLogging(
|
|
393
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target[prop]);
|
|
390
394
|
}
|
|
391
395
|
for (const prop of shared.getOwnPropertySymbols(target)) {
|
|
392
|
-
trackTargetForMutationLogging(
|
|
396
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target[prop]);
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
399
|
}
|
|
@@ -5902,6 +5906,22 @@ function getProperties(vm) {
|
|
|
5902
5906
|
['Shadow Mode', vm.shadowMode === 0 /* ShadowMode.Native */ ? 'native' : 'synthetic'],
|
|
5903
5907
|
];
|
|
5904
5908
|
}
|
|
5909
|
+
function getColor(opId) {
|
|
5910
|
+
// As of Sept 2024: primary (dark blue), secondary (light blue), tertiary (green)
|
|
5911
|
+
switch (opId) {
|
|
5912
|
+
// GlobalHydrate and Constructor tend to occur at the top level
|
|
5913
|
+
case 7 /* OperationId.GlobalHydrate */:
|
|
5914
|
+
case 0 /* OperationId.Constructor */:
|
|
5915
|
+
return 'primary';
|
|
5916
|
+
// GlobalRehydrate also occurs at the top level, but we want to use tertiary (green) because it's easier to
|
|
5917
|
+
// distinguish from primary, and at a glance you should be able to easily tell re-renders from first renders.
|
|
5918
|
+
case 8 /* OperationId.GlobalRehydrate */:
|
|
5919
|
+
return 'tertiary';
|
|
5920
|
+
// Everything else (patch/render/callbacks)
|
|
5921
|
+
default:
|
|
5922
|
+
return 'secondary';
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5905
5925
|
// Create a list of tag names to the properties that were mutated, to help answer the question of
|
|
5906
5926
|
// "why did this component re-render?"
|
|
5907
5927
|
function getMutationProperties(mutationLogs) {
|
|
@@ -5992,7 +6012,7 @@ function logOperationEnd(opId, vm) {
|
|
|
5992
6012
|
const markName = getMarkName(opId, vm);
|
|
5993
6013
|
const measureName = getMeasureName(opId, vm);
|
|
5994
6014
|
end(measureName, markName, {
|
|
5995
|
-
color: opId
|
|
6015
|
+
color: getColor(opId),
|
|
5996
6016
|
tooltipText: getTooltipText(measureName, opId),
|
|
5997
6017
|
properties: getProperties(vm),
|
|
5998
6018
|
});
|
|
@@ -6024,7 +6044,7 @@ function logGlobalOperationEnd(opId, mutationLogs) {
|
|
|
6024
6044
|
const opName = getOperationName(opId);
|
|
6025
6045
|
const markName = opName;
|
|
6026
6046
|
end(opName, markName, {
|
|
6027
|
-
color:
|
|
6047
|
+
color: getColor(opId),
|
|
6028
6048
|
tooltipText: getTooltipText(opName, opId),
|
|
6029
6049
|
properties: getMutationProperties(mutationLogs),
|
|
6030
6050
|
});
|
|
@@ -6038,7 +6058,7 @@ function logGlobalOperationEndWithVM(opId, vm) {
|
|
|
6038
6058
|
const opName = getOperationName(opId);
|
|
6039
6059
|
const markName = getMarkName(opId, vm);
|
|
6040
6060
|
end(opName, markName, {
|
|
6041
|
-
color:
|
|
6061
|
+
color: getColor(opId),
|
|
6042
6062
|
tooltipText: getTooltipText(opName, opId),
|
|
6043
6063
|
properties: getProperties(vm),
|
|
6044
6064
|
});
|
|
@@ -8396,5 +8416,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
8396
8416
|
exports.track = track;
|
|
8397
8417
|
exports.unwrap = unwrap;
|
|
8398
8418
|
exports.wire = wire;
|
|
8399
|
-
/** version: 8.1.0
|
|
8419
|
+
/** version: 8.1.0 */
|
|
8400
8420
|
//# sourceMappingURL=index.cjs.js.map
|