-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
275 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
*/ | ||
export function greet(): void; | ||
/** | ||
* @param {string} name | ||
*/ | ||
export function greet2(name: string): void; | ||
/** | ||
* @param {number} a | ||
* @param {number} b | ||
* @returns {number} | ||
*/ | ||
export function minus(a: number, b: number): number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { __wbg_set_wasm } from './index_bg.js'; | ||
import * as wasm from './index_bg.wasm'; | ||
__wbg_set_wasm(wasm); | ||
export * from './index_bg.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
let wasm; | ||
export function __wbg_set_wasm(val) { | ||
wasm = val; | ||
} | ||
|
||
const lTextDecoder = | ||
typeof TextDecoder === 'undefined' | ||
? (0, module.require)('util').TextDecoder | ||
: TextDecoder; | ||
|
||
let cachedTextDecoder = new lTextDecoder('utf-8', { | ||
ignoreBOM: true, | ||
fatal: true, | ||
}); | ||
|
||
cachedTextDecoder.decode(); | ||
|
||
let cachedUint8ArrayMemory0 = null; | ||
|
||
function getUint8ArrayMemory0() { | ||
if ( | ||
cachedUint8ArrayMemory0 === null || | ||
cachedUint8ArrayMemory0.byteLength === 0 | ||
) { | ||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachedUint8ArrayMemory0; | ||
} | ||
|
||
function getStringFromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode( | ||
getUint8ArrayMemory0().subarray(ptr, ptr + len), | ||
); | ||
} | ||
/** | ||
*/ | ||
export function greet() { | ||
wasm.greet(); | ||
} | ||
|
||
let WASM_VECTOR_LEN = 0; | ||
|
||
const lTextEncoder = | ||
typeof TextEncoder === 'undefined' | ||
? (0, module.require)('util').TextEncoder | ||
: TextEncoder; | ||
|
||
let cachedTextEncoder = new lTextEncoder('utf-8'); | ||
|
||
const encodeString = | ||
typeof cachedTextEncoder.encodeInto === 'function' | ||
? function (arg, view) { | ||
return cachedTextEncoder.encodeInto(arg, view); | ||
} | ||
: function (arg, view) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
view.set(buf); | ||
return { | ||
read: arg.length, | ||
written: buf.length, | ||
}; | ||
}; | ||
|
||
function passStringToWasm0(arg, malloc, realloc) { | ||
if (realloc === undefined) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
const ptr = malloc(buf.length, 1) >>> 0; | ||
getUint8ArrayMemory0() | ||
.subarray(ptr, ptr + buf.length) | ||
.set(buf); | ||
WASM_VECTOR_LEN = buf.length; | ||
return ptr; | ||
} | ||
|
||
let len = arg.length; | ||
let ptr = malloc(len, 1) >>> 0; | ||
|
||
const mem = getUint8ArrayMemory0(); | ||
|
||
let offset = 0; | ||
|
||
for (; offset < len; offset++) { | ||
const code = arg.charCodeAt(offset); | ||
if (code > 0x7f) break; | ||
mem[ptr + offset] = code; | ||
} | ||
|
||
if (offset !== len) { | ||
if (offset !== 0) { | ||
arg = arg.slice(offset); | ||
} | ||
ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0; | ||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); | ||
const ret = encodeString(arg, view); | ||
|
||
offset += ret.written; | ||
ptr = realloc(ptr, len, offset, 1) >>> 0; | ||
} | ||
|
||
WASM_VECTOR_LEN = offset; | ||
return ptr; | ||
} | ||
/** | ||
* @param {string} name | ||
*/ | ||
export function greet2(name) { | ||
const ptr0 = passStringToWasm0( | ||
name, | ||
wasm.__wbindgen_malloc, | ||
wasm.__wbindgen_realloc, | ||
); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.greet2(ptr0, len0); | ||
} | ||
|
||
/** | ||
* @param {number} a | ||
* @param {number} b | ||
* @returns {number} | ||
*/ | ||
export function minus(a, b) { | ||
const ret = wasm.minus(a, b); | ||
return ret; | ||
} | ||
|
||
export function __wbg_alert_f837f172b2a24942(arg0, arg1) { | ||
alert(getStringFromWasm0(arg0, arg1)); | ||
} | ||
|
||
export function __wbg_prompt_ec584a06a1c7c28b(arg0, arg1) { | ||
prompt(getStringFromWasm0(arg0, arg1)); | ||
} |
Binary file not shown.
13 changes: 13 additions & 0 deletions
13
examples/import-resources/minus-wasm-pack/index_bg.wasm.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function greet2(a: number, b: number): void; | ||
export function minus(a: number, b: number): number; | ||
export function greet(): void; | ||
export function __wbindgen_malloc(a: number, b: number): number; | ||
export function __wbindgen_realloc( | ||
a: number, | ||
b: number, | ||
c: number, | ||
d: number, | ||
): number; |