@lokascript/compilation-service 4.0.1 → 4.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/dist/http.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { C as CompilationService } from './service-2lEnO5hA.cjs';
2
+ import { C as CompilationService } from './service-TXPE1KWF.cjs';
3
3
  import '@lokascript/semantic/fidelity';
4
4
  import '@lokascript/framework/ir';
5
5
 
package/dist/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { C as CompilationService } from './service-2lEnO5hA.js';
2
+ import { C as CompilationService } from './service-TXPE1KWF.js';
3
3
  import '@lokascript/semantic/fidelity';
4
4
  import '@lokascript/framework/ir';
5
5
 
package/dist/http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CompilationService
3
- } from "./chunk-GWYYJAZY.js";
3
+ } from "./chunk-QUA3XGWW.js";
4
4
 
5
5
  // src/http.ts
6
6
  import { Hono } from "hono";
package/dist/index.cjs CHANGED
@@ -361,13 +361,14 @@ function liftNodeDiagnostics(node, diagnostics) {
361
361
  if (!Array.isArray(nodeDiags)) return;
362
362
  for (const d of nodeDiags) {
363
363
  if (d.severity !== "warning" && d.severity !== "error") continue;
364
+ const unread = d.code === "unconsumed-input" || d.code === "verbatim-clause";
364
365
  const diag = {
365
366
  severity: d.severity,
366
367
  // Parser codes are kebab-case; this surface uses UPPER_SNAKE (PARSE_ERROR &c).
367
- code: (d.code ?? "PARSE_DIAGNOSTIC").replace(/-/g, "_").toUpperCase(),
368
+ code: unread ? "UNCONSUMED_INPUT" : (d.code ?? "PARSE_DIAGNOSTIC").replace(/-/g, "_").toUpperCase(),
368
369
  message: d.message ?? "parser diagnostic"
369
370
  };
370
- if (d.code === "unconsumed-input") {
371
+ if (unread) {
371
372
  diag.suggestion = "Dropped tokens were parsed but bound to no role \u2014 usually a missing role marker (e.g. 'to'/'on'/'from' before the target), so the role fell back to a default like `me`. Compare the returned roles against your intent.";
372
373
  }
373
374
  diagnostics.push(diag);
@@ -2703,6 +2704,9 @@ function renderSvelteElement(el, analysis) {
2703
2704
  }
2704
2705
 
2705
2706
  // src/service.ts
2707
+ function isLossyTranslation(error) {
2708
+ return error instanceof Error && error.name === "LossyTranslationError" && typeof error.partial === "string";
2709
+ }
2706
2710
  var CompilationService = class _CompilationService {
2707
2711
  constructor(options = {}) {
2708
2712
  this.translateFn = null;
@@ -2863,6 +2867,21 @@ var CompilationService = class _CompilationService {
2863
2867
  diagnostics: this.translationCollisions(request)
2864
2868
  };
2865
2869
  } catch (error) {
2870
+ if (isLossyTranslation(error)) {
2871
+ return {
2872
+ ok: false,
2873
+ partial: error.partial,
2874
+ loss: { kind: error.loss.kind, lost: [...error.loss.lost] },
2875
+ diagnostics: [
2876
+ {
2877
+ severity: "error",
2878
+ code: "LOSSY_TRANSLATION",
2879
+ message: error.message,
2880
+ suggestion: "The translation would drop the part listed in `loss.lost`. Rewrite that part of the source, or translate the rest without it."
2881
+ }
2882
+ ]
2883
+ };
2884
+ }
2866
2885
  return {
2867
2886
  ok: false,
2868
2887
  diagnostics: [