@es-joy/jsoe 0.16.0 → 0.17.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.
Files changed (208) hide show
  1. package/.ncurc.cjs +4 -5
  2. package/CHANGES.md +4 -0
  3. package/README.md +27 -3
  4. package/badges/licenses-badge.svg +1 -0
  5. package/dist/formatAndTypeChoices.d.ts +39 -19
  6. package/dist/formatAndTypeChoices.d.ts.map +1 -1
  7. package/dist/formats/indexedDBKey.d.ts +1 -1
  8. package/dist/formats/indexedDBKey.d.ts.map +1 -1
  9. package/dist/formats/json.d.ts +1 -1
  10. package/dist/formats/json.d.ts.map +1 -1
  11. package/dist/formats/schema.d.ts +11 -0
  12. package/dist/formats/schema.d.ts.map +1 -0
  13. package/dist/formats/structuredCloning.d.ts +11 -13
  14. package/dist/formats/structuredCloning.d.ts.map +1 -1
  15. package/dist/formats.d.ts +86 -25
  16. package/dist/formats.d.ts.map +1 -1
  17. package/dist/fundamentalTypes/BooleanObjectType.d.ts +1 -1
  18. package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
  19. package/dist/fundamentalTypes/NumberObjectType.d.ts +1 -1
  20. package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
  21. package/dist/fundamentalTypes/StringObjectType.d.ts +1 -1
  22. package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
  23. package/dist/fundamentalTypes/arrayReferenceType.d.ts +1 -1
  24. package/dist/fundamentalTypes/arrayType.d.ts +3 -3
  25. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  26. package/dist/fundamentalTypes/bigintObjectType.d.ts +6 -0
  27. package/dist/fundamentalTypes/bigintObjectType.d.ts.map +1 -0
  28. package/dist/fundamentalTypes/bigintType.d.ts +1 -1
  29. package/dist/fundamentalTypes/bigintType.d.ts.map +1 -1
  30. package/dist/fundamentalTypes/blobType.d.ts +1 -1
  31. package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
  32. package/dist/fundamentalTypes/booleanType.d.ts +8 -0
  33. package/dist/fundamentalTypes/booleanType.d.ts.map +1 -0
  34. package/dist/fundamentalTypes/catchType.d.ts +6 -0
  35. package/dist/fundamentalTypes/catchType.d.ts.map +1 -0
  36. package/dist/fundamentalTypes/dateType.d.ts +4 -4
  37. package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
  38. package/dist/fundamentalTypes/domexceptionType.d.ts +1 -1
  39. package/dist/fundamentalTypes/domexceptionType.d.ts.map +1 -1
  40. package/dist/fundamentalTypes/enumType.d.ts +6 -0
  41. package/dist/fundamentalTypes/enumType.d.ts.map +1 -0
  42. package/dist/fundamentalTypes/errorType.d.ts +1 -1
  43. package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
  44. package/dist/fundamentalTypes/fileType.d.ts +1 -1
  45. package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
  46. package/dist/fundamentalTypes/filelistType.d.ts +1 -1
  47. package/dist/fundamentalTypes/filelistType.d.ts.map +1 -1
  48. package/dist/fundamentalTypes/functionType.d.ts +6 -0
  49. package/dist/fundamentalTypes/functionType.d.ts.map +1 -0
  50. package/dist/fundamentalTypes/literalType.d.ts +6 -0
  51. package/dist/fundamentalTypes/literalType.d.ts.map +1 -0
  52. package/dist/fundamentalTypes/mapType.d.ts +1 -1
  53. package/dist/fundamentalTypes/mapType.d.ts.map +1 -1
  54. package/dist/fundamentalTypes/nanType.d.ts +6 -0
  55. package/dist/fundamentalTypes/nanType.d.ts.map +1 -0
  56. package/dist/fundamentalTypes/nativeEnumType.d.ts +6 -0
  57. package/dist/fundamentalTypes/nativeEnumType.d.ts.map +1 -0
  58. package/dist/fundamentalTypes/neverType.d.ts +6 -0
  59. package/dist/fundamentalTypes/neverType.d.ts.map +1 -0
  60. package/dist/fundamentalTypes/noneditableType.d.ts +1 -1
  61. package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -1
  62. package/dist/fundamentalTypes/nullType.d.ts +1 -1
  63. package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
  64. package/dist/fundamentalTypes/numberType.d.ts +1 -1
  65. package/dist/fundamentalTypes/numberType.d.ts.map +1 -1
  66. package/dist/fundamentalTypes/objectReferenceType.d.ts +1 -1
  67. package/dist/fundamentalTypes/objectType.d.ts +1 -1
  68. package/dist/fundamentalTypes/objectType.d.ts.map +1 -1
  69. package/dist/fundamentalTypes/promiseType.d.ts +6 -0
  70. package/dist/fundamentalTypes/promiseType.d.ts.map +1 -0
  71. package/dist/fundamentalTypes/recordType.d.ts +6 -0
  72. package/dist/fundamentalTypes/recordType.d.ts.map +1 -0
  73. package/dist/fundamentalTypes/regexpType.d.ts +1 -1
  74. package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
  75. package/dist/fundamentalTypes/setType.d.ts +1 -1
  76. package/dist/fundamentalTypes/setType.d.ts.map +1 -1
  77. package/dist/fundamentalTypes/sparseUndefinedType.d.ts +1 -1
  78. package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
  79. package/dist/fundamentalTypes/stringType.d.ts +1 -1
  80. package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
  81. package/dist/fundamentalTypes/symbolType.d.ts +8 -0
  82. package/dist/fundamentalTypes/symbolType.d.ts.map +1 -0
  83. package/dist/fundamentalTypes/tupleType.d.ts +6 -0
  84. package/dist/fundamentalTypes/tupleType.d.ts.map +1 -0
  85. package/dist/fundamentalTypes/undefinedType.d.ts +1 -1
  86. package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
  87. package/dist/fundamentalTypes/voidType.d.ts +6 -0
  88. package/dist/fundamentalTypes/voidType.d.ts.map +1 -0
  89. package/dist/index.d.ts +2 -2
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +9660 -1586
  92. package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
  93. package/dist/subTypes/falseType.d.ts +1 -1
  94. package/dist/subTypes/trueType.d.ts +1 -1
  95. package/dist/superTypes/SpecialNumberType.d.ts +1 -1
  96. package/dist/superTypes/SpecialRealNumberType.d.ts +1 -1
  97. package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
  98. package/dist/superTypes/buffersourceType.d.ts +1 -1
  99. package/dist/superTypes/buffersourceType.d.ts.map +1 -1
  100. package/dist/superTypes/dommatrixType.d.ts +1 -1
  101. package/dist/superTypes/dommatrixType.d.ts.map +1 -1
  102. package/dist/superTypes/dompointType.d.ts +1 -1
  103. package/dist/superTypes/dompointType.d.ts.map +1 -1
  104. package/dist/superTypes/domrectType.d.ts +1 -1
  105. package/dist/superTypes/domrectType.d.ts.map +1 -1
  106. package/dist/superTypes/errorsSpecialType.d.ts +1 -1
  107. package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
  108. package/dist/typeChoices.d.ts +33 -16
  109. package/dist/typeChoices.d.ts.map +1 -1
  110. package/dist/types.d.ts +161 -157
  111. package/dist/types.d.ts.map +1 -1
  112. package/dist/utils/dialogs.d.ts +3 -3
  113. package/dist/utils/dialogs.d.ts.map +1 -1
  114. package/dist/utils/jsonPointer.d.ts.map +1 -1
  115. package/dist/utils/media.d.ts.map +1 -1
  116. package/dist/utils/objects.d.ts +16 -0
  117. package/dist/utils/objects.d.ts.map +1 -0
  118. package/dist/utils/types.d.ts +1 -1
  119. package/dist/utils/types.d.ts.map +1 -1
  120. package/dist/vendor-imports.d.ts +1 -1
  121. package/eslint.config.js +74 -0
  122. package/licenseInfo.json +4 -0
  123. package/package.json +33 -42
  124. package/rollup.config.js +15 -0
  125. package/src/formatAndTypeChoices.js +68 -54
  126. package/src/formats/indexedDBKey.js +9 -4
  127. package/src/formats/json.js +7 -4
  128. package/src/formats/schema.js +772 -0
  129. package/src/formats/structuredCloning.js +187 -86
  130. package/src/formats.js +61 -26
  131. package/src/fundamentalTypes/BooleanObjectType.js +18 -6
  132. package/src/fundamentalTypes/NumberObjectType.js +18 -5
  133. package/src/fundamentalTypes/StringObjectType.js +20 -8
  134. package/src/fundamentalTypes/arrayType.js +1241 -533
  135. package/src/fundamentalTypes/bigintObjectType.js +64 -0
  136. package/src/fundamentalTypes/bigintType.js +31 -5
  137. package/src/fundamentalTypes/blobType.js +201 -190
  138. package/src/fundamentalTypes/booleanType.js +63 -0
  139. package/src/fundamentalTypes/catchType.js +140 -0
  140. package/src/fundamentalTypes/dateType.js +57 -19
  141. package/src/fundamentalTypes/domexceptionType.js +61 -63
  142. package/src/fundamentalTypes/enumType.js +52 -0
  143. package/src/fundamentalTypes/errorType.js +20 -7
  144. package/src/fundamentalTypes/fileType.js +195 -189
  145. package/src/fundamentalTypes/filelistType.js +4 -0
  146. package/src/fundamentalTypes/functionType.js +150 -0
  147. package/src/fundamentalTypes/literalType.js +81 -0
  148. package/src/fundamentalTypes/mapType.js +4 -0
  149. package/src/fundamentalTypes/nanType.js +41 -0
  150. package/src/fundamentalTypes/nativeEnumType.js +155 -0
  151. package/src/fundamentalTypes/neverType.js +44 -0
  152. package/src/fundamentalTypes/noneditableType.js +19 -5
  153. package/src/fundamentalTypes/nullType.js +16 -6
  154. package/src/fundamentalTypes/numberType.js +49 -6
  155. package/src/fundamentalTypes/objectType.js +10 -2
  156. package/src/fundamentalTypes/promiseType.js +60 -0
  157. package/src/fundamentalTypes/recordType.js +42 -0
  158. package/src/fundamentalTypes/regexpType.js +51 -33
  159. package/src/fundamentalTypes/setType.js +4 -0
  160. package/src/fundamentalTypes/sparseUndefinedType.js +3 -0
  161. package/src/fundamentalTypes/stringType.js +254 -6
  162. package/src/fundamentalTypes/symbolType.js +81 -0
  163. package/src/fundamentalTypes/tupleType.js +39 -0
  164. package/src/fundamentalTypes/undefinedType.js +14 -4
  165. package/src/fundamentalTypes/voidType.js +48 -0
  166. package/src/jsoe.css +37 -3
  167. package/src/subTypes/blobHTMLType.js +33 -24
  168. package/src/superTypes/SpecialRealNumberType.js +22 -6
  169. package/src/superTypes/buffersourceType.js +86 -30
  170. package/src/superTypes/dommatrixType.js +24 -7
  171. package/src/superTypes/dompointType.js +27 -7
  172. package/src/superTypes/domrectType.js +33 -7
  173. package/src/superTypes/errorsSpecialType.js +30 -14
  174. package/src/typeChoices.js +115 -44
  175. package/src/types.js +129 -45
  176. package/src/utils/FileList.js +3 -3
  177. package/src/utils/dialogs.js +6 -8
  178. package/src/utils/objects.js +22 -0
  179. package/src/vendor-imports.js +1 -1
  180. package/tsconfig.json +2 -2
  181. package/vendor/jamilih/dist/jml-es.js +23 -6
  182. package/vendor/typeson-registry/dist/index.js +77 -47
  183. package/vendor/zod/lib/index.mjs +4236 -0
  184. package/vendor/zodex/dist/esm/dezerialize.d.ts +26 -0
  185. package/vendor/zodex/dist/esm/dezerialize.js +393 -0
  186. package/vendor/zodex/dist/esm/index.d.ts +9 -0
  187. package/vendor/zodex/dist/esm/index.js +4 -0
  188. package/vendor/zodex/dist/esm/infer.d.ts +29 -0
  189. package/vendor/zodex/dist/esm/infer.js +1 -0
  190. package/vendor/zodex/dist/esm/package.json +1 -0
  191. package/vendor/zodex/dist/esm/types.d.ts +201 -0
  192. package/vendor/zodex/dist/esm/types.js +13 -0
  193. package/vendor/zodex/dist/esm/ui.d.ts +23 -0
  194. package/vendor/zodex/dist/esm/ui.js +10 -0
  195. package/vendor/zodex/dist/esm/zerialize.d.ts +50 -0
  196. package/vendor/zodex/dist/esm/zerialize.js +417 -0
  197. package/vendor/zodex/dist/esm/zod-types.d.ts +11 -0
  198. package/vendor/zodex/dist/esm/zod-types.js +1 -0
  199. package/.eslintignore +0 -13
  200. package/.eslintrc.cjs +0 -145
  201. package/.nyc_output/out.json +0 -117370
  202. package/cypress.config.ts +0 -15
  203. package/demo/index-instrumented.html +0 -29
  204. package/demo/index-instrumented.js +0 -644
  205. package/demo/index.html +0 -29
  206. package/demo/index.js +0 -215
  207. package/src/formats/schemaAndArbitrary.js +0 -20
  208. package/src/formats/schemaOnly.js +0 -539
package/src/types.js CHANGED
@@ -12,18 +12,27 @@ import {$e, $$e} from './utils/templateUtils.js';
12
12
  import nullType from './fundamentalTypes/nullType.js';
13
13
  import trueType from './subTypes/trueType.js';
14
14
  import falseType from './subTypes/falseType.js';
15
+ import nanType from './fundamentalTypes/nanType.js';
16
+ import symbolType from './fundamentalTypes/symbolType.js';
15
17
  import blobHTMLType from './subTypes/blobHTMLType.js';
18
+ import booleanType from './fundamentalTypes/booleanType.js';
16
19
  import numberType from './fundamentalTypes/numberType.js';
17
20
  import bigintType from './fundamentalTypes/bigintType.js';
21
+ import bigintObjectType from './fundamentalTypes/bigintObjectType.js';
18
22
  import stringType from './fundamentalTypes/stringType.js';
19
23
  import arrayReferenceType from './fundamentalTypes/arrayReferenceType.js';
20
24
  import objectReferenceType from './fundamentalTypes/objectReferenceType.js';
21
25
  import arrayType from './fundamentalTypes/arrayType.js';
26
+ import tupleType from './fundamentalTypes/tupleType.js';
22
27
  import objectType from './fundamentalTypes/objectType.js';
28
+ import recordType from './fundamentalTypes/recordType.js';
23
29
  import dateType from './fundamentalTypes/dateType.js';
30
+ import enumType from './fundamentalTypes/enumType.js';
24
31
  import setType from './fundamentalTypes/setType.js';
25
32
  import mapType from './fundamentalTypes/mapType.js';
33
+ import literalType from './fundamentalTypes/literalType.js';
26
34
  import undefinedType from './fundamentalTypes/undefinedType.js';
35
+ import voidType from './fundamentalTypes/voidType.js';
27
36
  import regexpType from './fundamentalTypes/regexpType.js';
28
37
  import BooleanObjectType from './fundamentalTypes/BooleanObjectType.js';
29
38
  import NumberObjectType from './fundamentalTypes/NumberObjectType.js';
@@ -43,6 +52,11 @@ import dompointType from './superTypes/dompointType.js';
43
52
  import dommatrixType from './superTypes/dommatrixType.js';
44
53
  import buffersourceType from './superTypes/buffersourceType.js';
45
54
  import noneditableType from './fundamentalTypes/noneditableType.js';
55
+ import neverType from './fundamentalTypes/neverType.js';
56
+ import promiseType from './fundamentalTypes/promiseType.js';
57
+ import functionType from './fundamentalTypes/functionType.js';
58
+ import catchType from './fundamentalTypes/catchType.js';
59
+ import nativeEnumType from './fundamentalTypes/nativeEnumType.js';
46
60
 
47
61
  /**
48
62
  * Utility to retrieve the property value given a legend element.
@@ -113,9 +127,15 @@ export const getPropertyValueFromLegend = (legend) => {
113
127
  * HTMLButtonElement}
114
128
  */
115
129
 
130
+ /**
131
+ * @typedef {number} Integer
132
+ */
133
+
116
134
  /**
117
135
  * @callback GetOptionForType
118
136
  * @param {AvailableType} type
137
+ * @param {import('./formatAndTypeChoices.js').ZodexSchema|
138
+ * undefined} [schemaContent]
119
139
  * @returns {[string, {value: AvailableType, title?: string}]}
120
140
  */
121
141
 
@@ -123,18 +143,16 @@ export const getPropertyValueFromLegend = (legend) => {
123
143
  * @callback GetTypeOptionsForFormatAndState
124
144
  * @param {import('./formats.js').AvailableFormat} format
125
145
  * @param {string} [parserState]
126
- * @returns {[string, {value: AvailableType, title?: string}][]}
146
+ * @param {import('./formatAndTypeChoices.js').ZodexSchema|
147
+ * undefined} [schemaContent]
148
+ * @param {import('./formatAndTypeChoices.js').ZodexSchema|
149
+ * undefined} [schemaOriginal]
150
+ * @returns {{
151
+ * typeOptions: [string, {value: AvailableType, title?: string}][],
152
+ * schemaObjects: import('./formats/schema.js').ZodexSchema[]
153
+ * }}
127
154
  */
128
155
 
129
- /**
130
- * @typedef {(
131
- * keypath: string,
132
- * parentPath: string,
133
- * arrayOrObjectPropertyName: string,
134
- * valueType: string
135
- * ) => StateObject} GetPossibleSchemasForPathAndType
136
- */
137
-
138
156
  /**
139
157
  * @typedef {{
140
158
  * typeNamespace?: string,
@@ -145,8 +163,10 @@ export const getPropertyValueFromLegend = (legend) => {
145
163
  * error?: Error,
146
164
  * rootUI?: Element,
147
165
  * schema?: string,
148
- * schemaContent?: object,
149
- * getPossibleSchemasForPathAndType?: GetPossibleSchemasForPathAndType,
166
+ * schemaParent?: import('./formats/schema.js').ZodexSchema,
167
+ * schemaContent?: import('./formats/schema.js').ZodexSchema,
168
+ * specificSchema?: import('./formats/schema.js').ZodexSchema,
169
+ * specificSchemas?: import('./formats/schema.js').ZodexSchema[],
150
170
  * paths?: {[currentPath: string]: {
151
171
  * referentPath: string,
152
172
  * expectArrayReferent: boolean
@@ -166,11 +186,12 @@ export const getPropertyValueFromLegend = (legend) => {
166
186
  * bringIntoFocus?: boolean|undefined,
167
187
  * buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
168
188
  * format: import('./formats.js').AvailableFormat,
169
- * schemaContent?: object
170
- * schemaState?: GetPossibleSchemasForPathAndType,
189
+ * schemaContent?: import('./formats/schema.js').ZodexSchema
190
+ * specificSchemaObject?: import('./formats/schema.js').ZodexSchema
171
191
  * value: StructuredCloneValue,
172
192
  * hasValue: boolean,
173
193
  * replaced?: StructuredCloneValue,
194
+ * schemaFallingBack?: boolean
174
195
  * }) => HTMLElement} GetUIForModeAndType
175
196
  */
176
197
  /* eslint-enable jsdoc/valid-types -- readonly reserved */
@@ -193,7 +214,8 @@ export const getPropertyValueFromLegend = (legend) => {
193
214
  * @typedef {(cfg: {
194
215
  * type: AvailableType,
195
216
  * root: RootElement,
196
- * topRoot?: RootElement
217
+ * topRoot?: RootElement,
218
+ * avoidReport?: boolean
197
219
  * }) => boolean} Validate
198
220
  */
199
221
 
@@ -218,7 +240,9 @@ export const getPropertyValueFromLegend = (legend) => {
218
240
  * path: string
219
241
  * ][],
220
242
  * parent?: {[key: string]: any},
221
- * parentPath?: string|number
243
+ * parentPath?: string|number,
244
+ * schemaObject?: import('./formatAndTypeChoices.js').ZodexSchema|undefined
245
+ * schemaOriginal?: import('./formatAndTypeChoices.js').ZodexSchema|undefined
222
246
  * }) => [
223
247
  * value: StructuredCloneValue,
224
248
  * remnant: string,
@@ -256,6 +280,7 @@ export const getPropertyValueFromLegend = (legend) => {
256
280
  * parent?: object,
257
281
  * parentPath?: string|number,
258
282
  * types?: Types
283
+ * schemaObject?: import('./formatAndTypeChoices.js').ZodexSchema|undefined
259
284
  * }} RootInfo
260
285
  */
261
286
 
@@ -289,6 +314,10 @@ export const getPropertyValueFromLegend = (legend) => {
289
314
  * it is a `Map`. Do not use in other types.
290
315
  * @property {boolean} [set] Private context variable. Whether or not
291
316
  * it is a `Set`. Do not use in other types.
317
+ * @property {boolean} [record] Private context variable. Whether or not
318
+ * it is a `Record`. Do not use in other types.
319
+ * @property {boolean} [tuple] Private context variable. Whether or not
320
+ * it is a tuple type. Do not use in other types.
292
321
  * @property {boolean} [filelist] Private context variable. Whether or not
293
322
  * it is a `FileList` type. Do not use in other types.
294
323
  * @property {boolean} [sparse] Private context variable. Whether or not
@@ -303,8 +332,10 @@ export const getPropertyValueFromLegend = (legend) => {
303
332
  * present, use `stringRegex`
304
333
  * @property {RegExp} [stringRegexEnd] Used for string parsing. If not
305
334
  * present, use `stringRegex`
306
- * @property {(v: StructuredCloneValue) => boolean} [valueMatch] Function to
307
- * check whether this subtype matches
335
+ * @property {(
336
+ * v: StructuredCloneValue
337
+ * ) => boolean} [valueMatch] Function to check whether this type or subtype
338
+ * matches
308
339
  * @property {string} [superType] The greater fundamental type to which
309
340
  * the type belongs
310
341
  * @property {ToValue} [toValue] Converts from string to value. May use
@@ -325,7 +356,12 @@ export const getPropertyValueFromLegend = (legend) => {
325
356
  * topRoot?: HTMLDivElement,
326
357
  * resultType?: "keys"|"values"|"both",
327
358
  * format: import('./formats.js').AvailableFormat,
359
+ * specificSchemaObject?: import('./formats/schema.js').ZodexSchema,
328
360
  * types: Types
361
+ * bringIntoFocus?: boolean|undefined,
362
+ * buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
363
+ * schemaContent?: import('./formats/schema.js').ZodexSchema
364
+ * replaced?: any
329
365
  * }) => JamilihArray} viewUI
330
366
  * @property {(info: {
331
367
  * value?: StructuredCloneValue,
@@ -336,9 +372,12 @@ export const getPropertyValueFromLegend = (legend) => {
336
372
  * types: Types,
337
373
  * resultType?: "keys"|"values"|"both",
338
374
  * type?: AvailableType,
339
- * arrayState?: string,
375
+ * forcedState?: string,
340
376
  * buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
341
377
  * topRoot?: HTMLDivElement
378
+ * schemaContent?: import('./formats/schema.js').ZodexSchema,
379
+ * specificSchemaObject?: import('./formats/schema.js').ZodexSchema,
380
+ * schemaFallingBack?: boolean
342
381
  * }) => JamilihArray} editUI
343
382
  * @property {(info: {root: HTMLDivElement}) =>
344
383
  * HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
@@ -368,7 +407,8 @@ export const getPropertyValueFromLegend = (legend) => {
368
407
  */
369
408
 
370
409
  /**
371
- * @typedef {"null"|"true"|"false"|"number"|"bigint"|"string"|"arrayReference"|
410
+ * @typedef {"null"|"true"|"false"|"number"|"bigint"|"bigintObject"|
411
+ * "string"|"arrayReference"|
372
412
  * "objectReference"|"array"|"object"|"date"|"userObject"|"undef"|
373
413
  * "SpecialRealNumber"|"SpecialNumber"|"regexp"|"BooleanObject"|
374
414
  * "NumberObject"|"StringObject"|"map"|"set"|"file"|"filelist"|"blobHTML"|
@@ -376,8 +416,12 @@ export const getPropertyValueFromLegend = (legend) => {
376
416
  * "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
377
417
  * "int32array"|"uint32array"|"float32array"|"float64array"|"ValidDate"|
378
418
  * "arrayNonindexKeys"|"error"|"errors"|"blob"|"domexception"|"domrect"|
379
- * "dompoint"|"dommatrix"|"resurrectable"} AvailableType
419
+ * "dompoint"|"dommatrix"|"resurrectable"|"boolean"|"nan"|"tuple"|
420
+ * "record"|"void"|"enum"|"literal"|"symbol"|"never"|"promise"|
421
+ * "function"|"catch"|"nativeEnum"
422
+ * } AvailableType
380
423
  */
424
+ // Todo: When done with function/promise/symbol, move off here
381
425
 
382
426
  /**
383
427
  * @typedef {TypeObject & {
@@ -406,17 +450,24 @@ class Types {
406
450
  null: nullType,
407
451
  true: trueType,
408
452
  false: falseType,
453
+ nan: nanType, // Schema type
454
+ symbol: symbolType, // Non-cloning type
455
+ boolean: booleanType, // Schema type
409
456
  number: numberType,
410
457
  bigint: bigintType,
458
+ bigintObject: bigintObjectType,
411
459
  string: stringType,
412
460
  arrayReference: arrayReferenceType,
413
461
  objectReference: objectReferenceType,
414
462
  array: arrayType,
463
+ tuple: tupleType, // Schema type
415
464
  // Note: We don't do for BooleanObject/NumberObject/StringObject, date,
416
465
  // regexp, as added properties on them are not being cloned (in Chrome
417
466
  // at least)
418
467
  object: objectType,
468
+ record: recordType, // Schema type
419
469
  date: dateType,
470
+ enum: enumType,
420
471
 
421
472
  // This type is only for throwing upon cloning errors:
422
473
  // 'checkDataCloneException'
@@ -424,6 +475,7 @@ class Types {
424
475
  // passed in:
425
476
  userObject: ['User objects'],
426
477
  undef: undefinedType,
478
+ void: voidType,
427
479
  SpecialRealNumber: SpecialRealNumberSuperType,
428
480
  SpecialNumber: SpecialNumberSuperType,
429
481
 
@@ -435,6 +487,8 @@ class Types {
435
487
  NumberObject: NumberObjectType,
436
488
  StringObject: StringObjectType,
437
489
 
490
+ literal: literalType,
491
+
438
492
  map: mapType,
439
493
  set: setType,
440
494
 
@@ -449,6 +503,11 @@ class Types {
449
503
  dommatrix: dommatrixType,
450
504
 
451
505
  resurrectable: noneditableType,
506
+ never: neverType,
507
+ promise: promiseType,
508
+ function: functionType,
509
+ catch: catchType,
510
+ nativeEnum: nativeEnumType,
452
511
 
453
512
  buffersource: buffersourceType,
454
513
  dataview: {
@@ -575,9 +634,9 @@ class Types {
575
634
  async getControlsForFormatAndValue (
576
635
  format, record, stateObj
577
636
  ) {
578
- return await this.formats.getControlsForFormatAndValue(
637
+ return (await this.formats.getControlsForFormatAndValue(
579
638
  this, format, record, stateObj
580
- );
639
+ )).rootUI;
581
640
  }
582
641
 
583
642
  /**
@@ -647,7 +706,7 @@ class Types {
647
706
  }
648
707
 
649
708
  /** @type {GetOptionForType} */
650
- getOptionForType (type) {
709
+ getOptionForType (type, schemaContent = undefined) {
651
710
  const availableType = /** @type {TypeObject} */ (
652
711
  this.availableTypes[type]
653
712
  );
@@ -655,46 +714,64 @@ class Types {
655
714
  const optInfo = [
656
715
  ...availableType.option
657
716
  ];
658
- optInfo[1] = {value: type, ...(optInfo[1])};
717
+
718
+ if (schemaContent && schemaContent.description) {
719
+ optInfo[0] = `${optInfo[0]} (${schemaContent.description})`;
720
+ }
721
+
722
+ optInfo[1] = {
723
+ value: type,
724
+ ...(optInfo[1])
725
+ };
659
726
  return /** @type {[string, {value: AvailableType, title?: string}]} */ (
660
727
  optInfo
661
728
  );
662
729
  }
663
730
 
664
731
  /** @type {GetTypeOptionsForFormatAndState} */
665
- getTypeOptionsForFormatAndState (format, parserState) {
666
- const typesForFormatAndState = this.formats.getTypesForFormatAndState(
667
- this, format, parserState
668
- );
732
+ getTypeOptionsForFormatAndState (
733
+ format, parserState, schemaContent, schemaOriginal
734
+ ) {
735
+ const typesForFormatAndState =
736
+ this.formats.getTypesAndSchemasForFormatAndState(
737
+ this, format, parserState, schemaContent, schemaOriginal
738
+ );
669
739
  if (!typesForFormatAndState) {
670
740
  throw new Error('Unexpected type for format and state');
671
741
  }
672
742
 
673
- return typesForFormatAndState.map((type) => {
674
- return this.getOptionForType(type);
675
- });
743
+ return {
744
+ typeOptions: typesForFormatAndState.types.map((type, idx) => {
745
+ return this.getOptionForType(
746
+ type, typesForFormatAndState.schemaObjects[idx]
747
+ );
748
+ }),
749
+ schemaObjects: typesForFormatAndState.schemaObjects
750
+ };
676
751
  }
677
752
 
678
753
  /** @type {GetUIForModeAndType} */
679
754
  getUIForModeAndType ({
680
755
  readonly, resultType, typeNamespace, type, topRoot, bringIntoFocus,
681
- buildTypeChoices, format, schemaContent, schemaState, value, hasValue,
682
- replaced
756
+ buildTypeChoices, format, schemaContent, value, hasValue,
757
+ replaced, specificSchemaObject, schemaFallingBack
683
758
  }) {
684
759
  const typeObj = /** @type {TypeObject} */ (this.availableTypes[type]);
685
760
  const arg = hasValue
686
761
  ? {
687
762
  typeNamespace, type, buildTypeChoices,
688
- format, schemaContent, schemaState,
763
+ format, schemaContent,
689
764
  resultType, topRoot, bringIntoFocus, value,
690
765
  replaced,
766
+ specificSchemaObject, schemaFallingBack,
691
767
  types: this
692
768
  }
693
769
  : {
694
770
  typeNamespace, type, buildTypeChoices,
695
- format, schemaContent, schemaState,
771
+ format, schemaContent,
696
772
  resultType, topRoot, bringIntoFocus,
697
773
  replaced,
774
+ specificSchemaObject, schemaFallingBack,
698
775
  types: this
699
776
  };
700
777
  const root = /** @type {HTMLDivElement} */ (jml(
@@ -734,7 +811,7 @@ class Types {
734
811
  }
735
812
 
736
813
  /** @type {Validate} */
737
- validate ({type, root, topRoot}) {
814
+ validate ({type, root, topRoot, avoidReport}) {
738
815
  const typeObj = /** @type {TypeObject} */ (this.availableTypes[type]);
739
816
  // Todo (low): We limit for now to input boxes which have `validate`
740
817
  if (typeObj.validate) {
@@ -746,7 +823,13 @@ class Types {
746
823
  /* istanbul ignore next -- Should always have a message */
747
824
  : message || 'Invalid'
748
825
  );
749
- formControl.reportValidity();
826
+
827
+ // We don't want a focus as `reportValidity` does in at least
828
+ // some cases, but blur() would cause user to
829
+ // leave input (used during input handler)
830
+ if (!avoidReport) {
831
+ formControl.reportValidity();
832
+ }
750
833
  return valid;
751
834
  }
752
835
  return true;
@@ -772,11 +855,11 @@ class Types {
772
855
  /** @type {GetValueForString} */
773
856
  getValueForString (s, {
774
857
  format, state, endMatchTypeObjs = [], firstRun = true,
775
- rootHolder = [], parent, parentPath
858
+ rootHolder = [], parent, parentPath, schemaObject, schemaOriginal
776
859
  }) {
777
- const allowedTypes = this.formats.getTypesForFormatAndState(
778
- this, format, state
779
- );
860
+ const allowedTypes = this.formats.getTypesAndSchemasForFormatAndState(
861
+ this, format, state, schemaObject, schemaOriginal
862
+ )?.types;
780
863
  if (!allowedTypes) {
781
864
  throw new Error('Could not get types for format and state');
782
865
  }
@@ -866,7 +949,8 @@ class Types {
866
949
  remnant,
867
950
  rootHolder,
868
951
  parent,
869
- parentPath
952
+ parentPath,
953
+ schemaObject
870
954
  }
871
955
  );
872
956
  /* istanbul ignore next -- Good regexes should prevent */
@@ -982,9 +1066,9 @@ Types.validValuesSet = ({form, typeNamespace, keySelectClass}) => {
982
1066
  * @param {string} str
983
1067
  * @returns {string}
984
1068
  */
985
- function escapeRegex (str) {
1069
+ export function escapeRegex (str) {
986
1070
  return String(str).
987
- replaceAll(/[.\\+*?^[\]$(){}=!<>|:-]/gu, '\\$&');
1071
+ replaceAll(/[.\\+*?^[\]$(){}=!<>|:-]/gu, String.raw`\$&`);
988
1072
  }
989
1073
 
990
1074
  export default Types;
@@ -9,7 +9,7 @@ class FileList {
9
9
  * Set private properties and length.
10
10
  */
11
11
  constructor () {
12
- // eslint-disable-next-line prefer-rest-params
12
+ // eslint-disable-next-line prefer-rest-params -- Keep API
13
13
  this._files = arguments[0];
14
14
  this.length = this._files.length;
15
15
  }
@@ -20,12 +20,12 @@ class FileList {
20
20
  item (index) {
21
21
  return this._files[index];
22
22
  }
23
- /* eslint-disable class-methods-use-this */
23
+ /* eslint-disable class-methods-use-this -- API */
24
24
  /**
25
25
  * @returns {"FileList"}
26
26
  */
27
27
  get [Symbol.toStringTag] () {
28
- /* eslint-enable class-methods-use-this */
28
+ /* eslint-enable class-methods-use-this -- API */
29
29
  return 'FileList';
30
30
  }
31
31
  }
@@ -1,4 +1,4 @@
1
- /* eslint-disable promise/avoid-new */
1
+ /* eslint-disable promise/avoid-new -- Our own API */
2
2
  import {jml, nbsp, body} from '../vendor-imports.js';
3
3
  import {$e} from './templateUtils.js';
4
4
 
@@ -45,9 +45,7 @@ const dialogs = {
45
45
  atts.$on.close = /** @type {import('jamilih').EventHandler} */ (close);
46
46
  }
47
47
  }
48
- const dialog = /** @type {HTMLDialogElement} */ (
49
- jml('dialog', atts, children, body)
50
- );
48
+ const dialog = jml('dialog', atts, children, body);
51
49
  dialog.showModal();
52
50
  if (remove) {
53
51
  dialog.addEventListener('close', () => {
@@ -134,7 +132,7 @@ const dialogs = {
134
132
  const {submitClass = 'submit'} = message;
135
133
  const {message: outputMessage} = message;
136
134
  return new Promise((resolve /* , _reject */) => {
137
- const dialog = /** @type {HTMLDialogElement} */ (jml('dialog', [
135
+ const dialog = jml('dialog', [
138
136
  /** @type {string|import('jamilih').JamilihArray} */ (outputMessage),
139
137
  ['br'], ['br'],
140
138
  ['div', {class: submitClass}, [
@@ -143,7 +141,7 @@ const dialogs = {
143
141
  resolve();
144
142
  }}}, [this.localeStrings.ok]]
145
143
  ]]
146
- ], body));
144
+ ], body);
147
145
  dialog.showModal();
148
146
  });
149
147
  },
@@ -160,7 +158,7 @@ const dialogs = {
160
158
  resolve,
161
159
  reject
162
160
  ) => {
163
- const dialog = /** @type {HTMLDialogElement} */ (jml('dialog', atts, [
161
+ const dialog = jml('dialog', atts, [
164
162
  message,
165
163
  ['br'], ['br'],
166
164
  ['div', {class: submitClass}, [
@@ -174,7 +172,7 @@ const dialogs = {
174
172
  reject(new Error('cancelled'));
175
173
  }}}, [this.localeStrings.cancel]]
176
174
  ]]
177
- ], body));
175
+ ], body);
178
176
  dialog.showModal();
179
177
  });
180
178
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @typedef {any} ArbitraryObject
3
+ */
4
+ /**
5
+ * @typedef {{[key: string]: string|NestedObject}} NestedObject
6
+ */
7
+
8
+ /**
9
+ * @param {ArbitraryObject} obj
10
+ * @returns {ArbitraryObject}
11
+ */
12
+ export function copyObject (obj) {
13
+ const newObj = Array.isArray(obj)
14
+ ? /** @type {Array<ArbitraryObject> & {[key: string]: ArbitraryObject}} */ (
15
+ []
16
+ )
17
+ : /** @type {NestedObject} */ ({});
18
+ for (const [prop, val] of Object.entries(obj)) {
19
+ newObj[prop] = val && typeof val === 'object' ? copyObject(val) : val;
20
+ }
21
+ return newObj;
22
+ }
@@ -3,6 +3,6 @@ export {jml, body, nbsp, $} from 'jamilih';
3
3
 
4
4
  export {
5
5
  getJSONType, Typeson, unescapeKeyPathComponent, structuredCloningThrowing,
6
- resurrectable, toStringTag
6
+ resurrectable, toStringTag, hasConstructorOf
7
7
  } from 'typeson-registry';
8
8
  // } from '../node_modules/typeson-registry/dist/index.js';
package/tsconfig.json CHANGED
@@ -10,9 +10,9 @@
10
10
  "declarationMap": true,
11
11
  "emitDeclarationOnly": true,
12
12
  "strict": true,
13
- "target": "es6",
13
+ "target": "es2020",
14
14
  "outDir": "dist"
15
15
  },
16
16
  "include": ["src/**/*.js", "typings/sceditor.d.ts"],
17
- "exclude": ["node_modules", "src/deepEqual.js", "src/formats/schemaOnly.js", "src/formats/schemaAndArbitrary.js", "./src/index.ts", "./dist/**/*.js"]
17
+ "exclude": ["node_modules", "src/deepEqual.js", "src/formats/schema.js", "./src/index.ts", "./dist/**/*.js"]
18
18
  }
@@ -766,15 +766,27 @@ function getMatchingPlugin(opts, pluginName) {
766
766
  });
767
767
  }
768
768
 
769
+ /* eslint-disable jsdoc/valid-types -- pratt parser bug */
770
+ /**
771
+ * @template T
772
+ * @typedef {T[keyof T]} ValueOf
773
+ */
774
+ /* eslint-enable jsdoc/valid-types -- pratt parser bug */
775
+
776
+ /* eslint-disable jsdoc/valid-types -- pratt parser bug */
769
777
  /**
770
778
  * Creates an XHTML or HTML element (XHTML is preferred, but only in browsers
771
779
  * that support); any element after element can be omitted, and any subsequent
772
780
  * type or types added afterwards.
773
- * @param {JamilihArray} args
774
- * @returns {JamilihReturn} The newly created (and possibly already appended)
781
+ * @template {JamilihArray} T
782
+ * @param {T} args
783
+ * @returns {T extends [keyof HTMLElementTagNameMap, any?, any?, any?]
784
+ * ? HTMLElementTagNameMap[T[0]] : JamilihReturn}
785
+ * The newly created (and possibly already appended)
775
786
  * element or array of elements
776
787
  */
777
788
  const jml = function jml(...args) {
789
+ /* eslint-enable jsdoc/valid-types -- pratt parser bug */
778
790
  if (!win) {
779
791
  throw new Error('No window object');
780
792
  }
@@ -1353,9 +1365,11 @@ const jml = function jml(...args) {
1353
1365
  case 'null':
1354
1366
  // null always indicates a place-holder (only needed for last argument if want array returned)
1355
1367
  if (i === argc - 1) {
1356
- return nodes.length <= 1 ? nodes[0]
1357
- // eslint-disable-next-line unicorn/no-array-callback-reference
1358
- : nodes.reduce(_fragReducer, doc.createDocumentFragment()); // nodes;
1368
+ // Casting needing unless changing `jml()` signature with overloads
1369
+ return (/** @type {ArbitraryValue} */nodes.length <= 1 ? nodes[0]
1370
+ // eslint-disable-next-line unicorn/no-array-callback-reference
1371
+ : nodes.reduce(_fragReducer, doc.createDocumentFragment())
1372
+ ); // nodes;
1359
1373
  }
1360
1374
 
1361
1375
  throw new TypeError(`\`null\` values not allowed except as final Jamilih argument; index ${i} on args: ${JSON.stringify(args)}`);
@@ -1567,7 +1581,10 @@ const jml = function jml(...args) {
1567
1581
  if (isRoot && opts.$map && /** @type {MapWithRoot} */opts.$map.root) {
1568
1582
  setMap(true);
1569
1583
  }
1570
- return ret;
1584
+
1585
+ // Casting needing unless changing `jml()` signature with overloads
1586
+ return (/** @type {ArbitraryValue} */ret
1587
+ );
1571
1588
  };
1572
1589
 
1573
1590
  /**