@es-joy/jsoe 0.27.0 → 0.28.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 (49) hide show
  1. package/CHANGES.md +33 -0
  2. package/README.md +3 -1
  3. package/badges/coverage-badge.svg +1 -1
  4. package/badges/tests-badge.svg +1 -0
  5. package/dist/formats/schema.d.ts +11 -0
  6. package/dist/formats/schema.d.ts.map +1 -1
  7. package/dist/formats/structuredCloning.d.ts.map +1 -1
  8. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/typeChoices.d.ts +32 -2
  12. package/dist/typeChoices.d.ts.map +1 -1
  13. package/dist/types.d.ts +8 -2
  14. package/dist/types.d.ts.map +1 -1
  15. package/dist/utils/rawTypesonEditor.d.ts +110 -0
  16. package/dist/utils/rawTypesonEditor.d.ts.map +1 -0
  17. package/dist/vendor-imports.d.ts +4 -0
  18. package/docs/proposals/raw-typeson-edit-view.md +575 -0
  19. package/mmr.json +6 -0
  20. package/package.json +13 -4
  21. package/pnpm-workspace.yaml +1 -0
  22. package/src/formats/schema.js +3 -1
  23. package/src/formats/structuredCloning.js +24 -17
  24. package/src/fundamentalTypes/arrayType.js +105 -1
  25. package/src/jsoe.css +12 -0
  26. package/src/typeChoices.js +36 -7
  27. package/src/types.js +13 -2
  28. package/src/utils/rawTypesonEditor.js +669 -0
  29. package/src/vendor-imports.js +12 -0
  30. package/tsconfig.json +1 -1
  31. package/typings/json-6.d.ts +12 -0
  32. package/vendor/@codemirror/autocomplete/dist/index.js +2125 -0
  33. package/vendor/@codemirror/commands/dist/index.js +1826 -0
  34. package/vendor/@codemirror/lang-javascript/dist/index.js +513 -0
  35. package/vendor/@codemirror/language/dist/index.js +2693 -0
  36. package/vendor/@codemirror/lint/dist/index.js +956 -0
  37. package/vendor/@codemirror/search/dist/index.js +1238 -0
  38. package/vendor/@codemirror/state/dist/index.js +3947 -0
  39. package/vendor/@codemirror/view/dist/index.js +11867 -0
  40. package/vendor/@lezer/common/dist/index.js +2202 -0
  41. package/vendor/@lezer/highlight/dist/index.js +927 -0
  42. package/vendor/@lezer/javascript/dist/index.js +192 -0
  43. package/vendor/@lezer/lr/dist/index.js +1889 -0
  44. package/vendor/@marijn/find-cluster-break/src/index.js +87 -0
  45. package/vendor/codemirror/dist/index.js +96 -0
  46. package/vendor/crelt/index.js +28 -0
  47. package/vendor/json-6/dist/index.mjs +1783 -0
  48. package/vendor/style-mod/src/style-mod.js +172 -0
  49. package/vendor/w3c-keyname/index.js +119 -0
package/CHANGES.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # CHANGES TO `@es-joy/jsoe`
2
2
 
3
+ ## 0.28.0
4
+
5
+ - feat: add raw Typeson/JSON6 "View raw"/"Edit raw" buttons to every
6
+ object/array-family control (`object`, `array`, `set`, `map`, `record`,
7
+ `tuple`, `filelist`), including the root control
8
+ - New `Types` constructor options: `showRawTypesonControls` (default
9
+ `true`) shows or hides the buttons entirely; `allowUnsafeEval`
10
+ (default `false`) additionally offers editing/seeding the same value
11
+ as literal, `eval`'d JS source instead of Typeson/JSON6
12
+ - New `src/utils/rawTypesonEditor.js` opens a dialog with a
13
+ syntax-highlighted (CodeMirror 6) editor; Save re-populates the
14
+ control's children via the same walk `structuredCloning`'s `iterate`
15
+ already uses for building them, then re-validates. A schema-driven
16
+ control's raw edit is also checked against its own schema before
17
+ being accepted
18
+ - New dependencies `json-6` (parsing only — its own `stringify` has a
19
+ string-value-quoting bug, worked around locally) and CodeMirror 6,
20
+ vendored for the bundler-less demo pages
21
+ - Eval-mode source reconstruction covers `Date`/`RegExp`/`Map`/`Set`/
22
+ `Symbol`/boxed primitives/the `Error` family (including `cause` and
23
+ `AggregateError`'s nested errors)/`DOMException`/`DOMRect`/`DOMPoint`/
24
+ `DOMMatrix`/`ArrayBuffer`/`DataView`/typed arrays (including
25
+ `Float16Array`)/`Blob`/`File`/`FileList`/`-0`; a `Promise` or an
26
+ unrecognized class instance throws a clear error instead of silently
27
+ producing a same-shaped-but-wrong value
28
+ - New demo: `demo/index-unsafe-eval.html`
29
+ - fix: resetting an object/array-family control's legend numbering
30
+ (`$resetItemIndex`, used after a raw-value replace) now resets to the
31
+ container's own true starting baseline instead of an array-specific
32
+ `-1`, so replacing a container's content without changing its property
33
+ count keeps each unchanged property's legend number the same as before
34
+ the edit
35
+
3
36
  ## 0.27.0
4
37
 
5
38
  - feat: add `properties` schema support: a zodexy `{type: 'properties'}` node
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  [![Licenses badge](https://raw.githubusercontent.com/es-joy/jsoe/main/badges/licenses-badge.svg?sanitize=true)](badges/licenses-badge.svg)
2
- [![coverage badge](https://raw.githubusercontent.com/es-joy/jsoe/main/badges/coverage-badge.svg?sanitize=true)](badges/coverage-badge.svg)
2
+
3
+ [![Tests badge](./badges/tests-badge.svg)](badges/tests-badge.svg)
4
+ [![coverage badge](./badges/coverage-badge.svg)](badges/coverage-badge.svg)
3
5
 
4
6
  # @es-joy/jsoe
5
7
 
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 97.51%</text><text class="high" x="5" y="14">Statements 97.51%</text><text class="shadow" x="125.5" y="15">Branches 94.24%</text><text class="high" x="125" y="14">Branches 94.24%</text><text class="shadow" x="234.5" y="15">Lines 97.57%</text><text class="high" x="234" y="14">Lines 97.57%</text><text class="shadow" x="321.5" y="15">Functions 98.07%</text><text class="high" x="321" y="14">Functions 98.07%</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="421" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h113v20H0zM113 0h109v20H113zM222 0h87v20h-87zM309 0h112v20H309z"/><path fill="url(#smooth)" d="M0 0h421v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 96.7%</text><text class="high" x="5" y="14">Statements 96.7%</text><text class="shadow" x="118.5" y="15">Branches 93.41%</text><text class="high" x="118" y="14">Branches 93.41%</text><text class="shadow" x="227.5" y="15">Lines 96.76%</text><text class="high" x="227" y="14">Lines 96.76%</text><text class="shadow" x="314.5" y="15">Functions 97.57%</text><text class="high" x="314" y="14">Functions 97.57%</text></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" fill="#fff" rx="3"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#e05d44" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text x="5.5" y="15" class="shadow">Tests</text><text x="5" y="14" class="high">Tests</text><text x="46.5" y="15" class="shadow">795/797</text><text x="46" y="14" class="high">795/797</text></g></svg>
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Exported for reuse by `src/utils/rawTypesonEditor.js`, which must enforce
3
+ * the same schema conformance check before accepting a raw-edited value.
4
+ * @param {InstanceType<typeof import('../types.js').default>} types
5
+ * @param {ZodexSchema} schemaObject
6
+ * @param {ZodexSchema} originalShape
7
+ * @param {unknown} value
8
+ * @returns {ReturnType<ReturnType<typeof dezerialize>['safeParse']>}
9
+ */
10
+ export function parseValue(types: InstanceType<typeof import("../types.js").default>, schemaObject: ZodexSchema, originalShape: ZodexSchema, value: unknown): ReturnType<ReturnType<typeof dezerialize>["safeParse"]>;
1
11
  /**
2
12
  * Checks whether a record property name satisfies the record's `key` schema.
3
13
  *
@@ -55,6 +65,7 @@ export type ValueOf<T> = T[keyof T];
55
65
  export type AvailableZodexType = ValueOf<Pick<import("zodexy").SzType, "type">>;
56
66
  export type ZodexSchema = import("zodexy").SzType;
57
67
  export type NestedObject = import("../utils/objects.js").NestedObject;
68
+ import { dezerialize } from 'zodexy';
58
69
  /** @type {import('../formats.js').Format} */
59
70
  declare const schema: import("../formats.js").Format;
60
71
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/formats/schema.js"],"names":[],"mappings":"AAyOA;;;;;;;;;;;;;GAaG;AACH,yCALW,YAAY,CAAC,cAAc,aAAa,EAAE,OAAO,CAAC,aAClD,WAAW,GAAC,SAAS,OACrB,MAAM,GAAC,MAAM,GAAC,SAAS,GACrB,OAAO,CAenB;AAED;;;;;;;;GAQG;AACH,6CALW,YAAY,CAAC,cAAc,aAAa,EAAE,OAAO,CAAC,aAClD,OAAO,QAAQ,EAAE,OAAO,SACxB,OAAO,GACL;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAA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W,SACX,OAAO,GACL,OAAO,CAInB;AAiDD;;;GAGG;AACH,kDAHW,WAAW,GACT,WAAW,CAIvB;AAsOD;;;;GAIG;AACH,gDAJW,WAAW,gBACX,WAAW,GACT,GAAG,CAAC,WAAW,CAAC,CA8R5B;;;;;oBAx1BY,CAAC,IADD,CAAC,CAAC,MAAM,CAAC,CAAC;iCAKV,OAAO,CACf,IAAI,CAAC,OAAO,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CACtC;0BA8SS,OAAO,QAAQ,EAAE,MAAM;2BAGvB,OAAO,qBAAqB,EAAE,YAAY;4BAnU7B,QAAQ;AAs2BlC,6CAA6C;AAC7C,sBADW,OAAO,eAAe,EAAE,MAAM,CA0TvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"structuredCloning.d.ts","sourceRoot":"","sources":["../../src/formats/structuredCloning.js"],"names":[],"mappings":"AAaA,4CAA4C;AAC5C,2BADW,OAAO,SAAS,EAAE,WAAW,CActC;AAEF,iGAkBE;;;;;;oCA0BW,CAAC,IAAI,EAAE;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,aAAa,EAAE,sBAAsB,CAAC;IACnD,KAAK,EAAE,OAAO,eAAe,EAAE,oBAAoB,CAAC;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,sBAAsB,EAAE,WAAW,CAAC;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,KAAK,WAAW,GAAC,IAAI;kCAIZ,OAAO,kBAAkB,EAAE,mBAAmB;AAsgB3D,6CAA6C;AAC7C,iCADW,OAAO,eAAe,EAAE,MAAM,CA2JvC"}
1
+ {"version":3,"file":"structuredCloning.d.ts","sourceRoot":"","sources":["../../src/formats/structuredCloning.js"],"names":[],"mappings":"AAaA,4CAA4C;AAC5C,2BADW,OAAO,S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