@neocompose/cli 0.81.0 → 0.81.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/CHANGELOG.md +12 -0
- package/dist/neo.mjs +823 -265
- package/dist/test-worker.mjs +765 -98
- package/package.json +1 -1
- package/skills/neocompose-cli/SKILL.md +1 -1
- package/skills/neocompose-cli/references/animation-and-world-authoring.md +8 -0
- package/skills/neocompose-cli/references/cli-development.md +1 -1
- package/skills/neocompose-cli/references/commands-and-sync.md +3 -2
- package/skills/neocompose-cli/references/values-identities-and-references.md +8 -5
package/dist/test-worker.mjs
CHANGED
|
@@ -3600,6 +3600,8 @@ function isNSFunctionVariantApply(value) {
|
|
|
3600
3600
|
if (!isNSPointer(info.variantPointer)) return false;
|
|
3601
3601
|
if (info.rowPointer !== void 0 && !isNSPointer(info.rowPointer))
|
|
3602
3602
|
return false;
|
|
3603
|
+
if (info.declarativeReplay !== void 0 && info.declarativeReplay !== true)
|
|
3604
|
+
return false;
|
|
3603
3605
|
return isNSTypeInfoClass(info.schemaClassInfo) && info.schemaClassInfo.required;
|
|
3604
3606
|
}
|
|
3605
3607
|
function isNSFunctionClassConstructor(value) {
|
|
@@ -5284,7 +5286,9 @@ function isLiteralValueContent(value) {
|
|
|
5284
5286
|
for (const field of [
|
|
5285
5287
|
"instanceConstructorId",
|
|
5286
5288
|
"instanceVariantId",
|
|
5287
|
-
"instanceVariantRowValueId"
|
|
5289
|
+
"instanceVariantRowValueId",
|
|
5290
|
+
"instanceAppliedVariantId",
|
|
5291
|
+
"instanceAppliedVariantRowValueId"
|
|
5288
5292
|
]) {
|
|
5289
5293
|
const provenance = getField(value, field);
|
|
5290
5294
|
if (provenance !== void 0 && provenance !== null && (typeof provenance !== "string" || provenance.length === 0)) {
|
|
@@ -5310,6 +5314,9 @@ function isInitValueContent(value) {
|
|
|
5310
5314
|
if (getField(value, "instanceConstructorId") !== void 0) return false;
|
|
5311
5315
|
if (getField(value, "instanceVariantId") !== void 0) return false;
|
|
5312
5316
|
if (getField(value, "instanceVariantRowValueId") !== void 0) return false;
|
|
5317
|
+
if (getField(value, "instanceAppliedVariantId") !== void 0) return false;
|
|
5318
|
+
if (getField(value, "instanceAppliedVariantRowValueId") !== void 0)
|
|
5319
|
+
return false;
|
|
5313
5320
|
const classIdField = getField(value, "classId");
|
|
5314
5321
|
return classIdField === void 0 || classIdField === null;
|
|
5315
5322
|
}
|
|
@@ -6081,6 +6088,8 @@ var LITERAL_INSTANCE_IDENTITY_FIELDS = [
|
|
|
6081
6088
|
"instanceConstructorId",
|
|
6082
6089
|
"instanceVariantId",
|
|
6083
6090
|
"instanceVariantRowValueId",
|
|
6091
|
+
"instanceAppliedVariantId",
|
|
6092
|
+
"instanceAppliedVariantRowValueId",
|
|
6084
6093
|
"genericBindings"
|
|
6085
6094
|
];
|
|
6086
6095
|
function replaceLiteralValueClass(value, classId) {
|
|
@@ -6103,7 +6112,11 @@ function pickInstanceProvenance(source) {
|
|
|
6103
6112
|
...source.constructorArgs === void 0 ? {} : { constructorArgs: source.constructorArgs },
|
|
6104
6113
|
...source.instanceConstructorId === void 0 ? {} : { instanceConstructorId: source.instanceConstructorId },
|
|
6105
6114
|
...source.instanceVariantId === void 0 ? {} : { instanceVariantId: source.instanceVariantId },
|
|
6106
|
-
...source.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: source.instanceVariantRowValueId }
|
|
6115
|
+
...source.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: source.instanceVariantRowValueId },
|
|
6116
|
+
...source.instanceAppliedVariantId === void 0 ? {} : { instanceAppliedVariantId: source.instanceAppliedVariantId },
|
|
6117
|
+
...source.instanceAppliedVariantRowValueId === void 0 ? {} : {
|
|
6118
|
+
instanceAppliedVariantRowValueId: source.instanceAppliedVariantRowValueId
|
|
6119
|
+
}
|
|
6107
6120
|
};
|
|
6108
6121
|
}
|
|
6109
6122
|
function isVirtualInstanceRootShape(value) {
|
|
@@ -6276,7 +6289,7 @@ function decodeContentField(container, field, scope, children) {
|
|
|
6276
6289
|
)
|
|
6277
6290
|
};
|
|
6278
6291
|
}
|
|
6279
|
-
const decoded =
|
|
6292
|
+
const decoded = /* @__PURE__ */ Object.create(null);
|
|
6280
6293
|
for (const [key, entry] of Object.entries(
|
|
6281
6294
|
container
|
|
6282
6295
|
)) {
|
|
@@ -11533,12 +11546,8 @@ function evaluateLiteralContainer(args) {
|
|
|
11533
11546
|
const literal3 = {
|
|
11534
11547
|
value: evaluated.value,
|
|
11535
11548
|
classId: evaluated.classId,
|
|
11536
|
-
...
|
|
11537
|
-
...evaluated.
|
|
11538
|
-
...evaluated.instanceVariantId === void 0 ? {} : { instanceVariantId: evaluated.instanceVariantId },
|
|
11539
|
-
...evaluated.instanceVariantRowValueId === void 0 ? {} : {
|
|
11540
|
-
instanceVariantRowValueId: evaluated.instanceVariantRowValueId
|
|
11541
|
-
}
|
|
11549
|
+
...pickInstanceProvenance(evaluated),
|
|
11550
|
+
...evaluated.constructorArgs === void 0 ? {} : { constructorArgs: deepClonePlainData(evaluated.constructorArgs) }
|
|
11542
11551
|
};
|
|
11543
11552
|
if (isMemberLookupBase(args.member)) {
|
|
11544
11553
|
if (evaluated.existingValueRow !== void 0) {
|
|
@@ -11871,15 +11880,9 @@ function buildNewValue(projectId, body, timestamp2 = Date.now()) {
|
|
|
11871
11880
|
if (body.constructorArgs !== void 0 && body.constructorArgs !== null) {
|
|
11872
11881
|
props.constructorArgs = deepClonePlainData(body.constructorArgs);
|
|
11873
11882
|
}
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
if (body.instanceVariantId !== void 0) {
|
|
11878
|
-
props.instanceVariantId = body.instanceVariantId;
|
|
11879
|
-
}
|
|
11880
|
-
if (body.instanceVariantRowValueId !== void 0) {
|
|
11881
|
-
props.instanceVariantRowValueId = body.instanceVariantRowValueId;
|
|
11882
|
-
}
|
|
11883
|
+
const { constructorArgs: _constructorArgs, ...provenance } = pickInstanceProvenance(body);
|
|
11884
|
+
void _constructorArgs;
|
|
11885
|
+
Object.assign(props, provenance);
|
|
11883
11886
|
return props;
|
|
11884
11887
|
}
|
|
11885
11888
|
function retargetInitializerRootValueIds(rows, fromValueId, toValueId) {
|
|
@@ -12071,7 +12074,7 @@ function cloneDefaultDictionaryRecord(args) {
|
|
|
12071
12074
|
args.document,
|
|
12072
12075
|
args.member.entryMemberId
|
|
12073
12076
|
);
|
|
12074
|
-
const value =
|
|
12077
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
12075
12078
|
for (const [key, sourceValueId] of Object.entries(sourceValue)) {
|
|
12076
12079
|
value[key] = cloneDefaultValueForMember({
|
|
12077
12080
|
document: args.document,
|
|
@@ -12348,9 +12351,7 @@ function cloneMemberValueBase(body) {
|
|
|
12348
12351
|
return {
|
|
12349
12352
|
value: deepClonePlainData(body.value),
|
|
12350
12353
|
classId: body.classId,
|
|
12351
|
-
...body
|
|
12352
|
-
...body.instanceVariantId === void 0 ? {} : { instanceVariantId: body.instanceVariantId },
|
|
12353
|
-
...body.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: body.instanceVariantRowValueId },
|
|
12354
|
+
...pickInstanceProvenance({ ...body, constructorArgs: void 0 }),
|
|
12354
12355
|
...body.constructorArgs === void 0 || body.constructorArgs === null ? {} : {
|
|
12355
12356
|
constructorArgs: deepClonePlainData(body.constructorArgs)
|
|
12356
12357
|
}
|
|
@@ -13329,7 +13330,7 @@ function toCanonicalJsonValue(value) {
|
|
|
13329
13330
|
});
|
|
13330
13331
|
}
|
|
13331
13332
|
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
|
|
13332
|
-
const canonicalObject =
|
|
13333
|
+
const canonicalObject = /* @__PURE__ */ Object.create(null);
|
|
13333
13334
|
for (const [key, entryValue] of entries) {
|
|
13334
13335
|
const canonicalValue = toCanonicalJsonValue(entryValue);
|
|
13335
13336
|
if (canonicalValue === void 0) continue;
|
|
@@ -16971,6 +16972,7 @@ function makeUnindexedEvaluatorLookups(members, storedValues) {
|
|
|
16971
16972
|
hasStoredValueId: (id) => valueById.has(id),
|
|
16972
16973
|
unorderedListEntryIds: (containerValueId) => unorderedListMembership.get(containerValueId) ?? [],
|
|
16973
16974
|
virtualInstanceRowsForValue: () => [],
|
|
16975
|
+
virtualInstanceRootIdForValue: () => null,
|
|
16974
16976
|
rowForValueReference: (value) => valueRefMap.get(value) ?? null
|
|
16975
16977
|
};
|
|
16976
16978
|
}
|
|
@@ -17154,6 +17156,7 @@ function createEvaluatorLookupsBuild(members, storedValues, options = {}) {
|
|
|
17154
17156
|
hasStoredValueId: (id) => valueById.has(id),
|
|
17155
17157
|
unorderedListEntryIds: (containerValueId) => unorderedListMembership.get(containerValueId) ?? [],
|
|
17156
17158
|
virtualInstanceRowsForValue: () => [],
|
|
17159
|
+
virtualInstanceRootIdForValue: () => null,
|
|
17157
17160
|
rowForValueReference: (value) => rowByValueReference.get(value) ?? null,
|
|
17158
17161
|
evaluatorIndexes: indexes3.result,
|
|
17159
17162
|
...options.constructorInitializerDocument === void 0 ? {} : {
|
|
@@ -17271,6 +17274,7 @@ function layerEvaluatorLookups(base, overlay) {
|
|
|
17271
17274
|
hasStoredValueId: (id) => overlay.rows.has(id) || !overlay.hiddenIds.has(id) && (base.hasStoredValueId?.(id) ?? false),
|
|
17272
17275
|
unorderedListEntryIds,
|
|
17273
17276
|
virtualInstanceRowsForValue: () => [],
|
|
17277
|
+
virtualInstanceRootIdForValue: () => null,
|
|
17274
17278
|
rowForValueReference: (value) => evaluatorIndexes2.rowByValueReference.get(value) ?? null,
|
|
17275
17279
|
evaluatorIndexes: evaluatorIndexes2,
|
|
17276
17280
|
constructorInitializerIndexes: constructorInitializerIndexes2
|
|
@@ -17676,13 +17680,15 @@ function bindThisValue(ctx, thisValue) {
|
|
|
17676
17680
|
function observeValueWrite(ctx, row) {
|
|
17677
17681
|
ctx.beforeValueWrite?.(row);
|
|
17678
17682
|
ctx.__getterSubscriptions?.noteValueWrite(row.id);
|
|
17683
|
+
forgetVariantResolutionCopy(ctx, row.id);
|
|
17679
17684
|
}
|
|
17680
17685
|
function assertStoredReplayMutableValue(value, ctx, label, key) {
|
|
17681
|
-
const observesWrites = ctx.beforeValueWrite !== void 0 || ctx.__getterSubscriptions?.empty === false;
|
|
17686
|
+
const observesWrites = ctx.beforeValueWrite !== void 0 || ctx.__getterSubscriptions?.empty === false || hasVariantResolutionCopies(ctx);
|
|
17682
17687
|
if (ctx.storedConstructionReplay !== true && !ctx.assertValueWritable && !observesWrites)
|
|
17683
17688
|
return;
|
|
17684
17689
|
let rowId = findKnownRowIdByValueReference(value, ctx);
|
|
17685
17690
|
if (rowId === null) return;
|
|
17691
|
+
forgetVariantResolutionCopy(ctx, rowId);
|
|
17686
17692
|
const container = ctx.beforeValueWrite && evalValueById(ctx, rowId, ctx.__runtimeSessionValues, ctx.__valueOverlay);
|
|
17687
17693
|
if (container) ctx.beforeValueWrite?.(container);
|
|
17688
17694
|
if (key !== void 0 && value !== null && typeof value === "object") {
|
|
@@ -26490,12 +26496,7 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
|
|
|
26490
26496
|
deleteRuntimeSessionValue(ctx, rootRow.id);
|
|
26491
26497
|
ctx.__executionState?.constructorGroups.delete(rootRow.id);
|
|
26492
26498
|
const constructorArgs = typeof result.value === "object" && result.value !== null ? ctx.__constructedArgumentsByValue.get(result.value) ?? rootRow.constructorArgs ?? void 0 : void 0;
|
|
26493
|
-
const provenance = pickInstanceProvenance({
|
|
26494
|
-
constructorArgs,
|
|
26495
|
-
instanceConstructorId: rootRow.instanceConstructorId,
|
|
26496
|
-
instanceVariantId: rootRow.instanceVariantId,
|
|
26497
|
-
instanceVariantRowValueId: rootRow.instanceVariantRowValueId
|
|
26498
|
-
});
|
|
26499
|
+
const provenance = pickInstanceProvenance({ ...rootRow, constructorArgs });
|
|
26499
26500
|
return {
|
|
26500
26501
|
value: result.value,
|
|
26501
26502
|
classId: rootRow.classId ?? null,
|
|
@@ -27360,7 +27361,7 @@ function evalVariantInitialize(info, scope, ctx) {
|
|
|
27360
27361
|
scope,
|
|
27361
27362
|
ctx
|
|
27362
27363
|
);
|
|
27363
|
-
stampInstanceVariantProvenance(instance, selection, ctx
|
|
27364
|
+
stampInstanceVariantProvenance(instance, selection, ctx);
|
|
27364
27365
|
return instance;
|
|
27365
27366
|
}
|
|
27366
27367
|
const graph = resolveVariantGraph(selection, ctx);
|
|
@@ -27391,12 +27392,16 @@ function evalVariantInitialize(info, scope, ctx) {
|
|
|
27391
27392
|
ctx,
|
|
27392
27393
|
ctx.__variantDeclarativeAnsweredValueIds
|
|
27393
27394
|
);
|
|
27394
|
-
stampInstanceVariantProvenance(instance, selection, ctx
|
|
27395
|
+
stampInstanceVariantProvenance(instance, selection, ctx);
|
|
27395
27396
|
return instance;
|
|
27396
27397
|
} finally {
|
|
27397
27398
|
closeFrame();
|
|
27398
27399
|
}
|
|
27399
27400
|
}
|
|
27401
|
+
function isInsideAnotherExpansion(valueId, ctx) {
|
|
27402
|
+
const ownerRootId = ctx.vm.databaseVM?.virtualInstanceRootIdForValue(valueId) ?? null;
|
|
27403
|
+
return ownerRootId !== null && ownerRootId !== valueId;
|
|
27404
|
+
}
|
|
27400
27405
|
function evalVariantApply(info, scope, ctx) {
|
|
27401
27406
|
const receiver = evalPointer(info.receiverPointer, scope, ctx);
|
|
27402
27407
|
if (receiver === null || receiver === void 0) {
|
|
@@ -27408,12 +27413,12 @@ function evalVariantApply(info, scope, ctx) {
|
|
|
27408
27413
|
evalPointer(info.variantPointer, scope, ctx),
|
|
27409
27414
|
"ToVariant argument"
|
|
27410
27415
|
);
|
|
27411
|
-
|
|
27412
|
-
|
|
27416
|
+
const graph = selection.variantId === null ? null : resolveVariantGraph(selection, ctx);
|
|
27417
|
+
if (info.declarativeReplay === true) {
|
|
27418
|
+
if (graph !== null) applyVariantDeclarativeHalves(receiver, graph, ctx);
|
|
27413
27419
|
return receiver;
|
|
27414
27420
|
}
|
|
27415
|
-
const
|
|
27416
|
-
const rowParameters = resolveVariantRowParameter({
|
|
27421
|
+
const rowParameters = graph === null ? [] : resolveVariantRowParameter({
|
|
27417
27422
|
graph,
|
|
27418
27423
|
selection,
|
|
27419
27424
|
explicitPointer: info.rowPointer,
|
|
@@ -27422,13 +27427,18 @@ function evalVariantApply(info, scope, ctx) {
|
|
|
27422
27427
|
});
|
|
27423
27428
|
const rootRow = trackedRowForValueReference(receiver, ctx);
|
|
27424
27429
|
if (rootRow === null || !isLiteralValueContent(rootRow)) {
|
|
27430
|
+
if (graph === null) return receiver;
|
|
27425
27431
|
throw new NSGetterRuntimeError(
|
|
27426
27432
|
"ToVariant receiver has no addressable instance root."
|
|
27427
27433
|
);
|
|
27428
27434
|
}
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27435
|
+
if (graph === null && typeof rootRow.instanceAppliedVariantId !== "string") {
|
|
27436
|
+
return receiver;
|
|
27437
|
+
}
|
|
27438
|
+
const inPlace = ctx.__runtimeSessionValues?.has(rootRow.id) === true || isInsideAnotherExpansion(rootRow.id, ctx);
|
|
27439
|
+
const priorInstanceRoot = inPlace ? null : deepClonePlainData(rootRow);
|
|
27440
|
+
const applyValue = graph?.root.Apply;
|
|
27441
|
+
if (graph !== null && applyValue !== void 0 && applyValue !== null) {
|
|
27432
27442
|
invokeVariantClosure({
|
|
27433
27443
|
closureValueId: applyValue,
|
|
27434
27444
|
ctx,
|
|
@@ -27438,17 +27448,12 @@ function evalVariantApply(info, scope, ctx) {
|
|
|
27438
27448
|
});
|
|
27439
27449
|
}
|
|
27440
27450
|
if (priorInstanceRoot === null) {
|
|
27441
|
-
|
|
27442
|
-
applyVariantDeclarativeHalves(receiver, graph, ctx);
|
|
27451
|
+
if (graph !== null) applyVariantDeclarativeHalves(receiver, graph, ctx);
|
|
27443
27452
|
return receiver;
|
|
27444
27453
|
}
|
|
27445
27454
|
priorInstanceRoot.value = deepClonePlainData(rootRow.value);
|
|
27446
|
-
const answeredSlots = collectVariantDeclarativeAnsweredSlots(
|
|
27447
|
-
|
|
27448
|
-
graph,
|
|
27449
|
-
ctx
|
|
27450
|
-
);
|
|
27451
|
-
stampInstanceVariantProvenance(receiver, selection, ctx);
|
|
27455
|
+
const answeredSlots = graph === null ? [] : collectVariantDeclarativeAnsweredSlots(receiver, graph, ctx);
|
|
27456
|
+
stampAppliedVariantProvenance(rootRow, receiver, selection, ctx);
|
|
27452
27457
|
const resolver = ctx.vm.databaseVM?.resolveVariantInstanceGraph;
|
|
27453
27458
|
if (resolver === void 0) {
|
|
27454
27459
|
if (answeredSlots.length > 0) {
|
|
@@ -27457,26 +27462,41 @@ function evalVariantApply(info, scope, ctx) {
|
|
|
27457
27462
|
);
|
|
27458
27463
|
}
|
|
27459
27464
|
} else {
|
|
27465
|
+
const overlay = ctx.__valueOverlay;
|
|
27466
|
+
const copies = overlay === void 0 ? void 0 : variantResolutionCopies(overlay);
|
|
27460
27467
|
const resolution = resolver.call(ctx.vm.databaseVM, {
|
|
27461
27468
|
priorInstanceRoot,
|
|
27462
27469
|
nextInstanceRoot: deepClonePlainData(rootRow),
|
|
27463
27470
|
answeredValueIds: [...new Set(answeredSlots.map((slot) => slot.valueId))],
|
|
27464
27471
|
localRows: [
|
|
27465
27472
|
...ctx.__runtimeSessionValues?.values() ?? [],
|
|
27466
|
-
...
|
|
27467
|
-
]
|
|
27473
|
+
...overlay?.values() ?? []
|
|
27474
|
+
],
|
|
27475
|
+
virtualCopyIds: unwrittenVariantResolutionCopyIds(
|
|
27476
|
+
overlay,
|
|
27477
|
+
copies?.byRootId.get(rootRow.id)
|
|
27478
|
+
)
|
|
27468
27479
|
});
|
|
27469
27480
|
for (const valueId of resolution.clearedValueIds) {
|
|
27470
27481
|
const previous = readNeoScriptRuntimeRow(ctx, valueId);
|
|
27471
27482
|
if (previous) observeValueWrite(ctx, previous);
|
|
27472
27483
|
deleteRuntimeSessionValue(ctx, valueId);
|
|
27473
|
-
|
|
27484
|
+
overlay?.delete(valueId);
|
|
27485
|
+
}
|
|
27486
|
+
for (const valueId of copies?.byRootId.get(rootRow.id)?.keys() ?? []) {
|
|
27487
|
+
forgetVariantResolutionCopy(ctx, valueId);
|
|
27474
27488
|
}
|
|
27489
|
+
const virtualValueIds = new Set(resolution.virtualValueIds);
|
|
27475
27490
|
for (const row of resolution.rows) {
|
|
27476
27491
|
if (row.id === rootRow.id) continue;
|
|
27477
27492
|
const previous = readNeoScriptRuntimeRow(ctx, row.id);
|
|
27478
27493
|
if (previous) observeValueWrite(ctx, previous);
|
|
27479
|
-
|
|
27494
|
+
if (overlay === void 0 || copies === void 0) continue;
|
|
27495
|
+
const copy = deepClonePlainData(row);
|
|
27496
|
+
overlay.set(row.id, copy);
|
|
27497
|
+
if (virtualValueIds.has(row.id)) {
|
|
27498
|
+
trackVariantResolutionCopy(copies, rootRow.id, copy);
|
|
27499
|
+
}
|
|
27480
27500
|
}
|
|
27481
27501
|
if (typeof receiver !== "object" || receiver === null || Array.isArray(receiver) || typeof resolution.root.value !== "object" || resolution.root.value === null || Array.isArray(resolution.root.value)) {
|
|
27482
27502
|
throw new NSGetterRuntimeError(
|
|
@@ -27490,14 +27510,70 @@ function evalVariantApply(info, scope, ctx) {
|
|
|
27490
27510
|
}
|
|
27491
27511
|
return receiver;
|
|
27492
27512
|
}
|
|
27493
|
-
|
|
27513
|
+
var variantResolutionCopiesByOverlay = /* @__PURE__ */ new WeakMap();
|
|
27514
|
+
function variantResolutionCopies(overlay) {
|
|
27515
|
+
let copies = variantResolutionCopiesByOverlay.get(overlay);
|
|
27516
|
+
if (copies === void 0) {
|
|
27517
|
+
copies = { byRootId: /* @__PURE__ */ new Map(), rootIdByValueId: /* @__PURE__ */ new Map() };
|
|
27518
|
+
variantResolutionCopiesByOverlay.set(overlay, copies);
|
|
27519
|
+
}
|
|
27520
|
+
return copies;
|
|
27521
|
+
}
|
|
27522
|
+
function hasVariantResolutionCopies(ctx) {
|
|
27523
|
+
const overlay = ctx.__valueOverlay;
|
|
27524
|
+
if (overlay === void 0) return false;
|
|
27525
|
+
const copies = variantResolutionCopiesByOverlay.get(overlay);
|
|
27526
|
+
return copies !== void 0 && copies.rootIdByValueId.size > 0;
|
|
27527
|
+
}
|
|
27528
|
+
function trackVariantResolutionCopy(copies, rootId, copy) {
|
|
27529
|
+
let rootCopies = copies.byRootId.get(rootId);
|
|
27530
|
+
if (rootCopies === void 0) {
|
|
27531
|
+
rootCopies = /* @__PURE__ */ new Map();
|
|
27532
|
+
copies.byRootId.set(rootId, rootCopies);
|
|
27533
|
+
}
|
|
27534
|
+
rootCopies.set(copy.id, copy);
|
|
27535
|
+
copies.rootIdByValueId.set(copy.id, rootId);
|
|
27536
|
+
}
|
|
27537
|
+
function unwrittenVariantResolutionCopyIds(overlay, rootCopies) {
|
|
27538
|
+
if (overlay === void 0 || rootCopies === void 0) return [];
|
|
27539
|
+
const ids = [];
|
|
27540
|
+
for (const [id, copy] of rootCopies) {
|
|
27541
|
+
if (overlay.get(id) === copy) ids.push(id);
|
|
27542
|
+
}
|
|
27543
|
+
return ids;
|
|
27544
|
+
}
|
|
27545
|
+
function forgetVariantResolutionCopy(ctx, valueId) {
|
|
27546
|
+
const overlay = ctx.__valueOverlay;
|
|
27547
|
+
if (overlay === void 0) return;
|
|
27548
|
+
const copies = variantResolutionCopiesByOverlay.get(overlay);
|
|
27549
|
+
const rootId = copies?.rootIdByValueId.get(valueId);
|
|
27550
|
+
if (copies === void 0 || rootId === void 0) return;
|
|
27551
|
+
copies.rootIdByValueId.delete(valueId);
|
|
27552
|
+
copies.byRootId.get(rootId)?.delete(valueId);
|
|
27553
|
+
}
|
|
27554
|
+
function stampInstanceVariantProvenance(instance, selection, ctx) {
|
|
27494
27555
|
const row = trackedRowForValueReference(instance, ctx);
|
|
27495
27556
|
if (row === null || !isLiteralValueContent(row)) return;
|
|
27496
|
-
if (
|
|
27557
|
+
if (row.id === selection.rowValueId) return;
|
|
27497
27558
|
assertStoredReplayMutableValue(instance, ctx, "variant provenance");
|
|
27498
27559
|
row.instanceVariantId = selection.variantId;
|
|
27499
27560
|
row.instanceVariantRowValueId = selection.rowValueId;
|
|
27500
27561
|
}
|
|
27562
|
+
function stampAppliedVariantProvenance(rootRow, instance, selection, ctx) {
|
|
27563
|
+
const applied = typeof rootRow.instanceAppliedVariantId === "string";
|
|
27564
|
+
const variantId = applied ? rootRow.instanceAppliedVariantId : rootRow.instanceVariantId ?? null;
|
|
27565
|
+
const rowValueId = applied ? rootRow.instanceAppliedVariantRowValueId : rootRow.instanceVariantRowValueId;
|
|
27566
|
+
if (variantId === selection.variantId && (rowValueId ?? null) === selection.rowValueId) {
|
|
27567
|
+
return;
|
|
27568
|
+
}
|
|
27569
|
+
assertStoredReplayMutableValue(instance, ctx, "variant provenance");
|
|
27570
|
+
if (!isVirtualInstanceRootShape(rootRow)) {
|
|
27571
|
+
rootRow.instanceConstructorId = null;
|
|
27572
|
+
rootRow.constructorArgs = {};
|
|
27573
|
+
}
|
|
27574
|
+
rootRow.instanceAppliedVariantId = selection.variantId;
|
|
27575
|
+
rootRow.instanceAppliedVariantRowValueId = selection.rowValueId;
|
|
27576
|
+
}
|
|
27501
27577
|
function constructDeclaredClassValue(info, scope, ctx) {
|
|
27502
27578
|
const descriptor = validateClassConstructorDescriptor(info, ctx, false);
|
|
27503
27579
|
const schemaClass2 = descriptor.schemaClass;
|
|
@@ -27580,6 +27656,7 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
|
|
|
27580
27656
|
);
|
|
27581
27657
|
}
|
|
27582
27658
|
const rootRecord = root.value;
|
|
27659
|
+
recordConstructedFieldSchemaKeys(ctx, rootRecord, descriptor);
|
|
27583
27660
|
if (record4 !== null) {
|
|
27584
27661
|
const encoded = {};
|
|
27585
27662
|
for (let index = 0; index < argumentValues.length; index += 1) {
|
|
@@ -27620,7 +27697,6 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
|
|
|
27620
27697
|
}
|
|
27621
27698
|
const argumentsByValue = ctx.__constructedArgumentsByValue ?? (ctx.__constructedArgumentsByValue = /* @__PURE__ */ new WeakMap());
|
|
27622
27699
|
argumentsByValue.set(rootRecord, encoded);
|
|
27623
|
-
recordConstructedFieldSchemaKeys(ctx, rootRecord, descriptor);
|
|
27624
27700
|
root.constructorArgs = deepClonePlainData(encoded);
|
|
27625
27701
|
root.instanceConstructorId = record4.id;
|
|
27626
27702
|
} else {
|
|
@@ -28013,7 +28089,7 @@ function cloneConstructorArgumentGraph(args) {
|
|
|
28013
28089
|
member.classArguments,
|
|
28014
28090
|
args.ctx.vm.classes
|
|
28015
28091
|
);
|
|
28016
|
-
const record4 =
|
|
28092
|
+
const record4 = /* @__PURE__ */ Object.create(null);
|
|
28017
28093
|
clone.value = record4;
|
|
28018
28094
|
const sourceRecord = {
|
|
28019
28095
|
...virtualExpandedRecordForReceiver(source.value, args.ctx),
|
|
@@ -28057,7 +28133,7 @@ function cloneConstructorArgumentGraph(args) {
|
|
|
28057
28133
|
`Constructor import references missing Dictionary entry member '${member.entryMemberId}'.`
|
|
28058
28134
|
);
|
|
28059
28135
|
}
|
|
28060
|
-
const record4 =
|
|
28136
|
+
const record4 = /* @__PURE__ */ Object.create(null);
|
|
28061
28137
|
clone.value = record4;
|
|
28062
28138
|
const entryEnv = envFromStamp(clone.genericBindings);
|
|
28063
28139
|
for (const [key, childId] of Object.entries(source.value)) {
|
|
@@ -28300,7 +28376,7 @@ function materializeConstructorArgumentValue(args) {
|
|
|
28300
28376
|
args.ctx.vm.members
|
|
28301
28377
|
);
|
|
28302
28378
|
const row = registerConstructorArgumentRow(args, {});
|
|
28303
|
-
const record4 =
|
|
28379
|
+
const record4 = /* @__PURE__ */ Object.create(null);
|
|
28304
28380
|
for (const [key, rawEntry] of Object.entries(args.value)) {
|
|
28305
28381
|
const entry = constructorCollectionEntryValue(
|
|
28306
28382
|
rawEntry,
|
|
@@ -32303,12 +32379,7 @@ function materializeInitializerValue(args) {
|
|
|
32303
32379
|
value: evaluated.value,
|
|
32304
32380
|
...evaluated.classId === null ? {} : { classId: evaluated.classId },
|
|
32305
32381
|
...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
|
|
32306
|
-
...
|
|
32307
|
-
...evaluated.instanceConstructorId === void 0 ? {} : { instanceConstructorId: evaluated.instanceConstructorId },
|
|
32308
|
-
...evaluated.instanceVariantId === void 0 ? {} : { instanceVariantId: evaluated.instanceVariantId },
|
|
32309
|
-
...evaluated.instanceVariantRowValueId === void 0 ? {} : {
|
|
32310
|
-
instanceVariantRowValueId: evaluated.instanceVariantRowValueId
|
|
32311
|
-
}
|
|
32382
|
+
...deepClonePlainData(pickInstanceProvenance(evaluated))
|
|
32312
32383
|
};
|
|
32313
32384
|
const allCreated = [root, ...createdValues];
|
|
32314
32385
|
if (evaluated.provisionalRootId !== void 0) {
|
|
@@ -32331,7 +32402,8 @@ function materializeInitializerValue(args) {
|
|
|
32331
32402
|
return {
|
|
32332
32403
|
root,
|
|
32333
32404
|
createdValues,
|
|
32334
|
-
pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set()
|
|
32405
|
+
pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
|
|
32406
|
+
pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
|
|
32335
32407
|
};
|
|
32336
32408
|
}
|
|
32337
32409
|
function materializeMemberDefaultValue(args) {
|
|
@@ -32448,7 +32520,12 @@ function materializeMemberDefaultValue(args) {
|
|
|
32448
32520
|
storageKeyDeclarations,
|
|
32449
32521
|
supersededRootId: built.id
|
|
32450
32522
|
});
|
|
32451
|
-
return {
|
|
32523
|
+
return {
|
|
32524
|
+
root,
|
|
32525
|
+
createdValues: interior,
|
|
32526
|
+
pinnedRootSchemaKeys: /* @__PURE__ */ new Set(),
|
|
32527
|
+
pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
|
|
32528
|
+
};
|
|
32452
32529
|
}
|
|
32453
32530
|
|
|
32454
32531
|
// ../packages/neoscript-runtime/src/virtual-instance-graph.ts
|
|
@@ -32478,6 +32555,7 @@ function buildVirtualInstanceMaterializedIndex(args) {
|
|
|
32478
32555
|
})
|
|
32479
32556
|
};
|
|
32480
32557
|
}
|
|
32558
|
+
var KEPT_ROW_SAMPLE_LIMIT = 12;
|
|
32481
32559
|
function derivesContentFromMemberDefault(args) {
|
|
32482
32560
|
const member = args.member;
|
|
32483
32561
|
if (!isMemberClassBase(member)) return false;
|
|
@@ -32630,6 +32708,8 @@ function expandStoredInstance(args) {
|
|
|
32630
32708
|
instanceConstructorId: _instanceConstructorId,
|
|
32631
32709
|
instanceVariantId: _instanceVariantId,
|
|
32632
32710
|
instanceVariantRowValueId: _instanceVariantRowValueId,
|
|
32711
|
+
instanceAppliedVariantId: _instanceAppliedVariantId,
|
|
32712
|
+
instanceAppliedVariantRowValueId: _instanceAppliedVariantRowValueId,
|
|
32633
32713
|
...envelope
|
|
32634
32714
|
} = instanceRoot;
|
|
32635
32715
|
void _value;
|
|
@@ -32638,6 +32718,8 @@ function expandStoredInstance(args) {
|
|
|
32638
32718
|
void _instanceConstructorId;
|
|
32639
32719
|
void _instanceVariantId;
|
|
32640
32720
|
void _instanceVariantRowValueId;
|
|
32721
|
+
void _instanceAppliedVariantId;
|
|
32722
|
+
void _instanceAppliedVariantRowValueId;
|
|
32641
32723
|
const closedRootMember = closeClassArgumentsFromRowStamp(
|
|
32642
32724
|
rootMember,
|
|
32643
32725
|
instanceRoot
|
|
@@ -32719,11 +32801,26 @@ function expandStoredInstance(args) {
|
|
|
32719
32801
|
}
|
|
32720
32802
|
};
|
|
32721
32803
|
};
|
|
32722
|
-
const
|
|
32804
|
+
const constructed = derivesContentFromMemberDefault({
|
|
32723
32805
|
member: replayMember,
|
|
32724
32806
|
instanceRoot,
|
|
32725
32807
|
effectiveClassId: classId
|
|
32726
32808
|
}) ? replayDeclaredDefault() : replay([]);
|
|
32809
|
+
const appliedVariantId = instanceRoot.instanceAppliedVariantId;
|
|
32810
|
+
const materialized = typeof appliedVariantId !== "string" ? constructed : trackMaterialization(
|
|
32811
|
+
() => replayAppliedVariant({
|
|
32812
|
+
evaluateInitializer: args.evaluateInitializer,
|
|
32813
|
+
document: args.document,
|
|
32814
|
+
member: replayMember,
|
|
32815
|
+
constructed,
|
|
32816
|
+
classId,
|
|
32817
|
+
variantId: appliedVariantId,
|
|
32818
|
+
variantRowValueId: instanceRoot.instanceAppliedVariantRowValueId ?? null,
|
|
32819
|
+
...readTracking === void 0 ? {} : { readTracking },
|
|
32820
|
+
saveStaticBindings: args.saveStaticBindings,
|
|
32821
|
+
sessionStaticBindings: args.sessionStaticBindings
|
|
32822
|
+
})
|
|
32823
|
+
);
|
|
32727
32824
|
const rows = [materialized.root, ...materialized.createdValues];
|
|
32728
32825
|
assertVirtualExpansionIsLiteral(rows);
|
|
32729
32826
|
return {
|
|
@@ -32732,6 +32829,80 @@ function expandStoredInstance(args) {
|
|
|
32732
32829
|
pinnedRootSchemaKeys: /* @__PURE__ */ new Set()
|
|
32733
32830
|
};
|
|
32734
32831
|
}
|
|
32832
|
+
function replayAppliedVariant(args) {
|
|
32833
|
+
const rootId = args.constructed.root.id;
|
|
32834
|
+
const sessionValues = /* @__PURE__ */ new Map();
|
|
32835
|
+
sessionValues.set(rootId, args.constructed.root);
|
|
32836
|
+
for (const row of args.constructed.createdValues)
|
|
32837
|
+
sessionValues.set(row.id, row);
|
|
32838
|
+
const variant2 = args.document.databaseVM?.variantById?.(args.variantId) ?? args.document.variants?.find((entry) => entry.id === args.variantId);
|
|
32839
|
+
const variantClassId = variant2?.classId ?? args.classId;
|
|
32840
|
+
const schemaClassInfo = {
|
|
32841
|
+
type: 7 /* Class */,
|
|
32842
|
+
required: true,
|
|
32843
|
+
classId: args.classId
|
|
32844
|
+
};
|
|
32845
|
+
args.evaluateInitializer({
|
|
32846
|
+
init: {
|
|
32847
|
+
code: `virtual-applied-variant:${rootId}`,
|
|
32848
|
+
compiled: {
|
|
32849
|
+
compilerRevision: NEOSCRIPT_COMPILER_REVISION,
|
|
32850
|
+
parameters: evaluatorEnvelopeParameters(),
|
|
32851
|
+
instructions: [
|
|
32852
|
+
{
|
|
32853
|
+
type: "return" /* return */,
|
|
32854
|
+
pointer: {
|
|
32855
|
+
type: "function" /* function */,
|
|
32856
|
+
function: {
|
|
32857
|
+
type: "variantApply" /* variantApply */,
|
|
32858
|
+
info: {
|
|
32859
|
+
receiverPointer: {
|
|
32860
|
+
type: "reference" /* reference */,
|
|
32861
|
+
valueId: rootId
|
|
32862
|
+
},
|
|
32863
|
+
variantPointer: {
|
|
32864
|
+
type: "variant" /* variant */,
|
|
32865
|
+
classId: variantClassId,
|
|
32866
|
+
variantId: args.variantId,
|
|
32867
|
+
rowValueId: args.variantRowValueId
|
|
32868
|
+
},
|
|
32869
|
+
schemaClassInfo,
|
|
32870
|
+
declarativeReplay: true
|
|
32871
|
+
}
|
|
32872
|
+
}
|
|
32873
|
+
}
|
|
32874
|
+
}
|
|
32875
|
+
],
|
|
32876
|
+
typeInfo: schemaClassInfo
|
|
32877
|
+
}
|
|
32878
|
+
},
|
|
32879
|
+
member: args.member,
|
|
32880
|
+
document: args.document,
|
|
32881
|
+
createdValues: [],
|
|
32882
|
+
sessionValues,
|
|
32883
|
+
storedConstructionReplay: true,
|
|
32884
|
+
sourceValueId: rootId,
|
|
32885
|
+
...args.readTracking === void 0 ? {} : { readTracking: args.readTracking },
|
|
32886
|
+
saveStaticBindings: args.saveStaticBindings,
|
|
32887
|
+
sessionStaticBindings: args.sessionStaticBindings
|
|
32888
|
+
});
|
|
32889
|
+
const root = sessionValues.get(rootId);
|
|
32890
|
+
if (root === void 0) {
|
|
32891
|
+
throw new Error(
|
|
32892
|
+
`Applied variant "${args.variantId}" replay lost instance root "${rootId}".`
|
|
32893
|
+
);
|
|
32894
|
+
}
|
|
32895
|
+
sessionValues.delete(rootId);
|
|
32896
|
+
return {
|
|
32897
|
+
...args.constructed,
|
|
32898
|
+
root: {
|
|
32899
|
+
...root,
|
|
32900
|
+
instanceAppliedVariantId: args.variantId,
|
|
32901
|
+
instanceAppliedVariantRowValueId: args.variantRowValueId
|
|
32902
|
+
},
|
|
32903
|
+
createdValues: [...sessionValues.values()]
|
|
32904
|
+
};
|
|
32905
|
+
}
|
|
32735
32906
|
function resolveVirtualInstanceGraph(args) {
|
|
32736
32907
|
const expansion = args.expansionIndex ?? indexExpansion(args);
|
|
32737
32908
|
const recorder = args.readRecorder ?? null;
|
|
@@ -33550,6 +33721,11 @@ function expandStoredClassValue(args) {
|
|
|
33550
33721
|
pinnedRootSchemaKeys: /* @__PURE__ */ new Set()
|
|
33551
33722
|
};
|
|
33552
33723
|
}
|
|
33724
|
+
function owningInstanceRootId(graph) {
|
|
33725
|
+
let owner = graph;
|
|
33726
|
+
while (owner?.containingGraph !== void 0) owner = owner.containingGraph;
|
|
33727
|
+
return owner?.instanceRootId ?? null;
|
|
33728
|
+
}
|
|
33553
33729
|
function isStoredClassResolutionRoot(value) {
|
|
33554
33730
|
if (!isLiteralValueContent(value)) return false;
|
|
33555
33731
|
if (isVirtualInstanceRootShape(value)) return true;
|
|
@@ -33639,6 +33815,393 @@ function planVirtualOverrideResets(args) {
|
|
|
33639
33815
|
});
|
|
33640
33816
|
return { deletes, updates };
|
|
33641
33817
|
}
|
|
33818
|
+
function planCollapseVirtualInstance(args) {
|
|
33819
|
+
const protectedIds = args.protectedValueIds ?? /* @__PURE__ */ new Set();
|
|
33820
|
+
const pinnedIds = args.pinnedValueIds ?? /* @__PURE__ */ new Set();
|
|
33821
|
+
const deleteIds = /* @__PURE__ */ new Set();
|
|
33822
|
+
const pairingMismatchIds = /* @__PURE__ */ new Set();
|
|
33823
|
+
const updates = [];
|
|
33824
|
+
const subtreeFacts = /* @__PURE__ */ new Map();
|
|
33825
|
+
const stampsByPath = /* @__PURE__ */ new Map();
|
|
33826
|
+
const reproducibleByPath = /* @__PURE__ */ new Map();
|
|
33827
|
+
const isReproduciblePath = (location) => {
|
|
33828
|
+
const cached = reproducibleByPath.get(location.pathKey);
|
|
33829
|
+
if (cached !== void 0) return cached;
|
|
33830
|
+
reproducibleByPath.set(location.pathKey, false);
|
|
33831
|
+
const reproducible = computeReproduciblePath(location);
|
|
33832
|
+
reproducibleByPath.set(location.pathKey, reproducible);
|
|
33833
|
+
return reproducible;
|
|
33834
|
+
};
|
|
33835
|
+
const nestedRootIds = args.nestedRootValueIds ?? /* @__PURE__ */ new Set();
|
|
33836
|
+
const isNestedRoot = (valueId) => valueId !== args.graph.root.id && nestedRootIds.has(valueId);
|
|
33837
|
+
const ownsChildInterior = (child) => {
|
|
33838
|
+
const stored = child.materializedRow;
|
|
33839
|
+
if (stored === null) return true;
|
|
33840
|
+
if (isNestedRoot(stored.id)) return false;
|
|
33841
|
+
if (!isLiteralValueContent(stored)) return true;
|
|
33842
|
+
const provenance = args.graph.compareCreationProvenance(child);
|
|
33843
|
+
if (!provenance.sameType) return false;
|
|
33844
|
+
if (provenance.sameRecipe) return true;
|
|
33845
|
+
if (typeof stored.instanceConstructorId === "string") return false;
|
|
33846
|
+
if (typeof stored.instanceVariantId === "string") return false;
|
|
33847
|
+
if (typeof stored.instanceAppliedVariantId === "string") return false;
|
|
33848
|
+
const storedArgs = stored.constructorArgs;
|
|
33849
|
+
if (storedArgs != null && Object.keys(storedArgs).length > 0) return false;
|
|
33850
|
+
return !isInitValueContent(child.member.defaultValue);
|
|
33851
|
+
};
|
|
33852
|
+
const valuesById = args.valuesById ?? /* @__PURE__ */ new Map();
|
|
33853
|
+
const frameDerivedLineages = /* @__PURE__ */ new Set();
|
|
33854
|
+
for (const location of args.graph.locationsByPath.values()) {
|
|
33855
|
+
const derived = location.virtualRow.sourceValueId;
|
|
33856
|
+
if (typeof derived === "string") frameDerivedLineages.add(derived);
|
|
33857
|
+
}
|
|
33858
|
+
const ownsLineageByPath = /* @__PURE__ */ new Map();
|
|
33859
|
+
const frameOwnsLineage = (location) => {
|
|
33860
|
+
const cached = ownsLineageByPath.get(location.pathKey);
|
|
33861
|
+
if (cached !== void 0) return cached;
|
|
33862
|
+
ownsLineageByPath.set(location.pathKey, true);
|
|
33863
|
+
let owns = true;
|
|
33864
|
+
let parentPath = parentPathKey(location.pathKey);
|
|
33865
|
+
while (parentPath !== null) {
|
|
33866
|
+
const ancestor = args.graph.locationsByPath.get(parentPath);
|
|
33867
|
+
if (ancestor === void 0) break;
|
|
33868
|
+
const ancestorId = ancestor.materializedRow?.id;
|
|
33869
|
+
if (ancestorId !== void 0 && isNestedRoot(ancestorId)) {
|
|
33870
|
+
owns = false;
|
|
33871
|
+
break;
|
|
33872
|
+
}
|
|
33873
|
+
parentPath = parentPathKey(parentPath);
|
|
33874
|
+
}
|
|
33875
|
+
ownsLineageByPath.set(location.pathKey, owns);
|
|
33876
|
+
return owns;
|
|
33877
|
+
};
|
|
33878
|
+
const isCrossFrameLineageRecord = (location, stored) => {
|
|
33879
|
+
const storedSource = stored.sourceValueId ?? null;
|
|
33880
|
+
if (storedSource === null) return false;
|
|
33881
|
+
if (storedSource === stored.id) return false;
|
|
33882
|
+
if (frameDerivedLineages.has(storedSource)) return false;
|
|
33883
|
+
const named = valuesById.get(storedSource);
|
|
33884
|
+
if (named === void 0) return false;
|
|
33885
|
+
if (!isLiteralValueContent(stored)) return false;
|
|
33886
|
+
if (!isLiteralValueContent(named)) {
|
|
33887
|
+
return args.graph.compareLeafContent(location);
|
|
33888
|
+
}
|
|
33889
|
+
return semanticEqual(
|
|
33890
|
+
normalizeLeafPayload(named, location.member),
|
|
33891
|
+
normalizeLeafPayload(stored, location.member)
|
|
33892
|
+
);
|
|
33893
|
+
};
|
|
33894
|
+
const computeReproduciblePath = (location) => {
|
|
33895
|
+
const segment = location.parentSegment;
|
|
33896
|
+
if (segment === null || location.pathKey === ROOT_PATH) return true;
|
|
33897
|
+
const parentPath = parentPathKey(location.pathKey);
|
|
33898
|
+
if (parentPath === null) return true;
|
|
33899
|
+
const parent = args.graph.locationsByPath.get(parentPath);
|
|
33900
|
+
if (parent === void 0) return false;
|
|
33901
|
+
if (!isReproduciblePath(parent)) return false;
|
|
33902
|
+
if (!isMemberEntryCollectionBase(parent.member)) return true;
|
|
33903
|
+
if (listKindOf(parent.member) !== 1 /* Unordered */) return true;
|
|
33904
|
+
return unorderedEntryMatchedByProvenance(location);
|
|
33905
|
+
};
|
|
33906
|
+
const normalizedStoredRow = (location, stored) => {
|
|
33907
|
+
const cached = stampsByPath.get(location.pathKey);
|
|
33908
|
+
if (cached !== void 0) return withLegacyLineage(stored, cached);
|
|
33909
|
+
const stamp = settleLineage(stored, location.virtualRow, {
|
|
33910
|
+
reproduciblePosition: isReproduciblePath(location),
|
|
33911
|
+
frameOwnsLineage: frameOwnsLineage(location),
|
|
33912
|
+
crossFrameRecord: isCrossFrameLineageRecord(location, stored)
|
|
33913
|
+
});
|
|
33914
|
+
stampsByPath.set(location.pathKey, stamp);
|
|
33915
|
+
return withLegacyLineage(stored, stamp);
|
|
33916
|
+
};
|
|
33917
|
+
const compareSubtree = (location) => {
|
|
33918
|
+
const cached = subtreeFacts.get(location.pathKey);
|
|
33919
|
+
if (cached !== void 0) return cached;
|
|
33920
|
+
const stored = location.materializedRow;
|
|
33921
|
+
if (stored !== null && isInitValueContent(stored)) {
|
|
33922
|
+
const result2 = {
|
|
33923
|
+
defaultEqual: false,
|
|
33924
|
+
contentEqual: false,
|
|
33925
|
+
protected: true
|
|
33926
|
+
};
|
|
33927
|
+
subtreeFacts.set(location.pathKey, result2);
|
|
33928
|
+
return result2;
|
|
33929
|
+
}
|
|
33930
|
+
const real = stored === null ? null : normalizedStoredRow(location, stored);
|
|
33931
|
+
if (real === null) {
|
|
33932
|
+
const result2 = {
|
|
33933
|
+
defaultEqual: true,
|
|
33934
|
+
contentEqual: true,
|
|
33935
|
+
protected: false
|
|
33936
|
+
};
|
|
33937
|
+
subtreeFacts.set(location.pathKey, result2);
|
|
33938
|
+
return result2;
|
|
33939
|
+
}
|
|
33940
|
+
let protectedSubtree = protectedIds.has(real.id) || pinnedIds.has(real.id) || args.removableValueIds !== void 0 && !args.removableValueIds.has(real.id) || location.parentId === args.graph.root.id && location.parentSegment?.kind === "class" && args.graph.pinnedRootSchemaKeys?.has(
|
|
33941
|
+
location.parentSegment.schemaKey
|
|
33942
|
+
) === true;
|
|
33943
|
+
const ownsLineage = frameOwnsLineage(location);
|
|
33944
|
+
const pairingMismatch = provenancePairingDisagrees(
|
|
33945
|
+
real,
|
|
33946
|
+
location.virtualRow,
|
|
33947
|
+
{
|
|
33948
|
+
reproduciblePosition: isReproduciblePath(location),
|
|
33949
|
+
frameOwnsLineage: true,
|
|
33950
|
+
crossFrameRecord: isCrossFrameLineageRecord(location, real)
|
|
33951
|
+
}
|
|
33952
|
+
);
|
|
33953
|
+
let defaultEqual = !pairingMismatch && args.graph.compareCreationProvenance(location).sameRecipe;
|
|
33954
|
+
let contentEqual = true;
|
|
33955
|
+
const storedIsNull = real.value === null;
|
|
33956
|
+
const virtualIsNull = location.virtualRow.value === null;
|
|
33957
|
+
if (storedIsNull || virtualIsNull) {
|
|
33958
|
+
defaultEqual &&= storedIsNull && virtualIsNull;
|
|
33959
|
+
contentEqual &&= storedIsNull && virtualIsNull;
|
|
33960
|
+
} else if (isMemberClassBase(location.member)) {
|
|
33961
|
+
for (const schemaKey of Object.keys(stringRecord(real.value))) {
|
|
33962
|
+
const child = args.graph.locationsByPath.get(
|
|
33963
|
+
appendVirtualValuePath(location.pathKey, {
|
|
33964
|
+
kind: "class",
|
|
33965
|
+
schemaKey
|
|
33966
|
+
})
|
|
33967
|
+
);
|
|
33968
|
+
if (child === void 0) {
|
|
33969
|
+
defaultEqual = false;
|
|
33970
|
+
contentEqual = false;
|
|
33971
|
+
continue;
|
|
33972
|
+
}
|
|
33973
|
+
const facts = compareSubtree(child);
|
|
33974
|
+
defaultEqual &&= facts.defaultEqual;
|
|
33975
|
+
contentEqual &&= facts.contentEqual;
|
|
33976
|
+
protectedSubtree ||= facts.protected;
|
|
33977
|
+
}
|
|
33978
|
+
} else if (isMemberEntryCollectionBase(location.member)) {
|
|
33979
|
+
if (listKindOf(location.member) === 1 /* Unordered */) {
|
|
33980
|
+
protectedSubtree = true;
|
|
33981
|
+
const storedEntries = args.graph.materializedUnorderedEntryIdsByContainerId.get(real.id) ?? [];
|
|
33982
|
+
const virtualEntries = args.graph.expandedChildPathsByParentPath.get(location.pathKey) ?? [];
|
|
33983
|
+
const resolvedEntries = args.graph.childPathsByParentPath.get(location.pathKey) ?? [];
|
|
33984
|
+
const storedIsArray = Array.isArray(real.value);
|
|
33985
|
+
const virtualIsArray = Array.isArray(location.virtualRow.value);
|
|
33986
|
+
const entryCountsAgree = storedEntries.length === virtualEntries.length && resolvedEntries.length === storedEntries.length;
|
|
33987
|
+
defaultEqual &&= storedIsArray;
|
|
33988
|
+
defaultEqual &&= virtualIsArray;
|
|
33989
|
+
defaultEqual &&= entryCountsAgree;
|
|
33990
|
+
contentEqual &&= storedIsArray;
|
|
33991
|
+
contentEqual &&= virtualIsArray;
|
|
33992
|
+
contentEqual &&= entryCountsAgree;
|
|
33993
|
+
const resolvedStoredIds = [];
|
|
33994
|
+
for (const childPath of resolvedEntries) {
|
|
33995
|
+
const child = args.graph.locationsByPath.get(childPath);
|
|
33996
|
+
if (child?.materializedRow === null || child === void 0) {
|
|
33997
|
+
defaultEqual = false;
|
|
33998
|
+
contentEqual = false;
|
|
33999
|
+
continue;
|
|
34000
|
+
}
|
|
34001
|
+
resolvedStoredIds.push(child.materializedRow.id);
|
|
34002
|
+
const facts = compareSubtree(child);
|
|
34003
|
+
defaultEqual &&= facts.defaultEqual;
|
|
34004
|
+
contentEqual &&= facts.contentEqual;
|
|
34005
|
+
}
|
|
34006
|
+
const membershipEqual = semanticEqual(
|
|
34007
|
+
resolvedStoredIds.sort(),
|
|
34008
|
+
[...storedEntries].sort()
|
|
34009
|
+
);
|
|
34010
|
+
defaultEqual &&= membershipEqual;
|
|
34011
|
+
contentEqual &&= membershipEqual;
|
|
34012
|
+
} else {
|
|
34013
|
+
const stored2 = Array.isArray(real.value) ? real.value : null;
|
|
34014
|
+
const virtual = Array.isArray(location.virtualRow.value) ? location.virtualRow.value : null;
|
|
34015
|
+
const bothArrays = stored2 !== null && virtual !== null;
|
|
34016
|
+
const lengthsAgree = stored2?.length === virtual?.length;
|
|
34017
|
+
defaultEqual &&= bothArrays;
|
|
34018
|
+
defaultEqual &&= lengthsAgree;
|
|
34019
|
+
contentEqual &&= bothArrays;
|
|
34020
|
+
contentEqual &&= lengthsAgree;
|
|
34021
|
+
for (let index = 0; index < (stored2?.length ?? 0); index += 1) {
|
|
34022
|
+
if (stored2?.[index] === null && virtual?.[index] === null) continue;
|
|
34023
|
+
const child = args.graph.locationsByPath.get(
|
|
34024
|
+
appendVirtualValuePath(location.pathKey, { kind: "list", index })
|
|
34025
|
+
);
|
|
34026
|
+
if (child === void 0) {
|
|
34027
|
+
defaultEqual = false;
|
|
34028
|
+
contentEqual = false;
|
|
34029
|
+
continue;
|
|
34030
|
+
}
|
|
34031
|
+
const facts = compareSubtree(child);
|
|
34032
|
+
defaultEqual &&= facts.defaultEqual;
|
|
34033
|
+
contentEqual &&= facts.contentEqual;
|
|
34034
|
+
protectedSubtree ||= facts.protected;
|
|
34035
|
+
}
|
|
34036
|
+
}
|
|
34037
|
+
} else if (isMemberDictionaryBase(location.member)) {
|
|
34038
|
+
const stored2 = stringRecord(real.value);
|
|
34039
|
+
const virtual = stringRecord(location.virtualRow.value);
|
|
34040
|
+
const keysEqual = semanticEqual(
|
|
34041
|
+
Object.keys(stored2).sort(),
|
|
34042
|
+
Object.keys(virtual).sort()
|
|
34043
|
+
);
|
|
34044
|
+
defaultEqual &&= keysEqual;
|
|
34045
|
+
contentEqual &&= keysEqual;
|
|
34046
|
+
for (const key of Object.keys(stored2)) {
|
|
34047
|
+
const child = args.graph.locationsByPath.get(
|
|
34048
|
+
appendVirtualValuePath(location.pathKey, { kind: "dictionary", key })
|
|
34049
|
+
);
|
|
34050
|
+
if (child === void 0) {
|
|
34051
|
+
defaultEqual = false;
|
|
34052
|
+
contentEqual = false;
|
|
34053
|
+
continue;
|
|
34054
|
+
}
|
|
34055
|
+
const facts = compareSubtree(child);
|
|
34056
|
+
defaultEqual &&= facts.defaultEqual;
|
|
34057
|
+
contentEqual &&= facts.contentEqual;
|
|
34058
|
+
protectedSubtree ||= facts.protected;
|
|
34059
|
+
}
|
|
34060
|
+
} else {
|
|
34061
|
+
const leafEqual = args.graph.compareLeafContent(location);
|
|
34062
|
+
defaultEqual &&= leafEqual;
|
|
34063
|
+
contentEqual &&= leafEqual;
|
|
34064
|
+
}
|
|
34065
|
+
const result = { defaultEqual, contentEqual, protected: protectedSubtree };
|
|
34066
|
+
if (pairingMismatch && ownsLineage && contentEqual) {
|
|
34067
|
+
pairingMismatchIds.add(real.id);
|
|
34068
|
+
}
|
|
34069
|
+
subtreeFacts.set(location.pathKey, result);
|
|
34070
|
+
return result;
|
|
34071
|
+
};
|
|
34072
|
+
const deleteSubtree = (location) => {
|
|
34073
|
+
const descendants = [];
|
|
34074
|
+
const pending = [location.pathKey];
|
|
34075
|
+
while (pending.length > 0) {
|
|
34076
|
+
const path = pending.pop();
|
|
34077
|
+
if (path === void 0) continue;
|
|
34078
|
+
const candidate = args.graph.locationsByPath.get(path);
|
|
34079
|
+
if (candidate !== void 0) descendants.push(candidate);
|
|
34080
|
+
for (const childPath of args.graph.childPathsByParentPath.get(path) ?? []) {
|
|
34081
|
+
pending.push(childPath);
|
|
34082
|
+
}
|
|
34083
|
+
}
|
|
34084
|
+
descendants.sort(
|
|
34085
|
+
(left, right) => pathDepth(right.pathKey) - pathDepth(left.pathKey)
|
|
34086
|
+
);
|
|
34087
|
+
for (const candidate of descendants) {
|
|
34088
|
+
if (candidate.materializedRow !== null) {
|
|
34089
|
+
deleteIds.add(candidate.materializedRow.id);
|
|
34090
|
+
}
|
|
34091
|
+
}
|
|
34092
|
+
};
|
|
34093
|
+
const sparsifyClass = (location) => {
|
|
34094
|
+
const real = location.materializedRow;
|
|
34095
|
+
if (real === null || isInitValueContent(real) || !isMemberClassBase(location.member))
|
|
34096
|
+
return;
|
|
34097
|
+
const stored = stringRecord(real.value);
|
|
34098
|
+
const next = {};
|
|
34099
|
+
for (const [schemaKey, childId] of Object.entries(stored)) {
|
|
34100
|
+
const child = args.graph.locationsByPath.get(
|
|
34101
|
+
appendVirtualValuePath(location.pathKey, { kind: "class", schemaKey })
|
|
34102
|
+
);
|
|
34103
|
+
if (child === void 0) {
|
|
34104
|
+
next[schemaKey] = childId;
|
|
34105
|
+
continue;
|
|
34106
|
+
}
|
|
34107
|
+
const facts = compareSubtree(child);
|
|
34108
|
+
if (facts.defaultEqual && !facts.protected) {
|
|
34109
|
+
deleteSubtree(child);
|
|
34110
|
+
continue;
|
|
34111
|
+
}
|
|
34112
|
+
next[schemaKey] = child.materializedRow?.id ?? childId;
|
|
34113
|
+
if (!isMemberClassBase(child.member)) continue;
|
|
34114
|
+
if (!ownsChildInterior(child)) continue;
|
|
34115
|
+
sparsifyClass(child);
|
|
34116
|
+
}
|
|
34117
|
+
if (!semanticEqual(stored, next)) {
|
|
34118
|
+
updates.push({ valueId: real.id, value: next });
|
|
34119
|
+
}
|
|
34120
|
+
};
|
|
34121
|
+
const stampSurvivingRow = (valueId, pathKey) => {
|
|
34122
|
+
const stamp = stampsByPath.get(pathKey);
|
|
34123
|
+
if (stamp === void 0) return;
|
|
34124
|
+
if (stampIsEmpty(stamp)) return;
|
|
34125
|
+
const sourceValueId = stamp.clearSourceValueId ? null : stamp.sourceValueId;
|
|
34126
|
+
const existing = updates.find((update) => update.valueId === valueId);
|
|
34127
|
+
if (existing !== void 0) {
|
|
34128
|
+
if (sourceValueId !== null || stamp.clearSourceValueId) {
|
|
34129
|
+
existing.sourceValueId = sourceValueId;
|
|
34130
|
+
}
|
|
34131
|
+
return;
|
|
34132
|
+
}
|
|
34133
|
+
const location = args.graph.locationsById.get(valueId);
|
|
34134
|
+
const stored = location?.materializedRow;
|
|
34135
|
+
if (stored === void 0 || stored === null) return;
|
|
34136
|
+
updates.push({
|
|
34137
|
+
valueId,
|
|
34138
|
+
// Payload untouched: this update exists to carry lineage. The corpus
|
|
34139
|
+
// planner drops a change whose row is byte-identical, so a re-run over an
|
|
34140
|
+
// already-corrected row produces nothing.
|
|
34141
|
+
value: stored.value,
|
|
34142
|
+
...sourceValueId === null && !stamp.clearSourceValueId ? {} : { sourceValueId }
|
|
34143
|
+
});
|
|
34144
|
+
};
|
|
34145
|
+
sparsifyClass(args.graph.root);
|
|
34146
|
+
const deletes = [...deleteIds].sort((left, right) => {
|
|
34147
|
+
const leftLocation = args.graph.locationsById.get(left);
|
|
34148
|
+
const rightLocation = args.graph.locationsById.get(right);
|
|
34149
|
+
return pathDepth(rightLocation?.pathKey ?? ROOT_PATH) - pathDepth(leftLocation?.pathKey ?? ROOT_PATH);
|
|
34150
|
+
});
|
|
34151
|
+
const locatedRows = [];
|
|
34152
|
+
for (const location of args.graph.locationsByPath.values()) {
|
|
34153
|
+
if (location.pathKey === ROOT_PATH) continue;
|
|
34154
|
+
const row = location.materializedRow;
|
|
34155
|
+
if (row === null) continue;
|
|
34156
|
+
locatedRows.push({ id: row.id, pathKey: location.pathKey });
|
|
34157
|
+
}
|
|
34158
|
+
locatedRows.sort((left, right) => left.pathKey.localeCompare(right.pathKey));
|
|
34159
|
+
const materializedNonRoot = [];
|
|
34160
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
34161
|
+
for (const entry of locatedRows) {
|
|
34162
|
+
if (seenIds.has(entry.id)) continue;
|
|
34163
|
+
seenIds.add(entry.id);
|
|
34164
|
+
materializedNonRoot.push(entry);
|
|
34165
|
+
}
|
|
34166
|
+
const keptRowReasons = /* @__PURE__ */ new Map();
|
|
34167
|
+
const breakdown = { content: 0, provenanceOnly: 0, pinnedOrReference: 0 };
|
|
34168
|
+
const provenanceOnlySampleIds = [];
|
|
34169
|
+
const contentSampleIds = [];
|
|
34170
|
+
let keptReferenceTargetRows = 0;
|
|
34171
|
+
for (const entry of materializedNonRoot) {
|
|
34172
|
+
if (protectedIds.has(entry.id)) keptReferenceTargetRows += 1;
|
|
34173
|
+
if (deleteIds.has(entry.id)) continue;
|
|
34174
|
+
if (args.removableValueIds === void 0)
|
|
34175
|
+
stampSurvivingRow(entry.id, entry.pathKey);
|
|
34176
|
+
const reason = keptRowReason(subtreeFacts.get(entry.pathKey));
|
|
34177
|
+
keptRowReasons.set(entry.id, reason);
|
|
34178
|
+
breakdown[reason] += 1;
|
|
34179
|
+
if (reason === "provenanceOnly" && provenanceOnlySampleIds.length < KEPT_ROW_SAMPLE_LIMIT) {
|
|
34180
|
+
provenanceOnlySampleIds.push(entry.id);
|
|
34181
|
+
}
|
|
34182
|
+
if (reason === "content" && contentSampleIds.length < KEPT_ROW_SAMPLE_LIMIT) {
|
|
34183
|
+
contentSampleIds.push(entry.id);
|
|
34184
|
+
}
|
|
34185
|
+
}
|
|
34186
|
+
return {
|
|
34187
|
+
deletes,
|
|
34188
|
+
updates,
|
|
34189
|
+
deletedDefaultEqualRows: deletes.length,
|
|
34190
|
+
keptOverrideRows: keptRowReasons.size,
|
|
34191
|
+
keptReferenceTargetRows,
|
|
34192
|
+
pairingMismatchValueIds: [...pairingMismatchIds].sort(),
|
|
34193
|
+
keptRowBreakdown: breakdown,
|
|
34194
|
+
provenanceOnlySampleIds,
|
|
34195
|
+
contentSampleIds,
|
|
34196
|
+
keptRowReasons
|
|
34197
|
+
};
|
|
34198
|
+
}
|
|
34199
|
+
function keptRowReason(facts) {
|
|
34200
|
+
if (facts === void 0) return "content";
|
|
34201
|
+
if (!facts.contentEqual) return "content";
|
|
34202
|
+
if (!facts.defaultEqual) return "provenanceOnly";
|
|
34203
|
+
return "pinnedOrReference";
|
|
34204
|
+
}
|
|
33642
34205
|
function closeClassArgumentsFromRowStamp(member, row) {
|
|
33643
34206
|
if (!isMemberClassBase(member)) return member;
|
|
33644
34207
|
const stamp = row.genericBindings;
|
|
@@ -33977,7 +34540,9 @@ function compareContextualCreationProvenance(left, right, context) {
|
|
|
33977
34540
|
constructorArgs: literal3.constructorArgs ?? {},
|
|
33978
34541
|
instanceConstructorId: literal3.instanceConstructorId ?? null,
|
|
33979
34542
|
instanceVariantId: literal3.instanceVariantId ?? null,
|
|
33980
|
-
instanceVariantRowValueId: literal3.instanceVariantRowValueId ?? null
|
|
34543
|
+
instanceVariantRowValueId: literal3.instanceVariantRowValueId ?? null,
|
|
34544
|
+
instanceAppliedVariantId: literal3.instanceAppliedVariantId ?? null,
|
|
34545
|
+
instanceAppliedVariantRowValueId: literal3.instanceAppliedVariantRowValueId ?? null
|
|
33981
34546
|
};
|
|
33982
34547
|
};
|
|
33983
34548
|
return {
|
|
@@ -33988,10 +34553,80 @@ function compareContextualCreationProvenance(left, right, context) {
|
|
|
33988
34553
|
)
|
|
33989
34554
|
};
|
|
33990
34555
|
}
|
|
34556
|
+
var SYNTHETIC_LINEAGE_PREFIXES = ["missing-expansion:", "path:"];
|
|
34557
|
+
function unorderedEntryMatchedByProvenance(location) {
|
|
34558
|
+
const storedSource = location.materializedRow?.sourceValueId ?? null;
|
|
34559
|
+
if (storedSource === null) return false;
|
|
34560
|
+
return storedSource === (location.virtualRow.sourceValueId ?? null);
|
|
34561
|
+
}
|
|
34562
|
+
function adoptableLineage(stored, expanded, reproduciblePosition) {
|
|
34563
|
+
if (!reproduciblePosition) return null;
|
|
34564
|
+
const expandedSource = expanded.sourceValueId ?? null;
|
|
34565
|
+
if (expandedSource === null) return null;
|
|
34566
|
+
if (expandedSource === stored.id) return null;
|
|
34567
|
+
if (SYNTHETIC_LINEAGE_PREFIXES.some(
|
|
34568
|
+
(prefix) => expandedSource.startsWith(prefix)
|
|
34569
|
+
)) {
|
|
34570
|
+
return null;
|
|
34571
|
+
}
|
|
34572
|
+
return expandedSource;
|
|
34573
|
+
}
|
|
34574
|
+
function storedLineageIsMeaningless(materialized, reproduciblePosition) {
|
|
34575
|
+
const storedSource = materialized.sourceValueId ?? null;
|
|
34576
|
+
if (storedSource === null) return false;
|
|
34577
|
+
if (storedSource === materialized.id) return true;
|
|
34578
|
+
return !reproduciblePosition;
|
|
34579
|
+
}
|
|
34580
|
+
function provenancePairingDisagrees(materialized, expanded, frame) {
|
|
34581
|
+
const storedSource = materialized.sourceValueId ?? null;
|
|
34582
|
+
if (storedSource === null) return false;
|
|
34583
|
+
if (!frame.frameOwnsLineage) return false;
|
|
34584
|
+
if (frame.crossFrameRecord) return false;
|
|
34585
|
+
if (storedLineageIsMeaningless(materialized, frame.reproduciblePosition)) {
|
|
34586
|
+
return false;
|
|
34587
|
+
}
|
|
34588
|
+
return storedSource !== (expanded.sourceValueId ?? null);
|
|
34589
|
+
}
|
|
34590
|
+
function settleLineage(stored, expanded, frame) {
|
|
34591
|
+
const nothing = { sourceValueId: null, clearSourceValueId: false };
|
|
34592
|
+
if (!frame.frameOwnsLineage) return nothing;
|
|
34593
|
+
const storedSource = stored.sourceValueId ?? null;
|
|
34594
|
+
const expandedSource = expanded.sourceValueId ?? null;
|
|
34595
|
+
if (storedSource === null) {
|
|
34596
|
+
return {
|
|
34597
|
+
sourceValueId: adoptableLineage(
|
|
34598
|
+
stored,
|
|
34599
|
+
expanded,
|
|
34600
|
+
frame.reproduciblePosition
|
|
34601
|
+
),
|
|
34602
|
+
clearSourceValueId: false
|
|
34603
|
+
};
|
|
34604
|
+
}
|
|
34605
|
+
if (storedSource === expandedSource) return nothing;
|
|
34606
|
+
if (frame.crossFrameRecord && frame.reproduciblePosition) {
|
|
34607
|
+
return expandedSource === null ? { sourceValueId: null, clearSourceValueId: true } : { sourceValueId: expandedSource, clearSourceValueId: false };
|
|
34608
|
+
}
|
|
34609
|
+
if (storedLineageIsMeaningless(stored, frame.reproduciblePosition)) {
|
|
34610
|
+
return { sourceValueId: null, clearSourceValueId: true };
|
|
34611
|
+
}
|
|
34612
|
+
return nothing;
|
|
34613
|
+
}
|
|
33991
34614
|
function readClassId(row) {
|
|
33992
34615
|
const classId = Reflect.get(row, "classId");
|
|
33993
34616
|
return typeof classId === "string" ? classId : null;
|
|
33994
34617
|
}
|
|
34618
|
+
function stampIsEmpty(stamp) {
|
|
34619
|
+
return stamp.sourceValueId === null && !stamp.clearSourceValueId;
|
|
34620
|
+
}
|
|
34621
|
+
function withLegacyLineage(stored, stamp) {
|
|
34622
|
+
if (stampIsEmpty(stamp)) return stored;
|
|
34623
|
+
const next = {
|
|
34624
|
+
...stored,
|
|
34625
|
+
...stamp.sourceValueId === null ? {} : { sourceValueId: stamp.sourceValueId }
|
|
34626
|
+
};
|
|
34627
|
+
if (stamp.clearSourceValueId) delete next.sourceValueId;
|
|
34628
|
+
return next;
|
|
34629
|
+
}
|
|
33995
34630
|
function literalRow(row) {
|
|
33996
34631
|
if (!isLiteralValueContent(row)) {
|
|
33997
34632
|
throw new Error(`Expected literal instance row "${row.id}".`);
|
|
@@ -34207,40 +34842,37 @@ function resolveVariantInstanceGraphForDocument(args) {
|
|
|
34207
34842
|
rootMember,
|
|
34208
34843
|
readRecorder: args.readRecorder
|
|
34209
34844
|
});
|
|
34210
|
-
|
|
34845
|
+
let priorInstanceRoot = args.priorInstanceRoot;
|
|
34846
|
+
let nextInstanceRoot = args.nextInstanceRoot;
|
|
34847
|
+
const resolvePriorGraph = () => resolveVirtualInstanceGraph({
|
|
34211
34848
|
document: document2,
|
|
34212
|
-
instanceRoot:
|
|
34849
|
+
instanceRoot: priorInstanceRoot,
|
|
34213
34850
|
rootMember,
|
|
34214
34851
|
expandedRoot: priorExpanded.root,
|
|
34215
34852
|
expandedRows: priorExpanded.rows,
|
|
34216
34853
|
materializedRows: [...materializedById.values()],
|
|
34217
34854
|
readRecorder: args.readRecorder
|
|
34218
34855
|
});
|
|
34219
|
-
const priorAnsweredIds = [];
|
|
34220
|
-
const incomingAnsweredIds = [];
|
|
34221
|
-
for (const valueId of args.answeredValueIds) {
|
|
34222
|
-
const bucket = priorGraph.locationsById.has(valueId) ? priorAnsweredIds : incomingAnsweredIds;
|
|
34223
|
-
bucket.push(valueId);
|
|
34224
|
-
}
|
|
34225
34856
|
const clearedValueIds = /* @__PURE__ */ new Set();
|
|
34226
|
-
|
|
34227
|
-
const resetAnsweredValues = (graph, valueIds) => {
|
|
34228
|
-
if (valueIds.length === 0) return;
|
|
34229
|
-
const reset = planVirtualOverrideResets({ graph, valueIds });
|
|
34857
|
+
const applyReset = (graph, reset) => {
|
|
34230
34858
|
for (const valueId of reset.deletes) {
|
|
34231
34859
|
clearedValueIds.add(valueId);
|
|
34232
34860
|
materializedById.delete(valueId);
|
|
34233
34861
|
}
|
|
34234
34862
|
for (const update of reset.updates) {
|
|
34235
34863
|
if (update.valueId === nextInstanceRoot.id) {
|
|
34236
|
-
const nextRecord = { ...stringRecord(nextInstanceRoot.value) };
|
|
34237
34864
|
const resetRecord = stringRecord(update.value);
|
|
34238
34865
|
const priorRecord = stringRecord(graph.root.materializedRow?.value);
|
|
34239
|
-
|
|
34240
|
-
|
|
34241
|
-
|
|
34242
|
-
|
|
34243
|
-
|
|
34866
|
+
const withoutReset = (root2) => {
|
|
34867
|
+
const record4 = { ...stringRecord(root2.value) };
|
|
34868
|
+
for (const schemaKey of Object.keys(priorRecord)) {
|
|
34869
|
+
if (!Object.hasOwn(resetRecord, schemaKey))
|
|
34870
|
+
delete record4[schemaKey];
|
|
34871
|
+
}
|
|
34872
|
+
return { ...root2, value: record4 };
|
|
34873
|
+
};
|
|
34874
|
+
priorInstanceRoot = withoutReset(literalRow(priorInstanceRoot));
|
|
34875
|
+
nextInstanceRoot = withoutReset(literalRow(nextInstanceRoot));
|
|
34244
34876
|
}
|
|
34245
34877
|
const existing = materializedById.get(update.valueId);
|
|
34246
34878
|
if (existing !== void 0) {
|
|
@@ -34252,6 +34884,28 @@ function resolveVariantInstanceGraphForDocument(args) {
|
|
|
34252
34884
|
}
|
|
34253
34885
|
materializedById.set(nextInstanceRoot.id, nextInstanceRoot);
|
|
34254
34886
|
};
|
|
34887
|
+
let priorGraph = resolvePriorGraph();
|
|
34888
|
+
if (args.virtualCopyIds !== void 0 && args.virtualCopyIds.length > 0) {
|
|
34889
|
+
const collapse = planCollapseVirtualInstance({
|
|
34890
|
+
graph: priorGraph,
|
|
34891
|
+
removableValueIds: new Set(args.virtualCopyIds)
|
|
34892
|
+
});
|
|
34893
|
+
if (collapse.deletes.length > 0 || collapse.updates.length > 0) {
|
|
34894
|
+
applyReset(priorGraph, collapse);
|
|
34895
|
+
materializedById.set(priorInstanceRoot.id, priorInstanceRoot);
|
|
34896
|
+
priorGraph = resolvePriorGraph();
|
|
34897
|
+
}
|
|
34898
|
+
}
|
|
34899
|
+
const priorAnsweredIds = [];
|
|
34900
|
+
const incomingAnsweredIds = [];
|
|
34901
|
+
for (const valueId of args.answeredValueIds) {
|
|
34902
|
+
const bucket = priorGraph.locationsById.has(valueId) ? priorAnsweredIds : incomingAnsweredIds;
|
|
34903
|
+
bucket.push(valueId);
|
|
34904
|
+
}
|
|
34905
|
+
const resetAnsweredValues = (graph, valueIds) => {
|
|
34906
|
+
if (valueIds.length === 0) return;
|
|
34907
|
+
applyReset(graph, planVirtualOverrideResets({ graph, valueIds }));
|
|
34908
|
+
};
|
|
34255
34909
|
resetAnsweredValues(priorGraph, priorAnsweredIds);
|
|
34256
34910
|
materializedById.set(nextInstanceRoot.id, nextInstanceRoot);
|
|
34257
34911
|
const nextExpanded = expandStoredInstance({
|
|
@@ -34295,10 +34949,15 @@ function resolveVariantInstanceGraphForDocument(args) {
|
|
|
34295
34949
|
`ToVariant failed to resolve instance root '${args.nextInstanceRoot.id}'.`
|
|
34296
34950
|
);
|
|
34297
34951
|
}
|
|
34952
|
+
const virtualValueIds = /* @__PURE__ */ new Set();
|
|
34953
|
+
for (const location of nextGraph.locationsById.values()) {
|
|
34954
|
+
if (location.materializedRow === null) virtualValueIds.add(location.id);
|
|
34955
|
+
}
|
|
34298
34956
|
return {
|
|
34299
34957
|
root,
|
|
34300
34958
|
rows: [...nextGraph.rowsById.values()],
|
|
34301
|
-
clearedValueIds: [...clearedValueIds]
|
|
34959
|
+
clearedValueIds: [...clearedValueIds],
|
|
34960
|
+
virtualValueIds: [...virtualValueIds]
|
|
34302
34961
|
};
|
|
34303
34962
|
}
|
|
34304
34963
|
function variantSwapDeclaredMember(document2, rootValueId) {
|
|
@@ -34685,6 +35344,7 @@ function initializerEvaluatorLookups(document2, readTracking) {
|
|
|
34685
35344
|
return resolved;
|
|
34686
35345
|
},
|
|
34687
35346
|
virtualInstanceRowsForValue: (receiverValueId) => databaseVM.virtualInstanceRowsForValue(receiverValueId),
|
|
35347
|
+
virtualInstanceRootIdForValue: (valueId) => databaseVM.virtualInstanceRootIdForValue(valueId),
|
|
34688
35348
|
...databaseVM.worldGridQueryIndex === void 0 ? {} : { worldGridQueryIndex: () => databaseVM.worldGridQueryIndex() },
|
|
34689
35349
|
rowForValueReference: (value) => databaseVM.rowForValueReference?.(value) ?? null,
|
|
34690
35350
|
resolveVariantInstanceGraph: (args) => {
|
|
@@ -34740,6 +35400,9 @@ function initializerEvaluatorLookups(document2, readTracking) {
|
|
|
34740
35400
|
valueById: (id) => indexedLookups.valueById(id) ?? headlessVirtualResolver.valueById(id),
|
|
34741
35401
|
rowForValueReference: (value) => indexedLookups.rowForValueReference?.(value) ?? headlessVirtualResolver.rowForValueReference(value),
|
|
34742
35402
|
virtualInstanceRowsForValue: (receiverValueId) => headlessVirtualResolver.virtualInstanceRowsForValue(receiverValueId),
|
|
35403
|
+
virtualInstanceRootIdForValue: (valueId) => owningInstanceRootId(
|
|
35404
|
+
headlessVirtualResolver.virtualInstanceGraphForValue(valueId)
|
|
35405
|
+
),
|
|
34743
35406
|
recordVirtualInstanceReads: (reads, read) => headlessVirtualResolver.recordReads(reads, read),
|
|
34744
35407
|
// Headless hosts still evaluate `ToVariant` during
|
|
34745
35408
|
// stored-construction replay — production's variant-constructed
|
|
@@ -34862,6 +35525,7 @@ function evaluateMemberInitializer(args) {
|
|
|
34862
35525
|
);
|
|
34863
35526
|
const compiled = compileMemberInitializer(args, databaseVM);
|
|
34864
35527
|
const ctx = {
|
|
35528
|
+
...args.sessionValues === void 0 ? {} : { __runtimeSessionValues: args.sessionValues },
|
|
34865
35529
|
debugSink: args.document.debugSink,
|
|
34866
35530
|
beforeValueAllocation: args.document.beforeValueAllocation,
|
|
34867
35531
|
listenerDefaultCapture: args.document.listenerDefaultCapture,
|
|
@@ -34932,10 +35596,13 @@ function evaluateMemberInitializer(args) {
|
|
|
34932
35596
|
args.argumentValues ?? [],
|
|
34933
35597
|
{
|
|
34934
35598
|
exportInitializerValues: true,
|
|
34935
|
-
|
|
34936
|
-
|
|
34937
|
-
|
|
34938
|
-
|
|
35599
|
+
// Seeded rows already hold their placement.
|
|
35600
|
+
...args.sessionValues === void 0 ? {
|
|
35601
|
+
initializerResult: {
|
|
35602
|
+
member: args.member,
|
|
35603
|
+
genericEnv: args.genericEnv
|
|
35604
|
+
}
|
|
35605
|
+
} : {}
|
|
34939
35606
|
}
|
|
34940
35607
|
);
|
|
34941
35608
|
} catch (error) {
|
|
@@ -34958,9 +35625,12 @@ function evaluateMemberInitializer(args) {
|
|
|
34958
35625
|
);
|
|
34959
35626
|
}
|
|
34960
35627
|
const rootRow = initializerRootRow(result.value, created);
|
|
35628
|
+
const pinnedSchemaKeysByValueId = /* @__PURE__ */ new Map();
|
|
34961
35629
|
for (const row of created) {
|
|
34962
35630
|
if (row === rootRow) continue;
|
|
34963
35631
|
args.createdValues.push(row);
|
|
35632
|
+
const keys = typeof row.value === "object" && row.value !== null ? ctx.__constructedFieldSchemaKeysByValue?.get(row.value) : void 0;
|
|
35633
|
+
if (keys !== void 0) pinnedSchemaKeysByValueId.set(row.id, keys);
|
|
34964
35634
|
}
|
|
34965
35635
|
if (rootRow === null) return { value: result.value, classId: null };
|
|
34966
35636
|
const constructorArgs = (typeof result.value === "object" && result.value !== null ? ctx.__constructedArgumentsByValue?.get(result.value) : void 0) ?? // An implicit `new()` records its empty args on the row rather than in
|
|
@@ -34968,17 +35638,13 @@ function evaluateMemberInitializer(args) {
|
|
|
34968
35638
|
// origin or the recipe reads as an unrecorded overload.
|
|
34969
35639
|
rootRow.constructorArgs ?? void 0;
|
|
34970
35640
|
const pinnedRootSchemaKeys = typeof result.value === "object" && result.value !== null ? ctx.__constructedFieldSchemaKeysByValue?.get(result.value) : void 0;
|
|
34971
|
-
const provenance = pickInstanceProvenance({
|
|
34972
|
-
constructorArgs,
|
|
34973
|
-
instanceConstructorId: rootRow.instanceConstructorId,
|
|
34974
|
-
instanceVariantId: rootRow.instanceVariantId,
|
|
34975
|
-
instanceVariantRowValueId: rootRow.instanceVariantRowValueId
|
|
34976
|
-
});
|
|
35641
|
+
const provenance = pickInstanceProvenance({ ...rootRow, constructorArgs });
|
|
34977
35642
|
return {
|
|
34978
35643
|
value: result.value,
|
|
34979
35644
|
classId: rootRow.classId ?? null,
|
|
34980
35645
|
...rootRow.genericBindings === void 0 ? {} : { genericBindings: { ...rootRow.genericBindings } },
|
|
34981
35646
|
...pinnedRootSchemaKeys === void 0 ? {} : { pinnedRootSchemaKeys },
|
|
35647
|
+
...pinnedSchemaKeysByValueId.size === 0 ? {} : { pinnedSchemaKeysByValueId },
|
|
34982
35648
|
provisionalRootId: rootRow.id,
|
|
34983
35649
|
...provenance,
|
|
34984
35650
|
...provenance.constructorArgs === void 0 ? {} : {
|
|
@@ -35052,6 +35718,7 @@ function headlessVirtualInstanceLookups(document2, options = {}) {
|
|
|
35052
35718
|
valueById: (id) => indexed.valueById(id) ?? virtual.valueById(id),
|
|
35053
35719
|
rowForValueReference: (value) => indexed.rowForValueReference(value) ?? virtual.rowForValueReference(value),
|
|
35054
35720
|
virtualInstanceRowsForValue: (receiverValueId) => virtual.virtualInstanceRowsForValue(receiverValueId),
|
|
35721
|
+
virtualInstanceRootIdForValue: (valueId) => owningInstanceRootId(virtual.virtualInstanceGraphForValue(valueId)),
|
|
35055
35722
|
// Stored-construction replay evaluates `ToVariant`, and production's
|
|
35056
35723
|
// variant-constructed placements collapse through exactly this path.
|
|
35057
35724
|
resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument2({
|
|
@@ -41296,7 +41963,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
41296
41963
|
};
|
|
41297
41964
|
}
|
|
41298
41965
|
resolveDictionaryKey(expectedKey, keyAst, scope, pos, requireNonOptional, dictionaryLiteral = false) {
|
|
41299
|
-
const key = this.resolveExpression(keyAst, scope);
|
|
41966
|
+
const key = this.resolveExpression(keyAst, scope, expectedKey);
|
|
41300
41967
|
if (requireNonOptional && isNullable(key.type)) {
|
|
41301
41968
|
throw new CompileError(
|
|
41302
41969
|
`Dictionary keys must be non-optional; got ${this.describe(key.type)}`,
|
|
@@ -58796,7 +59463,7 @@ var INITIALIZER_KEY_PLACEHOLDER = new RegExp(
|
|
|
58796
59463
|
|
|
58797
59464
|
// ../packages/manifest/schema-contract/registry.mjs
|
|
58798
59465
|
var PROJECT_SCHEMA_CONTRACT = Object.freeze({
|
|
58799
|
-
cliVersion: "0.81.
|
|
59466
|
+
cliVersion: "0.81.1",
|
|
58800
59467
|
projectFileUploadBatchSize: 32,
|
|
58801
59468
|
documentRecords: {
|
|
58802
59469
|
member: {
|