@smithers-orchestrator/devtools 0.20.3 → 0.20.4
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/package.json +1 -1
- package/src/diffSnapshots.js +4 -11
- package/src/snapshotSerializer.js +1 -10
package/package.json
CHANGED
package/src/diffSnapshots.js
CHANGED
|
@@ -181,25 +181,18 @@ export function diffSnapshots(a, b) {
|
|
|
181
181
|
.map((id) => ({ op: "removeNode", id }));
|
|
182
182
|
const topLevelAddIds = [...addSet].filter((id) => {
|
|
183
183
|
const parentId = to.get(id)?.parentId;
|
|
184
|
-
return parentId
|
|
184
|
+
return parentId !== null && !addSet.has(parentId);
|
|
185
185
|
});
|
|
186
186
|
/** @type {DevToolsDeltaOp[]} */
|
|
187
187
|
const addOps = topLevelAddIds
|
|
188
188
|
.sort((leftId, rightId) => (to.get(leftId)?.node.depth ?? 0) - (to.get(rightId)?.node.depth ?? 0))
|
|
189
189
|
.map((id) => {
|
|
190
190
|
const entry = to.get(id);
|
|
191
|
-
if (!entry || entry.parentId === null) {
|
|
192
|
-
return /** @type {DevToolsDeltaOp} */ ({
|
|
193
|
-
op: "updateProps",
|
|
194
|
-
id,
|
|
195
|
-
props: /** @type {Record<string, unknown>} */ (cloneValue(entry?.node.props ?? {})),
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
191
|
return /** @type {DevToolsDeltaOp} */ ({
|
|
199
192
|
op: "addNode",
|
|
200
|
-
parentId: entry
|
|
201
|
-
index: entry
|
|
202
|
-
node: /** @type {DevToolsNode} */ (cloneValue(entry
|
|
193
|
+
parentId: /** @type {number} */ (entry?.parentId),
|
|
194
|
+
index: entry?.index ?? 0,
|
|
195
|
+
node: /** @type {DevToolsNode} */ (cloneValue(entry?.node)),
|
|
203
196
|
});
|
|
204
197
|
});
|
|
205
198
|
return {
|
|
@@ -11,9 +11,6 @@ const SNAPSHOT_SERIALIZER_DEFAULT_MAX_ENTRIES = 100_000;
|
|
|
11
11
|
* @returns {value is Record<string, unknown>}
|
|
12
12
|
*/
|
|
13
13
|
function isPlainObject(value) {
|
|
14
|
-
if (!value || typeof value !== "object") {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
14
|
const proto = Object.getPrototypeOf(value);
|
|
18
15
|
return proto === Object.prototype || proto === null;
|
|
19
16
|
}
|
|
@@ -76,9 +73,6 @@ function serializeInternal(value, state, depth, path) {
|
|
|
76
73
|
? "[Date: Invalid]"
|
|
77
74
|
: `[Date: ${value.toISOString()}]`;
|
|
78
75
|
}
|
|
79
|
-
if (valueType !== "object") {
|
|
80
|
-
return String(value);
|
|
81
|
-
}
|
|
82
76
|
if (state.traversed >= state.maxEntries) {
|
|
83
77
|
warn("MaxEntriesExceeded", path, state.onWarning);
|
|
84
78
|
return "[MaxEntries]";
|
|
@@ -96,10 +90,7 @@ function serializeInternal(value, state, depth, path) {
|
|
|
96
90
|
}
|
|
97
91
|
if (!isPlainObject(value)) {
|
|
98
92
|
const ctorName = value.constructor?.name;
|
|
99
|
-
if (ctorName && ctorName !== "Object") {
|
|
100
|
-
warn("UnsupportedType", path, state.onWarning, ctorName);
|
|
101
|
-
return `[${ctorName}]`;
|
|
102
|
-
}
|
|
93
|
+
if (ctorName && ctorName !== "Object") return warn("UnsupportedType", path, state.onWarning, ctorName), `[${ctorName}]`;
|
|
103
94
|
}
|
|
104
95
|
/** @type {Record<string, unknown>} */
|
|
105
96
|
const out = {};
|