@shapeshift-labs/frontier-lang-compiler 0.2.141 → 0.2.142

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/README.md CHANGED
@@ -200,11 +200,12 @@ interface, type, class, or object member additions. Existing class/object method
200
200
  or property body edits inside the declared member region are preserved for
201
201
  semantic replay while added members are neutralized; object member additions are
202
202
  re-emitted with safe commas when both sides add final properties.
203
- If staged whole-declaration replay cannot verify because head changed a sibling
204
- member inside the same declaration, `safeMergeJsTsSource` retries the direct
205
- semantic edit projection and admits the merge only when replay still verifies
206
- cleanly. That direct retry can project onto the staged top-level merge output,
207
- so safe import/declaration additions are preserved alongside the sibling edit.
203
+ When head changed an existing sibling declaration or sibling member,
204
+ `safeMergeJsTsSource` prefers the direct semantic edit projection over a
205
+ neutralized staged projection, and admits the merge only when replay still
206
+ verifies cleanly. That direct path projects onto a staged top-level output with
207
+ head declaration changes replayed first, so safe import/declaration additions
208
+ are preserved without dropping the head-side sibling edit.
208
209
 
209
210
  Project-level JS/TS safe merges compose the same file-level gates across a
210
211
  base/worker/head file set. They preserve head-only files, admit worker-only
@@ -20,23 +20,14 @@ import { idFragment, uniqueStrings } from './native-import-utils.js';
20
20
  function semanticEditFallbackResult(input, topLevelResult) {
21
21
  if (!shouldTrySemanticEditFallback(topLevelResult)) return topLevelResult;
22
22
  const stagedFallback = createStagedTopLevelSemanticFallback(input, topLevelResult);
23
- let selectedFallback = stagedFallback;
24
- let artifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallback);
25
- if (stagedFallback && artifacts.status !== 'verified') {
26
- const directFallback = stagedFallback.directProjectionHeadSourceText && stagedFallback.safeTopLevelChanges > 0
27
- ? { ...stagedFallback, projectionMode: 'direct' }
28
- : undefined;
29
- const directArtifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, directFallback);
30
- if (directArtifacts.status === 'verified') {
31
- artifacts = directArtifacts;
32
- selectedFallback = directFallback;
33
- } else if (directFallback) {
34
- const plainDirectArtifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, undefined);
35
- if (plainDirectArtifacts.status === 'verified') {
36
- artifacts = plainDirectArtifacts;
37
- selectedFallback = undefined;
38
- }
39
- }
23
+ const candidates = semanticFallbackCandidates(stagedFallback);
24
+ let selectedFallback = candidates[0];
25
+ let artifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, selectedFallback);
26
+ for (const candidate of candidates.slice(1)) {
27
+ if (artifacts.status === 'verified') break;
28
+ const nextArtifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, candidate);
29
+ if (nextArtifacts.status === 'verified') selectedFallback = candidate;
30
+ artifacts = nextArtifacts.status === 'verified' ? nextArtifacts : artifacts;
40
31
  }
41
32
  if (artifacts.status !== 'verified') return semanticEditFallbackBlockedResult(input, topLevelResult, artifacts);
42
33
  const resultBase = selectedFallback?.stagedTopLevelResult ?? topLevelResult;
@@ -83,6 +74,16 @@ function semanticEditFallbackResult(input, topLevelResult) {
83
74
  };
84
75
  }
85
76
 
77
+ function semanticFallbackCandidates(stagedFallback) {
78
+ if (!stagedFallback) return [undefined];
79
+ const headChanged = (stagedFallback.neutralization?.summary?.headChangedExistingDeclarations ?? 0) > 0;
80
+ const directFallback = stagedFallback.directProjectionHeadSourceText && (headChanged || stagedFallback.safeTopLevelChanges > 0)
81
+ ? { ...stagedFallback, projectionMode: 'direct' }
82
+ : undefined;
83
+ if (headChanged) return directFallback ? [directFallback, undefined] : [undefined];
84
+ return directFallback ? [stagedFallback, directFallback, undefined] : [stagedFallback];
85
+ }
86
+
86
87
  function createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallback) {
87
88
  try {
88
89
  const id = String(input.id ?? topLevelResult.id ?? 'js_ts_safe_merge');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.141",
3
+ "version": "0.2.142",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",