@es-joy/jsoe 0.5.0 → 0.6.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/.eslintignore +2 -0
- package/.eslintrc.cjs +2 -0
- package/.nyc_output/out.json +121296 -0
- package/CHANGES.md +10 -0
- package/README.md +47 -21
- package/cypress.config.ts +13 -0
- package/demo/index-instrumented.html +29 -0
- package/demo/index.html +10 -1
- package/demo/index.js +482 -126
- package/dist/formatAndTypeChoices.d.ts +10 -4
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/json.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts +2 -1
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts +6 -37
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/errorType.d.ts +6 -0
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -0
- package/dist/fundamentalTypes/mapType.d.ts +6 -0
- package/dist/fundamentalTypes/mapType.d.ts.map +1 -0
- package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
- package/dist/fundamentalTypes/objectReferenceType.d.ts.map +1 -1
- package/dist/fundamentalTypes/setType.d.ts +6 -0
- package/dist/fundamentalTypes/setType.d.ts.map +1 -0
- package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/subTypes/blobHTMLType.d.ts +12 -6
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/superTypes/SpecialNumberType.d.ts +14 -0
- package/dist/superTypes/SpecialNumberType.d.ts.map +1 -0
- package/dist/superTypes/SpecialRealNumberType.d.ts +6 -0
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -0
- package/dist/superTypes/errorsSpecialType.d.ts +8 -0
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -0
- package/dist/typeChoices.d.ts +4 -2
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +85 -233
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/dialogs.d.ts +22 -22
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/templateUtils.d.ts +6 -6
- package/dist/utils/templateUtils.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +1 -1
- package/package.json +39 -34
- package/rollup.config.js +14 -2
- package/server.js +1 -1
- package/src/formatAndTypeChoices.js +14 -13
- package/src/formats/indexedDBKey.js +2 -2
- package/src/formats/json.js +1 -2
- package/src/formats/structuredCloning.js +104 -29
- package/src/formats.js +2 -2
- package/src/fundamentalTypes/arrayReferenceType.js +3 -3
- package/src/fundamentalTypes/arrayType.js +384 -79
- package/src/fundamentalTypes/dateType.js +4 -6
- package/src/fundamentalTypes/errorType.js +416 -0
- package/src/fundamentalTypes/mapType.js +34 -0
- package/src/fundamentalTypes/nullType.js +1 -2
- package/src/fundamentalTypes/objectReferenceType.js +2 -1
- package/src/fundamentalTypes/regexpType.js +2 -2
- package/src/fundamentalTypes/setType.js +34 -0
- package/src/fundamentalTypes/sparseUndefinedType.js +2 -3
- package/src/fundamentalTypes/undefinedType.js +2 -3
- package/src/jsoe.css +3 -0
- package/src/subTypes/blobHTMLType.js +37 -33
- package/src/subTypes/falseType.js +2 -2
- package/src/subTypes/trueType.js +2 -2
- package/src/superTypes/{SpecialNumberSuperType.js → SpecialNumberType.js} +1 -1
- package/src/superTypes/{SpecialRealNumberSuperType.js → SpecialRealNumberType.js} +3 -2
- package/src/superTypes/errorsSpecialType.js +768 -0
- package/src/typeChoices.js +27 -20
- package/src/types.js +72 -40
- package/src/utils/dialogs.js +11 -12
- package/src/utils/jsonPointer.js +3 -3
- package/src/utils/templateUtils.js +4 -4
- package/src/vendor-imports.js +2 -2
- package/tsconfig.json +1 -1
- package/typings/CypressPlugins.d.ts +10 -0
- package/vendor/jamilih/dist/jml-es.js +126 -106
- package/vendor/typeson-registry/dist/index.js +188 -44
|
@@ -6,9 +6,14 @@ import dialogs from '../utils/dialogs.js';
|
|
|
6
6
|
import {isNullish} from '../utils/types.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
10
|
-
* loadBlob: (blob: Blob) => Promise<FileReader>,
|
|
9
|
+
* @typedef {HTMLTextAreaElement & {
|
|
11
10
|
* sceditorInstance: {val: (val?: string) => string|void}
|
|
11
|
+
* }} SCEditorTextarea
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {import('../types.js').TypeObject & {
|
|
16
|
+
* loadBlob: (blob: Blob) => Promise<string>
|
|
12
17
|
* }}
|
|
13
18
|
*/
|
|
14
19
|
const blobHTMLType = {
|
|
@@ -17,9 +22,6 @@ const blobHTMLType = {
|
|
|
17
22
|
stringRegex: /^data:text\/html(?:;base64)?,.*$/u,
|
|
18
23
|
valueMatch: (v) => v.type === 'text/html',
|
|
19
24
|
superType: 'blob',
|
|
20
|
-
sceditorInstance: {val () {
|
|
21
|
-
throw new Error('Not yet instantiated');
|
|
22
|
-
}},
|
|
23
25
|
toValue (s) {
|
|
24
26
|
// Todo (low): `Blob` untested; use https://stackoverflow.com/a/30407840/271577 ?
|
|
25
27
|
/**
|
|
@@ -51,34 +53,26 @@ const blobHTMLType = {
|
|
|
51
53
|
},
|
|
52
54
|
/* istanbul ignore next -- No dupe keys, array refs, or validation */
|
|
53
55
|
getInput ({root}) {
|
|
54
|
-
return /** @type {HTMLTextAreaElement} */ (
|
|
56
|
+
return /** @type {HTMLTextAreaElement} */ (
|
|
57
|
+
$e(root, 'textarea[name$=-blobHTML]')
|
|
58
|
+
);
|
|
55
59
|
},
|
|
56
|
-
getValue (
|
|
60
|
+
getValue ({root}) {
|
|
57
61
|
return this.toValue(
|
|
58
|
-
'data:text/html,' +
|
|
62
|
+
'data:text/html,' + /** @type {SCEditorTextarea} */ (
|
|
63
|
+
this.getInput({root})
|
|
64
|
+
).sceditorInstance.val()
|
|
59
65
|
// this.getInput({root}).value
|
|
60
66
|
).value;
|
|
61
67
|
},
|
|
62
|
-
loadBlob (blob) {
|
|
63
|
-
|
|
64
|
-
// eslint-disable-next-line promise/avoid-new
|
|
65
|
-
return new Promise((resolve, reject) => {
|
|
66
|
-
reader.addEventListener('loadend', () => {
|
|
67
|
-
resolve(reader);
|
|
68
|
-
});
|
|
69
|
-
reader.addEventListener(
|
|
70
|
-
'error',
|
|
71
|
-
/* istanbul ignore next -- How to simulate? */
|
|
72
|
-
(_e) => {
|
|
73
|
-
reject(reader.error);
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
reader.readAsText(blob);
|
|
77
|
-
});
|
|
68
|
+
async loadBlob (blob) {
|
|
69
|
+
return await blob.text();
|
|
78
70
|
},
|
|
79
|
-
async setValue ({
|
|
80
|
-
const
|
|
81
|
-
|
|
71
|
+
async setValue ({root, value}) {
|
|
72
|
+
const result = await this.loadBlob(value);
|
|
73
|
+
/** @type {SCEditorTextarea} */ (
|
|
74
|
+
this.getInput({root})
|
|
75
|
+
).sceditorInstance.val(/** @type {string} */ (result));
|
|
82
76
|
// this.getInput({root}).value = result;
|
|
83
77
|
},
|
|
84
78
|
viewUI ({value}) {
|
|
@@ -98,9 +92,9 @@ const blobHTMLType = {
|
|
|
98
92
|
])
|
|
99
93
|
);
|
|
100
94
|
// eslint-disable-next-line promise/prefer-await-to-then
|
|
101
|
-
this.loadBlob(value).then((
|
|
95
|
+
this.loadBlob(value).then((
|
|
102
96
|
result
|
|
103
|
-
|
|
97
|
+
) => {
|
|
104
98
|
val = /** @type {string} */ (result);
|
|
105
99
|
jml('iframe', {
|
|
106
100
|
sandbox: '',
|
|
@@ -118,9 +112,19 @@ const blobHTMLType = {
|
|
|
118
112
|
// return ['i', [`data:text/html,${value}`]];
|
|
119
113
|
},
|
|
120
114
|
editUI ({typeNamespace, value}) {
|
|
121
|
-
const textarea =
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
const textarea =
|
|
116
|
+
/**
|
|
117
|
+
* @type {SCEditorTextarea}
|
|
118
|
+
*/ (
|
|
119
|
+
jml('textarea', {name: `${typeNamespace}-blobHTML`})
|
|
120
|
+
);
|
|
121
|
+
textarea.sceditorInstance = {
|
|
122
|
+
/* istanbul ignore next */
|
|
123
|
+
val () {
|
|
124
|
+
throw new Error('Not yet instantiated');
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
124
128
|
const root = /** @type {HTMLDivElement} */ (jml(
|
|
125
129
|
'div',
|
|
126
130
|
{dataset: {type: 'blobHTML'}},
|
|
@@ -166,7 +170,7 @@ const blobHTMLType = {
|
|
|
166
170
|
emoticonsRoot: 'node_modules/sceditor/',
|
|
167
171
|
style: 'node_modules/sceditor/minified/themes/content/default.min.css'
|
|
168
172
|
});
|
|
169
|
-
|
|
173
|
+
textarea.sceditorInstance = sceditor.instance(textarea);
|
|
170
174
|
if (!isNullish(value)) {
|
|
171
175
|
/** @type {Required<import('../types.js').TypeObject>} */ (
|
|
172
176
|
this
|
|
@@ -16,7 +16,7 @@ const falseType = {
|
|
|
16
16
|
ct: 0,
|
|
17
17
|
/* istanbul ignore next -- No dupe keys, array refs, or validation */
|
|
18
18
|
getInput ({root}) {
|
|
19
|
-
return /** @type {HTMLInputElement} */ ($e(root, 'input'));
|
|
19
|
+
return /** @type {HTMLInputElement} */ ($e(root, 'input[value=false]'));
|
|
20
20
|
},
|
|
21
21
|
editUI ({typeNamespace}) {
|
|
22
22
|
this.ct++;
|
|
@@ -32,7 +32,7 @@ const falseType = {
|
|
|
32
32
|
'False',
|
|
33
33
|
['input', {
|
|
34
34
|
type: 'radio', name: `${typeNamespace}-false${this.ct}`,
|
|
35
|
-
value: 'false', checked: true
|
|
35
|
+
value: 'false', checked: true
|
|
36
36
|
}]
|
|
37
37
|
]]
|
|
38
38
|
]];
|
package/src/subTypes/trueType.js
CHANGED
|
@@ -6,7 +6,7 @@ import {$e} from '../utils/templateUtils.js';
|
|
|
6
6
|
const trueType = {
|
|
7
7
|
option: ['Boolean (true)', {value: 'true'}],
|
|
8
8
|
stringRegex: /^true$/u,
|
|
9
|
-
toValue: (_s) => ({value: true}),
|
|
9
|
+
toValue: (/* _s */) => ({value: true}),
|
|
10
10
|
valueMatch: (v) => v === true,
|
|
11
11
|
superType: 'boolean',
|
|
12
12
|
getValue: () => true,
|
|
@@ -25,7 +25,7 @@ const trueType = {
|
|
|
25
25
|
'True',
|
|
26
26
|
['input', {
|
|
27
27
|
type: 'radio', name: `${typeNamespace}-true${this.ct}`,
|
|
28
|
-
value: 'true', checked: true
|
|
28
|
+
value: 'true', checked: true
|
|
29
29
|
}]
|
|
30
30
|
]],
|
|
31
31
|
['label', [
|
|
@@ -41,7 +41,7 @@ const SpecialNumberSuperType = {
|
|
|
41
41
|
setValue ({root, value}) {
|
|
42
42
|
/** @type {Required<import('../types.js').TypeObject>} */ (
|
|
43
43
|
this
|
|
44
|
-
).getSelect({root}).value = String(value);
|
|
44
|
+
).getSelect({root}).value = Object.is(value, -0) ? '-0' : String(value);
|
|
45
45
|
},
|
|
46
46
|
viewUI ({value}) {
|
|
47
47
|
return ['i', {dataset: {type: 'SpecialNumber'}}, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {$e} from '../utils/templateUtils.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @type {import('./
|
|
4
|
+
* @type {import('./SpecialNumberType.js').SuperTypeObject}
|
|
5
5
|
*/
|
|
6
6
|
const SpecialRealNumberSuperType = {
|
|
7
7
|
option: ['Special Real Number', {title: '`Infinity`, `-Infinity`, `-0`'}],
|
|
@@ -29,13 +29,14 @@ const SpecialRealNumberSuperType = {
|
|
|
29
29
|
setValue ({root, value}) {
|
|
30
30
|
/** @type {Required<import('../types.js').TypeObject>} */ (
|
|
31
31
|
this
|
|
32
|
-
).getSelect({root}).value = String(value);
|
|
32
|
+
).getSelect({root}).value = Object.is(value, -0) ? '-0' : String(value);
|
|
33
33
|
},
|
|
34
34
|
viewUI ({value}) {
|
|
35
35
|
return ['i', {dataset: {type: 'SpecialRealNumber'}}, [
|
|
36
36
|
Object.is(value, -0) ? '-0' : String(value)
|
|
37
37
|
]];
|
|
38
38
|
},
|
|
39
|
+
/* istanbul ignore next -- No dupe keys, array refs, or validation */
|
|
39
40
|
getInput ({root}) {
|
|
40
41
|
return /** @type {HTMLSelectElement} */ ($e(root, 'select'));
|
|
41
42
|
},
|