@flowscripter/template-bun-wasm-rust-library 1.2.2 → 1.3.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/README.md +6 -3
- package/dist/dist/index.d.ts +2 -0
- package/dist/dist/index.d.ts.map +1 -0
- package/dist/flowscripter_template_bun_wasm_rust_library_bg-rbwp754y.wasm +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +101 -0
- package/dist/pkg/flowscripter_template_bun_wasm_rust_library.d.ts +21 -0
- package/dist/pkg/flowscripter_template_bun_wasm_rust_library.d.ts.map +1 -0
- package/dist/src/lib.d.ts +5 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/package.json +15 -2
- package/pkg/flowscripter_template_bun_wasm_rust_library_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -38,10 +38,13 @@ Install dependencies:
|
|
|
38
38
|
|
|
39
39
|
`bun install`
|
|
40
40
|
|
|
41
|
-
Build (
|
|
42
|
-
repository):
|
|
41
|
+
Build WASM/JS/types (produces `dist/` for Node.js and TypeScript consumers; Bun uses raw source directly):
|
|
43
42
|
|
|
44
|
-
`
|
|
43
|
+
`bun run build`
|
|
44
|
+
|
|
45
|
+
Build JS/types (produces `dist/` for Node.js and TypeScript consumers; Bun uses raw source directly):
|
|
46
|
+
|
|
47
|
+
`bun run build`
|
|
45
48
|
|
|
46
49
|
Test:
|
|
47
50
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":"AA8FA,uCAGC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// pkg/flowscripter_template_bun_wasm_rust_library.js
|
|
3
|
+
function add(a, b) {
|
|
4
|
+
const ret = wasm.add(a, b);
|
|
5
|
+
return ret;
|
|
6
|
+
}
|
|
7
|
+
function __wbg_get_imports() {
|
|
8
|
+
const import0 = {
|
|
9
|
+
__proto__: null,
|
|
10
|
+
__wbindgen_init_externref_table: function() {
|
|
11
|
+
const table = wasm.__wbindgen_externrefs;
|
|
12
|
+
const offset = table.grow(4);
|
|
13
|
+
table.set(0, undefined);
|
|
14
|
+
table.set(offset + 0, undefined);
|
|
15
|
+
table.set(offset + 1, null);
|
|
16
|
+
table.set(offset + 2, true);
|
|
17
|
+
table.set(offset + 3, false);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
__proto__: null,
|
|
22
|
+
"./flowscripter_template_bun_wasm_rust_library_bg.js": import0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var wasmModule;
|
|
26
|
+
var wasmInstance;
|
|
27
|
+
var wasm;
|
|
28
|
+
function __wbg_finalize_init(instance, module) {
|
|
29
|
+
wasmInstance = instance;
|
|
30
|
+
wasm = instance.exports;
|
|
31
|
+
wasmModule = module;
|
|
32
|
+
wasm.__wbindgen_start();
|
|
33
|
+
return wasm;
|
|
34
|
+
}
|
|
35
|
+
async function __wbg_load(module, imports) {
|
|
36
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
37
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
38
|
+
try {
|
|
39
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
42
|
+
if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
|
|
43
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
44
|
+
} else {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const bytes = await module.arrayBuffer();
|
|
50
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
51
|
+
} else {
|
|
52
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
53
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
54
|
+
return { instance, module };
|
|
55
|
+
} else {
|
|
56
|
+
return instance;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function expectedResponseType(type) {
|
|
60
|
+
switch (type) {
|
|
61
|
+
case "basic":
|
|
62
|
+
case "cors":
|
|
63
|
+
case "default":
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function __wbg_init(module_or_path) {
|
|
70
|
+
if (wasm !== undefined)
|
|
71
|
+
return wasm;
|
|
72
|
+
if (module_or_path !== undefined) {
|
|
73
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
74
|
+
({ module_or_path } = module_or_path);
|
|
75
|
+
} else {
|
|
76
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (module_or_path === undefined) {
|
|
80
|
+
module_or_path = new URL("flowscripter_template_bun_wasm_rust_library_bg.wasm", import.meta.url);
|
|
81
|
+
}
|
|
82
|
+
const imports = __wbg_get_imports();
|
|
83
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
84
|
+
module_or_path = fetch(module_or_path);
|
|
85
|
+
}
|
|
86
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
87
|
+
return __wbg_finalize_init(instance, module);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// pkg/flowscripter_template_bun_wasm_rust_library_bg.wasm
|
|
91
|
+
var flowscripter_template_bun_wasm_rust_library_bg_default = "./flowscripter_template_bun_wasm_rust_library_bg-rbwp754y.wasm";
|
|
92
|
+
|
|
93
|
+
// src/lib.ts
|
|
94
|
+
var wasmBuffer = typeof Bun !== "undefined" ? await Bun.file(flowscripter_template_bun_wasm_rust_library_bg_default).arrayBuffer() : await fetch(flowscripter_template_bun_wasm_rust_library_bg_default).then((response) => response.arrayBuffer());
|
|
95
|
+
async function world() {
|
|
96
|
+
await __wbg_init({ module_or_path: wasmBuffer });
|
|
97
|
+
console.info(`World ${add(3, 3)}`);
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
world
|
|
101
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds two numbers together.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* # Examples
|
|
6
|
+
* ```
|
|
7
|
+
* let arg1 = 3;
|
|
8
|
+
* let arg2 = 3;
|
|
9
|
+
* let answer = flowscripter_template_bun_wasm_rust_library::add(arg1, arg2);
|
|
10
|
+
*
|
|
11
|
+
* assert_eq!(6, answer);
|
|
12
|
+
* ```
|
|
13
|
+
* @param {number} a
|
|
14
|
+
* @param {number} b
|
|
15
|
+
* @returns {number}
|
|
16
|
+
*/
|
|
17
|
+
export function add(a: number, b: number): number;
|
|
18
|
+
export function initSync(module: any): any;
|
|
19
|
+
declare function __wbg_init(module_or_path: any): Promise<any>;
|
|
20
|
+
export { __wbg_init as default };
|
|
21
|
+
//# sourceMappingURL=flowscripter_template_bun_wasm_rust_library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowscripter_template_bun_wasm_rust_library.d.ts","sourceRoot":"","sources":["../../pkg/flowscripter_template_bun_wasm_rust_library.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,uBAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAKlB;AAgED,2CAkBC;AAED,+DAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAM3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/template-bun-wasm-rust-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Project template for a Rust library compiled to WASM exposed as a Bun module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"url": "git+https://github.com/flowscripter/template-bun-wasm-rust-library.git"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
+
"dist",
|
|
20
21
|
"src/**/*",
|
|
21
22
|
"pkg/**/*",
|
|
22
23
|
"index.ts",
|
|
@@ -24,10 +25,22 @@
|
|
|
24
25
|
"LICENSE"
|
|
25
26
|
],
|
|
26
27
|
"type": "module",
|
|
27
|
-
"
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"module": "dist/index.js",
|
|
30
|
+
"types": "dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"bun": "./index.ts",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
28
38
|
"publishConfig": {
|
|
29
39
|
"access": "public"
|
|
30
40
|
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "wasm-pack build --target web --release --no-pack && rm pkg/.gitignore && bun build index.ts --outdir dist --target bun && tsc -p tsconfig.build.json"
|
|
43
|
+
},
|
|
31
44
|
"devDependencies": {
|
|
32
45
|
"@types/bun": "^1.3.14",
|
|
33
46
|
"oxfmt": "0.54.0",
|
|
Binary file
|