@es-joy/jsoe 0.2.0 → 0.4.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 (192) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.cjs +2 -0
  3. package/.ncurc.cjs +9 -0
  4. package/CHANGES.md +9 -0
  5. package/README.md +2 -2
  6. package/demo/index.html +8 -0
  7. package/demo/index.js +1 -1
  8. package/dist/formatAndTypeChoices.d.ts +56 -0
  9. package/dist/formatAndTypeChoices.d.ts.map +1 -0
  10. package/dist/formats/indexedDBKey.d.ts +4 -0
  11. package/dist/formats/indexedDBKey.d.ts.map +1 -0
  12. package/dist/formats/json.d.ts +4 -0
  13. package/dist/formats/json.d.ts.map +1 -0
  14. package/dist/formats/schemaAndArbitrary.d.ts +6 -0
  15. package/dist/formats/schemaAndArbitrary.d.ts.map +1 -0
  16. package/dist/formats/schemaOnly.d.ts +6 -0
  17. package/dist/formats/schemaOnly.d.ts.map +1 -0
  18. package/dist/formats/structuredCloning.d.ts +20 -0
  19. package/dist/formats/structuredCloning.d.ts.map +1 -0
  20. package/dist/formats.d.ts +26 -0
  21. package/dist/formats.d.ts.map +1 -0
  22. package/dist/fundamentalTypes/BooleanObjectType.d.ts +8 -0
  23. package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -0
  24. package/dist/fundamentalTypes/NumberObjectType.d.ts +6 -0
  25. package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -0
  26. package/dist/fundamentalTypes/StringObjectType.d.ts +6 -0
  27. package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -0
  28. package/dist/fundamentalTypes/arrayReferenceType.d.ts +8 -0
  29. package/dist/fundamentalTypes/arrayReferenceType.d.ts.map +1 -0
  30. package/dist/fundamentalTypes/arrayType.d.ts +60 -0
  31. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -0
  32. package/dist/fundamentalTypes/bigintType.d.ts +6 -0
  33. package/dist/fundamentalTypes/bigintType.d.ts.map +1 -0
  34. package/dist/fundamentalTypes/dateType.d.ts +26 -0
  35. package/dist/fundamentalTypes/dateType.d.ts.map +1 -0
  36. package/dist/fundamentalTypes/nullType.d.ts +6 -0
  37. package/dist/fundamentalTypes/nullType.d.ts.map +1 -0
  38. package/dist/fundamentalTypes/numberType.d.ts +6 -0
  39. package/dist/fundamentalTypes/numberType.d.ts.map +1 -0
  40. package/dist/fundamentalTypes/objectReferenceType.d.ts +8 -0
  41. package/dist/fundamentalTypes/objectReferenceType.d.ts.map +1 -0
  42. package/dist/fundamentalTypes/objectType.d.ts +6 -0
  43. package/dist/fundamentalTypes/objectType.d.ts.map +1 -0
  44. package/dist/fundamentalTypes/regexpType.d.ts +8 -0
  45. package/dist/fundamentalTypes/regexpType.d.ts.map +1 -0
  46. package/dist/fundamentalTypes/sparseUndefinedType.d.ts +6 -0
  47. package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -0
  48. package/dist/fundamentalTypes/stringType.d.ts +6 -0
  49. package/dist/fundamentalTypes/stringType.d.ts.map +1 -0
  50. package/dist/fundamentalTypes/undefinedType.d.ts +6 -0
  51. package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -0
  52. package/dist/index.d.ts +5 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/src/deepEqual.d.ts +3 -0
  55. package/dist/src/deepEqual.d.ts.map +1 -0
  56. package/dist/src/formatAndTypeChoices.d.ts +47 -0
  57. package/dist/src/formatAndTypeChoices.d.ts.map +1 -0
  58. package/dist/src/formats/indexedDBKey.d.ts +9 -0
  59. package/dist/src/formats/indexedDBKey.d.ts.map +1 -0
  60. package/dist/src/formats/json.d.ts +9 -0
  61. package/dist/src/formats/json.d.ts.map +1 -0
  62. package/dist/src/formats/schemaAndArbitrary.d.ts +6 -0
  63. package/dist/src/formats/schemaAndArbitrary.d.ts.map +1 -0
  64. package/dist/src/formats/schemaOnly.d.ts +6 -0
  65. package/dist/src/formats/schemaOnly.d.ts.map +1 -0
  66. package/dist/src/formats/structuredCloning.d.ts +15 -0
  67. package/dist/src/formats/structuredCloning.d.ts.map +1 -0
  68. package/dist/src/formats.d.ts +18 -0
  69. package/dist/src/formats.d.ts.map +1 -0
  70. package/dist/src/fundamentalTypes/BooleanObjectType.d.ts +6 -0
  71. package/dist/src/fundamentalTypes/BooleanObjectType.d.ts.map +1 -0
  72. package/dist/src/fundamentalTypes/NumberObjectType.d.ts +6 -0
  73. package/dist/src/fundamentalTypes/NumberObjectType.d.ts.map +1 -0
  74. package/dist/src/fundamentalTypes/StringObjectType.d.ts +6 -0
  75. package/dist/src/fundamentalTypes/StringObjectType.d.ts.map +1 -0
  76. package/dist/src/fundamentalTypes/arrayReferenceType.d.ts +6 -0
  77. package/dist/src/fundamentalTypes/arrayReferenceType.d.ts.map +1 -0
  78. package/dist/src/fundamentalTypes/arrayType.d.ts +6 -0
  79. package/dist/src/fundamentalTypes/arrayType.d.ts.map +1 -0
  80. package/dist/src/fundamentalTypes/bigintType.d.ts +6 -0
  81. package/dist/src/fundamentalTypes/bigintType.d.ts.map +1 -0
  82. package/dist/src/fundamentalTypes/dateType.d.ts +6 -0
  83. package/dist/src/fundamentalTypes/dateType.d.ts.map +1 -0
  84. package/dist/src/fundamentalTypes/nullType.d.ts +6 -0
  85. package/dist/src/fundamentalTypes/nullType.d.ts.map +1 -0
  86. package/dist/src/fundamentalTypes/numberType.d.ts +6 -0
  87. package/dist/src/fundamentalTypes/numberType.d.ts.map +1 -0
  88. package/dist/src/fundamentalTypes/objectReferenceType.d.ts +6 -0
  89. package/dist/src/fundamentalTypes/objectReferenceType.d.ts.map +1 -0
  90. package/dist/src/fundamentalTypes/objectType.d.ts +6 -0
  91. package/dist/src/fundamentalTypes/objectType.d.ts.map +1 -0
  92. package/dist/src/fundamentalTypes/regexpType.d.ts +6 -0
  93. package/dist/src/fundamentalTypes/regexpType.d.ts.map +1 -0
  94. package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts +6 -0
  95. package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -0
  96. package/dist/src/fundamentalTypes/stringType.d.ts +6 -0
  97. package/dist/src/fundamentalTypes/stringType.d.ts.map +1 -0
  98. package/dist/src/fundamentalTypes/undefinedType.d.ts +6 -0
  99. package/dist/src/fundamentalTypes/undefinedType.d.ts.map +1 -0
  100. package/dist/src/index.d.ts +5 -0
  101. package/dist/src/index.d.ts.map +1 -0
  102. package/dist/src/subTypes/blobHTMLType.d.ts +26 -0
  103. package/dist/src/subTypes/blobHTMLType.d.ts.map +1 -0
  104. package/dist/src/subTypes/falseType.d.ts +6 -0
  105. package/dist/src/subTypes/falseType.d.ts.map +1 -0
  106. package/dist/src/subTypes/trueType.d.ts +6 -0
  107. package/dist/src/subTypes/trueType.d.ts.map +1 -0
  108. package/dist/src/superTypes/SpecialNumberSuperType.d.ts +11 -0
  109. package/dist/src/superTypes/SpecialNumberSuperType.d.ts.map +1 -0
  110. package/dist/src/superTypes/SpecialRealNumberSuperType.d.ts +6 -0
  111. package/dist/src/superTypes/SpecialRealNumberSuperType.d.ts.map +1 -0
  112. package/dist/src/typeChoices.d.ts +30 -0
  113. package/dist/src/typeChoices.d.ts.map +1 -0
  114. package/dist/src/types.d.ts +333 -0
  115. package/dist/src/types.d.ts.map +1 -0
  116. package/dist/src/utils/dialogs.d.ts +29 -0
  117. package/dist/src/utils/dialogs.d.ts.map +1 -0
  118. package/dist/src/utils/jsonPointer.d.ts +42 -0
  119. package/dist/src/utils/jsonPointer.d.ts.map +1 -0
  120. package/dist/src/utils/templateUtils.d.ts +59 -0
  121. package/dist/src/utils/templateUtils.d.ts.map +1 -0
  122. package/dist/src/utils/types.d.ts +2 -0
  123. package/dist/src/utils/types.d.ts.map +1 -0
  124. package/dist/subTypes/blobHTMLType.d.ts +14 -0
  125. package/dist/subTypes/blobHTMLType.d.ts.map +1 -0
  126. package/dist/subTypes/falseType.d.ts +8 -0
  127. package/dist/subTypes/falseType.d.ts.map +1 -0
  128. package/dist/subTypes/trueType.d.ts +8 -0
  129. package/dist/subTypes/trueType.d.ts.map +1 -0
  130. package/dist/superTypes/SpecialNumberSuperType.d.ts +14 -0
  131. package/dist/superTypes/SpecialNumberSuperType.d.ts.map +1 -0
  132. package/dist/superTypes/SpecialRealNumberSuperType.d.ts +6 -0
  133. package/dist/superTypes/SpecialRealNumberSuperType.d.ts.map +1 -0
  134. package/dist/typeChoices.d.ts +103 -0
  135. package/dist/typeChoices.d.ts.map +1 -0
  136. package/dist/types.d.ts +523 -0
  137. package/dist/types.d.ts.map +1 -0
  138. package/dist/utils/dialogs.d.ts +109 -0
  139. package/dist/utils/dialogs.d.ts.map +1 -0
  140. package/dist/utils/jsonPointer.d.ts +46 -0
  141. package/dist/utils/jsonPointer.d.ts.map +1 -0
  142. package/dist/utils/templateUtils.d.ts +59 -0
  143. package/dist/utils/templateUtils.d.ts.map +1 -0
  144. package/dist/utils/types.d.ts +2 -0
  145. package/dist/utils/types.d.ts.map +1 -0
  146. package/dist/vendor/jamilih/dist/jml-es.d.ts +436 -0
  147. package/dist/vendor/jamilih/dist/jml-es.d.ts.map +1 -0
  148. package/dist/vendor/typeson-registry/dist/index.d.ts +400 -0
  149. package/dist/vendor/typeson-registry/dist/index.d.ts.map +1 -0
  150. package/dist/vendor-imports.d.ts +3 -0
  151. package/dist/vendor-imports.d.ts.map +1 -0
  152. package/package.json +19 -14
  153. package/postorder-traversal.js +58 -0
  154. package/src/formatAndTypeChoices.js +95 -50
  155. package/src/formats/indexedDBKey.js +49 -56
  156. package/src/formats/json.js +47 -56
  157. package/src/formats/schemaOnly.js +12 -2
  158. package/src/formats/structuredCloning.js +162 -105
  159. package/src/formats.js +38 -10
  160. package/src/fundamentalTypes/BooleanObjectType.js +6 -4
  161. package/src/fundamentalTypes/NumberObjectType.js +5 -3
  162. package/src/fundamentalTypes/StringObjectType.js +1 -1
  163. package/src/fundamentalTypes/arrayReferenceType.js +29 -14
  164. package/src/fundamentalTypes/arrayType.js +789 -278
  165. package/src/fundamentalTypes/bigintType.js +2 -2
  166. package/src/fundamentalTypes/dateType.js +42 -14
  167. package/src/fundamentalTypes/nullType.js +1 -1
  168. package/src/fundamentalTypes/numberType.js +2 -2
  169. package/src/fundamentalTypes/objectReferenceType.js +7 -5
  170. package/src/fundamentalTypes/regexpType.js +45 -24
  171. package/src/fundamentalTypes/sparseUndefinedType.js +7 -1
  172. package/src/fundamentalTypes/stringType.js +1 -1
  173. package/src/fundamentalTypes/undefinedType.js +2 -2
  174. package/src/jsoe.css +1 -1
  175. package/src/subTypes/blobHTMLType.js +42 -22
  176. package/src/subTypes/falseType.js +2 -2
  177. package/src/subTypes/trueType.js +2 -2
  178. package/src/superTypes/SpecialNumberSuperType.js +30 -16
  179. package/src/superTypes/SpecialRealNumberSuperType.js +62 -0
  180. package/src/typeChoices.js +137 -55
  181. package/src/types.js +312 -148
  182. package/src/utils/dialogs.js +98 -29
  183. package/src/utils/jsonPointer.js +4 -0
  184. package/src/utils/templateUtils.js +27 -12
  185. package/src/vendor-imports.js +8 -0
  186. package/tsconfig.json +18 -0
  187. package/typings/sceditor.d.ts +20 -0
  188. package/vendor/jamilih/dist/jml-es.js +1019 -389
  189. package/vendor/jamilih/dist/jml.d.ts +436 -0
  190. package/vendor/jamilih/package.json +136 -0
  191. package/vendor/typeson-registry/dist/index.js +382 -84
  192. package/src/superTypes/InfinitiesSuperType.js +0 -49
@@ -0,0 +1,62 @@
1
+ import {$e} from '../utils/templateUtils.js';
2
+
3
+ /**
4
+ * @type {import('./SpecialNumberSuperType.js').SuperTypeObject}
5
+ */
6
+ const SpecialRealNumberSuperType = {
7
+ option: ['Special Real Number', {title: '`Infinity`, `-Infinity`, `-0`'}],
8
+ childTypes: ['infinity', 'negativeInfinity', 'negativeZero'],
9
+ stringRegex: /^(?:-?Infinity|-0)$/u,
10
+ toValue (s) {
11
+ return {
12
+ value: s === '-0'
13
+ ? -0
14
+ : s === 'Infinity'
15
+ ? Number.POSITIVE_INFINITY
16
+ : Number.NEGATIVE_INFINITY
17
+ };
18
+ },
19
+ getSelect ({root}) {
20
+ return /** @type {HTMLSelectElement} */ ($e(root, 'select'));
21
+ },
22
+ getValue ({root}) {
23
+ return this.toValue(
24
+ /** @type {Required<import('../types.js').TypeObject>} */ (
25
+ this
26
+ ).getSelect({root}).value
27
+ ).value;
28
+ },
29
+ setValue ({root, value}) {
30
+ /** @type {Required<import('../types.js').TypeObject>} */ (
31
+ this
32
+ ).getSelect({root}).value = String(value);
33
+ },
34
+ viewUI ({value}) {
35
+ return ['i', {dataset: {type: 'SpecialRealNumber'}}, [
36
+ Object.is(value, -0) ? '-0' : String(value)
37
+ ]];
38
+ },
39
+ getInput ({root}) {
40
+ return /** @type {HTMLSelectElement} */ ($e(root, 'select'));
41
+ },
42
+ editUI ({typeNamespace, value = Number.POSITIVE_INFINITY}) {
43
+ return ['div', {dataset: {type: 'SpecialRealNumber'}}, [
44
+ ['label', [
45
+ 'Special Real Number: ',
46
+ ['select', {name: `${typeNamespace}-SpecialRealNumber`}, [
47
+ ['option', {
48
+ value: 'Infinity', selected: value === Number.POSITIVE_INFINITY
49
+ }, ['Infinity']],
50
+ ['option', {
51
+ value: '-Infinity', selected: value === Number.NEGATIVE_INFINITY
52
+ }, ['-Infinity']],
53
+ ['option', {
54
+ value: '-0', selected: Object.is(value, -0)
55
+ }, ['-0']]
56
+ ]]
57
+ ]]
58
+ ]];
59
+ }
60
+ };
61
+
62
+ export default SpecialRealNumberSuperType;
@@ -1,30 +1,79 @@
1
+ import {jml} from './vendor-imports.js';
1
2
  import Formats, {getControlsForFormatAndValue} from './formats.js';
2
3
  import Types from './types.js';
3
- import {jml} from '../vendor/jamilih/dist/jml-es.js';
4
4
 
5
5
  import {$e, DOM} from './utils/templateUtils.js';
6
6
  import dialogs from './utils/dialogs.js';
7
7
 
8
8
  /**
9
- * An arbitrary Structured Clone, JSON, etc. value.
10
- * @typedef {any} StructuredCloneValue
9
+ * @typedef {(info: {type: string, editUI: Element}) => void} AddTypeAndEditUI
10
+ */
11
+
12
+ /**
13
+ * @typedef {(info?: {
14
+ * baseValue?: import('./formats.js').StructuredCloneValue,
15
+ * bringIntoFocus?: boolean
16
+ * }) => void} AddAndValidateEditUI
17
+ */
18
+
19
+ /**
20
+ * @typedef {() => void} SetStyles
21
+ */
22
+
23
+ /**
24
+ * @typedef {Element & {
25
+ * $addAndValidateEditUI: AddAndValidateEditUI,
26
+ * $setStyles: SetStyles
27
+ * }} TypeChoicesElementAPI
28
+ */
29
+
30
+ /**
31
+ * @callback GetValue
32
+ * @param {import('./types.js').StateObject} [stateObj] Will
33
+ * auto-set `typeNamespace` and `format`
34
+ * @param {string} [currentPath]
35
+ * @returns {import('./formats.js').StructuredCloneValue}
36
+ */
37
+
38
+ /**
39
+ * @callback GetType
40
+ * @returns {string|null|undefined}
41
+ */
42
+
43
+ /**
44
+ * @callback ValidValuesSet
45
+ * @returns {boolean}
46
+ */
47
+
48
+ /**
49
+ * @callback SetValue
50
+ * @param {import('./formats.js').StructuredCloneValue} value
51
+ * @param {import('./types.js').StateObject} stateObj
52
+ * @returns {Promise<void>}
11
53
  */
12
54
 
13
55
  /**
14
56
  * @callback BuildTypeChoices
15
- * @param {object} cfg
16
- * @param {string} cfg.format
17
- * @param {string} cfg.typeNamespace
18
- * @param {StructuredCloneValue} cfg.value
19
- * @param {boolean} [cfg.setValue=false]
20
- * @param {string} cfg.state
21
- * @param {string} cfg.keySelectClass
22
- * @param {boolean} cfg.requireObject
23
- * @param {boolean} cfg.objectHasValue
24
- * @param {RootElement} cfg.topRoot Always a `div` element?
25
- * @param {string} cfg.schema Schema name
26
- * @param {string} cfg.schemaContent Schema contents
27
- * @returns {[select: Element, typeContainer: Element]}
57
+ * @param {{
58
+ * format: import('./formats.js').AvailableFormat,
59
+ * typeNamespace?: string,
60
+ * value?: import('./formats.js').StructuredCloneValue,
61
+ * setValue?: boolean,
62
+ * state?: string,
63
+ * keySelectClass?: string,
64
+ * requireObject?: boolean,
65
+ * objectHasValue?: boolean,
66
+ * topRoot: import('./types.js').RootElement,
67
+ * schema?: string,
68
+ * schemaContent?: object,
69
+ * }} cfg
70
+ * @returns {{
71
+ * domArray: [select: Element, typeContainer: Element],
72
+ * getValue: GetValue,
73
+ * getType: GetType,
74
+ * validValuesSet: ValidValuesSet,
75
+ * setValue: SetValue
76
+ * }}
28
77
  */
29
78
 
30
79
  /**
@@ -50,7 +99,7 @@ export const buildTypeChoices = ({
50
99
  : Types.getTypeOptionsForFormatAndState(format, state);
51
100
 
52
101
  let editUI;
53
- const sel = jml('select', {
102
+ const sel = /** @type {HTMLSelectElement} */ (jml('select', {
54
103
  hidden: requireObject,
55
104
  class: `typeChoices-${typeNamespace}${keySelectClass
56
105
  ? ' ' + keySelectClass
@@ -58,15 +107,27 @@ export const buildTypeChoices = ({
58
107
  }`,
59
108
  // is: 'type-choices',
60
109
  $custom: {
110
+ /**
111
+ * @param {object} cfg
112
+ * @param {string} cfg.type
113
+ * @param {import('./formats.js').StructuredCloneValue} cfg.baseValue
114
+ * @param {boolean} cfg.bringIntoFocus
115
+ * @returns {void}
116
+ */
61
117
  $setType ({type, baseValue, bringIntoFocus}) {
62
118
  this.value = type;
63
119
  this.$setStyles();
64
120
  this.$addAndValidateEditUI({baseValue, bringIntoFocus});
65
121
  },
122
+ /**
123
+ * @type {(info: {type: string}) => void} cfg
124
+ */
66
125
  $setTypeNoEditUI ({type}) {
67
126
  this.value = type;
68
127
  this.$setStyles();
69
128
  },
129
+
130
+ /** @type {SetStyles} */
70
131
  $setStyles () {
71
132
  const {value: type} = this;
72
133
  this.dataset.type = type; // Used for styling
@@ -74,7 +135,7 @@ export const buildTypeChoices = ({
74
135
  if (parEl.nodeName.toLowerCase() === 'fieldset') {
75
136
  parEl.dataset.type = type;
76
137
  DOM.filterChildElements(parEl, 'legend').forEach((legend) => {
77
- legend.dataset.type = type;
138
+ /** @type {HTMLElement} */ (legend).dataset.type = type;
78
139
  });
79
140
  }
80
141
  },
@@ -86,6 +147,8 @@ export const buildTypeChoices = ({
86
147
  }
87
148
  return $e(container, 'div[data-type]');
88
149
  },
150
+
151
+ /** @type {AddAndValidateEditUI} */
89
152
  $addAndValidateEditUI ({baseValue, bringIntoFocus} = {}) {
90
153
  const {value: type} = this;
91
154
 
@@ -113,10 +176,15 @@ export const buildTypeChoices = ({
113
176
  // Needed; Array/object ref somewhere could now be valid or invalid
114
177
  Types.validateAllReferences({topRoot});
115
178
  },
179
+
180
+ /** @type {AddTypeAndEditUI} */
116
181
  $addTypeAndEditUI ({type, editUI}) {
117
182
  this.$setTypeNoEditUI({type});
118
183
  this.$addEditUI({editUI});
119
184
  },
185
+ /**
186
+ * @type {(info: {editUI: Element}) => void}
187
+ */
120
188
  $addEditUI ({editUI}) {
121
189
  const container = this.$getContainer();
122
190
  DOM.removeChildren(container);
@@ -128,6 +196,9 @@ export const buildTypeChoices = ({
128
196
  $getTopRoot () {
129
197
  return topRoot || this.$getTypeRoot();
130
198
  },
199
+ /**
200
+ * @returns {boolean}
201
+ */
131
202
  $validate () {
132
203
  const {value: type} = this;
133
204
  const container = this.$getContainer();
@@ -143,14 +214,16 @@ export const buildTypeChoices = ({
143
214
  $on: {change (e) {
144
215
  // We don't want form `onchange` to run `$checkForKeyDuplicates`
145
216
  // again (through `addAndValidateEditUI`->`validateAllReferences`)
146
- e.stopPropagation();
147
- this.$addAndValidateEditUI();
148
- this.$setStyles();
217
+ e?.stopPropagation();
218
+ /** @type {TypeChoicesElementAPI} */ (this).$addAndValidateEditUI();
219
+ /** @type {TypeChoicesElementAPI} */ (this).$setStyles();
149
220
  }}
150
221
  }, [
151
222
  ['option', {value: ''}, [
152
223
  '(Choose a type)'
153
224
  ]],
225
+ // [string, {value: AvailableType; title?: string | undefined;}]
226
+ // @ts-ignore Apparent TS bug
154
227
  ...typeOptions.map(
155
228
  ([optText, optAtts]) => [
156
229
  'option',
@@ -160,7 +233,7 @@ export const buildTypeChoices = ({
160
233
  [optText]
161
234
  ]
162
235
  )
163
- ]);
236
+ ]));
164
237
  if (setValue || (requireObject && !objectHasValue)) {
165
238
  setTimeout(async () => {
166
239
  if (!setValue) { // if (requireObject && !objectHasValue) {
@@ -179,8 +252,15 @@ export const buildTypeChoices = ({
179
252
  schemaContent
180
253
  }
181
254
  );
182
- const type = Types.getTypeForRoot(rootEditUI);
183
- sel.$addTypeAndEditUI({type, editUI: rootEditUI});
255
+ const type = /** @type {string} */ (
256
+ Types.getTypeForRoot(/** @type {HTMLDivElement} */ (
257
+ rootEditUI
258
+ ))
259
+ );
260
+ // eslint-disable-next-line max-len -- Long
261
+ /** @type {HTMLSelectElement & {$addTypeAndEditUI: AddTypeAndEditUI}} */ (
262
+ sel
263
+ ).$addTypeAndEditUI({type, editUI: rootEditUI});
184
264
  } catch (err) {
185
265
  /* istanbul ignore next -- At least some errors handled earlier */
186
266
  dialogs.alert({
@@ -193,7 +273,9 @@ export const buildTypeChoices = ({
193
273
  });
194
274
  }
195
275
 
196
- const typeContainer = jml('div', {class: 'typeContainer'});
276
+ const typeContainer = /** @type {HTMLDivElement} */ (
277
+ jml('div', {class: 'typeContainer'})
278
+ );
197
279
 
198
280
  return {
199
281
  domArray: [
@@ -201,49 +283,49 @@ export const buildTypeChoices = ({
201
283
  typeContainer
202
284
  ],
203
285
 
204
- /**
205
- * @param {import('./types.js').StateObject} [stateObj] Will
206
- * auto-set `typeNamespace` and `format`
207
- * @param {string} [currentPath]
208
- * @returns {StructuredCloneValue}
209
- */
286
+ /** @type {GetValue} */
210
287
  getValue (stateObj, currentPath) {
211
- const root = $e(typeContainer, 'div[data-type]');
212
- return Types.getValueForRoot(root, {
213
- typeNamespace,
214
- format,
215
- ...stateObj
216
- }, currentPath);
288
+ const root = /** @type {HTMLDivElement} */ (
289
+ $e(typeContainer, 'div[data-type]')
290
+ );
291
+ return Types.getValueForRoot(
292
+ root,
293
+ /** @type {import('./types.js').StateObject} */ ({
294
+ typeNamespace,
295
+ format,
296
+ ...stateObj
297
+ }), currentPath
298
+ );
217
299
  },
218
300
 
219
- /**
220
- * @returns {string|undefined}
221
- */
301
+ /** @type {GetType} */
222
302
  getType () {
223
- const root = $e(typeContainer, 'div[data-type]');
303
+ const root = /** @type {HTMLDivElement} */ (
304
+ $e(typeContainer, 'div[data-type]')
305
+ );
224
306
  return Types.getTypeForRoot(root);
225
307
  },
226
308
 
227
- /**
228
- * @returns {boolean}
229
- */
309
+ /** @type {ValidValuesSet} */
230
310
  validValuesSet () {
231
- const root = $e(typeContainer, 'div[data-type]');
232
- const form = root.closest('form');
311
+ const root = /** @type {HTMLDivElement} */ (
312
+ $e(typeContainer, 'div[data-type]')
313
+ );
314
+ const form = /** @type {HTMLFormElement} */ (root.closest('form'));
233
315
  return Types.validValuesSet({form, typeNamespace});
234
316
  },
235
317
 
236
- /**
237
- * @param {StructuredCloneValue} value
238
- * @param {import('./types.js').StateObject} stateObj
239
- * @returns {Promise<void>}
240
- */
318
+ /** @type {SetValue} */
241
319
  async setValue (value, stateObj) {
242
- const rootEditUI = await getControlsForFormatAndValue(
243
- format, value, stateObj
320
+ const rootEditUI = /** @type {HTMLDivElement} */ (
321
+ await getControlsForFormatAndValue(
322
+ format, value, stateObj
323
+ )
244
324
  );
245
- const type = Types.getTypeForRoot(rootEditUI);
246
- sel.$addTypeAndEditUI({type, editUI: rootEditUI});
325
+ const type = /** @type {string} */ (Types.getTypeForRoot(rootEditUI));
326
+ /** @type {HTMLSelectElement & {$addTypeAndEditUI: AddTypeAndEditUI}} */ (
327
+ sel
328
+ ).$addTypeAndEditUI({type, editUI: rootEditUI});
247
329
  }
248
330
  };
249
331
  };