rust-fetch 0.1.0 → 0.2.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/client.ts +10 -0
- package/package.json +6 -3
- package/server.ts +15 -0
- package/tsconfig.json +3 -3
- package/index.ts +0 -1
package/client.ts
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-fetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"export": {
|
|
8
8
|
"fetch": "./wasm-module/pkg/wasm_module",
|
|
9
|
-
"
|
|
9
|
+
"server": "server.ts",
|
|
10
|
+
"client": "client.ts"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
13
|
"build": "cd wasm-module && tsc index.ts",
|
|
@@ -16,11 +17,13 @@
|
|
|
16
17
|
"author": "",
|
|
17
18
|
"license": "ISC",
|
|
18
19
|
"dependencies": {
|
|
20
|
+
"path": "^0.12.7",
|
|
19
21
|
"wasm-module": "file:wasm-module/pkg"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.13.5",
|
|
22
25
|
"typescript": "^5.7.3"
|
|
23
26
|
},
|
|
24
27
|
"main": "index.js",
|
|
25
28
|
"description": ""
|
|
26
|
-
}
|
|
29
|
+
}
|
package/server.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// import init, { greet, add, fetch_wasm_map, fetch_wasm_json } from './wasm-module/pkg/wasm_module';
|
|
2
|
+
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { readFile } from 'fs/promises';
|
|
5
|
+
import initWasm from 'wasm-module';
|
|
6
|
+
|
|
7
|
+
const wasmPath = path.join(process.cwd(), 'node_modules', '@asemqaffaf/rust-fetch', 'wasm-module', 'pkg', 'wasm_module_bg.wasm');
|
|
8
|
+
|
|
9
|
+
export async function initializeWasm() {
|
|
10
|
+
const wasmBuffer = await readFile(wasmPath);
|
|
11
|
+
return await initWasm(wasmBuffer);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default initializeWasm;
|
|
15
|
+
export * from 'wasm-module';
|
package/tsconfig.json
CHANGED
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
26
|
|
|
27
27
|
/* Modules */
|
|
28
|
-
"module": "
|
|
28
|
+
"module": "NodeNext", /* Specify what module code is generated. */
|
|
29
29
|
"rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
-
|
|
30
|
+
"moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
31
|
"baseUrl": ".", /* Specify the base directory to resolve non-relative module names. */
|
|
32
32
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
33
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
34
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
|
|
35
|
+
"types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
36
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
37
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
38
|
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './wasm-module/pkg/wasm_module'
|