@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/CHANGELOG.md +331 -1
- package/dist/{chunk-GWYYJAZY.js → chunk-QUA3XGWW.js} +22 -3
- package/dist/chunk-QUA3XGWW.js.map +1 -0
- package/dist/http.cjs +21 -2
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.js +1 -1
- package/dist/index.cjs +21 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{service-2lEnO5hA.d.cts → service-TXPE1KWF.d.cts} +10 -0
- package/dist/{service-2lEnO5hA.d.ts → service-TXPE1KWF.d.ts} +10 -0
- package/package.json +6 -6
- package/dist/chunk-GWYYJAZY.js.map +0 -1
package/dist/http.d.cts
CHANGED
package/dist/http.d.ts
CHANGED
package/dist/http.js
CHANGED
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 (
|
|
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: [
|