@es-joy/jsoe 0.21.0 → 0.22.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.22.0
4
+
5
+ - feat: async encapsulation
6
+
3
7
  ## 0.21.0
4
8
 
5
9
  - feat: use sourcemaps
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 99.85%</text><text class="high" x="5" y="14">Statements 99.85%</text><text class="shadow" x="125.5" y="15">Branches 98.12%</text><text class="high" x="125" y="14">Branches 98.12%</text><text class="shadow" x="234.5" y="15">Lines 99.84%</text><text class="high" x="234" y="14">Lines 99.84%</text><text class="shadow" x="321.5" y="15">Functions 99.87%</text><text class="high" x="321" y="14">Functions 99.87%</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 99.84%</text><text class="high" x="5" y="14">Statements 99.84%</text><text class="shadow" x="125.5" y="15">Branches 99.49%</text><text class="high" x="125" y="14">Branches 99.49%</text><text class="shadow" x="234.5" y="15">Lines 99.84%</text><text class="high" x="234" y="14">Lines 99.84%</text><text class="shadow" x="321.5" y="15">Functions 99.87%</text><text class="high" x="321" y="14">Functions 99.87%</text></g></svg>
@@ -1 +1 @@
1
- {"version":3,"file":"structuredCloning.d.ts","sourceRoot":"","sources":["../../src/formats/structuredCloning.js"],"names":[],"mappings":";;;;;oCAwBa,CAAC,IAAI,EAAE;IACnB,QAAY,EAAE,MAAM,CAAC;IACrB,IAAQ,EAAE,OAAO,aAAa,EAAE,aAAa,CAAC;IAC9C,KAAS,EAAE,OAAO,eAAe,EAAE,oBAAoB,CAAC;IACxD,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAiB,CAAC,EAAE,OAAO,sBAAsB,EAAE,WAAW,CAAC;IAC/D,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAa,CAAC,EAAE,MAAM,CAAA;CACnB,KAAK,WAAW,GAAC,IAAI;kCAIZ,OAAO,kBAAkB,EAAE,mBAAmB;AA+b3D,6CAA6C;AAC7C,iCADW,OAAO,eAAe,EAAE,MAAM,CA2IvC"}
1
+ {"version":3,"file":"structuredCloning.d.ts","sourceRoot":"","sources":["../../src/formats/structuredCloning.js"],"names":[],"mappings":";;;;;oCAwBa,CAAC,IAAI,EAAE;IACnB,QAAY,EAAE,MAAM,CAAC;IACrB,IAAQ,EAAE,OAAO,aAAa,EAAE,aAAa,CAAC;IAC9C,KAAS,EAAE,OAAO,eAAe,EAAE,oBAAoB,CAAC;IACxD,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAiB,CAAC,EAAE,OAAO,sBAAsB,EAAE,WAAW,CAAC;IAC/D,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAa,CAAC,EAAE,MAAM,CAAA;CACnB,KAAK,WAAW,GAAC,IAAI;kCAIZ,OAAO,kBAAkB,EAAE,mBAAmB;AA+b3D,6CAA6C;AAC7C,iCADW,OAAO,eAAe,EAAE,MAAM,CAyIvC"}
package/dist/index.js CHANGED
@@ -3672,47 +3672,45 @@ const canonicalTypeToAvailableTypeAndSchema = (
3672
3672
 
3673
3673
  /** @type {import('../formats.js').Format} */
3674
3674
  const structuredCloning = {
3675
- iterate (records, stateObj) {
3675
+ async iterate (records, stateObj) {
3676
3676
  /* istanbul ignore if -- Just a guard */
3677
3677
  if (!stateObj.format) {
3678
3678
  stateObj.format = 'structuredCloning';
3679
3679
  }
3680
- // Todo: Replace this with async typeson?
3681
- // eslint-disable-next-line promise/avoid-new -- Our own API for now
3682
- return new Promise((resolve, reject) => {
3683
- const structuredCloningFixed = ie.filter(
3684
- (typeSpecSet) => {
3685
- return ![
3686
- // Not yet supported within JSOE
3687
- 'imagedata',
3688
- 'imagebitmap',
3689
- 'cryptokey',
3690
- 'domquad'
3691
- ].some((prop) => {
3692
- return Object.hasOwn(typeSpecSet, prop);
3693
- });
3694
- }
3695
- );
3696
- structuredCloningFixed.splice(
3697
- // Add after userObjects
3698
- 1,
3699
- 0,
3700
- W
3701
- );
3702
- const typeson = new c({
3703
- encapsulateObserver: encapsulateObserver(stateObj)
3704
- }).register(structuredCloningFixed);
3705
- typeson.encapsulate(records);
3706
- // Todo (low): We might want to run async encapsulate for
3707
- // async types (and put this after Promise resolves)
3708
- if (stateObj.error) {
3709
- reject(stateObj.error);
3710
- } else {
3711
- resolve(/** @type {Required<import('../types.js').StateObject>} */ (
3712
- stateObj
3713
- ));
3680
+
3681
+ const structuredCloningFixed = ie.filter(
3682
+ (typeSpecSet) => {
3683
+ return ![
3684
+ // Not yet supported within JSOE
3685
+ 'imagedata',
3686
+ 'imagebitmap',
3687
+ 'cryptokey',
3688
+ 'domquad'
3689
+ ].some((prop) => {
3690
+ return Object.hasOwn(typeSpecSet, prop);
3691
+ });
3714
3692
  }
3693
+ );
3694
+ structuredCloningFixed.splice(
3695
+ // Add after userObjects
3696
+ 1,
3697
+ 0,
3698
+ W
3699
+ );
3700
+ const typeson = new c({
3701
+ encapsulateObserver: encapsulateObserver(stateObj)
3702
+ }).register(structuredCloningFixed);
3703
+
3704
+ await typeson.encapsulateAsync(records, null, {
3705
+ throwOnBadSyncType: false
3715
3706
  });
3707
+
3708
+ if (stateObj.error) {
3709
+ throw stateObj.error;
3710
+ }
3711
+ return (/** @type {Required<import('../types.js').StateObject>} */ (
3712
+ stateObj
3713
+ ));
3716
3714
  },
3717
3715
  getTypesAndSchemasForState (types, state) {
3718
3716
  if (state && types.getContextInfo('structuredCloning', state)) {