@json-layout/core 1.10.3 → 1.10.5
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.10.
|
|
3
|
+
"version": "1.10.5",
|
|
4
4
|
"description": "Compilation and state management utilities for JSON Layout.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
"default": "./src/index.js"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
+
"./compile": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./types/compile/index.d.ts",
|
|
16
|
+
"default": "./src/compile/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"./state": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./types/state/index.d.ts",
|
|
22
|
+
"default": "./src/state/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
13
25
|
"./src/compile/serialize": {
|
|
14
26
|
"import": {
|
|
15
27
|
"types": "./types/compile/serialize.d.ts",
|
|
@@ -22,6 +34,12 @@
|
|
|
22
34
|
"default": "./src/utils/build.js"
|
|
23
35
|
}
|
|
24
36
|
},
|
|
37
|
+
"./utils/clone": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./types/utils/clone.d.ts",
|
|
40
|
+
"default": "./src/utils/clone.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
25
43
|
"./utils/doc-options": {
|
|
26
44
|
"import": {
|
|
27
45
|
"types": "./types/utils/doc-options.d.ts",
|
|
@@ -58,7 +76,7 @@
|
|
|
58
76
|
},
|
|
59
77
|
"homepage": "https://github.com/json-layout/json-layout#readme",
|
|
60
78
|
"peerDependencies": {
|
|
61
|
-
"@json-layout/vocabulary": "^2.3.
|
|
79
|
+
"@json-layout/vocabulary": "^2.3.1"
|
|
62
80
|
},
|
|
63
81
|
"dependencies": {
|
|
64
82
|
"ajv": "^8.17.1",
|
package/src/compile/options.js
CHANGED
|
@@ -85,7 +85,7 @@ export const produceCompileOptions = produce((draft, newOptions) => {
|
|
|
85
85
|
// @ts-ignore
|
|
86
86
|
if (key in newOptions) {
|
|
87
87
|
// components is problematic because it is an object with nested objects
|
|
88
|
-
// simply compare
|
|
88
|
+
// simply compare their keys instead of the whole object
|
|
89
89
|
if (key === 'components' && shallowEqualArray(Object.keys(draft.components ?? []), Object.keys(newOptions.components ?? []))) {
|
|
90
90
|
continue
|
|
91
91
|
}
|
package/src/compile/serialize.js
CHANGED
|
@@ -2,20 +2,7 @@
|
|
|
2
2
|
import { ok } from 'assert/strict'
|
|
3
3
|
import standaloneCode from 'ajv/dist/standalone/index.js'
|
|
4
4
|
import { parseModule, generateCode, builders } from 'magicast'
|
|
5
|
-
import { clone
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @generator
|
|
9
|
-
* @param {import('./index.js').CompiledLayout} compiledLayout
|
|
10
|
-
* @yields {import('./types.js').BaseCompObject}
|
|
11
|
-
* @returns {Generator<import('@json-layout/vocabulary').BaseCompObject>}
|
|
12
|
-
*/
|
|
13
|
-
function * iterCompObject (compiledLayout) {
|
|
14
|
-
for (const normalizedLayout of Object.values(compiledLayout.normalizedLayouts)) {
|
|
15
|
-
if (isSwitchStruct(normalizedLayout)) yield * normalizedLayout.switch
|
|
16
|
-
else yield normalizedLayout
|
|
17
|
-
}
|
|
18
|
-
}
|
|
5
|
+
import { clone } from '../utils/clone.js'
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* @param {import('./index.js').CompiledLayout} compiledLayout
|
|
@@ -66,16 +53,6 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
|
|
|
66
53
|
expressionsNodes.push(builders.raw(id))
|
|
67
54
|
}
|
|
68
55
|
|
|
69
|
-
/** @type {Record<string, Omit<import('@json-layout/vocabulary').ComponentInfo, 'schema'>>} */
|
|
70
|
-
const components = {}
|
|
71
|
-
for (const compObject of iterCompObject(compiledLayout)) {
|
|
72
|
-
if (!components[compObject.comp]) {
|
|
73
|
-
const component = { ...compiledLayout.options.components[compObject.comp] }
|
|
74
|
-
delete component.schema
|
|
75
|
-
components[compObject.comp] = component
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
56
|
const ast = parseModule(code)
|
|
80
57
|
ast.exports.compiledLayout = {
|
|
81
58
|
mainTree: compiledLayout.mainTree,
|
|
@@ -87,7 +64,7 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
|
|
|
87
64
|
expressions: expressionsNodes,
|
|
88
65
|
locale: compiledLayout.locale,
|
|
89
66
|
messages: compiledLayout.messages,
|
|
90
|
-
components,
|
|
67
|
+
components: compiledLayout.options.components,
|
|
91
68
|
localizeErrors: ast.exports.exportLocalizeErrors
|
|
92
69
|
}
|
|
93
70
|
delete ast.exports.exportLocalizeErrors
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clone } from '@json-layout/vocabulary'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,CAyElB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/utils/clone.js"],"names":[],"mappings":""}
|