@shapeshift-labs/frontier-lang-compiler 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ShapeShift Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,224 @@
1
+ # @shapeshift-labs/frontier-lang-compiler
2
+
3
+ Compiler facade for Frontier Lang. It composes the parser, checker, semantic kernel, and projection adapters for TypeScript, JavaScript, Rust, Python, and C.
4
+
5
+ ```js
6
+ import { compileFrontierSource } from '@shapeshift-labs/frontier-lang-compiler';
7
+
8
+ const result = compileFrontierSource(source, { target: 'typescript' });
9
+ if (result.ok) console.log(result.output);
10
+ ```
11
+
12
+ Resolve target-specific capability bindings without hardcoding one runtime into the source graph:
13
+
14
+ ```js
15
+ import { compileFrontierSource, resolveCapabilityAdapters } from '@shapeshift-labs/frontier-lang-compiler';
16
+
17
+ const result = compileFrontierSource(source, { target: 'rust' });
18
+ const bindings = resolveCapabilityAdapters(result.document, 'rust', { platform: 'native' });
19
+ console.log(bindings[0].status); // "bound", "unbound", or "unsupported"
20
+ ```
21
+
22
+ Create a loss-aware import bundle from a native parser or agent-produced AST:
23
+
24
+ ```js
25
+ import { importNativeSource } from '@shapeshift-labs/frontier-lang-compiler';
26
+
27
+ const imported = importNativeSource({
28
+ language: 'javascript',
29
+ parser: 'estree',
30
+ sourcePath: 'src/todo.js',
31
+ rootId: 'program',
32
+ nodes: {
33
+ program: { id: 'program', kind: 'Program', languageKind: 'ESTree.Program' }
34
+ }
35
+ });
36
+
37
+ console.log(imported.nativeSource.ast.rootId);
38
+ console.log(imported.patch.operations.length);
39
+ ```
40
+
41
+ ## Related Packages
42
+
43
+ The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
44
+
45
+ - [`@shapeshift-labs/frontier`](https://www.npmjs.com/package/@shapeshift-labs/frontier): Core JSON diff/apply, compact patch tuples, JSON Pointer, equality, clone, validation, Unicode helpers, and tiny dependency-free runtime budget/scheduler primitives.
46
+ - [`@shapeshift-labs/frontier-query`](https://www.npmjs.com/package/@shapeshift-labs/frontier-query): Shared query-key, selector path, condition, entity identity, and table-shape primitives.
47
+ - [`@shapeshift-labs/frontier-codec`](https://www.npmjs.com/package/@shapeshift-labs/frontier-codec): Patch serialization, binary frames, canonical JSON, and patch-history codecs.
48
+ - [`@shapeshift-labs/frontier-engine`](https://www.npmjs.com/package/@shapeshift-labs/frontier-engine): Stateful planned diff engine, adaptive profiles, schema plans, and engine-level history helpers.
49
+ - [`@shapeshift-labs/frontier-state`](https://www.npmjs.com/package/@shapeshift-labs/frontier-state): Patch-routed app-state subscriptions, owned commits, maintained views, and path mapping.
50
+ - [`@shapeshift-labs/frontier-dataflow`](https://www.npmjs.com/package/@shapeshift-labs/frontier-dataflow): Serializable incremental dataflow and materialized-view graphs for Frontier apps, including selectors, dependency DAGs, filters, joins, aggregations, stale paths, recompute budgets, output patches, provenance records, and proof of why derived views changed.
51
+ - [`@shapeshift-labs/frontier-state-cache`](https://www.npmjs.com/package/@shapeshift-labs/frontier-state-cache): Normalized query-result cache with entity/query watchers, persistence, change logs, optimistic layers, scheduled persistence, and mutation bridge.
52
+ - [`@shapeshift-labs/frontier-state-cache-idb`](https://www.npmjs.com/package/@shapeshift-labs/frontier-state-cache-idb): IndexedDB persistence adapter for Frontier state-cache snapshots and durable change logs.
53
+ - [`@shapeshift-labs/frontier-state-cache-file`](https://www.npmjs.com/package/@shapeshift-labs/frontier-state-cache-file): Structured file persistence adapter for Frontier state-cache snapshots and change logs.
54
+ - [`@shapeshift-labs/frontier-state-cache-sql`](https://www.npmjs.com/package/@shapeshift-labs/frontier-state-cache-sql): SQL persistence adapter for Frontier state-cache snapshots and change logs.
55
+ - [`@shapeshift-labs/frontier-schema`](https://www.npmjs.com/package/@shapeshift-labs/frontier-schema): JSON Schema validation, Frontier profile generation, CloudEvent envelopes, and query/table schema helpers.
56
+ - [`@shapeshift-labs/frontier-migrations`](https://www.npmjs.com/package/@shapeshift-labs/frontier-migrations): Boundary-first data migrations, import normalization, plugin/API version mapping, versioned envelopes, graph diagnostics, patch path rewrites, dry-run reports, and current-shape rehydration.
57
+ - [`@shapeshift-labs/frontier-event-log`](https://www.npmjs.com/package/@shapeshift-labs/frontier-event-log): Bounded event logs, replay cursors, consumer acknowledgements, keyed compaction, checkpoints, and Frontier patch event records.
58
+ - [`@shapeshift-labs/frontier-inspect`](https://www.npmjs.com/package/@shapeshift-labs/frontier-inspect): Cross-package inspection/evidence bundles, registry graph snapshots, feature/resource impact reports, timeline/event normalization, redaction, JSONL import/export, and AI-readable app feature maps.
59
+ - [`@shapeshift-labs/frontier-scheduler`](https://www.npmjs.com/package/@shapeshift-labs/frontier-scheduler): Deterministic work scheduling, lanes, cancellation, backpressure, frame policies, replay snapshots, and work graphs.
60
+ - [`@shapeshift-labs/frontier-logging`](https://www.npmjs.com/package/@shapeshift-labs/frontier-logging): Opt-in structured logging, browser telemetry, scheduled sinks, file sinks, exporters, benchmark traces, and Frontier patch/update summaries.
61
+ - [`@shapeshift-labs/frontier-mutation`](https://www.npmjs.com/package/@shapeshift-labs/frontier-mutation): Explicit mutation and selector plans compiled to Frontier patches or CRDT operations.
62
+ - [`@shapeshift-labs/frontier-effects`](https://www.npmjs.com/package/@shapeshift-labs/frontier-effects): Serializable effect descriptors and resource graphs for Frontier apps, including fetch, storage, timers, navigation, workers, clipboard, broadcast, WebSocket, stream, policy metadata, runtime records, redaction, JSONL, proof helpers, and registry graph output.
63
+ - [`@shapeshift-labs/frontier-auth`](https://www.npmjs.com/package/@shapeshift-labs/frontier-auth): Frontier-native auth contracts for providers, sessions, profile completeness, route and resource gates, account-linking policy, token issue/verify plans, runtime grants, audit events, registry graphs, lint resources, and auth evidence without owning app secrets, crypto, storage, or provider SDKs.
64
+ - [`@shapeshift-labs/frontier-policy`](https://www.npmjs.com/package/@shapeshift-labs/frontier-policy): Serializable policy and capability decisions for Frontier apps, effects, views, sync, routes, traces, and AI tools.
65
+ - [`@shapeshift-labs/frontier-flags`](https://www.npmjs.com/package/@shapeshift-labs/frontier-flags): Patchable policy-aware feature flag state for Frontier apps, including targeting, deterministic rollouts, experiment variants, kill switches, exposure records, audit logs, and replay evidence.
66
+ - [`@shapeshift-labs/frontier-tools`](https://www.npmjs.com/package/@shapeshift-labs/frontier-tools): Serializable app action/tool manifests for AI-operable Frontier apps, including availability, validation, dry-run plans, patch previews, effect/tool constraints, execution records, rollback links, and registry graph output.
67
+ - [`@shapeshift-labs/frontier-sandbox`](https://www.npmjs.com/package/@shapeshift-labs/frontier-sandbox): Runtime-agnostic sandbox contracts for Frontier patch-producing actions, including manifests, declared reads/writes/capabilities, host-validated patch/effect/event/log results, dynamic source modules, source event replay, and structural runtime adapters.
68
+ - [`@shapeshift-labs/frontier-sandbox-quickjs`](https://www.npmjs.com/package/@shapeshift-labs/frontier-sandbox-quickjs): QuickJS/WebAssembly runtime adapter for Frontier sandbox actions, including invocation/runtime isolation modes, deadline and memory limits, dynamic source execution, and patch/effect result normalization.
69
+ - [`@shapeshift-labs/frontier-workflow`](https://www.npmjs.com/package/@shapeshift-labs/frontier-workflow): Serializable durable workflow/process manifests for Frontier apps, including steps, waits, approvals, timers, retries, expected patches, compensation, records, timelines, and registry graph output.
70
+ - [`@shapeshift-labs/frontier-worker`](https://www.npmjs.com/package/@shapeshift-labs/frontier-worker): Serializable worker and edge task descriptors for Frontier apps, including queues, idempotency keys, retry and timeout policy, declared reads/writes/effects, snapshots, patch outputs, produced assets, execution records, logs, trace links, proof hashes, dedupe indexes, and registry graph output.
71
+ - [`@shapeshift-labs/frontier-queue`](https://www.npmjs.com/package/@shapeshift-labs/frontier-queue): Serializable durable queue state, leases, retries, dedupe keys, patch-carrying jobs, dead-letter records, replay evidence, and queue inspection for Frontier apps.
72
+ - [`@shapeshift-labs/frontier-swarm`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm): Hierarchical swarm plans, lanes, compute profiles, ownership policy, semantic ownership regions, task queues, event streams, run records, merge bundles, merge indexes, queue overlays, merge admission, changed-path checks, and proof artifacts for Frontier agent work.
73
+ - [`@shapeshift-labs/frontier-swarm-codex`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm-codex): Node Codex CLI adapter for Frontier swarm plans, including prompt rendering, worktree and snapshot workspaces, Codex argument compatibility, browser resource allocation, JSONL capture, verification commands, pid-backed stop, collect/apply workflows, merge indexes, queue overlays, merge bundles, and result artifacts.
74
+ - [`@shapeshift-labs/frontier-lang-kernel`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-kernel): Runtime-neutral semantic source graph, type/lattice/extern declarations, patch bundles, replay, hashing, evidence records, and merge-admission kernel for Frontier Lang.
75
+ - [`@shapeshift-labs/frontier-lang-parser`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-parser): Dependency-light Frontier Lang parser for modules, entities, state, actions, effects, types, externs, targets, and lattice declarations.
76
+ - [`@shapeshift-labs/frontier-lang-checker`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-checker): Checker and diagnostics for Frontier Lang semantic documents, including type symbols, effects, regions, lattice laws, CRDT metadata, and patch evidence.
77
+ - [`@shapeshift-labs/frontier-lang-typescript`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-typescript): TypeScript projection adapter for Frontier Lang semantic documents, including type/entity/state/action/extern declarations and CRDT lattice descriptors.
78
+ - [`@shapeshift-labs/frontier-lang-javascript`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-javascript): JavaScript projection adapter for Frontier Lang semantic documents, including ESM action stubs and schema/lattice descriptors.
79
+ - [`@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.
80
+ - [`@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.
81
+ - [`@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.
82
+ - [`@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.
83
+ - [`@shapeshift-labs/frontier-lang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang): Umbrella package for Frontier Lang kernel, parser, checker, and projection adapters.
84
+ - [`@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.
85
+ - [`@shapeshift-labs/frontier-kv-locks`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-locks): Lease-style lock records on top of Frontier KV, including acquire, renew, release, fencing tokens, expiration, owner evidence, and replayable lock events.
86
+ - [`@shapeshift-labs/frontier-kv-rate-limit`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-rate-limit): Patch-native rate limit buckets for Frontier KV, including fixed windows, sliding windows, token buckets, deterministic refill, consume evidence, and reset records.
87
+ - [`@shapeshift-labs/frontier-kv-file`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-file): Node file persistence adapter for Frontier KV snapshots and append-only JSONL event logs, including atomic writes, compaction, replay loading, and adapter evidence.
88
+ - [`@shapeshift-labs/frontier-kv-idb`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-idb): IndexedDB persistence adapter for Frontier KV snapshots and event logs, with structural IDB interfaces, upgrade planning, compact event storage, and replay loading.
89
+ - [`@shapeshift-labs/frontier-kv-redis`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-redis): Redis-compatible command planning and structural client adapter for Frontier KV operations, including key mapping, TTL commands, optimistic CAS scripts, and replay evidence without bundling Redis drivers.
90
+ - [`@shapeshift-labs/frontier-kv-server`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-server): Small Node HTTP server adapter for Frontier KV, including request planning, JSON endpoints for get/set/delete/scan/batch, optional rate-limit hooks, and replayable response evidence.
91
+ - [`@shapeshift-labs/frontier-assets`](https://www.npmjs.com/package/@shapeshift-labs/frontier-assets): Serializable asset and content provenance graphs for Frontier apps, including source files, generated variants, thumbnails, LOD chunks, shader/material dependencies, transforms, hashes, owners, runtime consumers, review plans, registry graph output, and impact queries.
92
+ - [`@shapeshift-labs/frontier-blueprint`](https://www.npmjs.com/package/@shapeshift-labs/frontier-blueprint): Serializable Blueprint/Prefab flyweight templates for Frontier apps, including parameterized instantiation, deterministic ID/path remapping, compact overrides, variants, effective-state materialization, scene/state patch emission, dependency metadata, and registry graph output.
93
+ - [`@shapeshift-labs/frontier-triggers`](https://www.npmjs.com/package/@shapeshift-labs/frontier-triggers): Capability-gated event trigger registry, scoped event envelopes, listener/reaction rules, structured rejection, deterministic event-to-action scheduling, replay/provenance records, and registry graph output.
94
+ - [`@shapeshift-labs/frontier-virtual`](https://www.npmjs.com/package/@shapeshift-labs/frontier-virtual): DOM-neutral virtualization, layout providers, range materialization, grids, spatial/frustum indexes, patch invalidation, camera anchors, and serializable layout state.
95
+ - [`@shapeshift-labs/frontier-table`](https://www.npmjs.com/package/@shapeshift-labs/frontier-table): Renderer-neutral data grid and table primitives for Frontier apps, including stable row identity, sorting, filtering, selection, virtual ranges, patch-driven edits, cache/dataflow descriptors, and CRDT-compatible row and cell operation frames.
96
+ - [`@shapeshift-labs/frontier-scene`](https://www.npmjs.com/package/@shapeshift-labs/frontier-scene): Patch-native 2D/3D scene graph, transform propagation, bounds queries, virtual/culling adapters, spatial invalidation, and camera/frustum materialization.
97
+ - [`@shapeshift-labs/frontier-pathfinding`](https://www.npmjs.com/package/@shapeshift-labs/frontier-pathfinding): Patch-native grid pathfinding, typed-array A*/Dijkstra search, flow fields, connected components, line-of-sight smoothing, dirty-cell invalidation, and scheduler-friendly path jobs.
98
+ - [`@shapeshift-labs/frontier-lod`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lod): Patch-native level-of-detail and significance selection for rendering and computation workloads, compact typed hot paths, multi-observer selection, budget degradation, materialization frames, and scheduler work plans.
99
+ - [`@shapeshift-labs/frontier-route`](https://www.npmjs.com/package/@shapeshift-labs/frontier-route): DOM-neutral app/game route resources, route and scene manifests, match/resolve/transition planning, dependency metadata, sessions, registry graph output, and impact queries.
100
+ - [`@shapeshift-labs/frontier-trace`](https://www.npmjs.com/package/@shapeshift-labs/frontier-trace): Serializable traces, spans, events, causal links, W3C trace context helpers, timeline/resource/path queries, critical-path analysis, registry graph output, JSONL/proof helpers, Chrome trace export, and redaction for app-wide feature observability.
101
+ - [`@shapeshift-labs/frontier-manifest`](https://www.npmjs.com/package/@shapeshift-labs/frontier-manifest): Build/static feature manifests for owners, routes, actions, states, migrations, tests, source files, assets, resources, tasks, dependency metadata, registry graph output, feature maps, JSONL export, and impact queries.
102
+ - [`@shapeshift-labs/frontier-view`](https://www.npmjs.com/package/@shapeshift-labs/frontier-view): Renderer-neutral view manifests, type defaults, validation frames, action bindings, visual channels, virtual/LOD hints, and data-to-representation mapping for Frontier apps.
103
+ - [`@shapeshift-labs/frontier-icons`](https://www.npmjs.com/package/@shapeshift-labs/frontier-icons): Renderer-neutral icon records, icon sets, lookup aliases, SVG frames, string rendering, and registry evidence for Frontier apps.
104
+ - [`@shapeshift-labs/frontier-design`](https://www.npmjs.com/package/@shapeshift-labs/frontier-design): Renderer-neutral design-system tokens, semantic roles, recipes, target style frames, CSS variable output, and registry graph evidence for Frontier apps.
105
+ - [`@shapeshift-labs/frontier-canvas`](https://www.npmjs.com/package/@shapeshift-labs/frontier-canvas): Renderer-neutral infinite canvas surfaces for Frontier apps, including camera and viewport math, pan/zoom plans, grid materialization, snapping, hit testing, selection handles, extensible tool dispatch, frame records, registry graph output, and impact/proof helpers.
106
+ - [`@shapeshift-labs/frontier-canvas-tools`](https://www.npmjs.com/package/@shapeshift-labs/frontier-canvas-tools): Renderer-neutral editor tools, state machines, transform handles, permissions, async records, and AI action bridges for Frontier canvas surfaces.
107
+ - [`@shapeshift-labs/frontier-dnd`](https://www.npmjs.com/package/@shapeshift-labs/frontier-dnd): Renderer-neutral drag-and-drop sessions, sensor descriptors, collision ranking, drop planning, reorder patches, state partitioning, and registry evidence for Frontier apps.
108
+ - [`@shapeshift-labs/frontier-dom`](https://www.npmjs.com/package/@shapeshift-labs/frontier-dom): Patch-native DOM and host renderer bindings, manifest hydration, JSX runtime/compiler helpers, SSR, devtools, and logging bridges.
109
+ - [`@shapeshift-labs/frontier-playwright`](https://www.npmjs.com/package/@shapeshift-labs/frontier-playwright): Playwright/headless automation probes for Frontier state, DOM, devtools, marks, and timeline queries.
110
+ - [`@shapeshift-labs/frontier-test`](https://www.npmjs.com/package/@shapeshift-labs/frontier-test): Serializable test/spec evidence manifests for Frontier apps, including fixtures, commands, expected patches/effects/routes/policies, coverage declarations, run plans, run records, report adapters, replay proofs, fuzzers, benchmarks, registry graph output, and impact queries.
111
+ - [`@shapeshift-labs/frontier-fixtures`](https://www.npmjs.com/package/@shapeshift-labs/frontier-fixtures): Deterministic fixture and scenario generation for Frontier apps, including schema-valid sample state, related entity collections, actor personas, route states, replay-verified patch streams, event records, JSONL bundles, and evidence summaries.
112
+ - [`@shapeshift-labs/frontier-component-preview`](https://www.npmjs.com/package/@shapeshift-labs/frontier-component-preview): Frontier-native component preview books, generated preview manifests, stateful variants, Vite virtual modules, standalone browser preview shells, inspector bridges, and preview harness evidence for Frontier apps.
113
+ - [`@shapeshift-labs/frontier-documentation`](https://www.npmjs.com/package/@shapeshift-labs/frontier-documentation): Frontier-native documentation manifests, generated documentation books, package/API/source discovery, Vite virtual modules, standalone browser docs shells, inspector bridges, search indexes, and documentation harness evidence for Frontier apps and packages.
114
+ - [`@shapeshift-labs/frontier-ast-walk`](https://www.npmjs.com/package/@shapeshift-labs/frontier-ast-walk): Dependency-light source graph, import/export/declaration/call analysis, Frontier package-use discovery, and business-logic placement findings for Frontier tools, apps, docs, fuzzers, benchmarks, and agent evidence.
115
+ - [`@shapeshift-labs/frontier-history`](https://www.npmjs.com/package/@shapeshift-labs/frontier-history): Serializable temporal explanation and causality records for Frontier apps, including field-change explanations, action/workflow/policy/effect/trace/test provenance, audit windows, undo planning, registry/provenance graph output, JSONL replay bundles, and proof hashes.
116
+ - [`@shapeshift-labs/frontier-application`](https://www.npmjs.com/package/@shapeshift-labs/frontier-application): Serializable whole-application graph and impact queries for Frontier apps, including features, owners, packages, routes, views, actions, mutations, state paths, effects, workers, assets, tests, traces, policies, workflows, migrations, benchmarks, registry graph output, feature maps, JSONL bundles, and proof hashes.
117
+ - [`@shapeshift-labs/frontier-linter`](https://www.npmjs.com/package/@shapeshift-labs/frontier-linter): Serializable Frontier lint rules, diagnostics, fixes, reports, and fast rule execution for package catalogs, registry graphs, application maps, manifests, traces, policies, workflows, workers, assets, tests, benchmarks, and source snippets.
118
+ - [`@shapeshift-labs/frontier-framework`](https://www.npmjs.com/package/@shapeshift-labs/frontier-framework): High-level app framework package for Frontier applications, including configuration, CLI scaffolding, Vite builds, monorepo layout, TSX route builds, split frontend/backend deploy artifacts, backend-neutral Fetch handler and sync transport contracts, runtime data-source migrations, devtools, harness gates, agent MCP/tool manifests, CI evidence gates, workflow manifests, SARIF/linter output, replay scripts, and evidence manifest output.
119
+ - [`@shapeshift-labs/frontier-crdt`](https://www.npmjs.com/package/@shapeshift-labs/frontier-crdt): Native CRDT documents, update tooling, awareness, branches, conflict introspection, version frames, and undo.
120
+ - [`@shapeshift-labs/frontier-crdt-sync`](https://www.npmjs.com/package/@shapeshift-labs/frontier-crdt-sync): CRDT sync endpoints, repo/storage/provider contracts, scheduled sync work, document URLs, local networks, model checking, forensics, and text binding contracts.
121
+ - [`@shapeshift-labs/frontier-crdt-websocket`](https://www.npmjs.com/package/@shapeshift-labs/frontier-crdt-websocket): WebSocket client/server transports for Frontier CRDT sync providers.
122
+ - [`@shapeshift-labs/frontier-react`](https://www.npmjs.com/package/@shapeshift-labs/frontier-react): React external-store hooks and adapters for Frontier state, cache, and CRDT surfaces.
123
+ - [`@shapeshift-labs/frontier-richtext`](https://www.npmjs.com/package/@shapeshift-labs/frontier-richtext): Rich text Delta normalization/application, marks, embeds, ranges, and cursor/selection transforms for local editor integrations.
124
+ - [`@shapeshift-labs/frontier-realtime`](https://www.npmjs.com/package/@shapeshift-labs/frontier-realtime): Shared realtime command, tick, snapshot, prediction, reconciliation, interpolation, rollback, message, and delta primitives.
125
+ - [`@shapeshift-labs/frontier-realtime-server`](https://www.npmjs.com/package/@shapeshift-labs/frontier-realtime-server): Authoritative realtime room, tick, command validation, rate-limit, session, and snapshot-history runtime.
126
+ - [`@shapeshift-labs/frontier-realtime-websocket`](https://www.npmjs.com/package/@shapeshift-labs/frontier-realtime-websocket): WebSocket client, wire, and Node room-server transport for Frontier realtime.
127
+ - [`@shapeshift-labs/frontier-game`](https://www.npmjs.com/package/@shapeshift-labs/frontier-game): Game-facing entity, component, player, room, ownership, spatial interest, rollback, physics, and replication helpers above realtime.
128
+
129
+ Package source repositories:
130
+
131
+ - [`siliconjungle/-shapeshift-labs-frontier`](https://github.com/siliconjungle/-shapeshift-labs-frontier)
132
+ - [`siliconjungle/-shapeshift-labs-frontier-query`](https://github.com/siliconjungle/-shapeshift-labs-frontier-query)
133
+ - [`siliconjungle/-shapeshift-labs-frontier-codec`](https://github.com/siliconjungle/-shapeshift-labs-frontier-codec)
134
+ - [`siliconjungle/-shapeshift-labs-frontier-engine`](https://github.com/siliconjungle/-shapeshift-labs-frontier-engine)
135
+ - [`siliconjungle/-shapeshift-labs-frontier-state`](https://github.com/siliconjungle/-shapeshift-labs-frontier-state)
136
+ - [`siliconjungle/-shapeshift-labs-frontier-dataflow`](https://github.com/siliconjungle/-shapeshift-labs-frontier-dataflow)
137
+ - [`siliconjungle/-shapeshift-labs-frontier-state-cache`](https://github.com/siliconjungle/-shapeshift-labs-frontier-state-cache)
138
+ - [`siliconjungle/-shapeshift-labs-frontier-state-cache-idb`](https://github.com/siliconjungle/-shapeshift-labs-frontier-state-cache-idb)
139
+ - [`siliconjungle/-shapeshift-labs-frontier-state-cache-file`](https://github.com/siliconjungle/-shapeshift-labs-frontier-state-cache-file)
140
+ - [`siliconjungle/-shapeshift-labs-frontier-state-cache-sql`](https://github.com/siliconjungle/-shapeshift-labs-frontier-state-cache-sql)
141
+ - [`siliconjungle/-shapeshift-labs-frontier-schema`](https://github.com/siliconjungle/-shapeshift-labs-frontier-schema)
142
+ - [`siliconjungle/-shapeshift-labs-frontier-migrations`](https://github.com/siliconjungle/-shapeshift-labs-frontier-migrations)
143
+ - [`siliconjungle/-shapeshift-labs-frontier-event-log`](https://github.com/siliconjungle/-shapeshift-labs-frontier-event-log)
144
+ - [`siliconjungle/-shapeshift-labs-frontier-inspect`](https://github.com/siliconjungle/-shapeshift-labs-frontier-inspect)
145
+ - [`siliconjungle/-shapeshift-labs-frontier-scheduler`](https://github.com/siliconjungle/-shapeshift-labs-frontier-scheduler)
146
+ - [`siliconjungle/-shapeshift-labs-frontier-logging`](https://github.com/siliconjungle/-shapeshift-labs-frontier-logging)
147
+ - [`siliconjungle/-shapeshift-labs-frontier-mutation`](https://github.com/siliconjungle/-shapeshift-labs-frontier-mutation)
148
+ - [`siliconjungle/-shapeshift-labs-frontier-effects`](https://github.com/siliconjungle/-shapeshift-labs-frontier-effects)
149
+ - [`siliconjungle/-shapeshift-labs-frontier-auth`](https://github.com/siliconjungle/-shapeshift-labs-frontier-auth)
150
+ - [`siliconjungle/-shapeshift-labs-frontier-policy`](https://github.com/siliconjungle/-shapeshift-labs-frontier-policy)
151
+ - [`siliconjungle/-shapeshift-labs-frontier-flags`](https://github.com/siliconjungle/-shapeshift-labs-frontier-flags)
152
+ - [`siliconjungle/-shapeshift-labs-frontier-tools`](https://github.com/siliconjungle/-shapeshift-labs-frontier-tools)
153
+ - [`siliconjungle/-shapeshift-labs-frontier-sandbox`](https://github.com/siliconjungle/-shapeshift-labs-frontier-sandbox)
154
+ - [`siliconjungle/-shapeshift-labs-frontier-sandbox-quickjs`](https://github.com/siliconjungle/-shapeshift-labs-frontier-sandbox-quickjs)
155
+ - [`siliconjungle/-shapeshift-labs-frontier-workflow`](https://github.com/siliconjungle/-shapeshift-labs-frontier-workflow)
156
+ - [`siliconjungle/-shapeshift-labs-frontier-worker`](https://github.com/siliconjungle/-shapeshift-labs-frontier-worker)
157
+ - [`siliconjungle/-shapeshift-labs-frontier-queue`](https://github.com/siliconjungle/-shapeshift-labs-frontier-queue)
158
+ - [`siliconjungle/-shapeshift-labs-frontier-swarm`](https://github.com/siliconjungle/-shapeshift-labs-frontier-swarm)
159
+ - [`siliconjungle/-shapeshift-labs-frontier-swarm-codex`](https://github.com/siliconjungle/-shapeshift-labs-frontier-swarm-codex)
160
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-kernel`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-kernel)
161
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-parser`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-parser)
162
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-checker`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-checker)
163
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-typescript`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-typescript)
164
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-javascript`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-javascript)
165
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-rust`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-rust)
166
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-python`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-python)
167
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-c`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-c)
168
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-compiler`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler)
169
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-cli`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-cli)
170
+ - [`siliconjungle/-shapeshift-labs-frontier-lang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang)
171
+ - [`siliconjungle/-shapeshift-labs-frontier-kv`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv)
172
+ - [`siliconjungle/-shapeshift-labs-frontier-kv-locks`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv-locks)
173
+ - [`siliconjungle/-shapeshift-labs-frontier-kv-rate-limit`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv-rate-limit)
174
+ - [`siliconjungle/-shapeshift-labs-frontier-kv-file`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv-file)
175
+ - [`siliconjungle/-shapeshift-labs-frontier-kv-idb`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv-idb)
176
+ - [`siliconjungle/-shapeshift-labs-frontier-kv-redis`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv-redis)
177
+ - [`siliconjungle/-shapeshift-labs-frontier-kv-server`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv-server)
178
+ - [`siliconjungle/-shapeshift-labs-frontier-assets`](https://github.com/siliconjungle/-shapeshift-labs-frontier-assets)
179
+ - [`siliconjungle/-shapeshift-labs-frontier-blueprint`](https://github.com/siliconjungle/-shapeshift-labs-frontier-blueprint)
180
+ - [`siliconjungle/-shapeshift-labs-frontier-triggers`](https://github.com/siliconjungle/-shapeshift-labs-frontier-triggers)
181
+ - [`siliconjungle/-shapeshift-labs-frontier-virtual`](https://github.com/siliconjungle/-shapeshift-labs-frontier-virtual)
182
+ - [`siliconjungle/-shapeshift-labs-frontier-table`](https://github.com/siliconjungle/-shapeshift-labs-frontier-table)
183
+ - [`siliconjungle/-shapeshift-labs-frontier-scene`](https://github.com/siliconjungle/-shapeshift-labs-frontier-scene)
184
+ - [`siliconjungle/-shapeshift-labs-frontier-pathfinding`](https://github.com/siliconjungle/-shapeshift-labs-frontier-pathfinding)
185
+ - [`siliconjungle/-shapeshift-labs-frontier-lod`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lod)
186
+ - [`siliconjungle/-shapeshift-labs-frontier-route`](https://github.com/siliconjungle/-shapeshift-labs-frontier-route)
187
+ - [`siliconjungle/-shapeshift-labs-frontier-trace`](https://github.com/siliconjungle/-shapeshift-labs-frontier-trace)
188
+ - [`siliconjungle/-shapeshift-labs-frontier-manifest`](https://github.com/siliconjungle/-shapeshift-labs-frontier-manifest)
189
+ - [`siliconjungle/-shapeshift-labs-frontier-view`](https://github.com/siliconjungle/-shapeshift-labs-frontier-view)
190
+ - [`siliconjungle/-shapeshift-labs-frontier-icons`](https://github.com/siliconjungle/-shapeshift-labs-frontier-icons)
191
+ - [`siliconjungle/-shapeshift-labs-frontier-design`](https://github.com/siliconjungle/-shapeshift-labs-frontier-design)
192
+ - [`siliconjungle/-shapeshift-labs-frontier-canvas`](https://github.com/siliconjungle/-shapeshift-labs-frontier-canvas)
193
+ - [`siliconjungle/-shapeshift-labs-frontier-canvas-tools`](https://github.com/siliconjungle/-shapeshift-labs-frontier-canvas-tools)
194
+ - [`siliconjungle/-shapeshift-labs-frontier-dnd`](https://github.com/siliconjungle/-shapeshift-labs-frontier-dnd)
195
+ - [`siliconjungle/-shapeshift-labs-frontier-dom`](https://github.com/siliconjungle/-shapeshift-labs-frontier-dom)
196
+ - [`siliconjungle/-shapeshift-labs-frontier-playwright`](https://github.com/siliconjungle/-shapeshift-labs-frontier-playwright)
197
+ - [`siliconjungle/-shapeshift-labs-frontier-test`](https://github.com/siliconjungle/-shapeshift-labs-frontier-test)
198
+ - [`siliconjungle/-shapeshift-labs-frontier-fixtures`](https://github.com/siliconjungle/-shapeshift-labs-frontier-fixtures)
199
+ - [`siliconjungle/-shapeshift-labs-frontier-component-preview`](https://github.com/siliconjungle/-shapeshift-labs-frontier-component-preview)
200
+ - [`siliconjungle/-shapeshift-labs-frontier-documentation`](https://github.com/siliconjungle/-shapeshift-labs-frontier-documentation)
201
+ - [`siliconjungle/-shapeshift-labs-frontier-ast-walk`](https://github.com/siliconjungle/-shapeshift-labs-frontier-ast-walk)
202
+ - [`siliconjungle/-shapeshift-labs-frontier-history`](https://github.com/siliconjungle/-shapeshift-labs-frontier-history)
203
+ - [`siliconjungle/-shapeshift-labs-frontier-application`](https://github.com/siliconjungle/-shapeshift-labs-frontier-application)
204
+ - [`siliconjungle/-shapeshift-labs-frontier-linter`](https://github.com/siliconjungle/-shapeshift-labs-frontier-linter)
205
+ - [`siliconjungle/-shapeshift-labs-frontier-framework`](https://github.com/siliconjungle/-shapeshift-labs-frontier-framework)
206
+ - [`siliconjungle/-shapeshift-labs-frontier-crdt`](https://github.com/siliconjungle/-shapeshift-labs-frontier-crdt)
207
+ - [`siliconjungle/-shapeshift-labs-frontier-crdt-sync`](https://github.com/siliconjungle/-shapeshift-labs-frontier-crdt-sync)
208
+ - [`siliconjungle/-shapeshift-labs-frontier-crdt-websocket`](https://github.com/siliconjungle/-shapeshift-labs-frontier-crdt-websocket)
209
+ - [`siliconjungle/-shapeshift-labs-frontier-react`](https://github.com/siliconjungle/-shapeshift-labs-frontier-react)
210
+ - [`siliconjungle/-shapeshift-labs-frontier-richtext`](https://github.com/siliconjungle/-shapeshift-labs-frontier-richtext)
211
+ - [`siliconjungle/-shapeshift-labs-frontier-realtime`](https://github.com/siliconjungle/-shapeshift-labs-frontier-realtime)
212
+ - [`siliconjungle/-shapeshift-labs-frontier-realtime-server`](https://github.com/siliconjungle/-shapeshift-labs-frontier-realtime-server)
213
+ - [`siliconjungle/-shapeshift-labs-frontier-realtime-websocket`](https://github.com/siliconjungle/-shapeshift-labs-frontier-realtime-websocket)
214
+ - [`siliconjungle/-shapeshift-labs-frontier-game`](https://github.com/siliconjungle/-shapeshift-labs-frontier-game)
215
+
216
+ ## Benchmarks
217
+
218
+ Run the package-local benchmark with:
219
+
220
+ ```sh
221
+ npm run bench
222
+ ```
223
+
224
+ These are Frontier-only package measurements for @shapeshift-labs/frontier-lang-compiler. They exercise the package's own parser, checker, compiler, projection, CLI, fuzz, or semantic-kernel surface without making competitor comparison claims.
@@ -0,0 +1,115 @@
1
+ import type {
2
+ CapabilityAdapterBinding,
3
+ CapabilityUnsupportedTarget,
4
+ CompileTarget,
5
+ EvidenceRecord,
6
+ FrontierLangDocument,
7
+ FrontierSourceLanguage,
8
+ LanguageImportResult,
9
+ NativeAstLossRecord,
10
+ NativeAstNode,
11
+ NativeAstRecord,
12
+ NativeSourceNode,
13
+ SemanticNode,
14
+ SemanticPatchBundle
15
+ } from '@shapeshift-labs/frontier-lang-kernel';
16
+ import type { Diagnostic } from '@shapeshift-labs/frontier-lang-checker';
17
+ import type { EmitTypeScriptOptions, TypeScriptAstModule } from '@shapeshift-labs/frontier-lang-typescript';
18
+ import type { EmitJavaScriptOptions, JavaScriptAstModule } from '@shapeshift-labs/frontier-lang-javascript';
19
+ import type { EmitRustOptions, RustAstModule } from '@shapeshift-labs/frontier-lang-rust';
20
+ import type { EmitPythonOptions, PythonAstModule } from '@shapeshift-labs/frontier-lang-python';
21
+ import type { CAstHeader, EmitCHeaderOptions } from '@shapeshift-labs/frontier-lang-c';
22
+
23
+ export type FrontierCompileTarget = 'typescript' | 'javascript' | 'rust' | 'python' | 'c';
24
+
25
+ export type FrontierCompileEmitOptions =
26
+ | EmitTypeScriptOptions
27
+ | EmitJavaScriptOptions
28
+ | EmitRustOptions
29
+ | EmitPythonOptions
30
+ | EmitCHeaderOptions;
31
+
32
+ export type FrontierTargetAst =
33
+ | TypeScriptAstModule
34
+ | JavaScriptAstModule
35
+ | RustAstModule
36
+ | PythonAstModule
37
+ | CAstHeader;
38
+
39
+ export interface FrontierCompileOptions {
40
+ readonly target?: FrontierCompileTarget | 'ts' | 'js' | 'rs' | 'py' | 'h';
41
+ readonly fileName?: string;
42
+ readonly parse?: Record<string, unknown>;
43
+ readonly check?: Record<string, unknown>;
44
+ readonly emit?: FrontierCompileEmitOptions;
45
+ readonly emitOnError?: boolean;
46
+ }
47
+
48
+ export interface FrontierCompileResult {
49
+ readonly ok: boolean;
50
+ readonly target: FrontierCompileTarget;
51
+ readonly hash: string;
52
+ readonly document: FrontierLangDocument;
53
+ readonly diagnostics: readonly Diagnostic[];
54
+ readonly ast?: FrontierTargetAst;
55
+ readonly output: string;
56
+ }
57
+
58
+ export interface CapabilityResolution {
59
+ readonly nodeId: string;
60
+ readonly name: string;
61
+ readonly capability: string;
62
+ readonly target: CompileTarget;
63
+ readonly status: 'bound' | 'unsupported' | 'unbound';
64
+ readonly adapters: readonly CapabilityAdapterBinding[];
65
+ readonly unsupported?: CapabilityUnsupportedTarget;
66
+ readonly reason?: string;
67
+ }
68
+
69
+ export interface ImportNativeSourceOptions {
70
+ readonly id?: string;
71
+ readonly language?: FrontierSourceLanguage;
72
+ readonly parser?: string;
73
+ readonly parserVersion?: string;
74
+ readonly sourcePath?: string;
75
+ readonly sourceHash?: string;
76
+ readonly symbol?: string;
77
+ readonly name?: string;
78
+ readonly nativeAst?: NativeAstRecord;
79
+ readonly nativeAstId?: string;
80
+ readonly nativeAstMetadata?: Record<string, unknown>;
81
+ readonly nativeSourceId?: string;
82
+ readonly nativeSourceMetadata?: Record<string, unknown>;
83
+ readonly documentId?: string;
84
+ readonly documentName?: string;
85
+ readonly documentMetadata?: Record<string, unknown>;
86
+ readonly rootId?: string;
87
+ readonly rootIds?: readonly string[];
88
+ readonly nodes?: Readonly<Record<string, NativeAstNode>>;
89
+ readonly semanticNodes?: readonly SemanticNode[];
90
+ readonly frontierNodeIds?: readonly string[];
91
+ readonly mappings?: readonly unknown[];
92
+ readonly semanticStatus?: 'native-only' | 'mapped' | 'partial' | string;
93
+ readonly losses?: readonly NativeAstLossRecord[];
94
+ readonly evidence?: readonly EvidenceRecord[];
95
+ readonly evidenceId?: string;
96
+ readonly patch?: SemanticPatchBundle;
97
+ readonly patchId?: string;
98
+ readonly author?: string;
99
+ readonly target?: CompileTarget;
100
+ readonly metadata?: Record<string, unknown>;
101
+ }
102
+
103
+ export type NativeSourceImportResult = LanguageImportResult & {
104
+ readonly nativeSource: NativeSourceNode;
105
+ };
106
+
107
+ export declare const FrontierCompileTargets: readonly FrontierCompileTarget[];
108
+ export declare function normalizeCompileTarget(target?: string): FrontierCompileTarget;
109
+ export declare function compileFrontierSource(source: string, options?: FrontierCompileOptions): FrontierCompileResult;
110
+ export declare function compileFrontierDocument(document: FrontierLangDocument, options?: FrontierCompileOptions): FrontierCompileResult;
111
+ export declare function projectFrontierAst(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: FrontierCompileEmitOptions): FrontierTargetAst;
112
+ export declare function renderTargetAst(ast: FrontierTargetAst, target?: FrontierCompileOptions['target']): string;
113
+ export declare function resolveCapabilityAdapters(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: { readonly platform?: string }): readonly CapabilityResolution[];
114
+ export declare function importNativeSource(input: ImportNativeSourceOptions): NativeSourceImportResult;
115
+ export declare function emitForTarget(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: FrontierCompileEmitOptions): string;
package/dist/index.js ADDED
@@ -0,0 +1,248 @@
1
+ import {
2
+ createDocument,
3
+ createImportResult,
4
+ createNativeAstRecord,
5
+ createPatch,
6
+ hashDocumentBase,
7
+ hashSemanticValue,
8
+ nativeSourceNode
9
+ } from '@shapeshift-labs/frontier-lang-kernel';
10
+ import { parseFrontierFile, parseFrontierSource } from '@shapeshift-labs/frontier-lang-parser';
11
+ import { checkDocument } from '@shapeshift-labs/frontier-lang-checker';
12
+ import { renderTypeScriptAst, toTypeScriptAst } from '@shapeshift-labs/frontier-lang-typescript';
13
+ import { renderJavaScriptAst, toJavaScriptAst } from '@shapeshift-labs/frontier-lang-javascript';
14
+ import { renderRustAst, toRustAst } from '@shapeshift-labs/frontier-lang-rust';
15
+ import { renderPythonAst, toPythonAst } from '@shapeshift-labs/frontier-lang-python';
16
+ import { renderCAst, toCAst } from '@shapeshift-labs/frontier-lang-c';
17
+
18
+ export const FrontierCompileTargets = Object.freeze([
19
+ 'typescript',
20
+ 'javascript',
21
+ 'rust',
22
+ 'python',
23
+ 'c'
24
+ ]);
25
+
26
+ const projectors = Object.freeze({
27
+ typescript: toTypeScriptAst,
28
+ javascript: toJavaScriptAst,
29
+ rust: toRustAst,
30
+ python: toPythonAst,
31
+ c: toCAst
32
+ });
33
+
34
+ const renderers = Object.freeze({
35
+ typescript: renderTypeScriptAst,
36
+ javascript: renderJavaScriptAst,
37
+ rust: renderRustAst,
38
+ python: renderPythonAst,
39
+ c: renderCAst
40
+ });
41
+
42
+ const canonicalTargets = Object.freeze({
43
+ ts: 'typescript',
44
+ js: 'javascript',
45
+ rs: 'rust',
46
+ py: 'python',
47
+ h: 'c'
48
+ });
49
+
50
+ export function normalizeCompileTarget(target) {
51
+ const normalized = String(target ?? 'typescript').toLowerCase();
52
+ const canonical = canonicalTargets[normalized] ?? normalized;
53
+ if (!FrontierCompileTargets.includes(canonical)) {
54
+ throw new Error(`Unknown Frontier compile target: ${target}`);
55
+ }
56
+ return canonical;
57
+ }
58
+
59
+ export function compileFrontierSource(source, options = {}) {
60
+ const document = options.fileName
61
+ ? parseFrontierFile(options.fileName, source)
62
+ : parseFrontierSource(source, options.parse);
63
+ return compileFrontierDocument(document, options);
64
+ }
65
+
66
+ export function compileFrontierDocument(document, options = {}) {
67
+ const target = normalizeCompileTarget(options.target);
68
+ const check = checkDocument(document, options.check ?? {});
69
+ const hash = hashDocumentBase(document);
70
+ if (!check.ok && options.emitOnError !== true) {
71
+ return {
72
+ ok: false,
73
+ target,
74
+ hash,
75
+ document,
76
+ diagnostics: check.diagnostics,
77
+ ast: undefined,
78
+ output: ''
79
+ };
80
+ }
81
+ const ast = projectFrontierAst(document, target, options.emit ?? {});
82
+ return {
83
+ ok: check.ok,
84
+ target,
85
+ hash,
86
+ document,
87
+ diagnostics: check.diagnostics,
88
+ ast,
89
+ output: renderTargetAst(ast, target)
90
+ };
91
+ }
92
+
93
+ export function projectFrontierAst(document, target = 'typescript', options = {}) {
94
+ const normalized = normalizeCompileTarget(target);
95
+ const projector = projectors[normalized];
96
+ return projector(document, options);
97
+ }
98
+
99
+ export function renderTargetAst(ast, target = 'typescript') {
100
+ const normalized = normalizeCompileTarget(target);
101
+ const renderer = renderers[normalized];
102
+ return renderer(ast);
103
+ }
104
+
105
+ export function resolveCapabilityAdapters(document, target = 'typescript', options = {}) {
106
+ const normalized = normalizeCompileTarget(target);
107
+ const platform = options.platform;
108
+ return Object.values(document.nodes)
109
+ .filter((node) => node.kind === 'capability')
110
+ .map((node) => {
111
+ const adapters = (node.adapters ?? []).filter((adapter) => {
112
+ if (adapter.target?.language !== normalized) return false;
113
+ if (platform && adapter.target?.platform && adapter.target.platform !== platform) return false;
114
+ return true;
115
+ });
116
+ const unsupported = (node.unsupportedTargets ?? []).find((item) => {
117
+ if (item.target?.language !== normalized) return false;
118
+ if (platform && item.target?.platform && item.target.platform !== platform) return false;
119
+ return true;
120
+ });
121
+ return {
122
+ nodeId: node.id,
123
+ name: node.name,
124
+ capability: node.capability,
125
+ target: { language: normalized, platform },
126
+ status: adapters.length ? 'bound' : unsupported ? 'unsupported' : 'unbound',
127
+ adapters,
128
+ unsupported,
129
+ reason: unsupported?.reason
130
+ };
131
+ });
132
+ }
133
+
134
+ export function importNativeSource(input) {
135
+ const language = input.language ?? input.nativeAst?.language;
136
+ if (!language) throw new Error('importNativeSource requires a language or nativeAst.language');
137
+ const sourcePath = input.sourcePath ?? input.nativeAst?.sourcePath;
138
+ const sourceHash = input.sourceHash ?? input.nativeAst?.sourceHash ?? hashSemanticValue(input.nativeAst?.nodes ?? input.nativeAst ?? {});
139
+ const importIdPart = idFragment(input.id ?? input.nativeSourceId ?? sourcePath ?? language);
140
+ const nativeAst = input.nativeAst ?? createNativeAstRecord({
141
+ id: input.nativeAstId ?? `native_ast_${importIdPart}`,
142
+ language,
143
+ parser: input.parser,
144
+ parserVersion: input.parserVersion,
145
+ sourcePath,
146
+ sourceHash,
147
+ rootId: input.rootId ?? 'native_root',
148
+ nodes: input.nodes ?? {
149
+ native_root: {
150
+ id: 'native_root',
151
+ kind: 'Unknown',
152
+ languageKind: `${language}.unknown`,
153
+ value: null,
154
+ metadata: { reason: 'no-native-ast-nodes-provided' }
155
+ }
156
+ },
157
+ losses: input.losses,
158
+ metadata: input.nativeAstMetadata
159
+ });
160
+ const frontierNodeIds = input.frontierNodeIds ?? input.semanticNodes?.map((node) => node.id) ?? [];
161
+ const losses = input.losses ?? nativeAst.losses ?? [];
162
+ const nativeSource = nativeSourceNode({
163
+ id: input.nativeSourceId ?? `native_source_${importIdPart}`,
164
+ name: input.name ?? sourcePath?.split(/[\\/]/).filter(Boolean).at(-1) ?? `${language}NativeSource`,
165
+ language,
166
+ parser: input.parser ?? nativeAst.parser,
167
+ parserVersion: input.parserVersion ?? nativeAst.parserVersion,
168
+ sourcePath,
169
+ sourceHash,
170
+ symbol: input.symbol,
171
+ ast: nativeAst,
172
+ frontierNodeIds,
173
+ losses,
174
+ target: input.target,
175
+ metadata: {
176
+ semanticStatus: input.semanticStatus ?? (input.semanticNodes?.length ? 'mapped' : 'native-only'),
177
+ mappings: input.mappings ?? [],
178
+ ...input.nativeSourceMetadata
179
+ }
180
+ });
181
+ const semanticNodes = input.semanticNodes ?? [];
182
+ const document = createDocument({
183
+ id: input.documentId ?? `document_${importIdPart}`,
184
+ name: input.documentName ?? nativeSource.name,
185
+ nodes: [...semanticNodes, nativeSource],
186
+ rootIds: input.rootIds,
187
+ metadata: {
188
+ sourceLanguage: language,
189
+ semanticStatus: input.semanticStatus ?? (semanticNodes.length ? 'mapped' : 'native-only'),
190
+ ...input.documentMetadata
191
+ }
192
+ });
193
+ const evidence = input.evidence ?? [{
194
+ id: input.evidenceId ?? `evidence_${importIdPart}_import`,
195
+ kind: 'import',
196
+ status: losses.some((loss) => loss.severity === 'error') ? 'failed' : 'passed',
197
+ path: sourcePath,
198
+ summary: `Imported ${language} native source with ${Object.keys(nativeAst.nodes).length} native AST node(s), ${semanticNodes.length} semantic node(s), and ${losses.length} loss record(s).`,
199
+ metadata: {
200
+ parser: nativeAst.parser,
201
+ sourcePath,
202
+ semanticStatus: input.semanticStatus ?? (semanticNodes.length ? 'mapped' : 'native-only')
203
+ }
204
+ }];
205
+ const patch = input.patch ?? createPatch({
206
+ id: input.patchId ?? `patch_${importIdPart}_import`,
207
+ author: input.author ?? '@shapeshift-labs/frontier-lang-compiler/importNativeSource',
208
+ risk: losses.some((loss) => loss.severity === 'error') ? 'high' : losses.length ? 'medium' : 'low',
209
+ operations: [...semanticNodes, nativeSource].map((node) => ({
210
+ op: 'upsertNode',
211
+ node,
212
+ touches: [{ id: node.id, access: node.kind === 'nativeSource' ? 'evidence' : 'schema' }]
213
+ })),
214
+ evidence,
215
+ metadata: { sourceLanguage: language, sourcePath }
216
+ });
217
+ return {
218
+ ...createImportResult({
219
+ id: input.id ?? `import_${importIdPart}`,
220
+ language,
221
+ sourcePath,
222
+ document,
223
+ patch,
224
+ nativeAst,
225
+ losses,
226
+ evidence,
227
+ metadata: {
228
+ nativeSourceId: nativeSource.id,
229
+ semanticStatus: input.semanticStatus ?? (semanticNodes.length ? 'mapped' : 'native-only'),
230
+ mappings: input.mappings ?? [],
231
+ ...input.metadata
232
+ }
233
+ }),
234
+ nativeSource
235
+ };
236
+ }
237
+
238
+ export function emitForTarget(document, target = 'typescript', options = {}) {
239
+ return renderTargetAst(projectFrontierAst(document, target, options), target);
240
+ }
241
+
242
+ function idFragment(value) {
243
+ return String(value ?? 'native')
244
+ .toLowerCase()
245
+ .replace(/[^a-z0-9]+/g, '_')
246
+ .replace(/^_+|_+$/g, '')
247
+ .slice(0, 80) || 'native';
248
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@shapeshift-labs/frontier-lang-compiler",
3
+ "version": "0.2.0",
4
+ "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "examples",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "scripts": {
22
+ "build": "node scripts/build.mjs",
23
+ "test": "npm run build && node test/smoke.mjs",
24
+ "fuzz": "npm run build && node fuzz/smoke.mjs",
25
+ "bench": "npm run build && node bench/smoke.mjs",
26
+ "prepare": "npm run build",
27
+ "prepack": "npm test",
28
+ "pack:dry": "npm pack --dry-run",
29
+ "readme:packages": "node benchmarks/package-readme-sections.mjs",
30
+ "readme:packages:check": "node benchmarks/package-readme-sections.mjs --check"
31
+ },
32
+ "keywords": [
33
+ "frontier",
34
+ "semantic-merge",
35
+ "compiler",
36
+ "typescript",
37
+ "javascript",
38
+ "rust",
39
+ "python",
40
+ "c"
41
+ ],
42
+ "author": "ShapeShift Labs",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler.git"
47
+ },
48
+ "bugs": {
49
+ "url": "https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler/issues"
50
+ },
51
+ "homepage": "https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler#readme",
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "dependencies": {
56
+ "@shapeshift-labs/frontier-lang-kernel": "0.3.0",
57
+ "@shapeshift-labs/frontier-lang-parser": "0.3.0",
58
+ "@shapeshift-labs/frontier-lang-checker": "0.3.0",
59
+ "@shapeshift-labs/frontier-lang-typescript": "0.3.0",
60
+ "@shapeshift-labs/frontier-lang-javascript": "0.2.0",
61
+ "@shapeshift-labs/frontier-lang-rust": "0.2.0",
62
+ "@shapeshift-labs/frontier-lang-python": "0.2.0",
63
+ "@shapeshift-labs/frontier-lang-c": "0.2.0"
64
+ }
65
+ }