usfm3 0.1.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 +15 -0
- package/usfm3_wasm.d.ts +84 -0
- package/usfm3_wasm.js +512 -0
- package/usfm3_wasm_bg.wasm +0 -0
package/package.json
ADDED
package/usfm3_wasm.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class ParseResult {
|
|
5
|
+
free(): void;
|
|
6
|
+
readonly diagnostics: Diagnostic[];
|
|
7
|
+
hasErrors(): boolean;
|
|
8
|
+
toUsj(): any;
|
|
9
|
+
toUsx(): string;
|
|
10
|
+
toUsfm(): string;
|
|
11
|
+
}
|
|
12
|
+
export function parse(usfm: string, options?: ParseOptions): ParseResult;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A diagnostic message with source location.
|
|
17
|
+
*/
|
|
18
|
+
export interface Diagnostic {
|
|
19
|
+
severity: Severity;
|
|
20
|
+
message: string;
|
|
21
|
+
code: DiagnosticCode;
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Machine-readable diagnostic code.
|
|
28
|
+
*/
|
|
29
|
+
export type DiagnosticCode = "UnknownMarker" | "UnclosedMarker" | "StrayCloseMarker" | "MisnestedMarker" | "MissingNestingPrefix" | "ImplicitClose" | "UnclosedNote" | "UnclosedAtEof" | "InvalidChapterSequence" | "InvalidVerseSequence" | "DuplicateChapter" | "DuplicateId" | "MissingIdMarker" | "InvalidBookCode" | "NoteSubmarkerOutsideNote" | "TextBeforeId" | "HeaderAfterBody" | "MilestoneMismatch" | "InvalidAttributes" | "MissingChapterNumber" | "MissingVerseNumber" | "MissingChapterMarker" | "CharCrossesVerseBoundary" | "EmptyFigure" | "UnquotedAttributeValue" | "MissingRequiredAttribute" | "DefaultAttributeNotDefined" | "BodyParagraphBeforeChapter" | "NonEmptyBlankLine" | "LeadingZeros" | "EmptyWordMarker" | "MissingMilestoneSelfClose";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Options for the `parse` function.
|
|
33
|
+
*/
|
|
34
|
+
export interface ParseOptions {
|
|
35
|
+
validate?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Severity level for diagnostics.
|
|
40
|
+
*/
|
|
41
|
+
export type Severity = "error" | "warning" | "info";
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
45
|
+
|
|
46
|
+
export interface InitOutput {
|
|
47
|
+
readonly memory: WebAssembly.Memory;
|
|
48
|
+
readonly __wbg_parseresult_free: (a: number, b: number) => void;
|
|
49
|
+
readonly parse: (a: number, b: number, c: number) => [number, number, number];
|
|
50
|
+
readonly parseresult_diagnostics: (a: number) => any;
|
|
51
|
+
readonly parseresult_hasErrors: (a: number) => number;
|
|
52
|
+
readonly parseresult_toUsfm: (a: number) => [number, number];
|
|
53
|
+
readonly parseresult_toUsj: (a: number) => [number, number, number];
|
|
54
|
+
readonly parseresult_toUsx: (a: number) => [number, number, number, number];
|
|
55
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
56
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
57
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
58
|
+
readonly __externref_table_alloc: () => number;
|
|
59
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
60
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
61
|
+
readonly __wbindgen_start: () => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
68
|
+
* a precompiled `WebAssembly.Module`.
|
|
69
|
+
*
|
|
70
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
71
|
+
*
|
|
72
|
+
* @returns {InitOutput}
|
|
73
|
+
*/
|
|
74
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
78
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
79
|
+
*
|
|
80
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<InitOutput>}
|
|
83
|
+
*/
|
|
84
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/usfm3_wasm.js
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
/* @ts-self-types="./usfm3_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
export class ParseResult {
|
|
4
|
+
static __wrap(ptr) {
|
|
5
|
+
ptr = ptr >>> 0;
|
|
6
|
+
const obj = Object.create(ParseResult.prototype);
|
|
7
|
+
obj.__wbg_ptr = ptr;
|
|
8
|
+
ParseResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
__destroy_into_raw() {
|
|
12
|
+
const ptr = this.__wbg_ptr;
|
|
13
|
+
this.__wbg_ptr = 0;
|
|
14
|
+
ParseResultFinalization.unregister(this);
|
|
15
|
+
return ptr;
|
|
16
|
+
}
|
|
17
|
+
free() {
|
|
18
|
+
const ptr = this.__destroy_into_raw();
|
|
19
|
+
wasm.__wbg_parseresult_free(ptr, 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the diagnostics array.
|
|
23
|
+
* @returns {any}
|
|
24
|
+
*/
|
|
25
|
+
get diagnostics() {
|
|
26
|
+
const ret = wasm.parseresult_diagnostics(this.__wbg_ptr);
|
|
27
|
+
return ret;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* True if any diagnostics have Error severity.
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
33
|
+
hasErrors() {
|
|
34
|
+
const ret = wasm.parseresult_hasErrors(this.__wbg_ptr);
|
|
35
|
+
return ret !== 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Serialize the parsed document to normalized USFM.
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
toUsfm() {
|
|
42
|
+
let deferred1_0;
|
|
43
|
+
let deferred1_1;
|
|
44
|
+
try {
|
|
45
|
+
const ret = wasm.parseresult_toUsfm(this.__wbg_ptr);
|
|
46
|
+
deferred1_0 = ret[0];
|
|
47
|
+
deferred1_1 = ret[1];
|
|
48
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
49
|
+
} finally {
|
|
50
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Serialize the parsed document to USJ (Unified Scripture JSON).
|
|
55
|
+
* @returns {any}
|
|
56
|
+
*/
|
|
57
|
+
toUsj() {
|
|
58
|
+
const ret = wasm.parseresult_toUsj(this.__wbg_ptr);
|
|
59
|
+
if (ret[2]) {
|
|
60
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
61
|
+
}
|
|
62
|
+
return takeFromExternrefTable0(ret[0]);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Serialize the parsed document to USX XML.
|
|
66
|
+
* @returns {string}
|
|
67
|
+
*/
|
|
68
|
+
toUsx() {
|
|
69
|
+
let deferred2_0;
|
|
70
|
+
let deferred2_1;
|
|
71
|
+
try {
|
|
72
|
+
const ret = wasm.parseresult_toUsx(this.__wbg_ptr);
|
|
73
|
+
var ptr1 = ret[0];
|
|
74
|
+
var len1 = ret[1];
|
|
75
|
+
if (ret[3]) {
|
|
76
|
+
ptr1 = 0; len1 = 0;
|
|
77
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
78
|
+
}
|
|
79
|
+
deferred2_0 = ptr1;
|
|
80
|
+
deferred2_1 = len1;
|
|
81
|
+
return getStringFromWasm0(ptr1, len1);
|
|
82
|
+
} finally {
|
|
83
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (Symbol.dispose) ParseResult.prototype[Symbol.dispose] = ParseResult.prototype.free;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} usfm
|
|
91
|
+
* @param {ParseOptions | null} [options]
|
|
92
|
+
* @returns {ParseResult}
|
|
93
|
+
*/
|
|
94
|
+
export function parse(usfm, options) {
|
|
95
|
+
const ptr0 = passStringToWasm0(usfm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
96
|
+
const len0 = WASM_VECTOR_LEN;
|
|
97
|
+
const ret = wasm.parse(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
98
|
+
if (ret[2]) {
|
|
99
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
100
|
+
}
|
|
101
|
+
return ParseResult.__wrap(ret[0]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function __wbg_get_imports() {
|
|
105
|
+
const import0 = {
|
|
106
|
+
__proto__: null,
|
|
107
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
108
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
109
|
+
return ret;
|
|
110
|
+
},
|
|
111
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
112
|
+
const ret = String(arg1);
|
|
113
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
114
|
+
const len1 = WASM_VECTOR_LEN;
|
|
115
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
116
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
117
|
+
},
|
|
118
|
+
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
119
|
+
const v = arg0;
|
|
120
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
121
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
122
|
+
},
|
|
123
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
124
|
+
const ret = debugString(arg1);
|
|
125
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
126
|
+
const len1 = WASM_VECTOR_LEN;
|
|
127
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
128
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
129
|
+
},
|
|
130
|
+
__wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
|
|
131
|
+
const ret = arg0 in arg1;
|
|
132
|
+
return ret;
|
|
133
|
+
},
|
|
134
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
135
|
+
const val = arg0;
|
|
136
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
137
|
+
return ret;
|
|
138
|
+
},
|
|
139
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
140
|
+
const ret = arg0 === undefined;
|
|
141
|
+
return ret;
|
|
142
|
+
},
|
|
143
|
+
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
144
|
+
const ret = arg0 == arg1;
|
|
145
|
+
return ret;
|
|
146
|
+
},
|
|
147
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
148
|
+
const obj = arg1;
|
|
149
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
150
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
151
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
152
|
+
},
|
|
153
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
154
|
+
const obj = arg1;
|
|
155
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
156
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
|
+
var len1 = WASM_VECTOR_LEN;
|
|
158
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
159
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
160
|
+
},
|
|
161
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
162
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
163
|
+
},
|
|
164
|
+
__wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
|
|
165
|
+
const ret = arg0[arg1];
|
|
166
|
+
return ret;
|
|
167
|
+
},
|
|
168
|
+
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
169
|
+
let result;
|
|
170
|
+
try {
|
|
171
|
+
result = arg0 instanceof ArrayBuffer;
|
|
172
|
+
} catch (_) {
|
|
173
|
+
result = false;
|
|
174
|
+
}
|
|
175
|
+
const ret = result;
|
|
176
|
+
return ret;
|
|
177
|
+
},
|
|
178
|
+
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
179
|
+
let result;
|
|
180
|
+
try {
|
|
181
|
+
result = arg0 instanceof Uint8Array;
|
|
182
|
+
} catch (_) {
|
|
183
|
+
result = false;
|
|
184
|
+
}
|
|
185
|
+
const ret = result;
|
|
186
|
+
return ret;
|
|
187
|
+
},
|
|
188
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
189
|
+
const ret = arg0.length;
|
|
190
|
+
return ret;
|
|
191
|
+
},
|
|
192
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
193
|
+
const ret = new Object();
|
|
194
|
+
return ret;
|
|
195
|
+
},
|
|
196
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
197
|
+
const ret = new Array();
|
|
198
|
+
return ret;
|
|
199
|
+
},
|
|
200
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
201
|
+
const ret = new Uint8Array(arg0);
|
|
202
|
+
return ret;
|
|
203
|
+
},
|
|
204
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
205
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
206
|
+
},
|
|
207
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
208
|
+
arg0[arg1] = arg2;
|
|
209
|
+
},
|
|
210
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
211
|
+
arg0[arg1 >>> 0] = arg2;
|
|
212
|
+
},
|
|
213
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
214
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
215
|
+
const ret = arg0;
|
|
216
|
+
return ret;
|
|
217
|
+
},
|
|
218
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
219
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
220
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
221
|
+
return ret;
|
|
222
|
+
},
|
|
223
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
224
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
225
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
226
|
+
return ret;
|
|
227
|
+
},
|
|
228
|
+
__wbindgen_init_externref_table: function() {
|
|
229
|
+
const table = wasm.__wbindgen_externrefs;
|
|
230
|
+
const offset = table.grow(4);
|
|
231
|
+
table.set(0, undefined);
|
|
232
|
+
table.set(offset + 0, undefined);
|
|
233
|
+
table.set(offset + 1, null);
|
|
234
|
+
table.set(offset + 2, true);
|
|
235
|
+
table.set(offset + 3, false);
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
__proto__: null,
|
|
240
|
+
"./usfm3_wasm_bg.js": import0,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const ParseResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
245
|
+
? { register: () => {}, unregister: () => {} }
|
|
246
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_parseresult_free(ptr >>> 0, 1));
|
|
247
|
+
|
|
248
|
+
function addToExternrefTable0(obj) {
|
|
249
|
+
const idx = wasm.__externref_table_alloc();
|
|
250
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
251
|
+
return idx;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function debugString(val) {
|
|
255
|
+
// primitive types
|
|
256
|
+
const type = typeof val;
|
|
257
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
258
|
+
return `${val}`;
|
|
259
|
+
}
|
|
260
|
+
if (type == 'string') {
|
|
261
|
+
return `"${val}"`;
|
|
262
|
+
}
|
|
263
|
+
if (type == 'symbol') {
|
|
264
|
+
const description = val.description;
|
|
265
|
+
if (description == null) {
|
|
266
|
+
return 'Symbol';
|
|
267
|
+
} else {
|
|
268
|
+
return `Symbol(${description})`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (type == 'function') {
|
|
272
|
+
const name = val.name;
|
|
273
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
274
|
+
return `Function(${name})`;
|
|
275
|
+
} else {
|
|
276
|
+
return 'Function';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// objects
|
|
280
|
+
if (Array.isArray(val)) {
|
|
281
|
+
const length = val.length;
|
|
282
|
+
let debug = '[';
|
|
283
|
+
if (length > 0) {
|
|
284
|
+
debug += debugString(val[0]);
|
|
285
|
+
}
|
|
286
|
+
for(let i = 1; i < length; i++) {
|
|
287
|
+
debug += ', ' + debugString(val[i]);
|
|
288
|
+
}
|
|
289
|
+
debug += ']';
|
|
290
|
+
return debug;
|
|
291
|
+
}
|
|
292
|
+
// Test for built-in
|
|
293
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
294
|
+
let className;
|
|
295
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
296
|
+
className = builtInMatches[1];
|
|
297
|
+
} else {
|
|
298
|
+
// Failed to match the standard '[object ClassName]'
|
|
299
|
+
return toString.call(val);
|
|
300
|
+
}
|
|
301
|
+
if (className == 'Object') {
|
|
302
|
+
// we're a user defined class or Object
|
|
303
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
304
|
+
// easier than looping through ownProperties of `val`.
|
|
305
|
+
try {
|
|
306
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
307
|
+
} catch (_) {
|
|
308
|
+
return 'Object';
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// errors
|
|
312
|
+
if (val instanceof Error) {
|
|
313
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
314
|
+
}
|
|
315
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
316
|
+
return className;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
320
|
+
ptr = ptr >>> 0;
|
|
321
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
let cachedDataViewMemory0 = null;
|
|
325
|
+
function getDataViewMemory0() {
|
|
326
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
327
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
328
|
+
}
|
|
329
|
+
return cachedDataViewMemory0;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function getStringFromWasm0(ptr, len) {
|
|
333
|
+
ptr = ptr >>> 0;
|
|
334
|
+
return decodeText(ptr, len);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let cachedUint8ArrayMemory0 = null;
|
|
338
|
+
function getUint8ArrayMemory0() {
|
|
339
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
340
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
341
|
+
}
|
|
342
|
+
return cachedUint8ArrayMemory0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function isLikeNone(x) {
|
|
346
|
+
return x === undefined || x === null;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
350
|
+
if (realloc === undefined) {
|
|
351
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
352
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
353
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
354
|
+
WASM_VECTOR_LEN = buf.length;
|
|
355
|
+
return ptr;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
let len = arg.length;
|
|
359
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
360
|
+
|
|
361
|
+
const mem = getUint8ArrayMemory0();
|
|
362
|
+
|
|
363
|
+
let offset = 0;
|
|
364
|
+
|
|
365
|
+
for (; offset < len; offset++) {
|
|
366
|
+
const code = arg.charCodeAt(offset);
|
|
367
|
+
if (code > 0x7F) break;
|
|
368
|
+
mem[ptr + offset] = code;
|
|
369
|
+
}
|
|
370
|
+
if (offset !== len) {
|
|
371
|
+
if (offset !== 0) {
|
|
372
|
+
arg = arg.slice(offset);
|
|
373
|
+
}
|
|
374
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
375
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
376
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
377
|
+
|
|
378
|
+
offset += ret.written;
|
|
379
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
WASM_VECTOR_LEN = offset;
|
|
383
|
+
return ptr;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function takeFromExternrefTable0(idx) {
|
|
387
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
388
|
+
wasm.__externref_table_dealloc(idx);
|
|
389
|
+
return value;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
393
|
+
cachedTextDecoder.decode();
|
|
394
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
395
|
+
let numBytesDecoded = 0;
|
|
396
|
+
function decodeText(ptr, len) {
|
|
397
|
+
numBytesDecoded += len;
|
|
398
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
399
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
400
|
+
cachedTextDecoder.decode();
|
|
401
|
+
numBytesDecoded = len;
|
|
402
|
+
}
|
|
403
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const cachedTextEncoder = new TextEncoder();
|
|
407
|
+
|
|
408
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
409
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
410
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
411
|
+
view.set(buf);
|
|
412
|
+
return {
|
|
413
|
+
read: arg.length,
|
|
414
|
+
written: buf.length
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
let WASM_VECTOR_LEN = 0;
|
|
420
|
+
|
|
421
|
+
let wasmModule, wasm;
|
|
422
|
+
function __wbg_finalize_init(instance, module) {
|
|
423
|
+
wasm = instance.exports;
|
|
424
|
+
wasmModule = module;
|
|
425
|
+
cachedDataViewMemory0 = null;
|
|
426
|
+
cachedUint8ArrayMemory0 = null;
|
|
427
|
+
wasm.__wbindgen_start();
|
|
428
|
+
return wasm;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function __wbg_load(module, imports) {
|
|
432
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
433
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
434
|
+
try {
|
|
435
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
436
|
+
} catch (e) {
|
|
437
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
438
|
+
|
|
439
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
440
|
+
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);
|
|
441
|
+
|
|
442
|
+
} else { throw e; }
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const bytes = await module.arrayBuffer();
|
|
447
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
448
|
+
} else {
|
|
449
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
450
|
+
|
|
451
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
452
|
+
return { instance, module };
|
|
453
|
+
} else {
|
|
454
|
+
return instance;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function expectedResponseType(type) {
|
|
459
|
+
switch (type) {
|
|
460
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
461
|
+
}
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function initSync(module) {
|
|
467
|
+
if (wasm !== undefined) return wasm;
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
if (module !== undefined) {
|
|
471
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
472
|
+
({module} = module)
|
|
473
|
+
} else {
|
|
474
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const imports = __wbg_get_imports();
|
|
479
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
480
|
+
module = new WebAssembly.Module(module);
|
|
481
|
+
}
|
|
482
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
483
|
+
return __wbg_finalize_init(instance, module);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async function __wbg_init(module_or_path) {
|
|
487
|
+
if (wasm !== undefined) return wasm;
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
if (module_or_path !== undefined) {
|
|
491
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
492
|
+
({module_or_path} = module_or_path)
|
|
493
|
+
} else {
|
|
494
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (module_or_path === undefined) {
|
|
499
|
+
module_or_path = new URL('usfm3_wasm_bg.wasm', import.meta.url);
|
|
500
|
+
}
|
|
501
|
+
const imports = __wbg_get_imports();
|
|
502
|
+
|
|
503
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
504
|
+
module_or_path = fetch(module_or_path);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
508
|
+
|
|
509
|
+
return __wbg_finalize_init(instance, module);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|