@es-joy/jsoe
v0.32.0
Published
Editing of arbitrary JavaScript objects
Readme
@es-joy/jsoe
JavaScript Object Editor.
Editing and viewing of arbitrary JavaScript objects.
See a demo of this tool or a demo of an app using this tool.
Formats
Formats are a collection of allowed types.
Supported formats include:
- Schemas (using zodexy serialization of Zod)
- Structured Cloning (using typeson) (e.g., IndexedDB values)
- JSON
- IndexedDB keys
Fundamental types
These are generally atomic types which correlate to JavaScript language structures.
Supported types include:
- Array reference (for cyclic arrays)
- Array
BigIntbigintObjectBlobBooleanobjectDateDOMException,ErrorTypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError,AggregateError,InternalErrorFileFileListMap- Non-editable type (catch-all for not-yet-supported object types; allows for preexisting data to be passed on transparently)
nullNumberobject- number
- Object reference (for cyclic objects)
- Object
RegExpSetStringobject- string
undefined
There are also the following fundamental (structured-cloning capable Zodexy) schema types:
boolean(using in place of true/false when schema specifies)catchenumliteralnan(standalone in Zodexy)void(preferred in Zodexy when specified as such)
And there are the following non-structured-cloning Zodexy schema types:
functionpromise
The following is no longer supported as a first class type by Zod and thus Zodexy, but it can be supported by type any with checks (as can other types).
symbol
Has some support for JSON references, but no UI for them at preent.
Subtypes
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.
Supported subtypes include:
- Blob (text/html)
falsetrue
Supertypes
These are collections of individual types, justified by the subitems not being so frequent as to necessitate their own separate enumeration.
Supported supertypes include:
- Special Real Number (
Infinity,-Infinity,-0) - Used with IndexedDB keys (even though -0 apparently to be converted to 0) - Special Number (
Infinity,-Infinity,-0,NaN) - Used with Structured Cloning values DOMMatrix(also includesDOMMatrixReadOnly)DOMPoint(also includesDOMPointReadOnly)DOMRect(also includesDOMRectReadOnly)buffersourceincludesArrayBuffer,DataView, and TypedArrays (int8array, uint8array, uint8clampedarray, int16array, uint16array, int32array, uint32array, float32array, float64array, bigint64array, biguint64array)
Known issues
- Cannot provide maps with object keys pointing to the same objects as used as map values; likewise with Sets?
- Certain cyclical structures may have issues
typeson-registry's structured cloning should throw on more objects, so bad data doesn't end up stored- Currently doesn't support using
isNullable; instead just usenullwith aunion. - Lacks support for certain Structured Cloning types. See to-dos below.
- Excessive use of
reportValidity(e.g., in BufferSource, as seen by index-instrumented demo) causing focus of element; should only be triggered by event (and only if not auto-triggered event)
To-dos
- Ability to replace content with raw JSON6/Typeson/Safe Eval (no functions in default mode, etc.)/AI (including speech-to-text) if it validates
- Expand fundamental types
- Not in typeson-registry
- Structured Cloning
- Web/API types (besides those listed below)
- Structured Cloning
- Already in typeson-registry
- Structured Cloning
- (JavaScript types already complete)
- Web/API types
- quotaexceedederror
- webtransporterror
- imagedata
- imagebitmap
- domquad
- cryptokey
- audiodata
- encodedaudiochunk
- encodedvideochunk
- videoframe
- Our own custom derivative types? (e.g., MIDI using TypedArray)
- Structured Cloning
- Not in typeson-registry
- Expand subtypes
- String
- As supported by Zod, JSON Schema, etc. (e.g., email addresses as
subtype of
string, color as a subtype of string)
- As supported by Zod, JSON Schema, etc. (e.g., email addresses as
subtype of
File/Blob- Drawing image for
image/png, etc.File's - Drawing SVG program for
application/svgFile - JS/CSS/HTML/XML/Markdown/JSON/CSV/text text editor (including syntax highlighting in view mode); with text-to-speech
- OCR (
TextDetectorAPI if implemented) added as image pop-up utility
- Drawing image for
- String
- Might put views and data into separate repos
- Could show more schema data (e.g., min and max) in viewUI, e.g., as extra
rows in the schema
metainfo toggle - Implement as Custom Elements?
- Add drag-and-drop support for
Filetype - Import CSV as array
- Schema-driven search
Might allow search on
.causeandAggregateError.errorsin the futureMight allow "Edit as raw" as JSON6 (edit query object directly)
Could add syntax highlighting for CSS Selector, XPath, Regexes
Need to allow multiple OR'd conditions (e.g., for string) like "matches regex" and "does not contain"
Objects: "Has property <property pull-down>" (avoid listing required)
Arrays, Set, FileList, tuple with rest: "Has length/size of <number>"; arrays: "Is/Is not sparse"
Union/Discriminated Union: "Has type <type pull-down>" (including when union is part of a key to records, maps, discriminator of discriminated union, etc.)
undefined/void, null, NaN, instanceof, Non-editable (no variants to allow for distinct search; if optional, would be in union); non-editable might allow arbitrary JS query against it, but...
boolean, BooleanObject: true or false
number, NumberObject: OR Ranges/Is Not Range, Is/Is Not Integer
bigint, bigint object: OR Ranges/Is Not Range
BufferSource: OR Range/IS Not Range
string, StringObject, Blob, File, regexp (source), symbol (description): OR literal or regex search/Does Not contain search; regexp gets multiple select search of flags or regex search?
Blob HTML:
- XPath (ideally JS like jtlt for XSLT-like JS or doc() and collection() as part of $for in FLWOR shorthand for XQuery-like JS)
- CSS selectors
- Full text search
- Regex search of raw HTML
Special number: multiple select of "Infinity", "-Negativity", "NaN"
date: OR date range, Is Not Range
Enum, Native Enum: multiple select; native enum also can search key vs. value
promise, Literal, catch: pass on children
function; pass on args, return type
Error, Special Errors, DOMException: Literal/Regex search of child string properties, numeric of number children; also pull-down of name for DOMException
DOMRect, DOMPoint, DOMMatrix: numeric search ranges for children; "Is/Is not Readonly"; DOMMatrix: "Is/Is not 3d"
Map, Record: string-type searches of keys, values; ideally would allow search to insist on match of key and value (e.g., has key 2-4 and value 7-9)
Tuple (with rest has size search as with arrays): otherwise just passes on children
