rust-fetch 0.3.1 → 0.3.2

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.
Files changed (3) hide show
  1. package/client.ts +1 -1
  2. package/package.json +1 -1
  3. package/server.ts +9 -25
package/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import initWasm from 'wasm-module';
1
+ import initWasm from 'wasm-module/pkg/wasm_module';
2
2
 
3
3
  const wasmPromise = initWasm();
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-fetch",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/server.ts CHANGED
@@ -1,29 +1,13 @@
1
- // import init, { greet, add, fetch_wasm_map, fetch_wasm_json } from './wasm-module/pkg/wasm_module';
2
-
3
1
  import * as path from 'path';
4
- import { readFile } from 'fs/promises';
5
- import initWasm, { fetch_wasm_json, InitOutput } from 'wasm-module';
6
- const wasmPath = path.join(process.cwd(), 'node_modules', '@asemqaffaf/rust-fetch', 'wasm-module', 'pkg', 'wasm_module_bg.wasm');
7
-
8
- let initialized = false;
9
- let initPromise: InitOutput | unknown = null;
10
- export async function initializeWasm() {
11
- const wasmBuffer = await readFile(wasmPath);
12
- return await initWasm(wasmBuffer);
13
- }
2
+ import { readFileSync } from 'fs';
14
3
 
15
- async function ensureInitialized() {
16
- if (!initialized) {
17
- if (!initPromise) {
18
- initPromise = initializeWasm();
19
- }
20
- await initPromise;
21
- initialized = true;
22
- }
23
- }
24
- (async () => {
25
- await ensureInitialized();
26
- })();
4
+ import initWasm from 'wasm-module';
5
+ const wasmPath = path.join(process.cwd(), 'node_modules', '@asemqaffaf/rust-fetch', 'wasm-module', 'pkg', 'wasm_module_bg.wasm');
6
+ export const wasmBuffer = readFileSync(wasmPath);
27
7
 
28
- export default initializeWasm;
8
+ export default initWasm;
29
9
  export * from 'wasm-module';
10
+
11
+ (async ()=>{
12
+ await initWasm(wasmBuffer);
13
+ })()