@shapeshift-labs/frontier-lang-compiler 0.2.31 → 0.2.33
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 +28 -2
- package/bench/smoke.mjs +36 -2
- package/dist/index.d.ts +74 -0
- package/dist/index.js +1813 -266
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -336,8 +336,10 @@ import {
|
|
|
336
336
|
createCSharpRoslynNativeImporterAdapter,
|
|
337
337
|
createGoAstNativeImporterAdapter,
|
|
338
338
|
createJavaAstNativeImporterAdapter,
|
|
339
|
+
createKotlinPsiNativeImporterAdapter,
|
|
339
340
|
createPythonAstNativeImporterAdapter,
|
|
340
341
|
createRustSynNativeImporterAdapter,
|
|
342
|
+
createSwiftSyntaxNativeImporterAdapter,
|
|
341
343
|
importNativeProject,
|
|
342
344
|
runNativeImporterAdapter
|
|
343
345
|
} from '@shapeshift-labs/frontier-lang-compiler';
|
|
@@ -366,11 +368,21 @@ const javaAstAdapter = createJavaAstNativeImporterAdapter({
|
|
|
366
368
|
javaVersion: '21',
|
|
367
369
|
sourceLevel: '21'
|
|
368
370
|
});
|
|
371
|
+
const kotlinPsiAdapter = createKotlinPsiNativeImporterAdapter({
|
|
372
|
+
parserModule: hostKotlinPsiParser,
|
|
373
|
+
kotlinVersion: '2.1',
|
|
374
|
+
analysisApiEvidence: { hash: kotlinAnalysisApiIndexHash }
|
|
375
|
+
});
|
|
369
376
|
const csharpRoslynAdapter = createCSharpRoslynNativeImporterAdapter({
|
|
370
377
|
parserModule: hostRoslynParser,
|
|
371
378
|
languageVersion: '12',
|
|
372
379
|
nullableContext: 'enabled'
|
|
373
380
|
});
|
|
381
|
+
const swiftSyntaxAdapter = createSwiftSyntaxNativeImporterAdapter({
|
|
382
|
+
parserModule: hostSwiftSyntaxParser,
|
|
383
|
+
swiftVersion: '6',
|
|
384
|
+
sourceKitEvidence: { hash: sourceKitIndexHash }
|
|
385
|
+
});
|
|
374
386
|
|
|
375
387
|
const imported = await runNativeImporterAdapter(babelAdapter, {
|
|
376
388
|
sourcePath: 'src/todo.ts',
|
|
@@ -379,7 +391,7 @@ const imported = await runNativeImporterAdapter(babelAdapter, {
|
|
|
379
391
|
|
|
380
392
|
const project = await importNativeProject({
|
|
381
393
|
projectRoot: 'src',
|
|
382
|
-
adapters: [babelAdapter, pythonAstAdapter, rustSynAdapter, clangAstAdapter, goAstAdapter, javaAstAdapter, csharpRoslynAdapter],
|
|
394
|
+
adapters: [babelAdapter, pythonAstAdapter, rustSynAdapter, clangAstAdapter, goAstAdapter, javaAstAdapter, kotlinPsiAdapter, csharpRoslynAdapter, swiftSyntaxAdapter],
|
|
383
395
|
sources: [
|
|
384
396
|
{ language: 'typescript', adapter: babelAdapter.id, sourcePath: 'src/todo.ts', sourceText },
|
|
385
397
|
{ language: 'python', adapter: pythonAstAdapter.id, sourcePath: 'tools/todo.py', sourceText: pythonSource },
|
|
@@ -387,7 +399,9 @@ const project = await importNativeProject({
|
|
|
387
399
|
{ language: 'c', adapter: clangAstAdapter.id, sourcePath: 'native/todo.c', sourceText: cSource },
|
|
388
400
|
{ language: 'go', adapter: goAstAdapter.id, sourcePath: 'cmd/todo/main.go', sourceText: goSource },
|
|
389
401
|
{ language: 'java', adapter: javaAstAdapter.id, sourcePath: 'src/main/java/Todo.java', sourceText: javaSource },
|
|
390
|
-
{ language: '
|
|
402
|
+
{ language: 'kotlin', adapter: kotlinPsiAdapter.id, sourcePath: 'src/main/kotlin/Todo.kt', sourceText: kotlinSource },
|
|
403
|
+
{ language: 'csharp', adapter: csharpRoslynAdapter.id, sourcePath: 'src/Todo.cs', sourceText: csharpSource },
|
|
404
|
+
{ language: 'swift', adapter: swiftSyntaxAdapter.id, sourcePath: 'Sources/Todo.swift', sourceText: swiftSource }
|
|
391
405
|
]
|
|
392
406
|
});
|
|
393
407
|
|
|
@@ -411,7 +425,9 @@ The built-in adapter factories are dependency-light wrappers for caller-owned pa
|
|
|
411
425
|
- `createClangAstNativeImporterAdapter`
|
|
412
426
|
- `createGoAstNativeImporterAdapter`
|
|
413
427
|
- `createJavaAstNativeImporterAdapter`
|
|
428
|
+
- `createKotlinPsiNativeImporterAdapter`
|
|
414
429
|
- `createCSharpRoslynNativeImporterAdapter`
|
|
430
|
+
- `createSwiftSyntaxNativeImporterAdapter`
|
|
415
431
|
- `createTreeSitterNativeImporterAdapter`
|
|
416
432
|
|
|
417
433
|
Adapter summaries include a structured `coverage` record so merge queues can distinguish exact parser AST imports from declaration scans. The record declares exactness, parser token/trivia support, diagnostics support, source-range and generated-range support, and semantic coverage. Built-in wrappers normalize native AST/CST nodes and declaration-level semantic indexes; they do not claim resolved references, types, control flow, generated ranges, or token/trivia fidelity unless the host adapter supplies that evidence.
|
|
@@ -459,6 +475,11 @@ The published Frontier package family is generated from one shared package catal
|
|
|
459
475
|
- [`@shapeshift-labs/frontier-lang-rust`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-rust): Rust projection adapter for Frontier Lang semantic documents, including structs, aliases, and action stubs.
|
|
460
476
|
- [`@shapeshift-labs/frontier-lang-python`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-python): Python projection adapter for Frontier Lang semantic documents, including dataclasses, typed patch records, and action stubs.
|
|
461
477
|
- [`@shapeshift-labs/frontier-lang-c`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-c): C header projection adapter for Frontier Lang semantic documents, including structs and action prototypes.
|
|
478
|
+
- [`@shapeshift-labs/frontier-lang-swift`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-swift): Swift source-language importer package for Frontier Lang semantic documents, including package-level metadata, SwiftSyntax adapter helpers, native import results, and semantic sidecar generation for SwiftSyntax/SwiftParser-shaped syntax trees.
|
|
479
|
+
- [`@shapeshift-labs/frontier-lang-java`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-java): Java source-language importer package for Frontier Lang semantic documents, including package-level metadata, Java AST adapter helpers, native import results, and semantic sidecar generation for javac/JDT/JavaParser-shaped ASTs.
|
|
480
|
+
- [`@shapeshift-labs/frontier-lang-go`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-go): Go source-language importer package for Frontier Lang semantic documents, including package-level metadata, Go AST adapter helpers, native import results, and semantic sidecar generation for go/ast File or Package trees.
|
|
481
|
+
- [`@shapeshift-labs/frontier-lang-csharp`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-csharp): C# Roslyn source-language importer package for Frontier Lang semantic documents, including package-level metadata, Roslyn adapter helpers, native import results, and semantic sidecar generation for SyntaxTree/SyntaxNode-shaped ASTs.
|
|
482
|
+
- [`@shapeshift-labs/frontier-lang-clang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-clang): Clang AST source-language importer package for Frontier Lang semantic documents, including package-level metadata, Clang AST JSON adapter helpers, native import results, and semantic sidecar generation for C/C++ translation units.
|
|
462
483
|
- [`@shapeshift-labs/frontier-lang-cli`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-cli): Command line interface for parsing, checking, hashing, and emitting Frontier Lang projects.
|
|
463
484
|
- [`@shapeshift-labs/frontier-lang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang): Umbrella package for Frontier Lang kernel, parser, checker, and projection adapters.
|
|
464
485
|
- [`@shapeshift-labs/frontier-kv`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv): Serializable in-memory key/value state for Frontier apps, including TTL, versioned compare-and-set, batched patch mutations, scans, watchers, snapshots, JSONL event evidence, and replay verification.
|
|
@@ -546,6 +567,11 @@ Package source repositories:
|
|
|
546
567
|
- [`siliconjungle/-shapeshift-labs-frontier-lang-python`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-python)
|
|
547
568
|
- [`siliconjungle/-shapeshift-labs-frontier-lang-c`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-c)
|
|
548
569
|
- [`siliconjungle/-shapeshift-labs-frontier-lang-compiler`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler)
|
|
570
|
+
- [`siliconjungle/-shapeshift-labs-frontier-lang-swift`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-swift)
|
|
571
|
+
- [`siliconjungle/-shapeshift-labs-frontier-lang-java`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-java)
|
|
572
|
+
- [`siliconjungle/-shapeshift-labs-frontier-lang-go`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-go)
|
|
573
|
+
- [`siliconjungle/-shapeshift-labs-frontier-lang-csharp`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-csharp)
|
|
574
|
+
- [`siliconjungle/-shapeshift-labs-frontier-lang-clang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-clang)
|
|
549
575
|
- [`siliconjungle/-shapeshift-labs-frontier-lang-cli`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-cli)
|
|
550
576
|
- [`siliconjungle/-shapeshift-labs-frontier-lang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang)
|
|
551
577
|
- [`siliconjungle/-shapeshift-labs-frontier-kv`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv)
|
package/bench/smoke.mjs
CHANGED
|
@@ -7,12 +7,14 @@ import {
|
|
|
7
7
|
createEstreeNativeImporterAdapter,
|
|
8
8
|
createGoAstNativeImporterAdapter,
|
|
9
9
|
createJavaAstNativeImporterAdapter,
|
|
10
|
+
createKotlinPsiNativeImporterAdapter,
|
|
10
11
|
createNativeImportCoverageMatrix,
|
|
11
12
|
createNativeParserAstFormatMatrix,
|
|
12
13
|
createProjectionTargetLossMatrix,
|
|
13
14
|
createNativeSourcePreservation,
|
|
14
15
|
createPythonAstNativeImporterAdapter,
|
|
15
16
|
createRustSynNativeImporterAdapter,
|
|
17
|
+
createSwiftSyntaxNativeImporterAdapter,
|
|
16
18
|
createSemanticImportSidecar,
|
|
17
19
|
diffNativeSources,
|
|
18
20
|
importExternalSemanticIndex,
|
|
@@ -47,6 +49,7 @@ const compileDurationMs = performance.now() - start;
|
|
|
47
49
|
|
|
48
50
|
const importStart = performance.now();
|
|
49
51
|
const estreeAdapter = createEstreeNativeImporterAdapter();
|
|
52
|
+
const kotlinPsiAdapter = createKotlinPsiNativeImporterAdapter();
|
|
50
53
|
let nativeSymbols = 0;
|
|
51
54
|
const nativeImportResults = [];
|
|
52
55
|
for (let index = 0; index < 150; index += 1) {
|
|
@@ -74,6 +77,37 @@ for (let index = 0; index < 150; index += 1) {
|
|
|
74
77
|
nativeSymbols += imported.semanticIndex?.symbols?.length ?? 0;
|
|
75
78
|
nativeImportResults.push(imported);
|
|
76
79
|
}
|
|
80
|
+
for (let index = 0; index < 50; index += 1) {
|
|
81
|
+
const imported = await runNativeImporterAdapter(kotlinPsiAdapter, {
|
|
82
|
+
sourcePath: `src/bench-${index}.kt`,
|
|
83
|
+
sourceText: `package bench\nclass BenchKotlin${index}(val title: String) { fun render${index}() = title }\n`,
|
|
84
|
+
adapterOptions: {
|
|
85
|
+
ast: {
|
|
86
|
+
kind: 'KtFile',
|
|
87
|
+
packageDirective: { kind: 'KtPackageDirective', fqName: 'bench' },
|
|
88
|
+
declarations: [{
|
|
89
|
+
kind: 'KtClass',
|
|
90
|
+
name: `BenchKotlin${index}`,
|
|
91
|
+
declarations: [{
|
|
92
|
+
kind: 'KtPrimaryConstructor',
|
|
93
|
+
parameters: [{
|
|
94
|
+
kind: 'KtParameter',
|
|
95
|
+
name: 'title',
|
|
96
|
+
typeReference: { text: 'String' },
|
|
97
|
+
valOrVarKeyword: 'val'
|
|
98
|
+
}]
|
|
99
|
+
}, {
|
|
100
|
+
kind: 'KtNamedFunction',
|
|
101
|
+
name: `render${index}`,
|
|
102
|
+
bodyExpression: { kind: 'KtBlockExpression' }
|
|
103
|
+
}]
|
|
104
|
+
}]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
nativeSymbols += imported.semanticIndex?.symbols?.length ?? 0;
|
|
109
|
+
nativeImportResults.push(imported);
|
|
110
|
+
}
|
|
77
111
|
const importDurationMs = performance.now() - importStart;
|
|
78
112
|
|
|
79
113
|
const matrixStart = performance.now();
|
|
@@ -83,7 +117,7 @@ const matrixDurationMs = performance.now() - matrixStart;
|
|
|
83
117
|
const parserFormatMatrixStart = performance.now();
|
|
84
118
|
const parserFormatMatrix = createNativeParserAstFormatMatrix({
|
|
85
119
|
imports: nativeImportResults,
|
|
86
|
-
adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter(), createJavaAstNativeImporterAdapter(), createCSharpRoslynNativeImporterAdapter()]
|
|
120
|
+
adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter(), createJavaAstNativeImporterAdapter(), kotlinPsiAdapter, createCSharpRoslynNativeImporterAdapter(), createSwiftSyntaxNativeImporterAdapter()]
|
|
87
121
|
});
|
|
88
122
|
const parserFormatMatrixDurationMs = performance.now() - parserFormatMatrixStart;
|
|
89
123
|
|
|
@@ -232,7 +266,7 @@ console.log(JSON.stringify({
|
|
|
232
266
|
compiles: 250,
|
|
233
267
|
bytes,
|
|
234
268
|
compileDurationMs: Number(compileDurationMs.toFixed(2)),
|
|
235
|
-
nativeImports:
|
|
269
|
+
nativeImports: nativeImportResults.length,
|
|
236
270
|
nativeSymbols,
|
|
237
271
|
nativeImportDurationMs: Number(importDurationMs.toFixed(2)),
|
|
238
272
|
coverageMatrixLanguages: coverageMatrix.summary.languages,
|
package/dist/index.d.ts
CHANGED
|
@@ -1497,6 +1497,45 @@ export interface JavaAstNativeImporterAdapterOptions {
|
|
|
1497
1497
|
readonly maxNodes?: number;
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
|
+
export interface KotlinPsiNativeImporterAdapterOptions {
|
|
1501
|
+
readonly id?: string;
|
|
1502
|
+
readonly language?: FrontierSourceLanguage;
|
|
1503
|
+
readonly parser?: string;
|
|
1504
|
+
readonly version?: string;
|
|
1505
|
+
readonly capabilities?: readonly string[];
|
|
1506
|
+
readonly coverage?: NativeImporterAdapterCoverageInput;
|
|
1507
|
+
readonly supportedExtensions?: readonly string[];
|
|
1508
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
1509
|
+
readonly ast?: unknown;
|
|
1510
|
+
readonly nativeAst?: unknown;
|
|
1511
|
+
readonly ktFile?: unknown;
|
|
1512
|
+
readonly file?: unknown;
|
|
1513
|
+
readonly sourceFile?: unknown;
|
|
1514
|
+
readonly root?: unknown;
|
|
1515
|
+
readonly parse?: (sourceText: string, options: Record<string, unknown>) => unknown;
|
|
1516
|
+
readonly parserModule?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1517
|
+
readonly kotlinPsi?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1518
|
+
readonly kotlinCompiler?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1519
|
+
readonly intellijPsi?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1520
|
+
readonly parserOptions?: Record<string, unknown>;
|
|
1521
|
+
readonly kotlinVersion?: string;
|
|
1522
|
+
readonly languageVersion?: string;
|
|
1523
|
+
readonly apiVersion?: string;
|
|
1524
|
+
readonly script?: boolean;
|
|
1525
|
+
readonly generated?: boolean;
|
|
1526
|
+
readonly analysisApiEvidence?: unknown;
|
|
1527
|
+
readonly firEvidence?: unknown;
|
|
1528
|
+
readonly compilerPluginEvidence?: unknown;
|
|
1529
|
+
readonly kspEvidence?: unknown;
|
|
1530
|
+
readonly kaptEvidence?: unknown;
|
|
1531
|
+
readonly multiplatformEvidence?: unknown;
|
|
1532
|
+
readonly buildVariantEvidence?: unknown;
|
|
1533
|
+
readonly positionResolver?: (position: unknown) => unknown;
|
|
1534
|
+
readonly lineMap?: unknown;
|
|
1535
|
+
readonly includeAnnotations?: boolean;
|
|
1536
|
+
readonly maxNodes?: number;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1500
1539
|
export interface CSharpRoslynNativeImporterAdapterOptions {
|
|
1501
1540
|
readonly id?: string;
|
|
1502
1541
|
readonly language?: FrontierSourceLanguage;
|
|
@@ -1531,6 +1570,39 @@ export interface CSharpRoslynNativeImporterAdapterOptions {
|
|
|
1531
1570
|
readonly maxNodes?: number;
|
|
1532
1571
|
}
|
|
1533
1572
|
|
|
1573
|
+
export interface SwiftSyntaxNativeImporterAdapterOptions {
|
|
1574
|
+
readonly id?: string;
|
|
1575
|
+
readonly language?: FrontierSourceLanguage;
|
|
1576
|
+
readonly parser?: string;
|
|
1577
|
+
readonly version?: string;
|
|
1578
|
+
readonly capabilities?: readonly string[];
|
|
1579
|
+
readonly coverage?: NativeImporterAdapterCoverageInput;
|
|
1580
|
+
readonly supportedExtensions?: readonly string[];
|
|
1581
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
1582
|
+
readonly ast?: unknown;
|
|
1583
|
+
readonly nativeAst?: unknown;
|
|
1584
|
+
readonly sourceFile?: unknown;
|
|
1585
|
+
readonly sourceFileSyntax?: unknown;
|
|
1586
|
+
readonly root?: unknown;
|
|
1587
|
+
readonly parse?: (sourceText: string, options: Record<string, unknown>) => unknown;
|
|
1588
|
+
readonly parserModule?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1589
|
+
readonly swiftSyntax?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1590
|
+
readonly swiftParser?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1591
|
+
readonly parserOptions?: Record<string, unknown>;
|
|
1592
|
+
readonly swiftVersion?: string;
|
|
1593
|
+
readonly languageMode?: string;
|
|
1594
|
+
readonly enableBareSlashRegex?: boolean;
|
|
1595
|
+
readonly parseTransition?: string;
|
|
1596
|
+
readonly generated?: boolean;
|
|
1597
|
+
readonly sourceKitEvidence?: unknown;
|
|
1598
|
+
readonly macroExpansionEvidence?: unknown;
|
|
1599
|
+
readonly packageResolutionEvidence?: unknown;
|
|
1600
|
+
readonly positionResolver?: (position: unknown) => unknown;
|
|
1601
|
+
readonly lineMap?: unknown;
|
|
1602
|
+
readonly sourceLocationConverter?: unknown;
|
|
1603
|
+
readonly maxNodes?: number;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1534
1606
|
export interface TreeSitterNativeImporterAdapterOptions {
|
|
1535
1607
|
readonly id?: string;
|
|
1536
1608
|
readonly language?: FrontierSourceLanguage;
|
|
@@ -1905,7 +1977,9 @@ export declare function createRustSynNativeImporterAdapter(options?: RustSynNati
|
|
|
1905
1977
|
export declare function createClangAstNativeImporterAdapter(options?: ClangAstNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1906
1978
|
export declare function createGoAstNativeImporterAdapter(options?: GoAstNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1907
1979
|
export declare function createJavaAstNativeImporterAdapter(options?: JavaAstNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1980
|
+
export declare function createKotlinPsiNativeImporterAdapter(options?: KotlinPsiNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1908
1981
|
export declare function createCSharpRoslynNativeImporterAdapter(options?: CSharpRoslynNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1982
|
+
export declare function createSwiftSyntaxNativeImporterAdapter(options?: SwiftSyntaxNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1909
1983
|
export declare function createTreeSitterNativeImporterAdapter(options?: TreeSitterNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1910
1984
|
export declare function runNativeImporterAdapter(adapter: NativeImporterAdapter, input: RunNativeImporterAdapterOptions): Promise<NativeImporterAdapterImportResult>;
|
|
1911
1985
|
export declare function runNativeTargetProjectionAdapter(adapter: NativeTargetProjectionAdapter, input: NativeTargetProjectionAdapterInput): NativeTargetProjectionResult;
|