@es-joy/jsoe 0.16.0 → 0.17.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 +4 -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 +9660 -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 +68 -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/demo/index.html DELETED
@@ -1,29 +0,0 @@
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="index.js"></script>
26
- </head>
27
- <body>
28
- </body>
29
- </html>
package/demo/index.js DELETED
@@ -1,215 +0,0 @@
1
- import {jml, body, $} from '../src/vendor-imports.js';
2
-
3
- import {
4
- typeChoices,
5
- getFormatAndSchemaChoices,
6
- formatAndTypeChoices,
7
- Types
8
- } from '../src/index.js';
9
-
10
- const types = new Types();
11
-
12
- const keyPathNotExpectedTypeChoices = formatAndTypeChoices({
13
- hasKeyPath: false,
14
- typeNamespace: 'demo-keypath-not-expected'
15
- });
16
-
17
- setTimeout(async function () {
18
- jml('section', {role: 'main'}, [
19
- ['h1', [
20
- 'Jsoe testing'
21
- ]],
22
- ['h2', [
23
- 'Format and type choices: No key path expected (type can vary at root)'
24
- ]],
25
-
26
- // Put inside form so can validate
27
- ['form', {id: 'formatAndTypeChoices'}, [
28
- ...keyPathNotExpectedTypeChoices.domArray
29
- ]],
30
-
31
- ['button', {
32
- id: 'getType',
33
- $on: {
34
- click () {
35
- // eslint-disable-next-line no-alert -- Simple demo
36
- alert(keyPathNotExpectedTypeChoices.getType());
37
- }
38
- }
39
- }, ['Get type']],
40
-
41
- ['button', {
42
- id: 'isValid',
43
- $on: {
44
- click () {
45
- // eslint-disable-next-line no-alert -- Simple demo
46
- alert(keyPathNotExpectedTypeChoices.validValuesSet());
47
- }
48
- }
49
- }, ['Is valid']],
50
-
51
- ['button', {
52
- id: 'logValue',
53
- $on: {
54
- click () {
55
- console.log(keyPathNotExpectedTypeChoices.getValue());
56
- }
57
- }
58
- }, ['Log value']],
59
-
60
- ['button', {
61
- id: 'viewUI',
62
- $on: {
63
- async click () {
64
- const controls =
65
- // eslint-disable-next-line @stylistic/max-len -- Long
66
- await keyPathNotExpectedTypeChoices.formats.getControlsForFormatAndValue(
67
- keyPathNotExpectedTypeChoices.types,
68
- 'structuredCloning',
69
- keyPathNotExpectedTypeChoices.getValue(),
70
- {
71
- readonly: true
72
- }
73
- );
74
- $('#viewUIResults').firstChild?.remove();
75
- $('#viewUIResults').append(controls);
76
- }
77
- }
78
- }, ['view UI']],
79
-
80
- ['div', {id: 'viewUIResults'}],
81
-
82
- ['button', {
83
- id: 'initializeWithValue',
84
- $on: {
85
- async click () {
86
- await keyPathNotExpectedTypeChoices.setValue(42);
87
- }
88
- }
89
- }, ['Initialize with a value']],
90
-
91
- ['h2', [
92
- 'Format and type choices: Key path expected (object required at root)'
93
- ]],
94
- ...formatAndTypeChoices({
95
- hasKeyPath: true,
96
- typeNamespace: 'demo-keypath-expected'
97
- }).domArray,
98
-
99
- ['h2', [
100
- 'Format choices without type selection ' +
101
- '(might use as retrieval return format)'
102
- ]],
103
- ['select', {id: 'formatAndSchemaChoices'}, [
104
- getFormatAndSchemaChoices()
105
- ]],
106
-
107
- ['h2', [
108
- 'Type choices only'
109
- ]],
110
-
111
- (() => {
112
- const typeSelection = typeChoices({
113
- format: 'structuredCloning',
114
- typeNamespace: 'demo-type-choices-only'
115
- });
116
-
117
- return ['form', {
118
- id: 'typeChoicesOnly',
119
- $on: {
120
- submit (e) {
121
- e.preventDefault();
122
- }
123
- }
124
- }, [
125
- ...typeSelection.domArray,
126
- ['button', {
127
- id: 'typeChoicesOnly-getType',
128
- $on: {
129
- click () {
130
- // eslint-disable-next-line no-alert -- Simple demo
131
- alert(typeSelection.getType());
132
- }
133
- }
134
- }, ['Get type']],
135
-
136
- ['button', {
137
- id: 'typeChoicesOnly-isValid',
138
- $on: {
139
- click () {
140
- // eslint-disable-next-line no-alert -- Simple demo
141
- alert(typeSelection.validValuesSet());
142
- }
143
- }
144
- }, ['Is valid']],
145
-
146
- ['button', {
147
- id: 'validateInitialType',
148
- $on: {
149
- click () {
150
- // eslint-disable-next-line no-alert -- Simple demo
151
- alert(typeSelection.domArray[0].$validate());
152
- }
153
- }
154
- }, [
155
- 'Validate initial type'
156
- ]],
157
-
158
- ['button', {
159
- id: 'typeChoicesOnly-logValue',
160
- $on: {
161
- click () {
162
- console.log(typeSelection.getValue());
163
- }
164
- }
165
- }, ['Log value']],
166
-
167
- ['button', {
168
- id: 'typeChoicesOnly-initializeWithValue',
169
- $on: {
170
- async click () {
171
- await typeSelection.setValue(42);
172
- }
173
- }
174
- }, ['Initialize with a value']]
175
- ]];
176
- })(),
177
-
178
- ['h2', [
179
- 'Convert arbitrary value to an editable menu'
180
- ]],
181
-
182
- await types.getControlsForFormatAndValue(
183
- 'structuredCloning',
184
- new Date('1999-01-01')
185
- ),
186
-
187
- ['h2', [
188
- 'Convert arbitrary value to a readonly menu'
189
- ]],
190
-
191
- await types.getControlsForFormatAndValue(
192
- 'structuredCloning',
193
- new Date('1999-01-01'), {
194
- readonly: true
195
- }
196
- ),
197
-
198
- ['h2', [
199
- 'Convert structured cloning string representation to value and log'
200
- ]],
201
- ['input', {
202
- id: 'getValueForString',
203
- placeholder: 'e.g., ["abc", 17]',
204
- $on: {
205
- change () {
206
- const types = new Types();
207
- const value = types.getValueForString(this.value, {
208
- format: 'structuredCloning'
209
- })[0];
210
- console.log(value);
211
- }
212
- }
213
- }]
214
- ], body);
215
- }, 500);
@@ -1,20 +0,0 @@
1
- import * as structuredCloning from './structuredCloning.js';
2
-
3
- /**
4
- * @type {import('./structuredCloning.js').FormatIterator}
5
- */
6
- export const iterate = (records, stateObj) => {
7
- console.log('records', records, stateObj);
8
- stateObj.format = 'schemaAndArbitrary';
9
- return structuredCloning.iterate(records, stateObj);
10
- };
11
-
12
- /**
13
- * @param {string} state
14
- * @returns {string[]}
15
- */
16
- export const getTypesForState = (state) => {
17
- return structuredCloning.getTypesForState.call(
18
- this, types, state
19
- );
20
- };