qail-wasm 0.5.3-alpha → 0.7.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/package.json +6 -2
- package/qail_wasm.d.ts +52 -0
- package/qail_wasm.js +192 -73
- package/qail_wasm_bg.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qail-wasm",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "QAIL parser and transpiler for JavaScript/TypeScript via WebAssembly",
|
|
4
|
-
"version": "0.
|
|
5
|
+
"version": "0.7.0",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
@@ -14,5 +15,8 @@
|
|
|
14
15
|
],
|
|
15
16
|
"main": "qail_wasm.js",
|
|
16
17
|
"homepage": "https://qail.rs",
|
|
17
|
-
"types": "qail_wasm.d.ts"
|
|
18
|
+
"types": "qail_wasm.d.ts",
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"./snippets/*"
|
|
21
|
+
]
|
|
18
22
|
}
|
package/qail_wasm.d.ts
CHANGED
|
@@ -1,8 +1,60 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Parse QAIL and return AST as JSON.
|
|
6
|
+
*/
|
|
4
7
|
export function parse(qail: string): any;
|
|
5
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Parse QAIL and return SQL string.
|
|
11
|
+
*/
|
|
6
12
|
export function parse_and_transpile(qail: string): string;
|
|
7
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Validate QAIL syntax (returns true if valid).
|
|
16
|
+
*/
|
|
8
17
|
export function validate(qail: string): boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get QAIL version.
|
|
21
|
+
*/
|
|
22
|
+
export function version(): string;
|
|
23
|
+
|
|
24
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
25
|
+
|
|
26
|
+
export interface InitOutput {
|
|
27
|
+
readonly memory: WebAssembly.Memory;
|
|
28
|
+
readonly parse_and_transpile: (a: number, b: number) => [number, number, number, number];
|
|
29
|
+
readonly parse: (a: number, b: number) => [number, number, number];
|
|
30
|
+
readonly validate: (a: number, b: number) => number;
|
|
31
|
+
readonly version: () => [number, number];
|
|
32
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
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>;
|
package/qail_wasm.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
let imports = {};
|
|
3
|
-
imports['__wbindgen_placeholder__'] = module.exports;
|
|
1
|
+
let wasm;
|
|
4
2
|
|
|
5
3
|
let cachedDataViewMemory0 = null;
|
|
6
4
|
function getDataViewMemory0() {
|
|
@@ -68,7 +66,15 @@ function takeFromExternrefTable0(idx) {
|
|
|
68
66
|
|
|
69
67
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
70
68
|
cachedTextDecoder.decode();
|
|
69
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
70
|
+
let numBytesDecoded = 0;
|
|
71
71
|
function decodeText(ptr, len) {
|
|
72
|
+
numBytesDecoded += len;
|
|
73
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
74
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
75
|
+
cachedTextDecoder.decode();
|
|
76
|
+
numBytesDecoded = len;
|
|
77
|
+
}
|
|
72
78
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -88,10 +94,11 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
88
94
|
let WASM_VECTOR_LEN = 0;
|
|
89
95
|
|
|
90
96
|
/**
|
|
97
|
+
* Parse QAIL and return AST as JSON.
|
|
91
98
|
* @param {string} qail
|
|
92
99
|
* @returns {any}
|
|
93
100
|
*/
|
|
94
|
-
function parse(qail) {
|
|
101
|
+
export function parse(qail) {
|
|
95
102
|
const ptr0 = passStringToWasm0(qail, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
96
103
|
const len0 = WASM_VECTOR_LEN;
|
|
97
104
|
const ret = wasm.parse(ptr0, len0);
|
|
@@ -100,13 +107,13 @@ function parse(qail) {
|
|
|
100
107
|
}
|
|
101
108
|
return takeFromExternrefTable0(ret[0]);
|
|
102
109
|
}
|
|
103
|
-
exports.parse = parse;
|
|
104
110
|
|
|
105
111
|
/**
|
|
112
|
+
* Parse QAIL and return SQL string.
|
|
106
113
|
* @param {string} qail
|
|
107
114
|
* @returns {string}
|
|
108
115
|
*/
|
|
109
|
-
function parse_and_transpile(qail) {
|
|
116
|
+
export function parse_and_transpile(qail) {
|
|
110
117
|
let deferred3_0;
|
|
111
118
|
let deferred3_1;
|
|
112
119
|
try {
|
|
@@ -126,80 +133,192 @@ function parse_and_transpile(qail) {
|
|
|
126
133
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
127
134
|
}
|
|
128
135
|
}
|
|
129
|
-
exports.parse_and_transpile = parse_and_transpile;
|
|
130
136
|
|
|
131
137
|
/**
|
|
138
|
+
* Validate QAIL syntax (returns true if valid).
|
|
132
139
|
* @param {string} qail
|
|
133
140
|
* @returns {boolean}
|
|
134
141
|
*/
|
|
135
|
-
function validate(qail) {
|
|
142
|
+
export function validate(qail) {
|
|
136
143
|
const ptr0 = passStringToWasm0(qail, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
137
144
|
const len0 = WASM_VECTOR_LEN;
|
|
138
145
|
const ret = wasm.validate(ptr0, len0);
|
|
139
146
|
return ret !== 0;
|
|
140
147
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get QAIL version.
|
|
151
|
+
* @returns {string}
|
|
152
|
+
*/
|
|
153
|
+
export function version() {
|
|
154
|
+
let deferred1_0;
|
|
155
|
+
let deferred1_1;
|
|
156
|
+
try {
|
|
157
|
+
const ret = wasm.version();
|
|
158
|
+
deferred1_0 = ret[0];
|
|
159
|
+
deferred1_1 = ret[1];
|
|
160
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
161
|
+
} finally {
|
|
162
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
167
|
+
|
|
168
|
+
async function __wbg_load(module, imports) {
|
|
169
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
170
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
171
|
+
try {
|
|
172
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
173
|
+
} catch (e) {
|
|
174
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
175
|
+
|
|
176
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
177
|
+
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);
|
|
178
|
+
|
|
179
|
+
} else {
|
|
180
|
+
throw e;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const bytes = await module.arrayBuffer();
|
|
186
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
187
|
+
} else {
|
|
188
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
189
|
+
|
|
190
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
191
|
+
return { instance, module };
|
|
192
|
+
} else {
|
|
193
|
+
return instance;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function __wbg_get_imports() {
|
|
199
|
+
const imports = {};
|
|
200
|
+
imports.wbg = {};
|
|
201
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
202
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
203
|
+
return ret;
|
|
204
|
+
};
|
|
205
|
+
imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
|
|
206
|
+
const ret = Number(arg0);
|
|
207
|
+
return ret;
|
|
208
|
+
};
|
|
209
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
210
|
+
const ret = String(arg1);
|
|
211
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
212
|
+
const len1 = WASM_VECTOR_LEN;
|
|
213
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
214
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
215
|
+
};
|
|
216
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
217
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
218
|
+
};
|
|
219
|
+
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
220
|
+
const ret = new Object();
|
|
221
|
+
return ret;
|
|
222
|
+
};
|
|
223
|
+
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
224
|
+
const ret = new Array();
|
|
225
|
+
return ret;
|
|
226
|
+
};
|
|
227
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
228
|
+
arg0[arg1] = arg2;
|
|
229
|
+
};
|
|
230
|
+
imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
231
|
+
arg0[arg1 >>> 0] = arg2;
|
|
232
|
+
};
|
|
233
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
234
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
235
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
236
|
+
return ret;
|
|
237
|
+
};
|
|
238
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
239
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
240
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
241
|
+
return ret;
|
|
242
|
+
};
|
|
243
|
+
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
244
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
245
|
+
const ret = arg0;
|
|
246
|
+
return ret;
|
|
247
|
+
};
|
|
248
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
249
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
250
|
+
const ret = arg0;
|
|
251
|
+
return ret;
|
|
252
|
+
};
|
|
253
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
254
|
+
const table = wasm.__wbindgen_externrefs;
|
|
255
|
+
const offset = table.grow(4);
|
|
256
|
+
table.set(0, undefined);
|
|
257
|
+
table.set(offset + 0, undefined);
|
|
258
|
+
table.set(offset + 1, null);
|
|
259
|
+
table.set(offset + 2, true);
|
|
260
|
+
table.set(offset + 3, false);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return imports;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function __wbg_finalize_init(instance, module) {
|
|
267
|
+
wasm = instance.exports;
|
|
268
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
269
|
+
cachedDataViewMemory0 = null;
|
|
270
|
+
cachedUint8ArrayMemory0 = null;
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
wasm.__wbindgen_start();
|
|
274
|
+
return wasm;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function initSync(module) {
|
|
278
|
+
if (wasm !== undefined) return wasm;
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
if (typeof module !== 'undefined') {
|
|
282
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
283
|
+
({module} = module)
|
|
284
|
+
} else {
|
|
285
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const imports = __wbg_get_imports();
|
|
290
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
291
|
+
module = new WebAssembly.Module(module);
|
|
292
|
+
}
|
|
293
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
294
|
+
return __wbg_finalize_init(instance, module);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function __wbg_init(module_or_path) {
|
|
298
|
+
if (wasm !== undefined) return wasm;
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
if (typeof module_or_path !== 'undefined') {
|
|
302
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
303
|
+
({module_or_path} = module_or_path)
|
|
304
|
+
} else {
|
|
305
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (typeof module_or_path === 'undefined') {
|
|
310
|
+
module_or_path = new URL('qail_wasm_bg.wasm', import.meta.url);
|
|
311
|
+
}
|
|
312
|
+
const imports = __wbg_get_imports();
|
|
313
|
+
|
|
314
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
315
|
+
module_or_path = fetch(module_or_path);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
319
|
+
|
|
320
|
+
return __wbg_finalize_init(instance, module);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { initSync };
|
|
324
|
+
export default __wbg_init;
|
package/qail_wasm_bg.wasm
CHANGED
|
Binary file
|