@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.
- package/.ncurc.cjs +4 -5
- package/CHANGES.md +4 -0
- package/README.md +27 -3
- package/badges/licenses-badge.svg +1 -0
- package/dist/formatAndTypeChoices.d.ts +39 -19
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/indexedDBKey.d.ts +1 -1
- package/dist/formats/indexedDBKey.d.ts.map +1 -1
- package/dist/formats/json.d.ts +1 -1
- package/dist/formats/json.d.ts.map +1 -1
- package/dist/formats/schema.d.ts +11 -0
- package/dist/formats/schema.d.ts.map +1 -0
- package/dist/formats/structuredCloning.d.ts +11 -13
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/formats.d.ts +86 -25
- package/dist/formats.d.ts.map +1 -1
- package/dist/fundamentalTypes/BooleanObjectType.d.ts +1 -1
- package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/NumberObjectType.d.ts +1 -1
- package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/StringObjectType.d.ts +1 -1
- package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayReferenceType.d.ts +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts +3 -3
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintObjectType.d.ts +6 -0
- package/dist/fundamentalTypes/bigintObjectType.d.ts.map +1 -0
- package/dist/fundamentalTypes/bigintType.d.ts +1 -1
- package/dist/fundamentalTypes/bigintType.d.ts.map +1 -1
- package/dist/fundamentalTypes/blobType.d.ts +1 -1
- package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
- package/dist/fundamentalTypes/booleanType.d.ts +8 -0
- package/dist/fundamentalTypes/booleanType.d.ts.map +1 -0
- package/dist/fundamentalTypes/catchType.d.ts +6 -0
- package/dist/fundamentalTypes/catchType.d.ts.map +1 -0
- package/dist/fundamentalTypes/dateType.d.ts +4 -4
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/domexceptionType.d.ts +1 -1
- package/dist/fundamentalTypes/domexceptionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/enumType.d.ts +6 -0
- package/dist/fundamentalTypes/enumType.d.ts.map +1 -0
- package/dist/fundamentalTypes/errorType.d.ts +1 -1
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
- package/dist/fundamentalTypes/fileType.d.ts +1 -1
- package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
- package/dist/fundamentalTypes/filelistType.d.ts +1 -1
- package/dist/fundamentalTypes/filelistType.d.ts.map +1 -1
- package/dist/fundamentalTypes/functionType.d.ts +6 -0
- package/dist/fundamentalTypes/functionType.d.ts.map +1 -0
- package/dist/fundamentalTypes/literalType.d.ts +6 -0
- package/dist/fundamentalTypes/literalType.d.ts.map +1 -0
- package/dist/fundamentalTypes/mapType.d.ts +1 -1
- package/dist/fundamentalTypes/mapType.d.ts.map +1 -1
- package/dist/fundamentalTypes/nanType.d.ts +6 -0
- package/dist/fundamentalTypes/nanType.d.ts.map +1 -0
- package/dist/fundamentalTypes/nativeEnumType.d.ts +6 -0
- package/dist/fundamentalTypes/nativeEnumType.d.ts.map +1 -0
- package/dist/fundamentalTypes/neverType.d.ts +6 -0
- package/dist/fundamentalTypes/neverType.d.ts.map +1 -0
- package/dist/fundamentalTypes/noneditableType.d.ts +1 -1
- package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -1
- package/dist/fundamentalTypes/nullType.d.ts +1 -1
- package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
- package/dist/fundamentalTypes/numberType.d.ts +1 -1
- package/dist/fundamentalTypes/numberType.d.ts.map +1 -1
- package/dist/fundamentalTypes/objectReferenceType.d.ts +1 -1
- package/dist/fundamentalTypes/objectType.d.ts +1 -1
- package/dist/fundamentalTypes/objectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/promiseType.d.ts +6 -0
- package/dist/fundamentalTypes/promiseType.d.ts.map +1 -0
- package/dist/fundamentalTypes/recordType.d.ts +6 -0
- package/dist/fundamentalTypes/recordType.d.ts.map +1 -0
- package/dist/fundamentalTypes/regexpType.d.ts +1 -1
- package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
- package/dist/fundamentalTypes/setType.d.ts +1 -1
- package/dist/fundamentalTypes/setType.d.ts.map +1 -1
- package/dist/fundamentalTypes/sparseUndefinedType.d.ts +1 -1
- package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/fundamentalTypes/symbolType.d.ts +8 -0
- package/dist/fundamentalTypes/symbolType.d.ts.map +1 -0
- package/dist/fundamentalTypes/tupleType.d.ts +6 -0
- package/dist/fundamentalTypes/tupleType.d.ts.map +1 -0
- package/dist/fundamentalTypes/undefinedType.d.ts +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/voidType.d.ts +6 -0
- package/dist/fundamentalTypes/voidType.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9660 -1586
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/subTypes/falseType.d.ts +1 -1
- package/dist/subTypes/trueType.d.ts +1 -1
- package/dist/superTypes/SpecialNumberType.d.ts +1 -1
- package/dist/superTypes/SpecialRealNumberType.d.ts +1 -1
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
- package/dist/superTypes/buffersourceType.d.ts +1 -1
- package/dist/superTypes/buffersourceType.d.ts.map +1 -1
- package/dist/superTypes/dommatrixType.d.ts +1 -1
- package/dist/superTypes/dommatrixType.d.ts.map +1 -1
- package/dist/superTypes/dompointType.d.ts +1 -1
- package/dist/superTypes/dompointType.d.ts.map +1 -1
- package/dist/superTypes/domrectType.d.ts +1 -1
- package/dist/superTypes/domrectType.d.ts.map +1 -1
- package/dist/superTypes/errorsSpecialType.d.ts +1 -1
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
- package/dist/typeChoices.d.ts +33 -16
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +161 -157
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/dialogs.d.ts +3 -3
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/jsonPointer.d.ts.map +1 -1
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/utils/objects.d.ts +16 -0
- package/dist/utils/objects.d.ts.map +1 -0
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +1 -1
- package/eslint.config.js +74 -0
- package/licenseInfo.json +4 -0
- package/package.json +33 -42
- package/rollup.config.js +15 -0
- package/src/formatAndTypeChoices.js +68 -54
- package/src/formats/indexedDBKey.js +9 -4
- package/src/formats/json.js +7 -4
- package/src/formats/schema.js +772 -0
- package/src/formats/structuredCloning.js +187 -86
- package/src/formats.js +61 -26
- package/src/fundamentalTypes/BooleanObjectType.js +18 -6
- package/src/fundamentalTypes/NumberObjectType.js +18 -5
- package/src/fundamentalTypes/StringObjectType.js +20 -8
- package/src/fundamentalTypes/arrayType.js +1241 -533
- package/src/fundamentalTypes/bigintObjectType.js +64 -0
- package/src/fundamentalTypes/bigintType.js +31 -5
- package/src/fundamentalTypes/blobType.js +201 -190
- package/src/fundamentalTypes/booleanType.js +63 -0
- package/src/fundamentalTypes/catchType.js +140 -0
- package/src/fundamentalTypes/dateType.js +57 -19
- package/src/fundamentalTypes/domexceptionType.js +61 -63
- package/src/fundamentalTypes/enumType.js +52 -0
- package/src/fundamentalTypes/errorType.js +20 -7
- package/src/fundamentalTypes/fileType.js +195 -189
- package/src/fundamentalTypes/filelistType.js +4 -0
- package/src/fundamentalTypes/functionType.js +150 -0
- package/src/fundamentalTypes/literalType.js +81 -0
- package/src/fundamentalTypes/mapType.js +4 -0
- package/src/fundamentalTypes/nanType.js +41 -0
- package/src/fundamentalTypes/nativeEnumType.js +155 -0
- package/src/fundamentalTypes/neverType.js +44 -0
- package/src/fundamentalTypes/noneditableType.js +19 -5
- package/src/fundamentalTypes/nullType.js +16 -6
- package/src/fundamentalTypes/numberType.js +49 -6
- package/src/fundamentalTypes/objectType.js +10 -2
- package/src/fundamentalTypes/promiseType.js +60 -0
- package/src/fundamentalTypes/recordType.js +42 -0
- package/src/fundamentalTypes/regexpType.js +51 -33
- package/src/fundamentalTypes/setType.js +4 -0
- package/src/fundamentalTypes/sparseUndefinedType.js +3 -0
- package/src/fundamentalTypes/stringType.js +254 -6
- package/src/fundamentalTypes/symbolType.js +81 -0
- package/src/fundamentalTypes/tupleType.js +39 -0
- package/src/fundamentalTypes/undefinedType.js +14 -4
- package/src/fundamentalTypes/voidType.js +48 -0
- package/src/jsoe.css +37 -3
- package/src/subTypes/blobHTMLType.js +33 -24
- package/src/superTypes/SpecialRealNumberType.js +22 -6
- package/src/superTypes/buffersourceType.js +86 -30
- package/src/superTypes/dommatrixType.js +24 -7
- package/src/superTypes/dompointType.js +27 -7
- package/src/superTypes/domrectType.js +33 -7
- package/src/superTypes/errorsSpecialType.js +30 -14
- package/src/typeChoices.js +115 -44
- package/src/types.js +129 -45
- package/src/utils/FileList.js +3 -3
- package/src/utils/dialogs.js +6 -8
- package/src/utils/objects.js +22 -0
- package/src/vendor-imports.js +1 -1
- package/tsconfig.json +2 -2
- package/vendor/jamilih/dist/jml-es.js +23 -6
- package/vendor/typeson-registry/dist/index.js +77 -47
- package/vendor/zod/lib/index.mjs +4236 -0
- package/vendor/zodex/dist/esm/dezerialize.d.ts +26 -0
- package/vendor/zodex/dist/esm/dezerialize.js +393 -0
- package/vendor/zodex/dist/esm/index.d.ts +9 -0
- package/vendor/zodex/dist/esm/index.js +4 -0
- package/vendor/zodex/dist/esm/infer.d.ts +29 -0
- package/vendor/zodex/dist/esm/infer.js +1 -0
- package/vendor/zodex/dist/esm/package.json +1 -0
- package/vendor/zodex/dist/esm/types.d.ts +201 -0
- package/vendor/zodex/dist/esm/types.js +13 -0
- package/vendor/zodex/dist/esm/ui.d.ts +23 -0
- package/vendor/zodex/dist/esm/ui.js +10 -0
- package/vendor/zodex/dist/esm/zerialize.d.ts +50 -0
- package/vendor/zodex/dist/esm/zerialize.js +417 -0
- package/vendor/zodex/dist/esm/zod-types.d.ts +11 -0
- package/vendor/zodex/dist/esm/zod-types.js +1 -0
- package/.eslintignore +0 -13
- package/.eslintrc.cjs +0 -145
- package/.nyc_output/out.json +0 -117370
- package/cypress.config.ts +0 -15
- package/demo/index-instrumented.html +0 -29
- package/demo/index-instrumented.js +0 -644
- package/demo/index.html +0 -29
- package/demo/index.js +0 -215
- package/src/formats/schemaAndArbitrary.js +0 -20
- 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
|
-
* @
|
|
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
|
-
*
|
|
149
|
-
*
|
|
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?:
|
|
170
|
-
*
|
|
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 {(
|
|
307
|
-
*
|
|
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
|
-
*
|
|
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"|"
|
|
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"
|
|
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
|
-
|
|
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 (
|
|
666
|
-
|
|
667
|
-
|
|
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
|
|
674
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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.
|
|
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;
|
package/src/utils/FileList.js
CHANGED
|
@@ -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
|
}
|
package/src/utils/dialogs.js
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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 =
|
|
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
|
+
}
|
package/src/vendor-imports.js
CHANGED
|
@@ -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": "
|
|
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/
|
|
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
|
-
* @
|
|
774
|
-
* @
|
|
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
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
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
|
-
|
|
1584
|
+
|
|
1585
|
+
// Casting needing unless changing `jml()` signature with overloads
|
|
1586
|
+
return (/** @type {ArbitraryValue} */ret
|
|
1587
|
+
);
|
|
1571
1588
|
};
|
|
1572
1589
|
|
|
1573
1590
|
/**
|