@es-joy/jsoe 0.8.1 → 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/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES TO `@es-joy/jsoe`
2
2
 
3
+ ## 0.9.0
4
+
5
+ - feat: add `blob` type
6
+
3
7
  ## 0.8.1
4
8
 
5
9
  - feat: fix bug with `file` in array/object context not triggering file
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. blob (besides HTML, including SVG), filelist
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 typeSelectionBlob = typeChoices({
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
- ...typeSelectionBlob.domArray,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-joy/jsoe",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./src/index.js",
@@ -337,15 +337,7 @@ const canonicalToAvailableType = (format, state, valType, v) => {
337
337
  valType = newValType;
338
338
  }
339
339
  }
340
- if (allowableTypes.some((allowableType) => {
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
- // 'blob', 'filelist',
463
+ // 'filelist',
466
464
  // 'arraybuffer',
467
465
  // 'dataview', 'imagedata', 'imagebitmap',
468
466
  /*