@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
@@ -1 +1 @@
1
- {"version":3,"file":"jsonPointer.d.ts","sourceRoot":"","sources":["../../src/utils/jsonPointer.js"],"names":[],"mappings":"8BA0Ca,GAAG;AA1ChB;;;GAGG;AACH,yCAHc,MAAM,KACP,MAAM,CAMlB;AAED;;;GAGG;AACH,wCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;GAGG;AACH,kDAHW,MAAM,GACJ,MAAM,CASlB;AAED;;;GAGG;AACH,0CAHW,MAAM,GACJ,MAAM,EAAE,CAMpB;AAED;;GAEG;AAEH;;;;GAIG;AACH,4CAJW,eAAe,YACf,MAAM,GACJ,eAAe,GAAC,MAAM,CAQlC;AAED;;;;;GAKG;AACH;IAJuB,IAAI,EAAhB,MAAM;IACe,GAAG,EAAxB,eAAe;IACb,MAAM,GAAC,eAAe,CAOlC;AAED;;;GAGG;AACH,+CAHW,MAAM,GACJ,MAAM,CAYlB"}
1
+ {"version":3,"file":"jsonPointer.d.ts","sourceRoot":"","sources":["../../src/utils/jsonPointer.js"],"names":[],"mappings":"8BA0Ca,GAAG;AA1ChB;;;GAGG;AACH,yCAHc,MAAM,EAAA,GACP,MAAM,CAMlB;AAED;;;GAGG;AACH,wCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;GAGG;AACH,kDAHW,MAAM,GACJ,MAAM,CASlB;AAED;;;GAGG;AACH,0CAHW,MAAM,GACJ,MAAM,EAAE,CAMpB;AAED;;GAEG;AAEH;;;;GAIG;AACH,4CAJW,eAAe,YACf,MAAM,GACJ,eAAe,GAAC,MAAM,CAQlC;AAED;;;;;GAKG;AACH,kDAJG;IAAoB,IAAI,EAAhB,MAAM;IACe,GAAG,EAAxB,eAAe;CACvB,GAAU,MAAM,GAAC,eAAe,CAOlC;AAED;;;GAGG;AACH,+CAHW,MAAM,GACJ,MAAM,CAYlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/utils/media.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,kCALW,WAAW,UACX,iBAAiB,GAEf,IAAI,CA4DhB;AAGD;;;GAGG;AACH,0CAHW,sBAAsB,GACpB,QAAQ,WAAW,GAAC,IAAI,CAAC,CAarC;AAED;;;GAGG;AACH,wDAHW,yBAAyB,GAAC,SAAS,GACjC,QAAQ,WAAW,GAAC,IAAI,CAAC,CAarC"}
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/utils/media.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,kCALW,WAAW,UACX,iBAAiB,GAEf,IAAI,CA4DhB;AAGD;;;GAGG;AACH,0CAHW,sBAAsB,GACpB,OAAO,CAAC,WAAW,GAAC,IAAI,CAAC,CAarC;AAED;;;GAGG;AACH,wDAHW,yBAAyB,GAAC,SAAS,GACjC,OAAO,CAAC,WAAW,GAAC,IAAI,CAAC,CAarC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @typedef {any} ArbitraryObject
3
+ */
4
+ /**
5
+ * @typedef {{[key: string]: string|NestedObject}} NestedObject
6
+ */
7
+ /**
8
+ * @param {ArbitraryObject} obj
9
+ * @returns {ArbitraryObject}
10
+ */
11
+ export function copyObject(obj: ArbitraryObject): ArbitraryObject;
12
+ export type ArbitraryObject = any;
13
+ export type NestedObject = {
14
+ [key: string]: string | NestedObject;
15
+ };
16
+ //# sourceMappingURL=objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/utils/objects.js"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AAEH;;;GAGG;AACH,gCAHW,eAAe,GACb,eAAe,CAY3B;8BApBY,GAAG;2BAGH;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAC,YAAY,CAAA;CAAC"}
@@ -1,2 +1,2 @@
1
- export function isNullish(obj: unknown): boolean;
1
+ export function isNullish(obj: unknown): obj is null | undefined;
2
2
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.js"],"names":[],"mappings":"AAGO,+BAFI,OAAO,WAIjB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.js"],"names":[],"mappings":"AAGO,+BAFI,OAAO,2BAIjB"}
@@ -1,3 +1,3 @@
1
1
  export { jml, body, nbsp, $ } from "jamilih";
2
- export { getJSONType, Typeson, unescapeKeyPathComponent, structuredCloningThrowing, resurrectable, toStringTag } from "typeson-registry";
2
+ export { getJSONType, Typeson, unescapeKeyPathComponent, structuredCloningThrowing, resurrectable, toStringTag, hasConstructorOf } from "typeson-registry";
3
3
  //# sourceMappingURL=vendor-imports.d.ts.map
@@ -0,0 +1,74 @@
1
+ import ashNazg from 'eslint-config-ash-nazg';
2
+
3
+ export default [
4
+ {
5
+ name: 'JSOE/Ignores',
6
+ ignores: [
7
+ 'coverage',
8
+ 'instrumented',
9
+ 'ignore',
10
+ 'src/deepEqual.js',
11
+ 'vendor',
12
+ 'typings/**',
13
+ 'dist'
14
+ ]
15
+ },
16
+ ...ashNazg(['sauron', 'browser']),
17
+ {
18
+ name: 'JSOE/Coverage',
19
+ settings: {
20
+ coverage: true
21
+ }
22
+ },
23
+ {
24
+ name: 'JSOE/Markdown',
25
+ files: ['*.md/*.js'],
26
+ rules: {
27
+ 'import/unambiguous': 'off'
28
+ }
29
+ },
30
+ {
31
+ name: 'JSOE/Cypress',
32
+ files: ['cypress/**'],
33
+ rules: {
34
+ 'unicorn/no-empty-file': 'off'
35
+ }
36
+ },
37
+ {
38
+ name: 'JSOE/main rules',
39
+ rules: {
40
+ 'no-console': 0,
41
+ 'no-shadow': 0,
42
+
43
+ '@stylistic/quotes': ['error', 'single', {
44
+ avoidEscape: true, allowTemplateLiterals: true
45
+ }],
46
+
47
+ 'jsdoc/require-jsdoc': ['warn', {
48
+ contexts: [
49
+ 'Program > VariableDeclaration > ' +
50
+ 'VariableDeclarator > ArrowFunctionExpression',
51
+ 'Program > VariableDeclaration > ' +
52
+ 'VariableDeclarator > FunctionExpression',
53
+ 'ExportNamedDeclaration > VariableDeclaration > ' +
54
+ 'VariableDeclarator > ArrowFunctionExpression',
55
+ 'ExportNamedDeclaration > VariableDeclaration > ' +
56
+ 'VariableDeclarator > FunctionExpression',
57
+ 'ExportDefaultDeclaration > ArrowFunctionExpression',
58
+ 'ExportDefaultDeclaration > FunctionExpression',
59
+
60
+ 'ClassDeclaration',
61
+ 'ClassExpression',
62
+ 'FunctionDeclaration', // Default is true
63
+ 'MethodDefinition'
64
+ ]
65
+ }],
66
+
67
+ // Disable until find time
68
+ 'prefer-named-capture-group': 0,
69
+ // Disable; waiting on https://github.com/mysticatea/eslint-plugin-node/issues/162
70
+ 'n/no-unpublished-import': 0,
71
+ 'unicorn/no-this-assignment': 0
72
+ }
73
+ }
74
+ ];
@@ -0,0 +1,4 @@
1
+ {
2
+ "bundledRootPackages": ["jamilih", "typeson-registry", "zod", "zodex"],
3
+ "filesByLicense": {}
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-joy/jsoe",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./src/index.js",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "description": "Editing of arbitrary JavaScript objects",
14
14
  "browserslist": [
15
- "cover 100%"
15
+ "defaults, not op_mini all"
16
16
  ],
17
17
  "nyc": {
18
18
  "excludeAfterRemap": true,
@@ -23,54 +23,40 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@brettz9/node-static": "^0.1.1",
26
- "jamilih": "0.58.2",
26
+ "jamilih": "0.59.2",
27
27
  "sceditor": "3.2.0",
28
- "typeson-registry": "9.2.1"
28
+ "typeson-registry": "11.0.0",
29
+ "zod": "^3.23.8",
30
+ "zodex": "github:brettz9/zodex#browser-dist"
29
31
  },
30
32
  "devDependencies": {
31
- "@babel/core": "^7.23.6",
32
- "@babel/plugin-transform-modules-commonjs": "^7.23.3",
33
- "@babel/preset-env": "^7.23.6",
34
- "@babel/register": "^7.22.15",
35
- "@brettz9/eslint-plugin": "^1.0.4",
36
- "@cypress/code-coverage": "^3.12.13",
33
+ "@babel/core": "^7.25.2",
34
+ "@babel/plugin-transform-modules-commonjs": "^7.24.8",
35
+ "@babel/preset-env": "^7.25.3",
36
+ "@babel/register": "^7.24.6",
37
+ "@cypress/code-coverage": "^3.12.44",
37
38
  "@rollup/plugin-babel": "^6.0.4",
38
- "@rollup/plugin-commonjs": "^25.0.7",
39
+ "@rollup/plugin-commonjs": "^26.0.1",
39
40
  "@rollup/plugin-node-resolve": "^15.2.3",
40
- "@stylistic/eslint-plugin": "^1.5.1",
41
- "@types/jsdom": "^21.1.6",
42
- "@types/node": "^20.10.4",
43
- "axe-core": "^4.8.2",
44
- "cypress": "^13.6.1",
41
+ "@types/jsdom": "^21.1.7",
42
+ "@types/node": "^22.1.0",
43
+ "axe-core": "^4.10.0",
44
+ "cypress": "^13.13.2",
45
45
  "cypress-axe": "^1.5.0",
46
- "eslint": "^8.55.0",
47
- "eslint-config-ash-nazg": "^35.1.0",
48
- "eslint-config-standard": "^17.1.0",
49
- "eslint-plugin-array-func": "^4.0.0",
50
- "eslint-plugin-compat": "^4.2.0",
51
- "eslint-plugin-cypress": "^2.15.1",
52
- "eslint-plugin-eslint-comments": "^3.2.0",
53
- "eslint-plugin-html": "^7.1.0",
54
- "eslint-plugin-import": "^2.29.0",
55
- "eslint-plugin-jsdoc": "^46.9.1",
56
- "eslint-plugin-markdown": "^3.0.1",
57
- "eslint-plugin-n": "^16.4.0",
58
- "eslint-plugin-no-unsanitized": "^4.0.2",
59
- "eslint-plugin-no-use-extend-native": "^0.5.0",
60
- "eslint-plugin-promise": "^6.1.1",
61
- "eslint-plugin-sonarjs": "^0.23.0",
62
- "eslint-plugin-standard": "^4.1.0",
63
- "eslint-plugin-unicorn": "^49.0.0",
46
+ "eslint": "^9.8.0",
47
+ "eslint-config-ash-nazg": "^36.11.1",
64
48
  "fast-deep-equal": "^3.1.3",
65
- "jsdom": "^21.1.1",
49
+ "jsdom": "^24.1.1",
50
+ "license-badger": "^0.21.1",
66
51
  "npm-run-all": "^4.1.5",
67
- "nyc": "^15.1.0",
68
- "open-cli": "^7.2.0",
69
- "rimraf": "^5.0.5",
70
- "rollup": "4.9.0",
52
+ "nyc": "^17.0.0",
53
+ "open-cli": "^8.0.0",
54
+ "rimraf": "^6.0.1",
55
+ "rollup": "4.20.0",
71
56
  "rollup-plugin-istanbul": "^5.0.0",
57
+ "rollup-plugin-no-op": "^1.0.2",
72
58
  "rollup-plugin-node-builtins": "^2.1.2",
73
- "typescript": "^5.3.3",
59
+ "typescript": "^5.5.4",
74
60
  "typeson": "^9.0.3",
75
61
  "webappfind-demos-samples": "^0.7.0"
76
62
  },
@@ -86,7 +72,7 @@
86
72
  "author": "Brett Zamir",
87
73
  "contributors": [],
88
74
  "engines": {
89
- "node": ">=14.0.0"
75
+ "node": ">=18.0.0"
90
76
  },
91
77
  "bugs": "https://github.com/es-joy/jsoe/issues",
92
78
  "license": "MIT",
@@ -94,6 +80,7 @@
94
80
  "scripts": {
95
81
  "tsc": "tsc",
96
82
  "tsc-cypress": "tsc -p cypress/tsconfig.json",
83
+ "license-badge": "license-badger --corrections --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
97
84
  "eslint": "eslint .",
98
85
  "lint": "npm run eslint --",
99
86
  "coverage": "open-cli http://localhost:8087/coverage/lcov-report/",
@@ -110,10 +97,14 @@
110
97
  "copy-index": "echo \"Copy our index.html file too? \"",
111
98
  "copy-jamilih": "cp node_modules/jamilih/dist/jml-es.js vendor/jamilih/dist/jml-es.js",
112
99
  "copy-typeson-registry": "cp node_modules/typeson-registry/dist/index.js vendor/typeson-registry/dist/index.js",
113
- "copy": "run-p copy-jamilih copy-typeson-registry",
100
+ "copy-zod": "cp node_modules/zod/lib/index.mjs vendor/zod/lib/index.mjs",
101
+ "copy-zodex": "cp -R node_modules/zodex/dist/esm vendor/zodex/dist",
102
+ "copy": "run-p copy-jamilih copy-typeson-registry copy-zod copy-zodex",
114
103
  "instrument": "run-s -c instrument-remove instrument-add copy-index rollup",
115
104
  "cypress:log": "ELECTRON_ENABLE_LOGGING=1 cypress run; nyc report",
116
105
  "cypress": "cypress run; nyc report",
106
+ "cypress:record": "cypress run --record --parallel",
107
+ "report": "nyc report",
117
108
  "test": "npm run eslint && npm run rollup && npm run cypress"
118
109
  }
119
110
  }
package/rollup.config.js CHANGED
@@ -4,9 +4,11 @@ import commonjs from '@rollup/plugin-commonjs';
4
4
  // import babel from 'rollup-plugin-babel';
5
5
  // import {terser} from 'rollup-plugin-terser';
6
6
  import istanbul from 'rollup-plugin-istanbul';
7
+ import noOp from 'rollup-plugin-no-op';
7
8
 
8
9
  export default [{
9
10
  input: 'src/index.js',
11
+ external: ['react'], // Todo: remove when removed from Zodex
10
12
  output: {
11
13
  file: 'dist/index.js',
12
14
  format: 'es'
@@ -22,6 +24,19 @@ export default [{
22
24
  format: 'es'
23
25
  },
24
26
  plugins: [
27
+ noOp({ids: ['react']}), // todo: remove when Zodex may remove dep.
28
+ istanbul(),
29
+ nodeResolve(),
30
+ commonjs()
31
+ ]
32
+ }, {
33
+ input: 'demo/index-schema.js',
34
+ output: {
35
+ file: 'instrumented/demo/index-schema.js',
36
+ format: 'es'
37
+ },
38
+ plugins: [
39
+ noOp({ids: ['react']}), // todo: remove when Zodex may remove dep.
25
40
  istanbul(),
26
41
  nodeResolve(),
27
42
  commonjs()
@@ -13,14 +13,17 @@ import {$e, DOM} from './utils/templateUtils.js';
13
13
  * Defaults to structured cloning.
14
14
  * @todo Compose from format metadata, so can make user customizable.
15
15
  * @param {object} cfg
16
- * @param {string} [cfg.schema] (NOT IN USE)
16
+ * @param {string[]} [cfg.schemas]
17
+ * @param {string} [cfg.selectedSchema]
17
18
  * @param {boolean} [cfg.hasKeyPath] Whether or not a key path is expected; if
18
19
  * true, an indexedDB key is not allowed here as a key does not support
19
20
  * the object type which is needed for a key path.
20
21
  * @returns {DocumentFragment}
21
22
  */
22
- export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
23
- const hasSchema = typeof schema === 'string';
23
+ export const getFormatAndSchemaChoices = ({
24
+ schemas, selectedSchema, hasKeyPath
25
+ } = {}) => {
26
+ const hasSchema = schemas && schemas.length;
24
27
  // eslint-disable-next-line @stylistic/max-len -- Long
25
28
  return /** @type {[optText: string, opts: {value: string, selected?: boolean}][]} */ ([
26
29
  ['JSON only', {value: 'json'}],
@@ -29,35 +32,18 @@ export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
29
32
  : [['IndexedDB key', {value: 'indexedDBKey'}]]),
30
33
  ['Structured Clone (via Typeson JSON)', {
31
34
  value: 'structuredCloning', selected: !hasSchema
32
- }]
33
- /* schema:
35
+ }],
34
36
  ...(hasSchema
35
- ? [
36
- [`Schema + arbitrary: ${schema}`, {
37
- value: 'schemaAndArbitrary',
38
- dataset: {schema}
39
- }],
40
- [`Schema only: ${schema}`, {
41
- value: 'schemaOnly',
37
+ ? schemas.map((schema, idx) => {
38
+ return [`Schema: ${schema}`, {
39
+ value: 'schema',
42
40
  dataset: {schema},
43
- selected: hasSchema
44
- }]
45
- ]
46
- : []
47
- )
48
- */
49
- /*
50
- // This can be supported for editing only
51
- ['Arbitrary (Non-Typeson-serializable will be read-only)', {
52
- value: 'arbitrary',
53
- title: 'Any value that the typeson-registry supports ' +
54
- 'for structured cloning'
55
- }]
56
- */
41
+ selected: selectedSchema ? schema === selectedSchema : idx === 0
42
+ }];
43
+ })
44
+ : [])
57
45
  ]).map(([optText, optAtts]) => {
58
- return /** @type {HTMLOptionElement} */ (
59
- jml('option', optAtts, [optText])
60
- );
46
+ return jml('option', optAtts, [optText]);
61
47
  }).reduce((
62
48
  frag,
63
49
  option
@@ -74,11 +60,16 @@ export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
74
60
  * @returns {Promise<void>}
75
61
  */
76
62
 
63
+ /**
64
+ * @typedef {import('./formats/schema.js').ZodexSchema} ZodexSchema
65
+ */
66
+
77
67
  /**
78
68
  * Builds a selector and container for types.
79
69
  * @param {object} cfg
80
- * @param {string} [cfg.schema] The schema name (NOT IN USE)
81
- * @param {object} [cfg.schemaContent] The schema content (NOT IN USE)
70
+ * @param {string[]} [cfg.schemas] The schema names
71
+ * @param {(schema: string) => Promise<ZodexSchema>} [cfg.getSchemaContent] The
72
+ * schema content retriever
82
73
  * @param {boolean} [cfg.hasValue] Set to `true` if you are supplying
83
74
  * your own value. If `false` and `hasKeyPath` is `true`,
84
75
  * will initialize with an object.
@@ -90,9 +81,10 @@ export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
90
81
  * plain object).
91
82
  * @param {string} [cfg.typeNamespace] Used to prevent conflicts with other
92
83
  * instances of typeChoices on the page
84
+ * @param {string} [cfg.selectedSchema]
93
85
  * @param {import('./formats.js').default} [cfg.formats]
94
86
  * @param {import('./types.js').default} [cfg.types]
95
- * @returns {{
87
+ * @returns {Promise<{
96
88
  * formatChoices: FormatChoices,
97
89
  * typesHolder: TypesHolder,
98
90
  * domArray: [formatChoices: FormatChoices, typesHolder: TypesHolder],
@@ -103,20 +95,21 @@ export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
103
95
  * setValue: SetValue,
104
96
  * formats: import('./formats.js').default,
105
97
  * types: import('./types.js').default
106
- * }} The selector for types and the container for them. Both should be
98
+ * }>} The selector for types and the container for them. Both should be
107
99
  * added to the page.
108
100
  */
109
- export function formatAndTypeChoices ({
110
- schema,
111
- schemaContent,
101
+ export async function formatAndTypeChoices ({
102
+ schemas,
103
+ getSchemaContent,
112
104
  hasValue,
113
105
  singleValue,
114
106
  hasKeyPath,
115
107
  typeNamespace,
108
+ selectedSchema,
116
109
  formats = new Formats(),
117
110
  types = new Types()
118
111
  }) {
119
- const format = 'structuredCloning';
112
+ const format = schemas && schemas.length ? 'schema' : 'structuredCloning';
120
113
  const formatChoices = /** @type {FormatChoices} */ (jml('select', {
121
114
  class: 'formatChoices',
122
115
  hidden: singleValue,
@@ -126,13 +119,21 @@ export function formatAndTypeChoices ({
126
119
  * Sets the desired format and rebuilds the type choices.
127
120
  * @callback SetFormat
128
121
  * @param {string} valueFormat
129
- * @returns {void}
122
+ * @param {boolean} [autoTrigger]
123
+ * @this {HTMLSelectElement & {
124
+ * $buildTypeChoices: TypeChoiceBuilder
125
+ * }}
126
+ * @returns {Promise<void>}
130
127
  */
131
128
 
132
129
  /**
133
130
  * Rebuilds the type choices.
134
131
  * @callback TypeChoiceBuilder
135
- * @returns {void}
132
+ * @param {boolean} [autoTrigger]
133
+ * @this {HTMLSelectElement & {
134
+ * $buildTypeChoices: TypeChoiceBuilder
135
+ * }}
136
+ * @returns {Promise<void>}
136
137
  */
137
138
 
138
139
  /**
@@ -145,38 +146,50 @@ export function formatAndTypeChoices ({
145
146
  /**
146
147
  * @type {SetFormat}
147
148
  */
148
- $setFormat (valueFormat) {
149
+ async $setFormat (valueFormat, autoTrigger) {
149
150
  this.value = valueFormat;
150
- this.$buildTypeChoices();
151
+ await this.$buildTypeChoices(autoTrigger);
151
152
  },
152
153
 
153
154
  /**
154
155
  * @type {TypeChoiceBuilder}
155
156
  */
156
- $buildTypeChoices () {
157
+ async $buildTypeChoices (autoTrigger) {
157
158
  DOM.removeChildren(typesHolder);
159
+ const {schema} = this.selectedOptions[0].dataset;
158
160
  jml({'#': buildTypeChoices({
161
+ autoTrigger,
159
162
  topRoot: /** @type {HTMLDivElement} */ (
160
163
  $e(typesHolder, 'div[data-type]')
161
164
  ),
162
165
  // resultType: 'both',
163
- format: this.value,
166
+ format: /** @type {import('./formats.js').AvailableFormat} */ (
167
+ this.value
168
+ ),
164
169
  formats,
165
170
  types,
166
171
  typeNamespace,
167
172
  requireObject: hasKeyPath,
168
173
  objectHasValue: hasValue,
169
174
  schema,
170
- schemaContent
175
+ schemaContent: await getSchemaContent?.(
176
+ /** @type {string} */ (schema)
177
+ )
171
178
  }).domArray}, typesHolder);
172
179
  }
173
180
  },
174
- $on: {change () {
175
- /** @type {HTMLElement & {$buildTypeChoices: TypeChoiceBuilder}} */ (
176
- this
177
- ).$buildTypeChoices();
178
- }}
179
- }, [getFormatAndSchemaChoices({schema, hasKeyPath})]));
181
+ $on: {
182
+ async change () {
183
+ await /**
184
+ * @type {HTMLSelectElement & {
185
+ * $buildTypeChoices: TypeChoiceBuilder
186
+ * }}
187
+ */ (
188
+ this
189
+ ).$buildTypeChoices();
190
+ }
191
+ }
192
+ }, [getFormatAndSchemaChoices({schemas, hasKeyPath, selectedSchema})]));
180
193
 
181
194
  /**
182
195
  * @callback TypeSelectGetter
@@ -189,7 +202,7 @@ export function formatAndTypeChoices ({
189
202
  * @property {TypeSelectGetter} $getTypeSelect
190
203
  */
191
204
 
192
- const typesHolder = /** @type {HTMLDivElement} */ (
205
+ const typesHolder = (
193
206
  jml('div', {class: 'typesHolder', $custom: {
194
207
  /**
195
208
  * @type {TypeRootGetter}
@@ -210,6 +223,10 @@ export function formatAndTypeChoices ({
210
223
  }})
211
224
  );
212
225
 
226
+ const schema = format === 'schema'
227
+ ? formatChoices.selectedOptions[0].dataset.schema
228
+ : undefined;
229
+
213
230
  jml({'#': buildTypeChoices({
214
231
  // resultType: 'both',
215
232
  topRoot: /** @type {HTMLDivElement} */ ($e(typesHolder, 'div[data-type]')),
@@ -220,7 +237,7 @@ export function formatAndTypeChoices ({
220
237
  requireObject: hasKeyPath,
221
238
  objectHasValue: hasValue,
222
239
  schema,
223
- schemaContent
240
+ schemaContent: await getSchemaContent?.(/** @type {string} */ (schema))
224
241
  }).domArray}, typesHolder);
225
242
 
226
243
  return {
@@ -283,14 +300,14 @@ export function formatAndTypeChoices ({
283
300
  /** @type {SetValue} */
284
301
  async setValue (value, stateObj) {
285
302
  const rootEditUI = /** @type {HTMLDivElement} */ (
286
- await formats.getControlsForFormatAndValue(
303
+ (await formats.getControlsForFormatAndValue(
287
304
  types,
288
305
  /** @type {import('./formats.js').AvailableFormat} */ (
289
306
  formatChoices.value
290
307
  ),
291
308
  value,
292
309
  stateObj
293
- )
310
+ )).rootUI
294
311
  );
295
312
  const type = Types.getTypeForRoot(rootEditUI);
296
313
  // eslint-disable-next-line @stylistic/max-len -- Long
@@ -27,17 +27,22 @@ const indexedDBKey = {
27
27
  }
28
28
  },
29
29
  convertFromTypeson (typesonType) {
30
- return typesonToIndexedDBKey.get(typesonType);
30
+ return {type: typesonToIndexedDBKey.get(typesonType)};
31
31
  },
32
32
  iterate (records, stateObj) {
33
33
  stateObj.format = 'indexedDBKey';
34
34
  return structuredCloning.iterate(records, stateObj);
35
35
  },
36
- getTypesForState (types, state) {
36
+ getTypesAndSchemasForState (types, state) {
37
+ /* istanbul ignore else -- See below */
37
38
  if (!state || ['array'].includes(state)) {
38
- return this.types();
39
+ return {
40
+ types: this.types(),
41
+ schemaObjects: []
42
+ };
39
43
  }
40
- // Can't be object, so shouldn't normally reach here
44
+ // eslint-disable-next-line @stylistic/max-len -- Long
45
+ /* istanbul ignore next -- Can't be object, so shouldn't normally reach here */
41
46
  return undefined;
42
47
  }
43
48
  };
@@ -26,7 +26,7 @@ const json = {
26
26
  },
27
27
  // A hack until we simply pass in our own types or do own parsing
28
28
  convertFromTypeson (typesonType) {
29
- return typesonToJson.get(typesonType);
29
+ return {type: typesonToJson.get(typesonType)};
30
30
  },
31
31
  testInvalid (newType, value) {
32
32
  switch (newType) {
@@ -41,12 +41,15 @@ const json = {
41
41
  return undefined; // Todo: Fix?
42
42
  }
43
43
  },
44
- getTypesForState (types, state) {
44
+ getTypesAndSchemasForState (types, state) {
45
45
  /* istanbul ignore else -- No other states apparently */
46
46
  if (!state || ['array', 'object'].includes(state)) {
47
- return this.types();
47
+ return {
48
+ types: this.types(),
49
+ schemaObjects: []
50
+ };
48
51
  }
49
- // Shouldn't normally reach here
52
+ /* istanbul ignore next -- Shouldn't normally reach here */
50
53
  return undefined;
51
54
  }
52
55
  };