@flowscripter/template-bun-wasm-rust-library 1.0.4 → 1.0.5
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 +3 -2
- package/package.json +1 -1
- package/pkg/flowscripter_template_bun_wasm_rust_library.d.ts +46 -0
- package/pkg/flowscripter_template_bun_wasm_rust_library.js +139 -0
- package/pkg/flowscripter_template_bun_wasm_rust_library_bg.wasm +0 -0
- package/pkg/flowscripter_template_bun_wasm_rust_library_bg.wasm.d.ts +6 -0
package/README.md
CHANGED
|
@@ -38,9 +38,10 @@ Install dependencies:
|
|
|
38
38
|
|
|
39
39
|
`bun install`
|
|
40
40
|
|
|
41
|
-
Build
|
|
41
|
+
Build (remove generated `.gitignore` to allow npm publish from root of
|
|
42
|
+
repository):
|
|
42
43
|
|
|
43
|
-
`wasm-pack build --target web --no-pack`
|
|
44
|
+
`wasm-pack build --target web --no-pack && rm pkg/.gitignore`
|
|
44
45
|
|
|
45
46
|
Test:
|
|
46
47
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Adds two numbers together.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* # Examples
|
|
8
|
+
* ```
|
|
9
|
+
* let arg1 = 3;
|
|
10
|
+
* let arg2 = 3;
|
|
11
|
+
* let answer = flowscripter_template_bun_wasm_rust_library::add(arg1, arg2);
|
|
12
|
+
*
|
|
13
|
+
* assert_eq!(6, answer);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function add(a: number, b: number): number;
|
|
17
|
+
|
|
18
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
19
|
+
|
|
20
|
+
export interface InitOutput {
|
|
21
|
+
readonly memory: WebAssembly.Memory;
|
|
22
|
+
readonly add: (a: number, b: number) => number;
|
|
23
|
+
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
24
|
+
readonly __wbindgen_start: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
28
|
+
/**
|
|
29
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
30
|
+
* a precompiled `WebAssembly.Module`.
|
|
31
|
+
*
|
|
32
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
33
|
+
*
|
|
34
|
+
* @returns {InitOutput}
|
|
35
|
+
*/
|
|
36
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
40
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
41
|
+
*
|
|
42
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Promise<InitOutput>}
|
|
45
|
+
*/
|
|
46
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds two numbers together.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* # Examples
|
|
8
|
+
* ```
|
|
9
|
+
* let arg1 = 3;
|
|
10
|
+
* let arg2 = 3;
|
|
11
|
+
* let answer = flowscripter_template_bun_wasm_rust_library::add(arg1, arg2);
|
|
12
|
+
*
|
|
13
|
+
* assert_eq!(6, answer);
|
|
14
|
+
* ```
|
|
15
|
+
* @param {number} a
|
|
16
|
+
* @param {number} b
|
|
17
|
+
* @returns {number}
|
|
18
|
+
*/
|
|
19
|
+
export function add(a, b) {
|
|
20
|
+
const ret = wasm.add(a, b);
|
|
21
|
+
return ret;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function __wbg_load(module, imports) {
|
|
25
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
26
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
27
|
+
try {
|
|
28
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
29
|
+
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
32
|
+
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);
|
|
33
|
+
|
|
34
|
+
} else {
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const bytes = await module.arrayBuffer();
|
|
41
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
42
|
+
|
|
43
|
+
} else {
|
|
44
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
45
|
+
|
|
46
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
47
|
+
return { instance, module };
|
|
48
|
+
|
|
49
|
+
} else {
|
|
50
|
+
return instance;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function __wbg_get_imports() {
|
|
56
|
+
const imports = {};
|
|
57
|
+
imports.wbg = {};
|
|
58
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
59
|
+
const table = wasm.__wbindgen_export_0;
|
|
60
|
+
const offset = table.grow(4);
|
|
61
|
+
table.set(0, undefined);
|
|
62
|
+
table.set(offset + 0, undefined);
|
|
63
|
+
table.set(offset + 1, null);
|
|
64
|
+
table.set(offset + 2, true);
|
|
65
|
+
table.set(offset + 3, false);
|
|
66
|
+
;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return imports;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function __wbg_init_memory(imports, memory) {
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function __wbg_finalize_init(instance, module) {
|
|
77
|
+
wasm = instance.exports;
|
|
78
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
wasm.__wbindgen_start();
|
|
82
|
+
return wasm;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function initSync(module) {
|
|
86
|
+
if (wasm !== undefined) return wasm;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if (typeof module !== 'undefined') {
|
|
90
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
91
|
+
({module} = module)
|
|
92
|
+
} else {
|
|
93
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const imports = __wbg_get_imports();
|
|
98
|
+
|
|
99
|
+
__wbg_init_memory(imports);
|
|
100
|
+
|
|
101
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
102
|
+
module = new WebAssembly.Module(module);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
106
|
+
|
|
107
|
+
return __wbg_finalize_init(instance, module);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function __wbg_init(module_or_path) {
|
|
111
|
+
if (wasm !== undefined) return wasm;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if (typeof module_or_path !== 'undefined') {
|
|
115
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
116
|
+
({module_or_path} = module_or_path)
|
|
117
|
+
} else {
|
|
118
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof module_or_path === 'undefined') {
|
|
123
|
+
module_or_path = new URL('flowscripter_template_bun_wasm_rust_library_bg.wasm', import.meta.url);
|
|
124
|
+
}
|
|
125
|
+
const imports = __wbg_get_imports();
|
|
126
|
+
|
|
127
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
128
|
+
module_or_path = fetch(module_or_path);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
__wbg_init_memory(imports);
|
|
132
|
+
|
|
133
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
134
|
+
|
|
135
|
+
return __wbg_finalize_init(instance, module);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { initSync };
|
|
139
|
+
export default __wbg_init;
|
|
Binary file
|