@json-layout/core 1.15.9 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-layout/core",
3
- "version": "1.15.9",
3
+ "version": "2.0.0",
4
4
  "description": "Compilation and state management utilities for JSON Layout.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,9 +12,9 @@ const Ajv = /** @type {typeof ajvModule.default} */ (ajvModule)
12
12
 
13
13
  /**
14
14
  * @param {import('./index.js').CompiledLayout} compiledLayout
15
- * @returns {string}
15
+ * @returns {Promise<string>}
16
16
  */
17
- export function serialize (compiledLayout) {
17
+ export async function serialize (compiledLayout) {
18
18
  ok(compiledLayout.schema)
19
19
  ok(compiledLayout.options)
20
20
 
@@ -64,7 +64,15 @@ export function serialize (compiledLayout) {
64
64
  }
65
65
 
66
66
  // import only the current locale from ajv-i18n
67
- code = `import localizeErrors from "ajv-i18n/localize/${compiledLayout.locale}/index.js";
67
+ let ajvI18nPath = `ajv-i18n/localize/${compiledLayout.locale}/index.js`
68
+ try {
69
+ await import(ajvI18nPath)
70
+ } catch (er) {
71
+ console.warn(`failed to load ${ajvI18nPath}, fallback to en`)
72
+ ajvI18nPath = 'ajv-i18n/localize/en/index.js'
73
+ }
74
+
75
+ code = `import localizeErrors from "${ajvI18nPath}";
68
76
  export const exportLocalizeErrors = localizeErrors;\n` + code
69
77
 
70
78
  i = 0
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @param {import('./index.js').CompiledLayout} compiledLayout
3
- * @returns {string}
3
+ * @returns {Promise<string>}
4
4
  */
5
- export function serialize(compiledLayout: import("./index.js").CompiledLayout): string;
5
+ export function serialize(compiledLayout: import("./index.js").CompiledLayout): Promise<string>;
6
6
  //# sourceMappingURL=serialize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,CA6FlB"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,OAAO,CAAC,MAAM,CAAC,CAqG3B"}