@shapeshift-labs/frontier-lang-compiler 0.2.81 → 0.2.83
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.
|
@@ -120,6 +120,30 @@ export interface SemanticEditScript {
|
|
|
120
120
|
readonly metadata?: Record<string, unknown>;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
export interface SemanticEditProjectionEdit {
|
|
124
|
+
readonly operationId?: string;
|
|
125
|
+
readonly status: 'applied' | 'already-applied';
|
|
126
|
+
readonly kind?: string;
|
|
127
|
+
readonly changeKind?: string;
|
|
128
|
+
readonly anchorKey?: string;
|
|
129
|
+
readonly conflictKey?: string;
|
|
130
|
+
readonly regionId?: string;
|
|
131
|
+
readonly regionKind?: string;
|
|
132
|
+
readonly sourcePath?: string;
|
|
133
|
+
readonly symbolId?: string;
|
|
134
|
+
readonly symbolName?: string;
|
|
135
|
+
readonly symbolKind?: string;
|
|
136
|
+
readonly headStart: number;
|
|
137
|
+
readonly headEnd: number;
|
|
138
|
+
readonly workerStart?: number;
|
|
139
|
+
readonly workerEnd?: number;
|
|
140
|
+
readonly deletedBytes: number;
|
|
141
|
+
readonly replacementBytes: number;
|
|
142
|
+
readonly deletedTextHash?: string;
|
|
143
|
+
readonly replacementTextHash?: string;
|
|
144
|
+
readonly replacementText?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
123
147
|
export interface SemanticEditProjection {
|
|
124
148
|
readonly kind: 'frontier.lang.semanticEditProjection';
|
|
125
149
|
readonly version: 1;
|
|
@@ -135,6 +159,7 @@ export interface SemanticEditProjection {
|
|
|
135
159
|
readonly projectedHash?: string;
|
|
136
160
|
readonly appliedOperations: readonly string[];
|
|
137
161
|
readonly skippedOperations: readonly string[];
|
|
162
|
+
readonly edits: readonly SemanticEditProjectionEdit[];
|
|
138
163
|
readonly sourceText?: string;
|
|
139
164
|
readonly admission: {
|
|
140
165
|
readonly status: 'auto-merge-candidate' | 'blocked';
|
|
@@ -32,6 +32,7 @@ export function projectSemanticEditScriptToSource(input = {}) {
|
|
|
32
32
|
projectedHash: sourceText === undefined ? undefined : hashSemanticValue(sourceText),
|
|
33
33
|
appliedOperations: blocked ? [] : edits.map((edit) => edit.operationId),
|
|
34
34
|
skippedOperations: blocked ? (script.operations ?? []).map((operation) => operation.id) : [],
|
|
35
|
+
edits: blocked ? [] : edits.map(projectionEditRecord),
|
|
35
36
|
sourceText,
|
|
36
37
|
admission: {
|
|
37
38
|
status: blocked ? 'blocked' : 'auto-merge-candidate',
|
|
@@ -43,6 +44,8 @@ export function projectSemanticEditScriptToSource(input = {}) {
|
|
|
43
44
|
autoMergeClaim: false,
|
|
44
45
|
semanticEquivalenceClaim: false,
|
|
45
46
|
editCount: edits.length,
|
|
47
|
+
appliedEditCount: edits.filter((edit) => !edit.alreadyApplied).length,
|
|
48
|
+
alreadyAppliedEditCount: edits.filter((edit) => edit.alreadyApplied).length,
|
|
46
49
|
...input.metadata
|
|
47
50
|
})
|
|
48
51
|
};
|
|
@@ -51,7 +54,7 @@ export function projectSemanticEditScriptToSource(input = {}) {
|
|
|
51
54
|
|
|
52
55
|
function sourceEditForOperation(operation, workerSourceText, headSourceText) {
|
|
53
56
|
if (operation.status === 'already-applied') {
|
|
54
|
-
return { ok: true, value: { operationId: operation.id, start: 0, end: 0, replacement: '', alreadyApplied: true } };
|
|
57
|
+
return { ok: true, value: { ...semanticEditIdentity(operation), operationId: operation.id, start: 0, end: 0, replacement: '', current: '', alreadyApplied: true } };
|
|
55
58
|
}
|
|
56
59
|
if (operation.status !== 'portable') return { ok: false, reasonCodes: [`operation-not-portable:${operation.id}`] };
|
|
57
60
|
const workerOffsets = spanOffsets(workerSourceText, operation.spans?.worker);
|
|
@@ -70,7 +73,61 @@ function sourceEditForOperation(operation, workerSourceText, headSourceText) {
|
|
|
70
73
|
reasons.push(`head-span-hash-mismatch:${operation.id}`);
|
|
71
74
|
}
|
|
72
75
|
if (reasons.length) return { ok: false, reasonCodes: reasons };
|
|
73
|
-
return {
|
|
76
|
+
return {
|
|
77
|
+
ok: true,
|
|
78
|
+
value: {
|
|
79
|
+
operationId: operation.id,
|
|
80
|
+
...semanticEditIdentity(operation),
|
|
81
|
+
start: headOffsets.start,
|
|
82
|
+
end: headOffsets.end,
|
|
83
|
+
workerStart: workerOffsets.start,
|
|
84
|
+
workerEnd: workerOffsets.end,
|
|
85
|
+
replacement,
|
|
86
|
+
current
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function projectionEditRecord(edit) {
|
|
92
|
+
return compactRecord({
|
|
93
|
+
operationId: edit.operationId,
|
|
94
|
+
status: edit.alreadyApplied ? 'already-applied' : 'applied',
|
|
95
|
+
kind: edit.kind,
|
|
96
|
+
changeKind: edit.changeKind,
|
|
97
|
+
anchorKey: edit.anchorKey,
|
|
98
|
+
conflictKey: edit.conflictKey,
|
|
99
|
+
regionId: edit.regionId,
|
|
100
|
+
regionKind: edit.regionKind,
|
|
101
|
+
sourcePath: edit.sourcePath,
|
|
102
|
+
symbolId: edit.symbolId,
|
|
103
|
+
symbolName: edit.symbolName,
|
|
104
|
+
symbolKind: edit.symbolKind,
|
|
105
|
+
headStart: edit.start,
|
|
106
|
+
headEnd: edit.end,
|
|
107
|
+
workerStart: edit.workerStart,
|
|
108
|
+
workerEnd: edit.workerEnd,
|
|
109
|
+
deletedBytes: edit.current.length,
|
|
110
|
+
replacementBytes: edit.replacement.length,
|
|
111
|
+
deletedTextHash: hashSemanticValue(edit.current),
|
|
112
|
+
replacementTextHash: hashSemanticValue(edit.replacement),
|
|
113
|
+
replacementText: edit.replacement
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function semanticEditIdentity(operation) {
|
|
118
|
+
const anchor = operation.anchor ?? {};
|
|
119
|
+
return compactRecord({
|
|
120
|
+
kind: operation.kind,
|
|
121
|
+
changeKind: operation.changeKind,
|
|
122
|
+
anchorKey: anchor.key,
|
|
123
|
+
conflictKey: anchor.conflictKey,
|
|
124
|
+
regionId: anchor.regionId,
|
|
125
|
+
regionKind: anchor.regionKind,
|
|
126
|
+
sourcePath: anchor.sourcePath,
|
|
127
|
+
symbolId: anchor.symbolId,
|
|
128
|
+
symbolName: anchor.symbolName,
|
|
129
|
+
symbolKind: anchor.symbolKind
|
|
130
|
+
});
|
|
74
131
|
}
|
|
75
132
|
|
|
76
133
|
function applySourceEdits(sourceText, edits) {
|
package/package.json
CHANGED