lingotweaker-wasm 0.2.1 → 0.2.3
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/README.md +22 -12
- package/node/lt_wasm.d.ts +58 -0
- package/node/lt_wasm.js +375 -0
- package/node/lt_wasm_bg.wasm +0 -0
- package/node/lt_wasm_bg.wasm.d.ts +20 -0
- package/node/package.json +1 -0
- package/pack.d.ts +34 -0
- package/pack.js +27 -21
- package/package.json +4 -2
- package/web/lt_wasm.d.ts +103 -0
- package/web/lt_wasm.js +472 -0
- package/web/lt_wasm_bg.wasm +0 -0
- package/web/lt_wasm_bg.wasm.d.ts +20 -0
- package/web/package.json +1 -0
package/README.md
CHANGED
|
@@ -10,13 +10,19 @@ npm install lingotweaker-wasm@next
|
|
|
10
10
|
|
|
11
11
|
## Browser
|
|
12
12
|
|
|
13
|
+
The engine's language data packs must be served from your own server —
|
|
14
|
+
browsers block cross-origin fetches, so the data helper has no built-in CDN
|
|
15
|
+
default. Install the `lingotweaker-data-<lang>` npm packages for the languages
|
|
16
|
+
you want, copy their `packs/` directory into your static assets, and pass its
|
|
17
|
+
URL as `baseUrl`:
|
|
18
|
+
|
|
13
19
|
```js
|
|
14
20
|
import init, { LtEngine } from "lingotweaker-wasm";
|
|
15
21
|
import { fetchPack } from "lingotweaker-wasm/pack";
|
|
16
22
|
|
|
17
23
|
await init();
|
|
18
24
|
|
|
19
|
-
const pack = await fetchPack("en"
|
|
25
|
+
const pack = await fetchPack("en", { baseUrl: "/static/lingotweaker-packs" });
|
|
20
26
|
const engine = new LtEngine(
|
|
21
27
|
"en-US",
|
|
22
28
|
pack,
|
|
@@ -56,24 +62,28 @@ passed in and pinned for the engine's date filters.
|
|
|
56
62
|
## Data
|
|
57
63
|
|
|
58
64
|
The package ships **code only** and depends on the code-only
|
|
59
|
-
`lingotweaker-data` loader; the packs ship in one
|
|
65
|
+
`lingotweaker-data` loader; the packs ship in one package per language
|
|
60
66
|
(`lingotweaker-data-<lang>`). In Node.js the data helper resolves installed
|
|
61
|
-
`lingotweaker-data-<lang>` packages
|
|
62
|
-
|
|
67
|
+
`lingotweaker-data-<lang>` packages automatically. In the browser you serve
|
|
68
|
+
the packs yourself (see above) and pass the directory URL as `baseUrl`:
|
|
63
69
|
|
|
64
70
|
```js
|
|
65
71
|
import { fetchPack, packUrl, manifestUrl } from "lingotweaker-wasm/pack";
|
|
66
72
|
|
|
67
|
-
await fetchPack("en");
|
|
68
|
-
await fetchPack("gn", { baseUrl: "
|
|
69
|
-
packUrl("de");
|
|
73
|
+
await fetchPack("en"); // installed lingotweaker-data-en (Node.js)
|
|
74
|
+
await fetchPack("gn", { baseUrl: "/static/lingotweaker-packs" }); // browser: your own server
|
|
75
|
+
packUrl("de", "/static/lingotweaker-packs"); // build a URL yourself
|
|
70
76
|
```
|
|
71
77
|
|
|
72
|
-
`baseUrl` points at a directory
|
|
73
|
-
`
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
`baseUrl` points at a directory with the same layout as the
|
|
79
|
+
`lingotweaker-data-<lang>` packages: a `packs/` subdirectory containing
|
|
80
|
+
`<lang>.pack.gz` plus a `manifest.json` listing file sizes and sha256 hashes.
|
|
81
|
+
Same-origin is the usual choice; any CORS-enabled static server works. Packs
|
|
82
|
+
are downloaded individually per language, on demand.
|
|
83
|
+
|
|
84
|
+
LingoTweaker is an independent project and includes a port of the legacy
|
|
85
|
+
LanguageTool proofreading engine and its rule data. Upstream references and
|
|
86
|
+
licenses are kept; see `THIRD_PARTY_NOTICES.md` in the repository.
|
|
77
87
|
|
|
78
88
|
LingoTweaker is an independent project and includes a port of the legacy
|
|
79
89
|
LanguageTool proofreading engine and its rule data. Upstream references and
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An immutable engine loaded from a data pack.
|
|
6
|
+
*/
|
|
7
|
+
export class LtEngine {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Number of rules actively matched by the pattern engine.
|
|
12
|
+
*/
|
|
13
|
+
active_rule_count(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Check `text` and return the LT-shaped JSON of `CheckResult`.
|
|
16
|
+
*/
|
|
17
|
+
check_json(text: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Check `text` and return only the matches as JSON: `{"matches":[…]}`.
|
|
20
|
+
*
|
|
21
|
+
* The demo (and any UI that only renders issues) never needs the input
|
|
22
|
+
* text and per-sentence text spans that [`Self::check_json`] also
|
|
23
|
+
* serializes; for long paragraphs this JSON round-trip is a measurable
|
|
24
|
+
* share of the per-check latency.
|
|
25
|
+
*/
|
|
26
|
+
check_matches_json(text: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Rules that failed to compile, as `[{rule, error}, …]` JSON.
|
|
29
|
+
*/
|
|
30
|
+
compile_failures_json(): string;
|
|
31
|
+
/**
|
|
32
|
+
* The language code this engine was built for.
|
|
33
|
+
*/
|
|
34
|
+
lang(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Build an engine for `lang` (e.g. `en-US`, `gn-ES`) from `pack`.
|
|
37
|
+
*
|
|
38
|
+
* `options` is a JSON object; all fields are optional:
|
|
39
|
+
* `variant` (`en-GB`) selects variant resources, `today` (ISO date or
|
|
40
|
+
* timestamp) pins the date filters, and `picky`, `enabledRules`,
|
|
41
|
+
* `disabledRules`, `enabledCategories`, `disabledCategories`,
|
|
42
|
+
* `enabledOnly` configure rule selection.
|
|
43
|
+
*/
|
|
44
|
+
constructor(lang: string, pack: Uint8Array, options?: string | null);
|
|
45
|
+
/**
|
|
46
|
+
* Like [`LtEngine::new`] but built from several packs: the first is the
|
|
47
|
+
* base pack, later ones are sidecars (split packs: `en` base + optional
|
|
48
|
+
* `en.models`/`en-GB`-style variant dictionaries; reads fall through to
|
|
49
|
+
* the later packs). `packs` is a JS array of `Uint8Array`s.
|
|
50
|
+
*/
|
|
51
|
+
static new_multi(lang: string, packs: Uint8Array[], options?: string | null): LtEngine;
|
|
52
|
+
/**
|
|
53
|
+
* The variant override, if any.
|
|
54
|
+
*/
|
|
55
|
+
variant(): string | undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function start(): void;
|
package/node/lt_wasm.js
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/* @ts-self-types="./lt_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An immutable engine loaded from a data pack.
|
|
5
|
+
*/
|
|
6
|
+
class LtEngine {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(LtEngine.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
LtEngineFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
LtEngineFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_ltengine_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Number of rules actively matched by the pattern engine.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
active_rule_count() {
|
|
28
|
+
const ret = wasm.ltengine_active_rule_count(this.__wbg_ptr);
|
|
29
|
+
return ret >>> 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check `text` and return the LT-shaped JSON of `CheckResult`.
|
|
33
|
+
* @param {string} text
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
check_json(text) {
|
|
37
|
+
let deferred3_0;
|
|
38
|
+
let deferred3_1;
|
|
39
|
+
try {
|
|
40
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
const ret = wasm.ltengine_check_json(this.__wbg_ptr, ptr0, len0);
|
|
43
|
+
var ptr2 = ret[0];
|
|
44
|
+
var len2 = ret[1];
|
|
45
|
+
if (ret[3]) {
|
|
46
|
+
ptr2 = 0; len2 = 0;
|
|
47
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
48
|
+
}
|
|
49
|
+
deferred3_0 = ptr2;
|
|
50
|
+
deferred3_1 = len2;
|
|
51
|
+
return getStringFromWasm0(ptr2, len2);
|
|
52
|
+
} finally {
|
|
53
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check `text` and return only the matches as JSON: `{"matches":[…]}`.
|
|
58
|
+
*
|
|
59
|
+
* The demo (and any UI that only renders issues) never needs the input
|
|
60
|
+
* text and per-sentence text spans that [`Self::check_json`] also
|
|
61
|
+
* serializes; for long paragraphs this JSON round-trip is a measurable
|
|
62
|
+
* share of the per-check latency.
|
|
63
|
+
* @param {string} text
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
check_matches_json(text) {
|
|
67
|
+
let deferred3_0;
|
|
68
|
+
let deferred3_1;
|
|
69
|
+
try {
|
|
70
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
71
|
+
const len0 = WASM_VECTOR_LEN;
|
|
72
|
+
const ret = wasm.ltengine_check_matches_json(this.__wbg_ptr, ptr0, len0);
|
|
73
|
+
var ptr2 = ret[0];
|
|
74
|
+
var len2 = ret[1];
|
|
75
|
+
if (ret[3]) {
|
|
76
|
+
ptr2 = 0; len2 = 0;
|
|
77
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
78
|
+
}
|
|
79
|
+
deferred3_0 = ptr2;
|
|
80
|
+
deferred3_1 = len2;
|
|
81
|
+
return getStringFromWasm0(ptr2, len2);
|
|
82
|
+
} finally {
|
|
83
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Rules that failed to compile, as `[{rule, error}, …]` JSON.
|
|
88
|
+
* @returns {string}
|
|
89
|
+
*/
|
|
90
|
+
compile_failures_json() {
|
|
91
|
+
let deferred2_0;
|
|
92
|
+
let deferred2_1;
|
|
93
|
+
try {
|
|
94
|
+
const ret = wasm.ltengine_compile_failures_json(this.__wbg_ptr);
|
|
95
|
+
var ptr1 = ret[0];
|
|
96
|
+
var len1 = ret[1];
|
|
97
|
+
if (ret[3]) {
|
|
98
|
+
ptr1 = 0; len1 = 0;
|
|
99
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
100
|
+
}
|
|
101
|
+
deferred2_0 = ptr1;
|
|
102
|
+
deferred2_1 = len1;
|
|
103
|
+
return getStringFromWasm0(ptr1, len1);
|
|
104
|
+
} finally {
|
|
105
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The language code this engine was built for.
|
|
110
|
+
* @returns {string}
|
|
111
|
+
*/
|
|
112
|
+
lang() {
|
|
113
|
+
let deferred1_0;
|
|
114
|
+
let deferred1_1;
|
|
115
|
+
try {
|
|
116
|
+
const ret = wasm.ltengine_lang(this.__wbg_ptr);
|
|
117
|
+
deferred1_0 = ret[0];
|
|
118
|
+
deferred1_1 = ret[1];
|
|
119
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
120
|
+
} finally {
|
|
121
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build an engine for `lang` (e.g. `en-US`, `gn-ES`) from `pack`.
|
|
126
|
+
*
|
|
127
|
+
* `options` is a JSON object; all fields are optional:
|
|
128
|
+
* `variant` (`en-GB`) selects variant resources, `today` (ISO date or
|
|
129
|
+
* timestamp) pins the date filters, and `picky`, `enabledRules`,
|
|
130
|
+
* `disabledRules`, `enabledCategories`, `disabledCategories`,
|
|
131
|
+
* `enabledOnly` configure rule selection.
|
|
132
|
+
* @param {string} lang
|
|
133
|
+
* @param {Uint8Array} pack
|
|
134
|
+
* @param {string | null} [options]
|
|
135
|
+
*/
|
|
136
|
+
constructor(lang, pack, options) {
|
|
137
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
+
const len0 = WASM_VECTOR_LEN;
|
|
139
|
+
const ptr1 = passArray8ToWasm0(pack, wasm.__wbindgen_malloc);
|
|
140
|
+
const len1 = WASM_VECTOR_LEN;
|
|
141
|
+
var ptr2 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
var len2 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.ltengine_new(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
144
|
+
if (ret[2]) {
|
|
145
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
146
|
+
}
|
|
147
|
+
this.__wbg_ptr = ret[0];
|
|
148
|
+
LtEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Like [`LtEngine::new`] but built from several packs: the first is the
|
|
153
|
+
* base pack, later ones are sidecars (split packs: `en` base + optional
|
|
154
|
+
* `en.models`/`en-GB`-style variant dictionaries; reads fall through to
|
|
155
|
+
* the later packs). `packs` is a JS array of `Uint8Array`s.
|
|
156
|
+
* @param {string} lang
|
|
157
|
+
* @param {Uint8Array[]} packs
|
|
158
|
+
* @param {string | null} [options]
|
|
159
|
+
* @returns {LtEngine}
|
|
160
|
+
*/
|
|
161
|
+
static new_multi(lang, packs, options) {
|
|
162
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
163
|
+
const len0 = WASM_VECTOR_LEN;
|
|
164
|
+
const ptr1 = passArrayJsValueToWasm0(packs, wasm.__wbindgen_malloc);
|
|
165
|
+
const len1 = WASM_VECTOR_LEN;
|
|
166
|
+
var ptr2 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
167
|
+
var len2 = WASM_VECTOR_LEN;
|
|
168
|
+
const ret = wasm.ltengine_new_multi(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
169
|
+
if (ret[2]) {
|
|
170
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
171
|
+
}
|
|
172
|
+
return LtEngine.__wrap(ret[0]);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The variant override, if any.
|
|
176
|
+
* @returns {string | undefined}
|
|
177
|
+
*/
|
|
178
|
+
variant() {
|
|
179
|
+
const ret = wasm.ltengine_variant(this.__wbg_ptr);
|
|
180
|
+
let v1;
|
|
181
|
+
if (ret[0] !== 0) {
|
|
182
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
183
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
184
|
+
}
|
|
185
|
+
return v1;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (Symbol.dispose) LtEngine.prototype[Symbol.dispose] = LtEngine.prototype.free;
|
|
189
|
+
exports.LtEngine = LtEngine;
|
|
190
|
+
|
|
191
|
+
function start() {
|
|
192
|
+
wasm.start();
|
|
193
|
+
}
|
|
194
|
+
exports.start = start;
|
|
195
|
+
function __wbg_get_imports() {
|
|
196
|
+
const import0 = {
|
|
197
|
+
__proto__: null,
|
|
198
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
199
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
200
|
+
return ret;
|
|
201
|
+
},
|
|
202
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
203
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
204
|
+
},
|
|
205
|
+
__wbg_error_757e9472f8410341: function(arg0, arg1) {
|
|
206
|
+
let deferred0_0;
|
|
207
|
+
let deferred0_1;
|
|
208
|
+
try {
|
|
209
|
+
deferred0_0 = arg0;
|
|
210
|
+
deferred0_1 = arg1;
|
|
211
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
212
|
+
} finally {
|
|
213
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
__wbg_length_31bdaf014f5fbde2: function(arg0) {
|
|
217
|
+
const ret = arg0.length;
|
|
218
|
+
return ret;
|
|
219
|
+
},
|
|
220
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
221
|
+
const ret = new Error();
|
|
222
|
+
return ret;
|
|
223
|
+
},
|
|
224
|
+
__wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
|
|
225
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
226
|
+
},
|
|
227
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
228
|
+
const ret = arg1.stack;
|
|
229
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
230
|
+
const len1 = WASM_VECTOR_LEN;
|
|
231
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
232
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
233
|
+
},
|
|
234
|
+
__wbindgen_init_externref_table: function() {
|
|
235
|
+
const table = wasm.__wbindgen_externrefs;
|
|
236
|
+
const offset = table.grow(4);
|
|
237
|
+
table.set(0, undefined);
|
|
238
|
+
table.set(offset + 0, undefined);
|
|
239
|
+
table.set(offset + 1, null);
|
|
240
|
+
table.set(offset + 2, true);
|
|
241
|
+
table.set(offset + 3, false);
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
__proto__: null,
|
|
246
|
+
"./lt_wasm_bg.js": import0,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const LtEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
251
|
+
? { register: () => {}, unregister: () => {} }
|
|
252
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ltengine_free(ptr, 1));
|
|
253
|
+
|
|
254
|
+
function addToExternrefTable0(obj) {
|
|
255
|
+
const idx = wasm.__externref_table_alloc();
|
|
256
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
257
|
+
return idx;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
261
|
+
ptr = ptr >>> 0;
|
|
262
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
let cachedDataViewMemory0 = null;
|
|
266
|
+
function getDataViewMemory0() {
|
|
267
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
268
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
269
|
+
}
|
|
270
|
+
return cachedDataViewMemory0;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getStringFromWasm0(ptr, len) {
|
|
274
|
+
return decodeText(ptr >>> 0, len);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let cachedUint8ArrayMemory0 = null;
|
|
278
|
+
function getUint8ArrayMemory0() {
|
|
279
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
280
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
281
|
+
}
|
|
282
|
+
return cachedUint8ArrayMemory0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function isLikeNone(x) {
|
|
286
|
+
return x === undefined || x === null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
290
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
291
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
292
|
+
WASM_VECTOR_LEN = arg.length;
|
|
293
|
+
return ptr;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
297
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
298
|
+
for (let i = 0; i < array.length; i++) {
|
|
299
|
+
const add = addToExternrefTable0(array[i]);
|
|
300
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
301
|
+
}
|
|
302
|
+
WASM_VECTOR_LEN = array.length;
|
|
303
|
+
return ptr;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
307
|
+
if (realloc === undefined) {
|
|
308
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
309
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
310
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
311
|
+
WASM_VECTOR_LEN = buf.length;
|
|
312
|
+
return ptr;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
let len = arg.length;
|
|
316
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
317
|
+
|
|
318
|
+
const mem = getUint8ArrayMemory0();
|
|
319
|
+
|
|
320
|
+
let offset = 0;
|
|
321
|
+
|
|
322
|
+
for (; offset < len; offset++) {
|
|
323
|
+
const code = arg.charCodeAt(offset);
|
|
324
|
+
if (code > 0x7F) break;
|
|
325
|
+
mem[ptr + offset] = code;
|
|
326
|
+
}
|
|
327
|
+
if (offset !== len) {
|
|
328
|
+
if (offset !== 0) {
|
|
329
|
+
arg = arg.slice(offset);
|
|
330
|
+
}
|
|
331
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
332
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
333
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
334
|
+
|
|
335
|
+
offset += ret.written;
|
|
336
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
WASM_VECTOR_LEN = offset;
|
|
340
|
+
return ptr;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function takeFromExternrefTable0(idx) {
|
|
344
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
345
|
+
wasm.__externref_table_dealloc(idx);
|
|
346
|
+
return value;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
350
|
+
cachedTextDecoder.decode();
|
|
351
|
+
function decodeText(ptr, len) {
|
|
352
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const cachedTextEncoder = new TextEncoder();
|
|
356
|
+
|
|
357
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
358
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
359
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
360
|
+
view.set(buf);
|
|
361
|
+
return {
|
|
362
|
+
read: arg.length,
|
|
363
|
+
written: buf.length
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
let WASM_VECTOR_LEN = 0;
|
|
369
|
+
|
|
370
|
+
const wasmPath = `${__dirname}/lt_wasm_bg.wasm`;
|
|
371
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
372
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
373
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
374
|
+
let wasm = wasmInstance.exports;
|
|
375
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_ltengine_free: (a: number, b: number) => void;
|
|
5
|
+
export const ltengine_active_rule_count: (a: number) => number;
|
|
6
|
+
export const ltengine_check_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
7
|
+
export const ltengine_check_matches_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
8
|
+
export const ltengine_compile_failures_json: (a: number) => [number, number, number, number];
|
|
9
|
+
export const ltengine_lang: (a: number) => [number, number];
|
|
10
|
+
export const ltengine_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
11
|
+
export const ltengine_new_multi: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
12
|
+
export const ltengine_variant: (a: number) => [number, number];
|
|
13
|
+
export const start: () => void;
|
|
14
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
18
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
19
|
+
export const __externref_table_alloc: () => number;
|
|
20
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/pack.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Type definitions for the data-pack helpers in pack.js.
|
|
2
|
+
|
|
3
|
+
/** The URL of the data manifest (`{ <lang>: { file, bytes, sha256 } }`) under `baseUrl`. */
|
|
4
|
+
export function manifestUrl(baseUrl: string): string
|
|
5
|
+
|
|
6
|
+
/** The URL of the gzipped pack for `lang` under `baseUrl`. */
|
|
7
|
+
export function packUrl(lang: string, baseUrl: string): string
|
|
8
|
+
|
|
9
|
+
/** Inflate a gzipped pack (browser `DecompressionStream`, else Node `zlib`). */
|
|
10
|
+
export function decompressPack(
|
|
11
|
+
bytes: Uint8Array | ArrayBuffer
|
|
12
|
+
): Promise<Uint8Array>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Load and inflate the pack for `lang` (`en`, `de`, `gn`, …).
|
|
16
|
+
*
|
|
17
|
+
* Without `options.baseUrl` this resolves the pack from the locally
|
|
18
|
+
* installed `lingotweaker-data-<lang>` npm packages (Node.js only). In a
|
|
19
|
+
* browser you must pass `baseUrl` pointing at a directory you serve with the
|
|
20
|
+
* same layout as the `lingotweaker-data-<lang>` packages (a `packs/`
|
|
21
|
+
* subdirectory containing `<lang>.pack.gz`); same-origin is the usual choice,
|
|
22
|
+
* since browsers block cross-origin fetches.
|
|
23
|
+
*/
|
|
24
|
+
export function fetchPack(
|
|
25
|
+
lang: string,
|
|
26
|
+
options?: {baseUrl?: string; fetch?: typeof fetch}
|
|
27
|
+
): Promise<Uint8Array>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Read and inflate a pack from the locally installed data packages (the
|
|
31
|
+
* code-only `lingotweaker-data` loader resolving `lingotweaker-data-<lang>`).
|
|
32
|
+
* Returns `null` outside Node.js, or when the package/language is missing.
|
|
33
|
+
*/
|
|
34
|
+
export function localPack(lang: string): Promise<Uint8Array | null>
|
package/pack.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
// Data helpers for the `lingotweaker-wasm` package.
|
|
2
2
|
//
|
|
3
3
|
// The engine itself is loaded from an in-memory data pack
|
|
4
|
-
// (`LtEngine(lang, pack, optionsJson)`); this module
|
|
5
|
-
//
|
|
4
|
+
// (`LtEngine(lang, pack, optionsJson)`); this module obtains those packs —
|
|
5
|
+
// either from the locally installed `lingotweaker-data-<lang>` npm packages
|
|
6
|
+
// (Node.js) or fetched from a `baseUrl` your server serves them from
|
|
7
|
+
// (browsers). Packs are gzip-compressed and inflated after loading.
|
|
6
8
|
//
|
|
7
9
|
// import { fetchPack } from "lingotweaker-wasm/pack";
|
|
8
|
-
// const pack = await fetchPack("en");
|
|
10
|
+
// const pack = await fetchPack("en", { baseUrl: "/static/lingotweaker-packs" });
|
|
9
11
|
// const engine = new LtEngine("en-US", pack, JSON.stringify({ today: new Date().toISOString() }));
|
|
12
|
+
//
|
|
13
|
+
// There is intentionally no built-in CDN default: pack files must be served
|
|
14
|
+
// from the same origin as the page (or any CORS-enabled server you pass as
|
|
15
|
+
// `baseUrl`), because browsers refuse cross-origin fetches otherwise.
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
"https://github.com/fiduswriter/LingoTweaker/releases/download/v0.2.1";
|
|
14
|
-
|
|
15
|
-
/** The URL of the release data manifest (`{ <lang>: { file, bytes, sha256 } }`). */
|
|
16
|
-
export function manifestUrl(baseUrl = DEFAULT_DATA_BASE_URL) {
|
|
17
|
+
/** The URL of the data manifest (`{ <lang>: { file, bytes, sha256 } }`) under `baseUrl`. */
|
|
18
|
+
export function manifestUrl(baseUrl) {
|
|
17
19
|
return `${baseUrl}/manifest.json`;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
/** The URL of the gzipped pack for `lang`. */
|
|
21
|
-
export function packUrl(lang, baseUrl
|
|
22
|
+
/** The URL of the gzipped pack for `lang` under `baseUrl`. */
|
|
23
|
+
export function packUrl(lang, baseUrl) {
|
|
22
24
|
return `${baseUrl}/packs/${lang}.pack.gz`;
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -34,21 +36,25 @@ export async function decompressPack(bytes) {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
|
-
*
|
|
39
|
+
* Load and inflate the pack for `lang` (`en`, `de`, `gn`, …).
|
|
38
40
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* Without `options.baseUrl` this resolves the pack from the locally
|
|
42
|
+
* installed `lingotweaker-data-<lang>` npm packages (Node.js only). In a
|
|
43
|
+
* browser you must pass `baseUrl` pointing at a directory you serve with the
|
|
44
|
+
* same layout as the `lingotweaker-data-<lang>` packages (a `packs/`
|
|
45
|
+
* subdirectory containing `<lang>.pack.gz`); same-origin is the usual choice,
|
|
46
|
+
* since browsers block cross-origin fetches.
|
|
44
47
|
*/
|
|
45
48
|
export async function fetchPack(lang, options = {}) {
|
|
46
|
-
const { fetch: fetchImpl = fetch } = options;
|
|
47
|
-
let { baseUrl } = options;
|
|
49
|
+
const { fetch: fetchImpl = fetch, baseUrl } = options;
|
|
48
50
|
if (!baseUrl) {
|
|
49
51
|
const local = await localPack(lang);
|
|
50
52
|
if (local) return local;
|
|
51
|
-
|
|
53
|
+
throw new Error(
|
|
54
|
+
`lingotweaker-wasm: no locally installed lingotweaker-data-${lang} package; ` +
|
|
55
|
+
`serve the packs/ directory of the lingotweaker-data-${lang} npm package from your ` +
|
|
56
|
+
`server and pass its URL as the fetchPack baseUrl option`
|
|
57
|
+
);
|
|
52
58
|
}
|
|
53
59
|
const url = packUrl(lang, baseUrl);
|
|
54
60
|
const response = await fetchImpl(url);
|
|
@@ -75,4 +81,4 @@ export async function localPack(lang) {
|
|
|
75
81
|
} catch {
|
|
76
82
|
return null;
|
|
77
83
|
}
|
|
78
|
-
}
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingotweaker-wasm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "LingoTweaker proofreading engine compiled to WebAssembly (browser and Node)",
|
|
5
5
|
"license": "LGPL-2.1-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"module": "./web/lt_wasm.js",
|
|
23
23
|
"types": "./web/lt_wasm.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"lingotweaker-data": "0.2.
|
|
25
|
+
"lingotweaker-data": "0.2.3"
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"default": "./node/lt_wasm.js"
|
|
42
42
|
},
|
|
43
43
|
"./pack": {
|
|
44
|
+
"types": "./pack.d.ts",
|
|
44
45
|
"default": "./pack.js"
|
|
45
46
|
},
|
|
46
47
|
"./package.json": "./package.json"
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"web",
|
|
50
51
|
"node",
|
|
51
52
|
"pack.js",
|
|
53
|
+
"pack.d.ts",
|
|
52
54
|
"README.md"
|
|
53
55
|
],
|
|
54
56
|
"engines": {
|
package/web/lt_wasm.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An immutable engine loaded from a data pack.
|
|
6
|
+
*/
|
|
7
|
+
export class LtEngine {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Number of rules actively matched by the pattern engine.
|
|
12
|
+
*/
|
|
13
|
+
active_rule_count(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Check `text` and return the LT-shaped JSON of `CheckResult`.
|
|
16
|
+
*/
|
|
17
|
+
check_json(text: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Check `text` and return only the matches as JSON: `{"matches":[…]}`.
|
|
20
|
+
*
|
|
21
|
+
* The demo (and any UI that only renders issues) never needs the input
|
|
22
|
+
* text and per-sentence text spans that [`Self::check_json`] also
|
|
23
|
+
* serializes; for long paragraphs this JSON round-trip is a measurable
|
|
24
|
+
* share of the per-check latency.
|
|
25
|
+
*/
|
|
26
|
+
check_matches_json(text: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Rules that failed to compile, as `[{rule, error}, …]` JSON.
|
|
29
|
+
*/
|
|
30
|
+
compile_failures_json(): string;
|
|
31
|
+
/**
|
|
32
|
+
* The language code this engine was built for.
|
|
33
|
+
*/
|
|
34
|
+
lang(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Build an engine for `lang` (e.g. `en-US`, `gn-ES`) from `pack`.
|
|
37
|
+
*
|
|
38
|
+
* `options` is a JSON object; all fields are optional:
|
|
39
|
+
* `variant` (`en-GB`) selects variant resources, `today` (ISO date or
|
|
40
|
+
* timestamp) pins the date filters, and `picky`, `enabledRules`,
|
|
41
|
+
* `disabledRules`, `enabledCategories`, `disabledCategories`,
|
|
42
|
+
* `enabledOnly` configure rule selection.
|
|
43
|
+
*/
|
|
44
|
+
constructor(lang: string, pack: Uint8Array, options?: string | null);
|
|
45
|
+
/**
|
|
46
|
+
* Like [`LtEngine::new`] but built from several packs: the first is the
|
|
47
|
+
* base pack, later ones are sidecars (split packs: `en` base + optional
|
|
48
|
+
* `en.models`/`en-GB`-style variant dictionaries; reads fall through to
|
|
49
|
+
* the later packs). `packs` is a JS array of `Uint8Array`s.
|
|
50
|
+
*/
|
|
51
|
+
static new_multi(lang: string, packs: Uint8Array[], options?: string | null): LtEngine;
|
|
52
|
+
/**
|
|
53
|
+
* The variant override, if any.
|
|
54
|
+
*/
|
|
55
|
+
variant(): string | undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function start(): void;
|
|
59
|
+
|
|
60
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
61
|
+
|
|
62
|
+
export interface InitOutput {
|
|
63
|
+
readonly memory: WebAssembly.Memory;
|
|
64
|
+
readonly __wbg_ltengine_free: (a: number, b: number) => void;
|
|
65
|
+
readonly ltengine_active_rule_count: (a: number) => number;
|
|
66
|
+
readonly ltengine_check_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
67
|
+
readonly ltengine_check_matches_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
68
|
+
readonly ltengine_compile_failures_json: (a: number) => [number, number, number, number];
|
|
69
|
+
readonly ltengine_lang: (a: number) => [number, number];
|
|
70
|
+
readonly ltengine_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
71
|
+
readonly ltengine_new_multi: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
72
|
+
readonly ltengine_variant: (a: number) => [number, number];
|
|
73
|
+
readonly start: () => void;
|
|
74
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
75
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
76
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
77
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
78
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
79
|
+
readonly __externref_table_alloc: () => number;
|
|
80
|
+
readonly __wbindgen_start: () => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
87
|
+
* a precompiled `WebAssembly.Module`.
|
|
88
|
+
*
|
|
89
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
90
|
+
*
|
|
91
|
+
* @returns {InitOutput}
|
|
92
|
+
*/
|
|
93
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
97
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
98
|
+
*
|
|
99
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<InitOutput>}
|
|
102
|
+
*/
|
|
103
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/web/lt_wasm.js
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/* @ts-self-types="./lt_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An immutable engine loaded from a data pack.
|
|
5
|
+
*/
|
|
6
|
+
export class LtEngine {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(LtEngine.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
LtEngineFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
LtEngineFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_ltengine_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Number of rules actively matched by the pattern engine.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
active_rule_count() {
|
|
28
|
+
const ret = wasm.ltengine_active_rule_count(this.__wbg_ptr);
|
|
29
|
+
return ret >>> 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check `text` and return the LT-shaped JSON of `CheckResult`.
|
|
33
|
+
* @param {string} text
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
check_json(text) {
|
|
37
|
+
let deferred3_0;
|
|
38
|
+
let deferred3_1;
|
|
39
|
+
try {
|
|
40
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
const ret = wasm.ltengine_check_json(this.__wbg_ptr, ptr0, len0);
|
|
43
|
+
var ptr2 = ret[0];
|
|
44
|
+
var len2 = ret[1];
|
|
45
|
+
if (ret[3]) {
|
|
46
|
+
ptr2 = 0; len2 = 0;
|
|
47
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
48
|
+
}
|
|
49
|
+
deferred3_0 = ptr2;
|
|
50
|
+
deferred3_1 = len2;
|
|
51
|
+
return getStringFromWasm0(ptr2, len2);
|
|
52
|
+
} finally {
|
|
53
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check `text` and return only the matches as JSON: `{"matches":[…]}`.
|
|
58
|
+
*
|
|
59
|
+
* The demo (and any UI that only renders issues) never needs the input
|
|
60
|
+
* text and per-sentence text spans that [`Self::check_json`] also
|
|
61
|
+
* serializes; for long paragraphs this JSON round-trip is a measurable
|
|
62
|
+
* share of the per-check latency.
|
|
63
|
+
* @param {string} text
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
check_matches_json(text) {
|
|
67
|
+
let deferred3_0;
|
|
68
|
+
let deferred3_1;
|
|
69
|
+
try {
|
|
70
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
71
|
+
const len0 = WASM_VECTOR_LEN;
|
|
72
|
+
const ret = wasm.ltengine_check_matches_json(this.__wbg_ptr, ptr0, len0);
|
|
73
|
+
var ptr2 = ret[0];
|
|
74
|
+
var len2 = ret[1];
|
|
75
|
+
if (ret[3]) {
|
|
76
|
+
ptr2 = 0; len2 = 0;
|
|
77
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
78
|
+
}
|
|
79
|
+
deferred3_0 = ptr2;
|
|
80
|
+
deferred3_1 = len2;
|
|
81
|
+
return getStringFromWasm0(ptr2, len2);
|
|
82
|
+
} finally {
|
|
83
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Rules that failed to compile, as `[{rule, error}, …]` JSON.
|
|
88
|
+
* @returns {string}
|
|
89
|
+
*/
|
|
90
|
+
compile_failures_json() {
|
|
91
|
+
let deferred2_0;
|
|
92
|
+
let deferred2_1;
|
|
93
|
+
try {
|
|
94
|
+
const ret = wasm.ltengine_compile_failures_json(this.__wbg_ptr);
|
|
95
|
+
var ptr1 = ret[0];
|
|
96
|
+
var len1 = ret[1];
|
|
97
|
+
if (ret[3]) {
|
|
98
|
+
ptr1 = 0; len1 = 0;
|
|
99
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
100
|
+
}
|
|
101
|
+
deferred2_0 = ptr1;
|
|
102
|
+
deferred2_1 = len1;
|
|
103
|
+
return getStringFromWasm0(ptr1, len1);
|
|
104
|
+
} finally {
|
|
105
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The language code this engine was built for.
|
|
110
|
+
* @returns {string}
|
|
111
|
+
*/
|
|
112
|
+
lang() {
|
|
113
|
+
let deferred1_0;
|
|
114
|
+
let deferred1_1;
|
|
115
|
+
try {
|
|
116
|
+
const ret = wasm.ltengine_lang(this.__wbg_ptr);
|
|
117
|
+
deferred1_0 = ret[0];
|
|
118
|
+
deferred1_1 = ret[1];
|
|
119
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
120
|
+
} finally {
|
|
121
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build an engine for `lang` (e.g. `en-US`, `gn-ES`) from `pack`.
|
|
126
|
+
*
|
|
127
|
+
* `options` is a JSON object; all fields are optional:
|
|
128
|
+
* `variant` (`en-GB`) selects variant resources, `today` (ISO date or
|
|
129
|
+
* timestamp) pins the date filters, and `picky`, `enabledRules`,
|
|
130
|
+
* `disabledRules`, `enabledCategories`, `disabledCategories`,
|
|
131
|
+
* `enabledOnly` configure rule selection.
|
|
132
|
+
* @param {string} lang
|
|
133
|
+
* @param {Uint8Array} pack
|
|
134
|
+
* @param {string | null} [options]
|
|
135
|
+
*/
|
|
136
|
+
constructor(lang, pack, options) {
|
|
137
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
+
const len0 = WASM_VECTOR_LEN;
|
|
139
|
+
const ptr1 = passArray8ToWasm0(pack, wasm.__wbindgen_malloc);
|
|
140
|
+
const len1 = WASM_VECTOR_LEN;
|
|
141
|
+
var ptr2 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
var len2 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.ltengine_new(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
144
|
+
if (ret[2]) {
|
|
145
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
146
|
+
}
|
|
147
|
+
this.__wbg_ptr = ret[0];
|
|
148
|
+
LtEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Like [`LtEngine::new`] but built from several packs: the first is the
|
|
153
|
+
* base pack, later ones are sidecars (split packs: `en` base + optional
|
|
154
|
+
* `en.models`/`en-GB`-style variant dictionaries; reads fall through to
|
|
155
|
+
* the later packs). `packs` is a JS array of `Uint8Array`s.
|
|
156
|
+
* @param {string} lang
|
|
157
|
+
* @param {Uint8Array[]} packs
|
|
158
|
+
* @param {string | null} [options]
|
|
159
|
+
* @returns {LtEngine}
|
|
160
|
+
*/
|
|
161
|
+
static new_multi(lang, packs, options) {
|
|
162
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
163
|
+
const len0 = WASM_VECTOR_LEN;
|
|
164
|
+
const ptr1 = passArrayJsValueToWasm0(packs, wasm.__wbindgen_malloc);
|
|
165
|
+
const len1 = WASM_VECTOR_LEN;
|
|
166
|
+
var ptr2 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
167
|
+
var len2 = WASM_VECTOR_LEN;
|
|
168
|
+
const ret = wasm.ltengine_new_multi(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
169
|
+
if (ret[2]) {
|
|
170
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
171
|
+
}
|
|
172
|
+
return LtEngine.__wrap(ret[0]);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The variant override, if any.
|
|
176
|
+
* @returns {string | undefined}
|
|
177
|
+
*/
|
|
178
|
+
variant() {
|
|
179
|
+
const ret = wasm.ltengine_variant(this.__wbg_ptr);
|
|
180
|
+
let v1;
|
|
181
|
+
if (ret[0] !== 0) {
|
|
182
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
183
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
184
|
+
}
|
|
185
|
+
return v1;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (Symbol.dispose) LtEngine.prototype[Symbol.dispose] = LtEngine.prototype.free;
|
|
189
|
+
|
|
190
|
+
export function start() {
|
|
191
|
+
wasm.start();
|
|
192
|
+
}
|
|
193
|
+
function __wbg_get_imports() {
|
|
194
|
+
const import0 = {
|
|
195
|
+
__proto__: null,
|
|
196
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
197
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
198
|
+
return ret;
|
|
199
|
+
},
|
|
200
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
201
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
202
|
+
},
|
|
203
|
+
__wbg_error_757e9472f8410341: function(arg0, arg1) {
|
|
204
|
+
let deferred0_0;
|
|
205
|
+
let deferred0_1;
|
|
206
|
+
try {
|
|
207
|
+
deferred0_0 = arg0;
|
|
208
|
+
deferred0_1 = arg1;
|
|
209
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
210
|
+
} finally {
|
|
211
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
__wbg_length_31bdaf014f5fbde2: function(arg0) {
|
|
215
|
+
const ret = arg0.length;
|
|
216
|
+
return ret;
|
|
217
|
+
},
|
|
218
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
219
|
+
const ret = new Error();
|
|
220
|
+
return ret;
|
|
221
|
+
},
|
|
222
|
+
__wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
|
|
223
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
224
|
+
},
|
|
225
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
226
|
+
const ret = arg1.stack;
|
|
227
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
228
|
+
const len1 = WASM_VECTOR_LEN;
|
|
229
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
230
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
231
|
+
},
|
|
232
|
+
__wbindgen_init_externref_table: function() {
|
|
233
|
+
const table = wasm.__wbindgen_externrefs;
|
|
234
|
+
const offset = table.grow(4);
|
|
235
|
+
table.set(0, undefined);
|
|
236
|
+
table.set(offset + 0, undefined);
|
|
237
|
+
table.set(offset + 1, null);
|
|
238
|
+
table.set(offset + 2, true);
|
|
239
|
+
table.set(offset + 3, false);
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
return {
|
|
243
|
+
__proto__: null,
|
|
244
|
+
"./lt_wasm_bg.js": import0,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const LtEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
249
|
+
? { register: () => {}, unregister: () => {} }
|
|
250
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ltengine_free(ptr, 1));
|
|
251
|
+
|
|
252
|
+
function addToExternrefTable0(obj) {
|
|
253
|
+
const idx = wasm.__externref_table_alloc();
|
|
254
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
255
|
+
return idx;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
259
|
+
ptr = ptr >>> 0;
|
|
260
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
let cachedDataViewMemory0 = null;
|
|
264
|
+
function getDataViewMemory0() {
|
|
265
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
266
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
267
|
+
}
|
|
268
|
+
return cachedDataViewMemory0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function getStringFromWasm0(ptr, len) {
|
|
272
|
+
return decodeText(ptr >>> 0, len);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let cachedUint8ArrayMemory0 = null;
|
|
276
|
+
function getUint8ArrayMemory0() {
|
|
277
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
278
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
279
|
+
}
|
|
280
|
+
return cachedUint8ArrayMemory0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function isLikeNone(x) {
|
|
284
|
+
return x === undefined || x === null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
288
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
289
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
290
|
+
WASM_VECTOR_LEN = arg.length;
|
|
291
|
+
return ptr;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
295
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
296
|
+
for (let i = 0; i < array.length; i++) {
|
|
297
|
+
const add = addToExternrefTable0(array[i]);
|
|
298
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
299
|
+
}
|
|
300
|
+
WASM_VECTOR_LEN = array.length;
|
|
301
|
+
return ptr;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
305
|
+
if (realloc === undefined) {
|
|
306
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
307
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
308
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
309
|
+
WASM_VECTOR_LEN = buf.length;
|
|
310
|
+
return ptr;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
let len = arg.length;
|
|
314
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
315
|
+
|
|
316
|
+
const mem = getUint8ArrayMemory0();
|
|
317
|
+
|
|
318
|
+
let offset = 0;
|
|
319
|
+
|
|
320
|
+
for (; offset < len; offset++) {
|
|
321
|
+
const code = arg.charCodeAt(offset);
|
|
322
|
+
if (code > 0x7F) break;
|
|
323
|
+
mem[ptr + offset] = code;
|
|
324
|
+
}
|
|
325
|
+
if (offset !== len) {
|
|
326
|
+
if (offset !== 0) {
|
|
327
|
+
arg = arg.slice(offset);
|
|
328
|
+
}
|
|
329
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
330
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
331
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
332
|
+
|
|
333
|
+
offset += ret.written;
|
|
334
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
WASM_VECTOR_LEN = offset;
|
|
338
|
+
return ptr;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function takeFromExternrefTable0(idx) {
|
|
342
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
343
|
+
wasm.__externref_table_dealloc(idx);
|
|
344
|
+
return value;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
348
|
+
cachedTextDecoder.decode();
|
|
349
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
350
|
+
let numBytesDecoded = 0;
|
|
351
|
+
function decodeText(ptr, len) {
|
|
352
|
+
numBytesDecoded += len;
|
|
353
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
354
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
355
|
+
cachedTextDecoder.decode();
|
|
356
|
+
numBytesDecoded = len;
|
|
357
|
+
}
|
|
358
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const cachedTextEncoder = new TextEncoder();
|
|
362
|
+
|
|
363
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
364
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
365
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
366
|
+
view.set(buf);
|
|
367
|
+
return {
|
|
368
|
+
read: arg.length,
|
|
369
|
+
written: buf.length
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let WASM_VECTOR_LEN = 0;
|
|
375
|
+
|
|
376
|
+
let wasmModule, wasmInstance, wasm;
|
|
377
|
+
function __wbg_finalize_init(instance, module) {
|
|
378
|
+
wasmInstance = instance;
|
|
379
|
+
wasm = instance.exports;
|
|
380
|
+
wasmModule = module;
|
|
381
|
+
cachedDataViewMemory0 = null;
|
|
382
|
+
cachedUint8ArrayMemory0 = null;
|
|
383
|
+
wasm.__wbindgen_start();
|
|
384
|
+
return wasm;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async function __wbg_load(module, imports) {
|
|
388
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
389
|
+
if (!module.ok) {
|
|
390
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
394
|
+
try {
|
|
395
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
396
|
+
} catch (e) {
|
|
397
|
+
const validResponse = expectedResponseType(module.type);
|
|
398
|
+
|
|
399
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
400
|
+
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);
|
|
401
|
+
|
|
402
|
+
} else { throw e; }
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const bytes = await module.arrayBuffer();
|
|
407
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
408
|
+
} else {
|
|
409
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
410
|
+
|
|
411
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
412
|
+
return { instance, module };
|
|
413
|
+
} else {
|
|
414
|
+
return instance;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function expectedResponseType(type) {
|
|
419
|
+
switch (type) {
|
|
420
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
421
|
+
}
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function initSync(module) {
|
|
427
|
+
if (wasm !== undefined) return wasm;
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
if (module !== undefined) {
|
|
431
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
432
|
+
({module} = module)
|
|
433
|
+
} else {
|
|
434
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const imports = __wbg_get_imports();
|
|
439
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
440
|
+
module = new WebAssembly.Module(module);
|
|
441
|
+
}
|
|
442
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
443
|
+
return __wbg_finalize_init(instance, module);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
async function __wbg_init(module_or_path) {
|
|
447
|
+
if (wasm !== undefined) return wasm;
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
if (module_or_path !== undefined) {
|
|
451
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
452
|
+
({module_or_path} = module_or_path)
|
|
453
|
+
} else {
|
|
454
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (module_or_path === undefined) {
|
|
459
|
+
module_or_path = new URL('lt_wasm_bg.wasm', import.meta.url);
|
|
460
|
+
}
|
|
461
|
+
const imports = __wbg_get_imports();
|
|
462
|
+
|
|
463
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
464
|
+
module_or_path = fetch(module_or_path);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
468
|
+
|
|
469
|
+
return __wbg_finalize_init(instance, module);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_ltengine_free: (a: number, b: number) => void;
|
|
5
|
+
export const ltengine_active_rule_count: (a: number) => number;
|
|
6
|
+
export const ltengine_check_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
7
|
+
export const ltengine_check_matches_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
8
|
+
export const ltengine_compile_failures_json: (a: number) => [number, number, number, number];
|
|
9
|
+
export const ltengine_lang: (a: number) => [number, number];
|
|
10
|
+
export const ltengine_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
11
|
+
export const ltengine_new_multi: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
12
|
+
export const ltengine_variant: (a: number) => [number, number];
|
|
13
|
+
export const start: () => void;
|
|
14
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
18
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
19
|
+
export const __externref_table_alloc: () => number;
|
|
20
|
+
export const __wbindgen_start: () => void;
|
package/web/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|