@shapeshift-labs/frontier-lang-compiler 0.2.103 → 0.2.104
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 +13 -0
- package/dist/declarations/bidirectional-target-change-source-edit.d.ts +30 -0
- package/dist/declarations/bidirectional-target-change.d.ts +10 -0
- package/dist/declarations/js-ts-safe-member-merge.d.ts +58 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +120 -0
- package/dist/declarations/js-ts-semantic-conflict-sidecars.d.ts +235 -0
- package/dist/declarations/js-ts-semantic-merge-contracts.d.ts +287 -0
- package/dist/declarations/js-ts-semantic-merge.d.ts +4 -0
- package/dist/declarations/native-import-losses.d.ts +3 -0
- package/dist/declarations/semantic-edit-replay-diagnostics.d.ts +12 -0
- package/dist/declarations/semantic-edit-script.d.ts +7 -4
- package/dist/declarations/semantic-patch-bundle-index.d.ts +45 -0
- package/dist/declarations/semantic-patch-bundle.d.ts +6 -4
- package/dist/declarations/semantic-sidecar-example.d.ts +18 -0
- package/dist/declarations/semantic-transform-identity.d.ts +3 -0
- package/dist/declarations/source-preservation.d.ts +72 -0
- package/dist/declarations/universal-capability.d.ts +4 -0
- package/dist/declarations/universal-conversion-artifacts.d.ts +61 -1
- package/dist/declarations/universal-conversion-compact-counts.d.ts +51 -0
- package/dist/declarations/universal-conversion-plan.d.ts +6 -1
- package/dist/declarations/universal-representation-coverage.d.ts +90 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/internal/index-impl/bidirectionalExactSourceBackprojection.js +199 -0
- package/dist/internal/index-impl/bidirectionalSameLanguageSourceProjection.js +112 -0
- package/dist/internal/index-impl/bidirectionalSourceEditProjection.js +319 -0
- package/dist/internal/index-impl/bidirectionalSourceEditProjectionArtifacts.js +67 -0
- package/dist/internal/index-impl/bidirectionalTargetChangeRecordInternals.js +17 -5
- package/dist/internal/index-impl/bidirectionalTargetRoundtripEvidence.js +58 -20
- package/dist/internal/index-impl/createBidirectionalTargetChangeRecord.js +60 -7
- package/dist/internal/index-impl/createLightweightNativeImport.js +1 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +28 -2
- package/dist/internal/index-impl/diffNativeSymbols.js +3 -3
- package/dist/internal/index-impl/nativeChangeProjectionSourceMapLinks.js +2 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +43 -8
- package/dist/internal/index-impl/replaySemanticEditLineEndings.js +34 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +39 -19
- package/dist/internal/index-impl/semanticEditBundleAdmission.js +7 -3
- package/dist/internal/index-impl/semanticEditBundleIndex.js +47 -1
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +40 -0
- package/dist/internal/index-impl/semanticEditOperationCoverage.js +33 -3
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +29 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +39 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +85 -0
- package/dist/internal/index-impl/semanticEditScripts.js +4 -0
- package/dist/internal/index-impl/semanticEditSourceRanges.js +27 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +1 -0
- package/dist/internal/index-impl/semanticPatchBundleAdmission.js +41 -7
- package/dist/internal/index-impl/semanticPatchBundleRecords.js +16 -0
- package/dist/internal/index-impl/semanticPatchBundleSourceRecords.js +2 -0
- package/dist/internal/index-impl/semanticSidecarQuality.js +111 -0
- package/dist/internal/index-impl/semanticSourceEditDedupe.js +69 -9
- package/dist/internal/index-impl/semanticTransformIdentityRecords.js +85 -9
- package/dist/js-ts-safe-member-merge-result.js +158 -0
- package/dist/js-ts-safe-member-merge.js +202 -0
- package/dist/js-ts-safe-merge-analyze.js +279 -0
- package/dist/js-ts-safe-merge-constants.js +50 -0
- package/dist/js-ts-safe-merge-context.js +118 -0
- package/dist/js-ts-safe-merge-ledger-validation.js +92 -0
- package/dist/js-ts-safe-merge-ledger.js +85 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +210 -0
- package/dist/js-ts-safe-merge-parse-statements.js +155 -0
- package/dist/js-ts-safe-merge-plan.js +190 -0
- package/dist/js-ts-safe-merge.js +175 -0
- package/dist/js-ts-semantic-conflict-sidecar-constants.js +77 -0
- package/dist/js-ts-semantic-conflict-sidecar-detectors.js +195 -0
- package/dist/js-ts-semantic-conflict-sidecar-normalize.js +203 -0
- package/dist/js-ts-semantic-conflict-sidecar-utils.js +190 -0
- package/dist/js-ts-semantic-conflict-sidecars.js +81 -0
- package/dist/js-ts-semantic-merge-contract-helpers.js +128 -0
- package/dist/js-ts-semantic-merge-contracts.js +217 -0
- package/dist/js-ts-semantic-merge-member-containers.js +100 -0
- package/dist/js-ts-semantic-merge-member-keys.js +142 -0
- package/dist/js-ts-semantic-merge-member-segments.js +185 -0
- package/dist/js-ts-semantic-merge-member-source.js +64 -0
- package/dist/js-ts-semantic-merge-member-utils.js +18 -0
- package/dist/js-ts-semantic-merge-parse.js +15 -0
- package/dist/js-ts-semantic-merge.js +21 -0
- package/dist/lightweight-dependency-effects.js +51 -0
- package/dist/lightweight-dependency-language.js +12 -1
- package/dist/lightweight-dependency-relations.js +14 -27
- package/dist/native-region-scanner-core.js +33 -1
- package/dist/native-region-scanner-csharp.js +151 -0
- package/dist/native-region-scanner-dart.js +91 -0
- package/dist/native-region-scanner-dynamic.js +21 -151
- package/dist/native-region-scanner-functional.js +40 -13
- package/dist/native-region-scanner-java.js +97 -0
- package/dist/native-region-scanner-js-class.js +100 -0
- package/dist/native-region-scanner-js-helpers.js +28 -86
- package/dist/native-region-scanner-js-imports.js +121 -1
- package/dist/native-region-scanner-js-nested.js +96 -8
- package/dist/native-region-scanner-js-structure.js +27 -0
- package/dist/native-region-scanner-js-types.js +99 -0
- package/dist/native-region-scanner-js.js +70 -118
- package/dist/native-region-scanner-kotlin.js +94 -0
- package/dist/native-region-scanner-main.js +15 -181
- package/dist/native-region-scanner-php.js +80 -0
- package/dist/native-region-scanner-python.js +62 -0
- package/dist/native-region-scanner-ruby.js +72 -0
- package/dist/native-region-scanner-scala.js +91 -0
- package/dist/native-region-scanner-spans.js +74 -0
- package/dist/native-region-scanner-swift.js +155 -0
- package/dist/native-region-scanner.js +14 -10
- package/dist/native-source-ledger-helpers.js +195 -0
- package/dist/native-source-ledger.js +306 -0
- package/dist/native-source-preservation-scanner.js +4 -0
- package/dist/semantic-import-callsite-regions.js +136 -0
- package/dist/semantic-import-effect-regions.js +283 -0
- package/dist/semantic-import-regions.js +11 -2
- package/dist/semantic-import-sidecar-entry.js +16 -2
- package/dist/semantic-import-sidecar-types.d.ts +2 -0
- package/dist/semantic-sidecar-example.js +68 -0
- package/dist/universal-capability-matrix.js +23 -0
- package/dist/universal-conversion-artifact-query.js +79 -2
- package/dist/universal-conversion-artifact-semantic-edit.js +103 -0
- package/dist/universal-conversion-artifact-summary.js +33 -1
- package/dist/universal-conversion-artifacts.js +13 -48
- package/dist/universal-conversion-plan-scoring.js +21 -1
- package/dist/universal-conversion-plan-summary.js +30 -0
- package/dist/universal-conversion-plan.js +25 -9
- package/dist/universal-conversion-route-metadata.js +96 -0
- package/dist/universal-conversion-route-operations.js +7 -0
- package/dist/universal-representation-coverage.js +193 -0
- package/package.json +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { uniqueStrings } from './native-import-utils.js';
|
|
2
|
+
|
|
3
|
+
export const UniversalRepresentationConstructKinds = Object.freeze([
|
|
4
|
+
'source-import',
|
|
5
|
+
'semantic-symbol',
|
|
6
|
+
'source-map',
|
|
7
|
+
'parser-feature',
|
|
8
|
+
'source-preservation',
|
|
9
|
+
'declaration-stub',
|
|
10
|
+
'target-adapter',
|
|
11
|
+
'runtime-capability',
|
|
12
|
+
'semantic-ownership',
|
|
13
|
+
'proof-evidence'
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export function createUniversalRepresentationCoverage(input = {}) {
|
|
17
|
+
const language = input.sourceLanguage ?? input.language?.language ?? input.language;
|
|
18
|
+
const target = input.target ?? input.targetCell?.target;
|
|
19
|
+
const imports = input.imports ?? input.language?.imports ?? {};
|
|
20
|
+
const parser = input.parser ?? input.language?.parser ?? {};
|
|
21
|
+
const projection = input.projection ?? input.language?.projection ?? {};
|
|
22
|
+
const runtime = input.runtime ?? {};
|
|
23
|
+
const mergeRefs = input.mergeRefs ?? {};
|
|
24
|
+
const evidence = input.evidence ?? [];
|
|
25
|
+
const constructs = representationConstructs({
|
|
26
|
+
evidence,
|
|
27
|
+
imports,
|
|
28
|
+
mergeRefs,
|
|
29
|
+
parser,
|
|
30
|
+
projection,
|
|
31
|
+
runtime,
|
|
32
|
+
targetCell: input.targetCell
|
|
33
|
+
});
|
|
34
|
+
const missing = missingRepresentation({ imports, parser, projection, runtime, mergeRefs, evidence });
|
|
35
|
+
const blockers = representationBlockers({ imports, parser, runtime, missing });
|
|
36
|
+
const review = representationReview({ imports, parser, projection, runtime, targetCell: input.targetCell });
|
|
37
|
+
return {
|
|
38
|
+
kind: 'frontier.lang.universalRepresentationCoverage',
|
|
39
|
+
version: 1,
|
|
40
|
+
language,
|
|
41
|
+
target,
|
|
42
|
+
constructKinds: uniqueStrings(constructs.map((item) => item.kind)),
|
|
43
|
+
constructs,
|
|
44
|
+
surfaces: representationSurfaces({ imports, parser, projection, runtime, mergeRefs, evidence }),
|
|
45
|
+
missing,
|
|
46
|
+
blockers,
|
|
47
|
+
review,
|
|
48
|
+
summary: {
|
|
49
|
+
constructs: constructs.length,
|
|
50
|
+
representedConstructs: constructs.filter((item) => item.status === 'represented').length,
|
|
51
|
+
reviewConstructs: constructs.filter((item) => item.status === 'review').length,
|
|
52
|
+
blockedConstructs: constructs.filter((item) => item.status === 'blocked').length,
|
|
53
|
+
missing: missing.length,
|
|
54
|
+
blockers: blockers.length,
|
|
55
|
+
review: review.length
|
|
56
|
+
},
|
|
57
|
+
autoMergeClaim: false,
|
|
58
|
+
semanticEquivalenceClaim: false
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function representationCoverageMatches(coverage, query = {}) {
|
|
63
|
+
return match(query.constructKind ?? query.construct, coverage?.constructKinds)
|
|
64
|
+
&& match(query.runtimeCapability, coverage?.surfaces?.runtime?.requiredCapabilities)
|
|
65
|
+
&& match(query.sourceMapPrecision, coverage?.surfaces?.sourceMaps?.precisions)
|
|
66
|
+
&& match(query.transformIdentityHash, coverage?.surfaces?.mergeRefs?.transformIdentityHashes);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function representationConstructs(input) {
|
|
70
|
+
return uniqueConstructs([
|
|
71
|
+
construct('source-import', input.imports.total ? 'represented' : 'missing', 'native-import', input.imports.total),
|
|
72
|
+
construct('semantic-symbol', input.imports.symbols ? 'represented' : 'missing', 'semantic-index', input.imports.symbols),
|
|
73
|
+
construct('source-map', input.imports.sourceMapMappings ? 'represented' : 'review', 'source-map', input.imports.sourceMapMappings),
|
|
74
|
+
construct('parser-feature', input.parser.rows ? 'represented' : 'missing', 'parser', input.parser.rows),
|
|
75
|
+
construct('source-preservation', input.projection.sourceProjection?.exactSource?.evidence?.importsWithExactSource ? 'represented' : 'review', 'projection', input.projection.sourceProjection?.exactSource?.evidence?.importsWithExactSource),
|
|
76
|
+
construct('declaration-stub', input.projection.sourceProjection?.stubs?.evidence?.importsWithDeclarations ? 'represented' : 'review', 'projection', input.projection.sourceProjection?.stubs?.evidence?.importsWithDeclarations),
|
|
77
|
+
construct('target-adapter', input.targetCell?.adapter ? 'represented' : input.targetCell?.lossClass === 'missingAdapter' ? 'blocked' : 'review', 'target-projection', input.targetCell?.adapter ? 1 : 0),
|
|
78
|
+
...runtimeConstructs(input.runtime),
|
|
79
|
+
construct('semantic-ownership', input.mergeRefs.semanticOwnershipKeys?.length ? 'represented' : 'review', 'merge-refs', input.mergeRefs.semanticOwnershipKeys?.length),
|
|
80
|
+
construct('proof-evidence', proofEvidenceCount(input.evidence) ? 'represented' : 'review', 'evidence', proofEvidenceCount(input.evidence))
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function construct(kind, status, surface, count = 0) {
|
|
85
|
+
return {
|
|
86
|
+
kind,
|
|
87
|
+
status,
|
|
88
|
+
surface,
|
|
89
|
+
count: Number(count ?? 0),
|
|
90
|
+
autoMergeClaim: false,
|
|
91
|
+
semanticEquivalenceClaim: false
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function runtimeConstructs(runtime) {
|
|
96
|
+
return (runtime.requiredCapabilities ?? []).map((capability) => construct(
|
|
97
|
+
'runtime-capability',
|
|
98
|
+
(runtime.missingCapabilities ?? []).includes(capability) ? 'blocked' : (runtime.adapterRequirements ?? []).some((entry) => entry.capability === capability) ? 'review' : 'represented',
|
|
99
|
+
`runtime:${capability}`,
|
|
100
|
+
1
|
|
101
|
+
));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function representationSurfaces(input) {
|
|
105
|
+
return {
|
|
106
|
+
sourceImport: { total: Number(input.imports.total ?? 0), readiness: input.imports.readiness },
|
|
107
|
+
semanticIndex: { symbols: Number(input.imports.symbols ?? 0), sourceMapMappings: Number(input.imports.sourceMapMappings ?? 0) },
|
|
108
|
+
sourceMaps: { mappings: Number(input.imports.sourceMapMappings ?? 0), precisions: sourceMapPrecisions(input) },
|
|
109
|
+
parser: { rows: Number(input.parser.rows ?? 0), mergeReadyParsers: input.parser.mergeReadyParsers ?? [] },
|
|
110
|
+
projection: {
|
|
111
|
+
targetEntries: input.projection.targets?.length ?? 0,
|
|
112
|
+
missingTargets: input.projection.missingTargets ?? [],
|
|
113
|
+
unsupportedTargets: input.projection.unsupportedTargets ?? []
|
|
114
|
+
},
|
|
115
|
+
runtime: {
|
|
116
|
+
requiredCapabilities: input.runtime.requiredCapabilities ?? [],
|
|
117
|
+
satisfiedCapabilities: input.runtime.satisfiedCapabilities ?? [],
|
|
118
|
+
missingCapabilities: input.runtime.missingCapabilities ?? [],
|
|
119
|
+
adapterRequirements: (input.runtime.adapterRequirements ?? []).map((entry) => entry.id ?? entry.capability).filter(Boolean)
|
|
120
|
+
},
|
|
121
|
+
mergeRefs: {
|
|
122
|
+
ownershipKeys: input.mergeRefs.semanticOwnershipKeys ?? [],
|
|
123
|
+
conflictKeys: input.mergeRefs.conflictKeys ?? [],
|
|
124
|
+
sourceMapIds: input.mergeRefs.sourceMapIds ?? [],
|
|
125
|
+
sourceMapMappingIds: input.mergeRefs.sourceMapMappingIds ?? [],
|
|
126
|
+
transformIdentityHashes: input.mergeRefs.transformIdentityHashes ?? []
|
|
127
|
+
},
|
|
128
|
+
evidence: {
|
|
129
|
+
records: input.evidence.length,
|
|
130
|
+
proofRecords: proofEvidenceCount(input.evidence)
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function missingRepresentation(input) {
|
|
136
|
+
return uniqueStrings([
|
|
137
|
+
...(input.imports.total ? [] : ['source-import']),
|
|
138
|
+
...(input.imports.symbols ? [] : ['semantic-symbol']),
|
|
139
|
+
...(input.imports.sourceMapMappings ? [] : ['source-map']),
|
|
140
|
+
...(input.parser.rows ? [] : ['parser-feature']),
|
|
141
|
+
...((input.projection.sourceProjection?.exactSource?.evidence?.importsWithExactSource ?? 0) ? [] : ['source-preservation']),
|
|
142
|
+
...(input.mergeRefs.semanticOwnershipKeys?.length ? [] : ['semantic-ownership']),
|
|
143
|
+
...(proofEvidenceCount(input.evidence) ? [] : ['proof-evidence'])
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function representationBlockers(input) {
|
|
148
|
+
return uniqueStrings([
|
|
149
|
+
...(input.imports.total ? [] : ['No source import evidence is available.']),
|
|
150
|
+
...(input.parser.rows ? [] : ['No parser feature evidence is available.']),
|
|
151
|
+
...((input.runtime.missingCapabilities ?? []).map((capability) => `Runtime capability is missing: ${capability}.`))
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function representationReview(input) {
|
|
156
|
+
return uniqueStrings([
|
|
157
|
+
...((input.imports.losses ?? 0) ? [`Native import has ${input.imports.losses} loss record(s).`] : []),
|
|
158
|
+
...((input.parser.reviewFeatures ?? []).map((feature) => `Parser feature needs review: ${feature}.`)),
|
|
159
|
+
...((input.projection.unsupportedTargets ?? []).map((target) => `Target projection has unsupported features for ${target}.`)),
|
|
160
|
+
...((input.runtime.adapterRequirements ?? []).map((entry) => entry.reason).filter(Boolean)),
|
|
161
|
+
...(input.targetCell?.reason ? [input.targetCell.reason] : [])
|
|
162
|
+
]);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function sourceMapPrecisions(input) {
|
|
166
|
+
return uniqueStrings([
|
|
167
|
+
...(input.imports.sourceMapMappings ? ['imported'] : []),
|
|
168
|
+
...(input.mergeRefs.sourceMapMappingIds?.length ? ['mapped'] : []),
|
|
169
|
+
...(input.projection.sourceProjection?.exactSource?.evidence?.importsWithExactSource ? ['exact-source'] : []),
|
|
170
|
+
...(input.projection.sourceProjection?.stubs?.evidence?.importsWithDeclarations ? ['declaration'] : [])
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function proofEvidenceCount(evidence) {
|
|
175
|
+
return (evidence ?? []).filter((record) => record?.status === 'passed' || record?.status === 'ok' || record?.status === 'success').length;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function uniqueConstructs(constructs) {
|
|
179
|
+
const seen = new Set();
|
|
180
|
+
return constructs.filter((item) => {
|
|
181
|
+
const key = `${item.kind}:${item.surface}:${item.status}`;
|
|
182
|
+
if (seen.has(key)) return false;
|
|
183
|
+
seen.add(key);
|
|
184
|
+
return true;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function match(filter, values) {
|
|
189
|
+
const filters = Array.isArray(filter) ? filter : filter === undefined ? [] : [filter];
|
|
190
|
+
if (!filters.length) return true;
|
|
191
|
+
const valueSet = new Set((values ?? []).map(String));
|
|
192
|
+
return filters.some((item) => valueSet.has(String(item)));
|
|
193
|
+
}
|
package/package.json
CHANGED