@es-joy/jsoe 0.10.0 → 0.11.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/.eslintrc.cjs +6 -0
- package/.nyc_output/out.json +6076 -3590
- package/CHANGES.md +4 -0
- package/README.md +4 -4
- package/demo/index.js +11 -1
- package/package.json +1 -1
- package/src/formats/structuredCloning.js +5 -6
- package/src/fundamentalTypes/domexceptionType.js +124 -0
- package/src/fundamentalTypes/dommatrixType.js +357 -0
- package/src/fundamentalTypes/dompointType.js +103 -0
- package/src/fundamentalTypes/domrectType.js +103 -0
- package/src/types.js +13 -14
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {$e} from '../utils/templateUtils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('../types.js').TypeObject}
|
|
5
|
+
*/
|
|
6
|
+
const domrectType = {
|
|
7
|
+
option: ['DOMRect'],
|
|
8
|
+
stringRegex: /^DOMRect\((.*)\)$/u,
|
|
9
|
+
toValue (s) {
|
|
10
|
+
const {x, y, width, height} = JSON.parse(s);
|
|
11
|
+
return {value: new DOMRect(x, y, width, height)};
|
|
12
|
+
},
|
|
13
|
+
getInput ({root}) {
|
|
14
|
+
return /** @type {HTMLInputElement} */ ($e(root, 'input'));
|
|
15
|
+
},
|
|
16
|
+
setValue ({root, value}) {
|
|
17
|
+
/** @type {HTMLInputElement} */ (
|
|
18
|
+
$e(root, '.x')
|
|
19
|
+
).value = String(value.x);
|
|
20
|
+
/** @type {HTMLInputElement} */ (
|
|
21
|
+
$e(root, '.y')
|
|
22
|
+
).value = String(value.y);
|
|
23
|
+
/** @type {HTMLInputElement} */ (
|
|
24
|
+
$e(root, '.width')
|
|
25
|
+
).value = String(value.width);
|
|
26
|
+
/** @type {HTMLInputElement} */ (
|
|
27
|
+
$e(root, '.height')
|
|
28
|
+
).value = String(value.height);
|
|
29
|
+
},
|
|
30
|
+
getValue ({root}) {
|
|
31
|
+
const x = Number(/** @type {HTMLInputElement} */ (
|
|
32
|
+
$e(root, '.x')
|
|
33
|
+
).value);
|
|
34
|
+
const y = Number(/** @type {HTMLInputElement} */ (
|
|
35
|
+
$e(root, '.y')
|
|
36
|
+
).value);
|
|
37
|
+
const width = Number(/** @type {HTMLInputElement} */ (
|
|
38
|
+
$e(root, '.width')
|
|
39
|
+
).value);
|
|
40
|
+
const height = Number(/** @type {HTMLInputElement} */ (
|
|
41
|
+
$e(root, '.height')
|
|
42
|
+
).value);
|
|
43
|
+
return new DOMRect(x, y, width, height);
|
|
44
|
+
},
|
|
45
|
+
viewUI ({value}) {
|
|
46
|
+
return ['div', {dataset: {type: 'domrect'}}, [
|
|
47
|
+
['b', ['x ']],
|
|
48
|
+
value.x,
|
|
49
|
+
['br'],
|
|
50
|
+
['b', ['y ']],
|
|
51
|
+
value.y,
|
|
52
|
+
['br'],
|
|
53
|
+
['b', ['width ']],
|
|
54
|
+
value.width,
|
|
55
|
+
['br'],
|
|
56
|
+
['b', ['height ']],
|
|
57
|
+
value.height
|
|
58
|
+
]];
|
|
59
|
+
},
|
|
60
|
+
editUI ({typeNamespace, value = {
|
|
61
|
+
x: '',
|
|
62
|
+
y: '',
|
|
63
|
+
width: '',
|
|
64
|
+
height: ''
|
|
65
|
+
}}) {
|
|
66
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
67
|
+
return ['div', {dataset: {type: 'domrect'}}, /** @type {import('jamilih').JamilihChildren} */ ([
|
|
68
|
+
['label', [
|
|
69
|
+
'x: ',
|
|
70
|
+
['input', {
|
|
71
|
+
class: 'x',
|
|
72
|
+
name: `${typeNamespace}-domrect-x`, value: value.x
|
|
73
|
+
}]
|
|
74
|
+
]],
|
|
75
|
+
['br'],
|
|
76
|
+
['label', [
|
|
77
|
+
'y: ',
|
|
78
|
+
['input', {
|
|
79
|
+
class: 'y',
|
|
80
|
+
name: `${typeNamespace}-domrect-y`, value: value.y
|
|
81
|
+
}]
|
|
82
|
+
]],
|
|
83
|
+
['br'],
|
|
84
|
+
['label', [
|
|
85
|
+
'width: ',
|
|
86
|
+
['input', {
|
|
87
|
+
class: 'width',
|
|
88
|
+
name: `${typeNamespace}-domrect-width`, value: value.width
|
|
89
|
+
}]
|
|
90
|
+
]],
|
|
91
|
+
['br'],
|
|
92
|
+
['label', [
|
|
93
|
+
'height: ',
|
|
94
|
+
['input', {
|
|
95
|
+
class: 'height',
|
|
96
|
+
name: `${typeNamespace}-domrect-height`, value: value.height
|
|
97
|
+
}]
|
|
98
|
+
]]
|
|
99
|
+
])];
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default domrectType;
|
package/src/types.js
CHANGED
|
@@ -37,6 +37,10 @@ import errorsSpecialType from './superTypes/errorsSpecialType.js';
|
|
|
37
37
|
import fileType from './fundamentalTypes/fileType.js';
|
|
38
38
|
import filelistType from './fundamentalTypes/filelistType.js';
|
|
39
39
|
import blobType from './fundamentalTypes/blobType.js';
|
|
40
|
+
import domexceptionType from './fundamentalTypes/domexceptionType.js';
|
|
41
|
+
import domrectType from './fundamentalTypes/domrectType.js';
|
|
42
|
+
import dompointType from './fundamentalTypes/dompointType.js';
|
|
43
|
+
import dommatrixType from './fundamentalTypes/dommatrixType.js';
|
|
40
44
|
|
|
41
45
|
/**
|
|
42
46
|
* Utility to retrieve the property value given a legend element.
|
|
@@ -392,6 +396,12 @@ Types.availableTypes = {
|
|
|
392
396
|
filelist: filelistType,
|
|
393
397
|
blob: blobType,
|
|
394
398
|
blobHTML: blobHTMLType,
|
|
399
|
+
|
|
400
|
+
domexception: domexceptionType,
|
|
401
|
+
domrect: domrectType,
|
|
402
|
+
dompoint: dompointType,
|
|
403
|
+
dommatrix: dommatrixType,
|
|
404
|
+
|
|
395
405
|
arraybuffer: {
|
|
396
406
|
option: ['ArrayBuffer']
|
|
397
407
|
},
|
|
@@ -437,17 +447,6 @@ Types.availableTypes = {
|
|
|
437
447
|
option: ['Float64Array']
|
|
438
448
|
},
|
|
439
449
|
|
|
440
|
-
// Intl (imperfect)
|
|
441
|
-
IntlCollator: {
|
|
442
|
-
option: ['Intl.Collator']
|
|
443
|
-
},
|
|
444
|
-
IntlDateTimeFormat: {
|
|
445
|
-
option: ['Intl.DateTimeFormat']
|
|
446
|
-
},
|
|
447
|
-
IntlNumberFormat: {
|
|
448
|
-
option: ['Intl.NumberFormat']
|
|
449
|
-
},
|
|
450
|
-
|
|
451
450
|
// We're catching this instead of using this
|
|
452
451
|
// sparseUndefined: sparseUndefinedType,
|
|
453
452
|
|
|
@@ -471,9 +470,9 @@ Types.availableTypes = {
|
|
|
471
470
|
* "NumberObject"|"StringObject"|"map"|"set"|"file"|"filelist"|"blobHTML"|
|
|
472
471
|
* "arraybuffer"|"arraybufferview"|"dataview"|"imagedata"|"imagebitmap"|
|
|
473
472
|
* "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
|
|
474
|
-
* "int32array"|"uint32array"|"float32array"|"float64array"|"
|
|
475
|
-
* "
|
|
476
|
-
* "
|
|
473
|
+
* "int32array"|"uint32array"|"float32array"|"float64array"|"ValidDate"|
|
|
474
|
+
* "arrayNonindexKeys"|"error"|"errors"|"blob"|"domexception"|"domrect"|
|
|
475
|
+
* "dompoint"|"dommatrix"} AvailableType
|
|
477
476
|
*/
|
|
478
477
|
|
|
479
478
|
/**
|