@es-joy/jsoe 0.13.7 → 0.14.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/.eslintrc.cjs +5 -0
- package/.nyc_output/out.json +13027 -11984
- package/CHANGES.md +10 -0
- package/README.md +5 -4
- package/demo/index.js +68 -2
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
- package/dist/fundamentalTypes/filelistType.d.ts.map +1 -1
- package/dist/fundamentalTypes/mapType.d.ts.map +1 -1
- package/dist/fundamentalTypes/noneditableType.d.ts +6 -0
- package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -0
- package/dist/fundamentalTypes/objectReferenceType.d.ts.map +1 -1
- package/dist/fundamentalTypes/objectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/setType.d.ts.map +1 -1
- package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/index.js +436 -109
- package/dist/superTypes/SpecialNumberType.d.ts +2 -10
- package/dist/superTypes/SpecialNumberType.d.ts.map +1 -1
- package/dist/superTypes/SpecialRealNumberType.d.ts +2 -2
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
- package/dist/superTypes/dommatrixType.d.ts +6 -0
- package/dist/superTypes/dommatrixType.d.ts.map +1 -0
- package/dist/superTypes/dompointType.d.ts +6 -0
- package/dist/superTypes/dompointType.d.ts.map +1 -0
- package/dist/superTypes/domrectType.d.ts +6 -0
- package/dist/superTypes/domrectType.d.ts.map +1 -0
- package/dist/superTypes/errorsSpecialType.d.ts +2 -2
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
- package/dist/types.d.ts +27 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +1 -1
- package/package.json +13 -13
- package/src/formats/structuredCloning.js +49 -6
- package/src/fundamentalTypes/BooleanObjectType.js +3 -1
- package/src/fundamentalTypes/NumberObjectType.js +3 -1
- package/src/fundamentalTypes/StringObjectType.js +3 -1
- package/src/fundamentalTypes/arrayType.js +4 -2
- package/src/fundamentalTypes/blobType.js +17 -13
- package/src/fundamentalTypes/dateType.js +6 -2
- package/src/fundamentalTypes/fileType.js +14 -12
- package/src/fundamentalTypes/filelistType.js +3 -1
- package/src/fundamentalTypes/mapType.js +3 -1
- package/src/fundamentalTypes/noneditableType.js +87 -0
- package/src/fundamentalTypes/objectReferenceType.js +3 -1
- package/src/fundamentalTypes/objectType.js +3 -1
- package/src/fundamentalTypes/setType.js +3 -1
- package/src/fundamentalTypes/sparseUndefinedType.js +3 -1
- package/src/fundamentalTypes/undefinedType.js +3 -1
- package/src/subTypes/blobHTMLType.js +1 -1
- package/src/superTypes/SpecialNumberType.js +2 -8
- package/src/superTypes/SpecialRealNumberType.js +2 -2
- package/src/{fundamentalTypes → superTypes}/dommatrixType.js +63 -10
- package/src/{fundamentalTypes → superTypes}/dompointType.js +60 -7
- package/src/{fundamentalTypes → superTypes}/domrectType.js +59 -7
- package/src/superTypes/errorsSpecialType.js +1 -1
- package/src/types.js +40 -17
- package/src/utils/media.js +3 -2
- package/src/vendor-imports.js +2 -1
- package/vendor/typeson-registry/dist/index.js +90 -28
package/src/types.js
CHANGED
|
@@ -38,9 +38,10 @@ import fileType from './fundamentalTypes/fileType.js';
|
|
|
38
38
|
import filelistType from './fundamentalTypes/filelistType.js';
|
|
39
39
|
import blobType from './fundamentalTypes/blobType.js';
|
|
40
40
|
import domexceptionType from './fundamentalTypes/domexceptionType.js';
|
|
41
|
-
import domrectType from './
|
|
42
|
-
import dompointType from './
|
|
43
|
-
import dommatrixType from './
|
|
41
|
+
import domrectType from './superTypes/domrectType.js';
|
|
42
|
+
import dompointType from './superTypes/dompointType.js';
|
|
43
|
+
import dommatrixType from './superTypes/dommatrixType.js';
|
|
44
|
+
import noneditableType from './fundamentalTypes/noneditableType.js';
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Utility to retrieve the property value given a legend element.
|
|
@@ -266,6 +267,16 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
266
267
|
* ) => void} TypeObjectSetValue
|
|
267
268
|
*/
|
|
268
269
|
|
|
270
|
+
/**
|
|
271
|
+
* @typedef {(
|
|
272
|
+
* s: string, info?: RootInfo
|
|
273
|
+
* ) => {
|
|
274
|
+
* value?: StructuredCloneValue,
|
|
275
|
+
* remnant?: string,
|
|
276
|
+
* assign?: false
|
|
277
|
+
* }} ToValue
|
|
278
|
+
*/
|
|
279
|
+
|
|
269
280
|
/**
|
|
270
281
|
* @typedef {object} TypeObject
|
|
271
282
|
* @property {[
|
|
@@ -295,13 +306,7 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
295
306
|
* check whether this subtype matches
|
|
296
307
|
* @property {string} [superType] The greater fundamental type to which
|
|
297
308
|
* the type belongs
|
|
298
|
-
* @property {
|
|
299
|
-
* s: string, info?: RootInfo
|
|
300
|
-
* ) => {
|
|
301
|
-
* value?: StructuredCloneValue,
|
|
302
|
-
* remnant?: string,
|
|
303
|
-
* assign?: false
|
|
304
|
-
* }} toValue Converts from string to value. May use
|
|
309
|
+
* @property {ToValue} [toValue] Converts from string to value. May use
|
|
305
310
|
* `stringRegex` to find components.
|
|
306
311
|
* @property {(info: {
|
|
307
312
|
* root: HTMLDivElement,
|
|
@@ -370,9 +375,15 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
370
375
|
* "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
|
|
371
376
|
* "int32array"|"uint32array"|"float32array"|"float64array"|"ValidDate"|
|
|
372
377
|
* "arrayNonindexKeys"|"error"|"errors"|"blob"|"domexception"|"domrect"|
|
|
373
|
-
* "dompoint"|"dommatrix"} AvailableType
|
|
378
|
+
* "dompoint"|"dommatrix"|"resurrectable"} AvailableType
|
|
374
379
|
*/
|
|
375
380
|
|
|
381
|
+
/**
|
|
382
|
+
* @typedef {TypeObject & {
|
|
383
|
+
* childTypes: string[]
|
|
384
|
+
* }} SuperTypeObject
|
|
385
|
+
*/
|
|
386
|
+
|
|
376
387
|
/**
|
|
377
388
|
*
|
|
378
389
|
*/
|
|
@@ -436,6 +447,8 @@ class Types {
|
|
|
436
447
|
dompoint: dompointType,
|
|
437
448
|
dommatrix: dommatrixType,
|
|
438
449
|
|
|
450
|
+
resurrectable: noneditableType,
|
|
451
|
+
|
|
439
452
|
arraybuffer: {
|
|
440
453
|
option: ['ArrayBuffer']
|
|
441
454
|
},
|
|
@@ -591,10 +604,13 @@ class Types {
|
|
|
591
604
|
(Types.getTypeForRoot(root))
|
|
592
605
|
]
|
|
593
606
|
);
|
|
594
|
-
// Ensure `stateObj` remains a reference
|
|
607
|
+
// Ensure `stateObj` remains a reference if present
|
|
595
608
|
return typeObject.getValue({
|
|
596
609
|
root,
|
|
597
|
-
|
|
610
|
+
/* istanbul ignore next -- Guard */
|
|
611
|
+
stateObj: stateObj ?? {
|
|
612
|
+
types: this
|
|
613
|
+
},
|
|
598
614
|
currentPath
|
|
599
615
|
});
|
|
600
616
|
}
|
|
@@ -636,11 +652,12 @@ class Types {
|
|
|
636
652
|
|
|
637
653
|
/** @type {GetOptionForType} */
|
|
638
654
|
getOptionForType (type) {
|
|
655
|
+
const availableType = /** @type {TypeObject} */ (
|
|
656
|
+
this.availableTypes[type]
|
|
657
|
+
);
|
|
639
658
|
/** @type {[string, {value?: AvailableType, title?: string}?]} */
|
|
640
659
|
const optInfo = [
|
|
641
|
-
...
|
|
642
|
-
this.availableTypes[type]
|
|
643
|
-
)).option
|
|
660
|
+
...availableType.option
|
|
644
661
|
];
|
|
645
662
|
optInfo[1] = {value: type, ...(optInfo[1])};
|
|
646
663
|
return /** @type {[string, {value: AvailableType, title?: string}]} */ (
|
|
@@ -656,6 +673,7 @@ class Types {
|
|
|
656
673
|
if (!typesForFormatAndState) {
|
|
657
674
|
throw new Error('Unexpected type for format and state');
|
|
658
675
|
}
|
|
676
|
+
|
|
659
677
|
return typesForFormatAndState.map((type) => {
|
|
660
678
|
return this.getOptionForType(type);
|
|
661
679
|
});
|
|
@@ -838,7 +856,12 @@ class Types {
|
|
|
838
856
|
// console.log('s0', s, '::', remnant, match);
|
|
839
857
|
let valObj;
|
|
840
858
|
try {
|
|
841
|
-
|
|
859
|
+
const typeObj = /** @type {TypeObject} */ (found[1]);
|
|
860
|
+
/* istanbul ignore if -- TS guard */
|
|
861
|
+
if (!typeObj.toValue) {
|
|
862
|
+
throw new Error('Type has no `toValue` method');
|
|
863
|
+
}
|
|
864
|
+
valObj = typeObj.toValue(
|
|
842
865
|
mtch.groups?.innerContent || innerContent || s, {
|
|
843
866
|
types: this,
|
|
844
867
|
format,
|
package/src/utils/media.js
CHANGED
|
@@ -75,9 +75,10 @@ async function getUserMedia (constraints) {
|
|
|
75
75
|
let stream = null;
|
|
76
76
|
try {
|
|
77
77
|
stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
78
|
-
/* c8 ignore next 4 */
|
|
79
78
|
} catch (err) {
|
|
79
|
+
/* istanbul ignore next */
|
|
80
80
|
console.error('err', err);
|
|
81
|
+
/* istanbul ignore next */
|
|
81
82
|
return null;
|
|
82
83
|
}
|
|
83
84
|
return stream;
|
|
@@ -93,8 +94,8 @@ async function startScreenCapture (displayMediaOptions) {
|
|
|
93
94
|
try {
|
|
94
95
|
captureStream =
|
|
95
96
|
await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
|
|
96
|
-
/* c8 ignore next 3 */
|
|
97
97
|
} catch (err) {
|
|
98
|
+
/* istanbul ignore next */
|
|
98
99
|
console.error(`Error: ${err}`);
|
|
99
100
|
}
|
|
100
101
|
return captureStream;
|
package/src/vendor-imports.js
CHANGED
|
@@ -2,6 +2,7 @@ export {jml, body, nbsp, $} from 'jamilih';
|
|
|
2
2
|
// export {jml, body, nbsp, $} from '../node_modules/jamilih/dist/jml-es.js';
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
|
-
getJSONType, Typeson, unescapeKeyPathComponent, structuredCloningThrowing
|
|
5
|
+
getJSONType, Typeson, unescapeKeyPathComponent, structuredCloningThrowing,
|
|
6
|
+
resurrectable, toStringTag
|
|
6
7
|
} from 'typeson-registry';
|
|
7
8
|
// } from '../node_modules/typeson-registry/dist/index.js';
|
|
@@ -500,14 +500,29 @@ const domexception = {
|
|
|
500
500
|
}
|
|
501
501
|
};
|
|
502
502
|
|
|
503
|
-
/* globals DOMMatrix */
|
|
503
|
+
/* globals DOMMatrix, DOMMatrixReadOnly */
|
|
504
504
|
|
|
505
505
|
/**
|
|
506
506
|
* @type {import('typeson').TypeSpecSet}
|
|
507
507
|
*/
|
|
508
|
-
const dommatrix = {
|
|
509
|
-
|
|
510
|
-
|
|
508
|
+
const dommatrix = {};
|
|
509
|
+
|
|
510
|
+
/* c8 ignore next */
|
|
511
|
+
if (typeof DOMMatrix !== 'undefined') {
|
|
512
|
+
create$5(DOMMatrix);
|
|
513
|
+
}
|
|
514
|
+
/* c8 ignore next */
|
|
515
|
+
if (typeof DOMMatrixReadOnly !== 'undefined') {
|
|
516
|
+
create$5(DOMMatrixReadOnly);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @param {typeof DOMMatrix|typeof DOMMatrixReadOnly} Ctor
|
|
521
|
+
* @returns {void}
|
|
522
|
+
*/
|
|
523
|
+
function create$5 (Ctor) {
|
|
524
|
+
dommatrix[Ctor.name.toLowerCase()] = {
|
|
525
|
+
test (x) { return toStringTag(x) === Ctor.name; },
|
|
511
526
|
replace (dm) {
|
|
512
527
|
if (dm.is2D) {
|
|
513
528
|
return {
|
|
@@ -540,26 +555,41 @@ const dommatrix = {
|
|
|
540
555
|
},
|
|
541
556
|
revive (o) {
|
|
542
557
|
if (Object.hasOwn(o, 'a')) {
|
|
543
|
-
return new
|
|
558
|
+
return new Ctor([o.a, o.b, o.c, o.d, o.e, o.f]);
|
|
544
559
|
}
|
|
545
|
-
return new
|
|
560
|
+
return new Ctor([
|
|
546
561
|
o.m11, o.m12, o.m13, o.m14,
|
|
547
562
|
o.m21, o.m22, o.m23, o.m24,
|
|
548
563
|
o.m31, o.m32, o.m33, o.m34,
|
|
549
564
|
o.m41, o.m42, o.m43, o.m44
|
|
550
565
|
]);
|
|
551
566
|
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
554
569
|
|
|
555
|
-
/* globals DOMPoint */
|
|
570
|
+
/* globals DOMPoint, DOMPointReadOnly */
|
|
556
571
|
|
|
557
572
|
/**
|
|
558
573
|
* @type {import('typeson').TypeSpecSet}
|
|
559
574
|
*/
|
|
560
|
-
const dompoint = {
|
|
561
|
-
|
|
562
|
-
|
|
575
|
+
const dompoint = {};
|
|
576
|
+
|
|
577
|
+
/* c8 ignore next */
|
|
578
|
+
if (typeof DOMPoint !== 'undefined') {
|
|
579
|
+
create$4(DOMPoint);
|
|
580
|
+
}
|
|
581
|
+
/* c8 ignore next */
|
|
582
|
+
if (typeof DOMPointReadOnly !== 'undefined') {
|
|
583
|
+
create$4(DOMPointReadOnly);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @param {typeof DOMPoint|typeof DOMPointReadOnly} Ctor
|
|
588
|
+
* @returns {void}
|
|
589
|
+
*/
|
|
590
|
+
function create$4 (Ctor) {
|
|
591
|
+
dompoint[Ctor.name.toLowerCase()] = {
|
|
592
|
+
test (x) { return toStringTag(x) === Ctor.name; },
|
|
563
593
|
replace (dp) {
|
|
564
594
|
return {
|
|
565
595
|
x: dp.x,
|
|
@@ -569,19 +599,56 @@ const dompoint = {
|
|
|
569
599
|
};
|
|
570
600
|
},
|
|
571
601
|
revive ({x, y, z, w}) {
|
|
572
|
-
return new
|
|
602
|
+
return new Ctor(x, y, z, w);
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/* globals DOMQuad */
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* @type {import('typeson').TypeSpecSet}
|
|
611
|
+
*/
|
|
612
|
+
const domquad = {
|
|
613
|
+
domquad: {
|
|
614
|
+
test (x) { return toStringTag(x) === 'DOMQuad'; },
|
|
615
|
+
replace (dp) {
|
|
616
|
+
return {
|
|
617
|
+
p1: dp.p1,
|
|
618
|
+
p2: dp.p2,
|
|
619
|
+
p3: dp.p3,
|
|
620
|
+
p4: dp.p4
|
|
621
|
+
};
|
|
622
|
+
},
|
|
623
|
+
revive ({p1, p2, p3, p4}) {
|
|
624
|
+
return new DOMQuad(p1, p2, p3, p4);
|
|
573
625
|
}
|
|
574
626
|
}
|
|
575
627
|
};
|
|
576
628
|
|
|
577
|
-
/* globals DOMRect */
|
|
629
|
+
/* globals DOMRect, DOMRectReadOnly */
|
|
578
630
|
|
|
579
631
|
/**
|
|
580
632
|
* @type {import('typeson').TypeSpecSet}
|
|
581
633
|
*/
|
|
582
|
-
const domrect = {
|
|
583
|
-
|
|
584
|
-
|
|
634
|
+
const domrect = {};
|
|
635
|
+
|
|
636
|
+
/* c8 ignore next */
|
|
637
|
+
if (typeof DOMRect !== 'undefined') {
|
|
638
|
+
create$3(DOMRect);
|
|
639
|
+
}
|
|
640
|
+
/* c8 ignore next */
|
|
641
|
+
if (typeof DOMRectReadOnly !== 'undefined') {
|
|
642
|
+
create$3(DOMRectReadOnly);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* @param {typeof DOMRect|typeof DOMRectReadOnly} Ctor
|
|
647
|
+
* @returns {void}
|
|
648
|
+
*/
|
|
649
|
+
function create$3 (Ctor) {
|
|
650
|
+
domrect[Ctor.name.toLowerCase()] = {
|
|
651
|
+
test (x) { return toStringTag(x) === Ctor.name; },
|
|
585
652
|
replace (dr) {
|
|
586
653
|
return {
|
|
587
654
|
x: dr.x,
|
|
@@ -591,10 +658,10 @@ const domrect = {
|
|
|
591
658
|
};
|
|
592
659
|
},
|
|
593
660
|
revive ({x, y, width, height}) {
|
|
594
|
-
return new
|
|
661
|
+
return new Ctor(x, y, width, height);
|
|
595
662
|
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
663
|
+
};
|
|
664
|
+
}
|
|
598
665
|
|
|
599
666
|
/**
|
|
600
667
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -719,12 +786,6 @@ function create$2 (Ctor) {
|
|
|
719
786
|
e.lineNumber = obj.lineNumber;
|
|
720
787
|
e.columnNumber = obj.columnNumber;
|
|
721
788
|
|
|
722
|
-
/* c8 ignore next 6 */
|
|
723
|
-
if (isAggregateError) {
|
|
724
|
-
/** @type {AggregateError} */ (
|
|
725
|
-
e
|
|
726
|
-
).errors = obj.errors;
|
|
727
|
-
}
|
|
728
789
|
return e;
|
|
729
790
|
}
|
|
730
791
|
};
|
|
@@ -1604,6 +1665,8 @@ const expObj = [
|
|
|
1604
1665
|
/* c8 ignore next */
|
|
1605
1666
|
typeof DOMPoint !== 'undefined' ? dompoint : [],
|
|
1606
1667
|
/* c8 ignore next */
|
|
1668
|
+
typeof DOMQuad !== 'undefined' ? domquad : [],
|
|
1669
|
+
/* c8 ignore next */
|
|
1607
1670
|
typeof DOMMatrix !== 'undefined' ? dommatrix : []
|
|
1608
1671
|
);
|
|
1609
1672
|
|
|
@@ -1673,7 +1736,6 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1673
1736
|
typeof val.nodeType === 'number' &&
|
|
1674
1737
|
typeof val.insertBefore === 'function')
|
|
1675
1738
|
) {
|
|
1676
|
-
alert(stringTag);
|
|
1677
1739
|
throw new DOMException(
|
|
1678
1740
|
'The object cannot be cloned.', 'DataCloneError'
|
|
1679
1741
|
);
|
|
@@ -1700,5 +1762,5 @@ const universal = [
|
|
|
1700
1762
|
// built-in into ecmasript standard.
|
|
1701
1763
|
];
|
|
1702
1764
|
|
|
1703
|
-
export { u as JSON_TYPES, c as Typeson, e as TypesonPromise, s as Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
|
|
1765
|
+
export { u as JSON_TYPES, c as Typeson, e as TypesonPromise, s as Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
|
|
1704
1766
|
//# sourceMappingURL=index.js.map
|