@json-layout/core 1.15.9 → 2.0.1

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.1",
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
@@ -54,7 +54,10 @@ export function makeSkeletonNode (
54
54
  [refFragment, schemaId, refPointer] = getJSONRef(sourceSchemaId, schema.$ref)
55
55
  refFragment.__pointer = refPointer
56
56
  schema = { ...rawSchema, ...refFragment }
57
- if (errorMessage && refFragment.errorMessage) throw new Error('errorMessage cannot be defined both on ref source and target')
57
+ if (errorMessage && refFragment.errorMessage) {
58
+ console.warn('errorMessage should not be defined both on ref source and target', pointer, errorMessage, refPointer, refFragment.errorMessage)
59
+ // throw new Error('errorMessage cannot be defined both on ref source and target')
60
+ }
58
61
  errorMessage = refFragment.errorMessage = refFragment.errorMessage ?? errorMessage ?? {}
59
62
  delete schema.$ref
60
63
  }
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAlBW,GAAG,kBACH,MAAM,WACN,OAAO,YAAY,EAAE,cAAc,cACnC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,iBACxD,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,iBACjD,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,oBACjD,MAAM,EAAE,oBACR,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,MAAM,CAAC,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO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