-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.js
More file actions
310 lines (305 loc) · 8.42 KB
/
lib.js
File metadata and controls
310 lines (305 loc) · 8.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
var Module = typeof Module !== 'undefined' ? Module : {};
var moduleOverrides = {};
var key;
for (key in Module) {
if (Module.hasOwnProperty(key)) {
moduleOverrides[key] = Module[key];
}
}
var arguments_ = [];
var err = Module['printErr'] || console.warn.bind(console);
for (key in moduleOverrides) {
if (moduleOverrides.hasOwnProperty(key)) {
Module[key] = moduleOverrides[key];
}
}
moduleOverrides = null;
if (Module['arguments']) arguments_ = Module['arguments'];
if (Module['thisProgram']) thisProgram = Module['thisProgram'];
if (Module['quit']) quit_ = Module['quit'];
var tempRet0 = 0;
var setTempRet0 = function (value) {
tempRet0 = value;
};
if (typeof WebAssembly !== 'object') {
abort('no native wasm support detected');
}
var wasmMemory;
var ABORT = false;
function assert(condition, text) {
if (!condition) {
abort('Assertion failed: ' + text);
}
}
function alignUp(x, multiple) {
if (x % multiple > 0) {
x += multiple - (x % multiple);
}
return x;
}
var buffer, HEAPU8;
function updateGlobalBufferAndViews(buf) {
buffer = buf;
Module['HEAP8'] = new Int8Array(buf);
Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf);
}
var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216;
var wasmTable;
var __ATPRERUN__ = [];
var __ATINIT__ = [];
var __ATPOSTRUN__ = [];
var runtimeInitialized = false;
function preRun() {
if (Module['preRun']) {
if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
while (Module['preRun'].length) {
addOnPreRun(Module['preRun'].shift());
}
}
callRuntimeCallbacks(__ATPRERUN__);
}
function initRuntime() {
runtimeInitialized = true;
callRuntimeCallbacks(__ATINIT__);
}
function postRun() {
if (Module['postRun']) {
if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
while (Module['postRun'].length) {
addOnPostRun(Module['postRun'].shift());
}
}
callRuntimeCallbacks(__ATPOSTRUN__);
}
function addOnPreRun(cb) {
__ATPRERUN__.unshift(cb);
}
function addOnInit(cb) {
__ATINIT__.unshift(cb);
}
function addOnPostRun(cb) {
__ATPOSTRUN__.unshift(cb);
}
let runDependencies = 0;
let runDependencyWatcher = null;
let dependenciesFulfilled = null;
function addRunDependency(id) {
runDependencies++;
if (Module['monitorRunDependencies']) {
Module['monitorRunDependencies'](runDependencies);
}
}
function removeRunDependency(id) {
runDependencies--;
if (Module['monitorRunDependencies']) {
Module['monitorRunDependencies'](runDependencies);
}
if (runDependencies == 0) {
if (runDependencyWatcher !== null) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null;
}
if (dependenciesFulfilled) {
const callback = dependenciesFulfilled;
dependenciesFulfilled = null;
callback();
}
}
}
Module['preloadedImages'] = {};
Module['preloadedAudios'] = {};
function abort(what) {
if (Module['onAbort']) {
Module['onAbort'](what);
}
what += '';
err(what);
ABORT = true;
var EXITSTATUS = 1;
what = 'abort(' + what + ').';
// const e = new WebAssembly.RuntimeError(what);
// throw e;
}
function getBinaryPromise(url) {
return fetch(url, { credentials: 'same-origin' }).then(function (response) {
if (!response['ok']) {
throw "failed to load wasm binary file at '" + url + "'";
}
return response['arrayBuffer']();
});
}
function init(filePathOrBuf) {
const info = { a: asmLibraryArg };
function receiveInstance(instance, module) {
const exports = instance.exports;
Module['asm'] = exports;
wasmMemory = Module['asm']['c'];
updateGlobalBufferAndViews(wasmMemory.buffer);
wasmTable = Module['asm']['l'];
addOnInit(Module['asm']['d']);
removeRunDependency('wasm-instantiate');
}
addRunDependency('wasm-instantiate');
function receiveInstantiationResult(result) {
receiveInstance(result['instance']);
}
function instantiateArrayBuffer(receiver) {
return getBinaryPromise(filePathOrBuf).then(function (binary) {
const result = WebAssembly.instantiate(binary, info);
return result;
})
.then(receiver, function (reason) {
err('failed to asynchronously prepare wasm: ' + reason);
abort(reason);
});
}
function instantiateAsync() {
if (filePathOrBuf && filePathOrBuf.byteLength > 0) {
return WebAssembly.instantiate(filePathOrBuf, info).then(receiveInstantiationResult, function (reason) {
err('wasm compile failed: ' + reason);
});
} else if (
typeof WebAssembly.instantiateStreaming === 'function' &&
typeof filePathOrBuf === 'string' &&
typeof fetch === 'function'
) {
return fetch(filePathOrBuf, { credentials: 'same-origin' }).then(function (response) {
const result = WebAssembly.instantiateStreaming(response, info);
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason);
err('falling back to ArrayBuffer instantiation');
return instantiateArrayBuffer(receiveInstantiationResult);
});
});
} else {
return instantiateArrayBuffer(receiveInstantiationResult);
}
}
if (Module['instantiateWasm']) {
try {
var exports = Module['instantiateWasm'](info, receiveInstance);
return exports;
} catch (e) {
err('Module.instantiateWasm callback failed with error: ' + e);
return false;
}
}
instantiateAsync();
return {};
}
function callRuntimeCallbacks(callbacks) {
while (callbacks.length > 0) {
const callback = callbacks.shift();
if (typeof callback == 'function') {
callback(Module);
continue;
}
const func = callback.func;
if (typeof func === 'number') {
if (callback.arg === undefined) {
wasmTable.get(func)();
} else {
wasmTable.get(func)(callback.arg);
}
} else {
func(callback.arg === undefined ? null : callback.arg);
}
}
}
function emscripten_realloc_buffer(size) {
try {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16);
updateGlobalBufferAndViews(wasmMemory.buffer);
return 1;
} catch (e) {}
}
function _emscripten_resize_heap(requestedSize) {
const oldSize = HEAPU8.length;
requestedSize = requestedSize >>> 0;
const maxHeapSize = 2147483648;
if (requestedSize > maxHeapSize) {
return false;
}
for (let cutDown = 1; cutDown <= 4; cutDown *= 2) {
let overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
const newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
const replacement = emscripten_realloc_buffer(newSize);
if (replacement) {
return true;
}
}
return false;
}
function _setTempRet0(val) {
setTempRet0(val);
}
const asmLibraryArg = { a: _emscripten_resize_heap, b: _setTempRet0 };
Module['___wasm_call_ctors'] = function () {
return (Module['___wasm_call_ctors'] = Module['asm']['d']).apply(null, arguments);
};
Module['_malloc'] = function () {
return (Module['_malloc'] = Module['asm']['e']).apply(null, arguments);
};
Module['_free'] = function () {
return (Module['_free'] = Module['asm']['f']).apply(null, arguments);
};
Module['_ZSTD_isError'] = function () {
return (Module['_ZSTD_isError'] = Module['asm']['g']).apply(null, arguments);
};
Module['_ZSTD_compressBound'] = function () {
return (Module['_ZSTD_compressBound'] = Module['asm']['h']).apply(null, arguments);
};
Module['_ZSTD_compress'] = function () {
return (Module['_ZSTD_compress'] = Module['asm']['i']).apply(null, arguments);
};
Module['_ZSTD_getFrameContentSize'] = function () {
return (Module['_ZSTD_getFrameContentSize'] = Module['asm']['j']).apply(null, arguments);
};
Module['_ZSTD_decompress'] = function () {
return (Module['_ZSTD_decompress'] = Module['asm']['k']).apply(null, arguments);
};
let calledRun;
dependenciesFulfilled = function runCaller() {
if (!calledRun) run();
if (!calledRun) dependenciesFulfilled = runCaller;
};
function run(args) {
args = args || arguments_;
if (runDependencies > 0) {
return;
}
preRun();
if (runDependencies > 0) {
return;
}
function doRun() {
if (calledRun) return;
calledRun = true;
Module['calledRun'] = true;
if (ABORT) return;
initRuntime();
if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
postRun();
}
if (Module['setStatus']) {
Module['setStatus']('Running...');
setTimeout(function () {
setTimeout(function () {
Module['setStatus']('');
}, 1);
doRun();
}, 1);
} else {
doRun();
}
}
Module['run'] = run;
if (Module['preInit']) {
if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
while (Module['preInit'].length > 0) {
Module['preInit'].pop()();
}
}
Module['init'] = init;
export { Module };