@presolve/compiler-wasm 0.1.0-alpha.6
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Presolve contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The sole public L12-C browser binding. Product validation and query
|
|
6
|
+
* projection remain inside the compiler's Rust authority.
|
|
7
|
+
*/
|
|
8
|
+
export function query_snapshot_v1(product_bytes: Uint8Array, request_bytes: Uint8Array): Uint8Array;
|
|
9
|
+
|
|
10
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
11
|
+
|
|
12
|
+
export interface InitOutput {
|
|
13
|
+
readonly memory: WebAssembly.Memory;
|
|
14
|
+
readonly query_snapshot_v1: (a: number, b: number, c: number, d: number) => [number, number];
|
|
15
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
16
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
17
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
18
|
+
readonly __wbindgen_start: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
25
|
+
* a precompiled `WebAssembly.Module`.
|
|
26
|
+
*
|
|
27
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
28
|
+
*
|
|
29
|
+
* @returns {InitOutput}
|
|
30
|
+
*/
|
|
31
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
35
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
36
|
+
*
|
|
37
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise<InitOutput>}
|
|
40
|
+
*/
|
|
41
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/* @ts-self-types="./presolve_compiler_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The sole public L12-C browser binding. Product validation and query
|
|
5
|
+
* projection remain inside the compiler's Rust authority.
|
|
6
|
+
* @param {Uint8Array} product_bytes
|
|
7
|
+
* @param {Uint8Array} request_bytes
|
|
8
|
+
* @returns {Uint8Array}
|
|
9
|
+
*/
|
|
10
|
+
export function query_snapshot_v1(product_bytes, request_bytes) {
|
|
11
|
+
const ptr0 = passArray8ToWasm0(product_bytes, wasm.__wbindgen_malloc);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
const ptr1 = passArray8ToWasm0(request_bytes, wasm.__wbindgen_malloc);
|
|
14
|
+
const len1 = WASM_VECTOR_LEN;
|
|
15
|
+
const ret = wasm.query_snapshot_v1(ptr0, len0, ptr1, len1);
|
|
16
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
17
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
18
|
+
return v3;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function __wbg_get_imports() {
|
|
22
|
+
const import0 = {
|
|
23
|
+
__proto__: null,
|
|
24
|
+
__wbindgen_init_externref_table: function() {
|
|
25
|
+
const table = wasm.__wbindgen_externrefs;
|
|
26
|
+
const offset = table.grow(4);
|
|
27
|
+
table.set(0, undefined);
|
|
28
|
+
table.set(offset + 0, undefined);
|
|
29
|
+
table.set(offset + 1, null);
|
|
30
|
+
table.set(offset + 2, true);
|
|
31
|
+
table.set(offset + 3, false);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
__proto__: null,
|
|
36
|
+
"./presolve_compiler_wasm_bg.js": import0,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
41
|
+
ptr = ptr >>> 0;
|
|
42
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let cachedUint8ArrayMemory0 = null;
|
|
46
|
+
function getUint8ArrayMemory0() {
|
|
47
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
48
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
49
|
+
}
|
|
50
|
+
return cachedUint8ArrayMemory0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
54
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
55
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
56
|
+
WASM_VECTOR_LEN = arg.length;
|
|
57
|
+
return ptr;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let WASM_VECTOR_LEN = 0;
|
|
61
|
+
|
|
62
|
+
let wasmModule, wasm;
|
|
63
|
+
function __wbg_finalize_init(instance, module) {
|
|
64
|
+
wasm = instance.exports;
|
|
65
|
+
wasmModule = module;
|
|
66
|
+
cachedUint8ArrayMemory0 = null;
|
|
67
|
+
wasm.__wbindgen_start();
|
|
68
|
+
return wasm;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function __wbg_load(module, imports) {
|
|
72
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
73
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
74
|
+
try {
|
|
75
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
78
|
+
|
|
79
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
80
|
+
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);
|
|
81
|
+
|
|
82
|
+
} else { throw e; }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const bytes = await module.arrayBuffer();
|
|
87
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
88
|
+
} else {
|
|
89
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
90
|
+
|
|
91
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
92
|
+
return { instance, module };
|
|
93
|
+
} else {
|
|
94
|
+
return instance;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function expectedResponseType(type) {
|
|
99
|
+
switch (type) {
|
|
100
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function initSync(module) {
|
|
107
|
+
if (wasm !== undefined) return wasm;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if (module !== undefined) {
|
|
111
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
112
|
+
({module} = module)
|
|
113
|
+
} else {
|
|
114
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const imports = __wbg_get_imports();
|
|
119
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
120
|
+
module = new WebAssembly.Module(module);
|
|
121
|
+
}
|
|
122
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
123
|
+
return __wbg_finalize_init(instance, module);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function __wbg_init(module_or_path) {
|
|
127
|
+
if (wasm !== undefined) return wasm;
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if (module_or_path !== undefined) {
|
|
131
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
132
|
+
({module_or_path} = module_or_path)
|
|
133
|
+
} else {
|
|
134
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (module_or_path === undefined) {
|
|
139
|
+
module_or_path = new URL('presolve_compiler_wasm_bg.wasm', import.meta.url);
|
|
140
|
+
}
|
|
141
|
+
const imports = __wbg_get_imports();
|
|
142
|
+
|
|
143
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
144
|
+
module_or_path = fetch(module_or_path);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
148
|
+
|
|
149
|
+
return __wbg_finalize_init(instance, module);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const query_snapshot_v1: (a: number, b: number, c: number, d: number) => [number, number];
|
|
5
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
6
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
7
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const __wbindgen_start: () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@presolve/compiler-wasm",
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
|
+
"description": "Compiler-owned Presolve WebAssembly query bindings.",
|
|
5
|
+
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/fierstdev/presolve.git",
|
|
10
|
+
"directory": "packages/compiler-wasm"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"tag": "alpha"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/presolve_compiler_wasm.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "../../scripts/build-compiler-wasm.sh",
|
|
24
|
+
"test": "node test/smoke.mjs"
|
|
25
|
+
}
|
|
26
|
+
}
|