@es-joy/jsoe 0.23.0 → 0.24.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/CHANGES.md +8 -0
- package/README.md +1 -1
- package/dist/formatAndTypeChoices.d.ts +9 -2
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/arbitraryJS.d.ts +4 -0
- package/dist/formats/arbitraryJS.d.ts.map +1 -0
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts +1 -1
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/formats.d.ts +13 -10
- package/dist/formats.d.ts.map +1 -1
- package/dist/fundamentalTypes/functionType.d.ts +1 -0
- package/dist/fundamentalTypes/functionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/promiseType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/fundamentalTypes/symbolType.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/types.d.ts +33 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +2 -1
- package/package.json +13 -14
- package/rollup.config.js +12 -0
- package/src/formatAndTypeChoices.js +32 -7
- package/src/formats/arbitraryJS.js +27 -0
- package/src/formats/indexedDBKey.js +1 -1
- package/src/formats/json.js +1 -1
- package/src/formats/schema.js +17 -13
- package/src/formats/structuredCloning.js +37 -8
- package/src/formats.js +15 -7
- package/src/fundamentalTypes/arrayReferenceType.js +1 -1
- package/src/fundamentalTypes/bigintObjectType.js +1 -1
- package/src/fundamentalTypes/bigintType.js +1 -1
- package/src/fundamentalTypes/functionType.js +237 -69
- package/src/fundamentalTypes/numberType.js +3 -3
- package/src/fundamentalTypes/objectReferenceType.js +1 -1
- package/src/fundamentalTypes/promiseType.js +144 -15
- package/src/fundamentalTypes/stringType.js +8 -7
- package/src/fundamentalTypes/symbolType.js +14 -6
- package/src/subTypes/blobHTMLType.js +3 -1
- package/src/types.js +31 -25
- package/src/vendor-imports.js +6 -1
- package/vendor/acorn/dist/acorn.d.mts +856 -0
- package/vendor/acorn/dist/acorn.d.ts +856 -0
- package/vendor/acorn/dist/acorn.js +6065 -0
- package/vendor/acorn/dist/acorn.mjs +6036 -0
- package/vendor/acorn/dist/bin.js +90 -0
- package/vendor/jamilih/dist/jml-es.js +9 -14
- package/vendor/typeson-registry/dist/index.js +70 -26
|
@@ -1,42 +1,165 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
jml, toStringTag,
|
|
3
|
+
Typeson, structuredCloningThrowing,
|
|
4
|
+
resurrectable as noneditable, symbol, promise
|
|
5
|
+
} from '../vendor-imports.js';
|
|
2
6
|
import {$e} from '../utils/templateUtils.js';
|
|
7
|
+
import arrayType from './arrayType.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const getTypeson = () => {
|
|
13
|
+
const structuredCloningFixed = structuredCloningThrowing.filter(
|
|
14
|
+
(typeSpecSet) => {
|
|
15
|
+
return ![
|
|
16
|
+
// Not yet supported within JSOE
|
|
17
|
+
'imagedata',
|
|
18
|
+
'imagebitmap',
|
|
19
|
+
'cryptokey',
|
|
20
|
+
'domquad'
|
|
21
|
+
].some((prop) => {
|
|
22
|
+
return Object.hasOwn(typeSpecSet, prop);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
structuredCloningFixed.splice(
|
|
27
|
+
// Add after userObjects
|
|
28
|
+
1,
|
|
29
|
+
0,
|
|
30
|
+
noneditable
|
|
31
|
+
);
|
|
32
|
+
return new Typeson().register(
|
|
33
|
+
[
|
|
34
|
+
...structuredCloningFixed,
|
|
35
|
+
symbol,
|
|
36
|
+
promise,
|
|
37
|
+
{
|
|
38
|
+
function: {
|
|
39
|
+
test (x) {
|
|
40
|
+
return typeof x === 'function';
|
|
41
|
+
},
|
|
42
|
+
replace (funcType) {
|
|
43
|
+
return '(' + funcType.toString() + ')';
|
|
44
|
+
},
|
|
45
|
+
revive (o) {
|
|
46
|
+
// eslint-disable-next-line no-eval -- User opted in
|
|
47
|
+
return eval(o);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
);
|
|
53
|
+
};
|
|
3
54
|
|
|
4
55
|
/**
|
|
5
56
|
* @type {import('../types.js').TypeObject}
|
|
6
57
|
*/
|
|
7
58
|
const promiseType = {
|
|
8
59
|
option: ['Promise'],
|
|
9
|
-
|
|
10
|
-
|
|
60
|
+
regexEndings: [',', ')'],
|
|
61
|
+
stringRegexBegin: /^Promise\(/u,
|
|
62
|
+
stringRegexEnd: /^\)/u,
|
|
63
|
+
array: true,
|
|
64
|
+
|
|
11
65
|
valueMatch (x) {
|
|
12
66
|
return toStringTag(x) === 'Promise';
|
|
13
67
|
},
|
|
14
|
-
toValue (
|
|
15
|
-
|
|
68
|
+
toValue (...args) {
|
|
69
|
+
const val = /** @type {import('../types.js').ToValue} */ (
|
|
70
|
+
arrayType.toValue
|
|
71
|
+
).apply(this, args);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
value: Promise.resolve(val.value[0]),
|
|
75
|
+
remnant: val.remnant
|
|
76
|
+
};
|
|
16
77
|
},
|
|
17
78
|
getInput ({root}) {
|
|
18
|
-
|
|
79
|
+
const childRoot = /** @type {HTMLDivElement} */ (
|
|
80
|
+
$e(root, 'div[data-type]')
|
|
81
|
+
);
|
|
82
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
83
|
+
return /** @type {HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|HTMLButtonElement} */ (
|
|
84
|
+
this.types?.getFormControlForRoot(childRoot)
|
|
85
|
+
);
|
|
19
86
|
},
|
|
20
87
|
setValue ({root, value}) {
|
|
21
|
-
|
|
88
|
+
// Need to wait a tick
|
|
89
|
+
setTimeout(async () => {
|
|
90
|
+
const val = await value;
|
|
91
|
+
const typeson = getTypeson();
|
|
92
|
+
const type = /** @type {import('../types.js').AvailableArbitraryType} */ (
|
|
93
|
+
await typeson.rootTypeName(val)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const select = /** @type {HTMLSelectElement} */ ($e(root, 'select'));
|
|
97
|
+
select.value = type;
|
|
98
|
+
select.dispatchEvent(new Event('change'));
|
|
99
|
+
|
|
100
|
+
const childRoot = /** @type {HTMLDivElement} */ (
|
|
101
|
+
$e(root, 'div[data-type]')
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
this.types?.setValue({
|
|
105
|
+
type,
|
|
106
|
+
root: childRoot,
|
|
107
|
+
value: val
|
|
108
|
+
});
|
|
109
|
+
const input = this.types?.getFormControlForRoot(childRoot);
|
|
110
|
+
// Avoid invalid number, etc.
|
|
111
|
+
input?.dispatchEvent(new Event('input'));
|
|
112
|
+
input?.blur();
|
|
113
|
+
});
|
|
22
114
|
},
|
|
23
115
|
getValue ({root}) {
|
|
24
|
-
|
|
116
|
+
const childRoot = /** @type {HTMLDivElement} */ (
|
|
117
|
+
$e(root, 'div[data-type]')
|
|
118
|
+
);
|
|
119
|
+
return Promise.resolve(this.types?.getValueForRoot(childRoot));
|
|
25
120
|
},
|
|
26
|
-
viewUI ({specificSchemaObject}) {
|
|
121
|
+
viewUI ({specificSchemaObject, types, value, ...args}) {
|
|
122
|
+
const typeson = getTypeson();
|
|
123
|
+
|
|
124
|
+
const span = jml('span');
|
|
125
|
+
const valueHolder = jml('div');
|
|
126
|
+
|
|
127
|
+
(async () => {
|
|
128
|
+
const val = await value;
|
|
129
|
+
const type = await typeson.rootTypeName(val);
|
|
130
|
+
span.textContent = type;
|
|
131
|
+
const typeObj = /** @type {import('../types.js').TypeObject} */ (
|
|
132
|
+
types.getTypeObject(
|
|
133
|
+
/** @type {import('../types.js').AvailableArbitraryType} */ (type)
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
valueHolder.append(
|
|
137
|
+
jml(...typeObj.viewUI({
|
|
138
|
+
specificSchemaObject, types, value: val, ...args
|
|
139
|
+
}))
|
|
140
|
+
);
|
|
141
|
+
})();
|
|
142
|
+
|
|
27
143
|
return ['span', {
|
|
28
144
|
dataset: {type: 'promise'},
|
|
29
145
|
title: specificSchemaObject?.description
|
|
30
146
|
}, [
|
|
31
|
-
|
|
32
|
-
|
|
147
|
+
'A Promise ',
|
|
148
|
+
span,
|
|
149
|
+
valueHolder
|
|
33
150
|
]];
|
|
34
151
|
},
|
|
35
152
|
editUI ({
|
|
36
|
-
format, type, buildTypeChoices, specificSchemaObject,
|
|
37
|
-
topRoot, schemaContent, typeNamespace
|
|
153
|
+
format, types, type, buildTypeChoices, specificSchemaObject,
|
|
154
|
+
topRoot, schemaContent, typeNamespace, value
|
|
38
155
|
}) {
|
|
39
|
-
|
|
156
|
+
this.types = types;
|
|
157
|
+
|
|
158
|
+
const div = jml('div', {
|
|
159
|
+
dataset: {type: 'promise'},
|
|
160
|
+
title: specificSchemaObject?.description ?? '(a Promise)'
|
|
161
|
+
}, [
|
|
162
|
+
'Promise ',
|
|
40
163
|
...(/** @type {import('../typeChoices.js').BuildTypeChoices} */ (
|
|
41
164
|
buildTypeChoices
|
|
42
165
|
)({
|
|
@@ -53,7 +176,13 @@ const promiseType = {
|
|
|
53
176
|
// itemIndex,
|
|
54
177
|
typeNamespace
|
|
55
178
|
}).domArray)
|
|
56
|
-
]
|
|
179
|
+
]);
|
|
180
|
+
|
|
181
|
+
if (value && this.setValue) {
|
|
182
|
+
this.setValue({root: div, value});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return [div];
|
|
57
186
|
}
|
|
58
187
|
};
|
|
59
188
|
|
|
@@ -3,22 +3,23 @@ import {$e} from '../utils/templateUtils.js';
|
|
|
3
3
|
|
|
4
4
|
// Adapted from Zod: https://github.com/colinhacks/zod/blob/9257ab78eec366c04331a3c2d59deb344a02d9f6/src/types.ts
|
|
5
5
|
const ipv4Regex =
|
|
6
|
-
/^(?:(?:25[0-5]|2[0-4]
|
|
6
|
+
/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/u;
|
|
7
7
|
const ipv6Regex =
|
|
8
|
-
/^(([a-
|
|
8
|
+
/^(([a-f\d]{1,4}:){7}|::([a-f\d]{1,4}:){0,6}|([a-f\d]{1,4}:):([a-f\d]{1,4}:){0,5}|([a-f\d]{1,4}:){2}:([a-f\d]{1,4}:){0,4}|([a-f\d]{1,4}:){3}:([a-f\d]{1,4}:){0,3}|([a-f\d]{1,4}:){4}:([a-f\d]{1,4}:){0,2}|([a-f\d]{1,4}:){5}:([a-f\d]{1,4}:)?)([a-f\d]{1,4}|(((25[0-5])|(2[0-4]\d)|(1\d{2})|(\d{1,2}))\.){3}((25[0-5])|(2[0-4]\d)|(1\d{2})|(\d{1,2})))$/u;
|
|
9
9
|
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
10
10
|
const base64Regex =
|
|
11
|
-
/^([
|
|
11
|
+
/^([\da-zA-Z+/]{4})*(([\da-zA-Z+/]{2}==)|([\da-zA-Z+/]{3}=))?$/u;
|
|
12
12
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
13
13
|
const emojiRegexStr = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
14
14
|
const emojiRegex = new RegExp(emojiRegexStr, 'u');
|
|
15
15
|
const cuidRegex = /^c[^\s-]{8,}$/iu;
|
|
16
|
-
const cuid2Regex = /^[
|
|
17
|
-
const ulidRegex = /^[
|
|
16
|
+
const cuid2Regex = /^[\da-z]+$/u;
|
|
17
|
+
const ulidRegex = /^[\dA-HJKMNP-TV-Z]{26}$/iu;
|
|
18
18
|
const uuidRegex =
|
|
19
|
-
/^[
|
|
20
|
-
const nanoidRegex = /^[a-
|
|
19
|
+
/^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu;
|
|
20
|
+
const nanoidRegex = /^[a-z\d_-]{21}$/iu;
|
|
21
21
|
const durationRegex =
|
|
22
|
+
// eslint-disable-next-line sonarjs/no-empty-after-reluctant -- Ok
|
|
22
23
|
/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/u;
|
|
23
24
|
// End adapted from Zod
|
|
24
25
|
|
|
@@ -5,7 +5,7 @@ import {$e} from '../utils/templateUtils.js';
|
|
|
5
5
|
*/
|
|
6
6
|
const symbolType = {
|
|
7
7
|
option: ['Symbol'],
|
|
8
|
-
stringRegex: /^(?<symbolClassType>Symbol|Symbol.for)\(
|
|
8
|
+
stringRegex: /^(?<symbolClassType>Symbol|Symbol.for)\((?<innerContent>[^)]*)\)$/u,
|
|
9
9
|
ct: 0,
|
|
10
10
|
valueMatch (x) {
|
|
11
11
|
return typeof x === 'symbol';
|
|
@@ -50,10 +50,17 @@ const symbolType = {
|
|
|
50
50
|
return ['span', {
|
|
51
51
|
dataset: {type: 'symbol'},
|
|
52
52
|
title: specificSchemaObject?.description ?? '(a Symbol)'
|
|
53
|
-
}, [
|
|
53
|
+
}, [
|
|
54
|
+
Symbol.keyFor(value) === undefined ? '' : ['b', ['Global: ']],
|
|
55
|
+
String(value).slice(7, -1)
|
|
56
|
+
]];
|
|
54
57
|
},
|
|
55
|
-
editUI ({typeNamespace, value = ''}) {
|
|
56
|
-
|
|
58
|
+
editUI ({typeNamespace, specificSchemaObject, value = ''}) {
|
|
59
|
+
this.ct++;
|
|
60
|
+
return ['div', {
|
|
61
|
+
dataset: {type: 'symbol'},
|
|
62
|
+
title: specificSchemaObject?.description ?? '(a Symbol)'
|
|
63
|
+
}, [
|
|
57
64
|
['label', [
|
|
58
65
|
'Symbol()',
|
|
59
66
|
['input', {
|
|
@@ -65,13 +72,14 @@ const symbolType = {
|
|
|
65
72
|
'Symbol.for()',
|
|
66
73
|
['input', {
|
|
67
74
|
type: 'radio', name: `${typeNamespace}-symbol${this.ct}`,
|
|
68
|
-
value: 'Symbol.for',
|
|
75
|
+
value: 'Symbol.for',
|
|
76
|
+
checked: value && Symbol.keyFor(value) !== undefined
|
|
69
77
|
}]
|
|
70
78
|
]],
|
|
71
79
|
['br'],
|
|
72
80
|
['input', {
|
|
73
81
|
className: 'symbolInput',
|
|
74
|
-
name: `${typeNamespace}-
|
|
82
|
+
name: `${typeNamespace}-symbol`,
|
|
75
83
|
value: String(value).slice(7, -1)
|
|
76
84
|
}]
|
|
77
85
|
]];
|
|
@@ -31,7 +31,9 @@ const blobHTMLType = {
|
|
|
31
31
|
*/
|
|
32
32
|
function dataURIToBlob (dataURI) {
|
|
33
33
|
// Adapted from https://stackoverflow.com/a/12300351/271577
|
|
34
|
-
const
|
|
34
|
+
const pos = dataURI.indexOf(',');
|
|
35
|
+
const mimeInfo = dataURI.slice(0, pos);
|
|
36
|
+
const bytes = dataURI.slice(pos + 1);
|
|
35
37
|
const [mimeString, encoding] = mimeInfo.split(':')[1].split(';');
|
|
36
38
|
let ab;
|
|
37
39
|
if (encoding === 'base64') {
|
package/src/types.js
CHANGED
|
@@ -55,10 +55,9 @@ import neverType from './fundamentalTypes/neverType.js';
|
|
|
55
55
|
import catchType from './fundamentalTypes/catchType.js';
|
|
56
56
|
import nativeEnumType from './fundamentalTypes/nativeEnumType.js';
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// import functionType from './fundamentalTypes/functionType.js';
|
|
58
|
+
import symbolType from './fundamentalTypes/symbolType.js';
|
|
59
|
+
import promiseType from './fundamentalTypes/promiseType.js';
|
|
60
|
+
import functionType from './fundamentalTypes/functionType.js';
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
63
|
* Utility to retrieve the property value given a legend element.
|
|
@@ -93,7 +92,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
93
92
|
* Utility to retrieve the type out of a type root element.
|
|
94
93
|
* @callback GetTypeForRoot
|
|
95
94
|
* @param {?RootElement} root
|
|
96
|
-
* @returns {
|
|
95
|
+
* @returns {AvailableArbitraryType} Why would it not exist?
|
|
97
96
|
*/
|
|
98
97
|
|
|
99
98
|
/**
|
|
@@ -135,7 +134,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
135
134
|
|
|
136
135
|
/**
|
|
137
136
|
* @callback GetOptionForType
|
|
138
|
-
* @param {
|
|
137
|
+
* @param {AvailableArbitraryType} type
|
|
139
138
|
* @param {import('./formatAndTypeChoices.js').ZodexSchema|
|
|
140
139
|
* undefined} [schemaContent]
|
|
141
140
|
* @returns {[string, {value: AvailableType, title?: string}]}
|
|
@@ -183,7 +182,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
183
182
|
* readonly?: boolean,
|
|
184
183
|
* resultType?: "both"|"keys"|"values",
|
|
185
184
|
* typeNamespace?: string,
|
|
186
|
-
* type:
|
|
185
|
+
* type: AvailableArbitraryType,
|
|
187
186
|
* topRoot?: RootElement,
|
|
188
187
|
* bringIntoFocus?: boolean|undefined,
|
|
189
188
|
* buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
|
|
@@ -214,7 +213,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
214
213
|
|
|
215
214
|
/**
|
|
216
215
|
* @typedef {(cfg: {
|
|
217
|
-
* type:
|
|
216
|
+
* type: AvailableArbitraryType,
|
|
218
217
|
* root: RootElement,
|
|
219
218
|
* topRoot?: RootElement,
|
|
220
219
|
* avoidReport?: boolean
|
|
@@ -223,7 +222,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
223
222
|
|
|
224
223
|
/**
|
|
225
224
|
* @typedef {(cfg: {
|
|
226
|
-
* type:
|
|
225
|
+
* type: AvailableArbitraryType,
|
|
227
226
|
* root: RootElement,
|
|
228
227
|
* value: StructuredCloneValue,
|
|
229
228
|
* }) => void} SetValue
|
|
@@ -289,10 +288,10 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
289
288
|
/**
|
|
290
289
|
* @typedef {(
|
|
291
290
|
* info: {
|
|
292
|
-
* root: HTMLDivElement,
|
|
293
|
-
* value: StructuredCloneValue
|
|
294
|
-
* }
|
|
295
|
-
* ) => void} TypeObjectSetValue
|
|
291
|
+
* root: HTMLDivElement,
|
|
292
|
+
* value: StructuredCloneValue
|
|
293
|
+
* }
|
|
294
|
+
* ) => void} TypeObjectSetValue
|
|
296
295
|
*/
|
|
297
296
|
|
|
298
297
|
/**
|
|
@@ -349,12 +348,13 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
349
348
|
* }) =>
|
|
350
349
|
* StructuredCloneValue
|
|
351
350
|
* } getValue Gets the value for the type
|
|
351
|
+
* @property {Types} [types]
|
|
352
352
|
* @property {TypeObjectSetValue} [setValue] Should set the value of the
|
|
353
353
|
* form's `getInput` element
|
|
354
354
|
* @property {(info: {
|
|
355
355
|
* value?: StructuredCloneValue,
|
|
356
356
|
* typeNamespace?: string,
|
|
357
|
-
* type?:
|
|
357
|
+
* type?: AvailableArbitraryType,
|
|
358
358
|
* topRoot?: HTMLDivElement,
|
|
359
359
|
* resultType?: "keys"|"values"|"both",
|
|
360
360
|
* format: import('./formats.js').AvailableFormat,
|
|
@@ -373,7 +373,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
373
373
|
* formats?: import('./formats.js').default,
|
|
374
374
|
* types: Types,
|
|
375
375
|
* resultType?: "keys"|"values"|"both",
|
|
376
|
-
* type?:
|
|
376
|
+
* type?: AvailableArbitraryType,
|
|
377
377
|
* forcedState?: string,
|
|
378
378
|
* buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
|
|
379
379
|
* topRoot?: HTMLDivElement
|
|
@@ -422,8 +422,10 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
422
422
|
* "record"|"void"|"enum"|"literal"|"never"|"catch"|"nativeEnum"
|
|
423
423
|
* } AvailableType
|
|
424
424
|
*/
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* @typedef {AvailableType|"symbol"|"promise"|"function"} AvailableArbitraryType
|
|
428
|
+
*/
|
|
427
429
|
|
|
428
430
|
/**
|
|
429
431
|
* @typedef {TypeObject & {
|
|
@@ -445,7 +447,7 @@ class Types {
|
|
|
445
447
|
this.customValidateAllReferences = undefined;
|
|
446
448
|
/**
|
|
447
449
|
* @type {{
|
|
448
|
-
* [key in
|
|
450
|
+
* [key in AvailableArbitraryType]: Partial<TypeObject>|string[]
|
|
449
451
|
* }}
|
|
450
452
|
*/
|
|
451
453
|
this.availableTypes = {
|
|
@@ -506,10 +508,9 @@ class Types {
|
|
|
506
508
|
resurrectable: noneditableType,
|
|
507
509
|
never: neverType,
|
|
508
510
|
|
|
509
|
-
//
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
// function: functionType,
|
|
511
|
+
symbol: symbolType, // Non-cloning type
|
|
512
|
+
promise: promiseType,
|
|
513
|
+
function: functionType,
|
|
513
514
|
|
|
514
515
|
catch: catchType,
|
|
515
516
|
nativeEnum: nativeEnumType,
|
|
@@ -716,7 +717,7 @@ class Types {
|
|
|
716
717
|
const availableType = /** @type {TypeObject} */ (
|
|
717
718
|
this.availableTypes[type]
|
|
718
719
|
);
|
|
719
|
-
/** @type {[string, {value?:
|
|
720
|
+
/** @type {[string, {value?: AvailableArbitraryType, title?: string}?]} */
|
|
720
721
|
const optInfo = [
|
|
721
722
|
...availableType.option
|
|
722
723
|
];
|
|
@@ -986,6 +987,9 @@ class Types {
|
|
|
986
987
|
}
|
|
987
988
|
}
|
|
988
989
|
if (firstRun) {
|
|
990
|
+
// Todo: should take into account `format`, e.g., to widen to
|
|
991
|
+
// allow `arbitraryJS` values; should also be using
|
|
992
|
+
// `structuredCloningFixed`
|
|
989
993
|
const typeson = new Typeson().register(
|
|
990
994
|
structuredCloningThrowing
|
|
991
995
|
);
|
|
@@ -1020,7 +1024,7 @@ class Types {
|
|
|
1020
1024
|
}
|
|
1021
1025
|
|
|
1022
1026
|
/**
|
|
1023
|
-
* @param {
|
|
1027
|
+
* @param {AvailableArbitraryType} type
|
|
1024
1028
|
* @returns {Partial<TypeObject>|string[]}
|
|
1025
1029
|
*/
|
|
1026
1030
|
getTypeObject (type) {
|
|
@@ -1030,7 +1034,9 @@ class Types {
|
|
|
1030
1034
|
|
|
1031
1035
|
/** @type {GetTypeForRoot} */
|
|
1032
1036
|
Types.getTypeForRoot = (root) => {
|
|
1033
|
-
return
|
|
1037
|
+
return /** @type {AvailableArbitraryType} */ (
|
|
1038
|
+
String(root ? root.dataset.type : root)
|
|
1039
|
+
);
|
|
1034
1040
|
};
|
|
1035
1041
|
|
|
1036
1042
|
/** @type {ValidValuesSet} */
|
package/src/vendor-imports.js
CHANGED
|
@@ -3,6 +3,11 @@ export {jml, body, nbsp, $} from 'jamilih';
|
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
5
|
getJSONType, Typeson, unescapeKeyPathComponent, structuredCloningThrowing,
|
|
6
|
-
resurrectable, toStringTag, hasConstructorOf
|
|
6
|
+
resurrectable, toStringTag, hasConstructorOf, symbol, promise
|
|
7
7
|
} from 'typeson-registry';
|
|
8
8
|
// } from '../node_modules/typeson-registry/dist/index.js';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
parse as parseAcorn
|
|
12
|
+
} from 'acorn';
|
|
13
|
+
// } from '../node_modules/acorn/dist/acorn.mjs';
|