@json-layout/core 2.8.0 → 2.8.2

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.
Files changed (87) hide show
  1. package/package.json +2 -2
  2. package/src/compile/serialize.js +18 -15
  3. package/src/compile/skeleton-node.js +25 -0
  4. package/src/i18n/de.js +1 -0
  5. package/src/i18n/en.js +1 -0
  6. package/src/i18n/fr.js +1 -0
  7. package/src/i18n/nl.js +1 -0
  8. package/src/i18n/types.ts +1 -0
  9. package/src/state/index.js +28 -0
  10. package/src/state/state-node.js +25 -3
  11. package/src/state/types.ts +6 -0
  12. package/types/compile/index.d.ts +16 -0
  13. package/types/compile/index.d.ts.map +1 -0
  14. package/types/compile/options.d.ts +6 -0
  15. package/types/compile/options.d.ts.map +1 -0
  16. package/types/compile/serialize.d.ts +6 -0
  17. package/types/compile/serialize.d.ts.map +1 -0
  18. package/types/compile/skeleton-node.d.ts +21 -0
  19. package/types/compile/skeleton-node.d.ts.map +1 -0
  20. package/types/compile/skeleton-tree.d.ts +19 -0
  21. package/types/compile/skeleton-tree.d.ts.map +1 -0
  22. package/types/compile/types.d.ts +61 -0
  23. package/types/compile/types.d.ts.map +1 -0
  24. package/types/compile/utils/resolve-refs.d.ts +17 -0
  25. package/types/compile/utils/resolve-refs.d.ts.map +1 -0
  26. package/types/compile/utils/x-i18n.d.ts +2 -0
  27. package/types/compile/utils/x-i18n.d.ts.map +1 -0
  28. package/types/i18n/de.d.ts +25 -0
  29. package/types/i18n/de.d.ts.map +1 -0
  30. package/types/i18n/en.d.ts +25 -0
  31. package/types/i18n/en.d.ts.map +1 -0
  32. package/types/i18n/fr.d.ts +25 -0
  33. package/types/i18n/fr.d.ts.map +1 -0
  34. package/types/i18n/index.d.ts +8 -0
  35. package/types/i18n/index.d.ts.map +1 -0
  36. package/types/i18n/nl.d.ts +25 -0
  37. package/types/i18n/nl.d.ts.map +1 -0
  38. package/types/i18n/types.d.ts +24 -0
  39. package/types/i18n/types.d.ts.map +1 -0
  40. package/types/index.d.ts +5 -0
  41. package/types/index.d.ts.map +1 -0
  42. package/types/state/index.d.ts +316 -0
  43. package/types/state/index.d.ts.map +1 -0
  44. package/types/state/options.d.ts +11 -0
  45. package/types/state/options.d.ts.map +1 -0
  46. package/types/state/state-node.d.ts +63 -0
  47. package/types/state/state-node.d.ts.map +1 -0
  48. package/types/state/state-tree.d.ts +13 -0
  49. package/types/state/state-tree.d.ts.map +1 -0
  50. package/types/state/types.d.ts +200 -0
  51. package/types/state/types.d.ts.map +1 -0
  52. package/types/state/utils/display.d.ts +51 -0
  53. package/types/state/utils/display.d.ts.map +1 -0
  54. package/types/state/utils/immutable.d.ts +21 -0
  55. package/types/state/utils/immutable.d.ts.map +1 -0
  56. package/types/state/utils/modified.d.ts +17 -0
  57. package/types/state/utils/modified.d.ts.map +1 -0
  58. package/types/state/utils/regexps.d.ts +6 -0
  59. package/types/state/utils/regexps.d.ts.map +1 -0
  60. package/types/state/utils/urls.d.ts +2 -0
  61. package/types/state/utils/urls.d.ts.map +1 -0
  62. package/types/utils/build.d.ts +5 -0
  63. package/types/utils/build.d.ts.map +1 -0
  64. package/types/utils/clone.d.ts +2 -0
  65. package/types/utils/clone.d.ts.map +1 -0
  66. package/types/utils/doc-options.d.ts +14 -0
  67. package/types/utils/doc-options.d.ts.map +1 -0
  68. package/types/webmcp/index.d.ts +90 -0
  69. package/types/webmcp/index.d.ts.map +1 -0
  70. package/types/webmcp/project.d.ts +111 -0
  71. package/types/webmcp/project.d.ts.map +1 -0
  72. package/types/webmcp/resolve.d.ts +11 -0
  73. package/types/webmcp/resolve.d.ts.map +1 -0
  74. package/types/webmcp/tools/describe-state.d.ts +79 -0
  75. package/types/webmcp/tools/describe-state.d.ts.map +1 -0
  76. package/types/webmcp/tools/edit-array.d.ts +88 -0
  77. package/types/webmcp/tools/edit-array.d.ts.map +1 -0
  78. package/types/webmcp/tools/fill-form-skill.d.ts +24 -0
  79. package/types/webmcp/tools/fill-form-skill.d.ts.map +1 -0
  80. package/types/webmcp/tools/get-data.d.ts +31 -0
  81. package/types/webmcp/tools/get-data.d.ts.map +1 -0
  82. package/types/webmcp/tools/get-field-suggestions.d.ts +66 -0
  83. package/types/webmcp/tools/get-field-suggestions.d.ts.map +1 -0
  84. package/types/webmcp/tools/set-data.d.ts +60 -0
  85. package/types/webmcp/tools/set-data.d.ts.map +1 -0
  86. package/types/webmcp/tools/set-field-value.d.ts +91 -0
  87. package/types/webmcp/tools/set-field-value.d.ts.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-layout/core",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "Compilation and state management utilities for JSON Layout.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "homepage": "https://github.com/json-layout/json-layout#readme",
84
84
  "peerDependencies": {
85
- "@json-layout/vocabulary": "^2.13.0"
85
+ "@json-layout/vocabulary": "^2.13.1"
86
86
  },
87
87
  "dependencies": {
88
88
  "ajv": "^8.17.1",
@@ -51,6 +51,8 @@ export async function serialize (compiledLayout) {
51
51
  let code = standaloneCode.default(ajv, validatesExports)
52
52
 
53
53
  code = code.replace('"use strict";', '')
54
+ // make the exportN validates module-local so the object below can reference them
55
+ code = code.replace(/export const (export\d+) =/g, 'const $1 =')
54
56
 
55
57
  // some internal imports to ajv are not translated to esm, we do it here
56
58
  // cf https://github.com/ajv-validator/ajv-formats/pull/73
@@ -76,8 +78,7 @@ export async function serialize (compiledLayout) {
76
78
  ajvI18nPath = 'ajv-i18n/localize/en/index.js'
77
79
  }
78
80
 
79
- code = `import localizeErrors from "${ajvI18nPath}";
80
- export const exportLocalizeErrors = localizeErrors;\n` + code
81
+ code = `import localizeErrors from "${ajvI18nPath}";\n` + code
81
82
 
82
83
  i = 0
83
84
  const expressionsNodes = []
@@ -91,30 +92,32 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
91
92
  expressionsNodes.push(builders.raw(id))
92
93
  }
93
94
 
94
- const ast = parseModule(code)
95
+ // reference the validate functions by name, keyed by json-pointer
96
+ /** @type {Record<string, any>} */
97
+ const validatesNodes = {}
98
+ i = 0
99
+ for (const pointer of Object.keys(compiledLayout.validates)) {
100
+ validatesNodes[pointer] = builders.raw(`export${i++}`)
101
+ }
102
+
103
+ // run magicast only on the small object literal; keep the large generated `code` as
104
+ // a raw string prefix (parsing it was the serialization bottleneck)
105
+ const ast = parseModule('export const compiledLayout = {}')
95
106
  ast.exports.compiledLayout = {
96
107
  mainTree: compiledLayout.mainTree,
97
108
  skeletonTrees: clone(compiledLayout.skeletonTrees),
98
109
  skeletonNodes: clone(compiledLayout.skeletonNodes),
99
110
  normalizedLayouts: clone(compiledLayout.normalizedLayouts),
100
- validates: {},
111
+ validates: validatesNodes,
101
112
  validationErrors: compiledLayout.validationErrors,
102
113
  expressions: expressionsNodes,
103
114
  locale: compiledLayout.locale,
104
115
  messages: compiledLayout.messages,
105
116
  components: compiledLayout.options.components,
106
- localizeErrors: ast.exports.exportLocalizeErrors
107
- }
108
- delete ast.exports.exportLocalizeErrors
109
-
110
- i = 0
111
- for (const pointer of Object.keys(compiledLayout.validates)) {
112
- const exportKey = `export${i++}`
113
- ast.exports.compiledLayout.validates[pointer] = ast.exports[exportKey]
114
- delete ast.exports[exportKey]
117
+ localizeErrors: builders.raw('localizeErrors')
115
118
  }
116
119
 
117
- const generatedCode = generateCode(ast).code.replace('export const compiledLayout = {', 'const compiledLayout = {')
120
+ const objectCode = generateCode(ast).code.replace('export const compiledLayout = {', 'const compiledLayout = {')
118
121
 
119
- return generatedCode
122
+ return `${code}\n${objectCode}`
120
123
  }
@@ -305,6 +305,7 @@ export function makeSkeletonNode (
305
305
  /** @type {string | undefined} */
306
306
  let discriminator
307
307
  if (schema.discriminator?.propertyName) discriminator = schema.discriminator?.propertyName
308
+ else discriminator = inferDiscriminator(schema.oneOf, schemaId, getJSONRef)
308
309
  const oneOfPointer = `${refPointerPrefix}/oneOf`
309
310
  if (!normalizedLayouts[oneOfPointer]) {
310
311
  const normalizationResult = normalizeLayoutFragment(
@@ -594,3 +595,27 @@ export function makeSkeletonNode (
594
595
 
595
596
  return node
596
597
  }
598
+
599
+ /**
600
+ * infer a discriminator when the keyword was not declared:
601
+ * a property that has a distinct const string value in every branch of the oneOf
602
+ * @param {any[]} oneOf
603
+ * @param {string} schemaId
604
+ * @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
605
+ * @returns {string | undefined}
606
+ */
607
+ function inferDiscriminator (oneOf, schemaId, getJSONRef) {
608
+ const fragments = oneOf.map(branch => branch.$ref ? getJSONRef(schemaId, branch.$ref)[0] : branch)
609
+ const candidateKeys = Object.keys(fragments[0]?.properties ?? {})
610
+ for (const key of candidateKeys) {
611
+ /** @type {string[]} */
612
+ const values = []
613
+ const distinct = fragments.every(fragment => {
614
+ const value = fragment?.properties?.[key]?.const
615
+ if (typeof value !== 'string' || values.includes(value)) return false
616
+ values.push(value)
617
+ return true
618
+ })
619
+ if (distinct) return key
620
+ }
621
+ }
package/src/i18n/de.js CHANGED
@@ -8,6 +8,7 @@ export default {
8
8
  confirm: 'Bestätigen',
9
9
  close: 'Schließen',
10
10
  duplicate: 'Duplizieren',
11
+ insertAfter: 'Danach einfügen',
11
12
  copy: 'Kopie',
12
13
  paste: 'Paste',
13
14
  sort: 'Sortieren',
package/src/i18n/en.js CHANGED
@@ -8,6 +8,7 @@ export default {
8
8
  confirm: 'Confirm',
9
9
  close: 'Close',
10
10
  duplicate: 'Duplicate',
11
+ insertAfter: 'Insert after',
11
12
  copy: 'Copy',
12
13
  paste: 'Paste',
13
14
  sort: 'Sort',
package/src/i18n/fr.js CHANGED
@@ -8,6 +8,7 @@ export default {
8
8
  confirm: 'Confirmer',
9
9
  close: 'Fermer',
10
10
  duplicate: 'Dupliquer',
11
+ insertAfter: 'Insérer après',
11
12
  copy: 'Copier',
12
13
  paste: 'Coller',
13
14
  sort: 'Trier',
package/src/i18n/nl.js CHANGED
@@ -8,6 +8,7 @@ export default {
8
8
  edit: 'Bewerken',
9
9
  close: 'Sluiten',
10
10
  duplicate: 'Verveelvoudigen',
11
+ insertAfter: 'Hierna invoegen',
11
12
  copy: 'Kopiëren',
12
13
  paste: 'Plakken',
13
14
  sort: 'Sorteren',
package/src/i18n/types.ts CHANGED
@@ -12,6 +12,7 @@ export interface StateOptionsMessages {
12
12
  edit: string
13
13
  close: string
14
14
  duplicate: string
15
+ insertAfter: string
15
16
  copy: string
16
17
  paste: string
17
18
  sort: string
@@ -139,6 +139,10 @@ export class StatefulLayout {
139
139
  set data (data) {
140
140
  logDataBinding('apply main data setter', data)
141
141
  this._data = data
142
+ // data replaced from outside is authoritative, previously activated oneOf branches
143
+ // are re-resolved from the new data (discriminator based or validation based)
144
+ this._explicitActivatedItems.clear()
145
+ this._reResolveActivatedItems = true
142
146
  this.updateState()
143
147
  }
144
148
 
@@ -285,6 +289,10 @@ export class StatefulLayout {
285
289
  /** @type {CreateStateTreeContext} */
286
290
  const createStateTreeContext = {
287
291
  activatedItems: this.activatedItems,
292
+ explicitActivatedItems: this._explicitActivatedItems,
293
+ // only the first tree creation after the data setter re-resolves activated branches,
294
+ // the following hydration iterations preserve them so that they cannot oscillate
295
+ reResolveActivatedItems: this._reResolveActivatedItems,
288
296
  autoActivatedItems: {},
289
297
  autofocusTarget: this._autofocusTarget,
290
298
  currentInput: this._currentInput,
@@ -303,6 +311,8 @@ export class StatefulLayout {
303
311
  // @ts-ignore
304
312
  if (this._options._debugCache) createStateTreeContext._debugCache = this._lastCreateStateTreeContext?._debugCache ?? {}
305
313
 
314
+ this._reResolveActivatedItems = false
315
+
306
316
  this._stateTree = createStateTree(
307
317
  createStateTreeContext,
308
318
  this._options,
@@ -453,6 +463,7 @@ export class StatefulLayout {
453
463
  if (activateKey !== undefined) {
454
464
  logActivatedItems(node.fullKey, 'activated item on input', activateKey)
455
465
  this.activatedItems = produce(this.activatedItems, draft => { draft[node.fullKey] = activateKey })
466
+ this._explicitActivatedItems.add(node.fullKey)
456
467
  this._autofocusTarget = node.fullKey + '/' + activateKey
457
468
  }
458
469
  if (node.parentFullKey === null) {
@@ -713,6 +724,21 @@ export class StatefulLayout {
713
724
  */
714
725
  activatedItems
715
726
 
727
+ /**
728
+ * keys of activatedItems that were explicitly selected by the user,
729
+ * as opposed to auto-activated from the data
730
+ * @private
731
+ * @type {Set<string>}
732
+ */
733
+ _explicitActivatedItems = new Set()
734
+
735
+ /**
736
+ * true after data was replaced from outside, consumed by the next state tree creation
737
+ * @private
738
+ * @type {boolean}
739
+ */
740
+ _reResolveActivatedItems = false
741
+
716
742
  /**
717
743
  * @param {StateNode} node
718
744
  * @param {number | string} key
@@ -720,6 +746,7 @@ export class StatefulLayout {
720
746
  activateItem (node, key) {
721
747
  logActivatedItems(node.fullKey, 'activate item explicitly', key)
722
748
  this.activatedItems = produce(this.activatedItems, draft => { draft[node.fullKey] = key })
749
+ this._explicitActivatedItems.add(node.fullKey)
723
750
  this._autofocusTarget = node.fullKey + '/' + key
724
751
  if (node.key === '$oneOf') {
725
752
  if (node.layout.emptyData && node.data && typeof node.data === 'object' && node.children?.[0]) {
@@ -764,6 +791,7 @@ export class StatefulLayout {
764
791
  if (key.startsWith(node.fullKey)) {
765
792
  logActivatedItems(node.fullKey, 'item deactivation deletes a key', key)
766
793
  delete draft[key]
794
+ this._explicitActivatedItems.delete(key)
767
795
  }
768
796
  }
769
797
  })
@@ -570,13 +570,34 @@ export function createStateNode (
570
570
  // find the oneOf child that was either previously selected
571
571
  // or the one matching the specified discriminator
572
572
  // or the one that is valid with current data
573
- let activeChildTreeIndex = /** @type {number} */(context.activatedItems[fullKey])
573
+ let activeChildTreeIndex = /** @type {number | undefined} */(context.activatedItems[fullKey])
574
574
  let validChildTreeIndex = -1
575
+ if (
576
+ activeChildTreeIndex !== undefined &&
577
+ skeleton.discriminator !== undefined &&
578
+ !context.explicitActivatedItems.has(fullKey) &&
579
+ data?.[skeleton.discriminator] !== undefined
580
+ ) {
581
+ // an auto-activated branch is only kept as long as the discriminator value in the data still matches it,
582
+ // so that data replaced from outside (main data setter) is re-resolved to the right branch
583
+ const activeTree = skeleton.childrenTrees[activeChildTreeIndex]
584
+ if (activeTree !== undefined && compiledLayout.skeletonTrees[activeTree].discriminatorValue !== data[skeleton.discriminator]) {
585
+ activeChildTreeIndex = undefined
586
+ }
587
+ }
575
588
  if (activeChildTreeIndex !== undefined) {
576
- // already explicitly activated, just check if data validates against the active variant
589
+ // already activated, just check if data validates against the active variant
577
590
  const activeTree = skeleton.childrenTrees[activeChildTreeIndex]
578
591
  if (activeTree !== undefined && compiledLayout.validates[compiledLayout.skeletonTrees[activeTree].refPointer](data)) {
579
592
  validChildTreeIndex = activeChildTreeIndex
593
+ } else if (context.reResolveActivatedItems) {
594
+ // data was replaced from outside (main data setter) and does not validate against the active branch,
595
+ // switch to another branch that validates the new data, keep the active branch if none does
596
+ const reResolvedIndex = skeleton.childrenTrees.findIndex((childTree) => compiledLayout.validates[compiledLayout.skeletonTrees[childTree].refPointer](data))
597
+ if (reResolvedIndex !== -1) {
598
+ activeChildTreeIndex = reResolvedIndex
599
+ validChildTreeIndex = reResolvedIndex
600
+ }
580
601
  }
581
602
  } else {
582
603
  // try discriminator-based resolution first (cheap string comparison)
@@ -599,7 +620,8 @@ export function createStateNode (
599
620
  if (activeChildTreeIndex !== -1) {
600
621
  const activeChildTree = compiledLayout.skeletonTrees[skeleton.childrenTrees[activeChildTreeIndex]]
601
622
  const activeChildNode = compiledLayout.skeletonNodes[activeChildTree.root]
602
- if (!(fullKey in context.activatedItems)) context.autoActivatedItems[fullKey] = activeChildTreeIndex
623
+ // record the auto-activated branch, also when it changed compared to a stale previously activated branch
624
+ if (context.activatedItems[fullKey] !== activeChildTreeIndex) context.autoActivatedItems[fullKey] = activeChildTreeIndex
603
625
  context.errors = context.errors?.filter(error => {
604
626
  // if an item was selected, remove the oneOf error
605
627
  if (matchLocalError(error, skeleton, dataPath, parentDataPath)) {
@@ -73,6 +73,12 @@ export interface CreateStateTreeContext {
73
73
  additionalPropertiesErrors?: ErrorObject[]
74
74
  files: FileRef[]
75
75
  activatedItems: Record<string, number | string>
76
+ // keys of activatedItems that were explicitly selected by the user (activateItem / input with activateKey)
77
+ // as opposed to auto-activated from the data, they are not challenged by the discriminator value in the data
78
+ explicitActivatedItems: Set<string>
79
+ // true on the first state tree creation after data was replaced from outside (main data setter),
80
+ // activated oneOf branches that do not validate the new data are then re-resolved
81
+ reResolveActivatedItems: boolean
76
82
  autoActivatedItems: Record<string, number | number>
77
83
  autofocusTarget: string | null
78
84
  currentInput: string | null
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @param {object} _schema
3
+ * @param {PartialCompileOptions} [partialOptions]
4
+ * @returns {CompiledLayout}
5
+ */
6
+ export function compile(_schema: object, partialOptions?: PartialCompileOptions): CompiledLayout;
7
+ export { resolveLocaleRefs } from "./utils/resolve-refs.js";
8
+ export { resolveXI18n } from "./utils/x-i18n.js";
9
+ export { produceCompileOptions } from "./options.js";
10
+ export type SkeletonTree = import("./types.js").SkeletonTree;
11
+ export type SkeletonNode = import("./types.js").SkeletonNode;
12
+ export type CompiledLayout = import("./types.js").CompiledLayout;
13
+ export type CompileOptions = import("./types.js").CompileOptions;
14
+ export type PartialCompileOptions = import("./types.js").PartialCompileOptions;
15
+ export type CompiledExpression = import("./types.js").CompiledExpression;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AA4BA;;;;GAIG;AACH,iCAJW,MAAM,mBACN,qBAAqB,GACnB,cAAc,CAuH1B;;;;2BAvIY,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"}
@@ -0,0 +1,6 @@
1
+ export function fillOptions(partialOptions: PartialCompileOptions): CompileOptions;
2
+ /** @type {(draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions} */
3
+ export const produceCompileOptions: (draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions;
4
+ export type CompileOptions = import("./types.js").CompileOptions;
5
+ export type PartialCompileOptions = import("./types.js").PartialCompileOptions;
6
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/compile/options.js"],"names":[],"mappings":"AAqBO,4CAHI,qBAAqB,GACnB,cAAc,CAwD1B;AAGD,yGAAyG;AACzG,oCADW,CAAC,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,qBAAqB,KAAK,qBAAqB,CAiBnG;6BArFW,OAAO,YAAY,EAAE,cAAc;oCACnC,OAAO,YAAY,EAAE,qBAAqB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {import('./index.js').CompiledLayout} compiledLayout
3
+ * @returns {Promise<string>}
4
+ */
5
+ export function serialize(compiledLayout: import("./index.js").CompiledLayout): Promise<string>;
6
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +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,OAAO,CAAC,MAAM,CAAC,CA4G3B"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @param {any} rawSchema
3
+ * @param {string} sourceSchemaId
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
7
+ * @param {Record<string, import('./types.js').SkeletonNode>} skeletonNodes
8
+ * @param {string[]} validatePointers
9
+ * @param {Record<string, string[]>} validationErrors
10
+ * @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
11
+ * @param {import('@json-layout/vocabulary').Expression[]} expressions
12
+ * @param {string | number} key
13
+ * @param {string} pointer
14
+ * @param {boolean} required
15
+ * @param {string} [condition]
16
+ * @param {boolean} [dependent]
17
+ * @param {string} [knownType]
18
+ * @returns {import('./types.js').SkeletonNode}
19
+ */
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>, skeletonNodes: Record<string, import("./types.js").SkeletonNode>, validatePointers: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import("@json-layout/vocabulary").NormalizedLayout>, expressions: import("@json-layout/vocabulary").Expression[], key: string | number, pointer: string, required: boolean, condition?: string, dependent?: boolean, knownType?: string): import("./types.js").SkeletonNode;
21
+ //# sourceMappingURL=skeleton-node.d.ts.map
@@ -0,0 +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,yBAAyB,EAAE,UAAU,EAAE,OAC9C,MAAM,GAAG,MAAM,WACf,MAAM,YACN,OAAO,cACP,MAAM,cACN,OAAO,cACP,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,CA6jB7C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @param {any} schema
3
+ * @param {string} schemaId
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
7
+ * @param {Record<string, import('./types.js').SkeletonNode>} skeletonNodes
8
+ * @param {string[]} validatePointers
9
+ * @param {Record<string, string[]>} validationErrors
10
+ * @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
11
+ * @param {import('@json-layout/vocabulary').Expression[]} expressions
12
+ * @param {string} pointer
13
+ * @param {string} [defaultTitle]
14
+ * @param {boolean} [deleteRootNodeTitle]
15
+ * @param {string} [discriminator]
16
+ * @returns {import('./types.js').SkeletonTree}
17
+ */
18
+ 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>, skeletonNodes: Record<string, import("./types.js").SkeletonNode>, validatePointers: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import("@json-layout/vocabulary").NormalizedLayout>, expressions: import("@json-layout/vocabulary").Expression[], pointer: string, defaultTitle?: string, deleteRootNodeTitle?: boolean, discriminator?: string): import("./types.js").SkeletonTree;
19
+ //# sourceMappingURL=skeleton-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton-tree.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-tree.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,yCAhBW,GAAG,YACH,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,yBAAyB,EAAE,UAAU,EAAE,WAC9C,MAAM,iBACN,MAAM,wBACN,OAAO,kBACP,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,CAqD7C"}
@@ -0,0 +1,61 @@
1
+ import type ajvModule from 'ajv/dist/2019.js';
2
+ import type { MarkedOptions } from 'marked';
3
+ import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase, type Expression, type NormalizeOptions } from '@json-layout/vocabulary';
4
+ import { type ValidateFunction, type SchemaObject } from 'ajv/dist/2019.js';
5
+ import { type Display } from '../state/utils/display.js';
6
+ import { type LocaleMessages } from '../i18n/types.js';
7
+ export interface ParentContextExpression {
8
+ data: unknown;
9
+ parent: ParentContextExpression | undefined | null;
10
+ }
11
+ export type CompiledExpression = (data: any, dataAlias: any, options: StateNodeOptionsBase, context: object, display: Display, layout: BaseCompObject, readOnly: boolean, summary: boolean, validates: Record<string, ValidateFunction>, rootData?: unknown, parent?: ParentContextExpression | null) => any;
12
+ export type CompileOptions = NormalizeOptions & {
13
+ ajv: ajvModule.default;
14
+ ajvOptions?: ajvModule.Options;
15
+ markedOptions?: MarkedOptions;
16
+ locale: string;
17
+ defaultLocale: string;
18
+ messages: LocaleMessages;
19
+ xI18n: boolean;
20
+ };
21
+ export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {
22
+ messages?: Partial<LocaleMessages>;
23
+ components?: Record<string, Omit<ComponentInfo, 'name'>>;
24
+ };
25
+ export interface CompiledLayout {
26
+ options?: CompileOptions;
27
+ schema?: SchemaObject;
28
+ mainTree: string;
29
+ skeletonTrees: Record<string, SkeletonTree>;
30
+ skeletonNodes: Record<string, SkeletonNode>;
31
+ validates: Record<string, ValidateFunction>;
32
+ validationErrors: Record<string, string[]>;
33
+ normalizedLayouts: Record<string, NormalizedLayout>;
34
+ expressions: CompiledExpression[];
35
+ locale: string;
36
+ messages: LocaleMessages;
37
+ components: Record<string, Omit<ComponentInfo, 'schema'>>;
38
+ localizeErrors: (errors: ajvModule.ErrorObject[]) => void;
39
+ }
40
+ export interface SkeletonTree {
41
+ title: string;
42
+ root: string;
43
+ refPointer: string;
44
+ discriminatorValue?: string;
45
+ }
46
+ export interface SkeletonNode {
47
+ title?: string;
48
+ key: string | number;
49
+ pointer: string;
50
+ refPointer: string;
51
+ pure: boolean;
52
+ propertyKeys: string[];
53
+ roPropertyKeys: string[];
54
+ condition?: Expression;
55
+ children?: string[];
56
+ childrenTrees?: string[];
57
+ discriminator?: string;
58
+ required?: boolean;
59
+ nullable?: boolean;
60
+ }
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC3K,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAoB,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,WAAW,uBAAuB;IACt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 in all refs
3
+ * @param {import('ajv').SchemaObject} schema
4
+ * @param {import('ajv/dist/2019.js').default} ajv
5
+ * @param {string} [locale]
6
+ * @param {string} [defaultLocale]
7
+ * @returns {(schemaId: string, ref: string) => [any, string, string]}
8
+ */
9
+ export function resolveLocaleRefs(schema: import("ajv").SchemaObject, ajv: import("ajv/dist/2019.js").default, locale?: string, defaultLocale?: string): (schemaId: string, ref: string) => [any, string, string];
10
+ /**
11
+ * partially resolve a schema but not recursively, used for layout normalization
12
+ * @param {import('ajv').SchemaObject} schema
13
+ * @param {string} schemaId
14
+ * @param {(schemaId: string, ref: string) => [any, string, string]} getJSONRef
15
+ */
16
+ export function partialResolveRefs(schema: import("ajv").SchemaObject, schemaId: string, getJSONRef: (schemaId: string, ref: string) => [any, string, string]): any;
17
+ //# sourceMappingURL=resolve-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-refs.d.ts","sourceRoot":"","sources":["../../../src/compile/utils/resolve-refs.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,0CANW,OAAO,KAAK,EAAE,YAAY,OAC1B,OAAO,kBAAkB,EAAE,OAAO,WAClC,MAAM,kBACN,MAAM,GACJ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CASpE;AAuCD;;;;;GAKG;AACH,2CAJW,OAAO,KAAK,EAAE,YAAY,YAC1B,MAAM,cACN,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,OA+ClE"}
@@ -0,0 +1,2 @@
1
+ export function resolveXI18n(schema: Record<string, any>, locale: string, defaultLocale?: string): void;
2
+ //# sourceMappingURL=x-i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-i18n.d.ts","sourceRoot":"","sources":["../../../src/compile/utils/x-i18n.js"],"names":[],"mappings":"AAOO,qCAJI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UACnB,MAAM,kBACN,MAAM,QAkBhB"}
@@ -0,0 +1,25 @@
1
+ declare const _default: {
2
+ errorOneOf: string;
3
+ errorRequired: string;
4
+ addItem: string;
5
+ delete: string;
6
+ edit: string;
7
+ confirm: string;
8
+ close: string;
9
+ duplicate: string;
10
+ insertAfter: string;
11
+ copy: string;
12
+ paste: string;
13
+ sort: string;
14
+ up: string;
15
+ down: string;
16
+ showHelp: string;
17
+ default: string;
18
+ name: string;
19
+ examples: string;
20
+ deprecated: string;
21
+ keyboardDate: string;
22
+ keyboardDateTime: string;
23
+ };
24
+ export default _default;
25
+ //# sourceMappingURL=de.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../src/i18n/de.js"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ declare const _default: {
2
+ errorOneOf: string;
3
+ errorRequired: string;
4
+ addItem: string;
5
+ delete: string;
6
+ edit: string;
7
+ confirm: string;
8
+ close: string;
9
+ duplicate: string;
10
+ insertAfter: string;
11
+ copy: string;
12
+ paste: string;
13
+ sort: string;
14
+ up: string;
15
+ down: string;
16
+ showHelp: string;
17
+ default: string;
18
+ name: string;
19
+ examples: string;
20
+ deprecated: string;
21
+ keyboardDate: string;
22
+ keyboardDateTime: string;
23
+ };
24
+ export default _default;
25
+ //# sourceMappingURL=en.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.js"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ declare const _default: {
2
+ errorOneOf: string;
3
+ errorRequired: string;
4
+ addItem: string;
5
+ delete: string;
6
+ edit: string;
7
+ confirm: string;
8
+ close: string;
9
+ duplicate: string;
10
+ insertAfter: string;
11
+ copy: string;
12
+ paste: string;
13
+ sort: string;
14
+ up: string;
15
+ down: string;
16
+ showHelp: string;
17
+ default: string;
18
+ name: string;
19
+ examples: string;
20
+ deprecated: string;
21
+ keyboardDate: string;
22
+ keyboardDateTime: string;
23
+ };
24
+ export default _default;
25
+ //# sourceMappingURL=fr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../src/i18n/fr.js"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ en: import("./types.js").LocaleMessages;
3
+ fr: import("./types.js").LocaleMessages;
4
+ nl: import("./types.js").LocaleMessages;
5
+ de: import("./types.js").LocaleMessages;
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ declare const _default: {
2
+ errorOneOf: string;
3
+ errorRequired: string;
4
+ addItem: string;
5
+ delete: string;
6
+ confirm: string;
7
+ edit: string;
8
+ close: string;
9
+ duplicate: string;
10
+ insertAfter: string;
11
+ copy: string;
12
+ paste: string;
13
+ sort: string;
14
+ up: string;
15
+ down: string;
16
+ showHelp: string;
17
+ default: string;
18
+ name: string;
19
+ examples: string;
20
+ deprecated: string;
21
+ keyboardDate: string;
22
+ keyboardDateTime: string;
23
+ };
24
+ export default _default;
25
+ //# sourceMappingURL=nl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nl.d.ts","sourceRoot":"","sources":["../../src/i18n/nl.js"],"names":[],"mappings":""}