@lokascript/framework 2.10.0 → 2.11.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/README.md +0 -2
- package/dist/api/create-dsl.d.ts +4 -2
- package/dist/api/create-dsl.d.ts.map +1 -1
- package/dist/api/index.js +18 -6
- package/dist/api/index.js.map +1 -1
- package/dist/index.cjs +18 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/__tests__/api-surface.test.ts +35 -0
- package/src/aot/registry-bridge.test.ts +5 -5
- package/src/api/create-dsl.test.ts +87 -5
- package/src/api/create-dsl.ts +42 -16
- package/src/api/domain-registry.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -2893,14 +2893,26 @@ var MultilingualDSLImpl = class {
|
|
|
2893
2893
|
}
|
|
2894
2894
|
translate(input, fromLanguage, toLanguage) {
|
|
2895
2895
|
if (isExplicitSyntax(input)) return input;
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2896
|
+
let node;
|
|
2897
|
+
try {
|
|
2898
|
+
node = this.parseWithConfidence(input, fromLanguage).node;
|
|
2899
|
+
} catch (parseError) {
|
|
2900
|
+
if (this.hasGrammarProfile(fromLanguage) && this.hasGrammarProfile(toLanguage)) {
|
|
2901
|
+
return this.transformer.transform(input, fromLanguage, toLanguage);
|
|
2901
2902
|
}
|
|
2903
|
+
throw parseError;
|
|
2904
|
+
}
|
|
2905
|
+
const rendered = this.registry.getSupportedLanguages().includes(toLanguage) ? this.render(node, toLanguage) : null;
|
|
2906
|
+
if (rendered != null) return rendered;
|
|
2907
|
+
if (this.hasGrammarProfile(fromLanguage) && this.hasGrammarProfile(toLanguage)) {
|
|
2908
|
+
return this.transformer.transform(input, fromLanguage, toLanguage);
|
|
2902
2909
|
}
|
|
2903
|
-
|
|
2910
|
+
throw new Error(
|
|
2911
|
+
`translate() could not render action "${node.action}" in language "${toLanguage}": no custom renderer, domain renderer, or schema pattern covers it, and no grammar profile is configured for the transformer fallback. Either add "${toLanguage}" to the DSL's languages/renderer, or set 'grammarProfile' on its LanguageConfig in createMultilingualDSL() (parse/validate/compile do not need it).`
|
|
2912
|
+
);
|
|
2913
|
+
}
|
|
2914
|
+
hasGrammarProfile(language) {
|
|
2915
|
+
return this.profileProvider.getProfile(language) != null;
|
|
2904
2916
|
}
|
|
2905
2917
|
compile(input, language) {
|
|
2906
2918
|
if (!this.codeGenerator) {
|