@es-joy/jsoe 0.16.0 → 0.18.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 +12 -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 +9663 -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 +71 -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/jsoe.css CHANGED
@@ -39,12 +39,20 @@ video.recordedMedia {
39
39
  height: 60px;
40
40
  }
41
41
 
42
- [data-type="undef"] {
42
+ :invalid {
43
+ background-color: 1px solid pink !important;
44
+ }
45
+
46
+ [data-type="undef"], [data-type="void"] {
43
47
  background-color: green;
44
48
  }
45
49
  [data-type="null"] {
46
50
  background-color: lightgreen;
47
51
  }
52
+ [data-type="nan"] {
53
+ background-color: green;
54
+ }
55
+
48
56
  [data-type="true"] {
49
57
  background-color: blue;
50
58
  color: white;
@@ -52,19 +60,35 @@ video.recordedMedia {
52
60
  [data-type="false"] {
53
61
  background-color: pink;
54
62
  }
63
+ [data-type="boolean"] {
64
+ background-color: aqua;
65
+ }
55
66
  [data-type="number"] {
56
67
  background-color: violet;
57
68
  }
58
69
  [data-type="string"] {
59
70
  background-color: lightblue;
60
71
  }
61
- [data-type="array"], [data-type="sparseArrays"], [data-type="arrayNonindexKeys"] {
72
+ [data-type="array"], [data-type="sparseArrays"], [data-type="arrayNonindexKeys"], [data-type="tuple"] {
62
73
  background-color: lightyellow;
63
74
  }
64
- [data-type="object"] {
75
+ [data-type="object"], [data-type="record"] {
65
76
  background-color: orange;
66
77
  }
67
78
 
79
+ [data-type="literal"] {
80
+ background-color: lightblue;
81
+ }
82
+
83
+ [data-type="symbol"] {
84
+ background-color: lightgreen;
85
+ }
86
+ [data-type="promise"] {
87
+ background-color: orange;
88
+ }
89
+ [data-type="function"] {
90
+ background-color: teal;
91
+ }
68
92
 
69
93
  [data-type="arrayReference"] {
70
94
  color: white;
@@ -113,6 +137,16 @@ video.recordedMedia {
113
137
  background-color: yellow;
114
138
  }
115
139
 
140
+ [data-type="map"], [data-type="set"],
141
+ [data-type="bigint"], [data-type="bigintObject"],
142
+ [data-type="never"], [data-type="domexception"],
143
+ [data-type="resurrectable"], /* i.e., `noneditable` */
144
+ [data-type="domrect"], [data-type="dompoint"],
145
+ [data-type="dommatrix"],
146
+ [data-type="catch"], [data-type="enum"], [data-type="nativeEnum"] {
147
+ background-color: lightgray;
148
+ }
149
+
116
150
  .typedArrayArea {
117
151
  overflow: auto;
118
152
  max-height: 250px;
@@ -1,4 +1,4 @@
1
- /* globals sceditor */
1
+ /* globals sceditor -- No ESM version yet */
2
2
  import {jml} from '../vendor-imports.js';
3
3
  import {$e} from '../utils/templateUtils.js';
4
4
 
@@ -20,7 +20,7 @@ const blobHTMLType = {
20
20
  // Todo (low): Support other content-types
21
21
  option: ['Blob (text/html)'],
22
22
  stringRegex: /^data:text\/html(?:;base64)?,.*$/u,
23
- valueMatch: (v) => v.type === 'text/html',
23
+ valueMatch: (v) => v && v.type === 'text/html',
24
24
  superType: 'blob',
25
25
  toValue (s) {
26
26
  // Todo (low): `Blob` untested; use https://stackoverflow.com/a/30407840/271577 ?
@@ -75,23 +75,26 @@ const blobHTMLType = {
75
75
  ).sceditorInstance.val(/** @type {string} */ (result));
76
76
  // this.getInput({root}).value = result;
77
77
  },
78
- viewUI ({value}) {
78
+ viewUI ({value, specificSchemaObject}) {
79
79
  /** @type {string} */
80
80
  let val;
81
- const div = /** @type {HTMLDivElement} */ (
82
- jml('div', {dataset: {type: 'blobHTML'}}, [
83
- 'HTML: ',
84
- ['button', {$on: {
85
- click () {
86
- dialogs.alert({message: ['div', [
87
- 'Source: ',
88
- ['textarea', {class: 'view-source'}, [val]]
89
- ]]});
90
- }
91
- }}, ['View source']]
92
- ])
93
- );
94
- // eslint-disable-next-line promise/prefer-await-to-then
81
+ const div = jml('div', {
82
+ dataset: {type: 'blobHTML'},
83
+ title: specificSchemaObject?.description ? 'HTML' : undefined
84
+ }, [
85
+ specificSchemaObject?.description ?? 'HTML',
86
+ ': ',
87
+ ['button', {$on: {
88
+ click () {
89
+ dialogs.alert({message: ['div', [
90
+ 'Source: ',
91
+ ['textarea', {class: 'view-source'}, [val]]
92
+ ]]});
93
+ }
94
+ }}, ['View source']]
95
+ ]);
96
+ // eslint-disable-next-line @stylistic/max-len -- Long
97
+ // eslint-disable-next-line promise/prefer-await-to-then -- Not an async method
95
98
  this.loadBlob(value).then((
96
99
  result
97
100
  ) => {
@@ -101,17 +104,20 @@ const blobHTMLType = {
101
104
  srcdoc: val
102
105
  }, div);
103
106
  return undefined;
104
- // eslint-disable-next-line promise/prefer-await-to-then
107
+ // eslint-disable-next-line @stylistic/max-len -- Long
108
+ // eslint-disable-next-line promise/prefer-await-to-then -- Not an async method
105
109
  }).catch(
106
110
  /* istanbul ignore next -- How to simulate? */
107
- () => {
108
- // Todo: Show an error message?
111
+ // eslint-disable-next-line promise/prefer-await-to-callbacks -- Not async
112
+ (err) => {
113
+ // Todo: Show an error message?
114
+ console.error('Err', err);
109
115
  }
110
116
  );
111
117
  return [div];
112
118
  // return ['i', [`data:text/html,${value}`]];
113
119
  },
114
- editUI ({typeNamespace, value}) {
120
+ editUI ({typeNamespace, specificSchemaObject, value}) {
115
121
  const textarea =
116
122
  /**
117
123
  * @type {SCEditorTextarea}
@@ -125,13 +131,16 @@ const blobHTMLType = {
125
131
  }
126
132
  };
127
133
 
128
- const root = /** @type {HTMLDivElement} */ (jml(
134
+ const root = jml(
129
135
  'div',
130
- {dataset: {type: 'blobHTML'}},
136
+ {
137
+ dataset: {type: 'blobHTML'},
138
+ title: specificSchemaObject?.description ?? 'Blob (HTML)'
139
+ },
131
140
  [
132
141
  textarea
133
142
  ]
134
- ));
143
+ );
135
144
  setTimeout(() => {
136
145
  // Push onto these: https://www.sceditor.com/documentation/formats/xhtml/
137
146
  // sceditor.formats.xhtml.converters array
@@ -7,6 +7,10 @@ const SpecialRealNumberSuperType = {
7
7
  option: ['Special Real Number', {title: '`Infinity`, `-Infinity`, `-0`'}],
8
8
  childTypes: ['infinity', 'negativeInfinity', 'negativeZero'],
9
9
  stringRegex: /^(?:-?Infinity|-0)$/u,
10
+ valueMatch (x) {
11
+ return Object.is(x, -0) || x === Number.POSITIVE_INFINITY ||
12
+ x === Number.NEGATIVE_INFINITY;
13
+ },
10
14
  toValue (s) {
11
15
  return {
12
16
  value: s === '-0'
@@ -31,19 +35,31 @@ const SpecialRealNumberSuperType = {
31
35
  this
32
36
  ).getSelect({root}).value = Object.is(value, -0) ? '-0' : String(value);
33
37
  },
34
- viewUI ({value}) {
35
- return ['i', {dataset: {type: 'SpecialRealNumber'}}, [
36
- Object.is(value, -0) ? '-0' : String(value)
38
+ viewUI ({value, specificSchemaObject}) {
39
+ const isNegativeZero = Object.is(value, -0);
40
+ return ['i', {
41
+ dataset: {type: 'SpecialRealNumber'},
42
+ title: specificSchemaObject?.description ?? (isNegativeZero
43
+ ? '(negative zero)'
44
+ : `(${String(value)})`)
45
+ }, [
46
+ isNegativeZero
47
+ ? '-0'
48
+ : String(value)
37
49
  ]];
38
50
  },
39
51
  /* istanbul ignore next -- No dupe keys, array refs, or validation */
40
52
  getInput ({root}) {
41
53
  return /** @type {HTMLSelectElement} */ ($e(root, 'select'));
42
54
  },
43
- editUI ({typeNamespace, value = Number.POSITIVE_INFINITY}) {
44
- return ['div', {dataset: {type: 'SpecialRealNumber'}}, [
55
+ editUI ({
56
+ typeNamespace, specificSchemaObject, value = Number.POSITIVE_INFINITY
57
+ }) {
58
+ return ['div', {
59
+ dataset: {type: 'SpecialRealNumber'},
60
+ title: specificSchemaObject?.description ?? 'Special Real Number'
61
+ }, [
45
62
  ['label', [
46
- 'Special Real Number: ',
47
63
  ['select', {name: `${typeNamespace}-SpecialRealNumber`}, [
48
64
  ['option', {
49
65
  value: 'Infinity', selected: value === Number.POSITIVE_INFINITY
@@ -110,6 +110,13 @@ const getTypedArray = (prop) => {
110
110
  }
111
111
  };
112
112
 
113
+ const bufferSourceClasses = new Set([
114
+ 'ArrayBuffer', 'DataView',
115
+ 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array',
116
+ 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array', 'BigInt64Array',
117
+ 'BigUint64Array'
118
+ ]);
119
+
113
120
  let idx = 0;
114
121
 
115
122
  /**
@@ -125,6 +132,9 @@ const buffersourceType = {
125
132
  'float64array', 'bigint64array', 'biguint64array'
126
133
  ],
127
134
  stringRegex: /^(?<bufferSourceClass>ArrayBuffer|DataView|(?:Int8|Uint8|Uint8Clamped|Int16|Uint16|Int32|Uint32|Float32|Float64|BigInt64|BigUint64)Array)\((?<innerContent>.*)\)$/u,
135
+ valueMatch (x) {
136
+ return bufferSourceClasses.has(toStringTag(x));
137
+ },
128
138
  toValue (s, rootInfo) {
129
139
  const {groups: {
130
140
  bufferSourceClass
@@ -278,12 +288,21 @@ const buffersourceType = {
278
288
  this.getInput({root})
279
289
  ).$value;
280
290
  },
281
- viewUI ({value}) {
291
+ viewUI ({value, specificSchemaObject}) {
282
292
  const stringTag = toStringTag(value);
283
293
  const buffer = stringTag === 'ArrayBuffer' ? value : value.buffer;
284
294
 
285
295
  return ['div', {dataset: {type: 'buffersource'}}, [
286
- ['b', {class: 'emphasis'}, [stringTag]],
296
+ ['b', {
297
+ class: 'emphasis',
298
+ title: specificSchemaObject?.description
299
+ ? (/^[aeiou]/iu).test(stringTag)
300
+ ? `(an ${stringTag})`
301
+ : `(a ${stringTag})`
302
+ : undefined
303
+ }, [
304
+ specificSchemaObject?.description ?? stringTag
305
+ ]],
287
306
  ['br'],
288
307
  ['b', ['Buffer byte length: ']],
289
308
  buffer.byteLength,
@@ -382,15 +401,16 @@ const buffersourceType = {
382
401
  }, ['View data']]
383
402
  ]];
384
403
  },
385
- editUI ({typeNamespace, value}) {
404
+ editUI ({typeNamespace, specificSchemaObject, value}) {
386
405
  idx++;
387
406
 
388
407
  /**
389
408
  * @typedef {() => void} BuildInstances
390
409
  */
391
410
 
392
- const div = /** @type {HTMLDivElement} */ (jml('div', {
393
- dataset: {type: 'buffersource'}
411
+ const div = jml('div', {
412
+ dataset: {type: 'buffersource'},
413
+ title: specificSchemaObject?.description ?? 'BufferSource'
394
414
  }, [
395
415
  ['fieldset', {
396
416
  class: 'returnType',
@@ -406,7 +426,11 @@ const buffersourceType = {
406
426
  $custom: {
407
427
  /** @type {BuildInstances} */
408
428
  $buildInstances () {
409
- const that = /** @type {HTMLFieldSetElement} */ (this);
429
+ const that = /**
430
+ * @type {HTMLFieldSetElement & {
431
+ * $buildInstances: BuildInstances
432
+ * }}
433
+ */ (this);
410
434
  const ancestor = /** @type {HTMLDivElement} */ (that.parentElement);
411
435
  const {value} = /** @type {HTMLInputElement} */ ($e(
412
436
  that, `[name=${typeNamespace}-buffersource-returnType-${idx}]` +
@@ -670,7 +694,8 @@ const buffersourceType = {
670
694
  'Byte length ',
671
695
  ['input', {
672
696
  class: 'byteLength',
673
- type: 'number', step: '1', size: '4', pattern: '\\d+',
697
+ type: 'number', step: '1', size: '4',
698
+ pattern: String.raw`\d+`,
674
699
  min: 0,
675
700
  $custom: {
676
701
  $value: value ?? new ArrayBuffer(0)
@@ -752,7 +777,8 @@ const buffersourceType = {
752
777
  'Max byte length ',
753
778
  ['input', {
754
779
  class: 'maxByteLength',
755
- type: 'number', step: '1', size: '4', pattern: '\\d+',
780
+ type: 'number', step: '1', size: '4',
781
+ pattern: String.raw`\d+`,
756
782
  min: 0,
757
783
  $on: {
758
784
  change (e) {
@@ -786,7 +812,8 @@ const buffersourceType = {
786
812
  'Byte length ',
787
813
  ['input', {
788
814
  class: 'dataViewByteLength',
789
- type: 'number', step: '1', size: '4', pattern: '\\d+',
815
+ type: 'number', step: '1', size: '4',
816
+ pattern: String.raw`\d+`,
790
817
  min: 0,
791
818
  $custom: {
792
819
  /**
@@ -795,9 +822,13 @@ const buffersourceType = {
795
822
 
796
823
  /** @type {CheckDataViewByteLength} */
797
824
  $checkDataViewByteLength (e) {
798
- const that = /** @type {HTMLInputElement} */ (
799
- this
800
- );
825
+ const that = /**
826
+ * @type {HTMLInputElement & {
827
+ * $checkDataViewByteLength: CheckDataViewByteLength
828
+ * }}
829
+ */ (
830
+ this
831
+ );
801
832
  const greatGrandparent = /** @type {HTMLElement} */
802
833
  (that.parentElement?.parentElement?.parentElement);
803
834
 
@@ -855,7 +886,8 @@ const buffersourceType = {
855
886
  'Byte offset ',
856
887
  ['input', {
857
888
  class: 'dataViewByteOffset',
858
- type: 'number', step: '1', size: '4', pattern: '\\d+',
889
+ type: 'number', step: '1', size: '4',
890
+ pattern: String.raw`\d+`,
859
891
  min: 0,
860
892
  $on: {
861
893
  change (e) {
@@ -884,7 +916,8 @@ const buffersourceType = {
884
916
  'Byte offset ',
885
917
  ['input', {
886
918
  class: 'typedArrayByteOffset',
887
- type: 'number', step: '1', size: '4', pattern: '\\d+',
919
+ type: 'number', step: '1', size: '4',
920
+ pattern: String.raw`\d+`,
888
921
  min: 0,
889
922
  max: (2 ** 53) - 1,
890
923
  $custom: {
@@ -894,7 +927,11 @@ const buffersourceType = {
894
927
 
895
928
  /** @type {CheckByteOffsetMultiple} */
896
929
  $checkByteOffsetMultiple (e) {
897
- const that = /** @type {HTMLInputElement} */ (this);
930
+ const that = /**
931
+ * @type {HTMLInputElement & {
932
+ * $checkByteOffsetMultiple: CheckByteOffsetMultiple
933
+ * }}
934
+ */ (this);
898
935
  const ancestor = /** @type {HTMLElement} */ (
899
936
  that.
900
937
  parentElement?.parentElement?.parentElement?.parentElement
@@ -979,7 +1016,12 @@ const buffersourceType = {
979
1016
 
980
1017
  /** @type {HTMLInputElement[]} */ (
981
1018
  $$e(/** @type {HTMLElement} */ (
982
- /** @type {HTMLSelectElement} */ (this).parentElement
1019
+ /**
1020
+ * @type {HTMLSelectElement & {
1021
+ * $setMinsAndMaxes: SetMinsAndMaxes,
1022
+ * $checkTypedArrayByteLength: CheckTypedArrayByteLength
1023
+ * }}
1024
+ */ (this).parentElement
983
1025
  ), '.typedArrayValue')
984
1026
  ).forEach((typedArrayValue) => {
985
1027
  typedArrayValue.className =
@@ -995,7 +1037,12 @@ const buffersourceType = {
995
1037
 
996
1038
  /** @type {CheckTypedArrayByteLength} */
997
1039
  $checkTypedArrayByteLength (e) {
998
- const that = /** @type {HTMLSelectElement} */ (this);
1040
+ const that = /**
1041
+ * @type {HTMLSelectElement & {
1042
+ * $setMinsAndMaxes: SetMinsAndMaxes,
1043
+ * $checkTypedArrayByteLength: CheckTypedArrayByteLength
1044
+ * }}
1045
+ */ (this);
999
1046
  const TypedArray = getTypedArray(
1000
1047
  /** @type {TypedArray} */ (that.value)
1001
1048
  );
@@ -1092,7 +1139,8 @@ const buffersourceType = {
1092
1139
  'Array length: ',
1093
1140
  ['input', {
1094
1141
  class: 'typedArrayLength',
1095
- type: 'number', step: '1', size: '4', pattern: '\\d+',
1142
+ type: 'number', step: '1', size: '4',
1143
+ pattern: String.raw`\d+`,
1096
1144
  min: 0,
1097
1145
  $custom: {
1098
1146
  /**
@@ -1104,7 +1152,12 @@ const buffersourceType = {
1104
1152
 
1105
1153
  /** @type {CheckBufferBounds} */
1106
1154
  $checkBufferBounds (e) {
1107
- const that = /** @type {HTMLInputElement} */ (this);
1155
+ const that = /**
1156
+ * @type {HTMLInputElement & {
1157
+ * $checkBufferBounds: CheckBufferBounds,
1158
+ * $buildTypedArray: BuildTypedArray
1159
+ * }}
1160
+ */ (this);
1108
1161
 
1109
1162
  const ancestor = /** @type {HTMLElement} */ (
1110
1163
  that.parentElement?.parentElement?.parentElement
@@ -1141,10 +1194,6 @@ const buffersourceType = {
1141
1194
  ? Number.parseInt(typedArrayByteOffsetVal)
1142
1195
  : 0;
1143
1196
 
1144
- console.log('1111', typedArrayByteOffset,
1145
- length, TypedArray.BYTES_PER_ELEMENT,
1146
- bufferByteLength);
1147
-
1148
1197
  if (
1149
1198
  (typedArrayByteOffset +
1150
1199
  (length * TypedArray.BYTES_PER_ELEMENT)) >
@@ -1170,7 +1219,12 @@ const buffersourceType = {
1170
1219
 
1171
1220
  /** @type {BuildTypedArray} */
1172
1221
  $buildTypedArray () {
1173
- const that = /** @type {HTMLInputElement} */ (this);
1222
+ const that = /**
1223
+ * @type {HTMLInputElement & {
1224
+ * $checkBufferBounds: CheckBufferBounds,
1225
+ * $buildTypedArray: BuildTypedArray
1226
+ * }}
1227
+ */ (this);
1174
1228
  const length = Number.parseInt(that.value);
1175
1229
  const grandparent = /** @type {HTMLElement} */ (
1176
1230
  that.parentElement?.parentElement
@@ -1224,8 +1278,8 @@ const buffersourceType = {
1224
1278
  },
1225
1279
  type: 'number', step: '1',
1226
1280
  pattern: value.startsWith('Float')
1227
- ? '\\d+(?:\\.\\d+)?'
1228
- : '\\d+',
1281
+ ? String.raw`\d+(?:\.\d+)?`
1282
+ : String.raw`\d+`,
1229
1283
  value: bufferByteLength.$typedArray[key]
1230
1284
  ? String(bufferByteLength.$typedArray[key])
1231
1285
  : '0',
@@ -1268,7 +1322,7 @@ const buffersourceType = {
1268
1322
  );
1269
1323
  // eslint-disable-next-line no-new -- Testing
1270
1324
  new TypedArray(length);
1271
- } catch (err) {
1325
+ } catch {
1272
1326
  that.setCustomValidity('Typed Array length is too long');
1273
1327
  e.stopPropagation();
1274
1328
  that.reportValidity();
@@ -1320,7 +1374,8 @@ const buffersourceType = {
1320
1374
  ['input', {
1321
1375
  type: 'number',
1322
1376
  class: 'dataViewSetByteOffset',
1323
- step: '1', size: '4', pattern: '\\d+'
1377
+ step: '1', size: '4',
1378
+ pattern: String.raw`\d+`
1324
1379
  }]
1325
1380
  ]
1326
1381
  ),
@@ -1330,7 +1385,8 @@ const buffersourceType = {
1330
1385
  'Value ',
1331
1386
  ['input', {
1332
1387
  type: 'number',
1333
- step: '1', size: '4', pattern: '\\d+',
1388
+ step: '1', size: '4',
1389
+ pattern: String.raw`\d+`,
1334
1390
  class: 'typedArrayValue typedArray-' + typedArray,
1335
1391
  ...getMinMaxForTypedArray(typedArray)
1336
1392
  }]
@@ -1434,7 +1490,7 @@ const buffersourceType = {
1434
1490
  ' ',
1435
1491
  ['div', {class: 'dataViewArea'}]
1436
1492
  ]]
1437
- ]));
1493
+ ]);
1438
1494
 
1439
1495
  if (this.setValue && value) {
1440
1496
  this.setValue({root: div, value});
@@ -10,6 +10,9 @@ const dommatrixType = {
10
10
  option: ['DOMMatrix'],
11
11
  childTypes: ['dommatrixreadonly'],
12
12
  stringRegex: /^(?<domMatrixClass>DOMMatrix|DOMMatrixReadOnly)\((?<innerContent>.*)\)$/u,
13
+ valueMatch (x) {
14
+ return ['DOMMatrix', 'DOMMatrixReadOnly'].includes(toStringTag(x));
15
+ },
13
16
  toValue (s, rootInfo) {
14
17
  const {groups: {
15
18
  domMatrixClass
@@ -35,7 +38,7 @@ const dommatrixType = {
35
38
  return {value: dommatrix};
36
39
  },
37
40
  getInput ({root}) {
38
- return /** @type {HTMLInputElement} */ ($e(root, 'input:not([type])'));
41
+ return /** @type {HTMLInputElement} */ ($e(root, 'input'));
39
42
  },
40
43
  setValue ({root, value: o}) {
41
44
  const {is2D} = o;
@@ -221,11 +224,17 @@ const dommatrixType = {
221
224
  m41, m42, m43, m44
222
225
  ]);
223
226
  },
224
- viewUI ({value}) {
227
+ viewUI ({value, specificSchemaObject}) {
225
228
  const isReadWrite = toStringTag(value) === 'DOMMatrix';
226
229
  return ['div', {dataset: {type: 'dommatrix'}}, [
227
- ['b', {class: 'emphasis'}, [
228
- isReadWrite ? 'DOMMatrix' : 'DOMMatrixReadOnly'
230
+ ['b', {
231
+ class: 'emphasis',
232
+ title: specificSchemaObject?.description
233
+ ? `(a \`${(isReadWrite ? 'DOMMatrix' : 'DOMMatrixReadOnly')}\`)`
234
+ : undefined
235
+ }, [
236
+ specificSchemaObject?.description ??
237
+ (isReadWrite ? 'DOMMatrix' : 'DOMMatrixReadOnly')
229
238
  ]],
230
239
  value.is2D
231
240
  ? ['div', [
@@ -301,11 +310,15 @@ const dommatrixType = {
301
310
  ]]
302
311
  ]];
303
312
  },
304
- editUI ({typeNamespace, value = {}}) {
313
+ editUI ({typeNamespace, specificSchemaObject, value = {}}) {
305
314
  idx++;
306
315
  const {is2D} = value;
307
- // eslint-disable-next-line @stylistic/max-len -- Long
308
- return ['div', {dataset: {type: 'dommatrix'}}, /** @type {import('jamilih').JamilihChildren} */ ([
316
+ const step = 'any'; // Proper step?
317
+
318
+ return ['div', {
319
+ dataset: {type: 'dommatrix'},
320
+ title: specificSchemaObject?.description ?? 'DOMMatrix'
321
+ }, /** @type {import('jamilih').JamilihChildren} */ ([
309
322
  ['div', [
310
323
  ['label', [
311
324
  ['input', {
@@ -376,6 +389,8 @@ const dommatrixType = {
376
389
  ['label', [
377
390
  label + ': ',
378
391
  ['input', {
392
+ type: 'number',
393
+ step,
379
394
  class: label,
380
395
  name: `${typeNamespace}-dommatrix-${label}`,
381
396
  value: value[label] ?? ''
@@ -397,6 +412,8 @@ const dommatrixType = {
397
412
  ['label', [
398
413
  label + ': ',
399
414
  ['input', {
415
+ type: 'number',
416
+ step,
400
417
  class: label,
401
418
  name: `${typeNamespace}-dommatrix-${label}`,
402
419
  value: value[label] ?? ''
@@ -10,6 +10,9 @@ const dompointType = {
10
10
  option: ['DOMPoint'],
11
11
  childTypes: ['dompointreadonly'],
12
12
  stringRegex: /^(?<domPointClass>DOMPoint|DOMPointReadOnly)\((?<innerContent>.*)\)$/u,
13
+ valueMatch (x) {
14
+ return ['DOMPoint', 'DOMPointReadOnly'].includes(toStringTag(x));
15
+ },
13
16
  toValue (s, rootInfo) {
14
17
  const {groups: {
15
18
  domPointClass
@@ -23,7 +26,7 @@ const dompointType = {
23
26
  )(x, y, z, w)};
24
27
  },
25
28
  getInput ({root}) {
26
- return /** @type {HTMLInputElement} */ ($e(root, 'input:not([type])'));
29
+ return /** @type {HTMLInputElement} */ ($e(root, 'input'));
27
30
  },
28
31
  setValue ({root, value}) {
29
32
  /** @type {HTMLInputElement} */ (
@@ -68,11 +71,17 @@ const dompointType = {
68
71
  ).checked;
69
72
  return new (isReadWrite ? DOMPoint : DOMPointReadOnly)(x, y, z, w);
70
73
  },
71
- viewUI ({value}) {
74
+ viewUI ({value, specificSchemaObject}) {
72
75
  const isReadWrite = toStringTag(value) === 'DOMPoint';
73
- return ['div', {dataset: {type: 'dompoint'}}, [
76
+ return ['div', {
77
+ dataset: {type: 'dompoint'},
78
+ title: specificSchemaObject?.description
79
+ ? `(a \`${(isReadWrite ? 'DOMPoint' : 'DOMPointReadOnly')}\`)`
80
+ : undefined
81
+ }, [
74
82
  ['b', {class: 'emphasis'}, [
75
- isReadWrite ? 'DOMPoint' : 'DOMPointReadOnly'
83
+ specificSchemaObject?.description ??
84
+ (isReadWrite ? 'DOMPoint' : 'DOMPointReadOnly')
76
85
  ]],
77
86
  ['br'],
78
87
  ['b', ['x ']],
@@ -88,15 +97,18 @@ const dompointType = {
88
97
  value.w
89
98
  ]];
90
99
  },
91
- editUI ({typeNamespace, value = {
100
+ editUI ({typeNamespace, specificSchemaObject, value = {
92
101
  x: '',
93
102
  y: '',
94
103
  z: '',
95
104
  w: ''
96
105
  }}) {
97
106
  idx++;
98
- // eslint-disable-next-line @stylistic/max-len -- Long
99
- return ['div', {dataset: {type: 'dompoint'}}, /** @type {import('jamilih').JamilihChildren} */ ([
107
+ const step = 'any'; // Proper step?
108
+ return ['div', {
109
+ dataset: {type: 'dompoint'},
110
+ title: specificSchemaObject?.description ?? 'DOMPoint'
111
+ }, /** @type {import('jamilih').JamilihChildren} */ ([
100
112
  ['div', [
101
113
  ['label', [
102
114
  ['input', {
@@ -123,6 +135,8 @@ const dompointType = {
123
135
  ['label', [
124
136
  'x: ',
125
137
  ['input', {
138
+ type: 'number',
139
+ step,
126
140
  class: 'x',
127
141
  name: `${typeNamespace}-dompoint-x`, value: value.x
128
142
  }]
@@ -131,6 +145,8 @@ const dompointType = {
131
145
  ['label', [
132
146
  'y: ',
133
147
  ['input', {
148
+ type: 'number',
149
+ step,
134
150
  class: 'y',
135
151
  name: `${typeNamespace}-dompoint-y`, value: value.y
136
152
  }]
@@ -139,6 +155,8 @@ const dompointType = {
139
155
  ['label', [
140
156
  'z: ',
141
157
  ['input', {
158
+ type: 'number',
159
+ step,
142
160
  class: 'z',
143
161
  name: `${typeNamespace}-dompoint-z`, value: value.z
144
162
  }]
@@ -147,6 +165,8 @@ const dompointType = {
147
165
  ['label', [
148
166
  'w: ',
149
167
  ['input', {
168
+ type: 'number',
169
+ step,
150
170
  class: 'w',
151
171
  name: `${typeNamespace}-dompoint-w`, value: value.w
152
172
  }]