@valerypopoff/rivet2-core 2.28.0 → 2.29.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/cjs/bundle.cjs +54 -12
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/utils/projectComparison/graphs.js +2 -2
- package/dist/esm/utils/projectComparison/identity.js +23 -0
- package/dist/esm/utils/projectComparison/nodes.js +10 -3
- package/dist/esm/utils/projectComparison.js +14 -6
- package/dist/types/utils/projectComparison/graphs.d.ts +2 -1
- package/dist/types/utils/projectComparison/identity.d.ts +11 -0
- package/dist/types/utils/projectComparison/nodes.d.ts +2 -1
- package/dist/types/utils/projectComparison.d.ts +4 -1
- package/package.json +1 -1
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -6311,6 +6311,26 @@ function compareConnections(beforeConnections, afterConnections) {
|
|
|
6311
6311
|
);
|
|
6312
6312
|
}
|
|
6313
6313
|
|
|
6314
|
+
// src/utils/projectComparison/identity.ts
|
|
6315
|
+
function comparisonProjectIdentity(id, side, identity) {
|
|
6316
|
+
const index = identity.pairs.findIndex((p) => (side === "before" ? p.beforeProjectId : p.afterProjectId) === id);
|
|
6317
|
+
return JSON.stringify(index < 0 ? ["project", id] : ["pair", index]);
|
|
6318
|
+
}
|
|
6319
|
+
function comparisonNodeIdentity(node, side, identity) {
|
|
6320
|
+
if (!identity || node.type !== "subGraph" && node.type !== "referencedGraphAlias") return node;
|
|
6321
|
+
const field2 = node.type === "subGraph" ? "targetProjectId" : "projectId";
|
|
6322
|
+
const data = (value) => {
|
|
6323
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
6324
|
+
const record4 = value;
|
|
6325
|
+
return typeof record4[field2] === "string" ? { ...record4, [field2]: comparisonProjectIdentity(record4[field2], side, identity) } : value;
|
|
6326
|
+
};
|
|
6327
|
+
return {
|
|
6328
|
+
...node,
|
|
6329
|
+
data: data(node.data),
|
|
6330
|
+
...node.variants ? { variants: node.variants.map((v) => ({ ...v, data: data(v.data) })) } : {}
|
|
6331
|
+
};
|
|
6332
|
+
}
|
|
6333
|
+
|
|
6314
6334
|
// src/utils/projectComparison/nodes.ts
|
|
6315
6335
|
function getProjectNodeFieldComparisons(comparison) {
|
|
6316
6336
|
const before = comparison.before;
|
|
@@ -6318,12 +6338,22 @@ function getProjectNodeFieldComparisons(comparison) {
|
|
|
6318
6338
|
if (!before || !after) {
|
|
6319
6339
|
return [];
|
|
6320
6340
|
}
|
|
6321
|
-
|
|
6341
|
+
const rawBefore = getComparableNodeRecord(before);
|
|
6342
|
+
const rawAfter = getComparableNodeRecord(after);
|
|
6343
|
+
const at = (record4, path) => path.reduce(
|
|
6344
|
+
(value, key) => value && typeof value === "object" ? value[key] : void 0,
|
|
6345
|
+
record4
|
|
6346
|
+
);
|
|
6347
|
+
return getChangedValueComparisons(
|
|
6348
|
+
[],
|
|
6349
|
+
getComparableNodeRecord(comparisonNodeIdentity(before, "before", comparison.identity)),
|
|
6350
|
+
getComparableNodeRecord(comparisonNodeIdentity(after, "after", comparison.identity))
|
|
6351
|
+
).map((change) => ({ ...change, before: at(rawBefore, change.path), after: at(rawAfter, change.path) }));
|
|
6322
6352
|
}
|
|
6323
6353
|
function getComparableGraphNodes(nodes) {
|
|
6324
6354
|
return nodes.filter((node) => node.type !== "comment");
|
|
6325
6355
|
}
|
|
6326
|
-
function compareNodes(beforeNodes, afterNodes) {
|
|
6356
|
+
function compareNodes(beforeNodes, afterNodes, identity) {
|
|
6327
6357
|
const beforeById = new Map(beforeNodes.map((node) => [node.id, node]));
|
|
6328
6358
|
const afterById = new Map(afterNodes.map((node) => [node.id, node]));
|
|
6329
6359
|
const nodeIds = unionKeys(Object.fromEntries(beforeById), Object.fromEntries(afterById));
|
|
@@ -6341,9 +6371,13 @@ function compareNodes(beforeNodes, afterNodes) {
|
|
|
6341
6371
|
nodeId,
|
|
6342
6372
|
{
|
|
6343
6373
|
id: nodeId,
|
|
6344
|
-
kind: areComparisonNodesEqual(
|
|
6374
|
+
kind: areComparisonNodesEqual(
|
|
6375
|
+
before && comparisonNodeIdentity(before, "before", identity),
|
|
6376
|
+
after && comparisonNodeIdentity(after, "after", identity)
|
|
6377
|
+
) ? "unchanged" : "changed",
|
|
6345
6378
|
before,
|
|
6346
|
-
after
|
|
6379
|
+
after,
|
|
6380
|
+
...identity ? { identity } : {}
|
|
6347
6381
|
}
|
|
6348
6382
|
];
|
|
6349
6383
|
})
|
|
@@ -6423,7 +6457,7 @@ function createEmptyProjectSummary() {
|
|
|
6423
6457
|
}
|
|
6424
6458
|
|
|
6425
6459
|
// src/utils/projectComparison/graphs.ts
|
|
6426
|
-
function compareGraphs(id, before, after) {
|
|
6460
|
+
function compareGraphs(id, before, after, identity) {
|
|
6427
6461
|
if (!before && after) {
|
|
6428
6462
|
return createOneSidedGraphComparison(id, after, "added");
|
|
6429
6463
|
}
|
|
@@ -6433,7 +6467,7 @@ function compareGraphs(id, before, after) {
|
|
|
6433
6467
|
if (!before || !after) {
|
|
6434
6468
|
throw new Error(`Cannot compare missing graph ${id}`);
|
|
6435
6469
|
}
|
|
6436
|
-
const nodes = compareNodes(getComparableGraphNodes(before.nodes), getComparableGraphNodes(after.nodes));
|
|
6470
|
+
const nodes = compareNodes(getComparableGraphNodes(before.nodes), getComparableGraphNodes(after.nodes), identity);
|
|
6437
6471
|
const connections = compareConnections(
|
|
6438
6472
|
getComparableGraphConnections(before.connections, before.nodes),
|
|
6439
6473
|
getComparableGraphConnections(after.connections, after.nodes)
|
|
@@ -6484,24 +6518,30 @@ function createOneSidedConnectionComparisons(connections, kind) {
|
|
|
6484
6518
|
}
|
|
6485
6519
|
|
|
6486
6520
|
// src/utils/projectComparison.ts
|
|
6487
|
-
function compareProjects(before, after) {
|
|
6521
|
+
function compareProjects(before, after, identity) {
|
|
6488
6522
|
const graphIds = unionKeys(before.graphs, after.graphs);
|
|
6489
6523
|
const graphs = Object.fromEntries(
|
|
6490
|
-
graphIds.map((graphId2) => [
|
|
6524
|
+
graphIds.map((graphId2) => [
|
|
6525
|
+
graphId2,
|
|
6526
|
+
compareGraphs(graphId2, before.graphs[graphId2], after.graphs[graphId2], identity)
|
|
6527
|
+
])
|
|
6491
6528
|
);
|
|
6492
|
-
const nodePrefabs = compareNodePrefabs(before.nodePrefabs ?? {}, after.nodePrefabs ?? {});
|
|
6529
|
+
const nodePrefabs = compareNodePrefabs(before.nodePrefabs ?? {}, after.nodePrefabs ?? {}, identity);
|
|
6493
6530
|
const uiGraphs = compareUiGraphs(before.uiGraphs ?? {}, after.uiGraphs ?? {});
|
|
6494
6531
|
return {
|
|
6495
6532
|
beforeProjectId: before.metadata.id,
|
|
6496
6533
|
afterProjectId: after.metadata.id,
|
|
6497
|
-
metadataChanged: !areComparisonValuesEqual(
|
|
6534
|
+
metadataChanged: !areComparisonValuesEqual(
|
|
6535
|
+
identity ? { ...before.metadata, id: comparisonProjectIdentity(before.metadata.id, "before", identity), path: void 0 } : before.metadata,
|
|
6536
|
+
identity ? { ...after.metadata, id: comparisonProjectIdentity(after.metadata.id, "after", identity), path: void 0 } : after.metadata
|
|
6537
|
+
),
|
|
6498
6538
|
graphs,
|
|
6499
6539
|
nodePrefabs,
|
|
6500
6540
|
uiGraphs,
|
|
6501
6541
|
summary: summarizeProjectComparison(graphs, nodePrefabs, uiGraphs)
|
|
6502
6542
|
};
|
|
6503
6543
|
}
|
|
6504
|
-
function compareNodePrefabs(before, after) {
|
|
6544
|
+
function compareNodePrefabs(before, after, identity) {
|
|
6505
6545
|
const prefabIds = unionKeys(before, after);
|
|
6506
6546
|
return Object.fromEntries(
|
|
6507
6547
|
prefabIds.map((prefabId) => {
|
|
@@ -6516,7 +6556,9 @@ function compareNodePrefabs(before, after) {
|
|
|
6516
6556
|
if (!beforePrefab || !afterPrefab) {
|
|
6517
6557
|
throw new Error(`Cannot compare missing library node ${prefabId}`);
|
|
6518
6558
|
}
|
|
6519
|
-
const sourceNodeComparison = Object.values(
|
|
6559
|
+
const sourceNodeComparison = Object.values(
|
|
6560
|
+
compareNodes([beforePrefab.sourceNode], [afterPrefab.sourceNode], identity)
|
|
6561
|
+
)[0];
|
|
6520
6562
|
return [
|
|
6521
6563
|
prefabId,
|
|
6522
6564
|
{
|