@shapeshift-labs/frontier-lang-compiler 0.2.16 → 0.2.17

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
@@ -9,6 +9,18 @@ const result = compileFrontierSource(source, { target: 'typescript' });
9
9
  if (result.ok) console.log(result.output);
10
10
  ```
11
11
 
12
+ Emit code with declaration-level source-map sidecars for semantic review and merge admission:
13
+
14
+ ```js
15
+ import { emitForTargetWithSourceMap } from '@shapeshift-labs/frontier-lang-compiler';
16
+
17
+ const { code, sourceMap, ast } = emitForTargetWithSourceMap(document, 'javascript', {
18
+ sourcePath: 'todo.frontier',
19
+ targetPath: 'todo.js',
20
+ semanticIndexId: 'semantic_index_todo'
21
+ });
22
+ ```
23
+
12
24
  Resolve target-specific capability bindings without hardcoding one runtime into the source graph:
13
25
 
14
26
  ```js
package/dist/index.d.ts CHANGED
@@ -21,11 +21,11 @@ import type {
21
21
  SourceSpan
22
22
  } from '@shapeshift-labs/frontier-lang-kernel';
23
23
  import type { Diagnostic } from '@shapeshift-labs/frontier-lang-checker';
24
- import type { EmitTypeScriptOptions, TypeScriptAstModule } from '@shapeshift-labs/frontier-lang-typescript';
25
- import type { EmitJavaScriptOptions, JavaScriptAstModule } from '@shapeshift-labs/frontier-lang-javascript';
26
- import type { EmitRustOptions, RustAstModule } from '@shapeshift-labs/frontier-lang-rust';
27
- import type { EmitPythonOptions, PythonAstModule } from '@shapeshift-labs/frontier-lang-python';
28
- import type { CAstHeader, EmitCHeaderOptions } from '@shapeshift-labs/frontier-lang-c';
24
+ import type { EmitTypeScriptOptions, TypeScriptAstModule, TypeScriptDocumentSourceMapResult, TypeScriptGeneratedSourceMapResult } from '@shapeshift-labs/frontier-lang-typescript';
25
+ import type { EmitJavaScriptOptions, EmitJavaScriptWithSourceMapResult, JavaScriptAstModule, JavaScriptSourceMapResult } from '@shapeshift-labs/frontier-lang-javascript';
26
+ import type { EmitRustOptions, EmitRustWithSourceMapResult, RustAstModule, RustSourceMapResult } from '@shapeshift-labs/frontier-lang-rust';
27
+ import type { EmitPythonOptions, EmitPythonWithSourceMapResult, PythonAstModule, PythonSourceMapResult } from '@shapeshift-labs/frontier-lang-python';
28
+ import type { CAstHeader, CSourceMapResult, EmitCHeaderOptions, EmitCHeaderWithSourceMapResult } from '@shapeshift-labs/frontier-lang-c';
29
29
 
30
30
  export type FrontierCompileTarget = 'typescript' | 'javascript' | 'rust' | 'python' | 'c';
31
31
 
@@ -43,6 +43,20 @@ export type FrontierTargetAst =
43
43
  | PythonAstModule
44
44
  | CAstHeader;
45
45
 
46
+ export type FrontierTargetSourceMapResult =
47
+ | TypeScriptGeneratedSourceMapResult
48
+ | JavaScriptSourceMapResult
49
+ | RustSourceMapResult
50
+ | PythonSourceMapResult
51
+ | CSourceMapResult;
52
+
53
+ export type FrontierTargetDocumentSourceMapResult =
54
+ | TypeScriptDocumentSourceMapResult
55
+ | EmitJavaScriptWithSourceMapResult
56
+ | EmitRustWithSourceMapResult
57
+ | EmitPythonWithSourceMapResult
58
+ | EmitCHeaderWithSourceMapResult;
59
+
46
60
  export interface FrontierCompileOptions {
47
61
  readonly target?: FrontierCompileTarget | 'ts' | 'js' | 'rs' | 'py' | 'h';
48
62
  readonly fileName?: string;
@@ -1180,6 +1194,8 @@ export declare function compileFrontierSource(source: string, options?: Frontier
1180
1194
  export declare function compileFrontierDocument(document: FrontierLangDocument, options?: FrontierCompileOptions): FrontierCompileResult;
1181
1195
  export declare function projectFrontierAst(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: FrontierCompileEmitOptions): FrontierTargetAst;
1182
1196
  export declare function renderTargetAst(ast: FrontierTargetAst, target?: FrontierCompileOptions['target']): string;
1197
+ export declare function renderTargetAstWithSourceMap(ast: FrontierTargetAst, target?: FrontierCompileOptions['target'], options?: FrontierCompileEmitOptions): FrontierTargetSourceMapResult;
1198
+ export declare function emitForTargetWithSourceMap(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: FrontierCompileEmitOptions): FrontierTargetDocumentSourceMapResult;
1183
1199
  export declare function resolveCapabilityAdapters(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: { readonly platform?: string }): readonly CapabilityResolution[];
1184
1200
  export declare function summarizeNativeImportLosses(losses?: readonly NativeAstLossRecord[], options?: NativeImportLossSummaryOptions): NativeImportLossSummary;
1185
1201
  export declare function classifyNativeImportReadiness(losses?: readonly NativeAstLossRecord[], options?: NativeImportLossSummaryOptions): NativeImportReadinessClassification;
package/dist/index.js CHANGED
@@ -15,11 +15,11 @@ import {
15
15
  } from '@shapeshift-labs/frontier-lang-kernel';
16
16
  import { parseFrontierFile, parseFrontierSource } from '@shapeshift-labs/frontier-lang-parser';
17
17
  import { checkDocument } from '@shapeshift-labs/frontier-lang-checker';
18
- import { renderTypeScriptAst, toTypeScriptAst } from '@shapeshift-labs/frontier-lang-typescript';
19
- import { renderJavaScriptAst, toJavaScriptAst } from '@shapeshift-labs/frontier-lang-javascript';
20
- import { renderRustAst, toRustAst } from '@shapeshift-labs/frontier-lang-rust';
21
- import { renderPythonAst, toPythonAst } from '@shapeshift-labs/frontier-lang-python';
22
- import { renderCAst, toCAst } from '@shapeshift-labs/frontier-lang-c';
18
+ import { renderTypeScriptAst, renderTypeScriptAstWithSourceMap, toTypeScriptAst } from '@shapeshift-labs/frontier-lang-typescript';
19
+ import { renderJavaScriptAst, renderJavaScriptAstWithSourceMap, toJavaScriptAst } from '@shapeshift-labs/frontier-lang-javascript';
20
+ import { renderRustAst, renderRustAstWithSourceMap, toRustAst } from '@shapeshift-labs/frontier-lang-rust';
21
+ import { renderPythonAst, renderPythonAstWithSourceMap, toPythonAst } from '@shapeshift-labs/frontier-lang-python';
22
+ import { renderCAst, renderCAstWithSourceMap, toCAst } from '@shapeshift-labs/frontier-lang-c';
23
23
 
24
24
  export const FrontierCompileTargets = Object.freeze([
25
25
  'typescript',
@@ -45,6 +45,14 @@ const renderers = Object.freeze({
45
45
  c: renderCAst
46
46
  });
47
47
 
48
+ const sourceMapRenderers = Object.freeze({
49
+ typescript: renderTypeScriptAstWithSourceMap,
50
+ javascript: renderJavaScriptAstWithSourceMap,
51
+ rust: renderRustAstWithSourceMap,
52
+ python: renderPythonAstWithSourceMap,
53
+ c: renderCAstWithSourceMap
54
+ });
55
+
48
56
  const canonicalTargets = Object.freeze({
49
57
  ts: 'typescript',
50
58
  js: 'javascript',
@@ -256,6 +264,12 @@ export function renderTargetAst(ast, target = 'typescript') {
256
264
  return renderer(ast);
257
265
  }
258
266
 
267
+ export function renderTargetAstWithSourceMap(ast, target = 'typescript', options = {}) {
268
+ const normalized = normalizeCompileTarget(target);
269
+ const renderer = sourceMapRenderers[normalized];
270
+ return renderer(ast, options);
271
+ }
272
+
259
273
  export function resolveCapabilityAdapters(document, target = 'typescript', options = {}) {
260
274
  const normalized = normalizeCompileTarget(target);
261
275
  const platform = options.platform;
@@ -4567,6 +4581,16 @@ export function emitForTarget(document, target = 'typescript', options = {}) {
4567
4581
  return renderTargetAst(projectFrontierAst(document, target, options), target);
4568
4582
  }
4569
4583
 
4584
+ export function emitForTargetWithSourceMap(document, target = 'typescript', options = {}) {
4585
+ const normalized = normalizeCompileTarget(target);
4586
+ const ast = projectFrontierAst(document, normalized, options);
4587
+ const result = renderTargetAstWithSourceMap(ast, normalized, {
4588
+ sourceMapId: options.sourceMapId ?? `sourcemap_${idFragment(document.id)}_${normalized}`,
4589
+ ...options
4590
+ });
4591
+ return { ...result, ast };
4592
+ }
4593
+
4570
4594
  function createJavaScriptSyntaxImporterAdapter(options) {
4571
4595
  return {
4572
4596
  id: options.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -56,13 +56,13 @@
56
56
  "access": "public"
57
57
  },
58
58
  "dependencies": {
59
- "@shapeshift-labs/frontier-lang-c": "0.2.4",
59
+ "@shapeshift-labs/frontier-lang-c": "0.2.5",
60
60
  "@shapeshift-labs/frontier-lang-checker": "0.3.4",
61
- "@shapeshift-labs/frontier-lang-javascript": "0.2.4",
61
+ "@shapeshift-labs/frontier-lang-javascript": "0.2.5",
62
62
  "@shapeshift-labs/frontier-lang-kernel": "0.3.4",
63
63
  "@shapeshift-labs/frontier-lang-parser": "0.3.4",
64
- "@shapeshift-labs/frontier-lang-python": "0.2.4",
65
- "@shapeshift-labs/frontier-lang-rust": "0.2.4",
64
+ "@shapeshift-labs/frontier-lang-python": "0.2.5",
65
+ "@shapeshift-labs/frontier-lang-rust": "0.2.5",
66
66
  "@shapeshift-labs/frontier-lang-typescript": "0.3.5"
67
67
  },
68
68
  "devDependencies": {