@es-joy/jsoe 0.8.0 → 0.9.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.
- package/.nyc_output/out.json +11255 -6080
- package/CHANGES.md +9 -0
- package/README.md +3 -2
- package/demo/index.js +16 -3
- package/package.json +1 -1
- package/src/formats/structuredCloning.js +9 -11
- package/src/fundamentalTypes/arrayType.js +4 -1
- package/src/fundamentalTypes/blobType.js +1001 -0
- package/src/fundamentalTypes/fileType.js +1 -101
- package/src/jsoe.css +4 -0
- package/src/types.js +3 -1
- package/src/utils/media.js +103 -0
package/CHANGES.md
CHANGED
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ Supported types include:
|
|
|
27
27
|
- Array reference (for cyclic arrays)
|
|
28
28
|
- Array
|
|
29
29
|
- `BigInt`
|
|
30
|
+
- `Blob`
|
|
30
31
|
- `Boolean` object
|
|
31
32
|
- `Date`
|
|
32
33
|
- `Error`
|
|
@@ -103,14 +104,14 @@ Supported supertypes include:
|
|
|
103
104
|
1. bigint64arrayconstructor
|
|
104
105
|
1. biguint64arrayconstructor
|
|
105
106
|
1. Web/API types
|
|
106
|
-
1.
|
|
107
|
+
1. filelist
|
|
107
108
|
1. imagedata, imagebitmap
|
|
108
109
|
1. Our own custom derivative types (e.g., MIDI using TypedArray)
|
|
109
110
|
1. Expand subtypes
|
|
110
111
|
1. String
|
|
111
112
|
1. As supported by Zod, JSON Schema, etc. (e.g., email addresses as
|
|
112
113
|
subtype of `string`, color as a subtype of string)
|
|
113
|
-
1. `File`
|
|
114
|
+
1. `File`/`Blob`
|
|
114
115
|
1. Drawing image for `image/png`, etc. `File`'s
|
|
115
116
|
1. Drawing SVG program for `application/svg` `File`
|
|
116
117
|
1. JS/CSS/HTML/XML/Markdown/JSON/CSV/text text editor (including
|
package/demo/index.js
CHANGED
|
@@ -337,12 +337,15 @@ setTimeout(async function () {
|
|
|
337
337
|
new File(['abc'], 'someName', {
|
|
338
338
|
lastModified: 1231231230,
|
|
339
339
|
type: 'text/plain'
|
|
340
|
+
}),
|
|
341
|
+
new Blob(['abc'], {
|
|
342
|
+
type: 'text/plain'
|
|
340
343
|
})
|
|
341
344
|
],
|
|
342
345
|
typeNamespace: 'demo-type-choices-only-initial-value'
|
|
343
346
|
});
|
|
344
347
|
|
|
345
|
-
const
|
|
348
|
+
const typeSelectionBlobHTML = typeChoices({
|
|
346
349
|
format: 'structuredCloning',
|
|
347
350
|
setValue: true,
|
|
348
351
|
value: new Blob(['<b>Testing</b>'], {type: 'text/html'}),
|
|
@@ -399,14 +402,24 @@ setTimeout(async function () {
|
|
|
399
402
|
typeNamespace: 'demo-type-choices-only-initial-value'
|
|
400
403
|
});
|
|
401
404
|
|
|
405
|
+
const typeSelectionBlob = typeChoices({
|
|
406
|
+
format: 'structuredCloning',
|
|
407
|
+
setValue: true,
|
|
408
|
+
value: new Blob(['abc'], {
|
|
409
|
+
type: 'text/plain'
|
|
410
|
+
}),
|
|
411
|
+
typeNamespace: 'demo-type-choices-only-initial-value'
|
|
412
|
+
});
|
|
413
|
+
|
|
402
414
|
return ['form', [
|
|
403
415
|
...typeSelection.domArray,
|
|
404
|
-
...
|
|
416
|
+
...typeSelectionBlobHTML.domArray,
|
|
405
417
|
...typeSelectionErrorWithCause.domArray,
|
|
406
418
|
...typeSelectionIndexedDBKey.domArray,
|
|
407
419
|
...typeSelectionTypeErrorWithCause.domArray,
|
|
408
420
|
...typeSelectionTypeErrorWithAggregate.domArray,
|
|
409
|
-
...typeSelectionFile.domArray
|
|
421
|
+
...typeSelectionFile.domArray,
|
|
422
|
+
...typeSelectionBlob.domArray
|
|
410
423
|
]];
|
|
411
424
|
})(),
|
|
412
425
|
|
package/package.json
CHANGED
|
@@ -337,15 +337,7 @@ const canonicalToAvailableType = (format, state, valType, v) => {
|
|
|
337
337
|
valType = newValType;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
|
|
341
|
-
if (allowableType === valType) {
|
|
342
|
-
ret = allowableType;
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
return false;
|
|
346
|
-
})) {
|
|
347
|
-
return /** @type {import('../types.js').AvailableType} */ (ret);
|
|
348
|
-
}
|
|
340
|
+
|
|
349
341
|
// console.log('ret', ret);
|
|
350
342
|
allowableTypes.some((allowableType) => {
|
|
351
343
|
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
@@ -364,6 +356,11 @@ const canonicalToAvailableType = (format, state, valType, v) => {
|
|
|
364
356
|
ret = allowableType;
|
|
365
357
|
return true;
|
|
366
358
|
}
|
|
359
|
+
if (allowableType === valType) {
|
|
360
|
+
ret = allowableType;
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
|
|
367
364
|
return false;
|
|
368
365
|
});
|
|
369
366
|
// console.log('ret2', ret);
|
|
@@ -457,12 +454,13 @@ const structuredCloning = {
|
|
|
457
454
|
'StringObject',
|
|
458
455
|
'error',
|
|
459
456
|
'errors',
|
|
460
|
-
'blobHTML',
|
|
457
|
+
'blobHTML', // Must come before `blob`
|
|
458
|
+
'blob',
|
|
461
459
|
'file',
|
|
462
460
|
'set',
|
|
463
461
|
'map'
|
|
464
462
|
// Ok, but will need some work
|
|
465
|
-
// '
|
|
463
|
+
// 'filelist',
|
|
466
464
|
// 'arraybuffer',
|
|
467
465
|
// 'dataview', 'imagedata', 'imagebitmap',
|
|
468
466
|
/*
|
|
@@ -1691,7 +1691,10 @@ const arrayType = {
|
|
|
1691
1691
|
// invalid date checkbox; is this sufficient to prevent
|
|
1692
1692
|
// other stray clicks apparently meant for the array
|
|
1693
1693
|
// and object reference checking?
|
|
1694
|
-
if (![
|
|
1694
|
+
if (![
|
|
1695
|
+
'checkbox', 'radio', 'file',
|
|
1696
|
+
'datetime-local'
|
|
1697
|
+
].includes(target.type)) {
|
|
1695
1698
|
e.preventDefault();
|
|
1696
1699
|
}
|
|
1697
1700
|
}
|