@scalable-vector-audio/sva-wasm 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/package.json CHANGED
@@ -2,16 +2,17 @@
2
2
  "name": "@scalable-vector-audio/sva-wasm",
3
3
  "type": "module",
4
4
  "description": "JS bindings: a composition a page fills node by node, rendered in the browser",
5
- "version": "0.8.0",
5
+ "version": "0.9.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/fredrikolis/scalable-vector-audio"
10
10
  },
11
11
  "files": [
12
- "sva_wasm_bg.wasm",
12
+ "snippets",
13
+ "sva_wasm.d.ts",
13
14
  "sva_wasm.js",
14
- "sva_wasm.d.ts"
15
+ "sva_wasm_bg.wasm"
15
16
  ],
16
17
  "main": "sva_wasm.js",
17
18
  "types": "sva_wasm.d.ts",
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright 2022 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+
14
+ // This file is kept similar to workerHelpers.js, but intended to be used in
15
+ // a bundlerless ES module environment (which has a few differences).
16
+
17
+ function waitForMsgType(target, type) {
18
+ return new Promise(resolve => {
19
+ target.addEventListener('message', function onMsg({ data }) {
20
+ if (data == null || data.type !== type) return;
21
+ target.removeEventListener('message', onMsg);
22
+ resolve(data);
23
+ });
24
+ });
25
+ }
26
+
27
+ // We need to wait for a specific message because this file is used both
28
+ // as a Worker and as a regular script, so it might receive unrelated
29
+ // messages on the page.
30
+ waitForMsgType(self, 'wasm_bindgen_worker_init').then(async data => {
31
+ const pkg = await import(data.mainJS);
32
+ await pkg.default(data.module, data.memory);
33
+ postMessage({ type: 'wasm_bindgen_worker_ready' });
34
+ pkg.wbg_rayon_start_worker(data.receiver);
35
+ });
36
+
37
+ // Note: this is never used, but necessary to prevent a bug in Firefox
38
+ // (https://bugzilla.mozilla.org/show_bug.cgi?id=1702191) where it collects
39
+ // Web Workers that have a shared WebAssembly memory with the main thread,
40
+ // but are not explicitly rooted via a `Worker` instance.
41
+ //
42
+ // By storing them in a variable, we can keep `Worker` objects around and
43
+ // prevent them from getting GC-d.
44
+ let _workers;
45
+
46
+ export async function startWorkers(module, memory, builder) {
47
+ if (builder.numThreads() === 0) {
48
+ throw new Error(`num_threads must be > 0.`);
49
+ }
50
+
51
+ const workerInit = {
52
+ type: 'wasm_bindgen_worker_init',
53
+ module,
54
+ memory,
55
+ receiver: builder.receiver(),
56
+ mainJS: builder.mainJS()
57
+ };
58
+
59
+ _workers = await Promise.all(
60
+ Array.from({ length: builder.numThreads() }, async () => {
61
+ // Self-spawn into a new Worker.
62
+ // The script is fetched as a blob so it works even if this script is
63
+ // hosted remotely (e.g. on a CDN). This avoids a cross-origin
64
+ // security error.
65
+ let scriptBlob = await fetch(import.meta.url).then(r => r.blob());
66
+ let url = URL.createObjectURL(scriptBlob);
67
+ const worker = new Worker(url, {
68
+ type: 'module'
69
+ });
70
+ worker.postMessage(workerInit);
71
+ await waitForMsgType(worker, 'wasm_bindgen_worker_ready');
72
+ URL.revokeObjectURL(url);
73
+ return worker;
74
+ })
75
+ );
76
+ builder.build();
77
+ }
package/sva_wasm.js CHANGED
@@ -560,7 +560,7 @@ function __wbg_get_imports(memory) {
560
560
  __wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
561
561
  arg0._wbg_cb_unref();
562
562
  },
563
- __wbg_arrayBuffer_8faea0dbff7bb078: function(arg0) {
563
+ __wbg_arrayBuffer_7695008a87569437: function(arg0) {
564
564
  const ret = arg0.arrayBuffer();
565
565
  return ret;
566
566
  },
@@ -580,10 +580,10 @@ function __wbg_get_imports(memory) {
580
580
  const ret = arg0.call(arg1, arg2);
581
581
  return ret;
582
582
  }, arguments); },
583
- __wbg_close_8e10f2694206c474: function(arg0) {
583
+ __wbg_close_3dd82b4c2057980f: function(arg0) {
584
584
  arg0.close();
585
585
  },
586
- __wbg_close_b4b133c61df00de8: function(arg0) {
586
+ __wbg_close_edc04fccc2bbdd46: function(arg0) {
587
587
  const ret = arg0.close();
588
588
  return ret;
589
589
  },
@@ -591,7 +591,7 @@ function __wbg_get_imports(memory) {
591
591
  const ret = Composition.__wrap(arg0);
592
592
  return ret;
593
593
  },
594
- __wbg_createWritable_06a4ac8a6ad39d55: function(arg0) {
594
+ __wbg_createWritable_715d11eae7f67b00: function(arg0) {
595
595
  const ret = arg0.createWritable();
596
596
  return ret;
597
597
  },
@@ -607,15 +607,15 @@ function __wbg_get_imports(memory) {
607
607
  const ret = Array.from(arg0);
608
608
  return ret;
609
609
  },
610
- __wbg_getDirectoryHandle_f316eb4e78c1ba4e: function(arg0, arg1, arg2, arg3) {
610
+ __wbg_getDirectoryHandle_869fbff4341b6f05: function(arg0, arg1, arg2, arg3) {
611
611
  const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
612
612
  return ret;
613
613
  },
614
- __wbg_getFileHandle_d3e853faba50cba0: function(arg0, arg1, arg2, arg3) {
614
+ __wbg_getFileHandle_f60394744d0f7ddf: function(arg0, arg1, arg2, arg3) {
615
615
  const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
616
616
  return ret;
617
617
  },
618
- __wbg_getFile_52182ea6c5e88f87: function(arg0) {
618
+ __wbg_getFile_42bddf489ab472d3: function(arg0) {
619
619
  const ret = arg0.getFile();
620
620
  return ret;
621
621
  },
@@ -659,7 +659,7 @@ function __wbg_get_imports(memory) {
659
659
  const ret = Array.isArray(arg0);
660
660
  return ret;
661
661
  },
662
- __wbg_keys_23502eb604e5f53f: function(arg0) {
662
+ __wbg_keys_5b4e733e29341069: function(arg0) {
663
663
  const ret = arg0.keys();
664
664
  return ret;
665
665
  },
@@ -675,11 +675,11 @@ function __wbg_get_imports(memory) {
675
675
  const ret = arg0.length;
676
676
  return ret;
677
677
  },
678
- __wbg_move_e8608e3c89e69c32: function(arg0, arg1, arg2, arg3) {
678
+ __wbg_move_6fdd0e877771c37a: function(arg0, arg1, arg2, arg3) {
679
679
  const ret = arg0.move(arg1, getStringFromWasm0(arg2, arg3));
680
680
  return ret;
681
681
  },
682
- __wbg_name_a2e8a8b265d5f9da: function(arg0, arg1) {
682
+ __wbg_name_7311158ca8140916: function(arg0, arg1) {
683
683
  const ret = arg1.name;
684
684
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
685
685
  const len1 = WASM_VECTOR_LEN;
@@ -694,6 +694,10 @@ function __wbg_get_imports(memory) {
694
694
  const ret = new Uint8Array(arg0);
695
695
  return ret;
696
696
  },
697
+ __wbg_new_738833e212f3e14d: function(arg0, arg1) {
698
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
699
+ return ret;
700
+ },
697
701
  __wbg_new_8f72ed7c652bf5a2: function(arg0, arg1) {
698
702
  try {
699
703
  var state0 = {a: arg0, b: arg1};
@@ -712,7 +716,7 @@ function __wbg_get_imports(memory) {
712
716
  state0.a = 0;
713
717
  }
714
718
  },
715
- __wbg_new_9f469be988f2ab2f: function() {
719
+ __wbg_new_b396b0480eb64f4f: function() {
716
720
  const ret = new MessageChannel();
717
721
  return ret;
718
722
  },
@@ -720,10 +724,6 @@ function __wbg_get_imports(memory) {
720
724
  const ret = new Object();
721
725
  return ret;
722
726
  },
723
- __wbg_new_ca25d2793a1a90e7: function(arg0, arg1) {
724
- const ret = new Error(getStringFromWasm0(arg0, arg1));
725
- return ret;
726
- },
727
727
  __wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
728
728
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
729
729
  return ret;
@@ -750,7 +750,7 @@ function __wbg_get_imports(memory) {
750
750
  const ret = new Worker(getStringFromWasm0(arg0, arg1));
751
751
  return ret;
752
752
  },
753
- __wbg_next_d4e18c69b9e1a65a: function(arg0) {
753
+ __wbg_next_eb57e40dfdcbec13: function(arg0) {
754
754
  const ret = arg0.next();
755
755
  return ret;
756
756
  },
@@ -758,19 +758,19 @@ function __wbg_get_imports(memory) {
758
758
  const ret = Array.of(arg0, arg1, arg2);
759
759
  return ret;
760
760
  },
761
- __wbg_parse_5da5b32f60321c75: function() { return handleError(function (arg0, arg1) {
761
+ __wbg_parse_ba292068b2893df4: function() { return handleError(function (arg0, arg1) {
762
762
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
763
763
  return ret;
764
764
  }, arguments); },
765
- __wbg_port1_d94f4557c07e4483: function(arg0) {
765
+ __wbg_port1_3892b7c53935a3a8: function(arg0) {
766
766
  const ret = arg0.port1;
767
767
  return ret;
768
768
  },
769
- __wbg_port2_56b630ec151ccaa1: function(arg0) {
769
+ __wbg_port2_0d7877ee85d5ce30: function(arg0) {
770
770
  const ret = arg0.port2;
771
771
  return ret;
772
772
  },
773
- __wbg_postMessage_32603db9cc3eea6c: function(arg0, arg1) {
773
+ __wbg_postMessage_658630782156a656: function(arg0, arg1) {
774
774
  arg0.postMessage(arg1);
775
775
  },
776
776
  __wbg_postMessage_8105a302ed002474: function() { return handleError(function (arg0, arg1) {
@@ -779,7 +779,7 @@ function __wbg_get_imports(memory) {
779
779
  __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
780
780
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
781
781
  },
782
- __wbg_query_2dc51b9bb1dd4e0d: function(arg0) {
782
+ __wbg_query_55fe98a95bf6dc27: function(arg0) {
783
783
  const ret = arg0.query();
784
784
  return ret;
785
785
  },
@@ -794,11 +794,11 @@ function __wbg_get_imports(memory) {
794
794
  const ret = Math.random();
795
795
  return ret;
796
796
  },
797
- __wbg_removeEntry_9fe63a7d9f052123: function(arg0, arg1, arg2) {
797
+ __wbg_removeEntry_076a427f76ab9ac6: function(arg0, arg1, arg2) {
798
798
  const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
799
799
  return ret;
800
800
  },
801
- __wbg_removeEntry_d3907d9c1838ed18: function(arg0, arg1, arg2, arg3) {
801
+ __wbg_removeEntry_52d29c84252df17a: function(arg0, arg1, arg2, arg3) {
802
802
  const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2), arg3);
803
803
  return ret;
804
804
  },
@@ -806,7 +806,7 @@ function __wbg_get_imports(memory) {
806
806
  const ret = Rendering.__wrap(arg0);
807
807
  return ret;
808
808
  },
809
- __wbg_request_f0117cc7ee6fd3ff: function(arg0, arg1, arg2, arg3) {
809
+ __wbg_request_77c726ad6dd59472: function(arg0, arg1, arg2, arg3) {
810
810
  const ret = arg0.request(getStringFromWasm0(arg1, arg2), arg3);
811
811
  return ret;
812
812
  },
@@ -821,23 +821,23 @@ function __wbg_get_imports(memory) {
821
821
  __wbg_set_c41f8dbc07a2190f: function(arg0, arg1, arg2) {
822
822
  arg0.set(getArrayF32FromWasm0(arg1, arg2));
823
823
  },
824
- __wbg_set_name_2f395b00415c310d: function(arg0, arg1, arg2) {
824
+ __wbg_set_name_1e2ec9adecadba72: function(arg0, arg1, arg2) {
825
825
  arg0.name = getStringFromWasm0(arg1, arg2);
826
826
  },
827
- __wbg_set_onmessage_2244c2525c4e0c38: function(arg0, arg1) {
827
+ __wbg_set_onmessage_0d85f20d44187a8a: function(arg0, arg1) {
828
828
  arg0.onmessage = arg1;
829
829
  },
830
- __wbg_set_onmessage_633c12d200c93f64: function(arg0, arg1) {
830
+ __wbg_set_onmessage_2244c2525c4e0c38: function(arg0, arg1) {
831
831
  arg0.onmessage = arg1;
832
832
  },
833
- __wbg_set_refusal_5ef41dad296ff42f: function(arg0, arg1) {
833
+ __wbg_set_refusal_ad3bfb6bc23b5632: function(arg0, arg1) {
834
834
  arg0.refusal = arg1;
835
835
  },
836
- __wbg_size_c3f9e88615db1ce0: function(arg0) {
836
+ __wbg_size_378b0f44f35abec6: function(arg0) {
837
837
  const ret = arg0.size;
838
838
  return ret;
839
839
  },
840
- __wbg_slice_a38db62418bdd422: function(arg0, arg1, arg2) {
840
+ __wbg_slice_3af259aa681affc3: function(arg0, arg1, arg2) {
841
841
  const ret = arg0.slice(arg1, arg2);
842
842
  return ret;
843
843
  },
@@ -897,20 +897,20 @@ function __wbg_get_imports(memory) {
897
897
  const ret = Atomics.waitAsync;
898
898
  return ret;
899
899
  },
900
- __wbg_warn_c87a3e30736afa6f: function(arg0, arg1) {
900
+ __wbg_warn_8b60e39b9aad81bc: function(arg0, arg1) {
901
901
  console.warn(getStringFromWasm0(arg0, arg1));
902
902
  },
903
- __wbg_write_ce9895aed50f18b0: function(arg0, arg1) {
903
+ __wbg_write_bb6c6b15440c3a18: function(arg0, arg1) {
904
904
  const ret = arg0.write(arg1);
905
905
  return ret;
906
906
  },
907
907
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
908
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 780, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
908
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 812, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
909
909
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_c71329924e24104e___convert__closures_____invoke___wasm_bindgen_c71329924e24104e___JsValue__core_40942630fbe58d9f___result__Result_____wasm_bindgen_c71329924e24104e___JsError___true_);
910
910
  return ret;
911
911
  },
912
912
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
913
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 806, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
913
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 838, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
914
914
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_c71329924e24104e___convert__closures_____invoke___js_sys_34ad8f88ff72db9___futures__task__wait_async_polyfill__MessageEvent______true_);
915
915
  return ret;
916
916
  },
package/sva_wasm_bg.wasm CHANGED
Binary file