@c9up/atom 0.1.12 → 0.1.13
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/index.win32-x64-msvc.node +0 -0
- package/package.json +7 -7
- package/scripts/clean-wasm-pack-meta.mjs +32 -0
- package/scripts/copy-napi.mjs +11 -3
- package/scripts/verify-wasm.mjs +29 -1
- package/wasm/atom_engine_wasm.d.ts +60 -0
- package/wasm/atom_engine_wasm.js +416 -0
- package/wasm/atom_engine_wasm_bg.wasm +0 -0
- package/wasm/atom_engine_wasm_bg.wasm.d.ts +17 -0
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/atom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Atom — exact decimal arithmetic for the Ream ecosystem (TypeScript + Rust N-API)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"wasm"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@biomejs/biome": "^2.
|
|
30
|
-
"@types/node": "^22.
|
|
31
|
-
"@vitest/coverage-v8": "
|
|
32
|
-
"typescript": "^6.0.
|
|
33
|
-
"vitest": "
|
|
29
|
+
"@biomejs/biome": "^2.5.12",
|
|
30
|
+
"@types/node": "^22.20.1",
|
|
31
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"vitest": "4.1.11"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=22.0.0"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"test:rust": "cargo test -p atom-engine",
|
|
53
53
|
"test:napi": "node scripts/verify-napi.mjs",
|
|
54
54
|
"bench": "pnpm build && node scripts/bench.mjs",
|
|
55
|
-
"build:wasm": "wasm-pack build --target web crates/atom-engine-wasm --out-dir ../../wasm",
|
|
55
|
+
"build:wasm": "wasm-pack build --target web crates/atom-engine-wasm --out-dir ../../wasm && node scripts/clean-wasm-pack-meta.mjs",
|
|
56
56
|
"lint": "biome check src/ tests/",
|
|
57
57
|
"test:coverage": "vitest run --coverage"
|
|
58
58
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
2
|
+
import { dirname, join } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
// Removes the package metadata `wasm-pack` writes into its output directory.
|
|
6
|
+
//
|
|
7
|
+
// `wasm-pack build` treats its out-dir as a publishable package of its own and
|
|
8
|
+
// scaffolds one: a `package.json`, and a `.gitignore` whose entire content is
|
|
9
|
+
// `*`. Ours is not a package — it is a directory inside this one, listed in
|
|
10
|
+
// `files`.
|
|
11
|
+
//
|
|
12
|
+
// The `.gitignore` is the damaging half. npm honours a .gitignore nested INSIDE
|
|
13
|
+
// a published directory even when `files` lists that directory, so a single `*`
|
|
14
|
+
// silently strips every artifact from the tarball — the built .js and .wasm, and
|
|
15
|
+
// the committed .d.ts stub with them. The package then publishes green and every
|
|
16
|
+
// browser consumer gets the engine-missing error. Measured here: with the file
|
|
17
|
+
// present `npm pack --dry-run` reports zero wasm/ entries, without it, two.
|
|
18
|
+
//
|
|
19
|
+
// Runs right after wasm-pack, before anything packs.
|
|
20
|
+
|
|
21
|
+
const wasmDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'wasm')
|
|
22
|
+
|
|
23
|
+
// Only what wasm-pack scaffolds. The artifacts and the committed .d.ts stay.
|
|
24
|
+
const generated = ['.gitignore', 'package.json', 'README.md', 'LICENSE']
|
|
25
|
+
|
|
26
|
+
for (const name of generated) {
|
|
27
|
+
const path = join(wasmDir, name)
|
|
28
|
+
if (existsSync(path)) {
|
|
29
|
+
rmSync(path)
|
|
30
|
+
console.log(`[wasm] removed generated wasm/${name}`)
|
|
31
|
+
}
|
|
32
|
+
}
|
package/scripts/copy-napi.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { copyFileSync, existsSync } from 'node:fs'
|
|
2
|
-
import { dirname, join } from 'node:path'
|
|
2
|
+
import { dirname, join, resolve } from 'node:path'
|
|
3
3
|
import { arch, env, platform } from 'node:process'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
|
|
@@ -20,16 +20,24 @@ const hostSuffixMap = {
|
|
|
20
20
|
'darwin-x64': 'darwin-x64', 'darwin-arm64': 'darwin-arm64', 'win32-x64': 'win32-x64-msvc',
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// Cargo writes its artifacts under CARGO_TARGET_DIR when that is set — a
|
|
24
|
+
// shared cache, a CI mount — so they are not under this package's `target/` at
|
|
25
|
+
// all. A relative value is resolved against the directory cargo ran in, which
|
|
26
|
+
// is this package root.
|
|
27
|
+
const targetDir = env.CARGO_TARGET_DIR
|
|
28
|
+
? resolve(root, env.CARGO_TARGET_DIR)
|
|
29
|
+
: join(root, 'target')
|
|
30
|
+
|
|
23
31
|
const triple = env.CARGO_BUILD_TARGET ?? ''
|
|
24
32
|
let suffix, os, releaseDir
|
|
25
33
|
if (triple) {
|
|
26
34
|
const entry = tripleMap[triple]
|
|
27
35
|
if (!entry) throw new Error(`${TAG} unsupported CARGO_BUILD_TARGET: ${triple}`)
|
|
28
36
|
suffix = entry.suffix; os = entry.os
|
|
29
|
-
releaseDir = join(
|
|
37
|
+
releaseDir = join(targetDir, triple, 'release')
|
|
30
38
|
} else {
|
|
31
39
|
suffix = hostSuffixMap[`${platform}-${arch}`]; os = platform
|
|
32
|
-
releaseDir = join(
|
|
40
|
+
releaseDir = join(targetDir, 'release')
|
|
33
41
|
if (!suffix) throw new Error(`${TAG} unsupported platform/arch: ${platform}-${arch}`)
|
|
34
42
|
}
|
|
35
43
|
|
package/scripts/verify-wasm.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
1
2
|
import { existsSync, readFileSync, statSync } from 'node:fs'
|
|
2
3
|
import { dirname, join } from 'node:path'
|
|
3
4
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
@@ -53,4 +54,31 @@ if (wasm.cmp('1.20', '1.2') !== 0) {
|
|
|
53
54
|
throw new Error('[atom:wasm] cmp smoke test failed')
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
// Present on disk is NOT the same question as present in the package, and it is
|
|
58
|
+
// the weaker one. `wasm-pack` writes a `.gitignore` of `*` into its out-dir, and
|
|
59
|
+
// npm honours a .gitignore nested inside a published directory even when `files`
|
|
60
|
+
// lists that directory — so every check above, smoke tests included, can pass
|
|
61
|
+
// while the tarball ships nothing. That is exactly how 0.1.12 went out.
|
|
62
|
+
//
|
|
63
|
+
// So ask the packer. `--ignore-scripts` keeps this from re-entering
|
|
64
|
+
// prepublishOnly, which is what invoked us.
|
|
65
|
+
const packed = JSON.parse(
|
|
66
|
+
execFileSync('npm', ['pack', '--dry-run', '--json', '--ignore-scripts'], {
|
|
67
|
+
cwd: join(here, '..'),
|
|
68
|
+
encoding: 'utf-8',
|
|
69
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
70
|
+
}),
|
|
71
|
+
)[0]
|
|
72
|
+
|
|
73
|
+
const shipped = new Set(packed.files.map((f) => f.path))
|
|
74
|
+
for (const name of required) {
|
|
75
|
+
if (!shipped.has(`wasm/${name}`)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`[atom:wasm] wasm/${name} is on disk but NOT in the tarball — something is excluding it ` +
|
|
78
|
+
`(a .gitignore or .npmignore nested in wasm/ will do this even though "wasm" is in package.json files). ` +
|
|
79
|
+
`Run \`node scripts/clean-wasm-pack-meta.mjs\` after wasm-pack.`,
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(`[atom:wasm] browser artifacts present, functional, and in the tarball (${shipped.size} files)`)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function add(a: string, b: string): string;
|
|
5
|
+
|
|
6
|
+
export function cmp(a: string, b: string): number;
|
|
7
|
+
|
|
8
|
+
export function div(a: string, b: string, precision: number): string;
|
|
9
|
+
|
|
10
|
+
export function mul(a: string, b: string): string;
|
|
11
|
+
|
|
12
|
+
export function pow(a: string, exp: number, precision: number): string;
|
|
13
|
+
|
|
14
|
+
export function rem(a: string, b: string): string;
|
|
15
|
+
|
|
16
|
+
export function sqrt(a: string, precision: number): string;
|
|
17
|
+
|
|
18
|
+
export function sub(a: string, b: string): string;
|
|
19
|
+
|
|
20
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
21
|
+
|
|
22
|
+
export interface InitOutput {
|
|
23
|
+
readonly memory: WebAssembly.Memory;
|
|
24
|
+
readonly add: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
25
|
+
readonly cmp: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
26
|
+
readonly div: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
27
|
+
readonly mul: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
28
|
+
readonly pow: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
29
|
+
readonly rem: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
30
|
+
readonly sqrt: (a: number, b: number, c: number) => [number, number, number, number];
|
|
31
|
+
readonly sub: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
32
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
33
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
34
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
35
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
36
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
37
|
+
readonly __wbindgen_start: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
44
|
+
* a precompiled `WebAssembly.Module`.
|
|
45
|
+
*
|
|
46
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
47
|
+
*
|
|
48
|
+
* @returns {InitOutput}
|
|
49
|
+
*/
|
|
50
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
54
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
55
|
+
*
|
|
56
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Promise<InitOutput>}
|
|
59
|
+
*/
|
|
60
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/* @ts-self-types="./atom_engine_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} a
|
|
5
|
+
* @param {string} b
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function add(a, b) {
|
|
9
|
+
let deferred4_0;
|
|
10
|
+
let deferred4_1;
|
|
11
|
+
try {
|
|
12
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
15
|
+
const len1 = WASM_VECTOR_LEN;
|
|
16
|
+
const ret = wasm.add(ptr0, len0, ptr1, len1);
|
|
17
|
+
var ptr3 = ret[0];
|
|
18
|
+
var len3 = ret[1];
|
|
19
|
+
if (ret[3]) {
|
|
20
|
+
ptr3 = 0; len3 = 0;
|
|
21
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
22
|
+
}
|
|
23
|
+
deferred4_0 = ptr3;
|
|
24
|
+
deferred4_1 = len3;
|
|
25
|
+
return getStringFromWasm0(ptr3, len3);
|
|
26
|
+
} finally {
|
|
27
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} a
|
|
33
|
+
* @param {string} b
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
export function cmp(a, b) {
|
|
37
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
40
|
+
const len1 = WASM_VECTOR_LEN;
|
|
41
|
+
const ret = wasm.cmp(ptr0, len0, ptr1, len1);
|
|
42
|
+
if (ret[2]) {
|
|
43
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
44
|
+
}
|
|
45
|
+
return ret[0];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {string} a
|
|
50
|
+
* @param {string} b
|
|
51
|
+
* @param {number} precision
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function div(a, b, precision) {
|
|
55
|
+
let deferred4_0;
|
|
56
|
+
let deferred4_1;
|
|
57
|
+
try {
|
|
58
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
61
|
+
const len1 = WASM_VECTOR_LEN;
|
|
62
|
+
const ret = wasm.div(ptr0, len0, ptr1, len1, precision);
|
|
63
|
+
var ptr3 = ret[0];
|
|
64
|
+
var len3 = ret[1];
|
|
65
|
+
if (ret[3]) {
|
|
66
|
+
ptr3 = 0; len3 = 0;
|
|
67
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
68
|
+
}
|
|
69
|
+
deferred4_0 = ptr3;
|
|
70
|
+
deferred4_1 = len3;
|
|
71
|
+
return getStringFromWasm0(ptr3, len3);
|
|
72
|
+
} finally {
|
|
73
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {string} a
|
|
79
|
+
* @param {string} b
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
export function mul(a, b) {
|
|
83
|
+
let deferred4_0;
|
|
84
|
+
let deferred4_1;
|
|
85
|
+
try {
|
|
86
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
87
|
+
const len0 = WASM_VECTOR_LEN;
|
|
88
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
89
|
+
const len1 = WASM_VECTOR_LEN;
|
|
90
|
+
const ret = wasm.mul(ptr0, len0, ptr1, len1);
|
|
91
|
+
var ptr3 = ret[0];
|
|
92
|
+
var len3 = ret[1];
|
|
93
|
+
if (ret[3]) {
|
|
94
|
+
ptr3 = 0; len3 = 0;
|
|
95
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
96
|
+
}
|
|
97
|
+
deferred4_0 = ptr3;
|
|
98
|
+
deferred4_1 = len3;
|
|
99
|
+
return getStringFromWasm0(ptr3, len3);
|
|
100
|
+
} finally {
|
|
101
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} a
|
|
107
|
+
* @param {number} exp
|
|
108
|
+
* @param {number} precision
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
export function pow(a, exp, precision) {
|
|
112
|
+
let deferred3_0;
|
|
113
|
+
let deferred3_1;
|
|
114
|
+
try {
|
|
115
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ret = wasm.pow(ptr0, len0, exp, precision);
|
|
118
|
+
var ptr2 = ret[0];
|
|
119
|
+
var len2 = ret[1];
|
|
120
|
+
if (ret[3]) {
|
|
121
|
+
ptr2 = 0; len2 = 0;
|
|
122
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
123
|
+
}
|
|
124
|
+
deferred3_0 = ptr2;
|
|
125
|
+
deferred3_1 = len2;
|
|
126
|
+
return getStringFromWasm0(ptr2, len2);
|
|
127
|
+
} finally {
|
|
128
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {string} a
|
|
134
|
+
* @param {string} b
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
export function rem(a, b) {
|
|
138
|
+
let deferred4_0;
|
|
139
|
+
let deferred4_1;
|
|
140
|
+
try {
|
|
141
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
const len0 = WASM_VECTOR_LEN;
|
|
143
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
144
|
+
const len1 = WASM_VECTOR_LEN;
|
|
145
|
+
const ret = wasm.rem(ptr0, len0, ptr1, len1);
|
|
146
|
+
var ptr3 = ret[0];
|
|
147
|
+
var len3 = ret[1];
|
|
148
|
+
if (ret[3]) {
|
|
149
|
+
ptr3 = 0; len3 = 0;
|
|
150
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
151
|
+
}
|
|
152
|
+
deferred4_0 = ptr3;
|
|
153
|
+
deferred4_1 = len3;
|
|
154
|
+
return getStringFromWasm0(ptr3, len3);
|
|
155
|
+
} finally {
|
|
156
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} a
|
|
162
|
+
* @param {number} precision
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*/
|
|
165
|
+
export function sqrt(a, precision) {
|
|
166
|
+
let deferred3_0;
|
|
167
|
+
let deferred3_1;
|
|
168
|
+
try {
|
|
169
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
171
|
+
const ret = wasm.sqrt(ptr0, len0, precision);
|
|
172
|
+
var ptr2 = ret[0];
|
|
173
|
+
var len2 = ret[1];
|
|
174
|
+
if (ret[3]) {
|
|
175
|
+
ptr2 = 0; len2 = 0;
|
|
176
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
177
|
+
}
|
|
178
|
+
deferred3_0 = ptr2;
|
|
179
|
+
deferred3_1 = len2;
|
|
180
|
+
return getStringFromWasm0(ptr2, len2);
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @param {string} a
|
|
188
|
+
* @param {string} b
|
|
189
|
+
* @returns {string}
|
|
190
|
+
*/
|
|
191
|
+
export function sub(a, b) {
|
|
192
|
+
let deferred4_0;
|
|
193
|
+
let deferred4_1;
|
|
194
|
+
try {
|
|
195
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
196
|
+
const len0 = WASM_VECTOR_LEN;
|
|
197
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
198
|
+
const len1 = WASM_VECTOR_LEN;
|
|
199
|
+
const ret = wasm.sub(ptr0, len0, ptr1, len1);
|
|
200
|
+
var ptr3 = ret[0];
|
|
201
|
+
var len3 = ret[1];
|
|
202
|
+
if (ret[3]) {
|
|
203
|
+
ptr3 = 0; len3 = 0;
|
|
204
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
205
|
+
}
|
|
206
|
+
deferred4_0 = ptr3;
|
|
207
|
+
deferred4_1 = len3;
|
|
208
|
+
return getStringFromWasm0(ptr3, len3);
|
|
209
|
+
} finally {
|
|
210
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function __wbg_get_imports() {
|
|
214
|
+
const import0 = {
|
|
215
|
+
__proto__: null,
|
|
216
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
217
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
218
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
219
|
+
return ret;
|
|
220
|
+
},
|
|
221
|
+
__wbindgen_init_externref_table: function() {
|
|
222
|
+
const table = wasm.__wbindgen_externrefs;
|
|
223
|
+
const offset = table.grow(4);
|
|
224
|
+
table.set(0, undefined);
|
|
225
|
+
table.set(offset + 0, undefined);
|
|
226
|
+
table.set(offset + 1, null);
|
|
227
|
+
table.set(offset + 2, true);
|
|
228
|
+
table.set(offset + 3, false);
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
__proto__: null,
|
|
233
|
+
"./atom_engine_wasm_bg.js": import0,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function getStringFromWasm0(ptr, len) {
|
|
238
|
+
return decodeText(ptr >>> 0, len);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let cachedUint8ArrayMemory0 = null;
|
|
242
|
+
function getUint8ArrayMemory0() {
|
|
243
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
244
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
245
|
+
}
|
|
246
|
+
return cachedUint8ArrayMemory0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
250
|
+
if (realloc === undefined) {
|
|
251
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
252
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
253
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
254
|
+
WASM_VECTOR_LEN = buf.length;
|
|
255
|
+
return ptr;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let len = arg.length;
|
|
259
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
260
|
+
|
|
261
|
+
const mem = getUint8ArrayMemory0();
|
|
262
|
+
|
|
263
|
+
let offset = 0;
|
|
264
|
+
|
|
265
|
+
for (; offset < len; offset++) {
|
|
266
|
+
const code = arg.charCodeAt(offset);
|
|
267
|
+
if (code > 0x7F) break;
|
|
268
|
+
mem[ptr + offset] = code;
|
|
269
|
+
}
|
|
270
|
+
if (offset !== len) {
|
|
271
|
+
if (offset !== 0) {
|
|
272
|
+
arg = arg.slice(offset);
|
|
273
|
+
}
|
|
274
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
275
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
276
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
277
|
+
|
|
278
|
+
offset += ret.written;
|
|
279
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
WASM_VECTOR_LEN = offset;
|
|
283
|
+
return ptr;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function takeFromExternrefTable0(idx) {
|
|
287
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
288
|
+
wasm.__externref_table_dealloc(idx);
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
293
|
+
cachedTextDecoder.decode();
|
|
294
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
295
|
+
let numBytesDecoded = 0;
|
|
296
|
+
function decodeText(ptr, len) {
|
|
297
|
+
numBytesDecoded += len;
|
|
298
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
299
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
300
|
+
cachedTextDecoder.decode();
|
|
301
|
+
numBytesDecoded = len;
|
|
302
|
+
}
|
|
303
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const cachedTextEncoder = new TextEncoder();
|
|
307
|
+
|
|
308
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
309
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
310
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
311
|
+
view.set(buf);
|
|
312
|
+
return {
|
|
313
|
+
read: arg.length,
|
|
314
|
+
written: buf.length
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
let WASM_VECTOR_LEN = 0;
|
|
320
|
+
|
|
321
|
+
let wasmModule, wasmInstance, wasm;
|
|
322
|
+
function __wbg_finalize_init(instance, module) {
|
|
323
|
+
wasmInstance = instance;
|
|
324
|
+
wasm = instance.exports;
|
|
325
|
+
wasmModule = module;
|
|
326
|
+
cachedUint8ArrayMemory0 = null;
|
|
327
|
+
wasm.__wbindgen_start();
|
|
328
|
+
return wasm;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async function __wbg_load(module, imports) {
|
|
332
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
333
|
+
if (!module.ok) {
|
|
334
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
338
|
+
try {
|
|
339
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
340
|
+
} catch (e) {
|
|
341
|
+
const validResponse = expectedResponseType(module.type);
|
|
342
|
+
|
|
343
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
344
|
+
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);
|
|
345
|
+
|
|
346
|
+
} else { throw e; }
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const bytes = await module.arrayBuffer();
|
|
351
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
352
|
+
} else {
|
|
353
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
354
|
+
|
|
355
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
356
|
+
return { instance, module };
|
|
357
|
+
} else {
|
|
358
|
+
return instance;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function expectedResponseType(type) {
|
|
363
|
+
switch (type) {
|
|
364
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function initSync(module) {
|
|
371
|
+
if (wasm !== undefined) return wasm;
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
if (module !== undefined) {
|
|
375
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
376
|
+
({module} = module)
|
|
377
|
+
} else {
|
|
378
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const imports = __wbg_get_imports();
|
|
383
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
384
|
+
module = new WebAssembly.Module(module);
|
|
385
|
+
}
|
|
386
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
387
|
+
return __wbg_finalize_init(instance, module);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async function __wbg_init(module_or_path) {
|
|
391
|
+
if (wasm !== undefined) return wasm;
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
if (module_or_path !== undefined) {
|
|
395
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
396
|
+
({module_or_path} = module_or_path)
|
|
397
|
+
} else {
|
|
398
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (module_or_path === undefined) {
|
|
403
|
+
module_or_path = new URL('atom_engine_wasm_bg.wasm', import.meta.url);
|
|
404
|
+
}
|
|
405
|
+
const imports = __wbg_get_imports();
|
|
406
|
+
|
|
407
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
408
|
+
module_or_path = fetch(module_or_path);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
412
|
+
|
|
413
|
+
return __wbg_finalize_init(instance, module);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const add: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
|
+
export const cmp: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
6
|
+
export const div: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
7
|
+
export const mul: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
8
|
+
export const pow: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
+
export const rem: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
+
export const sqrt: (a: number, b: number, c: number) => [number, number, number, number];
|
|
11
|
+
export const sub: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
12
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
13
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
14
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
15
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
16
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const __wbindgen_start: () => void;
|