@es-joy/jsoe 0.5.1 → 0.6.1

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 (80) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.cjs +2 -0
  3. package/.nyc_output/out.json +121296 -0
  4. package/CHANGES.md +10 -0
  5. package/README.md +47 -21
  6. package/cypress.config.ts +13 -0
  7. package/demo/index-instrumented.html +29 -0
  8. package/demo/index.html +10 -1
  9. package/demo/index.js +482 -126
  10. package/dist/formatAndTypeChoices.d.ts +2 -2
  11. package/dist/formatAndTypeChoices.d.ts.map +1 -1
  12. package/dist/formats/json.d.ts.map +1 -1
  13. package/dist/formats/structuredCloning.d.ts +2 -1
  14. package/dist/formats/structuredCloning.d.ts.map +1 -1
  15. package/dist/fundamentalTypes/arrayType.d.ts +6 -37
  16. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  17. package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
  18. package/dist/fundamentalTypes/errorType.d.ts +6 -0
  19. package/dist/fundamentalTypes/errorType.d.ts.map +1 -0
  20. package/dist/fundamentalTypes/mapType.d.ts +6 -0
  21. package/dist/fundamentalTypes/mapType.d.ts.map +1 -0
  22. package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
  23. package/dist/fundamentalTypes/objectReferenceType.d.ts.map +1 -1
  24. package/dist/fundamentalTypes/setType.d.ts +6 -0
  25. package/dist/fundamentalTypes/setType.d.ts.map +1 -0
  26. package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
  27. package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
  28. package/dist/subTypes/blobHTMLType.d.ts +12 -6
  29. package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
  30. package/dist/superTypes/SpecialNumberType.d.ts +14 -0
  31. package/dist/superTypes/SpecialNumberType.d.ts.map +1 -0
  32. package/dist/superTypes/SpecialRealNumberType.d.ts +6 -0
  33. package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -0
  34. package/dist/superTypes/errorsSpecialType.d.ts +8 -0
  35. package/dist/superTypes/errorsSpecialType.d.ts.map +1 -0
  36. package/dist/typeChoices.d.ts +4 -2
  37. package/dist/typeChoices.d.ts.map +1 -1
  38. package/dist/types.d.ts +83 -231
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/utils/dialogs.d.ts +22 -22
  41. package/dist/utils/dialogs.d.ts.map +1 -1
  42. package/dist/utils/templateUtils.d.ts +6 -6
  43. package/dist/utils/templateUtils.d.ts.map +1 -1
  44. package/dist/vendor-imports.d.ts +1 -1
  45. package/package.json +39 -34
  46. package/rollup.config.js +14 -2
  47. package/server.js +1 -1
  48. package/src/formatAndTypeChoices.js +9 -9
  49. package/src/formats/indexedDBKey.js +2 -2
  50. package/src/formats/json.js +1 -2
  51. package/src/formats/structuredCloning.js +101 -29
  52. package/src/formats.js +2 -2
  53. package/src/fundamentalTypes/arrayReferenceType.js +3 -3
  54. package/src/fundamentalTypes/arrayType.js +390 -87
  55. package/src/fundamentalTypes/dateType.js +4 -6
  56. package/src/fundamentalTypes/errorType.js +416 -0
  57. package/src/fundamentalTypes/mapType.js +34 -0
  58. package/src/fundamentalTypes/nullType.js +1 -2
  59. package/src/fundamentalTypes/objectReferenceType.js +2 -1
  60. package/src/fundamentalTypes/regexpType.js +2 -2
  61. package/src/fundamentalTypes/setType.js +34 -0
  62. package/src/fundamentalTypes/sparseUndefinedType.js +2 -3
  63. package/src/fundamentalTypes/undefinedType.js +2 -3
  64. package/src/jsoe.css +3 -0
  65. package/src/subTypes/blobHTMLType.js +37 -33
  66. package/src/subTypes/falseType.js +2 -2
  67. package/src/subTypes/trueType.js +2 -2
  68. package/src/superTypes/{SpecialNumberSuperType.js → SpecialNumberType.js} +1 -1
  69. package/src/superTypes/{SpecialRealNumberSuperType.js → SpecialRealNumberType.js} +3 -2
  70. package/src/superTypes/errorsSpecialType.js +768 -0
  71. package/src/typeChoices.js +27 -20
  72. package/src/types.js +71 -39
  73. package/src/utils/dialogs.js +11 -12
  74. package/src/utils/jsonPointer.js +3 -3
  75. package/src/utils/templateUtils.js +4 -4
  76. package/src/vendor-imports.js +2 -2
  77. package/tsconfig.json +1 -1
  78. package/typings/CypressPlugins.d.ts +10 -0
  79. package/vendor/jamilih/dist/jml-es.js +126 -106
  80. package/vendor/typeson-registry/dist/index.js +188 -44
@@ -41,7 +41,7 @@ import dialogs from './utils/dialogs.js';
41
41
 
42
42
  /**
43
43
  * @callback GetType
44
- * @returns {string|null|undefined}
44
+ * @returns {string}
45
45
  */
46
46
 
47
47
  /**
@@ -64,6 +64,7 @@ import dialogs from './utils/dialogs.js';
64
64
  * value?: import('./formats.js').StructuredCloneValue,
65
65
  * setValue?: boolean,
66
66
  * state?: string,
67
+ * arrayState?: string,
67
68
  * keySelectClass?: string,
68
69
  * requireObject?: boolean,
69
70
  * objectHasValue?: boolean,
@@ -103,6 +104,22 @@ export const buildTypeChoices = ({
103
104
  : Types.getTypeOptionsForFormatAndState(format, state);
104
105
 
105
106
  let editUI;
107
+
108
+ /** @type {GetValue} */
109
+ const $getValue = (stateObj, currentPath) => {
110
+ const root = /** @type {HTMLDivElement} */ (
111
+ $e(typeContainer, 'div[data-type]')
112
+ );
113
+ return Types.getValueForRoot(
114
+ root,
115
+ /** @type {import('./types.js').StateObject} */ ({
116
+ typeNamespace,
117
+ format,
118
+ ...stateObj
119
+ }),
120
+ currentPath
121
+ );
122
+ };
106
123
  const sel = /** @type {HTMLSelectElement} */ (jml('select', {
107
124
  hidden: requireObject,
108
125
  class: `typeChoices-${typeNamespace}${keySelectClass
@@ -111,6 +128,7 @@ export const buildTypeChoices = ({
111
128
  }`,
112
129
  // is: 'type-choices',
113
130
  $custom: {
131
+ $getValue,
114
132
  /** @type {SetType} */
115
133
  $setType ({type, baseValue, bringIntoFocus}) {
116
134
  this.value = type;
@@ -150,7 +168,9 @@ export const buildTypeChoices = ({
150
168
  $addAndValidateEditUI ({baseValue, bringIntoFocus} = {}) {
151
169
  const {value: type} = this;
152
170
 
153
- if (!type) { return; }
171
+ if (!type) {
172
+ return;
173
+ }
154
174
  let topRoot = this.$getTopRoot();
155
175
 
156
176
  // Todo (low): Try to avoid need for `baseValue`
@@ -250,12 +270,11 @@ export const buildTypeChoices = ({
250
270
  schemaContent
251
271
  }
252
272
  );
253
- const type = /** @type {string} */ (
273
+ const type =
254
274
  Types.getTypeForRoot(/** @type {HTMLDivElement} */ (
255
275
  rootEditUI
256
- ))
257
- );
258
- // eslint-disable-next-line max-len -- Long
276
+ ));
277
+ // eslint-disable-next-line @stylistic/max-len -- Long
259
278
  /** @type {HTMLSelectElement & {$addTypeAndEditUI: AddTypeAndEditUI}} */ (
260
279
  sel
261
280
  ).$addTypeAndEditUI({type, editUI: rootEditUI});
@@ -282,19 +301,7 @@ export const buildTypeChoices = ({
282
301
  ],
283
302
 
284
303
  /** @type {GetValue} */
285
- getValue (stateObj, currentPath) {
286
- const root = /** @type {HTMLDivElement} */ (
287
- $e(typeContainer, 'div[data-type]')
288
- );
289
- return Types.getValueForRoot(
290
- root,
291
- /** @type {import('./types.js').StateObject} */ ({
292
- typeNamespace,
293
- format,
294
- ...stateObj
295
- }), currentPath
296
- );
297
- },
304
+ getValue: $getValue,
298
305
 
299
306
  /** @type {GetType} */
300
307
  getType () {
@@ -320,7 +327,7 @@ export const buildTypeChoices = ({
320
327
  format, value, stateObj
321
328
  )
322
329
  );
323
- const type = /** @type {string} */ (Types.getTypeForRoot(rootEditUI));
330
+ const type = Types.getTypeForRoot(rootEditUI);
324
331
  /** @type {HTMLSelectElement & {$addTypeAndEditUI: AddTypeAndEditUI}} */ (
325
332
  sel
326
333
  ).$addTypeAndEditUI({type, editUI: rootEditUI});
package/src/types.js CHANGED
@@ -21,15 +21,19 @@ import objectReferenceType from './fundamentalTypes/objectReferenceType.js';
21
21
  import arrayType from './fundamentalTypes/arrayType.js';
22
22
  import objectType from './fundamentalTypes/objectType.js';
23
23
  import dateType from './fundamentalTypes/dateType.js';
24
+ import setType from './fundamentalTypes/setType.js';
25
+ import mapType from './fundamentalTypes/mapType.js';
24
26
  import undefinedType from './fundamentalTypes/undefinedType.js';
25
27
  import regexpType from './fundamentalTypes/regexpType.js';
26
28
  import BooleanObjectType from './fundamentalTypes/BooleanObjectType.js';
27
29
  import NumberObjectType from './fundamentalTypes/NumberObjectType.js';
28
30
  import StringObjectType from './fundamentalTypes/StringObjectType.js';
29
- import sparseUndefinedType from './fundamentalTypes/sparseUndefinedType.js';
31
+ // import sparseUndefinedType from './fundamentalTypes/sparseUndefinedType.js';
30
32
  import SpecialRealNumberSuperType from
31
- './superTypes/SpecialRealNumberSuperType.js';
32
- import SpecialNumberSuperType from './superTypes/SpecialNumberSuperType.js';
33
+ './superTypes/SpecialRealNumberType.js';
34
+ import SpecialNumberSuperType from './superTypes/SpecialNumberType.js';
35
+ import errorType from './fundamentalTypes/errorType.js';
36
+ import errorsSpecialType from './superTypes/errorsSpecialType.js';
33
37
 
34
38
  /**
35
39
  * Utility to retrieve the property value given a legend element.
@@ -59,7 +63,7 @@ export const getPropertyValueFromLegend = (legend) => {
59
63
  * Utility to retrieve the type out of a type root element.
60
64
  * @callback GetTypeForRoot
61
65
  * @param {?RootElement} root
62
- * @returns {string|undefined|null} Why would it not exist?
66
+ * @returns {string} Why would it not exist?
63
67
  */
64
68
 
65
69
  /**
@@ -196,8 +200,7 @@ export const getPropertyValueFromLegend = (legend) => {
196
200
  /**
197
201
  * @type {{
198
202
  * availableTypes: {
199
- * [key in AvailableType]: Partial<TypeObject>|string[]|
200
- * {valid: true}|{sparse: true}
203
+ * [key in AvailableType]: Partial<TypeObject>|string[]
201
204
  * },
202
205
  * getTypeForRoot: GetTypeForRoot,
203
206
  * getValueForRoot: GetValueForRoot,
@@ -234,6 +237,7 @@ const Types = {};
234
237
  /**
235
238
  * @typedef {{
236
239
  * format: import('./formats.js').AvailableFormat,
240
+ * match: boolean|RegExpMatchArray|null
237
241
  * endMatchTypeObjs: TypeObject[],
238
242
  * remnant: string,
239
243
  * rootHolder: [
@@ -247,6 +251,15 @@ const Types = {};
247
251
  * }} RootInfo
248
252
  */
249
253
 
254
+ /**
255
+ * @typedef {(
256
+ * info: {
257
+ * root: HTMLDivElement,
258
+ * value: StructuredCloneValue
259
+ * }
260
+ * ) => void} TypeObjectSetValue
261
+ */
262
+
250
263
  /**
251
264
  * @typedef {object} TypeObject
252
265
  * @property {[
@@ -254,6 +267,14 @@ const Types = {};
254
267
  * ]} option Creates the option HTML. May set an option `title` or `value`
255
268
  * @property {boolean} [array] Private context variable. Whether or not
256
269
  * it is an array. Do not use in other types.
270
+ * @property {boolean} [map] Private context variable. Whether or not
271
+ * it is a Map. Do not use in other types.
272
+ * @property {boolean} [set] Private context variable. Whether or not
273
+ * it is a set. Do not use in other types.
274
+ * @property {boolean} [sparse] Private context variable. Whether or not
275
+ * it is a sparse array. Do not use in other types.
276
+ * @property {boolean} [valid] Private context variable. Whether or not
277
+ * it is a valid date. Do not use in other types.
257
278
  * @property {string[]} [regexEndings] Used for string parsing.
258
279
  * @property {RegExp|((nonGrouping?: boolean) => RegExp)} [stringRegex] Used
259
280
  * for string parsing. If not present, use `stringRegexBegin` and
@@ -268,7 +289,11 @@ const Types = {};
268
289
  * the type belongs
269
290
  * @property {(
270
291
  * s: string, info?: RootInfo
271
- * ) => StructuredCloneValue} toValue Converts from string to value. May use
292
+ * ) => {
293
+ * value?: StructuredCloneValue,
294
+ * remnant?: string,
295
+ * assign?: false
296
+ * }} toValue Converts from string to value. May use
272
297
  * `stringRegex` to find components.
273
298
  * @property {(info: {
274
299
  * root: HTMLDivElement,
@@ -277,12 +302,8 @@ const Types = {};
277
302
  * }) =>
278
303
  * StructuredCloneValue
279
304
  * } getValue Gets the value for the type
280
- * @property {(
281
- * info: {
282
- * root: HTMLDivElement,
283
- * value: StructuredCloneValue
284
- * }
285
- * ) => void} [setValue] Should set the value of the form's `getInput` element
305
+ * @property {TypeObjectSetValue} [setValue] Should set the value of the
306
+ * form's `getInput` element
286
307
  * @property {(info: {
287
308
  * value?: StructuredCloneValue,
288
309
  * typeNamespace?: string,
@@ -298,6 +319,7 @@ const Types = {};
298
319
  * format?: import('./formats.js').AvailableFormat,
299
320
  * resultType?: "keys"|"values"|"both",
300
321
  * type?: AvailableType,
322
+ * arrayState?: string,
301
323
  * buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
302
324
  * topRoot?: HTMLDivElement
303
325
  * }) => JamilihArray} editUI
@@ -350,17 +372,16 @@ Types.availableTypes = {
350
372
  SpecialRealNumber: SpecialRealNumberSuperType,
351
373
  SpecialNumber: SpecialNumberSuperType,
352
374
 
375
+ error: errorType,
376
+ errors: errorsSpecialType,
377
+
353
378
  regexp: regexpType,
354
379
  BooleanObject: BooleanObjectType,
355
380
  NumberObject: NumberObjectType,
356
381
  StringObject: StringObjectType,
357
382
 
358
- map: {
359
- option: ['Map']
360
- },
361
- set: {
362
- option: ['Set']
363
- },
383
+ map: mapType,
384
+ set: setType,
364
385
 
365
386
  file: {
366
387
  option: ['File']
@@ -426,7 +447,7 @@ Types.availableTypes = {
426
447
  },
427
448
 
428
449
  // We're catching this instead of using this
429
- sparseUndefined: sparseUndefinedType,
450
+ // sparseUndefined: sparseUndefinedType,
430
451
 
431
452
  ValidDate: {
432
453
  valid: true
@@ -449,8 +470,8 @@ Types.availableTypes = {
449
470
  * "arraybuffer"|"arraybufferview"|"dataview"|"imagedata"|"imagebitmap"|
450
471
  * "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
451
472
  * "int32array"|"uint32array"|"float32array"|"float64array"|"IntlCollator"|
452
- * "IntlDateTimeFormat"|"IntlNumberFormat"|"sparseUndefined"|"ValidDate"|
453
- * "arrayNonindexKeys"} AvailableType
473
+ * "IntlDateTimeFormat"|"IntlNumberFormat"|"ValidDate"|
474
+ * "arrayNonindexKeys"|"error"|"errors"} AvailableType
454
475
  */
455
476
 
456
477
  /**
@@ -484,7 +505,7 @@ copyTypeObjs(
484
505
  );
485
506
 
486
507
  Types.getTypeForRoot = (root) => {
487
- return root && root.dataset.type;
508
+ return String(root ? root.dataset.type : root);
488
509
  };
489
510
 
490
511
  /**
@@ -726,8 +747,8 @@ Types.setValue = ({type, root, value}) => {
726
747
  * @returns {string}
727
748
  */
728
749
  function escapeRegex (str) {
729
- return String(str)
730
- .replace(/[.\\+*?^[\]$(){}=!<>|:-]/gu, '\\$&');
750
+ return String(str).
751
+ replaceAll(/[.\\+*?^[\]$(){}=!<>|:-]/gu, '\\$&');
731
752
  }
732
753
 
733
754
  // Todo (low): Should really add real parser
@@ -771,7 +792,7 @@ Types.getValueForString = (s, {
771
792
  * @type {RegExpMatchArray|boolean|null}
772
793
  */
773
794
  let match = null;
774
- let found = allowedTypeObjs.find(([_type, typObj]) => {
795
+ let found = allowedTypeObjs.find(([/* _type */, typObj]) => {
775
796
  const typeObj = /** @type {TypeObject} */ (typObj);
776
797
  let {stringRegex} = typeObj;
777
798
  if (typeof typeObj.stringRegex === 'function') {
@@ -794,7 +815,7 @@ Types.getValueForString = (s, {
794
815
 
795
816
  let beginOnly = false;
796
817
  if (found === undefined) {
797
- found = allowedTypeObjs.find(([_type, typObj]) => {
818
+ found = allowedTypeObjs.find(([/* _type */, typObj]) => {
798
819
  const typeObj = /** @type {TypeObject} */ (typObj);
799
820
  const {stringRegexBegin} = typeObj;
800
821
  match = Boolean(stringRegexBegin && s) && s.match(
@@ -809,23 +830,32 @@ Types.getValueForString = (s, {
809
830
  }
810
831
  let assign = true;
811
832
  if (found !== undefined) {
812
- // @ts-ignore The `found` is evaluated again, so sets `match` to non-null
813
- const [content, innerContent] = /** @type {RegExpMatchArray} */ (match);
833
+ // The `found` is evaluated again, so sets `match` to non-null
834
+ const mtch = /** @type {RegExpMatchArray} */ (
835
+ /** @type {unknown} */ (match)
836
+ );
837
+ const [content, innerContent] = mtch;
814
838
  let remnant = s.slice(content.length);
815
839
  s = s.slice(0, content.length);
816
840
  // console.log('s0', s, '::', remnant, match);
817
841
  let valObj;
818
842
  try {
819
- valObj = /** @type {TypeObject} */ (found[1]).toValue(innerContent || s, {
820
- format,
821
- endMatchTypeObjs,
822
- remnant,
823
- rootHolder,
824
- parent,
825
- parentPath
826
- });
843
+ valObj = /** @type {TypeObject} */ (found[1]).toValue(
844
+ mtch.groups?.innerContent || innerContent || s, {
845
+ format,
846
+ match,
847
+ endMatchTypeObjs,
848
+ remnant,
849
+ rootHolder,
850
+ parent,
851
+ parentPath
852
+ }
853
+ );
854
+ /* istanbul ignore next -- Good regexes should prevent */
827
855
  } catch (e) {
856
+ /* istanbul ignore next -- Good regexes should prevent */
828
857
  console.log('eee', e);
858
+ /* istanbul ignore next -- Good regexes should prevent */
829
859
  throw e;
830
860
  }
831
861
  if (valObj.assign === false) {
@@ -838,7 +868,9 @@ Types.getValueForString = (s, {
838
868
 
839
869
  if (beginOnly && endMatchTypeObjs.length) {
840
870
  const endMatch = remnant.match(
841
- /** @type {RegExp} */ (endMatchTypeObjs.slice(-1)[0].stringRegexEnd)
871
+ /** @type {RegExp} */ (/** @type {TypeObject} */ (
872
+ endMatchTypeObjs.at(-1)
873
+ ).stringRegexEnd)
842
874
  );
843
875
  if (endMatch) {
844
876
  endMatchTypeObjs.pop(); // Safe now to extract
@@ -859,7 +891,7 @@ Types.getValueForString = (s, {
859
891
  // @ts-expect-error Reference method exists
860
892
  const val = typeObject.resolveReference(path, topRoot);
861
893
  const basicType = getJSONType(val);
862
- // eslint-disable-next-line max-len -- Long
894
+ // eslint-disable-next-line @stylistic/max-len -- Long
863
895
  /* istanbul ignore else -- Successful reference always an object/array? */
864
896
  if (
865
897
  ['array', 'object'].includes(type) && basicType === type
@@ -18,7 +18,7 @@ const dialogs = {
18
18
  /** @type {Locale} */
19
19
  localeStrings: {},
20
20
  /**
21
- * @param {Locale} [locale={}]
21
+ * @param {Locale} [locale]
22
22
  * @returns {void}
23
23
  */
24
24
  setLocale (locale = {}) {
@@ -29,7 +29,7 @@ const dialogs = {
29
29
  * @typedef {object} MakeDialogArgs
30
30
  * @property {import('jamilih').JamilihAttributes} [atts={}]
31
31
  * @property {import('jamilih').JamilihChildren} [children=[]]
32
- * @property {import('jamilih').EventHandler} [close]
32
+ * @property {import('jamilih').EventHandler|boolean} [close]
33
33
  * @property {boolean} [remove=true]
34
34
  */
35
35
  /**
@@ -42,7 +42,7 @@ const dialogs = {
42
42
  atts.$on = {};
43
43
  }
44
44
  if (!('close' in atts.$on)) {
45
- atts.$on.close = close;
45
+ atts.$on.close = /** @type {import('jamilih').EventHandler} */ (close);
46
46
  }
47
47
  }
48
48
  const dialog = /** @type {HTMLDialogElement} */ (
@@ -60,10 +60,10 @@ const dialogs = {
60
60
  * @typedef {object} MakeCancelArgs
61
61
  * @property {(
62
62
  * info: {e: Event, dialog: HTMLDialogElement}
63
- * ) => boolean} cancel
64
- * @property {string} cancelClass
65
- * @property {string} submitClass
66
- * @property {...MakeDialogArgs} args
63
+ * ) => boolean} [cancel]
64
+ * @property {string} [cancelClass]
65
+ * @property {string} [submitClass]
66
+ * @property {...MakeDialogArgs} [args]
67
67
  */
68
68
  /**
69
69
  * @param {MakeCancelArgs} cfg
@@ -78,7 +78,6 @@ const dialogs = {
78
78
  jml('div', {class: submitClass}, [
79
79
  ['br'], ['br'],
80
80
  ['button', {class: cancelClass, $on: {
81
- // @ts-ignore Erring out of IDE
82
81
  click (e) {
83
82
  e.preventDefault();
84
83
  if (cancel) {
@@ -100,7 +99,7 @@ const dialogs = {
100
99
  /**
101
100
  * @param {object} cfg
102
101
  * @param {(info: {e: Event, dialog: HTMLDialogElement}) => void} cfg.submit
103
- * @param {string} [cfg.submitClass="submit"]
102
+ * @param {string} [cfg.submitClass]
104
103
  * @param {MakeCancelArgs} [cfg.args]
105
104
  * @returns {HTMLDialogElement}
106
105
  */
@@ -133,7 +132,7 @@ const dialogs = {
133
132
  message = typeof message === 'string' ? {message} : message;
134
133
  const {submitClass = 'submit'} = message;
135
134
  const {message: outputMessage} = message;
136
- return new Promise((resolve, _reject) => {
135
+ return new Promise((resolve /* , _reject */) => {
137
136
  const dialog = /** @type {HTMLDialogElement} */ (jml('dialog', [
138
137
  /** @type {string|import('jamilih').JamilihArray} */ (outputMessage),
139
138
  ['br'], ['br'],
@@ -149,9 +148,9 @@ const dialogs = {
149
148
  },
150
149
  /**
151
150
  * @param {object} cfg
152
- * @param {import('jamilih').JamilihAttributes} [cfg.atts={}]
151
+ * @param {import('jamilih').JamilihAttributes} [cfg.atts]
153
152
  * @param {string|{message: string}} cfg.message
154
- * @param {string} [cfg.submitClass="submit"]
153
+ * @param {string} [cfg.submitClass]
155
154
  */
156
155
  confirm ({atts = {}, message, submitClass = 'submit'}) {
157
156
  ({message} = typeof message === 'string' ? {message} : message);
@@ -13,7 +13,7 @@ const makeJSONPointer = (...args) => {
13
13
  * @returns {string}
14
14
  */
15
15
  const escapeJSONPointer = (path) => {
16
- return path.replace(/~/gu, '~0').replace(/\//gu, '~1');
16
+ return path.replaceAll('~', '~0').replaceAll('/', '~1');
17
17
  };
18
18
 
19
19
  /**
@@ -21,7 +21,7 @@ const escapeJSONPointer = (path) => {
21
21
  * @returns {string}
22
22
  */
23
23
  const unescapeJSONPointerPart = (pathPart) => {
24
- return pathPart.replace(/~([01])/gu, (_n0, n1) => {
24
+ return pathPart.replaceAll(/~([01])/gu, (_n0, n1) => {
25
25
  if (n1 === '0') {
26
26
  return '~';
27
27
  }
@@ -81,7 +81,7 @@ const typesonPathToJSONPointer = (path) => {
81
81
  // Keep `~0` (representing tilde) escaped as same sequence in
82
82
  // JSONPointer (that's why we don't just use
83
83
  // Typeson's `unescapeKeyPathComponent` + `escapeJSONPointer` here)
84
- return keyPathComponent.replace(/~1/gu, '.').replace(/\//gu, '~1');
84
+ return keyPathComponent.replaceAll('~1', '.').replaceAll('/', '~1');
85
85
  }).join('/');
86
86
  };
87
87
 
@@ -1,4 +1,3 @@
1
-
2
1
  const nbsp = '\u00A0';
3
2
  const upArrow = '\u2191';
4
3
  const downArrow = '\u2193';
@@ -19,7 +18,7 @@ const $$ = (sel) => [...(/** @type {NodeListOf<HTMLElement>} */ (
19
18
  ))];
20
19
 
21
20
  /**
22
- * @param {HTMLElement|string} el
21
+ * @param {Element|HTMLElement|string} el
23
22
  * @param {string} descendentsSel
24
23
  * @returns {HTMLElement|null}
25
24
  */
@@ -47,7 +46,7 @@ const $$e = (el, descendentsSel) => {
47
46
  };
48
47
 
49
48
  /**
50
- * @param {Node} node
49
+ * @param {Node|string} node
51
50
  * @returns {void}
52
51
  */
53
52
  const removeChildren = (node) => {
@@ -72,7 +71,7 @@ const removeIfExists = (sel) => {
72
71
  };
73
72
 
74
73
  /**
75
- * @param {HTMLElement} el
74
+ * @param {HTMLElement|string} el
76
75
  * @param {string|string[]} selectors
77
76
  * @returns {HTMLElement[]}
78
77
  */
@@ -97,6 +96,7 @@ const filterChildElements = (el, selectors) => {
97
96
  selectors = Array.isArray(selectors) ? selectors : [selectors];
98
97
  selectors.forEach((sel) => {
99
98
  filtered = filtered.reduce((els, childElement) => {
99
+ /* istanbul ignore if -- Guard */
100
100
  if (!childElement) {
101
101
  return els;
102
102
  }
@@ -1,5 +1,5 @@
1
- export {jml, body, nbsp} from 'jamilih';
2
- // export {jml, body, nbsp} from '../node_modules/jamilih/dist/jml-es.js';
1
+ export {jml, body, nbsp, $} from 'jamilih';
2
+ // export {jml, body, nbsp, $} from '../node_modules/jamilih/dist/jml-es.js';
3
3
 
4
4
  export {
5
5
  getJSONType,
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "lib": ["es2022", "DOM"],
3
+ "lib": ["es2023", "DOM"],
4
4
  "moduleResolution": "nodenext",
5
5
  "module": "NodeNext",
6
6
  "allowJs": true,
@@ -0,0 +1,10 @@
1
+ declare namespace Cypress {
2
+ interface Chainable {
3
+ clearAndType(sel: string, content: string): Chainable
4
+ clickAndType(sel: string, content: string): Chainable
5
+ typeAndBlur(sel: string, content: string): Chainable
6
+ clearTypeAndBlur(sel: string, content: string): Chainable
7
+ checkAccessibility(): void
8
+ visitURLAndCheckAccessibility(url: string, CypressVisitOptions?: object): void
9
+ }
10
+ }