@lokascript/compilation-service 4.1.0 → 4.3.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 +246 -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.cjs
CHANGED
|
@@ -353,13 +353,14 @@ function liftNodeDiagnostics(node, diagnostics) {
|
|
|
353
353
|
if (!Array.isArray(nodeDiags)) return;
|
|
354
354
|
for (const d of nodeDiags) {
|
|
355
355
|
if (d.severity !== "warning" && d.severity !== "error") continue;
|
|
356
|
+
const unread = d.code === "unconsumed-input" || d.code === "verbatim-clause";
|
|
356
357
|
const diag = {
|
|
357
358
|
severity: d.severity,
|
|
358
359
|
// Parser codes are kebab-case; this surface uses UPPER_SNAKE (PARSE_ERROR &c).
|
|
359
|
-
code: (d.code ?? "PARSE_DIAGNOSTIC").replace(/-/g, "_").toUpperCase(),
|
|
360
|
+
code: unread ? "UNCONSUMED_INPUT" : (d.code ?? "PARSE_DIAGNOSTIC").replace(/-/g, "_").toUpperCase(),
|
|
360
361
|
message: d.message ?? "parser diagnostic"
|
|
361
362
|
};
|
|
362
|
-
if (
|
|
363
|
+
if (unread) {
|
|
363
364
|
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.";
|
|
364
365
|
}
|
|
365
366
|
diagnostics.push(diag);
|
|
@@ -2695,6 +2696,9 @@ function renderSvelteElement(el, analysis) {
|
|
|
2695
2696
|
}
|
|
2696
2697
|
|
|
2697
2698
|
// src/service.ts
|
|
2699
|
+
function isLossyTranslation(error) {
|
|
2700
|
+
return error instanceof Error && error.name === "LossyTranslationError" && typeof error.partial === "string";
|
|
2701
|
+
}
|
|
2698
2702
|
var CompilationService = class _CompilationService {
|
|
2699
2703
|
constructor(options = {}) {
|
|
2700
2704
|
this.translateFn = null;
|
|
@@ -2855,6 +2859,21 @@ var CompilationService = class _CompilationService {
|
|
|
2855
2859
|
diagnostics: this.translationCollisions(request)
|
|
2856
2860
|
};
|
|
2857
2861
|
} catch (error) {
|
|
2862
|
+
if (isLossyTranslation(error)) {
|
|
2863
|
+
return {
|
|
2864
|
+
ok: false,
|
|
2865
|
+
partial: error.partial,
|
|
2866
|
+
loss: { kind: error.loss.kind, lost: [...error.loss.lost] },
|
|
2867
|
+
diagnostics: [
|
|
2868
|
+
{
|
|
2869
|
+
severity: "error",
|
|
2870
|
+
code: "LOSSY_TRANSLATION",
|
|
2871
|
+
message: error.message,
|
|
2872
|
+
suggestion: "The translation would drop the part listed in `loss.lost`. Rewrite that part of the source, or translate the rest without it."
|
|
2873
|
+
}
|
|
2874
|
+
]
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2858
2877
|
return {
|
|
2859
2878
|
ok: false,
|
|
2860
2879
|
diagnostics: [
|