@elaraai/east 0.0.1-beta.25 → 0.0.1-beta.26
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/src/ast_to_ir.js +1 -1
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +22 -0
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +35 -0
- package/dist/src/compile.js.map +1 -1
- package/dist/src/expr/array.d.ts +8 -0
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +11 -0
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/blob.d.ts +8 -0
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +11 -0
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +46 -0
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +124 -1
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/boolean.d.ts +8 -0
- package/dist/src/expr/boolean.d.ts.map +1 -1
- package/dist/src/expr/boolean.js +11 -0
- package/dist/src/expr/boolean.js.map +1 -1
- package/dist/src/expr/datetime.d.ts +28 -0
- package/dist/src/expr/datetime.d.ts.map +1 -1
- package/dist/src/expr/datetime.js +31 -0
- package/dist/src/expr/datetime.js.map +1 -1
- package/dist/src/expr/dict.d.ts +8 -0
- package/dist/src/expr/dict.d.ts.map +1 -1
- package/dist/src/expr/dict.js +11 -0
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/float.d.ts +46 -0
- package/dist/src/expr/float.d.ts.map +1 -1
- package/dist/src/expr/float.js +52 -0
- package/dist/src/expr/float.js.map +1 -1
- package/dist/src/expr/index.d.ts +91 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +97 -2
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/integer.d.ts +73 -0
- package/dist/src/expr/integer.d.ts.map +1 -1
- package/dist/src/expr/integer.js +52 -0
- package/dist/src/expr/integer.js.map +1 -1
- package/dist/src/expr/set.d.ts +8 -0
- package/dist/src/expr/set.d.ts.map +1 -1
- package/dist/src/expr/set.js +11 -0
- package/dist/src/expr/set.js.map +1 -1
- package/dist/src/expr/string.d.ts +28 -0
- package/dist/src/expr/string.d.ts.map +1 -1
- package/dist/src/expr/string.js +31 -0
- package/dist/src/expr/string.js.map +1 -1
- package/dist/src/expr/variant.d.ts +8 -0
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +11 -0
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/fuzz.d.ts +36 -2
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +344 -77
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +5 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +6 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/patch/apply.d.ts +15 -0
- package/dist/src/patch/apply.d.ts.map +1 -0
- package/dist/src/patch/apply.js +380 -0
- package/dist/src/patch/apply.js.map +1 -0
- package/dist/src/patch/compose.d.ts +15 -0
- package/dist/src/patch/compose.d.ts.map +1 -0
- package/dist/src/patch/compose.js +480 -0
- package/dist/src/patch/compose.js.map +1 -0
- package/dist/src/patch/diff.d.ts +15 -0
- package/dist/src/patch/diff.d.ts.map +1 -0
- package/dist/src/patch/diff.js +328 -0
- package/dist/src/patch/diff.js.map +1 -0
- package/dist/src/patch/fuzz.d.ts +73 -0
- package/dist/src/patch/fuzz.d.ts.map +1 -0
- package/dist/src/patch/fuzz.js +159 -0
- package/dist/src/patch/fuzz.js.map +1 -0
- package/dist/src/patch/index.d.ts +18 -0
- package/dist/src/patch/index.d.ts.map +1 -0
- package/dist/src/patch/index.js +20 -0
- package/dist/src/patch/index.js.map +1 -0
- package/dist/src/patch/invert.d.ts +15 -0
- package/dist/src/patch/invert.d.ts.map +1 -0
- package/dist/src/patch/invert.js +302 -0
- package/dist/src/patch/invert.js.map +1 -0
- package/dist/src/patch/type_of_patch.d.ts +17 -0
- package/dist/src/patch/type_of_patch.d.ts.map +1 -0
- package/dist/src/patch/type_of_patch.js +143 -0
- package/dist/src/patch/type_of_patch.js.map +1 -0
- package/dist/src/patch/types.d.ts +166 -0
- package/dist/src/patch/types.d.ts.map +1 -0
- package/dist/src/patch/types.js +69 -0
- package/dist/src/patch/types.js.map +1 -0
- package/package.json +1 -2
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* composeFor - Combine two sequential patches.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { toEastTypeValue } from "../type_of_type.js";
|
|
11
|
+
import { isVariant, variant } from "../containers/variant.js";
|
|
12
|
+
import { equalFor, compareFor } from "../comparison.js";
|
|
13
|
+
import { printFor } from "../serialization/east.js";
|
|
14
|
+
import { SortedMap } from "../containers/sortedmap.js";
|
|
15
|
+
import { ConflictError } from "./types.js";
|
|
16
|
+
import { applyFor } from "./apply.js";
|
|
17
|
+
import { invertFor } from "./invert.js";
|
|
18
|
+
export function composeFor(type, ctx = { compose: [], apply: [], invert: [], types: [], equal: [], print: [] }) {
|
|
19
|
+
// Convert to EastTypeValue and use a properly typed variable
|
|
20
|
+
const t = isVariant(type) ? type : toEastTypeValue(type);
|
|
21
|
+
if (t.type === "Never") {
|
|
22
|
+
return (_first, _second) => {
|
|
23
|
+
throw new Error("Cannot compose patches for type Never");
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else if (t.type === "Null" ||
|
|
27
|
+
t.type === "Boolean" ||
|
|
28
|
+
t.type === "Integer" ||
|
|
29
|
+
t.type === "Float" ||
|
|
30
|
+
t.type === "String" ||
|
|
31
|
+
t.type === "DateTime" ||
|
|
32
|
+
t.type === "Blob") {
|
|
33
|
+
return (first, second) => {
|
|
34
|
+
if (first.type === "unchanged") {
|
|
35
|
+
return second;
|
|
36
|
+
}
|
|
37
|
+
else if (second.type === "unchanged") {
|
|
38
|
+
return first;
|
|
39
|
+
}
|
|
40
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
41
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new Error("Invalid patch composition for primitive");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else if (t.type === "Array") {
|
|
49
|
+
let applyRet;
|
|
50
|
+
let invertRet;
|
|
51
|
+
const composeRet = (first, second) => {
|
|
52
|
+
if (first.type === "unchanged") {
|
|
53
|
+
return second;
|
|
54
|
+
}
|
|
55
|
+
else if (second.type === "unchanged") {
|
|
56
|
+
return first;
|
|
57
|
+
}
|
|
58
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
59
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
60
|
+
}
|
|
61
|
+
else if (first.type === "replace" && second.type === "patch") {
|
|
62
|
+
const afterSecond = applyRet(first.value.after, second);
|
|
63
|
+
return variant("replace", { before: first.value.before, after: afterSecond });
|
|
64
|
+
}
|
|
65
|
+
else if (first.type === "patch" && second.type === "replace") {
|
|
66
|
+
const invertedFirst = invertRet(first);
|
|
67
|
+
const originalBefore = applyRet(second.value.before, invertedFirst);
|
|
68
|
+
return variant("replace", { before: originalBefore, after: second.value.after });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// patch + patch: concatenate operations
|
|
72
|
+
const p1Ops = first.value;
|
|
73
|
+
const p2Ops = second.value;
|
|
74
|
+
const result = [...p1Ops, ...p2Ops];
|
|
75
|
+
if (result.length === 0) {
|
|
76
|
+
return variant("unchanged", null);
|
|
77
|
+
}
|
|
78
|
+
return variant("patch", result);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const arrayEqual = equalFor(t, ctx.equal);
|
|
82
|
+
const arrayPrint = printFor(t, ctx.print);
|
|
83
|
+
// Push compose context first
|
|
84
|
+
ctx.compose.push(composeRet);
|
|
85
|
+
ctx.types.push(t);
|
|
86
|
+
ctx.equal.push(arrayEqual);
|
|
87
|
+
ctx.print.push(arrayPrint);
|
|
88
|
+
// Build apply/invert handlers using applyFor/invertFor
|
|
89
|
+
applyRet = applyFor(t, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
90
|
+
invertRet = invertFor(t, { invert: ctx.invert, types: ctx.types, equal: ctx.equal });
|
|
91
|
+
// Push them so .Recursive lookups work during element compose recursion
|
|
92
|
+
ctx.apply.push(applyRet);
|
|
93
|
+
ctx.invert.push(invertRet);
|
|
94
|
+
// Recurse into element type for compose
|
|
95
|
+
composeFor(t.value, ctx);
|
|
96
|
+
ctx.compose.pop();
|
|
97
|
+
ctx.apply.pop();
|
|
98
|
+
ctx.invert.pop();
|
|
99
|
+
ctx.types.pop();
|
|
100
|
+
ctx.equal.pop();
|
|
101
|
+
ctx.print.pop();
|
|
102
|
+
return composeRet;
|
|
103
|
+
}
|
|
104
|
+
else if (t.type === "Set") {
|
|
105
|
+
const keyPrint = printFor(t.value);
|
|
106
|
+
const keyCompare = compareFor(t.value);
|
|
107
|
+
// Pass full context so recursive type references can be resolved
|
|
108
|
+
const apply = applyFor(t, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
109
|
+
const invert = invertFor(t, { invert: ctx.invert, types: ctx.types, equal: ctx.equal });
|
|
110
|
+
return (first, second) => {
|
|
111
|
+
if (first.type === "unchanged") {
|
|
112
|
+
return second;
|
|
113
|
+
}
|
|
114
|
+
else if (second.type === "unchanged") {
|
|
115
|
+
return first;
|
|
116
|
+
}
|
|
117
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
118
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
119
|
+
}
|
|
120
|
+
else if (first.type === "patch" && second.type === "patch") {
|
|
121
|
+
const result = new SortedMap(undefined, keyCompare);
|
|
122
|
+
for (const [key, op] of first.value) {
|
|
123
|
+
result.set(key, op);
|
|
124
|
+
}
|
|
125
|
+
for (const [key, op] of second.value) {
|
|
126
|
+
if (result.has(key)) {
|
|
127
|
+
const firstOp = result.get(key);
|
|
128
|
+
if (firstOp.type === "insert" && op.type === "delete") {
|
|
129
|
+
result.delete(key);
|
|
130
|
+
}
|
|
131
|
+
else if (firstOp.type === "delete" && op.type === "insert") {
|
|
132
|
+
result.delete(key);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw new ConflictError(`Cannot compose patches - conflicting operations on key ${keyPrint(key)}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
result.set(key, op);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (result.size === 0) {
|
|
143
|
+
return variant("unchanged", null);
|
|
144
|
+
}
|
|
145
|
+
return variant("patch", result);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
if (first.type === "replace") {
|
|
149
|
+
const afterSecond = apply(first.value.after, second);
|
|
150
|
+
return variant("replace", { before: first.value.before, after: afterSecond });
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Compute original before by inverting first and applying to second.before
|
|
154
|
+
const invertedFirst = invert(first);
|
|
155
|
+
const originalBefore = apply(second.value.before, invertedFirst);
|
|
156
|
+
return variant("replace", { before: originalBefore, after: second.value.after });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
else if (t.type === "Dict") {
|
|
162
|
+
let valueCompose;
|
|
163
|
+
let valueApply;
|
|
164
|
+
let applyRet;
|
|
165
|
+
let invertRet;
|
|
166
|
+
const keyPrint = printFor(t.value.key);
|
|
167
|
+
const keyCompare = compareFor(t.value.key);
|
|
168
|
+
const composeRet = (first, second) => {
|
|
169
|
+
if (first.type === "unchanged") {
|
|
170
|
+
return second;
|
|
171
|
+
}
|
|
172
|
+
else if (second.type === "unchanged") {
|
|
173
|
+
return first;
|
|
174
|
+
}
|
|
175
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
176
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
177
|
+
}
|
|
178
|
+
else if (first.type === "patch" && second.type === "patch") {
|
|
179
|
+
const result = new SortedMap(undefined, keyCompare);
|
|
180
|
+
for (const [key, op] of first.value) {
|
|
181
|
+
result.set(key, op);
|
|
182
|
+
}
|
|
183
|
+
for (const [key, op] of second.value) {
|
|
184
|
+
if (result.has(key)) {
|
|
185
|
+
const firstOp = result.get(key);
|
|
186
|
+
if (firstOp.type === "insert" && op.type === "delete") {
|
|
187
|
+
result.delete(key);
|
|
188
|
+
}
|
|
189
|
+
else if (firstOp.type === "insert" && op.type === "update") {
|
|
190
|
+
const newValue = valueApply(firstOp.value, op.value);
|
|
191
|
+
result.set(key, variant("insert", newValue));
|
|
192
|
+
}
|
|
193
|
+
else if (firstOp.type === "delete" && op.type === "insert") {
|
|
194
|
+
result.set(key, variant("update", variant("replace", { before: firstOp.value, after: op.value })));
|
|
195
|
+
}
|
|
196
|
+
else if (firstOp.type === "update" && op.type === "delete") {
|
|
197
|
+
throw new ConflictError(`Cannot compose patches - update then delete on key ${keyPrint(key)}`);
|
|
198
|
+
}
|
|
199
|
+
else if (firstOp.type === "update" && op.type === "update") {
|
|
200
|
+
const composed = valueCompose(firstOp.value, op.value);
|
|
201
|
+
result.set(key, variant("update", composed));
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw new ConflictError(`Cannot compose patches - conflicting operations on key ${keyPrint(key)}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
result.set(key, op);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (result.size === 0) {
|
|
212
|
+
return variant("unchanged", null);
|
|
213
|
+
}
|
|
214
|
+
return variant("patch", result);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
if (first.type === "replace") {
|
|
218
|
+
const afterSecond = applyRet(first.value.after, second);
|
|
219
|
+
return variant("replace", { before: first.value.before, after: afterSecond });
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
// Compute original before by inverting first and applying to second.before
|
|
223
|
+
const invertedFirst = invertRet(first);
|
|
224
|
+
const originalBefore = applyRet(second.value.before, invertedFirst);
|
|
225
|
+
return variant("replace", { before: originalBefore, after: second.value.after });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
// Build print handler for this dict type
|
|
230
|
+
const dictPrint = printFor(t, ctx.print);
|
|
231
|
+
// Build dict equality using equalFor with current context
|
|
232
|
+
const dictEqual = equalFor(t, ctx.equal);
|
|
233
|
+
// Push compose context first
|
|
234
|
+
ctx.compose.push(composeRet);
|
|
235
|
+
ctx.types.push(t);
|
|
236
|
+
ctx.equal.push(dictEqual);
|
|
237
|
+
ctx.print.push(dictPrint);
|
|
238
|
+
// Build Dict apply/invert handlers (these recurse internally with their own push/pop)
|
|
239
|
+
applyRet = applyFor(t, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
240
|
+
invertRet = invertFor(t, { invert: ctx.invert, types: ctx.types, equal: ctx.equal });
|
|
241
|
+
// Push them so .Recursive lookups work during value compose recursion
|
|
242
|
+
ctx.apply.push(applyRet);
|
|
243
|
+
ctx.invert.push(invertRet);
|
|
244
|
+
// Recurse into value type for compose
|
|
245
|
+
valueCompose = composeFor(t.value.value, ctx);
|
|
246
|
+
// Build value apply with proper context (Dict handler is now in ctx.apply)
|
|
247
|
+
valueApply = applyFor(t.value.value, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
248
|
+
ctx.compose.pop();
|
|
249
|
+
ctx.apply.pop();
|
|
250
|
+
ctx.invert.pop();
|
|
251
|
+
ctx.types.pop();
|
|
252
|
+
ctx.equal.pop();
|
|
253
|
+
ctx.print.pop();
|
|
254
|
+
return composeRet;
|
|
255
|
+
}
|
|
256
|
+
else if (t.type === "Struct") {
|
|
257
|
+
const fieldComposes = {};
|
|
258
|
+
let applyRet;
|
|
259
|
+
let invertRet;
|
|
260
|
+
const composeRet = (first, second) => {
|
|
261
|
+
if (first.type === "unchanged") {
|
|
262
|
+
return second;
|
|
263
|
+
}
|
|
264
|
+
else if (second.type === "unchanged") {
|
|
265
|
+
return first;
|
|
266
|
+
}
|
|
267
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
268
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
269
|
+
}
|
|
270
|
+
else if (first.type === "patch" && second.type === "patch") {
|
|
271
|
+
const result = {};
|
|
272
|
+
let allUnchanged = true;
|
|
273
|
+
for (const { name } of t.value) {
|
|
274
|
+
const composed = fieldComposes[name](first.value[name], second.value[name]);
|
|
275
|
+
result[name] = composed;
|
|
276
|
+
if (composed.type !== "unchanged") {
|
|
277
|
+
allUnchanged = false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (allUnchanged) {
|
|
281
|
+
return variant("unchanged", null);
|
|
282
|
+
}
|
|
283
|
+
return variant("patch", result);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
if (first.type === "replace") {
|
|
287
|
+
const afterSecond = applyRet(first.value.after, second);
|
|
288
|
+
return variant("replace", { before: first.value.before, after: afterSecond });
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
// Compute original before by inverting first and applying to second.before
|
|
292
|
+
const invertedFirst = invertRet(first);
|
|
293
|
+
const originalBefore = applyRet(second.value.before, invertedFirst);
|
|
294
|
+
return variant("replace", { before: originalBefore, after: second.value.after });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const structEqual = equalFor(t, ctx.equal);
|
|
299
|
+
const structPrint = printFor(t, ctx.print);
|
|
300
|
+
// Push compose context first
|
|
301
|
+
ctx.compose.push(composeRet);
|
|
302
|
+
ctx.types.push(t);
|
|
303
|
+
ctx.equal.push(structEqual);
|
|
304
|
+
ctx.print.push(structPrint);
|
|
305
|
+
// Build apply/invert handlers using applyFor/invertFor
|
|
306
|
+
applyRet = applyFor(t, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
307
|
+
invertRet = invertFor(t, { invert: ctx.invert, types: ctx.types, equal: ctx.equal });
|
|
308
|
+
// Push them so .Recursive lookups work during field compose recursion
|
|
309
|
+
ctx.apply.push(applyRet);
|
|
310
|
+
ctx.invert.push(invertRet);
|
|
311
|
+
// Recurse into field types for compose
|
|
312
|
+
for (const { name, type: fieldType } of t.value) {
|
|
313
|
+
fieldComposes[name] = composeFor(fieldType, ctx);
|
|
314
|
+
}
|
|
315
|
+
ctx.compose.pop();
|
|
316
|
+
ctx.apply.pop();
|
|
317
|
+
ctx.invert.pop();
|
|
318
|
+
ctx.types.pop();
|
|
319
|
+
ctx.equal.pop();
|
|
320
|
+
ctx.print.pop();
|
|
321
|
+
return composeRet;
|
|
322
|
+
}
|
|
323
|
+
else if (t.type === "Variant") {
|
|
324
|
+
const caseComposes = {};
|
|
325
|
+
let applyRet;
|
|
326
|
+
let invertRet;
|
|
327
|
+
const composeRet = (first, second) => {
|
|
328
|
+
if (first.type === "unchanged") {
|
|
329
|
+
return second;
|
|
330
|
+
}
|
|
331
|
+
else if (second.type === "unchanged") {
|
|
332
|
+
return first;
|
|
333
|
+
}
|
|
334
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
335
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
336
|
+
}
|
|
337
|
+
else if (first.type === "patch" && second.type === "patch") {
|
|
338
|
+
if (first.value.type !== second.value.type) {
|
|
339
|
+
throw new ConflictError(`Cannot compose variant patches for different cases: ${first.value.type} and ${second.value.type}`);
|
|
340
|
+
}
|
|
341
|
+
const caseName = first.value.type;
|
|
342
|
+
const composed = caseComposes[caseName](first.value.value, second.value.value);
|
|
343
|
+
if (composed.type === "unchanged") {
|
|
344
|
+
return variant("unchanged", null);
|
|
345
|
+
}
|
|
346
|
+
return variant("patch", variant(caseName, composed));
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
if (first.type === "replace") {
|
|
350
|
+
const afterSecond = applyRet(first.value.after, second);
|
|
351
|
+
return variant("replace", { before: first.value.before, after: afterSecond });
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// first is "patch", second is "replace"
|
|
355
|
+
// Compute original before by inverting first and applying to second.before
|
|
356
|
+
const invertedFirst = invertRet(first);
|
|
357
|
+
const originalBefore = applyRet(second.value.before, invertedFirst);
|
|
358
|
+
return variant("replace", { before: originalBefore, after: second.value.after });
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
const variantEqual = equalFor(t, ctx.equal);
|
|
363
|
+
const variantPrint = printFor(t, ctx.print);
|
|
364
|
+
// Push compose context first
|
|
365
|
+
ctx.compose.push(composeRet);
|
|
366
|
+
ctx.types.push(t);
|
|
367
|
+
ctx.equal.push(variantEqual);
|
|
368
|
+
ctx.print.push(variantPrint);
|
|
369
|
+
// Build apply/invert handlers using applyFor/invertFor
|
|
370
|
+
applyRet = applyFor(t, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
371
|
+
invertRet = invertFor(t, { invert: ctx.invert, types: ctx.types, equal: ctx.equal });
|
|
372
|
+
// Push them so .Recursive lookups work during case compose recursion
|
|
373
|
+
ctx.apply.push(applyRet);
|
|
374
|
+
ctx.invert.push(invertRet);
|
|
375
|
+
// Recurse into case types for compose
|
|
376
|
+
for (const { name, type: caseType } of t.value) {
|
|
377
|
+
caseComposes[name] = composeFor(caseType, ctx);
|
|
378
|
+
}
|
|
379
|
+
ctx.compose.pop();
|
|
380
|
+
ctx.apply.pop();
|
|
381
|
+
ctx.invert.pop();
|
|
382
|
+
ctx.types.pop();
|
|
383
|
+
ctx.equal.pop();
|
|
384
|
+
ctx.print.pop();
|
|
385
|
+
return composeRet;
|
|
386
|
+
}
|
|
387
|
+
else if (t.type === "Ref") {
|
|
388
|
+
let innerCompose;
|
|
389
|
+
let applyRet;
|
|
390
|
+
let invertRet;
|
|
391
|
+
const composeRet = (first, second) => {
|
|
392
|
+
if (first.type === "unchanged") {
|
|
393
|
+
return second;
|
|
394
|
+
}
|
|
395
|
+
else if (second.type === "unchanged") {
|
|
396
|
+
return first;
|
|
397
|
+
}
|
|
398
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
399
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
400
|
+
}
|
|
401
|
+
else if (first.type === "patch" && second.type === "patch") {
|
|
402
|
+
const composed = innerCompose(first.value, second.value);
|
|
403
|
+
if (composed.type === "unchanged") {
|
|
404
|
+
return variant("unchanged", null);
|
|
405
|
+
}
|
|
406
|
+
return variant("patch", composed);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
if (first.type === "replace") {
|
|
410
|
+
const afterSecond = applyRet(first.value.after, second);
|
|
411
|
+
return variant("replace", { before: first.value.before, after: afterSecond });
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
// Compute original before by inverting first and applying to second.before
|
|
415
|
+
const invertedFirst = invertRet(first);
|
|
416
|
+
const originalBefore = applyRet(second.value.before, invertedFirst);
|
|
417
|
+
return variant("replace", { before: originalBefore, after: second.value.after });
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
// Build print handler for this ref type
|
|
422
|
+
const refPrint = printFor(t, ctx.print);
|
|
423
|
+
// Build ref equality using equalFor with current context
|
|
424
|
+
const refEqual = equalFor(t, ctx.equal);
|
|
425
|
+
// Push compose context first
|
|
426
|
+
ctx.compose.push(composeRet);
|
|
427
|
+
ctx.types.push(t);
|
|
428
|
+
ctx.equal.push(refEqual);
|
|
429
|
+
ctx.print.push(refPrint);
|
|
430
|
+
// Build Ref apply/invert handlers (these recurse internally with their own push/pop)
|
|
431
|
+
applyRet = applyFor(t, { apply: ctx.apply, types: ctx.types, equal: ctx.equal, print: ctx.print });
|
|
432
|
+
invertRet = invertFor(t, { invert: ctx.invert, types: ctx.types, equal: ctx.equal });
|
|
433
|
+
// Push them so .Recursive lookups work during inner compose recursion
|
|
434
|
+
ctx.apply.push(applyRet);
|
|
435
|
+
ctx.invert.push(invertRet);
|
|
436
|
+
// Recurse into inner type for compose
|
|
437
|
+
innerCompose = composeFor(t.value, ctx);
|
|
438
|
+
ctx.compose.pop();
|
|
439
|
+
ctx.apply.pop();
|
|
440
|
+
ctx.invert.pop();
|
|
441
|
+
ctx.types.pop();
|
|
442
|
+
ctx.equal.pop();
|
|
443
|
+
ctx.print.pop();
|
|
444
|
+
return composeRet;
|
|
445
|
+
}
|
|
446
|
+
else if (t.type === "Recursive") {
|
|
447
|
+
// Recursive types use replace-only semantics - only unchanged and replace patches
|
|
448
|
+
return (first, second) => {
|
|
449
|
+
if (first.type === "unchanged") {
|
|
450
|
+
return second;
|
|
451
|
+
}
|
|
452
|
+
else if (second.type === "unchanged") {
|
|
453
|
+
return first;
|
|
454
|
+
}
|
|
455
|
+
else if (first.type === "replace" && second.type === "replace") {
|
|
456
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
throw new Error(`Invalid patch types for recursive type composition: ${first.type}, ${second.type}`);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
else if (t.type === "Function" || t.type === "AsyncFunction") {
|
|
464
|
+
return (first, second) => {
|
|
465
|
+
if (first.type === "unchanged") {
|
|
466
|
+
return second;
|
|
467
|
+
}
|
|
468
|
+
else if (second.type === "unchanged") {
|
|
469
|
+
return first;
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
return variant("replace", { before: first.value.before, after: second.value.after });
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
throw new Error(`Unhandled type in composeFor: ${t.type}`);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/patch/compose.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAsB,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAgC,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAuB,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,UAAU,UAAU,CAAC,IAA8B,EAAE,MAAsB,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IACtJ,6DAA6D;IAC7D,MAAM,CAAC,GAAkB,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,IAAgB,CAAC,CAAC;IAEpF,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAA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AChB,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACvC,OAAO,KAAK,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,OAAO,OAAO,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,iCAAkC,CAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* diffFor - Compute difference between two East values.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type EastTypeValue } from "../type_of_type.js";
|
|
11
|
+
import type { EastType, ValueTypeOf } from "../types.js";
|
|
12
|
+
import { type DiffContext } from "./types.js";
|
|
13
|
+
export declare function diffFor(type: EastTypeValue, ctx?: DiffContext): (before: any, after: any) => any;
|
|
14
|
+
export declare function diffFor<T extends EastType>(type: T): (before: ValueTypeOf<T>, after: ValueTypeOf<T>) => any;
|
|
15
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/patch/diff.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMzD,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,YAAY,CAAC;AAE1D,wBAAgB,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAClG,wBAAgB,OAAO,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC"}
|