@shapeshift-labs/frontier-lang-compiler 0.2.136 → 0.2.138

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.
@@ -47,7 +47,9 @@ export function createSourceMergePlan(base, worker, head, workerPlan, headPlan,
47
47
  label: 'import'
48
48
  });
49
49
  const headImportGroupsByAnchor = new Map(headImportInsertionGroups.map((group) => [insertionGroupKey(group), group]));
50
+ const countedImportInsertionGroups = new Set();
50
51
  for (const group of importInsertionGroups) {
52
+ countedImportInsertionGroups.add(insertionGroupKey(group));
51
53
  const anchor = headEntriesByBaseKey.get(group.anchorKey);
52
54
  if (!anchor) {
53
55
  addConflict(context, {
@@ -68,7 +70,10 @@ export function createSourceMergePlan(base, worker, head, workerPlan, headPlan,
68
70
  end: insertionSpan.end,
69
71
  text: importInsertionText(entries, detectLineEnding(head.sourceText))
70
72
  });
71
- importDeclarationAdditions += group.entries.length;
73
+ importDeclarationAdditions += entries.length;
74
+ }
75
+ for (const group of headImportInsertionGroups) {
76
+ if (!countedImportInsertionGroups.has(insertionGroupKey(group))) importDeclarationAdditions += group.entries.length;
72
77
  }
73
78
 
74
79
  const insertionGroups = variantInsertionGroups(worker, workerPlan.matchedVariantKeys, 'worker', context, {
@@ -83,7 +88,9 @@ export function createSourceMergePlan(base, worker, head, workerPlan, headPlan,
83
88
  });
84
89
  const headDeclarationGroupsByAnchor = new Map(headInsertionGroups.map((group) => [insertionGroupKey(group), group]));
85
90
  let topLevelDeclarationAdditions = 0;
91
+ const countedDeclarationInsertionGroups = new Set();
86
92
  for (const group of insertionGroups) {
93
+ countedDeclarationInsertionGroups.add(insertionGroupKey(group));
87
94
  const anchor = headEntriesByBaseKey.get(group.anchorKey);
88
95
  if (!anchor) {
89
96
  addConflict(context, {
@@ -104,7 +111,10 @@ export function createSourceMergePlan(base, worker, head, workerPlan, headPlan,
104
111
  end: insertionSpan.end,
105
112
  text: declarationInsertionText(entries, detectLineEnding(head.sourceText))
106
113
  });
107
- topLevelDeclarationAdditions += group.entries.length;
114
+ topLevelDeclarationAdditions += entries.length;
115
+ }
116
+ for (const group of headInsertionGroups) {
117
+ if (!countedDeclarationInsertionGroups.has(insertionGroupKey(group))) topLevelDeclarationAdditions += group.entries.length;
108
118
  }
109
119
 
110
120
  return {
@@ -38,7 +38,7 @@ function semanticEditFallbackResult(input, topLevelResult) {
38
38
  },
39
39
  summary: {
40
40
  ...resultBase.summary,
41
- changedExistingDeclarations: topLevelResult.summary?.changedExistingDeclarations ?? resultBase.summary?.changedExistingDeclarations ?? 0,
41
+ changedExistingDeclarations: semanticFallbackChangedExistingDeclarations(topLevelResult, resultBase, stagedFallback),
42
42
  conflicts: 0,
43
43
  gatesPassed: gates.filter((gate) => gate.status === 'passed').length,
44
44
  semanticEditOperations: artifacts.script.summary.operations,
@@ -62,7 +62,28 @@ function semanticEditFallbackResult(input, topLevelResult) {
62
62
 
63
63
  function shouldTrySemanticEditFallback(result) {
64
64
  const conflicts = result.conflicts ?? [];
65
- return conflicts.length > 0 && conflicts.every((conflict) => conflict.code === JsTsSafeMergeConflictCodes.changedExistingDeclaration);
65
+ return conflicts.length > 0 && conflicts.every((conflict) => semanticFallbackConflictCodes.has(conflict.code));
66
+ }
67
+
68
+ const semanticFallbackConflictCodes = new Set([
69
+ JsTsSafeMergeConflictCodes.changedExistingDeclaration,
70
+ JsTsSafeMergeConflictCodes.typeAliasConflict
71
+ ]);
72
+
73
+ function semanticFallbackConflictCode(result) {
74
+ return result.conflicts?.find((conflict) => semanticFallbackConflictCodes.has(conflict.code))?.code
75
+ ?? JsTsSafeMergeConflictCodes.changedExistingDeclaration;
76
+ }
77
+
78
+ function semanticFallbackChangedExistingDeclarations(topLevelResult, resultBase, stagedFallback) {
79
+ const conflictCount = (topLevelResult.conflicts ?? [])
80
+ .filter((conflict) => semanticFallbackConflictCodes.has(conflict.code)).length;
81
+ return Math.max(
82
+ topLevelResult.summary?.changedExistingDeclarations ?? 0,
83
+ resultBase?.summary?.changedExistingDeclarations ?? 0,
84
+ stagedFallback?.neutralization?.summary?.workerChangedExistingDeclarations ?? 0,
85
+ conflictCount
86
+ );
66
87
  }
67
88
 
68
89
  function createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallback) {
@@ -240,7 +261,7 @@ function semanticEditFallbackBlockedResult(input, topLevelResult, artifacts) {
240
261
  : topLevelResult.admission?.reasonCodes ?? [];
241
262
  const gates = semanticEditGates(artifacts);
242
263
  const conflict = {
243
- code: JsTsSafeMergeConflictCodes.changedExistingDeclaration,
264
+ code: semanticFallbackConflictCode(topLevelResult),
244
265
  gateId: 'semantic-edit-replay',
245
266
  message: 'JS/TS semantic edit fallback did not verify a clean replay.',
246
267
  side: 'worker',
@@ -262,6 +283,7 @@ function semanticEditFallbackBlockedResult(input, topLevelResult, artifacts) {
262
283
  },
263
284
  summary: {
264
285
  ...topLevelResult.summary,
286
+ changedExistingDeclarations: semanticFallbackChangedExistingDeclarations(topLevelResult, topLevelResult),
265
287
  conflicts: 1,
266
288
  gatesPassed: gates.filter((gate) => gate.status === 'passed').length,
267
289
  semanticEditOperations: artifacts.summary.operations,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.136",
3
+ "version": "0.2.138",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",