@shapeshift-labs/frontier-lang-compiler 0.2.35 → 0.2.36
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/index.d.ts +21 -1
- package/dist/index.js +58 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ import type {
|
|
|
20
20
|
SourceMapRecord,
|
|
21
21
|
SourcePreservationLevel,
|
|
22
22
|
SourcePreservationRecord,
|
|
23
|
-
SourceSpan
|
|
23
|
+
SourceSpan,
|
|
24
|
+
UniversalAstLayerMap,
|
|
25
|
+
UniversalAstLayerRecord
|
|
24
26
|
} from '@shapeshift-labs/frontier-lang-kernel';
|
|
25
27
|
import type { Diagnostic } from '@shapeshift-labs/frontier-lang-checker';
|
|
26
28
|
import type { EmitTypeScriptOptions, TypeScriptAstModule, TypeScriptDocumentSourceMapResult, TypeScriptGeneratedSourceMapResult } from '@shapeshift-labs/frontier-lang-typescript';
|
|
@@ -963,6 +965,9 @@ export interface SemanticImportSidecarImportEntry {
|
|
|
963
965
|
readonly sourceMapMappingCount: number;
|
|
964
966
|
readonly sourcePreservationRecordCount: number;
|
|
965
967
|
readonly sourcePreservationLevels: readonly SourcePreservationLevel[];
|
|
968
|
+
readonly universalAstLayerCount: number;
|
|
969
|
+
readonly universalAstLayerNames: readonly string[];
|
|
970
|
+
readonly universalAstLayerIds: readonly string[];
|
|
966
971
|
readonly readiness: SemanticMergeReadiness;
|
|
967
972
|
readonly emptySemanticIndex: boolean;
|
|
968
973
|
readonly regionTaxonomy?: SemanticImportRegionTaxonomySummary;
|
|
@@ -986,6 +991,14 @@ export interface SemanticImportSidecarSourcePreservationRecord {
|
|
|
986
991
|
readonly reasons: readonly string[];
|
|
987
992
|
}
|
|
988
993
|
|
|
994
|
+
export interface SemanticImportSidecarUniversalAstLayerSummary {
|
|
995
|
+
readonly total: number;
|
|
996
|
+
readonly names: readonly string[];
|
|
997
|
+
readonly ids: readonly string[];
|
|
998
|
+
readonly byName: Readonly<Record<string, number>>;
|
|
999
|
+
readonly empty: boolean;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
989
1002
|
export interface SemanticImportSidecar {
|
|
990
1003
|
readonly kind: 'frontier.lang.semanticImportSidecar';
|
|
991
1004
|
readonly version: 1;
|
|
@@ -1014,6 +1027,7 @@ export interface SemanticImportSidecar {
|
|
|
1014
1027
|
readonly sourceMapMappingIds: readonly string[];
|
|
1015
1028
|
readonly records: readonly SemanticImportSidecarSourcePreservationRecord[];
|
|
1016
1029
|
};
|
|
1030
|
+
readonly universalAstLayers: SemanticImportSidecarUniversalAstLayerSummary;
|
|
1017
1031
|
readonly patchHints: readonly SemanticImportPatchHint[];
|
|
1018
1032
|
readonly mergeCandidates: readonly {
|
|
1019
1033
|
readonly id?: string;
|
|
@@ -1043,6 +1057,8 @@ export interface SemanticImportSidecar {
|
|
|
1043
1057
|
readonly regionKinds: number;
|
|
1044
1058
|
readonly sourceMapMappings: number;
|
|
1045
1059
|
readonly sourcePreservationRecords: number;
|
|
1060
|
+
readonly universalAstLayers: number;
|
|
1061
|
+
readonly universalAstLayerNames: readonly string[];
|
|
1046
1062
|
readonly readiness: SemanticMergeReadiness;
|
|
1047
1063
|
readonly emptySemanticIndex: boolean;
|
|
1048
1064
|
};
|
|
@@ -2190,9 +2206,13 @@ export declare function diffNativeSourceImports(input: DiffNativeSourceImportsOp
|
|
|
2190
2206
|
export declare function importNativeProject(input: ImportNativeProjectOptions): Promise<NativeProjectImportResult>;
|
|
2191
2207
|
export declare function createUniversalAstFromDocument(document: FrontierLangDocument, input?: {
|
|
2192
2208
|
readonly id?: string;
|
|
2209
|
+
readonly nativeSources?: readonly NativeSourceNode[];
|
|
2193
2210
|
readonly semanticIndex?: SemanticIndexRecord;
|
|
2194
2211
|
readonly sourceMaps?: readonly SourceMapRecord[];
|
|
2212
|
+
readonly losses?: readonly NativeAstLossRecord[];
|
|
2195
2213
|
readonly evidence?: readonly EvidenceRecord[];
|
|
2214
|
+
readonly mergeCandidates?: readonly SemanticMergeCandidateRecord[];
|
|
2215
|
+
readonly layers?: UniversalAstLayerMap | readonly UniversalAstLayerRecord[];
|
|
2196
2216
|
readonly metadata?: Record<string, unknown>;
|
|
2197
2217
|
}): FrontierUniversalAstEnvelope;
|
|
2198
2218
|
export declare function readUniversalAstJson(source: string): FrontierUniversalAstEnvelope;
|
package/dist/index.js
CHANGED
|
@@ -2565,6 +2565,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
|
|
|
2565
2565
|
const lossSummary = summarizeNativeImportLosses(losses, { evidence });
|
|
2566
2566
|
const regionTaxonomy = summarizeSemanticImportRegionTaxonomy(ownershipRegions);
|
|
2567
2567
|
const sourcePreservation = summarizeKernelSourcePreservation(importResult, imports);
|
|
2568
|
+
const universalAstLayers = summarizeSemanticImportSidecarUniversalAstLayers(importEntries);
|
|
2568
2569
|
const readiness = mergeCandidates.reduce(
|
|
2569
2570
|
(current, candidate) => maxSemanticMergeReadiness(current, candidate.readiness),
|
|
2570
2571
|
lossSummary.semanticMergeReadiness
|
|
@@ -2586,6 +2587,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
|
|
|
2586
2587
|
ids: sourceMaps.map((sourceMap) => sourceMap.id).filter(Boolean)
|
|
2587
2588
|
},
|
|
2588
2589
|
sourcePreservation,
|
|
2590
|
+
universalAstLayers,
|
|
2589
2591
|
patchHints,
|
|
2590
2592
|
mergeCandidates: mergeCandidates.map((candidate) => ({
|
|
2591
2593
|
id: candidate.id,
|
|
@@ -2615,6 +2617,8 @@ export function createSemanticImportSidecar(importResult, options = {}) {
|
|
|
2615
2617
|
regionKinds: regionTaxonomy.presentKinds.length,
|
|
2616
2618
|
sourceMapMappings: sourceMapMappings.length,
|
|
2617
2619
|
sourcePreservationRecords: sourcePreservation.total,
|
|
2620
|
+
universalAstLayers: universalAstLayers.total,
|
|
2621
|
+
universalAstLayerNames: universalAstLayers.names,
|
|
2618
2622
|
readiness,
|
|
2619
2623
|
emptySemanticIndex: symbols.length === 0
|
|
2620
2624
|
},
|
|
@@ -8577,6 +8581,7 @@ function semanticImportSidecarEntry(imported, index, options) {
|
|
|
8577
8581
|
const sourceMaps = imported?.sourceMaps ?? imported?.universalAst?.sourceMaps ?? [];
|
|
8578
8582
|
const sourceMapMappings = sourceMaps.flatMap((sourceMap) => sourceMap?.mappings ?? []);
|
|
8579
8583
|
const sourcePreservationRecords = collectKernelSourcePreservationFromImport(imported);
|
|
8584
|
+
const universalAstLayers = summarizeUniversalAstLayers(imported?.universalAst);
|
|
8580
8585
|
const mappingsBySymbolId = new Map();
|
|
8581
8586
|
for (const mapping of sourceMapMappings) {
|
|
8582
8587
|
if (mapping.semanticSymbolId && !mappingsBySymbolId.has(mapping.semanticSymbolId)) {
|
|
@@ -8623,6 +8628,9 @@ function semanticImportSidecarEntry(imported, index, options) {
|
|
|
8623
8628
|
sourceMapMappingCount: sourceMapMappings.length,
|
|
8624
8629
|
sourcePreservationRecordCount: sourcePreservationRecords.length,
|
|
8625
8630
|
sourcePreservationLevels: uniqueStrings(sourcePreservationRecords.map((record) => record.level).filter(Boolean)),
|
|
8631
|
+
universalAstLayerCount: universalAstLayers.total,
|
|
8632
|
+
universalAstLayerNames: universalAstLayers.names,
|
|
8633
|
+
universalAstLayerIds: universalAstLayers.ids,
|
|
8626
8634
|
readiness: imported?.metadata?.semanticMergeReadiness ?? imported?.mergeCandidates?.[0]?.readiness ?? 'needs-review',
|
|
8627
8635
|
emptySemanticIndex: symbols.length === 0,
|
|
8628
8636
|
regionTaxonomy,
|
|
@@ -8631,6 +8639,52 @@ function semanticImportSidecarEntry(imported, index, options) {
|
|
|
8631
8639
|
};
|
|
8632
8640
|
}
|
|
8633
8641
|
|
|
8642
|
+
function summarizeSemanticImportSidecarUniversalAstLayers(importEntries) {
|
|
8643
|
+
const names = [];
|
|
8644
|
+
const ids = [];
|
|
8645
|
+
const byName = {};
|
|
8646
|
+
for (const entry of importEntries) {
|
|
8647
|
+
names.push(...(entry.universalAstLayerNames ?? []));
|
|
8648
|
+
ids.push(...(entry.universalAstLayerIds ?? []));
|
|
8649
|
+
for (const name of entry.universalAstLayerNames ?? []) {
|
|
8650
|
+
byName[name] = (byName[name] ?? 0) + 1;
|
|
8651
|
+
}
|
|
8652
|
+
}
|
|
8653
|
+
const uniqueNames = uniqueStrings(names);
|
|
8654
|
+
return {
|
|
8655
|
+
total: ids.length,
|
|
8656
|
+
names: uniqueNames,
|
|
8657
|
+
ids: uniqueStrings(ids),
|
|
8658
|
+
byName,
|
|
8659
|
+
empty: ids.length === 0
|
|
8660
|
+
};
|
|
8661
|
+
}
|
|
8662
|
+
|
|
8663
|
+
function summarizeUniversalAstLayers(universalAst) {
|
|
8664
|
+
const layers = collectUniversalAstLayerRecords(universalAst?.layers);
|
|
8665
|
+
const names = uniqueStrings(layers.map((layer) => layer.layer).filter(Boolean));
|
|
8666
|
+
const ids = uniqueStrings(layers.map((layer) => layer.id).filter(Boolean));
|
|
8667
|
+
const byName = {};
|
|
8668
|
+
for (const layer of layers) {
|
|
8669
|
+
if (!layer?.layer) continue;
|
|
8670
|
+
byName[layer.layer] = (byName[layer.layer] ?? 0) + 1;
|
|
8671
|
+
}
|
|
8672
|
+
return {
|
|
8673
|
+
total: layers.length,
|
|
8674
|
+
names,
|
|
8675
|
+
ids,
|
|
8676
|
+
byName,
|
|
8677
|
+
empty: layers.length === 0
|
|
8678
|
+
};
|
|
8679
|
+
}
|
|
8680
|
+
|
|
8681
|
+
function collectUniversalAstLayerRecords(layers) {
|
|
8682
|
+
if (!layers) return [];
|
|
8683
|
+
if (Array.isArray(layers)) return layers.filter(Boolean);
|
|
8684
|
+
if (typeof layers !== 'object') return [];
|
|
8685
|
+
return Object.values(layers).flatMap((value) => Array.isArray(value) ? value : [value]).filter(Boolean);
|
|
8686
|
+
}
|
|
8687
|
+
|
|
8634
8688
|
function semanticOwnershipRegionForSymbol(imported, symbol, mapping, nativeNode, options = {}) {
|
|
8635
8689
|
const sourcePath = mapping?.sourceSpan?.path ?? symbol.definitionSpan?.path ?? nativeNode?.span?.path ?? imported?.sourcePath ?? imported?.nativeSource?.sourcePath ?? imported?.nativeAst?.sourcePath;
|
|
8636
8690
|
const language = symbol.language ?? imported?.language ?? imported?.nativeAst?.language ?? imported?.nativeSource?.language;
|
|
@@ -9359,9 +9413,13 @@ export function createUniversalAstFromDocument(document, input = {}) {
|
|
|
9359
9413
|
return createUniversalAstEnvelope({
|
|
9360
9414
|
id: input.id ?? `universal_ast_${idFragment(document.id)}`,
|
|
9361
9415
|
document,
|
|
9416
|
+
nativeSources: input.nativeSources,
|
|
9362
9417
|
semanticIndex: input.semanticIndex,
|
|
9363
9418
|
sourceMaps: input.sourceMaps ?? [],
|
|
9419
|
+
losses: input.losses,
|
|
9364
9420
|
evidence: input.evidence ?? [],
|
|
9421
|
+
mergeCandidates: input.mergeCandidates,
|
|
9422
|
+
layers: input.layers,
|
|
9365
9423
|
metadata: input.metadata
|
|
9366
9424
|
});
|
|
9367
9425
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshift-labs/frontier-lang-compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
4
4
|
"description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@shapeshift-labs/frontier-lang-c": "0.2.5",
|
|
60
60
|
"@shapeshift-labs/frontier-lang-checker": "0.3.4",
|
|
61
61
|
"@shapeshift-labs/frontier-lang-javascript": "0.2.5",
|
|
62
|
-
"@shapeshift-labs/frontier-lang-kernel": "0.3.
|
|
62
|
+
"@shapeshift-labs/frontier-lang-kernel": "0.3.6",
|
|
63
63
|
"@shapeshift-labs/frontier-lang-parser": "0.3.4",
|
|
64
64
|
"@shapeshift-labs/frontier-lang-python": "0.2.5",
|
|
65
65
|
"@shapeshift-labs/frontier-lang-rust": "0.2.5",
|