@tracecode/harness 0.5.0 → 0.5.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/LICENSE +67 -80
- package/README.md +2 -1
- package/dist/index.cjs +51 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -33
- package/dist/index.js.map +1 -1
- package/dist/javascript.cjs +37 -19
- package/dist/javascript.cjs.map +1 -1
- package/dist/javascript.js +37 -19
- package/dist/javascript.js.map +1 -1
- package/dist/python.cjs +14 -14
- package/dist/python.cjs.map +1 -1
- package/dist/python.d.cts +8 -8
- package/dist/python.d.ts +8 -8
- package/dist/python.js +14 -14
- package/dist/python.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1415,7 +1415,7 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
1415
1415
|
except TypeError:
|
|
1416
1416
|
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in obj]
|
|
1417
1417
|
return {"__type__": "set", "values": sorted_vals}
|
|
1418
|
-
elif (
|
|
1418
|
+
elif isinstance(obj, TreeNode):
|
|
1419
1419
|
obj_ref = id(obj)
|
|
1420
1420
|
if obj_ref in node_refs:
|
|
1421
1421
|
return {"__ref__": node_refs[obj_ref]}
|
|
@@ -1431,7 +1431,7 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
1431
1431
|
if hasattr(obj, 'right'):
|
|
1432
1432
|
result["right"] = _serialize(obj.right, depth + 1, node_refs)
|
|
1433
1433
|
return result
|
|
1434
|
-
elif (
|
|
1434
|
+
elif isinstance(obj, ListNode):
|
|
1435
1435
|
obj_ref = id(obj)
|
|
1436
1436
|
if obj_ref in node_refs:
|
|
1437
1437
|
return {"__ref__": node_refs[obj_ref]}
|
|
@@ -1509,14 +1509,14 @@ def _serialize(obj, depth=0):
|
|
|
1509
1509
|
return {"__type__": "set", "values": sorted([_serialize(x, depth + 1) for x in obj])}
|
|
1510
1510
|
except TypeError:
|
|
1511
1511
|
return {"__type__": "set", "values": [_serialize(x, depth + 1) for x in obj]}
|
|
1512
|
-
elif (
|
|
1512
|
+
elif isinstance(obj, TreeNode):
|
|
1513
1513
|
result = {"__type__": "TreeNode", "val": _serialize(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1)}
|
|
1514
1514
|
if hasattr(obj, 'left'):
|
|
1515
1515
|
result["left"] = _serialize(obj.left, depth + 1)
|
|
1516
1516
|
if hasattr(obj, 'right'):
|
|
1517
1517
|
result["right"] = _serialize(obj.right, depth + 1)
|
|
1518
1518
|
return result
|
|
1519
|
-
elif (
|
|
1519
|
+
elif isinstance(obj, ListNode):
|
|
1520
1520
|
result = {"__type__": "ListNode", "val": _serialize(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1)}
|
|
1521
1521
|
result["next"] = _serialize(obj.next, depth + 1)
|
|
1522
1522
|
return result
|
|
@@ -1591,14 +1591,14 @@ def _serialize(obj, depth=0):
|
|
|
1591
1591
|
return {"__type__": "set", "values": sorted([_serialize(x, depth + 1) for x in obj])}
|
|
1592
1592
|
except TypeError:
|
|
1593
1593
|
return {"__type__": "set", "values": [_serialize(x, depth + 1) for x in obj]}
|
|
1594
|
-
elif
|
|
1594
|
+
elif isinstance(obj, TreeNode):
|
|
1595
1595
|
result = {"__type__": "TreeNode", "val": _serialize(getattr(obj, 'val', None), depth + 1)}
|
|
1596
1596
|
if hasattr(obj, 'left'):
|
|
1597
1597
|
result["left"] = _serialize(obj.left, depth + 1)
|
|
1598
1598
|
if hasattr(obj, 'right'):
|
|
1599
1599
|
result["right"] = _serialize(obj.right, depth + 1)
|
|
1600
1600
|
return result
|
|
1601
|
-
elif
|
|
1601
|
+
elif isinstance(obj, ListNode):
|
|
1602
1602
|
result = {"__type__": "ListNode", "val": _serialize(getattr(obj, 'val', None), depth + 1)}
|
|
1603
1603
|
result["next"] = _serialize(obj.next, depth + 1)
|
|
1604
1604
|
return result
|
|
@@ -1630,14 +1630,14 @@ def _serialize(obj, depth=0):
|
|
|
1630
1630
|
return {"__type__": "set", "values": sorted([_serialize(x, depth + 1) for x in obj])}
|
|
1631
1631
|
except TypeError:
|
|
1632
1632
|
return {"__type__": "set", "values": [_serialize(x, depth + 1) for x in obj]}
|
|
1633
|
-
elif (
|
|
1633
|
+
elif isinstance(obj, TreeNode):
|
|
1634
1634
|
result = {"__type__": "TreeNode", "val": _serialize(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1)}
|
|
1635
1635
|
if hasattr(obj, 'left'):
|
|
1636
1636
|
result["left"] = _serialize(obj.left, depth + 1)
|
|
1637
1637
|
if hasattr(obj, 'right'):
|
|
1638
1638
|
result["right"] = _serialize(obj.right, depth + 1)
|
|
1639
1639
|
return result
|
|
1640
|
-
elif (
|
|
1640
|
+
elif isinstance(obj, ListNode):
|
|
1641
1641
|
result = {"__type__": "ListNode", "val": _serialize(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1)}
|
|
1642
1642
|
result["next"] = _serialize(obj.next, depth + 1)
|
|
1643
1643
|
return result
|
|
@@ -1865,7 +1865,7 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
1865
1865
|
except TypeError:
|
|
1866
1866
|
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in obj]
|
|
1867
1867
|
return {"__type__": "set", "values": sorted_vals}
|
|
1868
|
-
elif (
|
|
1868
|
+
elif isinstance(obj, TreeNode):
|
|
1869
1869
|
obj_ref = id(obj)
|
|
1870
1870
|
if obj_ref in node_refs:
|
|
1871
1871
|
return {"__ref__": node_refs[obj_ref]}
|
|
@@ -1881,7 +1881,7 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
1881
1881
|
if hasattr(obj, 'right'):
|
|
1882
1882
|
result["right"] = _serialize(obj.right, depth + 1, node_refs)
|
|
1883
1883
|
return result
|
|
1884
|
-
elif (
|
|
1884
|
+
elif isinstance(obj, ListNode):
|
|
1885
1885
|
obj_ref = id(obj)
|
|
1886
1886
|
if obj_ref in node_refs:
|
|
1887
1887
|
return {"__ref__": node_refs[obj_ref]}
|
|
@@ -1959,14 +1959,14 @@ def _serialize(obj, depth=0):
|
|
|
1959
1959
|
return {"__type__": "set", "values": sorted([_serialize(x, depth + 1) for x in obj])}
|
|
1960
1960
|
except TypeError:
|
|
1961
1961
|
return {"__type__": "set", "values": [_serialize(x, depth + 1) for x in obj]}
|
|
1962
|
-
elif (
|
|
1962
|
+
elif isinstance(obj, TreeNode):
|
|
1963
1963
|
result = {"__type__": "TreeNode", "val": _serialize(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1)}
|
|
1964
1964
|
if hasattr(obj, 'left'):
|
|
1965
1965
|
result["left"] = _serialize(obj.left, depth + 1)
|
|
1966
1966
|
if hasattr(obj, 'right'):
|
|
1967
1967
|
result["right"] = _serialize(obj.right, depth + 1)
|
|
1968
1968
|
return result
|
|
1969
|
-
elif (
|
|
1969
|
+
elif isinstance(obj, ListNode):
|
|
1970
1970
|
result = {"__type__": "ListNode", "val": _serialize(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1)}
|
|
1971
1971
|
result["next"] = _serialize(obj.next, depth + 1)
|
|
1972
1972
|
return result
|
|
@@ -2041,14 +2041,14 @@ def _serialize(obj, depth=0):
|
|
|
2041
2041
|
return {"__type__": "set", "values": sorted([_serialize(x, depth + 1) for x in obj])}
|
|
2042
2042
|
except TypeError:
|
|
2043
2043
|
return {"__type__": "set", "values": [_serialize(x, depth + 1) for x in obj]}
|
|
2044
|
-
elif
|
|
2044
|
+
elif isinstance(obj, TreeNode):
|
|
2045
2045
|
result = {"__type__": "TreeNode", "val": _serialize(getattr(obj, 'val', None), depth + 1)}
|
|
2046
2046
|
if hasattr(obj, 'left'):
|
|
2047
2047
|
result["left"] = _serialize(obj.left, depth + 1)
|
|
2048
2048
|
if hasattr(obj, 'right'):
|
|
2049
2049
|
result["right"] = _serialize(obj.right, depth + 1)
|
|
2050
2050
|
return result
|
|
2051
|
-
elif
|
|
2051
|
+
elif isinstance(obj, ListNode):
|
|
2052
2052
|
result = {"__type__": "ListNode", "val": _serialize(getattr(obj, 'val', None), depth + 1)}
|
|
2053
2053
|
result["next"] = _serialize(obj.next, depth + 1)
|
|
2054
2054
|
return result
|
|
@@ -2142,16 +2142,17 @@ function createConsoleProxy(output) {
|
|
|
2142
2142
|
}
|
|
2143
2143
|
function isLikelyTreeNodeValue(value) {
|
|
2144
2144
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2145
|
-
const
|
|
2146
|
-
|
|
2147
|
-
|
|
2145
|
+
const record = value;
|
|
2146
|
+
if (record.__type__ === "TreeNode") return true;
|
|
2147
|
+
const ctor = value.constructor;
|
|
2148
|
+
return ctor?.name === "TreeNode";
|
|
2148
2149
|
}
|
|
2149
2150
|
function isLikelyListNodeValue(value) {
|
|
2150
2151
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
const
|
|
2154
|
-
return
|
|
2152
|
+
const record = value;
|
|
2153
|
+
if (record.__type__ === "ListNode") return true;
|
|
2154
|
+
const ctor = value.constructor;
|
|
2155
|
+
return ctor?.name === "ListNode";
|
|
2155
2156
|
}
|
|
2156
2157
|
function getCustomClassName(value) {
|
|
2157
2158
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
@@ -2206,22 +2207,25 @@ function serializeValue(value, depth = 0, seen = /* @__PURE__ */ new WeakSet(),
|
|
|
2206
2207
|
const nodePrefix = isTree ? "tree" : "list";
|
|
2207
2208
|
const nodeId = `${nodePrefix}-${nodeRefState.nextId++}`;
|
|
2208
2209
|
nodeRefState.ids.set(objectValue, nodeId);
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
};
|
|
2217
|
-
}
|
|
2218
|
-
return {
|
|
2210
|
+
const out2 = isTree ? {
|
|
2211
|
+
__type__: "TreeNode",
|
|
2212
|
+
__id__: nodeId,
|
|
2213
|
+
val: serializeValue(nodeValue.val ?? nodeValue.value ?? null, depth + 1, seen, nodeRefState),
|
|
2214
|
+
left: serializeValue(nodeValue.left ?? null, depth + 1, seen, nodeRefState),
|
|
2215
|
+
right: serializeValue(nodeValue.right ?? null, depth + 1, seen, nodeRefState)
|
|
2216
|
+
} : {
|
|
2219
2217
|
__type__: "ListNode",
|
|
2220
2218
|
__id__: nodeId,
|
|
2221
2219
|
val: serializeValue(nodeValue.val ?? nodeValue.value ?? null, depth + 1, seen, nodeRefState),
|
|
2222
2220
|
next: serializeValue(nodeValue.next ?? null, depth + 1, seen, nodeRefState),
|
|
2223
2221
|
..."prev" in nodeValue ? { prev: serializeValue(nodeValue.prev ?? null, depth + 1, seen, nodeRefState) } : {}
|
|
2224
2222
|
};
|
|
2223
|
+
const skipped = isTree ? /* @__PURE__ */ new Set(["__id__", "__type__", "__class__", "val", "value", "left", "right"]) : /* @__PURE__ */ new Set(["__id__", "__type__", "__class__", "val", "value", "next", "prev"]);
|
|
2224
|
+
for (const [k, v] of Object.entries(nodeValue)) {
|
|
2225
|
+
if (skipped.has(k)) continue;
|
|
2226
|
+
out2[k] = serializeValue(v, depth + 1, seen, nodeRefState);
|
|
2227
|
+
}
|
|
2228
|
+
return out2;
|
|
2225
2229
|
}
|
|
2226
2230
|
const customClassName = getCustomClassName(value);
|
|
2227
2231
|
if (customClassName) {
|
|
@@ -2385,21 +2389,31 @@ function materializeTreeInput(value) {
|
|
|
2385
2389
|
}
|
|
2386
2390
|
const record = value;
|
|
2387
2391
|
if (isLikelyTreeNodeValue(record)) {
|
|
2388
|
-
|
|
2392
|
+
const node = {
|
|
2389
2393
|
val: record.val ?? record.value ?? null,
|
|
2390
2394
|
value: record.val ?? record.value ?? null,
|
|
2391
2395
|
left: materializeTreeInput(record.left ?? null),
|
|
2392
2396
|
right: materializeTreeInput(record.right ?? null)
|
|
2393
2397
|
};
|
|
2398
|
+
for (const [key, nested] of Object.entries(record)) {
|
|
2399
|
+
if (key === "__id__" || key === "__type__" || key === "val" || key === "value" || key === "left" || key === "right") continue;
|
|
2400
|
+
node[key] = materializeTreeInput(nested);
|
|
2401
|
+
}
|
|
2402
|
+
return node;
|
|
2394
2403
|
}
|
|
2395
2404
|
const taggedRecord = value;
|
|
2396
2405
|
if (taggedRecord.__type__ === "TreeNode") {
|
|
2397
|
-
|
|
2406
|
+
const node = {
|
|
2398
2407
|
val: taggedRecord.val ?? taggedRecord.value ?? null,
|
|
2399
2408
|
value: taggedRecord.val ?? taggedRecord.value ?? null,
|
|
2400
2409
|
left: materializeTreeInput(taggedRecord.left ?? null),
|
|
2401
2410
|
right: materializeTreeInput(taggedRecord.right ?? null)
|
|
2402
2411
|
};
|
|
2412
|
+
for (const [key, nested] of Object.entries(taggedRecord)) {
|
|
2413
|
+
if (key === "__id__" || key === "__type__" || key === "val" || key === "value" || key === "left" || key === "right") continue;
|
|
2414
|
+
node[key] = materializeTreeInput(nested);
|
|
2415
|
+
}
|
|
2416
|
+
return node;
|
|
2403
2417
|
}
|
|
2404
2418
|
return value;
|
|
2405
2419
|
}
|
|
@@ -2443,6 +2457,10 @@ function materializeListInput(value, refs = /* @__PURE__ */ new Map(), materiali
|
|
|
2443
2457
|
refs.set(taggedRecord.__id__, node);
|
|
2444
2458
|
}
|
|
2445
2459
|
node.next = materializeListInput(taggedRecord.next ?? null, refs, materialized);
|
|
2460
|
+
for (const [key, nested] of Object.entries(taggedRecord)) {
|
|
2461
|
+
if (key === "__id__" || key === "__type__" || key === "__class__" || key === "val" || key === "value" || key === "next") continue;
|
|
2462
|
+
node[key] = materializeListInput(nested, refs, materialized);
|
|
2463
|
+
}
|
|
2446
2464
|
return node;
|
|
2447
2465
|
}
|
|
2448
2466
|
return value;
|