@json-layout/core 0.21.1 → 0.23.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 +1 -1
- package/src/compile/index.js +30 -12
- package/src/compile/serialize.js +2 -1
- package/src/compile/skeleton-node.js +78 -23
- package/src/compile/skeleton-tree.js +22 -2
- package/src/compile/types.ts +3 -2
- package/src/compile/utils/resolve-refs.js +99 -38
- package/src/state/index.js +13 -7
- package/src/state/state-node.js +16 -10
- package/src/state/types.ts +2 -2
- package/src/state/utils/immutable.js +3 -2
- package/types/compile/index.d.ts +1 -1
- package/types/compile/index.d.ts.map +1 -1
- package/types/compile/serialize.d.ts.map +1 -1
- package/types/compile/skeleton-node.d.ts +6 -3
- package/types/compile/skeleton-node.d.ts.map +1 -1
- package/types/compile/skeleton-tree.d.ts +4 -1
- package/types/compile/skeleton-tree.d.ts.map +1 -1
- package/types/compile/types.d.ts +3 -2
- package/types/compile/types.d.ts.map +1 -1
- package/types/compile/utils/resolve-refs.d.ts +10 -2
- package/types/compile/utils/resolve-refs.d.ts.map +1 -1
- package/types/state/index.d.ts +1 -1
- package/types/state/index.d.ts.map +1 -1
- package/types/state/state-node.d.ts.map +1 -1
- package/types/state/types.d.ts +1 -1
- package/types/state/types.d.ts.map +1 -1
- package/types/state/utils/immutable.d.ts +3 -3
- package/types/state/utils/immutable.d.ts.map +1 -1
package/package.json
CHANGED
package/src/compile/index.js
CHANGED
|
@@ -9,11 +9,12 @@ import MarkdownIt from 'markdown-it'
|
|
|
9
9
|
import { produce } from 'immer'
|
|
10
10
|
import i18n from '../i18n/index.js'
|
|
11
11
|
import { makeSkeletonTree } from './skeleton-tree.js'
|
|
12
|
-
import {
|
|
12
|
+
import { resolveLocaleRefs } from './utils/resolve-refs.js'
|
|
13
13
|
import clone from '../utils/clone.js'
|
|
14
14
|
import { standardComponents } from '@json-layout/vocabulary'
|
|
15
|
+
import { shallowEqualArray } from '../state/utils/immutable.js'
|
|
15
16
|
|
|
16
|
-
export {
|
|
17
|
+
export { resolveLocaleRefs } from './utils/resolve-refs.js'
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* @typedef {import('./types.js').SkeletonTree} SkeletonTree
|
|
@@ -36,9 +37,18 @@ const ajvLocalize = /** @type {typeof ajvLocalizeModule.default} */ (ajvLocalize
|
|
|
36
37
|
export const produceCompileOptions = produce((draft, newOptions) => {
|
|
37
38
|
for (const key of ['ajv', 'ajvOptions', 'code', 'markdown', 'markdownItOptions', 'locale', 'messages', 'optionsKeys', 'components']) {
|
|
38
39
|
// @ts-ignore
|
|
39
|
-
if (key in newOptions)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if (key in newOptions) {
|
|
41
|
+
// components is problematic because it is an object with nested objects
|
|
42
|
+
// simply compare there keys instead of the whole object
|
|
43
|
+
if (key === 'components' && shallowEqualArray(Object.keys(draft.components ?? []), Object.keys(newOptions.components ?? []))) {
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
draft[key] = newOptions[key]
|
|
48
|
+
} else {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
delete draft[key]
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
53
|
})
|
|
44
54
|
|
|
@@ -103,9 +113,8 @@ export function compile (_schema, partialOptions = {}) {
|
|
|
103
113
|
const options = fillOptions(partialOptions)
|
|
104
114
|
|
|
105
115
|
const schema = /** @type {import('ajv').SchemaObject} */(clone(_schema))
|
|
106
|
-
|
|
107
116
|
schema.$id = schema.$id ?? '_jl'
|
|
108
|
-
|
|
117
|
+
const getJSONRef = resolveLocaleRefs(schema, options.ajv, options.locale)
|
|
109
118
|
|
|
110
119
|
/** @type {string[]} */
|
|
111
120
|
const validatePointers = []
|
|
@@ -115,18 +124,26 @@ export function compile (_schema, partialOptions = {}) {
|
|
|
115
124
|
const expressionsDefinitions = []
|
|
116
125
|
/** @type {Record<string, string[]>} */
|
|
117
126
|
const validationErrors = {}
|
|
118
|
-
|
|
119
|
-
const
|
|
127
|
+
/** @type {Record<string, import('./types.js').SkeletonTree>} */
|
|
128
|
+
const skeletonTrees = {}
|
|
129
|
+
|
|
130
|
+
// makeSkeletonTree also mutates the schema (adding some error messages)
|
|
131
|
+
const mainTreePointer = `${schema.$id}#`
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
skeletonTrees[mainTreePointer] = 'recursing'
|
|
134
|
+
skeletonTrees[mainTreePointer] = makeSkeletonTree(
|
|
120
135
|
schema,
|
|
136
|
+
schema.$id,
|
|
121
137
|
options,
|
|
138
|
+
getJSONRef,
|
|
139
|
+
skeletonTrees,
|
|
122
140
|
validatePointers,
|
|
123
141
|
validationErrors,
|
|
124
142
|
normalizedLayouts,
|
|
125
143
|
expressionsDefinitions,
|
|
126
|
-
|
|
144
|
+
mainTreePointer,
|
|
127
145
|
'main'
|
|
128
146
|
)
|
|
129
|
-
|
|
130
147
|
options.ajv.addSchema(schema)
|
|
131
148
|
|
|
132
149
|
const uriResolver = options.ajv.opts.uriResolver
|
|
@@ -168,7 +185,8 @@ export function compile (_schema, partialOptions = {}) {
|
|
|
168
185
|
return {
|
|
169
186
|
options,
|
|
170
187
|
schema,
|
|
171
|
-
|
|
188
|
+
mainTree: mainTreePointer,
|
|
189
|
+
skeletonTrees,
|
|
172
190
|
validates,
|
|
173
191
|
validationErrors,
|
|
174
192
|
normalizedLayouts,
|
package/src/compile/serialize.js
CHANGED
|
@@ -79,7 +79,8 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
|
|
|
79
79
|
|
|
80
80
|
const ast = parseModule(code)
|
|
81
81
|
ast.exports.compiledLayout = {
|
|
82
|
-
|
|
82
|
+
mainTree: compiledLayout.mainTree,
|
|
83
|
+
skeletonTrees: clone(compiledLayout.skeletonTrees),
|
|
83
84
|
normalizedLayouts: clone(compiledLayout.normalizedLayouts),
|
|
84
85
|
validates: {},
|
|
85
86
|
validationErrors: compiledLayout.validationErrors,
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
// import Debug from 'debug'
|
|
2
2
|
import { normalizeLayoutFragment, isSwitchStruct, isGetItemsExpression, isGetItemsFetch, isItemsLayout, getSchemaFragmentType } from '@json-layout/vocabulary'
|
|
3
3
|
import { makeSkeletonTree } from './skeleton-tree.js'
|
|
4
|
+
import { partialResolveRefs } from './utils/resolve-refs.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @param {any}
|
|
7
|
+
* @param {any} rawSchema
|
|
8
|
+
* @param {string} sourceSchemaId
|
|
7
9
|
* @param {import('./index.js').CompileOptions} options
|
|
10
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
11
|
+
* @param {Record<string, import('./types.js').SkeletonTree>} skeletonTrees
|
|
8
12
|
* @param {string[]} validates
|
|
9
13
|
* @param {Record<string, string[]>} validationErrors
|
|
10
14
|
* @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
|
|
11
15
|
* @param {import('@json-layout/vocabulary').Expression[]} expressions
|
|
12
16
|
* @param {string | number} key
|
|
13
|
-
* @param {string}
|
|
17
|
+
* @param {string} currentPointer
|
|
14
18
|
* @param {string | null} parentPointer
|
|
15
19
|
* @param {boolean} required
|
|
16
20
|
* @param {string} [condition]
|
|
@@ -19,24 +23,37 @@ import { makeSkeletonTree } from './skeleton-tree.js'
|
|
|
19
23
|
* @returns {import('./types.js').SkeletonNode}
|
|
20
24
|
*/
|
|
21
25
|
export function makeSkeletonNode (
|
|
22
|
-
|
|
26
|
+
rawSchema,
|
|
27
|
+
sourceSchemaId,
|
|
23
28
|
options,
|
|
29
|
+
getJSONRef,
|
|
30
|
+
skeletonTrees,
|
|
24
31
|
validates,
|
|
25
32
|
validationErrors,
|
|
26
33
|
normalizedLayouts,
|
|
27
34
|
expressions,
|
|
28
35
|
key,
|
|
29
|
-
|
|
36
|
+
currentPointer,
|
|
30
37
|
parentPointer,
|
|
31
38
|
required,
|
|
32
39
|
condition,
|
|
33
40
|
dependent,
|
|
34
41
|
knownType
|
|
35
42
|
) {
|
|
43
|
+
let schemaId = sourceSchemaId
|
|
44
|
+
let schema = rawSchema
|
|
45
|
+
let pointer = currentPointer
|
|
46
|
+
let refFragment
|
|
47
|
+
if (schema.$ref) {
|
|
48
|
+
[refFragment, schemaId, pointer] = getJSONRef(sourceSchemaId, schema.$ref)
|
|
49
|
+
schema = {...rawSchema, ...refFragment}
|
|
50
|
+
delete schema.$ref
|
|
51
|
+
}
|
|
52
|
+
schema = partialResolveRefs(schema, schemaId, getJSONRef)
|
|
36
53
|
const { type, nullable } = knownType ? { type: knownType, nullable: false } : getSchemaFragmentType(schema)
|
|
37
54
|
|
|
38
55
|
// improve on ajv error messages based on ajv-errors (https://ajv.js.org/packages/ajv-errors.html)
|
|
39
|
-
|
|
56
|
+
rawSchema.errorMessage = rawSchema.errorMessage ?? {}
|
|
40
57
|
if (!normalizedLayouts[pointer]) {
|
|
41
58
|
const normalizationResult = normalizeLayoutFragment(
|
|
42
59
|
/** @type {import('@json-layout/vocabulary').SchemaFragment} */(schema),
|
|
@@ -138,7 +155,10 @@ export function makeSkeletonNode (
|
|
|
138
155
|
const dependent = schema.dependentRequired && Object.values(schema.dependentRequired).some(dependentProperties => dependentProperties.includes(propertyKey))
|
|
139
156
|
node.children.push(makeSkeletonNode(
|
|
140
157
|
schema.properties[propertyKey],
|
|
158
|
+
schemaId,
|
|
141
159
|
options,
|
|
160
|
+
getJSONRef,
|
|
161
|
+
skeletonTrees,
|
|
142
162
|
validates,
|
|
143
163
|
validationErrors,
|
|
144
164
|
normalizedLayouts,
|
|
@@ -156,7 +176,10 @@ export function makeSkeletonNode (
|
|
|
156
176
|
const dependentPointer = schema.dependentSchemas?.[propertyKey] ? `${pointer}/dependentSchemas/${propertyKey}` : `${pointer}/dependencies/${propertyKey}`
|
|
157
177
|
node.children.push(makeSkeletonNode(
|
|
158
178
|
dependentSchema,
|
|
179
|
+
schemaId,
|
|
159
180
|
options,
|
|
181
|
+
getJSONRef,
|
|
182
|
+
skeletonTrees,
|
|
160
183
|
validates,
|
|
161
184
|
validationErrors,
|
|
162
185
|
normalizedLayouts,
|
|
@@ -177,7 +200,10 @@ export function makeSkeletonNode (
|
|
|
177
200
|
for (let i = 0; i < schema.allOf.length; i++) {
|
|
178
201
|
const allOfNode = makeSkeletonNode(
|
|
179
202
|
schema.allOf[i],
|
|
203
|
+
schemaId,
|
|
180
204
|
options,
|
|
205
|
+
getJSONRef,
|
|
206
|
+
skeletonTrees,
|
|
181
207
|
validates,
|
|
182
208
|
validationErrors,
|
|
183
209
|
normalizedLayouts,
|
|
@@ -213,23 +239,32 @@ export function makeSkeletonNode (
|
|
|
213
239
|
validationErrors[oneOfPointer.replace('_jl#', '/')] = normalizationResult.errors
|
|
214
240
|
}
|
|
215
241
|
}
|
|
216
|
-
/** @type {
|
|
242
|
+
/** @type {string[]} */
|
|
217
243
|
const childrenTrees = []
|
|
218
244
|
/** @type {string[]} */
|
|
219
245
|
for (let i = 0; i < schema.oneOf.length; i++) {
|
|
220
246
|
if (!schema.oneOf[i].type) schema.oneOf[i].type = type
|
|
221
247
|
const title = schema.oneOf[i].title ?? `option ${i}`
|
|
222
248
|
delete schema.oneOf[i].title
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
249
|
+
const childTreePointer = `${oneOfPointer}/${i}`
|
|
250
|
+
if (!skeletonTrees[childTreePointer]) {
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
skeletonTrees[childTreePointer] = 'recursing'
|
|
253
|
+
skeletonTrees[childTreePointer] = makeSkeletonTree(
|
|
254
|
+
schema.oneOf[i],
|
|
255
|
+
schemaId,
|
|
256
|
+
options,
|
|
257
|
+
getJSONRef,
|
|
258
|
+
skeletonTrees,
|
|
259
|
+
validates,
|
|
260
|
+
validationErrors,
|
|
261
|
+
normalizedLayouts,
|
|
262
|
+
expressions,
|
|
263
|
+
childTreePointer,
|
|
264
|
+
title
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
childrenTrees.push(childTreePointer)
|
|
233
268
|
}
|
|
234
269
|
node.children = node.children ?? []
|
|
235
270
|
node.children.push({
|
|
@@ -237,7 +272,7 @@ export function makeSkeletonNode (
|
|
|
237
272
|
pointer: `${pointer}/oneOf`,
|
|
238
273
|
parentPointer: pointer,
|
|
239
274
|
childrenTrees,
|
|
240
|
-
pure: childrenTrees[0]
|
|
275
|
+
pure: skeletonTrees[childrenTrees[0]]?.root.pure,
|
|
241
276
|
propertyKeys: [],
|
|
242
277
|
roPropertyKeys: []
|
|
243
278
|
})
|
|
@@ -250,7 +285,10 @@ export function makeSkeletonNode (
|
|
|
250
285
|
node.children = node.children ?? []
|
|
251
286
|
node.children.push(makeSkeletonNode(
|
|
252
287
|
schema.then,
|
|
288
|
+
schemaId,
|
|
253
289
|
options,
|
|
290
|
+
getJSONRef,
|
|
291
|
+
skeletonTrees,
|
|
254
292
|
validates,
|
|
255
293
|
validationErrors,
|
|
256
294
|
normalizedLayouts,
|
|
@@ -268,7 +306,10 @@ export function makeSkeletonNode (
|
|
|
268
306
|
node.children = node.children ?? []
|
|
269
307
|
node.children.push(makeSkeletonNode(
|
|
270
308
|
schema.else,
|
|
309
|
+
schemaId,
|
|
271
310
|
options,
|
|
311
|
+
getJSONRef,
|
|
312
|
+
skeletonTrees,
|
|
272
313
|
validates,
|
|
273
314
|
validationErrors,
|
|
274
315
|
normalizedLayouts,
|
|
@@ -300,7 +341,10 @@ export function makeSkeletonNode (
|
|
|
300
341
|
node.children = schema.items.map((/** @type {any} */ itemSchema, /** @type {number} */ i) => {
|
|
301
342
|
return makeSkeletonNode(
|
|
302
343
|
itemSchema,
|
|
344
|
+
schemaId,
|
|
303
345
|
options,
|
|
346
|
+
getJSONRef,
|
|
347
|
+
skeletonTrees,
|
|
304
348
|
validates,
|
|
305
349
|
validationErrors,
|
|
306
350
|
normalizedLayouts,
|
|
@@ -312,23 +356,34 @@ export function makeSkeletonNode (
|
|
|
312
356
|
)
|
|
313
357
|
})
|
|
314
358
|
} else {
|
|
315
|
-
|
|
316
|
-
|
|
359
|
+
const childTreePointer = `${pointer}/items`
|
|
360
|
+
if (!skeletonTrees[childTreePointer]) {
|
|
361
|
+
// @ts-ignore
|
|
362
|
+
skeletonTrees[childTreePointer] = 'recursing'
|
|
363
|
+
skeletonTrees[childTreePointer] = makeSkeletonTree(
|
|
317
364
|
schema.items,
|
|
365
|
+
schemaId,
|
|
318
366
|
options,
|
|
367
|
+
getJSONRef,
|
|
368
|
+
skeletonTrees,
|
|
319
369
|
validates,
|
|
320
370
|
validationErrors,
|
|
321
371
|
normalizedLayouts,
|
|
322
372
|
expressions,
|
|
323
|
-
|
|
373
|
+
childTreePointer,
|
|
324
374
|
schema.items.title
|
|
325
375
|
)
|
|
326
|
-
|
|
376
|
+
}
|
|
377
|
+
node.childrenTrees = [childTreePointer]
|
|
327
378
|
}
|
|
328
379
|
}
|
|
329
380
|
|
|
330
|
-
for (const child of node.children || [])
|
|
331
|
-
|
|
381
|
+
for (const child of node.children || []) {
|
|
382
|
+
if (!child.pure) node.pure = false
|
|
383
|
+
}
|
|
384
|
+
for (const childTree of node.childrenTrees || []) {
|
|
385
|
+
if (!skeletonTrees[childTree]?.root?.pure) node.pure = false
|
|
386
|
+
}
|
|
332
387
|
|
|
333
388
|
return node
|
|
334
389
|
}
|
|
@@ -5,7 +5,10 @@ import { makeSkeletonNode } from './skeleton-node.js'
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {any} schema
|
|
8
|
+
* @param {string} schemaId
|
|
8
9
|
* @param {import('./index.js').CompileOptions} options
|
|
10
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
11
|
+
* @param {Record<string, import('./types.js').SkeletonTree>} skeletonTrees
|
|
9
12
|
* @param {string[]} validates
|
|
10
13
|
* @param {Record<string, string[]>} validationErrors
|
|
11
14
|
* @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
|
|
@@ -16,7 +19,10 @@ import { makeSkeletonNode } from './skeleton-node.js'
|
|
|
16
19
|
*/
|
|
17
20
|
export function makeSkeletonTree (
|
|
18
21
|
schema,
|
|
22
|
+
schemaId,
|
|
19
23
|
options,
|
|
24
|
+
getJSONRef,
|
|
25
|
+
skeletonTrees,
|
|
20
26
|
validates,
|
|
21
27
|
validationErrors,
|
|
22
28
|
normalizedLayouts,
|
|
@@ -24,7 +30,21 @@ export function makeSkeletonTree (
|
|
|
24
30
|
pointer,
|
|
25
31
|
title
|
|
26
32
|
) {
|
|
27
|
-
const root = makeSkeletonNode(
|
|
28
|
-
|
|
33
|
+
const root = makeSkeletonNode(
|
|
34
|
+
schema,
|
|
35
|
+
schemaId,
|
|
36
|
+
options,
|
|
37
|
+
getJSONRef,
|
|
38
|
+
skeletonTrees,
|
|
39
|
+
validates,
|
|
40
|
+
validationErrors,
|
|
41
|
+
normalizedLayouts,
|
|
42
|
+
expressions,
|
|
43
|
+
'',
|
|
44
|
+
pointer,
|
|
45
|
+
null,
|
|
46
|
+
true
|
|
47
|
+
)
|
|
48
|
+
validates.push(root.pointer)
|
|
29
49
|
return { title, root }
|
|
30
50
|
}
|
package/src/compile/types.ts
CHANGED
|
@@ -41,7 +41,8 @@ export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> &
|
|
|
41
41
|
export interface CompiledLayout {
|
|
42
42
|
options?: CompileOptions
|
|
43
43
|
schema?: SchemaObject
|
|
44
|
-
|
|
44
|
+
mainTree: string,
|
|
45
|
+
skeletonTrees: Record<string, SkeletonTree>
|
|
45
46
|
validates: Record<string, ValidateFunction>
|
|
46
47
|
validationErrors: Record<string, string[]>
|
|
47
48
|
normalizedLayouts: Record<string, NormalizedLayout>
|
|
@@ -70,7 +71,7 @@ export interface SkeletonNode {
|
|
|
70
71
|
roPropertyKeys: string[]
|
|
71
72
|
condition?: Expression
|
|
72
73
|
children?: SkeletonNode[] // optional children in the case of arrays and object nodes
|
|
73
|
-
childrenTrees?:
|
|
74
|
+
childrenTrees?: string[] // other trees that can be instantiated with separate validation (for example in the case of new array items of oneOfs, etc)
|
|
74
75
|
required?: boolean
|
|
75
76
|
nullable?: boolean
|
|
76
77
|
}
|
|
@@ -1,69 +1,130 @@
|
|
|
1
1
|
import ajvModule from 'ajv/dist/2019.js'
|
|
2
|
-
|
|
3
|
-
const Ajv = ajvModule.default
|
|
2
|
+
import clone from '../../utils/clone.js'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @param {Record<string, import('ajv').SchemaObject>} schemas
|
|
7
|
-
* @param {string} ref
|
|
8
6
|
* @param {ajvModule.default} ajv
|
|
9
|
-
* @returns {[any, string]}
|
|
7
|
+
* @returns {(schemaId: string, ref: string) => [any, string, string]}
|
|
10
8
|
*/
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
const prepareGetJSONRef = (schemas, ajv) =>
|
|
10
|
+
{
|
|
11
|
+
return (sourceSchemaId, ref) => {
|
|
12
|
+
const fullRef = ajv.opts.uriResolver.resolve(sourceSchemaId, ref)
|
|
13
|
+
const [schemaId, pointer] = fullRef.split('#')
|
|
14
|
+
schemas[schemaId] = schemas[schemaId] ?? (ajv.getSchema(schemaId)?.schema)
|
|
15
|
+
if (!schemas[schemaId]) throw new Error(`reference not found ${schemaId}`)
|
|
16
|
+
const pointerParts = pointer.split('/').filter(p => !!p)
|
|
17
|
+
const { value: fragment } = pointerParts.reduce((a, pointerPart) => {
|
|
18
|
+
a.path.push(pointerPart)
|
|
19
|
+
if (!(pointerPart in a.value)) throw new Error(`reference not found ${schemaId}#${a.path.join('/')}`)
|
|
20
|
+
a.value = a.value[pointerPart]
|
|
21
|
+
return a
|
|
22
|
+
}, { path: /** @type {string[]} */([]), value: schemas[schemaId] })
|
|
23
|
+
return [fragment, schemaId, fullRef]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* mutates a schema by replacing ~$locale~ in all refs
|
|
29
|
+
* @param {import('ajv').SchemaObject} schema
|
|
30
|
+
* @param {ajvModule.default} ajv
|
|
31
|
+
* @param {string} locale
|
|
32
|
+
* @returns {(schemaId: string, ref: string) => [any, string, string]}
|
|
33
|
+
*/
|
|
34
|
+
export function resolveLocaleRefs (schema, ajv, locale = 'en') {
|
|
35
|
+
if (!schema.$id) throw new Error('missing schema id')
|
|
36
|
+
const getJSONRef = prepareGetJSONRef({ [schema.$id]: schema }, ajv)
|
|
37
|
+
/** @type {any[]} */
|
|
38
|
+
const recursed = []
|
|
39
|
+
recurseResolveLocale(schema, schema.$id, getJSONRef, locale, recursed)
|
|
40
|
+
return getJSONRef
|
|
23
41
|
}
|
|
24
42
|
|
|
25
43
|
/**
|
|
26
|
-
* @param {Record<string, import('ajv').SchemaObject>} schemas
|
|
27
44
|
* @param {import('ajv').SchemaObject} schemaFragment
|
|
28
45
|
* @param {string} schemaId
|
|
29
|
-
* @param {
|
|
46
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
30
47
|
* @param {string} locale
|
|
31
|
-
* @
|
|
48
|
+
* @param {any[]} recursed
|
|
32
49
|
*/
|
|
33
|
-
|
|
50
|
+
|
|
51
|
+
const recurseResolveLocale = (schemaFragment, schemaId, getJSONRef, locale, recursed) => {
|
|
52
|
+
if (recursed.includes(schemaFragment)) return
|
|
53
|
+
recursed.push(schemaFragment)
|
|
34
54
|
for (const key of Object.keys(schemaFragment)) {
|
|
35
55
|
if (schemaFragment[key] && typeof schemaFragment[key] === 'object') {
|
|
36
56
|
if ('$ref' in schemaFragment[key]) {
|
|
37
|
-
const
|
|
38
|
-
const
|
|
57
|
+
const ref = schemaFragment[key].$ref.replace('~$locale~', locale)
|
|
58
|
+
const refDefaultLocale = schemaFragment[key].$ref.replace('~$locale~', 'en')
|
|
39
59
|
let refFragment, refSchemaId
|
|
40
60
|
try {
|
|
41
|
-
[refFragment, refSchemaId] = getJSONRef(
|
|
61
|
+
[refFragment, refSchemaId] = getJSONRef(schemaId, ref)
|
|
62
|
+
schemaFragment[key].$ref = ref
|
|
42
63
|
} catch (err) {
|
|
43
|
-
[refFragment, refSchemaId] = getJSONRef(
|
|
64
|
+
[refFragment, refSchemaId] = getJSONRef(schemaId, refDefaultLocale)
|
|
65
|
+
schemaFragment[key].$ref = refDefaultLocale
|
|
44
66
|
}
|
|
45
|
-
if (typeof refFragment === '
|
|
46
|
-
schemaFragment[key] = { ...refFragment, ...schemaFragment[key] }
|
|
47
|
-
delete schemaFragment[key].$ref
|
|
48
|
-
} else {
|
|
67
|
+
if (typeof refFragment === 'string') {
|
|
49
68
|
schemaFragment[key] = refFragment
|
|
69
|
+
} else {
|
|
70
|
+
recurseResolveLocale(refFragment, refSchemaId, getJSONRef, locale, recursed)
|
|
50
71
|
}
|
|
51
|
-
recurse(schemas, schemaFragment[key], refSchemaId, ajv, locale)
|
|
52
72
|
} else {
|
|
53
|
-
|
|
73
|
+
recurseResolveLocale(schemaFragment[key], schemaId, getJSONRef, locale, recursed)
|
|
54
74
|
}
|
|
55
75
|
}
|
|
56
76
|
}
|
|
57
|
-
return schemaFragment
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
/**
|
|
80
|
+
* partially resolve a schema but not recursively, used for layout normalization
|
|
61
81
|
* @param {import('ajv').SchemaObject} schema
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {string}
|
|
64
|
-
* @returns {import('ajv').SchemaObject}
|
|
82
|
+
* @param {string} schemaId
|
|
83
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
65
84
|
*/
|
|
66
|
-
export function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
export function partialResolveRefs (schema, schemaId, getJSONRef) {
|
|
86
|
+
let clonedSchema = null
|
|
87
|
+
if (schema.items && schema.items.$ref) {
|
|
88
|
+
const [refFragment] = getJSONRef(schemaId, schema.items.$ref)
|
|
89
|
+
clonedSchema = clonedSchema ?? clone(schema)
|
|
90
|
+
clonedSchema.items = { ...refFragment, ... schema.items }
|
|
91
|
+
}
|
|
92
|
+
if (schema.properties) {
|
|
93
|
+
for (const key in schema.properties) {
|
|
94
|
+
if (schema.properties[key].$ref) {
|
|
95
|
+
const [refFragment] = getJSONRef(schemaId, schema.properties[key].$ref)
|
|
96
|
+
clonedSchema = clonedSchema ?? clone(schema)
|
|
97
|
+
clonedSchema.properties[key] = { ...refFragment, ... schema.properties[key] }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (schema.oneOf) {
|
|
102
|
+
for (let i = 0; i < schema.oneOf.length; i++) {
|
|
103
|
+
if (schema.oneOf[i].$ref) {
|
|
104
|
+
const [refFragment] = getJSONRef(schemaId, schema.oneOf[i].$ref)
|
|
105
|
+
clonedSchema = clonedSchema ?? clone(schema)
|
|
106
|
+
clonedSchema.oneOf[i] = { ...refFragment, ... schema.oneOf[i] }
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (schema.anyOf) {
|
|
111
|
+
for (let i = 0; i < schema.anyOf.length; i++) {
|
|
112
|
+
if (schema.anyOf[i].$ref) {
|
|
113
|
+
const [refFragment] = getJSONRef(schemaId, schema.anyOf[i].$ref)
|
|
114
|
+
clonedSchema = clonedSchema ?? clone(schema)
|
|
115
|
+
clonedSchema.anyOf[i] = { ...refFragment, ... schema.anyOf[i] }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (schema.allOf) {
|
|
120
|
+
for (let i = 0; i < schema.allOf.length; i++) {
|
|
121
|
+
if (schema.allOf[i].$ref) {
|
|
122
|
+
const [refFragment] = getJSONRef(schemaId, schema.allOf[i].$ref)
|
|
123
|
+
clonedSchema = clonedSchema ?? clone(schema)
|
|
124
|
+
clonedSchema.allOf[i] = { ...refFragment, ... schema.allOf[i] }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return clonedSchema ?? schema
|
|
130
|
+
}
|
package/src/state/index.js
CHANGED
|
@@ -218,6 +218,7 @@ export class StatefulLayout {
|
|
|
218
218
|
* @param {unknown} [data]
|
|
219
219
|
*/
|
|
220
220
|
constructor (compiledLayout, skeletonTree, options, data) {
|
|
221
|
+
logDataBinding('create stateful layout', compiledLayout, skeletonTree, options, data)
|
|
221
222
|
this._compiledLayout = compiledLayout
|
|
222
223
|
this.skeletonTree = skeletonTree
|
|
223
224
|
/** @type {import('mitt').Emitter<StatefulLayoutEvents>} */
|
|
@@ -226,8 +227,9 @@ export class StatefulLayout {
|
|
|
226
227
|
this._autofocusTarget = this.options.autofocus ? '' : null
|
|
227
228
|
this._previousAutofocusTarget = null
|
|
228
229
|
this._data = data
|
|
230
|
+
this._previousData = data
|
|
229
231
|
this.initValidationState()
|
|
230
|
-
this.
|
|
232
|
+
this.activatedItems = {}
|
|
231
233
|
this.updateState()
|
|
232
234
|
this.handleAutofocus()
|
|
233
235
|
}
|
|
@@ -295,7 +297,7 @@ export class StatefulLayout {
|
|
|
295
297
|
createStateTree (rehydrate = false) {
|
|
296
298
|
/** @type {CreateStateTreeContext} */
|
|
297
299
|
const createStateTreeContext = {
|
|
298
|
-
|
|
300
|
+
activatedItems: this.activatedItems,
|
|
299
301
|
autofocusTarget: this._autofocusTarget,
|
|
300
302
|
initial: !this._lastCreateStateTreeContext,
|
|
301
303
|
rehydrate,
|
|
@@ -322,7 +324,6 @@ export class StatefulLayout {
|
|
|
322
324
|
validatedChildren: createStateTreeContext.nodes.filter(n => n.validated).map(n => n.fullKey)
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
|
-
this.activeItems = createStateTreeContext.activeItems
|
|
326
327
|
this.files = shallowProduceArray(this.files, createStateTreeContext.files)
|
|
327
328
|
}
|
|
328
329
|
|
|
@@ -416,7 +417,7 @@ export class StatefulLayout {
|
|
|
416
417
|
}
|
|
417
418
|
|
|
418
419
|
if (activateKey !== undefined) {
|
|
419
|
-
this.
|
|
420
|
+
this.activatedItems = produce(this.activatedItems, draft => { draft[node.fullKey] = activateKey })
|
|
420
421
|
this._autofocusTarget = node.fullKey + '/' + activateKey
|
|
421
422
|
}
|
|
422
423
|
if (node.parentFullKey === null) {
|
|
@@ -625,14 +626,14 @@ export class StatefulLayout {
|
|
|
625
626
|
/**
|
|
626
627
|
* @type {Record<string, number>}
|
|
627
628
|
*/
|
|
628
|
-
|
|
629
|
+
activatedItems
|
|
629
630
|
|
|
630
631
|
/**
|
|
631
632
|
* @param {StateNode} node
|
|
632
633
|
* @param {number} key
|
|
633
634
|
*/
|
|
634
635
|
activateItem (node, key) {
|
|
635
|
-
this.
|
|
636
|
+
this.activatedItems = produce(this.activatedItems, draft => { draft[node.fullKey] = key })
|
|
636
637
|
this._autofocusTarget = node.fullKey + '/' + key
|
|
637
638
|
if (node.key === '$oneOf') {
|
|
638
639
|
this.input(node, undefined)
|
|
@@ -646,7 +647,12 @@ export class StatefulLayout {
|
|
|
646
647
|
* @param {StateNode} node
|
|
647
648
|
*/
|
|
648
649
|
deactivateItem (node) {
|
|
649
|
-
|
|
650
|
+
// also deactivate children oneOf for example
|
|
651
|
+
this.activatedItems = produce(this.activatedItems, draft => {
|
|
652
|
+
for (const key in draft) {
|
|
653
|
+
if (key.startsWith(node.fullKey)) delete draft[key]
|
|
654
|
+
}
|
|
655
|
+
})
|
|
650
656
|
this.updateState()
|
|
651
657
|
}
|
|
652
658
|
|
package/src/state/state-node.js
CHANGED
|
@@ -67,7 +67,7 @@ const produceStateNodeMessages = produce((draft, layoutMessages, options) => {
|
|
|
67
67
|
|
|
68
68
|
/** @type {(draft: Record<string, unknown>, parentDataPath: string, children?: import('../index.js').StateNode[], additionalPropertiesErrors?: import('ajv').ErrorObject[], propertyKeys?: string[], removePropertyKeys?: string[]) => Record<string, unknown>} */
|
|
69
69
|
const produceStateNodeData = produce((draft, parentDataPath, children, additionalPropertiesErrors, propertyKeys, removePropertyKeys) => {
|
|
70
|
-
if (propertyKeys) {
|
|
70
|
+
if (propertyKeys && (propertyKeys.length || children?.length)) {
|
|
71
71
|
for (const key of Object.keys(draft)) {
|
|
72
72
|
if (!propertyKeys.includes(key)) delete draft[key]
|
|
73
73
|
}
|
|
@@ -159,7 +159,10 @@ const matchError = (error, skeleton, dataPath, parentDataPath) => {
|
|
|
159
159
|
* @returns {boolean}
|
|
160
160
|
*/
|
|
161
161
|
const matchChildError = (error, skeleton, dataPath, parentDataPath) => {
|
|
162
|
-
if (!
|
|
162
|
+
if (!(
|
|
163
|
+
error.schemaPath === skeleton.pointer ||
|
|
164
|
+
error.schemaPath.startsWith(skeleton.pointer + '/')
|
|
165
|
+
)) return false
|
|
163
166
|
if (error.instancePath.startsWith(dataPath)) return true
|
|
164
167
|
return false
|
|
165
168
|
}
|
|
@@ -262,7 +265,7 @@ export function createStateNode (
|
|
|
262
265
|
// NOTE we have to exclude nodes with errors from the cache, because context.errors is unpurely modified
|
|
263
266
|
// TODO: implement a cleaner way to filter context.errors while being able to reuse nodes with errors
|
|
264
267
|
if (skeleton.pure && reusedNode && !reusedNode.error && !reusedNode.childError) {
|
|
265
|
-
cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validationState, context.
|
|
268
|
+
cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validationState, context.activatedItems, context.initial, data]
|
|
266
269
|
if (context.cacheKeys[fullKey] && shallowEqualArray(context.cacheKeys[fullKey], cacheKey)) {
|
|
267
270
|
return reusedNode
|
|
268
271
|
}
|
|
@@ -334,7 +337,7 @@ export function createStateNode (
|
|
|
334
337
|
if (key === '$oneOf' && skeleton.childrenTrees) {
|
|
335
338
|
// find the oneOf child that was either previously selected, if none were selected select the child that is valid with current data
|
|
336
339
|
/** @type {number} */
|
|
337
|
-
const activeChildTreeIndex = fullKey in context.
|
|
340
|
+
const activeChildTreeIndex = fullKey in context.activatedItems ? context.activatedItems[fullKey] : skeleton.childrenTrees?.findIndex((childTree) => compiledLayout.validates[compiledLayout.skeletonTrees[childTree].root.pointer](data))
|
|
338
341
|
if (activeChildTreeIndex !== -1) {
|
|
339
342
|
context.errors = context.errors?.filter(error => {
|
|
340
343
|
const originalError = error.params?.errors?.[0] ?? error
|
|
@@ -344,10 +347,9 @@ export function createStateNode (
|
|
|
344
347
|
if (originalError.schemaPath.startsWith(skeleton.pointer) && !originalError.schemaPath.startsWith(skeleton.pointer + '/' + activeChildTreeIndex)) return false
|
|
345
348
|
return true
|
|
346
349
|
})
|
|
347
|
-
context.activeItems = produce(context.activeItems, draft => { draft[fullKey] = activeChildTreeIndex })
|
|
348
350
|
const activeChildKey = `${fullKey}/${activeChildTreeIndex}`
|
|
349
351
|
if (context.autofocusTarget === fullKey) context.autofocusTarget = activeChildKey
|
|
350
|
-
const activeChildTree = skeleton.childrenTrees[activeChildTreeIndex]
|
|
352
|
+
const activeChildTree = compiledLayout.skeletonTrees[skeleton.childrenTrees[activeChildTreeIndex]]
|
|
351
353
|
children = [
|
|
352
354
|
createStateNode(
|
|
353
355
|
context,
|
|
@@ -372,7 +374,7 @@ export function createStateNode (
|
|
|
372
374
|
|
|
373
375
|
if (layout.comp === 'list') {
|
|
374
376
|
const arrayData = /** @type {unknown[]} */(data ?? [])
|
|
375
|
-
const childSkeleton = /** @type {import('../index.js').SkeletonNode} */(skeleton?.childrenTrees?.[0]?.root)
|
|
377
|
+
const childSkeleton = /** @type {import('../index.js').SkeletonNode} */(skeleton?.childrenTrees?.[0] && compiledLayout.skeletonTrees[skeleton?.childrenTrees?.[0]]?.root)
|
|
376
378
|
const listItemOptions = layout.listEditMode === 'inline' ? options : produceReadonlyArrayItemOptions(options)
|
|
377
379
|
children = []
|
|
378
380
|
let focusChild = context.autofocusTarget === fullKey
|
|
@@ -382,7 +384,7 @@ export function createStateNode (
|
|
|
382
384
|
if (focusChild) context.autofocusTarget = childFullKey
|
|
383
385
|
const child = createStateNode(
|
|
384
386
|
context,
|
|
385
|
-
(layout.listEditMode === 'inline-single' && context.
|
|
387
|
+
(layout.listEditMode === 'inline-single' && context.activatedItems[fullKey] === i) ? options : listItemOptions,
|
|
386
388
|
compiledLayout,
|
|
387
389
|
i,
|
|
388
390
|
childFullKey,
|
|
@@ -420,7 +422,8 @@ export function createStateNode (
|
|
|
420
422
|
(validationState.initialized === false && options.initialValidation === 'always') ||
|
|
421
423
|
(validationState.initialized === false && options.initialValidation === 'withData' && !isDataEmpty(data))
|
|
422
424
|
|
|
423
|
-
|
|
425
|
+
/** @type {unknown} */
|
|
426
|
+
let nodeData = typeof data === 'object' && !(data instanceof File)
|
|
424
427
|
? produceStateNodeData(
|
|
425
428
|
/** @type {Record<string, unknown>} */(data ?? {}),
|
|
426
429
|
dataPath,
|
|
@@ -446,7 +449,10 @@ export function createStateNode (
|
|
|
446
449
|
} else {
|
|
447
450
|
if (layout.getDefaultData && useDefaultData(nodeData, layout, options)) {
|
|
448
451
|
if (!context.rehydrate) {
|
|
449
|
-
|
|
452
|
+
const defaultData = evalExpression(compiledLayout.expressions, layout.getDefaultData, nodeData, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
453
|
+
if (nodeData === undefined || !isDataEmpty(defaultData)) {
|
|
454
|
+
nodeData = defaultData
|
|
455
|
+
}
|
|
450
456
|
}
|
|
451
457
|
} else {
|
|
452
458
|
if (isDataEmpty(nodeData)) {
|
package/src/state/types.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface CreateStateTreeContext {
|
|
|
62
62
|
errors?: ErrorObject[]
|
|
63
63
|
additionalPropertiesErrors?: ErrorObject[]
|
|
64
64
|
files: FileRef[]
|
|
65
|
-
|
|
65
|
+
activatedItems: Record<string, number>
|
|
66
66
|
autofocusTarget: string | null
|
|
67
67
|
initial: boolean
|
|
68
68
|
rehydrate: boolean
|
|
@@ -76,7 +76,7 @@ export interface FileRef {
|
|
|
76
76
|
dataPath: string
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentWidth, validationState,
|
|
79
|
+
// [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentWidth, validationState, activatedItems, initial, data]
|
|
80
80
|
export type StateNodeCacheKey = [
|
|
81
81
|
StateNodeOptions,
|
|
82
82
|
CompiledLayout,
|
|
@@ -28,11 +28,12 @@ export function shallowProduceObject (previousObj = {}, newObj = {}) {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @template ItemType
|
|
31
|
-
* @param {any[]} a1
|
|
32
|
-
* @param {any[]} a2
|
|
31
|
+
* @param {any[] | null | undefined} a1
|
|
32
|
+
* @param {any[] | null | undefined} a2
|
|
33
33
|
* @returns {boolean}
|
|
34
34
|
*/
|
|
35
35
|
export function shallowEqualArray (a1 = [], a2 = []) {
|
|
36
|
+
if (!a1 || !a2) return a1 === a2
|
|
36
37
|
if (a1.length !== a2.length) return false
|
|
37
38
|
for (let i = 0; i < a1.length; i++) { if (a1[i] !== a2[i]) return false }
|
|
38
39
|
return true
|
package/types/compile/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @returns {CompiledLayout}
|
|
5
5
|
*/
|
|
6
6
|
export function compile(_schema: object, partialOptions?: import("./types.js").PartialCompileOptions | undefined): CompiledLayout;
|
|
7
|
-
export {
|
|
7
|
+
export { resolveLocaleRefs } from "./utils/resolve-refs.js";
|
|
8
8
|
/** @type {(draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions} */
|
|
9
9
|
export const produceCompileOptions: (draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions;
|
|
10
10
|
export type SkeletonTree = import('./types.js').SkeletonTree;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AA0GA;;;;GAIG;AACH,iCAJW,MAAM,4EAEJ,cAAc,CA0F1B;;AApKD,yGAAyG;AACzG,4CADmB,qBAAqB,cAAc,qBAAqB,KAAK,qBAAqB,CAiBnG;2BAjCW,OAAO,YAAY,EAAE,YAAY;2BACjC,OAAO,YAAY,EAAE,YAAY;6BACjC,OAAO,YAAY,EAAE,cAAc;6BACnC,OAAO,YAAY,EAAE,cAAc;oCACnC,OAAO,YAAY,EAAE,qBAAqB;iCAC1C,OAAO,YAAY,EAAE,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,CAmFlB"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {any}
|
|
2
|
+
* @param {any} rawSchema
|
|
3
|
+
* @param {string} sourceSchemaId
|
|
3
4
|
* @param {import('./index.js').CompileOptions} options
|
|
5
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
6
|
+
* @param {Record<string, import('./types.js').SkeletonTree>} skeletonTrees
|
|
4
7
|
* @param {string[]} validates
|
|
5
8
|
* @param {Record<string, string[]>} validationErrors
|
|
6
9
|
* @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
|
|
7
10
|
* @param {import('@json-layout/vocabulary').Expression[]} expressions
|
|
8
11
|
* @param {string | number} key
|
|
9
|
-
* @param {string}
|
|
12
|
+
* @param {string} currentPointer
|
|
10
13
|
* @param {string | null} parentPointer
|
|
11
14
|
* @param {boolean} required
|
|
12
15
|
* @param {string} [condition]
|
|
@@ -14,5 +17,5 @@
|
|
|
14
17
|
* @param {string} [knownType]
|
|
15
18
|
* @returns {import('./types.js').SkeletonNode}
|
|
16
19
|
*/
|
|
17
|
-
export function makeSkeletonNode(
|
|
20
|
+
export function makeSkeletonNode(rawSchema: any, sourceSchemaId: string, options: import('./index.js').CompileOptions, getJSONRef: (schemaId: string, ref: string) => [any, string, string], skeletonTrees: Record<string, import('./types.js').SkeletonTree>, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], key: string | number, currentPointer: string, parentPointer: string | null, required: boolean, condition?: string | undefined, dependent?: boolean | undefined, knownType?: string | undefined): import('./types.js').SkeletonNode;
|
|
18
21
|
//# sourceMappingURL=skeleton-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAlBW,GAAG,kBACH,MAAM,WACN,OAAO,YAAY,EAAE,cAAc,yBACxB,MAAM,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,iBACxD,OAAO,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,aACjD,MAAM,EAAE,oBACR,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,OAC9C,MAAM,GAAG,MAAM,kBACf,MAAM,iBACN,MAAM,GAAG,IAAI,YACb,OAAO,oGAIL,OAAO,YAAY,EAAE,YAAY,CA8W7C"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {any} schema
|
|
3
|
+
* @param {string} schemaId
|
|
3
4
|
* @param {import('./index.js').CompileOptions} options
|
|
5
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
6
|
+
* @param {Record<string, import('./types.js').SkeletonTree>} skeletonTrees
|
|
4
7
|
* @param {string[]} validates
|
|
5
8
|
* @param {Record<string, string[]>} validationErrors
|
|
6
9
|
* @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
|
|
@@ -9,5 +12,5 @@
|
|
|
9
12
|
* @param {string} title
|
|
10
13
|
* @returns {import('./types.js').SkeletonTree}
|
|
11
14
|
*/
|
|
12
|
-
export function makeSkeletonTree(schema: any, options: import('./index.js').CompileOptions, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], pointer: string, title: string): import('./types.js').SkeletonTree;
|
|
15
|
+
export function makeSkeletonTree(schema: any, schemaId: string, options: import('./index.js').CompileOptions, getJSONRef: (schemaId: string, ref: string) => [any, string, string], skeletonTrees: Record<string, import('./types.js').SkeletonTree>, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], pointer: string, title: string): import('./types.js').SkeletonTree;
|
|
13
16
|
//# sourceMappingURL=skeleton-tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-tree.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-tree.js"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"skeleton-tree.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-tree.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,yCAbW,GAAG,YACH,MAAM,WACN,OAAO,YAAY,EAAE,cAAc,yBACxB,MAAM,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,iBACxD,OAAO,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,aACjD,MAAM,EAAE,oBACR,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,WAC9C,MAAM,SACN,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,CAgC7C"}
|
package/types/compile/types.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> &
|
|
|
27
27
|
export interface CompiledLayout {
|
|
28
28
|
options?: CompileOptions;
|
|
29
29
|
schema?: SchemaObject;
|
|
30
|
-
|
|
30
|
+
mainTree: string;
|
|
31
|
+
skeletonTrees: Record<string, SkeletonTree>;
|
|
31
32
|
validates: Record<string, ValidateFunction>;
|
|
32
33
|
validationErrors: Record<string, string[]>;
|
|
33
34
|
normalizedLayouts: Record<string, NormalizedLayout>;
|
|
@@ -50,7 +51,7 @@ export interface SkeletonNode {
|
|
|
50
51
|
roPropertyKeys: string[];
|
|
51
52
|
condition?: Expression;
|
|
52
53
|
children?: SkeletonNode[];
|
|
53
|
-
childrenTrees?:
|
|
54
|
+
childrenTrees?: string[];
|
|
54
55
|
required?: boolean;
|
|
55
56
|
nullable?: boolean;
|
|
56
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AACzC,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IACzD,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,KAAK,IAAI,CAAA;CAC1D;AAID,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,YAAY,CAAA;CACnB;AAID,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* mutates a schema by replacing ~$locale~ in all refs
|
|
2
3
|
* @param {import('ajv').SchemaObject} schema
|
|
3
4
|
* @param {ajvModule.default} ajv
|
|
4
5
|
* @param {string} locale
|
|
5
|
-
* @returns {
|
|
6
|
+
* @returns {(schemaId: string, ref: string) => [any, string, string]}
|
|
6
7
|
*/
|
|
7
|
-
export function
|
|
8
|
+
export function resolveLocaleRefs(schema: import('ajv').SchemaObject, ajv: ajvModule.default, locale?: string): (schemaId: string, ref: string) => [any, string, string];
|
|
9
|
+
/**
|
|
10
|
+
* partially resolve a schema but not recursively, used for layout normalization
|
|
11
|
+
* @param {import('ajv').SchemaObject} schema
|
|
12
|
+
* @param {string} schemaId
|
|
13
|
+
* @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
|
|
14
|
+
*/
|
|
15
|
+
export function partialResolveRefs(schema: import('ajv').SchemaObject, schemaId: string, getJSONRef: (schemaId: string, ref: string) => [any, string, string]): any;
|
|
8
16
|
import ajvModule from 'ajv/dist/2019.js';
|
|
9
17
|
//# sourceMappingURL=resolve-refs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-refs.d.ts","sourceRoot":"","sources":["../../../src/compile/utils/resolve-refs.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-refs.d.ts","sourceRoot":"","sources":["../../../src/compile/utils/resolve-refs.js"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,0CALW,OAAO,KAAK,EAAE,YAAY,OAC1B,UAAU,OAAO,WACjB,MAAM,cACO,MAAM,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CASpE;AAsCD;;;;;GAKG;AACH,2CAJW,OAAO,KAAK,EAAE,YAAY,YAC1B,MAAM,yBACK,MAAM,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,OA+ClE;sBAjIqB,kBAAkB"}
|
package/types/state/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,mEAAmE;AACnE,+BADkB,SAAS,GAAG,SAAS,8CACoC;AAE3E,iLAAiL;AACjL,iCADkB,SAAS,GAAG,SAAS,cAAc,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,aAAa,CAAC,yHACnB;AAoCjG;IAgIE;;;;;OAKG;IACH,4BALW,OAAO,aAAa,EAAE,cAAc,gBACpC,OAAO,aAAa,EAAE,YAAY,WAClC,QAAQ,qBAAqB,CAAC,SAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+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AY;yBACjC,OAAO,YAAY,EAAE,UAAU;8BAC/B,OAAO,YAAY,EAAE,eAAe;6BACpC,OAAO,YAAY,EAAE,cAAc;iCACnC,OAAO,YAAY,EAAE,kBAAkB;6BACvC,OAAO,YAAY,EAAE,cAAc;kCACnC,OAAO,YAAY,EAAE,mBAAmB;uBACxC,OAAO,YAAY,EAAE,QAAQ;+BAC7B,OAAO,YAAY,EAAE,gBAAgB;0BACrC,OAAO,YAAY,EAAE,WAAW;8BAChC,OAAO,YAAY,EAAE,eAAe;uBACpC,OAAO,YAAY,EAAE,QAAQ;4BAC7B,OAAO,YAAY,EAAE,aAAa;sBAClC,OAAO,YAAY,EAAE,OAAO;wBApCjB,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"AAyKA;;;;;;;;;;;GAWG;AACH,4CAXW,OAAO,aAAa,EAAE,kBAAkB,EAAE,cAC1C,OAAO,yBAAyB,EAAE,UAAU,QAC5C,GAAG,WACH,OAAO,YAAY,EAAE,gBAAgB,WACrC,OAAO,oBAAoB,EAAE,OAAO,UACpC,OAAO,yBAAyB,EAAE,cAAc,aAChD,OAAO,MAAM,EAAE,OAAO,KAAK,EAAE,gBAAgB,CAAC,YAC9C,OAAO,iBACP,OAAO,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAC1D,GAAG,CAef;AA+BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAjBW,OAAO,YAAY,EAAE,sBAAsB,iBAC3C,OAAO,YAAY,EAAE,gBAAgB,kBACrC,OAAO,aAAa,EAAE,cAAc,OACpC,MAAM,GAAG,MAAM,WACf,MAAM,iBACN,MAAM,GAAG,IAAI,YACb,MAAM,kBACN,MAAM,GAAG,IAAI,YACb,OAAO,aAAa,EAAE,YAAY,mBAClC,OAAO,yBAAyB,EAAE,KAAK,GAAG,IAAI,iBAC9C,OAAO,oBAAoB,EAAE,OAAO,QACpC,OAAO,iBACP,OAAO,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,mBAC5D,OAAO,YAAY,EAAE,eAAe,4DAElC,OAAO,YAAY,EAAE,SAAS,CA6R1C;AAED,uFAAuF;AACvF,yCADmB,GAAG,QAAQ,OAAO,YAAY,EAAE,SAAS,QAAQ,OAAO,KAAK,GAAG,CAOjF"}
|
package/types/state/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface CreateStateTreeContext {
|
|
|
32
32
|
errors?: ErrorObject[];
|
|
33
33
|
additionalPropertiesErrors?: ErrorObject[];
|
|
34
34
|
files: FileRef[];
|
|
35
|
-
|
|
35
|
+
activatedItems: Record<string, number>;
|
|
36
36
|
autofocusTarget: string | null;
|
|
37
37
|
initial: boolean;
|
|
38
38
|
rehydrate: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,iBAAiB,EACvB,MAAM,yBAAyB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IAAC,QAAQ,EAAE,SAAS,EAAE,CAAC;IAAC,aAAa,EAAE,YAAY,EAAE,CAAA;CAAE,CAAA;AAEtH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAAA;AAE1F,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CAAE,CAAA"}
|
|
@@ -13,9 +13,9 @@ export function shallowProduceArray<ItemType>(previousArray?: ItemType[], newArr
|
|
|
13
13
|
export function shallowProduceObject(previousObj?: Record<string, any>, newObj?: Record<string, any>): Record<string, any>;
|
|
14
14
|
/**
|
|
15
15
|
* @template ItemType
|
|
16
|
-
* @param {any[]} a1
|
|
17
|
-
* @param {any[]} a2
|
|
16
|
+
* @param {any[] | null | undefined} a1
|
|
17
|
+
* @param {any[] | null | undefined} a2
|
|
18
18
|
* @returns {boolean}
|
|
19
19
|
*/
|
|
20
|
-
export function shallowEqualArray<ItemType>(a1?: any[], a2?: any[]): boolean;
|
|
20
|
+
export function shallowEqualArray<ItemType>(a1?: any[] | null | undefined, a2?: any[] | null | undefined): boolean;
|
|
21
21
|
//# sourceMappingURL=immutable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"immutable.d.ts","sourceRoot":"","sources":["../../../src/state/utils/immutable.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,6GAIC;AAED;;;;GAIG;AACH,mDAJW,OAAO,MAAM,EAAE,GAAG,CAAC,WACnB,OAAO,MAAM,EAAE,GAAG,CAAC,GACjB,OAAO,MAAM,EAAE,GAAG,CAAC,CAW/B;AAED;;;;;GAKG;AACH,iDAJW,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"immutable.d.ts","sourceRoot":"","sources":["../../../src/state/utils/immutable.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,6GAIC;AAED;;;;GAIG;AACH,mDAJW,OAAO,MAAM,EAAE,GAAG,CAAC,WACnB,OAAO,MAAM,EAAE,GAAG,CAAC,GACjB,OAAO,MAAM,EAAE,GAAG,CAAC,CAW/B;AAED;;;;;GAKG;AACH,iDAJW,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,OACxB,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,GACtB,OAAO,CAOnB"}
|