@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.
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 +10 -4
  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 +85 -233
  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 +14 -13
  49. package/src/formats/indexedDBKey.js +2 -2
  50. package/src/formats/json.js +1 -2
  51. package/src/formats/structuredCloning.js +104 -29
  52. package/src/formats.js +2 -2
  53. package/src/fundamentalTypes/arrayReferenceType.js +3 -3
  54. package/src/fundamentalTypes/arrayType.js +384 -79
  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 +72 -40
  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
package/CHANGES.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGES TO `@es-joy/jsoe`
2
2
 
3
+ ## 0.6.0
4
+
5
+ - feat: add `set`, `map`, `error`, and special error types
6
+ - fix: ensure `Types.getTypeForRoot` always returns a string
7
+ - fix: ensure Blob textarea is independent per instance
8
+
9
+ ## 0.5.1
10
+
11
+ - fix: TS types
12
+
3
13
  ## 0.5.0
4
14
 
5
15
  - chore: update `jamilih`, `typeson-registry`, devDeps.;
package/README.md CHANGED
@@ -12,6 +12,8 @@ app using this tool.
12
12
 
13
13
  Formats are a collection of allowed types.
14
14
 
15
+ Supported formats include:
16
+
15
17
  - Structured Cloning (using [typeson](https://github.com/dfahlander/typeson)) (e.g., IndexedDB)
16
18
  - JSON
17
19
  - IndexedDB keys
@@ -20,17 +22,24 @@ Formats are a collection of allowed types.
20
22
 
21
23
  These are generally atomic types which correlate to JavaScript language structures.
22
24
 
25
+ Supported types include:
26
+
23
27
  - Array reference (for cyclic arrays)
24
28
  - Array
25
29
  - `BigInt`
26
30
  - `Boolean` object
27
31
  - `Date`
32
+ - `Error`
33
+ - `TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`,
34
+ `URIError`, `AggregateError`, `InternalError`
35
+ - `Map`
28
36
  - `null`
29
37
  - `Number` object
30
38
  - number
31
39
  - Object reference (for cyclic objects)
32
40
  - Object
33
41
  - `RegExp`
42
+ - `Set`
34
43
  - `String` object
35
44
  - string
36
45
  - `undefined`
@@ -39,6 +48,8 @@ These are generally atomic types which correlate to JavaScript language structur
39
48
 
40
49
  These map to a subset of JavaScript language structures. Note that false and true were common and limited enough in number to justify their own subtype for the sake of having a quick pull-down entry.
41
50
 
51
+ Supported subtypes include:
52
+
42
53
  - Blob (text/html)
43
54
  - `false`
44
55
  - `true`
@@ -48,9 +59,20 @@ These map to a subset of JavaScript language structures. Note that false and tru
48
59
  These are collections of individual types, justified by the subitems not being so frequent as to necessitate their own
49
60
  separate enumeration.
50
61
 
62
+ Supported supertypes include:
63
+
51
64
  - Special Real Number (`Infinity`, `-Infinity`, `-0`) - Used with IndexedDB keys (even though -0 apparently [to be converted](https://github.com/w3c/IndexedDB/issues/375) to 0)
52
65
  - Special Number (`Infinity`, `-Infinity`, `-0`, `NaN`) - Used with Structured Cloning values
53
66
 
67
+ ## Known issues
68
+
69
+ - Cannot provide maps with object keys pointing to the same objects as used
70
+ as map values; likewise with Sets?
71
+ - Certain cyclical structures may have issues
72
+ - `typeson-registry`'s structured cloning should throw on more objects, so
73
+ bad data doesn't end up stored
74
+ - Lacks support for certain Structured Cloning types. See to-dos below.
75
+
54
76
  ## To-dos
55
77
 
56
78
  1. Add tests of demo (lower priority as have tests in `idb-manager`)
@@ -58,28 +80,32 @@ separate enumeration.
58
80
  1. Expand fundamental types
59
81
  1. Not in typeson-registry
60
82
  1. Structured Cloning
61
- 1. arraybufferview
83
+ 1. Web/API types (besides those listed below)
84
+ 1. See <https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#webapi_types>
62
85
  1. Already in typeson-registry
63
86
  1. Structured Cloning
64
- 1. map, set,
65
- 1. blob, file, filelist
66
- 1. arraybuffer
67
- 1. dataview, imagedata, imagebitmap
68
- 1. error, errors
69
- 1. Typed Arrays
70
- 1. int8array
71
- 1. uint8array
72
- 1. uint8clampedarray
73
- 1. int16array
74
- 1. uint16array
75
- 1. int32array
76
- 1. uint32array
77
- 1. float32array
78
- 1. float64array
79
- 1. Intl (imperfect)
80
- 1. IntlCollator
81
- 1. IntlDateTimeFormat
82
- 1. IntlNumberFormat
87
+ 1. JavaScript types
88
+ 1. ArrayBuffer
89
+ 1. arraybuffer
90
+ 1. DataView
91
+ 1. dataview
92
+ 1. TypedArray
93
+ 1. int8array
94
+ 1. uint8array
95
+ 1. uint8clampedarray
96
+ 1. int16array
97
+ 1. uint16array
98
+ 1. int32array
99
+ 1. uint32array
100
+ 1. float32array
101
+ 1. float64array
102
+ 1. bigint64arrayconstructor
103
+ 1. biguint64arrayconstructor
104
+ 1. Web/API types
105
+ 1. blob (besides HTML), file, filelist
106
+ 1. imagedata, imagebitmap
83
107
  1. Expand subtypes
84
108
  1. As supported by Zod, JSON Schema, etc. (e.g., email addresses as
85
- subtype of `string`)
109
+ subtype of `string`, color as a subtype of string)
110
+ 1. Might put views and data into separate repos
111
+ 1. Implement as Custom Elements?
@@ -0,0 +1,13 @@
1
+ import {defineConfig} from 'cypress';
2
+ import plugins from './cypress/plugins/index.js';
3
+
4
+ export default defineConfig({
5
+ defaultCommandTimeout: 8000,
6
+ video: false,
7
+ e2e: {
8
+ baseUrl: 'http://127.0.0.1:8087',
9
+ setupNodeEvents (on, config) {
10
+ return plugins(on, config);
11
+ }
12
+ }
13
+ });
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSOE Demo</title>
6
+ <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
7
+ <link rel="stylesheet" href="../src/jsoe.css" />
8
+ <!-- SCEditor (CKEditor was appealing for features but won't support unrecognized tags:
9
+ https://github.com/ckeditor/ckeditor5/issues/592 )
10
+ Filed https://github.com/samclarke/SCEditor/issues/584 to be able to import as ES6 module
11
+ -->
12
+ <link rel="stylesheet" href="../node_modules/sceditor/minified/themes/default.min.css" />
13
+
14
+ <script src="../node_modules/sceditor/minified/sceditor.min.js"></script>
15
+ <script src="../node_modules/sceditor/minified/formats/bbcode.js"></script>
16
+ <script src="../node_modules/sceditor/minified/formats/xhtml.js"></script>
17
+ <script type="importmap">
18
+ {
19
+ "imports": {
20
+ "jamilih": "../vendor/jamilih/dist/jml-es.js",
21
+ "typeson-registry": "../vendor/typeson-registry/dist/index.js"
22
+ }
23
+ }
24
+ </script>
25
+ <script type="module" src="../instrumented/demo/index.js"></script>
26
+ </head>
27
+ <body>
28
+ </body>
29
+ </html>
package/demo/index.html CHANGED
@@ -1,10 +1,19 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title>JSOE Demo</title>
6
6
  <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
7
7
  <link rel="stylesheet" href="../src/jsoe.css" />
8
+ <!-- SCEditor (CKEditor was appealing for features but won't support unrecognized tags:
9
+ https://github.com/ckeditor/ckeditor5/issues/592 )
10
+ Filed https://github.com/samclarke/SCEditor/issues/584 to be able to import as ES6 module
11
+ -->
12
+ <link rel="stylesheet" href="../node_modules/sceditor/minified/themes/default.min.css" />
13
+
14
+ <script src="../node_modules/sceditor/minified/sceditor.min.js"></script>
15
+ <script src="../node_modules/sceditor/minified/formats/bbcode.js"></script>
16
+ <script src="../node_modules/sceditor/minified/formats/xhtml.js"></script>
8
17
  <script type="importmap">
9
18
  {
10
19
  "imports": {