@es-joy/jsoe 0.21.0 → 0.23.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 +8 -0
- package/badges/coverage-badge.svg +1 -1
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/index.js +1 -21841
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/rollup.config.js +15 -8
- package/src/formats/structuredCloning.js +33 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@es-joy/jsoe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@brettz9/node-static": "^0.1.1",
|
|
29
|
-
"jamilih": "0.
|
|
29
|
+
"jamilih": "0.60.0",
|
|
30
30
|
"sceditor": "3.2.0",
|
|
31
31
|
"typeson-registry": "11.0.0",
|
|
32
32
|
"zod": "^3.23.8",
|
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.25.2",
|
|
37
37
|
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
|
|
38
|
-
"@babel/preset-env": "^7.25.
|
|
38
|
+
"@babel/preset-env": "^7.25.4",
|
|
39
39
|
"@babel/register": "^7.24.6",
|
|
40
40
|
"@cypress/code-coverage": "^3.12.45",
|
|
41
41
|
"@rollup/plugin-babel": "^6.0.4",
|
|
42
42
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
43
43
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
44
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
44
45
|
"@types/jsdom": "^21.1.7",
|
|
45
46
|
"@types/node": "^22.5.0",
|
|
46
47
|
"axe-core": "^4.10.0",
|
package/rollup.config.js
CHANGED
|
@@ -2,7 +2,7 @@ import builtins from 'rollup-plugin-node-builtins';
|
|
|
2
2
|
import {nodeResolve} from '@rollup/plugin-node-resolve';
|
|
3
3
|
import commonjs from '@rollup/plugin-commonjs';
|
|
4
4
|
// import babel from 'rollup-plugin-babel';
|
|
5
|
-
|
|
5
|
+
import terser from '@rollup/plugin-terser';
|
|
6
6
|
import istanbul from 'rollup-plugin-istanbul';
|
|
7
7
|
import noOp from 'rollup-plugin-no-op';
|
|
8
8
|
|
|
@@ -15,6 +15,13 @@ export default [{
|
|
|
15
15
|
format: 'es'
|
|
16
16
|
},
|
|
17
17
|
plugins: [
|
|
18
|
+
terser({
|
|
19
|
+
/* eslint-disable camelcase -- API */
|
|
20
|
+
// Needed for Typeson's `Undefined` and other constructor detection
|
|
21
|
+
keep_fnames: true,
|
|
22
|
+
keep_classnames: true // Keep in case implementing above as classes
|
|
23
|
+
/* eslint-enable camelcase -- API */
|
|
24
|
+
}),
|
|
18
25
|
nodeResolve(),
|
|
19
26
|
commonjs()
|
|
20
27
|
]
|
|
@@ -76,13 +83,13 @@ export default [{
|
|
|
76
83
|
},
|
|
77
84
|
plugins: [
|
|
78
85
|
/*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
babel(),
|
|
87
|
+
terser({
|
|
88
|
+
// Needed for Typeson's `Undefined` and other constructor detection
|
|
89
|
+
keep_fnames: true,
|
|
90
|
+
keep_classnames: true // Keep in case implementing above as classes
|
|
91
|
+
}),
|
|
92
|
+
*/
|
|
86
93
|
builtins(),
|
|
87
94
|
nodeResolve(),
|
|
88
95
|
commonjs({
|
|
@@ -484,47 +484,45 @@ const canonicalTypeToAvailableTypeAndSchema = (
|
|
|
484
484
|
|
|
485
485
|
/** @type {import('../formats.js').Format} */
|
|
486
486
|
const structuredCloning = {
|
|
487
|
-
iterate (records, stateObj) {
|
|
487
|
+
async iterate (records, stateObj) {
|
|
488
488
|
/* istanbul ignore if -- Just a guard */
|
|
489
489
|
if (!stateObj.format) {
|
|
490
490
|
stateObj.format = 'structuredCloning';
|
|
491
491
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
return Object.hasOwn(typeSpecSet, prop);
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
);
|
|
508
|
-
structuredCloningFixed.splice(
|
|
509
|
-
// Add after userObjects
|
|
510
|
-
1,
|
|
511
|
-
0,
|
|
512
|
-
noneditable
|
|
513
|
-
);
|
|
514
|
-
const typeson = new Typeson({
|
|
515
|
-
encapsulateObserver: encapsulateObserver(stateObj)
|
|
516
|
-
}).register(structuredCloningFixed);
|
|
517
|
-
typeson.encapsulate(records);
|
|
518
|
-
// Todo (low): We might want to run async encapsulate for
|
|
519
|
-
// async types (and put this after Promise resolves)
|
|
520
|
-
if (stateObj.error) {
|
|
521
|
-
reject(stateObj.error);
|
|
522
|
-
} else {
|
|
523
|
-
resolve(/** @type {Required<import('../types.js').StateObject>} */ (
|
|
524
|
-
stateObj
|
|
525
|
-
));
|
|
492
|
+
|
|
493
|
+
const structuredCloningFixed = structuredCloningThrowing.filter(
|
|
494
|
+
(typeSpecSet) => {
|
|
495
|
+
return ![
|
|
496
|
+
// Not yet supported within JSOE
|
|
497
|
+
'imagedata',
|
|
498
|
+
'imagebitmap',
|
|
499
|
+
'cryptokey',
|
|
500
|
+
'domquad'
|
|
501
|
+
].some((prop) => {
|
|
502
|
+
return Object.hasOwn(typeSpecSet, prop);
|
|
503
|
+
});
|
|
526
504
|
}
|
|
505
|
+
);
|
|
506
|
+
structuredCloningFixed.splice(
|
|
507
|
+
// Add after userObjects
|
|
508
|
+
1,
|
|
509
|
+
0,
|
|
510
|
+
noneditable
|
|
511
|
+
);
|
|
512
|
+
const typeson = new Typeson({
|
|
513
|
+
encapsulateObserver: encapsulateObserver(stateObj)
|
|
514
|
+
}).register(structuredCloningFixed);
|
|
515
|
+
|
|
516
|
+
await typeson.encapsulateAsync(records, null, {
|
|
517
|
+
throwOnBadSyncType: false
|
|
527
518
|
});
|
|
519
|
+
|
|
520
|
+
if (stateObj.error) {
|
|
521
|
+
throw stateObj.error;
|
|
522
|
+
}
|
|
523
|
+
return (/** @type {Required<import('../types.js').StateObject>} */ (
|
|
524
|
+
stateObj
|
|
525
|
+
));
|
|
528
526
|
},
|
|
529
527
|
getTypesAndSchemasForState (types, state) {
|
|
530
528
|
if (state && types.getContextInfo('structuredCloning', state)) {
|