qail-wasm 0.5.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 +18 -0
- package/qail_wasm.d.ts +8 -0
- package/qail_wasm.js +205 -0
- package/qail_wasm_bg.wasm +0 -0
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "qail-wasm",
|
|
3
|
+
"description": "QAIL parser and transpiler for JavaScript/TypeScript via WebAssembly",
|
|
4
|
+
"version": "0.5.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/qail-rs/qail"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"qail_wasm_bg.wasm",
|
|
12
|
+
"qail_wasm.js",
|
|
13
|
+
"qail_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "qail_wasm.js",
|
|
16
|
+
"homepage": "https://qail.rs",
|
|
17
|
+
"types": "qail_wasm.d.ts"
|
|
18
|
+
}
|
package/qail_wasm.d.ts
ADDED
package/qail_wasm.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
|
|
5
|
+
let cachedDataViewMemory0 = null;
|
|
6
|
+
function getDataViewMemory0() {
|
|
7
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
8
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
9
|
+
}
|
|
10
|
+
return cachedDataViewMemory0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getStringFromWasm0(ptr, len) {
|
|
14
|
+
ptr = ptr >>> 0;
|
|
15
|
+
return decodeText(ptr, len);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let cachedUint8ArrayMemory0 = null;
|
|
19
|
+
function getUint8ArrayMemory0() {
|
|
20
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
21
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
22
|
+
}
|
|
23
|
+
return cachedUint8ArrayMemory0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
27
|
+
if (realloc === undefined) {
|
|
28
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
29
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
30
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
31
|
+
WASM_VECTOR_LEN = buf.length;
|
|
32
|
+
return ptr;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let len = arg.length;
|
|
36
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
37
|
+
|
|
38
|
+
const mem = getUint8ArrayMemory0();
|
|
39
|
+
|
|
40
|
+
let offset = 0;
|
|
41
|
+
|
|
42
|
+
for (; offset < len; offset++) {
|
|
43
|
+
const code = arg.charCodeAt(offset);
|
|
44
|
+
if (code > 0x7F) break;
|
|
45
|
+
mem[ptr + offset] = code;
|
|
46
|
+
}
|
|
47
|
+
if (offset !== len) {
|
|
48
|
+
if (offset !== 0) {
|
|
49
|
+
arg = arg.slice(offset);
|
|
50
|
+
}
|
|
51
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
52
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
53
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
54
|
+
|
|
55
|
+
offset += ret.written;
|
|
56
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
WASM_VECTOR_LEN = offset;
|
|
60
|
+
return ptr;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function takeFromExternrefTable0(idx) {
|
|
64
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
65
|
+
wasm.__externref_table_dealloc(idx);
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
70
|
+
cachedTextDecoder.decode();
|
|
71
|
+
function decodeText(ptr, len) {
|
|
72
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const cachedTextEncoder = new TextEncoder();
|
|
76
|
+
|
|
77
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
78
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
79
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
80
|
+
view.set(buf);
|
|
81
|
+
return {
|
|
82
|
+
read: arg.length,
|
|
83
|
+
written: buf.length
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let WASM_VECTOR_LEN = 0;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {string} qail
|
|
92
|
+
* @returns {any}
|
|
93
|
+
*/
|
|
94
|
+
function parse(qail) {
|
|
95
|
+
const ptr0 = passStringToWasm0(qail, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
96
|
+
const len0 = WASM_VECTOR_LEN;
|
|
97
|
+
const ret = wasm.parse(ptr0, len0);
|
|
98
|
+
if (ret[2]) {
|
|
99
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
100
|
+
}
|
|
101
|
+
return takeFromExternrefTable0(ret[0]);
|
|
102
|
+
}
|
|
103
|
+
exports.parse = parse;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} qail
|
|
107
|
+
* @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
function parse_and_transpile(qail) {
|
|
110
|
+
let deferred3_0;
|
|
111
|
+
let deferred3_1;
|
|
112
|
+
try {
|
|
113
|
+
const ptr0 = passStringToWasm0(qail, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
114
|
+
const len0 = WASM_VECTOR_LEN;
|
|
115
|
+
const ret = wasm.parse_and_transpile(ptr0, len0);
|
|
116
|
+
var ptr2 = ret[0];
|
|
117
|
+
var len2 = ret[1];
|
|
118
|
+
if (ret[3]) {
|
|
119
|
+
ptr2 = 0; len2 = 0;
|
|
120
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
121
|
+
}
|
|
122
|
+
deferred3_0 = ptr2;
|
|
123
|
+
deferred3_1 = len2;
|
|
124
|
+
return getStringFromWasm0(ptr2, len2);
|
|
125
|
+
} finally {
|
|
126
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.parse_and_transpile = parse_and_transpile;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @param {string} qail
|
|
133
|
+
* @returns {boolean}
|
|
134
|
+
*/
|
|
135
|
+
function validate(qail) {
|
|
136
|
+
const ptr0 = passStringToWasm0(qail, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
137
|
+
const len0 = WASM_VECTOR_LEN;
|
|
138
|
+
const ret = wasm.validate(ptr0, len0);
|
|
139
|
+
return ret !== 0;
|
|
140
|
+
}
|
|
141
|
+
exports.validate = validate;
|
|
142
|
+
|
|
143
|
+
exports.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
144
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
145
|
+
return ret;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
149
|
+
const ret = String(arg1);
|
|
150
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
151
|
+
const len1 = WASM_VECTOR_LEN;
|
|
152
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
153
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
157
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
exports.__wbg_new_1ba21ce319a06297 = function() {
|
|
161
|
+
const ret = new Object();
|
|
162
|
+
return ret;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
exports.__wbg_new_25f239778d6112b9 = function() {
|
|
166
|
+
const ret = new Array();
|
|
167
|
+
return ret;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
171
|
+
arg0[arg1] = arg2;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
exports.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
175
|
+
arg0[arg1 >>> 0] = arg2;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
179
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
180
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
181
|
+
return ret;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
185
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
186
|
+
const ret = arg0;
|
|
187
|
+
return ret;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
exports.__wbindgen_init_externref_table = function() {
|
|
191
|
+
const table = wasm.__wbindgen_externrefs;
|
|
192
|
+
const offset = table.grow(4);
|
|
193
|
+
table.set(0, undefined);
|
|
194
|
+
table.set(offset + 0, undefined);
|
|
195
|
+
table.set(offset + 1, null);
|
|
196
|
+
table.set(offset + 2, true);
|
|
197
|
+
table.set(offset + 3, false);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const wasmPath = `${__dirname}/qail_wasm_bg.wasm`;
|
|
201
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
202
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
203
|
+
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
204
|
+
|
|
205
|
+
wasm.__wbindgen_start();
|
|
Binary file
|