Guest User

Untitled

a guest
Apr 7th, 2019
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 270.77 KB | None | 0 0
  1. var Module = (function() {
  2. var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
  3. return (
  4. function(Module) {
  5. Module = Module || {};
  6.  
  7. var Module = typeof Module !== "undefined" ? Module : {};
  8. var moduleOverrides = {};
  9. var key;
  10. for (key in Module) {
  11. if (Module.hasOwnProperty(key)) {
  12. moduleOverrides[key] = Module[key]
  13. }
  14. }
  15. Module["arguments"] = [];
  16. Module["thisProgram"] = "./this.program";
  17. Module["quit"] = function(status, toThrow) {
  18. throw toThrow
  19. };
  20. Module["preRun"] = [];
  21. Module["postRun"] = [];
  22. var ENVIRONMENT_IS_WEB = false;
  23. var ENVIRONMENT_IS_WORKER = false;
  24. var ENVIRONMENT_IS_NODE = false;
  25. var ENVIRONMENT_IS_SHELL = false;
  26. ENVIRONMENT_IS_WEB = typeof window === "object";
  27. ENVIRONMENT_IS_WORKER = typeof importScripts === "function";
  28. ENVIRONMENT_IS_NODE = typeof process === "object" && typeof require === "function" && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER;
  29. ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
  30. var scriptDirectory = "";
  31.  
  32. function locateFile(path) {
  33. if (Module["locateFile"]) {
  34. return Module["locateFile"](path, scriptDirectory)
  35. } else {
  36. return scriptDirectory + path
  37. }
  38. }
  39. if (ENVIRONMENT_IS_NODE) {
  40. scriptDirectory = __dirname + "/";
  41. var nodeFS;
  42. var nodePath;
  43. Module["read"] = function shell_read(filename, binary) {
  44. var ret;
  45. if (!nodeFS) nodeFS = require("fs");
  46. if (!nodePath) nodePath = require("path");
  47. filename = nodePath["normalize"](filename);
  48. ret = nodeFS["readFileSync"](filename);
  49. return binary ? ret : ret.toString()
  50. };
  51. Module["readBinary"] = function readBinary(filename) {
  52. var ret = Module["read"](filename, true);
  53. if (!ret.buffer) {
  54. ret = new Uint8Array(ret)
  55. }
  56. assert(ret.buffer);
  57. return ret
  58. };
  59. if (process["argv"].length > 1) {
  60. Module["thisProgram"] = process["argv"][1].replace(/\\/g, "/")
  61. }
  62. Module["arguments"] = process["argv"].slice(2);
  63. process["on"]("uncaughtException", function(ex) {
  64. if (!(ex instanceof ExitStatus)) {
  65. throw ex
  66. }
  67. });
  68. process["on"]("unhandledRejection", abort);
  69. Module["quit"] = function(status) {
  70. process["exit"](status)
  71. };
  72. Module["inspect"] = function() {
  73. return "[Emscripten Module object]"
  74. }
  75. } else if (ENVIRONMENT_IS_SHELL) {
  76. if (typeof read != "undefined") {
  77. Module["read"] = function shell_read(f) {
  78. return read(f)
  79. }
  80. }
  81. Module["readBinary"] = function readBinary(f) {
  82. var data;
  83. if (typeof readbuffer === "function") {
  84. return new Uint8Array(readbuffer(f))
  85. }
  86. data = read(f, "binary");
  87. assert(typeof data === "object");
  88. return data
  89. };
  90. if (typeof scriptArgs != "undefined") {
  91. Module["arguments"] = scriptArgs
  92. } else if (typeof arguments != "undefined") {
  93. Module["arguments"] = arguments
  94. }
  95. if (typeof quit === "function") {
  96. Module["quit"] = function(status) {
  97. quit(status)
  98. }
  99. }
  100. } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
  101. if (ENVIRONMENT_IS_WORKER) {
  102. scriptDirectory = self.location.href
  103. } else if (document.currentScript) {
  104. scriptDirectory = document.currentScript.src
  105. }
  106. if (_scriptDir) {
  107. scriptDirectory = _scriptDir
  108. }
  109. if (scriptDirectory.indexOf("blob:") !== 0) {
  110. scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1)
  111. } else {
  112. scriptDirectory = ""
  113. }
  114. Module["read"] = function shell_read(url) {
  115. var xhr = new XMLHttpRequest;
  116. xhr.open("GET", url, false);
  117. xhr.send(null);
  118. return xhr.responseText
  119. };
  120. if (ENVIRONMENT_IS_WORKER) {
  121. Module["readBinary"] = function readBinary(url) {
  122. var xhr = new XMLHttpRequest;
  123. xhr.open("GET", url, false);
  124. xhr.responseType = "arraybuffer";
  125. xhr.send(null);
  126. return new Uint8Array(xhr.response)
  127. }
  128. }
  129. Module["readAsync"] = function readAsync(url, onload, onerror) {
  130. var xhr = new XMLHttpRequest;
  131. xhr.open("GET", url, true);
  132. xhr.responseType = "arraybuffer";
  133. xhr.onload = function xhr_onload() {
  134. if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
  135. onload(xhr.response);
  136. return
  137. }
  138. onerror()
  139. };
  140. xhr.onerror = onerror;
  141. xhr.send(null)
  142. };
  143. Module["setWindowTitle"] = function(title) {
  144. document.title = title
  145. }
  146. } else {}
  147. var out = Module["print"] || (typeof console !== "undefined" ? console.log.bind(console) : typeof print !== "undefined" ? print : null);
  148. var err = Module["printErr"] || (typeof printErr !== "undefined" ? printErr : typeof console !== "undefined" && console.warn.bind(console) || out);
  149. for (key in moduleOverrides) {
  150. if (moduleOverrides.hasOwnProperty(key)) {
  151. Module[key] = moduleOverrides[key]
  152. }
  153. }
  154. moduleOverrides = undefined;
  155.  
  156. function dynamicAlloc(size) {
  157. var ret = HEAP32[DYNAMICTOP_PTR >> 2];
  158. var end = ret + size + 15 & -16;
  159. if (end <= _emscripten_get_heap_size()) {
  160. HEAP32[DYNAMICTOP_PTR >> 2] = end
  161. } else {
  162. return 0
  163. }
  164. return ret
  165. }
  166.  
  167. function getNativeTypeSize(type) {
  168. switch (type) {
  169. case "i1":
  170. case "i8":
  171. return 1;
  172. case "i16":
  173. return 2;
  174. case "i32":
  175. return 4;
  176. case "i64":
  177. return 8;
  178. case "float":
  179. return 4;
  180. case "double":
  181. return 8;
  182. default:
  183. {
  184. if (type[type.length - 1] === "*") {
  185. return 4
  186. } else if (type[0] === "i") {
  187. var bits = parseInt(type.substr(1));
  188. assert(bits % 8 === 0, "getNativeTypeSize invalid bits " + bits + ", type " + type);
  189. return bits / 8
  190. } else {
  191. return 0
  192. }
  193. }
  194. }
  195. }
  196. var asm2wasmImports = {
  197. "f64-rem": function(x, y) {
  198. return x % y
  199. },
  200. "debugger": function() {
  201. debugger
  202. }
  203. };
  204. var functionPointers = new Array(0);
  205. if (typeof WebAssembly !== "object") {
  206. err("no native wasm support detected")
  207. }
  208. var wasmMemory;
  209. var wasmTable;
  210. var ABORT = false;
  211. var EXITSTATUS = 0;
  212.  
  213. function assert(condition, text) {
  214. if (!condition) {
  215. abort("Assertion failed: " + text)
  216. }
  217. }
  218.  
  219. function setValue(ptr, value, type, noSafe) {
  220. type = type || "i8";
  221. if (type.charAt(type.length - 1) === "*") type = "i32";
  222. switch (type) {
  223. case "i1":
  224. HEAP8[ptr >> 0] = value;
  225. break;
  226. case "i8":
  227. HEAP8[ptr >> 0] = value;
  228. break;
  229. case "i16":
  230. HEAP16[ptr >> 1] = value;
  231. break;
  232. case "i32":
  233. HEAP32[ptr >> 2] = value;
  234. break;
  235. case "i64":
  236. tempI64 = [value >>> 0, (tempDouble = value, +Math_abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math_min(+Math_floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math_ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1];
  237. break;
  238. case "float":
  239. HEAPF32[ptr >> 2] = value;
  240. break;
  241. case "double":
  242. HEAPF64[ptr >> 3] = value;
  243. break;
  244. default:
  245. abort("invalid type for setValue: " + type)
  246. }
  247. }
  248. var ALLOC_NONE = 3;
  249.  
  250. function allocate(slab, types, allocator, ptr) {
  251. var zeroinit, size;
  252. if (typeof slab === "number") {
  253. zeroinit = true;
  254. size = slab
  255. } else {
  256. zeroinit = false;
  257. size = slab.length
  258. }
  259. var singleType = typeof types === "string" ? types : null;
  260. var ret;
  261. if (allocator == ALLOC_NONE) {
  262. ret = ptr
  263. } else {
  264. ret = [_malloc, stackAlloc, dynamicAlloc][allocator](Math.max(size, singleType ? 1 : types.length))
  265. }
  266. if (zeroinit) {
  267. var stop;
  268. ptr = ret;
  269. assert((ret & 3) == 0);
  270. stop = ret + (size & ~3);
  271. for (; ptr < stop; ptr += 4) {
  272. HEAP32[ptr >> 2] = 0
  273. }
  274. stop = ret + size;
  275. while (ptr < stop) {
  276. HEAP8[ptr++ >> 0] = 0
  277. }
  278. return ret
  279. }
  280. if (singleType === "i8") {
  281. if (slab.subarray || slab.slice) {
  282. HEAPU8.set(slab, ret)
  283. } else {
  284. HEAPU8.set(new Uint8Array(slab), ret)
  285. }
  286. return ret
  287. }
  288. var i = 0,
  289. type, typeSize, previousType;
  290. while (i < size) {
  291. var curr = slab[i];
  292. type = singleType || types[i];
  293. if (type === 0) {
  294. i++;
  295. continue
  296. }
  297. if (type == "i64") type = "i32";
  298. setValue(ret + i, curr, type);
  299. if (previousType !== type) {
  300. typeSize = getNativeTypeSize(type);
  301. previousType = type
  302. }
  303. i += typeSize
  304. }
  305. return ret
  306. }
  307.  
  308. function getMemory(size) {
  309. if (!runtimeInitialized) return dynamicAlloc(size);
  310. return _malloc(size)
  311. }
  312. var UTF8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : undefined;
  313.  
  314. function UTF8ArrayToString(u8Array, idx, maxBytesToRead) {
  315. var endIdx = idx + maxBytesToRead;
  316. var endPtr = idx;
  317. while (u8Array[endPtr] && !(endPtr >= endIdx)) ++endPtr;
  318. if (endPtr - idx > 16 && u8Array.subarray && UTF8Decoder) {
  319. return UTF8Decoder.decode(u8Array.subarray(idx, endPtr))
  320. } else {
  321. var str = "";
  322. while (idx < endPtr) {
  323. var u0 = u8Array[idx++];
  324. if (!(u0 & 128)) {
  325. str += String.fromCharCode(u0);
  326. continue
  327. }
  328. var u1 = u8Array[idx++] & 63;
  329. if ((u0 & 224) == 192) {
  330. str += String.fromCharCode((u0 & 31) << 6 | u1);
  331. continue
  332. }
  333. var u2 = u8Array[idx++] & 63;
  334. if ((u0 & 240) == 224) {
  335. u0 = (u0 & 15) << 12 | u1 << 6 | u2
  336. } else {
  337. u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | u8Array[idx++] & 63
  338. }
  339. if (u0 < 65536) {
  340. str += String.fromCharCode(u0)
  341. } else {
  342. var ch = u0 - 65536;
  343. str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023)
  344. }
  345. }
  346. }
  347. return str
  348. }
  349.  
  350. function UTF8ToString(ptr, maxBytesToRead) {
  351. return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""
  352. }
  353.  
  354. function stringToUTF8Array(str, outU8Array, outIdx, maxBytesToWrite) {
  355. if (!(maxBytesToWrite > 0)) return 0;
  356. var startIdx = outIdx;
  357. var endIdx = outIdx + maxBytesToWrite - 1;
  358. for (var i = 0; i < str.length; ++i) {
  359. var u = str.charCodeAt(i);
  360. if (u >= 55296 && u <= 57343) {
  361. var u1 = str.charCodeAt(++i);
  362. u = 65536 + ((u & 1023) << 10) | u1 & 1023
  363. }
  364. if (u <= 127) {
  365. if (outIdx >= endIdx) break;
  366. outU8Array[outIdx++] = u
  367. } else if (u <= 2047) {
  368. if (outIdx + 1 >= endIdx) break;
  369. outU8Array[outIdx++] = 192 | u >> 6;
  370. outU8Array[outIdx++] = 128 | u & 63
  371. } else if (u <= 65535) {
  372. if (outIdx + 2 >= endIdx) break;
  373. outU8Array[outIdx++] = 224 | u >> 12;
  374. outU8Array[outIdx++] = 128 | u >> 6 & 63;
  375. outU8Array[outIdx++] = 128 | u & 63
  376. } else {
  377. if (outIdx + 3 >= endIdx) break;
  378. outU8Array[outIdx++] = 240 | u >> 18;
  379. outU8Array[outIdx++] = 128 | u >> 12 & 63;
  380. outU8Array[outIdx++] = 128 | u >> 6 & 63;
  381. outU8Array[outIdx++] = 128 | u & 63
  382. }
  383. }
  384. outU8Array[outIdx] = 0;
  385. return outIdx - startIdx
  386. }
  387.  
  388. function stringToUTF8(str, outPtr, maxBytesToWrite) {
  389. return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite)
  390. }
  391.  
  392. function lengthBytesUTF8(str) {
  393. var len = 0;
  394. for (var i = 0; i < str.length; ++i) {
  395. var u = str.charCodeAt(i);
  396. if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str.charCodeAt(++i) & 1023;
  397. if (u <= 127) ++len;
  398. else if (u <= 2047) len += 2;
  399. else if (u <= 65535) len += 3;
  400. else len += 4
  401. }
  402. return len
  403. }
  404. var UTF16Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-16le") : undefined;
  405.  
  406. function allocateUTF8(str) {
  407. var size = lengthBytesUTF8(str) + 1;
  408. var ret = _malloc(size);
  409. if (ret) stringToUTF8Array(str, HEAP8, ret, size);
  410. return ret
  411. }
  412.  
  413. function writeAsciiToMemory(str, buffer, dontAddNull) {
  414. for (var i = 0; i < str.length; ++i) {
  415. HEAP8[buffer++ >> 0] = str.charCodeAt(i)
  416. }
  417. if (!dontAddNull) HEAP8[buffer >> 0] = 0
  418. }
  419.  
  420. function demangle(func) {
  421. return func
  422. }
  423.  
  424. function demangleAll(text) {
  425. var regex = /__Z[\w\d_]+/g;
  426. return text.replace(regex, function(x) {
  427. var y = demangle(x);
  428. return x === y ? x : y + " [" + x + "]"
  429. })
  430. }
  431.  
  432. function jsStackTrace() {
  433. var err = new Error;
  434. if (!err.stack) {
  435. try {
  436. throw new Error(0)
  437. } catch (e) {
  438. err = e
  439. }
  440. if (!err.stack) {
  441. return "(no stack trace available)"
  442. }
  443. }
  444. return err.stack.toString()
  445. }
  446.  
  447. function stackTrace() {
  448. var js = jsStackTrace();
  449. if (Module["extraStackTrace"]) js += "\n" + Module["extraStackTrace"]();
  450. return demangleAll(js)
  451. }
  452. var PAGE_SIZE = 16384;
  453. var WASM_PAGE_SIZE = 65536;
  454. var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
  455.  
  456. function updateGlobalBufferViews() {
  457. Module["HEAP8"] = HEAP8 = new Int8Array(buffer);
  458. Module["HEAP16"] = HEAP16 = new Int16Array(buffer);
  459. Module["HEAP32"] = HEAP32 = new Int32Array(buffer);
  460. Module["HEAPU8"] = HEAPU8 = new Uint8Array(buffer);
  461. Module["HEAPU16"] = HEAPU16 = new Uint16Array(buffer);
  462. Module["HEAPU32"] = HEAPU32 = new Uint32Array(buffer);
  463. Module["HEAPF32"] = HEAPF32 = new Float32Array(buffer);
  464. Module["HEAPF64"] = HEAPF64 = new Float64Array(buffer)
  465. }
  466. var DYNAMIC_BASE = 5606656,
  467. DYNAMICTOP_PTR = 363520;
  468. var TOTAL_STACK = 5242880;
  469. var INITIAL_TOTAL_MEMORY = Module["TOTAL_MEMORY"] || 67108864;
  470. if (INITIAL_TOTAL_MEMORY < TOTAL_STACK) err("TOTAL_MEMORY should be larger than TOTAL_STACK, was " + INITIAL_TOTAL_MEMORY + "! (TOTAL_STACK=" + TOTAL_STACK + ")");
  471. if (Module["buffer"]) {
  472. buffer = Module["buffer"]
  473. } else {
  474. if (typeof WebAssembly === "object" && typeof WebAssembly.Memory === "function") {
  475. wasmMemory = new WebAssembly.Memory({
  476. "initial": INITIAL_TOTAL_MEMORY / WASM_PAGE_SIZE,
  477. "maximum": INITIAL_TOTAL_MEMORY / WASM_PAGE_SIZE
  478. });
  479. buffer = wasmMemory.buffer
  480. } else {
  481. buffer = new ArrayBuffer(INITIAL_TOTAL_MEMORY)
  482. }
  483. }
  484. updateGlobalBufferViews();
  485. HEAP32[DYNAMICTOP_PTR >> 2] = DYNAMIC_BASE;
  486.  
  487. function callRuntimeCallbacks(callbacks) {
  488. while (callbacks.length > 0) {
  489. var callback = callbacks.shift();
  490. if (typeof callback == "function") {
  491. callback();
  492. continue
  493. }
  494. var func = callback.func;
  495. if (typeof func === "number") {
  496. if (callback.arg === undefined) {
  497. Module["dynCall_v"](func)
  498. } else {
  499. Module["dynCall_vi"](func, callback.arg)
  500. }
  501. } else {
  502. func(callback.arg === undefined ? null : callback.arg)
  503. }
  504. }
  505. }
  506. var __ATPRERUN__ = [];
  507. var __ATINIT__ = [];
  508. var __ATMAIN__ = [];
  509. var __ATPOSTRUN__ = [];
  510. var runtimeInitialized = false;
  511.  
  512. function preRun() {
  513. if (Module["preRun"]) {
  514. if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
  515. while (Module["preRun"].length) {
  516. addOnPreRun(Module["preRun"].shift())
  517. }
  518. }
  519. callRuntimeCallbacks(__ATPRERUN__)
  520. }
  521.  
  522. function ensureInitRuntime() {
  523. if (runtimeInitialized) return;
  524. runtimeInitialized = true;
  525. if (!Module["noFSInit"] && !FS.init.initialized) FS.init();
  526. TTY.init();
  527. callRuntimeCallbacks(__ATINIT__)
  528. }
  529.  
  530. function preMain() {
  531. FS.ignorePermissions = false;
  532. callRuntimeCallbacks(__ATMAIN__)
  533. }
  534.  
  535. function postRun() {
  536. if (Module["postRun"]) {
  537. if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
  538. while (Module["postRun"].length) {
  539. addOnPostRun(Module["postRun"].shift())
  540. }
  541. }
  542. callRuntimeCallbacks(__ATPOSTRUN__)
  543. }
  544.  
  545. function addOnPreRun(cb) {
  546. __ATPRERUN__.unshift(cb)
  547. }
  548.  
  549. function addOnPostRun(cb) {
  550. __ATPOSTRUN__.unshift(cb)
  551. }
  552. var Math_abs = Math.abs;
  553. var Math_ceil = Math.ceil;
  554. var Math_floor = Math.floor;
  555. var Math_min = Math.min;
  556. var runDependencies = 0;
  557. var runDependencyWatcher = null;
  558. var dependenciesFulfilled = null;
  559.  
  560. function getUniqueRunDependency(id) {
  561. return id
  562. }
  563.  
  564. function addRunDependency(id) {
  565. runDependencies++;
  566. if (Module["monitorRunDependencies"]) {
  567. Module["monitorRunDependencies"](runDependencies)
  568. }
  569. }
  570.  
  571. function removeRunDependency(id) {
  572. runDependencies--;
  573. if (Module["monitorRunDependencies"]) {
  574. Module["monitorRunDependencies"](runDependencies)
  575. }
  576. if (runDependencies == 0) {
  577. if (runDependencyWatcher !== null) {
  578. clearInterval(runDependencyWatcher);
  579. runDependencyWatcher = null
  580. }
  581. if (dependenciesFulfilled) {
  582. var callback = dependenciesFulfilled;
  583. dependenciesFulfilled = null;
  584. callback()
  585. }
  586. }
  587. }
  588. Module["preloadedImages"] = {};
  589. Module["preloadedAudios"] = {};
  590. var dataURIPrefix = "data:application/octet-stream;base64,";
  591.  
  592. function isDataURI(filename) {
  593. return String.prototype.startsWith ? filename.startsWith(dataURIPrefix) : filename.indexOf(dataURIPrefix) === 0
  594. }
  595. var wasmBinaryFile = "harfbuzzjs.wasm";
  596. if (!isDataURI(wasmBinaryFile)) {
  597. wasmBinaryFile = locateFile(wasmBinaryFile)
  598. }
  599.  
  600. function getBinary() {
  601. try {
  602. if (Module["wasmBinary"]) {
  603. return new Uint8Array(Module["wasmBinary"])
  604. }
  605. if (Module["readBinary"]) {
  606. return Module["readBinary"](wasmBinaryFile)
  607. } else {
  608. throw "both async and sync fetching of the wasm failed"
  609. }
  610. } catch (err) {
  611. abort(err)
  612. }
  613. }
  614.  
  615. function getBinaryPromise() {
  616. if (!Module["wasmBinary"] && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch === "function") {
  617. return fetch(wasmBinaryFile, {
  618. credentials: "same-origin"
  619. }).then(function(response) {
  620. if (!response["ok"]) {
  621. throw "failed to load wasm binary file at '" + wasmBinaryFile + "'"
  622. }
  623. return response["arrayBuffer"]()
  624. }).catch(function() {
  625. return getBinary()
  626. })
  627. }
  628. return new Promise(function(resolve, reject) {
  629. resolve(getBinary())
  630. })
  631. }
  632.  
  633. function createWasm(env) {
  634. var info = {
  635. "env": env,
  636. "global": {
  637. "NaN": NaN,
  638. Infinity: Infinity
  639. },
  640. "global.Math": Math,
  641. "asm2wasm": asm2wasmImports
  642. };
  643.  
  644. function receiveInstance(instance, module) {
  645. var exports = instance.exports;
  646. Module["asm"] = exports;
  647. removeRunDependency("wasm-instantiate")
  648. }
  649. addRunDependency("wasm-instantiate");
  650. if (Module["instantiateWasm"]) {
  651. try {
  652. return Module["instantiateWasm"](info, receiveInstance)
  653. } catch (e) {
  654. err("Module.instantiateWasm callback failed with error: " + e);
  655. return false
  656. }
  657. }
  658.  
  659. function receiveInstantiatedSource(output) {
  660. receiveInstance(output["instance"])
  661. }
  662.  
  663. function instantiateArrayBuffer(receiver) {
  664. getBinaryPromise().then(function(binary) {
  665. return WebAssembly.instantiate(binary, info)
  666. }).then(receiver, function(reason) {
  667. err("failed to asynchronously prepare wasm: " + reason);
  668. abort(reason)
  669. })
  670. }
  671. if (!Module["wasmBinary"] && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && typeof fetch === "function") {
  672. WebAssembly.instantiateStreaming(fetch(wasmBinaryFile, {
  673. credentials: "same-origin"
  674. }), info).then(receiveInstantiatedSource, function(reason) {
  675. err("wasm streaming compile failed: " + reason);
  676. err("falling back to ArrayBuffer instantiation");
  677. instantiateArrayBuffer(receiveInstantiatedSource)
  678. })
  679. } else {
  680. instantiateArrayBuffer(receiveInstantiatedSource)
  681. }
  682. return {}
  683. }
  684. Module["asm"] = function(global, env, providedBuffer) {
  685. env["memory"] = wasmMemory;
  686. env["table"] = wasmTable = new WebAssembly.Table({
  687. "initial": 310,
  688. "maximum": 310,
  689. "element": "anyfunc"
  690. });
  691. env["__memory_base"] = 1024;
  692. env["__table_base"] = 0;
  693. var exports = createWasm(env);
  694. return exports
  695. };
  696. __ATINIT__.push({
  697. func: function() {
  698. ___emscripten_environ_constructor()
  699. }
  700. });
  701.  
  702. function ___assert_fail(condition, filename, line, func) {
  703. abort("Assertion failed: " + UTF8ToString(condition) + ", at: " + [filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function"])
  704. }
  705. var ENV = {};
  706.  
  707. function ___buildEnvironment(environ) {
  708. var MAX_ENV_VALUES = 64;
  709. var TOTAL_ENV_SIZE = 1024;
  710. var poolPtr;
  711. var envPtr;
  712. if (!___buildEnvironment.called) {
  713. ___buildEnvironment.called = true;
  714. ENV["USER"] = ENV["LOGNAME"] = "web_user";
  715. ENV["PATH"] = "/";
  716. ENV["PWD"] = "/";
  717. ENV["HOME"] = "/home/web_user";
  718. ENV["LANG"] = "C.UTF-8";
  719. ENV["_"] = Module["thisProgram"];
  720. poolPtr = getMemory(TOTAL_ENV_SIZE);
  721. envPtr = getMemory(MAX_ENV_VALUES * 4);
  722. HEAP32[envPtr >> 2] = poolPtr;
  723. HEAP32[environ >> 2] = envPtr
  724. } else {
  725. envPtr = HEAP32[environ >> 2];
  726. poolPtr = HEAP32[envPtr >> 2]
  727. }
  728. var strings = [];
  729. var totalSize = 0;
  730. for (var key in ENV) {
  731. if (typeof ENV[key] === "string") {
  732. var line = key + "=" + ENV[key];
  733. strings.push(line);
  734. totalSize += line.length
  735. }
  736. }
  737. if (totalSize > TOTAL_ENV_SIZE) {
  738. throw new Error("Environment size exceeded TOTAL_ENV_SIZE!")
  739. }
  740. var ptrSize = 4;
  741. for (var i = 0; i < strings.length; i++) {
  742. var line = strings[i];
  743. writeAsciiToMemory(line, poolPtr);
  744. HEAP32[envPtr + i * ptrSize >> 2] = poolPtr;
  745. poolPtr += line.length + 1
  746. }
  747. HEAP32[envPtr + strings.length * ptrSize >> 2] = 0
  748. }
  749.  
  750. function ___lock() {}
  751.  
  752. function ___setErrNo(value) {
  753. if (Module["___errno_location"]) HEAP32[Module["___errno_location"]() >> 2] = value;
  754. return value
  755. }
  756.  
  757. function ___map_file(pathname, size) {
  758. ___setErrNo(1);
  759. return -1
  760. }
  761. var PATH = {
  762. splitPath: function(filename) {
  763. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  764. return splitPathRe.exec(filename).slice(1)
  765. },
  766. normalizeArray: function(parts, allowAboveRoot) {
  767. var up = 0;
  768. for (var i = parts.length - 1; i >= 0; i--) {
  769. var last = parts[i];
  770. if (last === ".") {
  771. parts.splice(i, 1)
  772. } else if (last === "..") {
  773. parts.splice(i, 1);
  774. up++
  775. } else if (up) {
  776. parts.splice(i, 1);
  777. up--
  778. }
  779. }
  780. if (allowAboveRoot) {
  781. for (; up; up--) {
  782. parts.unshift("..")
  783. }
  784. }
  785. return parts
  786. },
  787. normalize: function(path) {
  788. var isAbsolute = path.charAt(0) === "/",
  789. trailingSlash = path.substr(-1) === "/";
  790. path = PATH.normalizeArray(path.split("/").filter(function(p) {
  791. return !!p
  792. }), !isAbsolute).join("/");
  793. if (!path && !isAbsolute) {
  794. path = "."
  795. }
  796. if (path && trailingSlash) {
  797. path += "/"
  798. }
  799. return (isAbsolute ? "/" : "") + path
  800. },
  801. dirname: function(path) {
  802. var result = PATH.splitPath(path),
  803. root = result[0],
  804. dir = result[1];
  805. if (!root && !dir) {
  806. return "."
  807. }
  808. if (dir) {
  809. dir = dir.substr(0, dir.length - 1)
  810. }
  811. return root + dir
  812. },
  813. basename: function(path) {
  814. if (path === "/") return "/";
  815. var lastSlash = path.lastIndexOf("/");
  816. if (lastSlash === -1) return path;
  817. return path.substr(lastSlash + 1)
  818. },
  819. extname: function(path) {
  820. return PATH.splitPath(path)[3]
  821. },
  822. join: function() {
  823. var paths = Array.prototype.slice.call(arguments, 0);
  824. return PATH.normalize(paths.join("/"))
  825. },
  826. join2: function(l, r) {
  827. return PATH.normalize(l + "/" + r)
  828. },
  829. resolve: function() {
  830. var resolvedPath = "",
  831. resolvedAbsolute = false;
  832. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  833. var path = i >= 0 ? arguments[i] : FS.cwd();
  834. if (typeof path !== "string") {
  835. throw new TypeError("Arguments to path.resolve must be strings")
  836. } else if (!path) {
  837. return ""
  838. }
  839. resolvedPath = path + "/" + resolvedPath;
  840. resolvedAbsolute = path.charAt(0) === "/"
  841. }
  842. resolvedPath = PATH.normalizeArray(resolvedPath.split("/").filter(function(p) {
  843. return !!p
  844. }), !resolvedAbsolute).join("/");
  845. return (resolvedAbsolute ? "/" : "") + resolvedPath || "."
  846. },
  847. relative: function(from, to) {
  848. from = PATH.resolve(from).substr(1);
  849. to = PATH.resolve(to).substr(1);
  850.  
  851. function trim(arr) {
  852. var start = 0;
  853. for (; start < arr.length; start++) {
  854. if (arr[start] !== "") break
  855. }
  856. var end = arr.length - 1;
  857. for (; end >= 0; end--) {
  858. if (arr[end] !== "") break
  859. }
  860. if (start > end) return [];
  861. return arr.slice(start, end - start + 1)
  862. }
  863. var fromParts = trim(from.split("/"));
  864. var toParts = trim(to.split("/"));
  865. var length = Math.min(fromParts.length, toParts.length);
  866. var samePartsLength = length;
  867. for (var i = 0; i < length; i++) {
  868. if (fromParts[i] !== toParts[i]) {
  869. samePartsLength = i;
  870. break
  871. }
  872. }
  873. var outputParts = [];
  874. for (var i = samePartsLength; i < fromParts.length; i++) {
  875. outputParts.push("..")
  876. }
  877. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  878. return outputParts.join("/")
  879. }
  880. };
  881. var TTY = {
  882. ttys: [],
  883. init: function() {},
  884. shutdown: function() {},
  885. register: function(dev, ops) {
  886. TTY.ttys[dev] = {
  887. input: [],
  888. output: [],
  889. ops: ops
  890. };
  891. FS.registerDevice(dev, TTY.stream_ops)
  892. },
  893. stream_ops: {
  894. open: function(stream) {
  895. var tty = TTY.ttys[stream.node.rdev];
  896. if (!tty) {
  897. throw new FS.ErrnoError(ERRNO_CODES.ENODEV)
  898. }
  899. stream.tty = tty;
  900. stream.seekable = false
  901. },
  902. close: function(stream) {
  903. stream.tty.ops.flush(stream.tty)
  904. },
  905. flush: function(stream) {
  906. stream.tty.ops.flush(stream.tty)
  907. },
  908. read: function(stream, buffer, offset, length, pos) {
  909. if (!stream.tty || !stream.tty.ops.get_char) {
  910. throw new FS.ErrnoError(ERRNO_CODES.ENXIO)
  911. }
  912. var bytesRead = 0;
  913. for (var i = 0; i < length; i++) {
  914. var result;
  915. try {
  916. result = stream.tty.ops.get_char(stream.tty)
  917. } catch (e) {
  918. throw new FS.ErrnoError(ERRNO_CODES.EIO)
  919. }
  920. if (result === undefined && bytesRead === 0) {
  921. throw new FS.ErrnoError(ERRNO_CODES.EAGAIN)
  922. }
  923. if (result === null || result === undefined) break;
  924. bytesRead++;
  925. buffer[offset + i] = result
  926. }
  927. if (bytesRead) {
  928. stream.node.timestamp = Date.now()
  929. }
  930. return bytesRead
  931. },
  932. write: function(stream, buffer, offset, length, pos) {
  933. if (!stream.tty || !stream.tty.ops.put_char) {
  934. throw new FS.ErrnoError(ERRNO_CODES.ENXIO)
  935. }
  936. try {
  937. for (var i = 0; i < length; i++) {
  938. stream.tty.ops.put_char(stream.tty, buffer[offset + i])
  939. }
  940. } catch (e) {
  941. throw new FS.ErrnoError(ERRNO_CODES.EIO)
  942. }
  943. if (length) {
  944. stream.node.timestamp = Date.now()
  945. }
  946. return i
  947. }
  948. },
  949. default_tty_ops: {
  950. get_char: function(tty) {
  951. if (!tty.input.length) {
  952. var result = null;
  953. if (ENVIRONMENT_IS_NODE) {
  954. var BUFSIZE = 256;
  955. var buf = new Buffer(BUFSIZE);
  956. var bytesRead = 0;
  957. var isPosixPlatform = process.platform != "win32";
  958. var fd = process.stdin.fd;
  959. if (isPosixPlatform) {
  960. var usingDevice = false;
  961. try {
  962. fd = fs.openSync("/dev/stdin", "r");
  963. usingDevice = true
  964. } catch (e) {}
  965. }
  966. try {
  967. bytesRead = fs.readSync(fd, buf, 0, BUFSIZE, null)
  968. } catch (e) {
  969. if (e.toString().indexOf("EOF") != -1) bytesRead = 0;
  970. else throw e
  971. }
  972. if (usingDevice) {
  973. fs.closeSync(fd)
  974. }
  975. if (bytesRead > 0) {
  976. result = buf.slice(0, bytesRead).toString("utf-8")
  977. } else {
  978. result = null
  979. }
  980. } else if (typeof window != "undefined" && typeof window.prompt == "function") {
  981. result = window.prompt("Input: ");
  982. if (result !== null) {
  983. result += "\n"
  984. }
  985. } else if (typeof readline == "function") {
  986. result = readline();
  987. if (result !== null) {
  988. result += "\n"
  989. }
  990. }
  991. if (!result) {
  992. return null
  993. }
  994. tty.input = intArrayFromString(result, true)
  995. }
  996. return tty.input.shift()
  997. },
  998. put_char: function(tty, val) {
  999. if (val === null || val === 10) {
  1000. out(UTF8ArrayToString(tty.output, 0));
  1001. tty.output = []
  1002. } else {
  1003. if (val != 0) tty.output.push(val)
  1004. }
  1005. },
  1006. flush: function(tty) {
  1007. if (tty.output && tty.output.length > 0) {
  1008. out(UTF8ArrayToString(tty.output, 0));
  1009. tty.output = []
  1010. }
  1011. }
  1012. },
  1013. default_tty1_ops: {
  1014. put_char: function(tty, val) {
  1015. if (val === null || val === 10) {
  1016. err(UTF8ArrayToString(tty.output, 0));
  1017. tty.output = []
  1018. } else {
  1019. if (val != 0) tty.output.push(val)
  1020. }
  1021. },
  1022. flush: function(tty) {
  1023. if (tty.output && tty.output.length > 0) {
  1024. err(UTF8ArrayToString(tty.output, 0));
  1025. tty.output = []
  1026. }
  1027. }
  1028. }
  1029. };
  1030. var MEMFS = {
  1031. ops_table: null,
  1032. mount: function(mount) {
  1033. return MEMFS.createNode(null, "/", 16384 | 511, 0)
  1034. },
  1035. createNode: function(parent, name, mode, dev) {
  1036. if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
  1037. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  1038. }
  1039. if (!MEMFS.ops_table) {
  1040. MEMFS.ops_table = {
  1041. dir: {
  1042. node: {
  1043. getattr: MEMFS.node_ops.getattr,
  1044. setattr: MEMFS.node_ops.setattr,
  1045. lookup: MEMFS.node_ops.lookup,
  1046. mknod: MEMFS.node_ops.mknod,
  1047. rename: MEMFS.node_ops.rename,
  1048. unlink: MEMFS.node_ops.unlink,
  1049. rmdir: MEMFS.node_ops.rmdir,
  1050. readdir: MEMFS.node_ops.readdir,
  1051. symlink: MEMFS.node_ops.symlink
  1052. },
  1053. stream: {
  1054. llseek: MEMFS.stream_ops.llseek
  1055. }
  1056. },
  1057. file: {
  1058. node: {
  1059. getattr: MEMFS.node_ops.getattr,
  1060. setattr: MEMFS.node_ops.setattr
  1061. },
  1062. stream: {
  1063. llseek: MEMFS.stream_ops.llseek,
  1064. read: MEMFS.stream_ops.read,
  1065. write: MEMFS.stream_ops.write,
  1066. allocate: MEMFS.stream_ops.allocate,
  1067. mmap: MEMFS.stream_ops.mmap,
  1068. msync: MEMFS.stream_ops.msync
  1069. }
  1070. },
  1071. link: {
  1072. node: {
  1073. getattr: MEMFS.node_ops.getattr,
  1074. setattr: MEMFS.node_ops.setattr,
  1075. readlink: MEMFS.node_ops.readlink
  1076. },
  1077. stream: {}
  1078. },
  1079. chrdev: {
  1080. node: {
  1081. getattr: MEMFS.node_ops.getattr,
  1082. setattr: MEMFS.node_ops.setattr
  1083. },
  1084. stream: FS.chrdev_stream_ops
  1085. }
  1086. }
  1087. }
  1088. var node = FS.createNode(parent, name, mode, dev);
  1089. if (FS.isDir(node.mode)) {
  1090. node.node_ops = MEMFS.ops_table.dir.node;
  1091. node.stream_ops = MEMFS.ops_table.dir.stream;
  1092. node.contents = {}
  1093. } else if (FS.isFile(node.mode)) {
  1094. node.node_ops = MEMFS.ops_table.file.node;
  1095. node.stream_ops = MEMFS.ops_table.file.stream;
  1096. node.usedBytes = 0;
  1097. node.contents = null
  1098. } else if (FS.isLink(node.mode)) {
  1099. node.node_ops = MEMFS.ops_table.link.node;
  1100. node.stream_ops = MEMFS.ops_table.link.stream
  1101. } else if (FS.isChrdev(node.mode)) {
  1102. node.node_ops = MEMFS.ops_table.chrdev.node;
  1103. node.stream_ops = MEMFS.ops_table.chrdev.stream
  1104. }
  1105. node.timestamp = Date.now();
  1106. if (parent) {
  1107. parent.contents[name] = node
  1108. }
  1109. return node
  1110. },
  1111. getFileDataAsRegularArray: function(node) {
  1112. if (node.contents && node.contents.subarray) {
  1113. var arr = [];
  1114. for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]);
  1115. return arr
  1116. }
  1117. return node.contents
  1118. },
  1119. getFileDataAsTypedArray: function(node) {
  1120. if (!node.contents) return new Uint8Array;
  1121. if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes);
  1122. return new Uint8Array(node.contents)
  1123. },
  1124. expandFileStorage: function(node, newCapacity) {
  1125. var prevCapacity = node.contents ? node.contents.length : 0;
  1126. if (prevCapacity >= newCapacity) return;
  1127. var CAPACITY_DOUBLING_MAX = 1024 * 1024;
  1128. newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) | 0);
  1129. if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
  1130. var oldContents = node.contents;
  1131. node.contents = new Uint8Array(newCapacity);
  1132. if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
  1133. return
  1134. },
  1135. resizeFileStorage: function(node, newSize) {
  1136. if (node.usedBytes == newSize) return;
  1137. if (newSize == 0) {
  1138. node.contents = null;
  1139. node.usedBytes = 0;
  1140. return
  1141. }
  1142. if (!node.contents || node.contents.subarray) {
  1143. var oldContents = node.contents;
  1144. node.contents = new Uint8Array(new ArrayBuffer(newSize));
  1145. if (oldContents) {
  1146. node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)))
  1147. }
  1148. node.usedBytes = newSize;
  1149. return
  1150. }
  1151. if (!node.contents) node.contents = [];
  1152. if (node.contents.length > newSize) node.contents.length = newSize;
  1153. else
  1154. while (node.contents.length < newSize) node.contents.push(0);
  1155. node.usedBytes = newSize
  1156. },
  1157. node_ops: {
  1158. getattr: function(node) {
  1159. var attr = {};
  1160. attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
  1161. attr.ino = node.id;
  1162. attr.mode = node.mode;
  1163. attr.nlink = 1;
  1164. attr.uid = 0;
  1165. attr.gid = 0;
  1166. attr.rdev = node.rdev;
  1167. if (FS.isDir(node.mode)) {
  1168. attr.size = 4096
  1169. } else if (FS.isFile(node.mode)) {
  1170. attr.size = node.usedBytes
  1171. } else if (FS.isLink(node.mode)) {
  1172. attr.size = node.link.length
  1173. } else {
  1174. attr.size = 0
  1175. }
  1176. attr.atime = new Date(node.timestamp);
  1177. attr.mtime = new Date(node.timestamp);
  1178. attr.ctime = new Date(node.timestamp);
  1179. attr.blksize = 4096;
  1180. attr.blocks = Math.ceil(attr.size / attr.blksize);
  1181. return attr
  1182. },
  1183. setattr: function(node, attr) {
  1184. if (attr.mode !== undefined) {
  1185. node.mode = attr.mode
  1186. }
  1187. if (attr.timestamp !== undefined) {
  1188. node.timestamp = attr.timestamp
  1189. }
  1190. if (attr.size !== undefined) {
  1191. MEMFS.resizeFileStorage(node, attr.size)
  1192. }
  1193. },
  1194. lookup: function(parent, name) {
  1195. throw FS.genericErrors[ERRNO_CODES.ENOENT]
  1196. },
  1197. mknod: function(parent, name, mode, dev) {
  1198. return MEMFS.createNode(parent, name, mode, dev)
  1199. },
  1200. rename: function(old_node, new_dir, new_name) {
  1201. if (FS.isDir(old_node.mode)) {
  1202. var new_node;
  1203. try {
  1204. new_node = FS.lookupNode(new_dir, new_name)
  1205. } catch (e) {}
  1206. if (new_node) {
  1207. for (var i in new_node.contents) {
  1208. throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)
  1209. }
  1210. }
  1211. }
  1212. delete old_node.parent.contents[old_node.name];
  1213. old_node.name = new_name;
  1214. new_dir.contents[new_name] = old_node;
  1215. old_node.parent = new_dir
  1216. },
  1217. unlink: function(parent, name) {
  1218. delete parent.contents[name]
  1219. },
  1220. rmdir: function(parent, name) {
  1221. var node = FS.lookupNode(parent, name);
  1222. for (var i in node.contents) {
  1223. throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)
  1224. }
  1225. delete parent.contents[name]
  1226. },
  1227. readdir: function(node) {
  1228. var entries = [".", ".."];
  1229. for (var key in node.contents) {
  1230. if (!node.contents.hasOwnProperty(key)) {
  1231. continue
  1232. }
  1233. entries.push(key)
  1234. }
  1235. return entries
  1236. },
  1237. symlink: function(parent, newname, oldpath) {
  1238. var node = MEMFS.createNode(parent, newname, 511 | 40960, 0);
  1239. node.link = oldpath;
  1240. return node
  1241. },
  1242. readlink: function(node) {
  1243. if (!FS.isLink(node.mode)) {
  1244. throw new FS.ErrnoError(ERRNO_CODES.EINVAL)
  1245. }
  1246. return node.link
  1247. }
  1248. },
  1249. stream_ops: {
  1250. read: function(stream, buffer, offset, length, position) {
  1251. var contents = stream.node.contents;
  1252. if (position >= stream.node.usedBytes) return 0;
  1253. var size = Math.min(stream.node.usedBytes - position, length);
  1254. if (size > 8 && contents.subarray) {
  1255. buffer.set(contents.subarray(position, position + size), offset)
  1256. } else {
  1257. for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i]
  1258. }
  1259. return size
  1260. },
  1261. write: function(stream, buffer, offset, length, position, canOwn) {
  1262. if (!length) return 0;
  1263. var node = stream.node;
  1264. node.timestamp = Date.now();
  1265. if (buffer.subarray && (!node.contents || node.contents.subarray)) {
  1266. if (canOwn) {
  1267. node.contents = buffer.subarray(offset, offset + length);
  1268. node.usedBytes = length;
  1269. return length
  1270. } else if (node.usedBytes === 0 && position === 0) {
  1271. node.contents = new Uint8Array(buffer.subarray(offset, offset + length));
  1272. node.usedBytes = length;
  1273. return length
  1274. } else if (position + length <= node.usedBytes) {
  1275. node.contents.set(buffer.subarray(offset, offset + length), position);
  1276. return length
  1277. }
  1278. }
  1279. MEMFS.expandFileStorage(node, position + length);
  1280. if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position);
  1281. else {
  1282. for (var i = 0; i < length; i++) {
  1283. node.contents[position + i] = buffer[offset + i]
  1284. }
  1285. }
  1286. node.usedBytes = Math.max(node.usedBytes, position + length);
  1287. return length
  1288. },
  1289. llseek: function(stream, offset, whence) {
  1290. var position = offset;
  1291. if (whence === 1) {
  1292. position += stream.position
  1293. } else if (whence === 2) {
  1294. if (FS.isFile(stream.node.mode)) {
  1295. position += stream.node.usedBytes
  1296. }
  1297. }
  1298. if (position < 0) {
  1299. throw new FS.ErrnoError(ERRNO_CODES.EINVAL)
  1300. }
  1301. return position
  1302. },
  1303. allocate: function(stream, offset, length) {
  1304. MEMFS.expandFileStorage(stream.node, offset + length);
  1305. stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length)
  1306. },
  1307. mmap: function(stream, buffer, offset, length, position, prot, flags) {
  1308. if (!FS.isFile(stream.node.mode)) {
  1309. throw new FS.ErrnoError(ERRNO_CODES.ENODEV)
  1310. }
  1311. var ptr;
  1312. var allocated;
  1313. var contents = stream.node.contents;
  1314. if (!(flags & 2) && (contents.buffer === buffer || contents.buffer === buffer.buffer)) {
  1315. allocated = false;
  1316. ptr = contents.byteOffset
  1317. } else {
  1318. if (position > 0 || position + length < stream.node.usedBytes) {
  1319. if (contents.subarray) {
  1320. contents = contents.subarray(position, position + length)
  1321. } else {
  1322. contents = Array.prototype.slice.call(contents, position, position + length)
  1323. }
  1324. }
  1325. allocated = true;
  1326. ptr = _malloc(length);
  1327. if (!ptr) {
  1328. throw new FS.ErrnoError(ERRNO_CODES.ENOMEM)
  1329. }
  1330. buffer.set(contents, ptr)
  1331. }
  1332. return {
  1333. ptr: ptr,
  1334. allocated: allocated
  1335. }
  1336. },
  1337. msync: function(stream, buffer, offset, length, mmapFlags) {
  1338. if (!FS.isFile(stream.node.mode)) {
  1339. throw new FS.ErrnoError(ERRNO_CODES.ENODEV)
  1340. }
  1341. if (mmapFlags & 2) {
  1342. return 0
  1343. }
  1344. var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
  1345. return 0
  1346. }
  1347. }
  1348. };
  1349. var IDBFS = {
  1350. dbs: {},
  1351. indexedDB: function() {
  1352. if (typeof indexedDB !== "undefined") return indexedDB;
  1353. var ret = null;
  1354. if (typeof window === "object") ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
  1355. assert(ret, "IDBFS used, but indexedDB not supported");
  1356. return ret
  1357. },
  1358. DB_VERSION: 21,
  1359. DB_STORE_NAME: "FILE_DATA",
  1360. mount: function(mount) {
  1361. return MEMFS.mount.apply(null, arguments)
  1362. },
  1363. syncfs: function(mount, populate, callback) {
  1364. IDBFS.getLocalSet(mount, function(err, local) {
  1365. if (err) return callback(err);
  1366. IDBFS.getRemoteSet(mount, function(err, remote) {
  1367. if (err) return callback(err);
  1368. var src = populate ? remote : local;
  1369. var dst = populate ? local : remote;
  1370. IDBFS.reconcile(src, dst, callback)
  1371. })
  1372. })
  1373. },
  1374. getDB: function(name, callback) {
  1375. var db = IDBFS.dbs[name];
  1376. if (db) {
  1377. return callback(null, db)
  1378. }
  1379. var req;
  1380. try {
  1381. req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION)
  1382. } catch (e) {
  1383. return callback(e)
  1384. }
  1385. if (!req) {
  1386. return callback("Unable to connect to IndexedDB")
  1387. }
  1388. req.onupgradeneeded = function(e) {
  1389. var db = e.target.result;
  1390. var transaction = e.target.transaction;
  1391. var fileStore;
  1392. if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
  1393. fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME)
  1394. } else {
  1395. fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME)
  1396. }
  1397. if (!fileStore.indexNames.contains("timestamp")) {
  1398. fileStore.createIndex("timestamp", "timestamp", {
  1399. unique: false
  1400. })
  1401. }
  1402. };
  1403. req.onsuccess = function() {
  1404. db = req.result;
  1405. IDBFS.dbs[name] = db;
  1406. callback(null, db)
  1407. };
  1408. req.onerror = function(e) {
  1409. callback(this.error);
  1410. e.preventDefault()
  1411. }
  1412. },
  1413. getLocalSet: function(mount, callback) {
  1414. var entries = {};
  1415.  
  1416. function isRealDir(p) {
  1417. return p !== "." && p !== ".."
  1418. }
  1419.  
  1420. function toAbsolute(root) {
  1421. return function(p) {
  1422. return PATH.join2(root, p)
  1423. }
  1424. }
  1425. var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
  1426. while (check.length) {
  1427. var path = check.pop();
  1428. var stat;
  1429. try {
  1430. stat = FS.stat(path)
  1431. } catch (e) {
  1432. return callback(e)
  1433. }
  1434. if (FS.isDir(stat.mode)) {
  1435. check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)))
  1436. }
  1437. entries[path] = {
  1438. timestamp: stat.mtime
  1439. }
  1440. }
  1441. return callback(null, {
  1442. type: "local",
  1443. entries: entries
  1444. })
  1445. },
  1446. getRemoteSet: function(mount, callback) {
  1447. var entries = {};
  1448. IDBFS.getDB(mount.mountpoint, function(err, db) {
  1449. if (err) return callback(err);
  1450. try {
  1451. var transaction = db.transaction([IDBFS.DB_STORE_NAME], "readonly");
  1452. transaction.onerror = function(e) {
  1453. callback(this.error);
  1454. e.preventDefault()
  1455. };
  1456. var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
  1457. var index = store.index("timestamp");
  1458. index.openKeyCursor().onsuccess = function(event) {
  1459. var cursor = event.target.result;
  1460. if (!cursor) {
  1461. return callback(null, {
  1462. type: "remote",
  1463. db: db,
  1464. entries: entries
  1465. })
  1466. }
  1467. entries[cursor.primaryKey] = {
  1468. timestamp: cursor.key
  1469. };
  1470. cursor.continue()
  1471. }
  1472. } catch (e) {
  1473. return callback(e)
  1474. }
  1475. })
  1476. },
  1477. loadLocalEntry: function(path, callback) {
  1478. var stat, node;
  1479. try {
  1480. var lookup = FS.lookupPath(path);
  1481. node = lookup.node;
  1482. stat = FS.stat(path)
  1483. } catch (e) {
  1484. return callback(e)
  1485. }
  1486. if (FS.isDir(stat.mode)) {
  1487. return callback(null, {
  1488. timestamp: stat.mtime,
  1489. mode: stat.mode
  1490. })
  1491. } else if (FS.isFile(stat.mode)) {
  1492. node.contents = MEMFS.getFileDataAsTypedArray(node);
  1493. return callback(null, {
  1494. timestamp: stat.mtime,
  1495. mode: stat.mode,
  1496. contents: node.contents
  1497. })
  1498. } else {
  1499. return callback(new Error("node type not supported"))
  1500. }
  1501. },
  1502. storeLocalEntry: function(path, entry, callback) {
  1503. try {
  1504. if (FS.isDir(entry.mode)) {
  1505. FS.mkdir(path, entry.mode)
  1506. } else if (FS.isFile(entry.mode)) {
  1507. FS.writeFile(path, entry.contents, {
  1508. canOwn: true
  1509. })
  1510. } else {
  1511. return callback(new Error("node type not supported"))
  1512. }
  1513. FS.chmod(path, entry.mode);
  1514. FS.utime(path, entry.timestamp, entry.timestamp)
  1515. } catch (e) {
  1516. return callback(e)
  1517. }
  1518. callback(null)
  1519. },
  1520. removeLocalEntry: function(path, callback) {
  1521. try {
  1522. var lookup = FS.lookupPath(path);
  1523. var stat = FS.stat(path);
  1524. if (FS.isDir(stat.mode)) {
  1525. FS.rmdir(path)
  1526. } else if (FS.isFile(stat.mode)) {
  1527. FS.unlink(path)
  1528. }
  1529. } catch (e) {
  1530. return callback(e)
  1531. }
  1532. callback(null)
  1533. },
  1534. loadRemoteEntry: function(store, path, callback) {
  1535. var req = store.get(path);
  1536. req.onsuccess = function(event) {
  1537. callback(null, event.target.result)
  1538. };
  1539. req.onerror = function(e) {
  1540. callback(this.error);
  1541. e.preventDefault()
  1542. }
  1543. },
  1544. storeRemoteEntry: function(store, path, entry, callback) {
  1545. var req = store.put(entry, path);
  1546. req.onsuccess = function() {
  1547. callback(null)
  1548. };
  1549. req.onerror = function(e) {
  1550. callback(this.error);
  1551. e.preventDefault()
  1552. }
  1553. },
  1554. removeRemoteEntry: function(store, path, callback) {
  1555. var req = store.delete(path);
  1556. req.onsuccess = function() {
  1557. callback(null)
  1558. };
  1559. req.onerror = function(e) {
  1560. callback(this.error);
  1561. e.preventDefault()
  1562. }
  1563. },
  1564. reconcile: function(src, dst, callback) {
  1565. var total = 0;
  1566. var create = [];
  1567. Object.keys(src.entries).forEach(function(key) {
  1568. var e = src.entries[key];
  1569. var e2 = dst.entries[key];
  1570. if (!e2 || e.timestamp > e2.timestamp) {
  1571. create.push(key);
  1572. total++
  1573. }
  1574. });
  1575. var remove = [];
  1576. Object.keys(dst.entries).forEach(function(key) {
  1577. var e = dst.entries[key];
  1578. var e2 = src.entries[key];
  1579. if (!e2) {
  1580. remove.push(key);
  1581. total++
  1582. }
  1583. });
  1584. if (!total) {
  1585. return callback(null)
  1586. }
  1587. var errored = false;
  1588. var completed = 0;
  1589. var db = src.type === "remote" ? src.db : dst.db;
  1590. var transaction = db.transaction([IDBFS.DB_STORE_NAME], "readwrite");
  1591. var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
  1592.  
  1593. function done(err) {
  1594. if (err) {
  1595. if (!done.errored) {
  1596. done.errored = true;
  1597. return callback(err)
  1598. }
  1599. return
  1600. }
  1601. if (++completed >= total) {
  1602. return callback(null)
  1603. }
  1604. }
  1605. transaction.onerror = function(e) {
  1606. done(this.error);
  1607. e.preventDefault()
  1608. };
  1609. create.sort().forEach(function(path) {
  1610. if (dst.type === "local") {
  1611. IDBFS.loadRemoteEntry(store, path, function(err, entry) {
  1612. if (err) return done(err);
  1613. IDBFS.storeLocalEntry(path, entry, done)
  1614. })
  1615. } else {
  1616. IDBFS.loadLocalEntry(path, function(err, entry) {
  1617. if (err) return done(err);
  1618. IDBFS.storeRemoteEntry(store, path, entry, done)
  1619. })
  1620. }
  1621. });
  1622. remove.sort().reverse().forEach(function(path) {
  1623. if (dst.type === "local") {
  1624. IDBFS.removeLocalEntry(path, done)
  1625. } else {
  1626. IDBFS.removeRemoteEntry(store, path, done)
  1627. }
  1628. })
  1629. }
  1630. };
  1631. var NODEFS = {
  1632. isWindows: false,
  1633. staticInit: function() {
  1634. NODEFS.isWindows = !!process.platform.match(/^win/);
  1635. var flags = process["binding"]("constants");
  1636. if (flags["fs"]) {
  1637. flags = flags["fs"]
  1638. }
  1639. NODEFS.flagsForNodeMap = {
  1640. 1024: flags["O_APPEND"],
  1641. 64: flags["O_CREAT"],
  1642. 128: flags["O_EXCL"],
  1643. 0: flags["O_RDONLY"],
  1644. 2: flags["O_RDWR"],
  1645. 4096: flags["O_SYNC"],
  1646. 512: flags["O_TRUNC"],
  1647. 1: flags["O_WRONLY"]
  1648. }
  1649. },
  1650. bufferFrom: function(arrayBuffer) {
  1651. return Buffer.alloc ? Buffer.from(arrayBuffer) : new Buffer(arrayBuffer)
  1652. },
  1653. mount: function(mount) {
  1654. assert(ENVIRONMENT_IS_NODE);
  1655. return NODEFS.createNode(null, "/", NODEFS.getMode(mount.opts.root), 0)
  1656. },
  1657. createNode: function(parent, name, mode, dev) {
  1658. if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
  1659. throw new FS.ErrnoError(ERRNO_CODES.EINVAL)
  1660. }
  1661. var node = FS.createNode(parent, name, mode);
  1662. node.node_ops = NODEFS.node_ops;
  1663. node.stream_ops = NODEFS.stream_ops;
  1664. return node
  1665. },
  1666. getMode: function(path) {
  1667. var stat;
  1668. try {
  1669. stat = fs.lstatSync(path);
  1670. if (NODEFS.isWindows) {
  1671. stat.mode = stat.mode | (stat.mode & 292) >> 2
  1672. }
  1673. } catch (e) {
  1674. if (!e.code) throw e;
  1675. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1676. }
  1677. return stat.mode
  1678. },
  1679. realPath: function(node) {
  1680. var parts = [];
  1681. while (node.parent !== node) {
  1682. parts.push(node.name);
  1683. node = node.parent
  1684. }
  1685. parts.push(node.mount.opts.root);
  1686. parts.reverse();
  1687. return PATH.join.apply(null, parts)
  1688. },
  1689. flagsForNode: function(flags) {
  1690. flags &= ~2097152;
  1691. flags &= ~2048;
  1692. flags &= ~32768;
  1693. flags &= ~524288;
  1694. var newFlags = 0;
  1695. for (var k in NODEFS.flagsForNodeMap) {
  1696. if (flags & k) {
  1697. newFlags |= NODEFS.flagsForNodeMap[k];
  1698. flags ^= k
  1699. }
  1700. }
  1701. if (!flags) {
  1702. return newFlags
  1703. } else {
  1704. throw new FS.ErrnoError(ERRNO_CODES.EINVAL)
  1705. }
  1706. },
  1707. node_ops: {
  1708. getattr: function(node) {
  1709. var path = NODEFS.realPath(node);
  1710. var stat;
  1711. try {
  1712. stat = fs.lstatSync(path)
  1713. } catch (e) {
  1714. if (!e.code) throw e;
  1715. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1716. }
  1717. if (NODEFS.isWindows && !stat.blksize) {
  1718. stat.blksize = 4096
  1719. }
  1720. if (NODEFS.isWindows && !stat.blocks) {
  1721. stat.blocks = (stat.size + stat.blksize - 1) / stat.blksize | 0
  1722. }
  1723. return {
  1724. dev: stat.dev,
  1725. ino: stat.ino,
  1726. mode: stat.mode,
  1727. nlink: stat.nlink,
  1728. uid: stat.uid,
  1729. gid: stat.gid,
  1730. rdev: stat.rdev,
  1731. size: stat.size,
  1732. atime: stat.atime,
  1733. mtime: stat.mtime,
  1734. ctime: stat.ctime,
  1735. blksize: stat.blksize,
  1736. blocks: stat.blocks
  1737. }
  1738. },
  1739. setattr: function(node, attr) {
  1740. var path = NODEFS.realPath(node);
  1741. try {
  1742. if (attr.mode !== undefined) {
  1743. fs.chmodSync(path, attr.mode);
  1744. node.mode = attr.mode
  1745. }
  1746. if (attr.timestamp !== undefined) {
  1747. var date = new Date(attr.timestamp);
  1748. fs.utimesSync(path, date, date)
  1749. }
  1750. if (attr.size !== undefined) {
  1751. fs.truncateSync(path, attr.size)
  1752. }
  1753. } catch (e) {
  1754. if (!e.code) throw e;
  1755. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1756. }
  1757. },
  1758. lookup: function(parent, name) {
  1759. var path = PATH.join2(NODEFS.realPath(parent), name);
  1760. var mode = NODEFS.getMode(path);
  1761. return NODEFS.createNode(parent, name, mode)
  1762. },
  1763. mknod: function(parent, name, mode, dev) {
  1764. var node = NODEFS.createNode(parent, name, mode, dev);
  1765. var path = NODEFS.realPath(node);
  1766. try {
  1767. if (FS.isDir(node.mode)) {
  1768. fs.mkdirSync(path, node.mode)
  1769. } else {
  1770. fs.writeFileSync(path, "", {
  1771. mode: node.mode
  1772. })
  1773. }
  1774. } catch (e) {
  1775. if (!e.code) throw e;
  1776. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1777. }
  1778. return node
  1779. },
  1780. rename: function(oldNode, newDir, newName) {
  1781. var oldPath = NODEFS.realPath(oldNode);
  1782. var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
  1783. try {
  1784. fs.renameSync(oldPath, newPath)
  1785. } catch (e) {
  1786. if (!e.code) throw e;
  1787. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1788. }
  1789. },
  1790. unlink: function(parent, name) {
  1791. var path = PATH.join2(NODEFS.realPath(parent), name);
  1792. try {
  1793. fs.unlinkSync(path)
  1794. } catch (e) {
  1795. if (!e.code) throw e;
  1796. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1797. }
  1798. },
  1799. rmdir: function(parent, name) {
  1800. var path = PATH.join2(NODEFS.realPath(parent), name);
  1801. try {
  1802. fs.rmdirSync(path)
  1803. } catch (e) {
  1804. if (!e.code) throw e;
  1805. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1806. }
  1807. },
  1808. readdir: function(node) {
  1809. var path = NODEFS.realPath(node);
  1810. try {
  1811. return fs.readdirSync(path)
  1812. } catch (e) {
  1813. if (!e.code) throw e;
  1814. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1815. }
  1816. },
  1817. symlink: function(parent, newName, oldPath) {
  1818. var newPath = PATH.join2(NODEFS.realPath(parent), newName);
  1819. try {
  1820. fs.symlinkSync(oldPath, newPath)
  1821. } catch (e) {
  1822. if (!e.code) throw e;
  1823. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1824. }
  1825. },
  1826. readlink: function(node) {
  1827. var path = NODEFS.realPath(node);
  1828. try {
  1829. path = fs.readlinkSync(path);
  1830. path = NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root), path);
  1831. return path
  1832. } catch (e) {
  1833. if (!e.code) throw e;
  1834. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1835. }
  1836. }
  1837. },
  1838. stream_ops: {
  1839. open: function(stream) {
  1840. var path = NODEFS.realPath(stream.node);
  1841. try {
  1842. if (FS.isFile(stream.node.mode)) {
  1843. stream.nfd = fs.openSync(path, NODEFS.flagsForNode(stream.flags))
  1844. }
  1845. } catch (e) {
  1846. if (!e.code) throw e;
  1847. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1848. }
  1849. },
  1850. close: function(stream) {
  1851. try {
  1852. if (FS.isFile(stream.node.mode) && stream.nfd) {
  1853. fs.closeSync(stream.nfd)
  1854. }
  1855. } catch (e) {
  1856. if (!e.code) throw e;
  1857. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1858. }
  1859. },
  1860. read: function(stream, buffer, offset, length, position) {
  1861. if (length === 0) return 0;
  1862. try {
  1863. return fs.readSync(stream.nfd, NODEFS.bufferFrom(buffer.buffer), offset, length, position)
  1864. } catch (e) {
  1865. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1866. }
  1867. },
  1868. write: function(stream, buffer, offset, length, position) {
  1869. try {
  1870. return fs.writeSync(stream.nfd, NODEFS.bufferFrom(buffer.buffer), offset, length, position)
  1871. } catch (e) {
  1872. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1873. }
  1874. },
  1875. llseek: function(stream, offset, whence) {
  1876. var position = offset;
  1877. if (whence === 1) {
  1878. position += stream.position
  1879. } else if (whence === 2) {
  1880. if (FS.isFile(stream.node.mode)) {
  1881. try {
  1882. var stat = fs.fstatSync(stream.nfd);
  1883. position += stat.size
  1884. } catch (e) {
  1885. throw new FS.ErrnoError(ERRNO_CODES[e.code])
  1886. }
  1887. }
  1888. }
  1889. if (position < 0) {
  1890. throw new FS.ErrnoError(ERRNO_CODES.EINVAL)
  1891. }
  1892. return position
  1893. }
  1894. }
  1895. };
  1896. var WORKERFS = {
  1897. DIR_MODE: 16895,
  1898. FILE_MODE: 33279,
  1899. reader: null,
  1900. mount: function(mount) {
  1901. assert(ENVIRONMENT_IS_WORKER);
  1902. if (!WORKERFS.reader) WORKERFS.reader = new FileReaderSync;
  1903. var root = WORKERFS.createNode(null, "/", WORKERFS.DIR_MODE, 0);
  1904. var createdParents = {};
  1905.  
  1906. function ensureParent(path) {
  1907. var parts = path.split("/");
  1908. var parent = root;
  1909. for (var i = 0; i < parts.length - 1; i++) {
  1910. var curr = parts.slice(0, i + 1).join("/");
  1911. if (!createdParents[curr]) {
  1912. createdParents[curr] = WORKERFS.createNode(parent, parts[i], WORKERFS.DIR_MODE, 0)
  1913. }
  1914. parent = createdParents[curr]
  1915. }
  1916. return parent
  1917. }
  1918.  
  1919. function base(path) {
  1920. var parts = path.split("/");
  1921. return parts[parts.length - 1]
  1922. }
  1923. Array.prototype.forEach.call(mount.opts["files"] || [], function(file) {
  1924. WORKERFS.createNode(ensureParent(file.name), base(file.name), WORKERFS.FILE_MODE, 0, file, file.lastModifiedDate)
  1925. });
  1926. (mount.opts["blobs"] || []).forEach(function(obj) {
  1927. WORKERFS.createNode(ensureParent(obj["name"]), base(obj["name"]), WORKERFS.FILE_MODE, 0, obj["data"])
  1928. });
  1929. (mount.opts["packages"] || []).forEach(function(pack) {
  1930. pack["metadata"].files.forEach(function(file) {
  1931. var name = file.filename.substr(1);
  1932. WORKERFS.createNode(ensureParent(name), base(name), WORKERFS.FILE_MODE, 0, pack["blob"].slice(file.start, file.end))
  1933. })
  1934. });
  1935. return root
  1936. },
  1937. createNode: function(parent, name, mode, dev, contents, mtime) {
  1938. var node = FS.createNode(parent, name, mode);
  1939. node.mode = mode;
  1940. node.node_ops = WORKERFS.node_ops;
  1941. node.stream_ops = WORKERFS.stream_ops;
  1942. node.timestamp = (mtime || new Date).getTime();
  1943. assert(WORKERFS.FILE_MODE !== WORKERFS.DIR_MODE);
  1944. if (mode === WORKERFS.FILE_MODE) {
  1945. node.size = contents.size;
  1946. node.contents = contents
  1947. } else {
  1948. node.size = 4096;
  1949. node.contents = {}
  1950. }
  1951. if (parent) {
  1952. parent.contents[name] = node
  1953. }
  1954. return node
  1955. },
  1956. node_ops: {
  1957. getattr: function(node) {
  1958. return {
  1959. dev: 1,
  1960. ino: undefined,
  1961. mode: node.mode,
  1962. nlink: 1,
  1963. uid: 0,
  1964. gid: 0,
  1965. rdev: undefined,
  1966. size: node.size,
  1967. atime: new Date(node.timestamp),
  1968. mtime: new Date(node.timestamp),
  1969. ctime: new Date(node.timestamp),
  1970. blksize: 4096,
  1971. blocks: Math.ceil(node.size / 4096)
  1972. }
  1973. },
  1974. setattr: function(node, attr) {
  1975. if (attr.mode !== undefined) {
  1976. node.mode = attr.mode
  1977. }
  1978. if (attr.timestamp !== undefined) {
  1979. node.timestamp = attr.timestamp
  1980. }
  1981. },
  1982. lookup: function(parent, name) {
  1983. throw new FS.ErrnoError(ERRNO_CODES.ENOENT)
  1984. },
  1985. mknod: function(parent, name, mode, dev) {
  1986. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  1987. },
  1988. rename: function(oldNode, newDir, newName) {
  1989. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  1990. },
  1991. unlink: function(parent, name) {
  1992. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  1993. },
  1994. rmdir: function(parent, name) {
  1995. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  1996. },
  1997. readdir: function(node) {
  1998. var entries = [".", ".."];
  1999. for (var key in node.contents) {
  2000. if (!node.contents.hasOwnProperty(key)) {
  2001. continue
  2002. }
  2003. entries.push(key)
  2004. }
  2005. return entries
  2006. },
  2007. symlink: function(parent, newName, oldPath) {
  2008. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  2009. },
  2010. readlink: function(node) {
  2011. throw new FS.ErrnoError(ERRNO_CODES.EPERM)
  2012. }
  2013. },
  2014. stream_ops: {
  2015. read: function(stream, buffer, offset, length, position) {
  2016. if (position >= stream.node.size) return 0;
  2017. var chunk = stream.node.contents.slice(position, position + length);
  2018. var ab = WORKERFS.reader.readAsArrayBuffer(chunk);
  2019. buffer.set(new Uint8Array(ab), offset);
  2020. return chunk.size
  2021. },
  2022. write: function(stream, buffer, offset, length, position) {
  2023. throw new FS.ErrnoError(ERRNO_CODES.EIO)
  2024. },
  2025. llseek: function(stream, offset, whence) {
  2026. var position = offset;
  2027. if (whence === 1) {
  2028. position += stream.position
  2029. } else if (whence === 2) {
  2030. if (FS.isFile(stream.node.mode)) {
  2031. position += stream.node.size
  2032. }
  2033. }
  2034. if (position < 0) {
  2035. throw new FS.ErrnoError(ERRNO_CODES.EINVAL)
  2036. }
  2037. return position
  2038. }
  2039. }
  2040. };
  2041. var FS = {
  2042. root: null,
  2043. mounts: [],
  2044. devices: {},
  2045. streams: [],
  2046. nextInode: 1,
  2047. nameTable: null,
  2048. currentPath: "/",
  2049. initialized: false,
  2050. ignorePermissions: true,
  2051. trackingDelegate: {},
  2052. tracking: {
  2053. openFlags: {
  2054. READ: 1,
  2055. WRITE: 2
  2056. }
  2057. },
  2058. ErrnoError: null,
  2059. genericErrors: {},
  2060. filesystems: null,
  2061. syncFSRequests: 0,
  2062. handleFSError: function(e) {
  2063. if (!(e instanceof FS.ErrnoError)) throw e + " : " + stackTrace();
  2064. return ___setErrNo(e.errno)
  2065. },
  2066. lookupPath: function(path, opts) {
  2067. path = PATH.resolve(FS.cwd(), path);
  2068. opts = opts || {};
  2069. if (!path) return {
  2070. path: "",
  2071. node: null
  2072. };
  2073. var defaults = {
  2074. follow_mount: true,
  2075. recurse_count: 0
  2076. };
  2077. for (var key in defaults) {
  2078. if (opts[key] === undefined) {
  2079. opts[key] = defaults[key]
  2080. }
  2081. }
  2082. if (opts.recurse_count > 8) {
  2083. throw new FS.ErrnoError(40)
  2084. }
  2085. var parts = PATH.normalizeArray(path.split("/").filter(function(p) {
  2086. return !!p
  2087. }), false);
  2088. var current = FS.root;
  2089. var current_path = "/";
  2090. for (var i = 0; i < parts.length; i++) {
  2091. var islast = i === parts.length - 1;
  2092. if (islast && opts.parent) {
  2093. break
  2094. }
  2095. current = FS.lookupNode(current, parts[i]);
  2096. current_path = PATH.join2(current_path, parts[i]);
  2097. if (FS.isMountpoint(current)) {
  2098. if (!islast || islast && opts.follow_mount) {
  2099. current = current.mounted.root
  2100. }
  2101. }
  2102. if (!islast || opts.follow) {
  2103. var count = 0;
  2104. while (FS.isLink(current.mode)) {
  2105. var link = FS.readlink(current_path);
  2106. current_path = PATH.resolve(PATH.dirname(current_path), link);
  2107. var lookup = FS.lookupPath(current_path, {
  2108. recurse_count: opts.recurse_count
  2109. });
  2110. current = lookup.node;
  2111. if (count++ > 40) {
  2112. throw new FS.ErrnoError(40)
  2113. }
  2114. }
  2115. }
  2116. }
  2117. return {
  2118. path: current_path,
  2119. node: current
  2120. }
  2121. },
  2122. getPath: function(node) {
  2123. var path;
  2124. while (true) {
  2125. if (FS.isRoot(node)) {
  2126. var mount = node.mount.mountpoint;
  2127. if (!path) return mount;
  2128. return mount[mount.length - 1] !== "/" ? mount + "/" + path : mount + path
  2129. }
  2130. path = path ? node.name + "/" + path : node.name;
  2131. node = node.parent
  2132. }
  2133. },
  2134. hashName: function(parentid, name) {
  2135. var hash = 0;
  2136. for (var i = 0; i < name.length; i++) {
  2137. hash = (hash << 5) - hash + name.charCodeAt(i) | 0
  2138. }
  2139. return (parentid + hash >>> 0) % FS.nameTable.length
  2140. },
  2141. hashAddNode: function(node) {
  2142. var hash = FS.hashName(node.parent.id, node.name);
  2143. node.name_next = FS.nameTable[hash];
  2144. FS.nameTable[hash] = node
  2145. },
  2146. hashRemoveNode: function(node) {
  2147. var hash = FS.hashName(node.parent.id, node.name);
  2148. if (FS.nameTable[hash] === node) {
  2149. FS.nameTable[hash] = node.name_next
  2150. } else {
  2151. var current = FS.nameTable[hash];
  2152. while (current) {
  2153. if (current.name_next === node) {
  2154. current.name_next = node.name_next;
  2155. break
  2156. }
  2157. current = current.name_next
  2158. }
  2159. }
  2160. },
  2161. lookupNode: function(parent, name) {
  2162. var err = FS.mayLookup(parent);
  2163. if (err) {
  2164. throw new FS.ErrnoError(err, parent)
  2165. }
  2166. var hash = FS.hashName(parent.id, name);
  2167. for (var node = FS.nameTable[hash]; node; node = node.name_next) {
  2168. var nodeName = node.name;
  2169. if (node.parent.id === parent.id && nodeName === name) {
  2170. return node
  2171. }
  2172. }
  2173. return FS.lookup(parent, name)
  2174. },
  2175. createNode: function(parent, name, mode, rdev) {
  2176. if (!FS.FSNode) {
  2177. FS.FSNode = function(parent, name, mode, rdev) {
  2178. if (!parent) {
  2179. parent = this
  2180. }
  2181. this.parent = parent;
  2182. this.mount = parent.mount;
  2183. this.mounted = null;
  2184. this.id = FS.nextInode++;
  2185. this.name = name;
  2186. this.mode = mode;
  2187. this.node_ops = {};
  2188. this.stream_ops = {};
  2189. this.rdev = rdev
  2190. };
  2191. FS.FSNode.prototype = {};
  2192. var readMode = 292 | 73;
  2193. var writeMode = 146;
  2194. Object.defineProperties(FS.FSNode.prototype, {
  2195. read: {
  2196. get: function() {
  2197. return (this.mode & readMode) === readMode
  2198. },
  2199. set: function(val) {
  2200. val ? this.mode |= readMode : this.mode &= ~readMode
  2201. }
  2202. },
  2203. write: {
  2204. get: function() {
  2205. return (this.mode & writeMode) === writeMode
  2206. },
  2207. set: function(val) {
  2208. val ? this.mode |= writeMode : this.mode &= ~writeMode
  2209. }
  2210. },
  2211. isFolder: {
  2212. get: function() {
  2213. return FS.isDir(this.mode)
  2214. }
  2215. },
  2216. isDevice: {
  2217. get: function() {
  2218. return FS.isChrdev(this.mode)
  2219. }
  2220. }
  2221. })
  2222. }
  2223. var node = new FS.FSNode(parent, name, mode, rdev);
  2224. FS.hashAddNode(node);
  2225. return node
  2226. },
  2227. destroyNode: function(node) {
  2228. FS.hashRemoveNode(node)
  2229. },
  2230. isRoot: function(node) {
  2231. return node === node.parent
  2232. },
  2233. isMountpoint: function(node) {
  2234. return !!node.mounted
  2235. },
  2236. isFile: function(mode) {
  2237. return (mode & 61440) === 32768
  2238. },
  2239. isDir: function(mode) {
  2240. return (mode & 61440) === 16384
  2241. },
  2242. isLink: function(mode) {
  2243. return (mode & 61440) === 40960
  2244. },
  2245. isChrdev: function(mode) {
  2246. return (mode & 61440) === 8192
  2247. },
  2248. isBlkdev: function(mode) {
  2249. return (mode & 61440) === 24576
  2250. },
  2251. isFIFO: function(mode) {
  2252. return (mode & 61440) === 4096
  2253. },
  2254. isSocket: function(mode) {
  2255. return (mode & 49152) === 49152
  2256. },
  2257. flagModes: {
  2258. "r": 0,
  2259. "rs": 1052672,
  2260. "r+": 2,
  2261. "w": 577,
  2262. "wx": 705,
  2263. "xw": 705,
  2264. "w+": 578,
  2265. "wx+": 706,
  2266. "xw+": 706,
  2267. "a": 1089,
  2268. "ax": 1217,
  2269. "xa": 1217,
  2270. "a+": 1090,
  2271. "ax+": 1218,
  2272. "xa+": 1218
  2273. },
  2274. modeStringToFlags: function(str) {
  2275. var flags = FS.flagModes[str];
  2276. if (typeof flags === "undefined") {
  2277. throw new Error("Unknown file open mode: " + str)
  2278. }
  2279. return flags
  2280. },
  2281. flagsToPermissionString: function(flag) {
  2282. var perms = ["r", "w", "rw"][flag & 3];
  2283. if (flag & 512) {
  2284. perms += "w"
  2285. }
  2286. return perms
  2287. },
  2288. nodePermissions: function(node, perms) {
  2289. if (FS.ignorePermissions) {
  2290. return 0
  2291. }
  2292. if (perms.indexOf("r") !== -1 && !(node.mode & 292)) {
  2293. return 13
  2294. } else if (perms.indexOf("w") !== -1 && !(node.mode & 146)) {
  2295. return 13
  2296. } else if (perms.indexOf("x") !== -1 && !(node.mode & 73)) {
  2297. return 13
  2298. }
  2299. return 0
  2300. },
  2301. mayLookup: function(dir) {
  2302. var err = FS.nodePermissions(dir, "x");
  2303. if (err) return err;
  2304. if (!dir.node_ops.lookup) return 13;
  2305. return 0
  2306. },
  2307. mayCreate: function(dir, name) {
  2308. try {
  2309. var node = FS.lookupNode(dir, name);
  2310. return 17
  2311. } catch (e) {}
  2312. return FS.nodePermissions(dir, "wx")
  2313. },
  2314. mayDelete: function(dir, name, isdir) {
  2315. var node;
  2316. try {
  2317. node = FS.lookupNode(dir, name)
  2318. } catch (e) {
  2319. return e.errno
  2320. }
  2321. var err = FS.nodePermissions(dir, "wx");
  2322. if (err) {
  2323. return err
  2324. }
  2325. if (isdir) {
  2326. if (!FS.isDir(node.mode)) {
  2327. return 20
  2328. }
  2329. if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
  2330. return 16
  2331. }
  2332. } else {
  2333. if (FS.isDir(node.mode)) {
  2334. return 21
  2335. }
  2336. }
  2337. return 0
  2338. },
  2339. mayOpen: function(node, flags) {
  2340. if (!node) {
  2341. return 2
  2342. }
  2343. if (FS.isLink(node.mode)) {
  2344. return 40
  2345. } else if (FS.isDir(node.mode)) {
  2346. if (FS.flagsToPermissionString(flags) !== "r" || flags & 512) {
  2347. return 21
  2348. }
  2349. }
  2350. return FS.nodePermissions(node, FS.flagsToPermissionString(flags))
  2351. },
  2352. MAX_OPEN_FDS: 4096,
  2353. nextfd: function(fd_start, fd_end) {
  2354. fd_start = fd_start || 0;
  2355. fd_end = fd_end || FS.MAX_OPEN_FDS;
  2356. for (var fd = fd_start; fd <= fd_end; fd++) {
  2357. if (!FS.streams[fd]) {
  2358. return fd
  2359. }
  2360. }
  2361. throw new FS.ErrnoError(24)
  2362. },
  2363. getStream: function(fd) {
  2364. return FS.streams[fd]
  2365. },
  2366. createStream: function(stream, fd_start, fd_end) {
  2367. if (!FS.FSStream) {
  2368. FS.FSStream = function() {};
  2369. FS.FSStream.prototype = {};
  2370. Object.defineProperties(FS.FSStream.prototype, {
  2371. object: {
  2372. get: function() {
  2373. return this.node
  2374. },
  2375. set: function(val) {
  2376. this.node = val
  2377. }
  2378. },
  2379. isRead: {
  2380. get: function() {
  2381. return (this.flags & 2097155) !== 1
  2382. }
  2383. },
  2384. isWrite: {
  2385. get: function() {
  2386. return (this.flags & 2097155) !== 0
  2387. }
  2388. },
  2389. isAppend: {
  2390. get: function() {
  2391. return this.flags & 1024
  2392. }
  2393. }
  2394. })
  2395. }
  2396. var newStream = new FS.FSStream;
  2397. for (var p in stream) {
  2398. newStream[p] = stream[p]
  2399. }
  2400. stream = newStream;
  2401. var fd = FS.nextfd(fd_start, fd_end);
  2402. stream.fd = fd;
  2403. FS.streams[fd] = stream;
  2404. return stream
  2405. },
  2406. closeStream: function(fd) {
  2407. FS.streams[fd] = null
  2408. },
  2409. chrdev_stream_ops: {
  2410. open: function(stream) {
  2411. var device = FS.getDevice(stream.node.rdev);
  2412. stream.stream_ops = device.stream_ops;
  2413. if (stream.stream_ops.open) {
  2414. stream.stream_ops.open(stream)
  2415. }
  2416. },
  2417. llseek: function() {
  2418. throw new FS.ErrnoError(29)
  2419. }
  2420. },
  2421. major: function(dev) {
  2422. return dev >> 8
  2423. },
  2424. minor: function(dev) {
  2425. return dev & 255
  2426. },
  2427. makedev: function(ma, mi) {
  2428. return ma << 8 | mi
  2429. },
  2430. registerDevice: function(dev, ops) {
  2431. FS.devices[dev] = {
  2432. stream_ops: ops
  2433. }
  2434. },
  2435. getDevice: function(dev) {
  2436. return FS.devices[dev]
  2437. },
  2438. getMounts: function(mount) {
  2439. var mounts = [];
  2440. var check = [mount];
  2441. while (check.length) {
  2442. var m = check.pop();
  2443. mounts.push(m);
  2444. check.push.apply(check, m.mounts)
  2445. }
  2446. return mounts
  2447. },
  2448. syncfs: function(populate, callback) {
  2449. if (typeof populate === "function") {
  2450. callback = populate;
  2451. populate = false
  2452. }
  2453. FS.syncFSRequests++;
  2454. if (FS.syncFSRequests > 1) {
  2455. console.log("warning: " + FS.syncFSRequests + " FS.syncfs operations in flight at once, probably just doing extra work")
  2456. }
  2457. var mounts = FS.getMounts(FS.root.mount);
  2458. var completed = 0;
  2459.  
  2460. function doCallback(err) {
  2461. FS.syncFSRequests--;
  2462. return callback(err)
  2463. }
  2464.  
  2465. function done(err) {
  2466. if (err) {
  2467. if (!done.errored) {
  2468. done.errored = true;
  2469. return doCallback(err)
  2470. }
  2471. return
  2472. }
  2473. if (++completed >= mounts.length) {
  2474. doCallback(null)
  2475. }
  2476. }
  2477. mounts.forEach(function(mount) {
  2478. if (!mount.type.syncfs) {
  2479. return done(null)
  2480. }
  2481. mount.type.syncfs(mount, populate, done)
  2482. })
  2483. },
  2484. mount: function(type, opts, mountpoint) {
  2485. var root = mountpoint === "/";
  2486. var pseudo = !mountpoint;
  2487. var node;
  2488. if (root && FS.root) {
  2489. throw new FS.ErrnoError(16)
  2490. } else if (!root && !pseudo) {
  2491. var lookup = FS.lookupPath(mountpoint, {
  2492. follow_mount: false
  2493. });
  2494. mountpoint = lookup.path;
  2495. node = lookup.node;
  2496. if (FS.isMountpoint(node)) {
  2497. throw new FS.ErrnoError(16)
  2498. }
  2499. if (!FS.isDir(node.mode)) {
  2500. throw new FS.ErrnoError(20)
  2501. }
  2502. }
  2503. var mount = {
  2504. type: type,
  2505. opts: opts,
  2506. mountpoint: mountpoint,
  2507. mounts: []
  2508. };
  2509. var mountRoot = type.mount(mount);
  2510. mountRoot.mount = mount;
  2511. mount.root = mountRoot;
  2512. if (root) {
  2513. FS.root = mountRoot
  2514. } else if (node) {
  2515. node.mounted = mount;
  2516. if (node.mount) {
  2517. node.mount.mounts.push(mount)
  2518. }
  2519. }
  2520. return mountRoot
  2521. },
  2522. unmount: function(mountpoint) {
  2523. var lookup = FS.lookupPath(mountpoint, {
  2524. follow_mount: false
  2525. });
  2526. if (!FS.isMountpoint(lookup.node)) {
  2527. throw new FS.ErrnoError(22)
  2528. }
  2529. var node = lookup.node;
  2530. var mount = node.mounted;
  2531. var mounts = FS.getMounts(mount);
  2532. Object.keys(FS.nameTable).forEach(function(hash) {
  2533. var current = FS.nameTable[hash];
  2534. while (current) {
  2535. var next = current.name_next;
  2536. if (mounts.indexOf(current.mount) !== -1) {
  2537. FS.destroyNode(current)
  2538. }
  2539. current = next
  2540. }
  2541. });
  2542. node.mounted = null;
  2543. var idx = node.mount.mounts.indexOf(mount);
  2544. node.mount.mounts.splice(idx, 1)
  2545. },
  2546. lookup: function(parent, name) {
  2547. return parent.node_ops.lookup(parent, name)
  2548. },
  2549. mknod: function(path, mode, dev) {
  2550. var lookup = FS.lookupPath(path, {
  2551. parent: true
  2552. });
  2553. var parent = lookup.node;
  2554. var name = PATH.basename(path);
  2555. if (!name || name === "." || name === "..") {
  2556. throw new FS.ErrnoError(22)
  2557. }
  2558. var err = FS.mayCreate(parent, name);
  2559. if (err) {
  2560. throw new FS.ErrnoError(err)
  2561. }
  2562. if (!parent.node_ops.mknod) {
  2563. throw new FS.ErrnoError(1)
  2564. }
  2565. return parent.node_ops.mknod(parent, name, mode, dev)
  2566. },
  2567. create: function(path, mode) {
  2568. mode = mode !== undefined ? mode : 438;
  2569. mode &= 4095;
  2570. mode |= 32768;
  2571. return FS.mknod(path, mode, 0)
  2572. },
  2573. mkdir: function(path, mode) {
  2574. mode = mode !== undefined ? mode : 511;
  2575. mode &= 511 | 512;
  2576. mode |= 16384;
  2577. return FS.mknod(path, mode, 0)
  2578. },
  2579. mkdirTree: function(path, mode) {
  2580. var dirs = path.split("/");
  2581. var d = "";
  2582. for (var i = 0; i < dirs.length; ++i) {
  2583. if (!dirs[i]) continue;
  2584. d += "/" + dirs[i];
  2585. try {
  2586. FS.mkdir(d, mode)
  2587. } catch (e) {
  2588. if (e.errno != 17) throw e
  2589. }
  2590. }
  2591. },
  2592. mkdev: function(path, mode, dev) {
  2593. if (typeof dev === "undefined") {
  2594. dev = mode;
  2595. mode = 438
  2596. }
  2597. mode |= 8192;
  2598. return FS.mknod(path, mode, dev)
  2599. },
  2600. symlink: function(oldpath, newpath) {
  2601. if (!PATH.resolve(oldpath)) {
  2602. throw new FS.ErrnoError(2)
  2603. }
  2604. var lookup = FS.lookupPath(newpath, {
  2605. parent: true
  2606. });
  2607. var parent = lookup.node;
  2608. if (!parent) {
  2609. throw new FS.ErrnoError(2)
  2610. }
  2611. var newname = PATH.basename(newpath);
  2612. var err = FS.mayCreate(parent, newname);
  2613. if (err) {
  2614. throw new FS.ErrnoError(err)
  2615. }
  2616. if (!parent.node_ops.symlink) {
  2617. throw new FS.ErrnoError(1)
  2618. }
  2619. return parent.node_ops.symlink(parent, newname, oldpath)
  2620. },
  2621. rename: function(old_path, new_path) {
  2622. var old_dirname = PATH.dirname(old_path);
  2623. var new_dirname = PATH.dirname(new_path);
  2624. var old_name = PATH.basename(old_path);
  2625. var new_name = PATH.basename(new_path);
  2626. var lookup, old_dir, new_dir;
  2627. try {
  2628. lookup = FS.lookupPath(old_path, {
  2629. parent: true
  2630. });
  2631. old_dir = lookup.node;
  2632. lookup = FS.lookupPath(new_path, {
  2633. parent: true
  2634. });
  2635. new_dir = lookup.node
  2636. } catch (e) {
  2637. throw new FS.ErrnoError(16)
  2638. }
  2639. if (!old_dir || !new_dir) throw new FS.ErrnoError(2);
  2640. if (old_dir.mount !== new_dir.mount) {
  2641. throw new FS.ErrnoError(18)
  2642. }
  2643. var old_node = FS.lookupNode(old_dir, old_name);
  2644. var relative = PATH.relative(old_path, new_dirname);
  2645. if (relative.charAt(0) !== ".") {
  2646. throw new FS.ErrnoError(22)
  2647. }
  2648. relative = PATH.relative(new_path, old_dirname);
  2649. if (relative.charAt(0) !== ".") {
  2650. throw new FS.ErrnoError(39)
  2651. }
  2652. var new_node;
  2653. try {
  2654. new_node = FS.lookupNode(new_dir, new_name)
  2655. } catch (e) {}
  2656. if (old_node === new_node) {
  2657. return
  2658. }
  2659. var isdir = FS.isDir(old_node.mode);
  2660. var err = FS.mayDelete(old_dir, old_name, isdir);
  2661. if (err) {
  2662. throw new FS.ErrnoError(err)
  2663. }
  2664. err = new_node ? FS.mayDelete(new_dir, new_name, isdir) : FS.mayCreate(new_dir, new_name);
  2665. if (err) {
  2666. throw new FS.ErrnoError(err)
  2667. }
  2668. if (!old_dir.node_ops.rename) {
  2669. throw new FS.ErrnoError(1)
  2670. }
  2671. if (FS.isMountpoint(old_node) || new_node && FS.isMountpoint(new_node)) {
  2672. throw new FS.ErrnoError(16)
  2673. }
  2674. if (new_dir !== old_dir) {
  2675. err = FS.nodePermissions(old_dir, "w");
  2676. if (err) {
  2677. throw new FS.ErrnoError(err)
  2678. }
  2679. }
  2680. try {
  2681. if (FS.trackingDelegate["willMovePath"]) {
  2682. FS.trackingDelegate["willMovePath"](old_path, new_path)
  2683. }
  2684. } catch (e) {
  2685. console.log("FS.trackingDelegate['willMovePath']('" + old_path + "', '" + new_path + "') threw an exception: " + e.message)
  2686. }
  2687. FS.hashRemoveNode(old_node);
  2688. try {
  2689. old_dir.node_ops.rename(old_node, new_dir, new_name)
  2690. } catch (e) {
  2691. throw e
  2692. } finally {
  2693. FS.hashAddNode(old_node)
  2694. }
  2695. try {
  2696. if (FS.trackingDelegate["onMovePath"]) FS.trackingDelegate["onMovePath"](old_path, new_path)
  2697. } catch (e) {
  2698. console.log("FS.trackingDelegate['onMovePath']('" + old_path + "', '" + new_path + "') threw an exception: " + e.message)
  2699. }
  2700. },
  2701. rmdir: function(path) {
  2702. var lookup = FS.lookupPath(path, {
  2703. parent: true
  2704. });
  2705. var parent = lookup.node;
  2706. var name = PATH.basename(path);
  2707. var node = FS.lookupNode(parent, name);
  2708. var err = FS.mayDelete(parent, name, true);
  2709. if (err) {
  2710. throw new FS.ErrnoError(err)
  2711. }
  2712. if (!parent.node_ops.rmdir) {
  2713. throw new FS.ErrnoError(1)
  2714. }
  2715. if (FS.isMountpoint(node)) {
  2716. throw new FS.ErrnoError(16)
  2717. }
  2718. try {
  2719. if (FS.trackingDelegate["willDeletePath"]) {
  2720. FS.trackingDelegate["willDeletePath"](path)
  2721. }
  2722. } catch (e) {
  2723. console.log("FS.trackingDelegate['willDeletePath']('" + path + "') threw an exception: " + e.message)
  2724. }
  2725. parent.node_ops.rmdir(parent, name);
  2726. FS.destroyNode(node);
  2727. try {
  2728. if (FS.trackingDelegate["onDeletePath"]) FS.trackingDelegate["onDeletePath"](path)
  2729. } catch (e) {
  2730. console.log("FS.trackingDelegate['onDeletePath']('" + path + "') threw an exception: " + e.message)
  2731. }
  2732. },
  2733. readdir: function(path) {
  2734. var lookup = FS.lookupPath(path, {
  2735. follow: true
  2736. });
  2737. var node = lookup.node;
  2738. if (!node.node_ops.readdir) {
  2739. throw new FS.ErrnoError(20)
  2740. }
  2741. return node.node_ops.readdir(node)
  2742. },
  2743. unlink: function(path) {
  2744. var lookup = FS.lookupPath(path, {
  2745. parent: true
  2746. });
  2747. var parent = lookup.node;
  2748. var name = PATH.basename(path);
  2749. var node = FS.lookupNode(parent, name);
  2750. var err = FS.mayDelete(parent, name, false);
  2751. if (err) {
  2752. throw new FS.ErrnoError(err)
  2753. }
  2754. if (!parent.node_ops.unlink) {
  2755. throw new FS.ErrnoError(1)
  2756. }
  2757. if (FS.isMountpoint(node)) {
  2758. throw new FS.ErrnoError(16)
  2759. }
  2760. try {
  2761. if (FS.trackingDelegate["willDeletePath"]) {
  2762. FS.trackingDelegate["willDeletePath"](path)
  2763. }
  2764. } catch (e) {
  2765. console.log("FS.trackingDelegate['willDeletePath']('" + path + "') threw an exception: " + e.message)
  2766. }
  2767. parent.node_ops.unlink(parent, name);
  2768. FS.destroyNode(node);
  2769. try {
  2770. if (FS.trackingDelegate["onDeletePath"]) FS.trackingDelegate["onDeletePath"](path)
  2771. } catch (e) {
  2772. console.log("FS.trackingDelegate['onDeletePath']('" + path + "') threw an exception: " + e.message)
  2773. }
  2774. },
  2775. readlink: function(path) {
  2776. var lookup = FS.lookupPath(path);
  2777. var link = lookup.node;
  2778. if (!link) {
  2779. throw new FS.ErrnoError(2)
  2780. }
  2781. if (!link.node_ops.readlink) {
  2782. throw new FS.ErrnoError(22)
  2783. }
  2784. return PATH.resolve(FS.getPath(link.parent), link.node_ops.readlink(link))
  2785. },
  2786. stat: function(path, dontFollow) {
  2787. var lookup = FS.lookupPath(path, {
  2788. follow: !dontFollow
  2789. });
  2790. var node = lookup.node;
  2791. if (!node) {
  2792. throw new FS.ErrnoError(2)
  2793. }
  2794. if (!node.node_ops.getattr) {
  2795. throw new FS.ErrnoError(1)
  2796. }
  2797. return node.node_ops.getattr(node)
  2798. },
  2799. lstat: function(path) {
  2800. return FS.stat(path, true)
  2801. },
  2802. chmod: function(path, mode, dontFollow) {
  2803. var node;
  2804. if (typeof path === "string") {
  2805. var lookup = FS.lookupPath(path, {
  2806. follow: !dontFollow
  2807. });
  2808. node = lookup.node
  2809. } else {
  2810. node = path
  2811. }
  2812. if (!node.node_ops.setattr) {
  2813. throw new FS.ErrnoError(1)
  2814. }
  2815. node.node_ops.setattr(node, {
  2816. mode: mode & 4095 | node.mode & ~4095,
  2817. timestamp: Date.now()
  2818. })
  2819. },
  2820. lchmod: function(path, mode) {
  2821. FS.chmod(path, mode, true)
  2822. },
  2823. fchmod: function(fd, mode) {
  2824. var stream = FS.getStream(fd);
  2825. if (!stream) {
  2826. throw new FS.ErrnoError(9)
  2827. }
  2828. FS.chmod(stream.node, mode)
  2829. },
  2830. chown: function(path, uid, gid, dontFollow) {
  2831. var node;
  2832. if (typeof path === "string") {
  2833. var lookup = FS.lookupPath(path, {
  2834. follow: !dontFollow
  2835. });
  2836. node = lookup.node
  2837. } else {
  2838. node = path
  2839. }
  2840. if (!node.node_ops.setattr) {
  2841. throw new FS.ErrnoError(1)
  2842. }
  2843. node.node_ops.setattr(node, {
  2844. timestamp: Date.now()
  2845. })
  2846. },
  2847. lchown: function(path, uid, gid) {
  2848. FS.chown(path, uid, gid, true)
  2849. },
  2850. fchown: function(fd, uid, gid) {
  2851. var stream = FS.getStream(fd);
  2852. if (!stream) {
  2853. throw new FS.ErrnoError(9)
  2854. }
  2855. FS.chown(stream.node, uid, gid)
  2856. },
  2857. truncate: function(path, len) {
  2858. if (len < 0) {
  2859. throw new FS.ErrnoError(22)
  2860. }
  2861. var node;
  2862. if (typeof path === "string") {
  2863. var lookup = FS.lookupPath(path, {
  2864. follow: true
  2865. });
  2866. node = lookup.node
  2867. } else {
  2868. node = path
  2869. }
  2870. if (!node.node_ops.setattr) {
  2871. throw new FS.ErrnoError(1)
  2872. }
  2873. if (FS.isDir(node.mode)) {
  2874. throw new FS.ErrnoError(21)
  2875. }
  2876. if (!FS.isFile(node.mode)) {
  2877. throw new FS.ErrnoError(22)
  2878. }
  2879. var err = FS.nodePermissions(node, "w");
  2880. if (err) {
  2881. throw new FS.ErrnoError(err)
  2882. }
  2883. node.node_ops.setattr(node, {
  2884. size: len,
  2885. timestamp: Date.now()
  2886. })
  2887. },
  2888. ftruncate: function(fd, len) {
  2889. var stream = FS.getStream(fd);
  2890. if (!stream) {
  2891. throw new FS.ErrnoError(9)
  2892. }
  2893. if ((stream.flags & 2097155) === 0) {
  2894. throw new FS.ErrnoError(22)
  2895. }
  2896. FS.truncate(stream.node, len)
  2897. },
  2898. utime: function(path, atime, mtime) {
  2899. var lookup = FS.lookupPath(path, {
  2900. follow: true
  2901. });
  2902. var node = lookup.node;
  2903. node.node_ops.setattr(node, {
  2904. timestamp: Math.max(atime, mtime)
  2905. })
  2906. },
  2907. open: function(path, flags, mode, fd_start, fd_end) {
  2908. if (path === "") {
  2909. throw new FS.ErrnoError(2)
  2910. }
  2911. flags = typeof flags === "string" ? FS.modeStringToFlags(flags) : flags;
  2912. mode = typeof mode === "undefined" ? 438 : mode;
  2913. if (flags & 64) {
  2914. mode = mode & 4095 | 32768
  2915. } else {
  2916. mode = 0
  2917. }
  2918. var node;
  2919. if (typeof path === "object") {
  2920. node = path
  2921. } else {
  2922. path = PATH.normalize(path);
  2923. try {
  2924. var lookup = FS.lookupPath(path, {
  2925. follow: !(flags & 131072)
  2926. });
  2927. node = lookup.node
  2928. } catch (e) {}
  2929. }
  2930. var created = false;
  2931. if (flags & 64) {
  2932. if (node) {
  2933. if (flags & 128) {
  2934. throw new FS.ErrnoError(17)
  2935. }
  2936. } else {
  2937. node = FS.mknod(path, mode, 0);
  2938. created = true
  2939. }
  2940. }
  2941. if (!node) {
  2942. throw new FS.ErrnoError(2)
  2943. }
  2944. if (FS.isChrdev(node.mode)) {
  2945. flags &= ~512
  2946. }
  2947. if (flags & 65536 && !FS.isDir(node.mode)) {
  2948. throw new FS.ErrnoError(20)
  2949. }
  2950. if (!created) {
  2951. var err = FS.mayOpen(node, flags);
  2952. if (err) {
  2953. throw new FS.ErrnoError(err)
  2954. }
  2955. }
  2956. if (flags & 512) {
  2957. FS.truncate(node, 0)
  2958. }
  2959. flags &= ~(128 | 512);
  2960. var stream = FS.createStream({
  2961. node: node,
  2962. path: FS.getPath(node),
  2963. flags: flags,
  2964. seekable: true,
  2965. position: 0,
  2966. stream_ops: node.stream_ops,
  2967. ungotten: [],
  2968. error: false
  2969. }, fd_start, fd_end);
  2970. if (stream.stream_ops.open) {
  2971. stream.stream_ops.open(stream)
  2972. }
  2973. if (Module["logReadFiles"] && !(flags & 1)) {
  2974. if (!FS.readFiles) FS.readFiles = {};
  2975. if (!(path in FS.readFiles)) {
  2976. FS.readFiles[path] = 1;
  2977. console.log("FS.trackingDelegate error on read file: " + path)
  2978. }
  2979. }
  2980. try {
  2981. if (FS.trackingDelegate["onOpenFile"]) {
  2982. var trackingFlags = 0;
  2983. if ((flags & 2097155) !== 1) {
  2984. trackingFlags |= FS.tracking.openFlags.READ
  2985. }
  2986. if ((flags & 2097155) !== 0) {
  2987. trackingFlags |= FS.tracking.openFlags.WRITE
  2988. }
  2989. FS.trackingDelegate["onOpenFile"](path, trackingFlags)
  2990. }
  2991. } catch (e) {
  2992. console.log("FS.trackingDelegate['onOpenFile']('" + path + "', flags) threw an exception: " + e.message)
  2993. }
  2994. return stream
  2995. },
  2996. close: function(stream) {
  2997. if (FS.isClosed(stream)) {
  2998. throw new FS.ErrnoError(9)
  2999. }
  3000. if (stream.getdents) stream.getdents = null;
  3001. try {
  3002. if (stream.stream_ops.close) {
  3003. stream.stream_ops.close(stream)
  3004. }
  3005. } catch (e) {
  3006. throw e
  3007. } finally {
  3008. FS.closeStream(stream.fd)
  3009. }
  3010. stream.fd = null
  3011. },
  3012. isClosed: function(stream) {
  3013. return stream.fd === null
  3014. },
  3015. llseek: function(stream, offset, whence) {
  3016. if (FS.isClosed(stream)) {
  3017. throw new FS.ErrnoError(9)
  3018. }
  3019. if (!stream.seekable || !stream.stream_ops.llseek) {
  3020. throw new FS.ErrnoError(29)
  3021. }
  3022. if (whence != 0 && whence != 1 && whence != 2) {
  3023. throw new FS.ErrnoError(22)
  3024. }
  3025. stream.position = stream.stream_ops.llseek(stream, offset, whence);
  3026. stream.ungotten = [];
  3027. return stream.position
  3028. },
  3029. read: function(stream, buffer, offset, length, position) {
  3030. if (length < 0 || position < 0) {
  3031. throw new FS.ErrnoError(22)
  3032. }
  3033. if (FS.isClosed(stream)) {
  3034. throw new FS.ErrnoError(9)
  3035. }
  3036. if ((stream.flags & 2097155) === 1) {
  3037. throw new FS.ErrnoError(9)
  3038. }
  3039. if (FS.isDir(stream.node.mode)) {
  3040. throw new FS.ErrnoError(21)
  3041. }
  3042. if (!stream.stream_ops.read) {
  3043. throw new FS.ErrnoError(22)
  3044. }
  3045. var seeking = typeof position !== "undefined";
  3046. if (!seeking) {
  3047. position = stream.position
  3048. } else if (!stream.seekable) {
  3049. throw new FS.ErrnoError(29)
  3050. }
  3051. var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
  3052. if (!seeking) stream.position += bytesRead;
  3053. return bytesRead
  3054. },
  3055. write: function(stream, buffer, offset, length, position, canOwn) {
  3056. if (length < 0 || position < 0) {
  3057. throw new FS.ErrnoError(22)
  3058. }
  3059. if (FS.isClosed(stream)) {
  3060. throw new FS.ErrnoError(9)
  3061. }
  3062. if ((stream.flags & 2097155) === 0) {
  3063. throw new FS.ErrnoError(9)
  3064. }
  3065. if (FS.isDir(stream.node.mode)) {
  3066. throw new FS.ErrnoError(21)
  3067. }
  3068. if (!stream.stream_ops.write) {
  3069. throw new FS.ErrnoError(22)
  3070. }
  3071. if (stream.flags & 1024) {
  3072. FS.llseek(stream, 0, 2)
  3073. }
  3074. var seeking = typeof position !== "undefined";
  3075. if (!seeking) {
  3076. position = stream.position
  3077. } else if (!stream.seekable) {
  3078. throw new FS.ErrnoError(29)
  3079. }
  3080. var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
  3081. if (!seeking) stream.position += bytesWritten;
  3082. try {
  3083. if (stream.path && FS.trackingDelegate["onWriteToFile"]) FS.trackingDelegate["onWriteToFile"](stream.path)
  3084. } catch (e) {
  3085. console.log("FS.trackingDelegate['onWriteToFile']('" + stream.path + "') threw an exception: " + e.message)
  3086. }
  3087. return bytesWritten
  3088. },
  3089. allocate: function(stream, offset, length) {
  3090. if (FS.isClosed(stream)) {
  3091. throw new FS.ErrnoError(9)
  3092. }
  3093. if (offset < 0 || length <= 0) {
  3094. throw new FS.ErrnoError(22)
  3095. }
  3096. if ((stream.flags & 2097155) === 0) {
  3097. throw new FS.ErrnoError(9)
  3098. }
  3099. if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
  3100. throw new FS.ErrnoError(19)
  3101. }
  3102. if (!stream.stream_ops.allocate) {
  3103. throw new FS.ErrnoError(95)
  3104. }
  3105. stream.stream_ops.allocate(stream, offset, length)
  3106. },
  3107. mmap: function(stream, buffer, offset, length, position, prot, flags) {
  3108. if ((stream.flags & 2097155) === 1) {
  3109. throw new FS.ErrnoError(13)
  3110. }
  3111. if (!stream.stream_ops.mmap) {
  3112. throw new FS.ErrnoError(19)
  3113. }
  3114. return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags)
  3115. },
  3116. msync: function(stream, buffer, offset, length, mmapFlags) {
  3117. if (!stream || !stream.stream_ops.msync) {
  3118. return 0
  3119. }
  3120. return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags)
  3121. },
  3122. munmap: function(stream) {
  3123. return 0
  3124. },
  3125. ioctl: function(stream, cmd, arg) {
  3126. if (!stream.stream_ops.ioctl) {
  3127. throw new FS.ErrnoError(25)
  3128. }
  3129. return stream.stream_ops.ioctl(stream, cmd, arg)
  3130. },
  3131. readFile: function(path, opts) {
  3132. opts = opts || {};
  3133. opts.flags = opts.flags || "r";
  3134. opts.encoding = opts.encoding || "binary";
  3135. if (opts.encoding !== "utf8" && opts.encoding !== "binary") {
  3136. throw new Error('Invalid encoding type "' + opts.encoding + '"')
  3137. }
  3138. var ret;
  3139. var stream = FS.open(path, opts.flags);
  3140. var stat = FS.stat(path);
  3141. var length = stat.size;
  3142. var buf = new Uint8Array(length);
  3143. FS.read(stream, buf, 0, length, 0);
  3144. if (opts.encoding === "utf8") {
  3145. ret = UTF8ArrayToString(buf, 0)
  3146. } else if (opts.encoding === "binary") {
  3147. ret = buf
  3148. }
  3149. FS.close(stream);
  3150. return ret
  3151. },
  3152. writeFile: function(path, data, opts) {
  3153. opts = opts || {};
  3154. opts.flags = opts.flags || "w";
  3155. var stream = FS.open(path, opts.flags, opts.mode);
  3156. if (typeof data === "string") {
  3157. var buf = new Uint8Array(lengthBytesUTF8(data) + 1);
  3158. var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
  3159. FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn)
  3160. } else if (ArrayBuffer.isView(data)) {
  3161. FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn)
  3162. } else {
  3163. throw new Error("Unsupported data type")
  3164. }
  3165. FS.close(stream)
  3166. },
  3167. cwd: function() {
  3168. return FS.currentPath
  3169. },
  3170. chdir: function(path) {
  3171. var lookup = FS.lookupPath(path, {
  3172. follow: true
  3173. });
  3174. if (lookup.node === null) {
  3175. throw new FS.ErrnoError(2)
  3176. }
  3177. if (!FS.isDir(lookup.node.mode)) {
  3178. throw new FS.ErrnoError(20)
  3179. }
  3180. var err = FS.nodePermissions(lookup.node, "x");
  3181. if (err) {
  3182. throw new FS.ErrnoError(err)
  3183. }
  3184. FS.currentPath = lookup.path
  3185. },
  3186. createDefaultDirectories: function() {
  3187. FS.mkdir("/tmp");
  3188. FS.mkdir("/home");
  3189. FS.mkdir("/home/web_user")
  3190. },
  3191. createDefaultDevices: function() {
  3192. FS.mkdir("/dev");
  3193. FS.registerDevice(FS.makedev(1, 3), {
  3194. read: function() {
  3195. return 0
  3196. },
  3197. write: function(stream, buffer, offset, length, pos) {
  3198. return length
  3199. }
  3200. });
  3201. FS.mkdev("/dev/null", FS.makedev(1, 3));
  3202. TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
  3203. TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
  3204. FS.mkdev("/dev/tty", FS.makedev(5, 0));
  3205. FS.mkdev("/dev/tty1", FS.makedev(6, 0));
  3206. var random_device;
  3207. if (typeof crypto === "object" && typeof crypto["getRandomValues"] === "function") {
  3208. var randomBuffer = new Uint8Array(1);
  3209. random_device = function() {
  3210. crypto.getRandomValues(randomBuffer);
  3211. return randomBuffer[0]
  3212. }
  3213. } else if (ENVIRONMENT_IS_NODE) {
  3214. try {
  3215. var crypto_module = require("crypto");
  3216. random_device = function() {
  3217. return crypto_module["randomBytes"](1)[0]
  3218. }
  3219. } catch (e) {}
  3220. } else {}
  3221. if (!random_device) {
  3222. random_device = function() {
  3223. abort("random_device")
  3224. }
  3225. }
  3226. FS.createDevice("/dev", "random", random_device);
  3227. FS.createDevice("/dev", "urandom", random_device);
  3228. FS.mkdir("/dev/shm");
  3229. FS.mkdir("/dev/shm/tmp")
  3230. },
  3231. createSpecialDirectories: function() {
  3232. FS.mkdir("/proc");
  3233. FS.mkdir("/proc/self");
  3234. FS.mkdir("/proc/self/fd");
  3235. FS.mount({
  3236. mount: function() {
  3237. var node = FS.createNode("/proc/self", "fd", 16384 | 511, 73);
  3238. node.node_ops = {
  3239. lookup: function(parent, name) {
  3240. var fd = +name;
  3241. var stream = FS.getStream(fd);
  3242. if (!stream) throw new FS.ErrnoError(9);
  3243. var ret = {
  3244. parent: null,
  3245. mount: {
  3246. mountpoint: "fake"
  3247. },
  3248. node_ops: {
  3249. readlink: function() {
  3250. return stream.path
  3251. }
  3252. }
  3253. };
  3254. ret.parent = ret;
  3255. return ret
  3256. }
  3257. };
  3258. return node
  3259. }
  3260. }, {}, "/proc/self/fd")
  3261. },
  3262. createStandardStreams: function() {
  3263. if (Module["stdin"]) {
  3264. FS.createDevice("/dev", "stdin", Module["stdin"])
  3265. } else {
  3266. FS.symlink("/dev/tty", "/dev/stdin")
  3267. }
  3268. if (Module["stdout"]) {
  3269. FS.createDevice("/dev", "stdout", null, Module["stdout"])
  3270. } else {
  3271. FS.symlink("/dev/tty", "/dev/stdout")
  3272. }
  3273. if (Module["stderr"]) {
  3274. FS.createDevice("/dev", "stderr", null, Module["stderr"])
  3275. } else {
  3276. FS.symlink("/dev/tty1", "/dev/stderr")
  3277. }
  3278. var stdin = FS.open("/dev/stdin", "r");
  3279. var stdout = FS.open("/dev/stdout", "w");
  3280. var stderr = FS.open("/dev/stderr", "w")
  3281. },
  3282. ensureErrnoError: function() {
  3283. if (FS.ErrnoError) return;
  3284. FS.ErrnoError = function ErrnoError(errno, node) {
  3285. this.node = node;
  3286. this.setErrno = function(errno) {
  3287. this.errno = errno
  3288. };
  3289. this.setErrno(errno);
  3290. this.message = "FS error";
  3291. if (this.stack) Object.defineProperty(this, "stack", {
  3292. value: (new Error).stack,
  3293. writable: true
  3294. })
  3295. };
  3296. FS.ErrnoError.prototype = new Error;
  3297. FS.ErrnoError.prototype.constructor = FS.ErrnoError;
  3298. [2].forEach(function(code) {
  3299. FS.genericErrors[code] = new FS.ErrnoError(code);
  3300. FS.genericErrors[code].stack = "<generic error, no stack>"
  3301. })
  3302. },
  3303. staticInit: function() {
  3304. FS.ensureErrnoError();
  3305. FS.nameTable = new Array(4096);
  3306. FS.mount(MEMFS, {}, "/");
  3307. FS.createDefaultDirectories();
  3308. FS.createDefaultDevices();
  3309. FS.createSpecialDirectories();
  3310. FS.filesystems = {
  3311. "MEMFS": MEMFS,
  3312. "IDBFS": IDBFS,
  3313. "NODEFS": NODEFS,
  3314. "WORKERFS": WORKERFS
  3315. }
  3316. },
  3317. init: function(input, output, error) {
  3318. FS.init.initialized = true;
  3319. FS.ensureErrnoError();
  3320. Module["stdin"] = input || Module["stdin"];
  3321. Module["stdout"] = output || Module["stdout"];
  3322. Module["stderr"] = error || Module["stderr"];
  3323. FS.createStandardStreams()
  3324. },
  3325. quit: function() {
  3326. FS.init.initialized = false;
  3327. var fflush = Module["_fflush"];
  3328. if (fflush) fflush(0);
  3329. for (var i = 0; i < FS.streams.length; i++) {
  3330. var stream = FS.streams[i];
  3331. if (!stream) {
  3332. continue
  3333. }
  3334. FS.close(stream)
  3335. }
  3336. },
  3337. getMode: function(canRead, canWrite) {
  3338. var mode = 0;
  3339. if (canRead) mode |= 292 | 73;
  3340. if (canWrite) mode |= 146;
  3341. return mode
  3342. },
  3343. joinPath: function(parts, forceRelative) {
  3344. var path = PATH.join.apply(null, parts);
  3345. if (forceRelative && path[0] == "/") path = path.substr(1);
  3346. return path
  3347. },
  3348. absolutePath: function(relative, base) {
  3349. return PATH.resolve(base, relative)
  3350. },
  3351. standardizePath: function(path) {
  3352. return PATH.normalize(path)
  3353. },
  3354. findObject: function(path, dontResolveLastLink) {
  3355. var ret = FS.analyzePath(path, dontResolveLastLink);
  3356. if (ret.exists) {
  3357. return ret.object
  3358. } else {
  3359. ___setErrNo(ret.error);
  3360. return null
  3361. }
  3362. },
  3363. analyzePath: function(path, dontResolveLastLink) {
  3364. try {
  3365. var lookup = FS.lookupPath(path, {
  3366. follow: !dontResolveLastLink
  3367. });
  3368. path = lookup.path
  3369. } catch (e) {}
  3370. var ret = {
  3371. isRoot: false,
  3372. exists: false,
  3373. error: 0,
  3374. name: null,
  3375. path: null,
  3376. object: null,
  3377. parentExists: false,
  3378. parentPath: null,
  3379. parentObject: null
  3380. };
  3381. try {
  3382. var lookup = FS.lookupPath(path, {
  3383. parent: true
  3384. });
  3385. ret.parentExists = true;
  3386. ret.parentPath = lookup.path;
  3387. ret.parentObject = lookup.node;
  3388. ret.name = PATH.basename(path);
  3389. lookup = FS.lookupPath(path, {
  3390. follow: !dontResolveLastLink
  3391. });
  3392. ret.exists = true;
  3393. ret.path = lookup.path;
  3394. ret.object = lookup.node;
  3395. ret.name = lookup.node.name;
  3396. ret.isRoot = lookup.path === "/"
  3397. } catch (e) {
  3398. ret.error = e.errno
  3399. }
  3400. return ret
  3401. },
  3402. createFolder: function(parent, name, canRead, canWrite) {
  3403. var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name);
  3404. var mode = FS.getMode(canRead, canWrite);
  3405. return FS.mkdir(path, mode)
  3406. },
  3407. createPath: function(parent, path, canRead, canWrite) {
  3408. parent = typeof parent === "string" ? parent : FS.getPath(parent);
  3409. var parts = path.split("/").reverse();
  3410. while (parts.length) {
  3411. var part = parts.pop();
  3412. if (!part) continue;
  3413. var current = PATH.join2(parent, part);
  3414. try {
  3415. FS.mkdir(current)
  3416. } catch (e) {}
  3417. parent = current
  3418. }
  3419. return current
  3420. },
  3421. createFile: function(parent, name, properties, canRead, canWrite) {
  3422. var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name);
  3423. var mode = FS.getMode(canRead, canWrite);
  3424. return FS.create(path, mode)
  3425. },
  3426. createDataFile: function(parent, name, data, canRead, canWrite, canOwn) {
  3427. var path = name ? PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name) : parent;
  3428. var mode = FS.getMode(canRead, canWrite);
  3429. var node = FS.create(path, mode);
  3430. if (data) {
  3431. if (typeof data === "string") {
  3432. var arr = new Array(data.length);
  3433. for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
  3434. data = arr
  3435. }
  3436. FS.chmod(node, mode | 146);
  3437. var stream = FS.open(node, "w");
  3438. FS.write(stream, data, 0, data.length, 0, canOwn);
  3439. FS.close(stream);
  3440. FS.chmod(node, mode)
  3441. }
  3442. return node
  3443. },
  3444. createDevice: function(parent, name, input, output) {
  3445. var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name);
  3446. var mode = FS.getMode(!!input, !!output);
  3447. if (!FS.createDevice.major) FS.createDevice.major = 64;
  3448. var dev = FS.makedev(FS.createDevice.major++, 0);
  3449. FS.registerDevice(dev, {
  3450. open: function(stream) {
  3451. stream.seekable = false
  3452. },
  3453. close: function(stream) {
  3454. if (output && output.buffer && output.buffer.length) {
  3455. output(10)
  3456. }
  3457. },
  3458. read: function(stream, buffer, offset, length, pos) {
  3459. var bytesRead = 0;
  3460. for (var i = 0; i < length; i++) {
  3461. var result;
  3462. try {
  3463. result = input()
  3464. } catch (e) {
  3465. throw new FS.ErrnoError(5)
  3466. }
  3467. if (result === undefined && bytesRead === 0) {
  3468. throw new FS.ErrnoError(11)
  3469. }
  3470. if (result === null || result === undefined) break;
  3471. bytesRead++;
  3472. buffer[offset + i] = result
  3473. }
  3474. if (bytesRead) {
  3475. stream.node.timestamp = Date.now()
  3476. }
  3477. return bytesRead
  3478. },
  3479. write: function(stream, buffer, offset, length, pos) {
  3480. for (var i = 0; i < length; i++) {
  3481. try {
  3482. output(buffer[offset + i])
  3483. } catch (e) {
  3484. throw new FS.ErrnoError(5)
  3485. }
  3486. }
  3487. if (length) {
  3488. stream.node.timestamp = Date.now()
  3489. }
  3490. return i
  3491. }
  3492. });
  3493. return FS.mkdev(path, mode, dev)
  3494. },
  3495. createLink: function(parent, name, target, canRead, canWrite) {
  3496. var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name);
  3497. return FS.symlink(target, path)
  3498. },
  3499. forceLoadFile: function(obj) {
  3500. if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
  3501. var success = true;
  3502. if (typeof XMLHttpRequest !== "undefined") {
  3503. throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")
  3504. } else if (Module["read"]) {
  3505. try {
  3506. obj.contents = intArrayFromString(Module["read"](obj.url), true);
  3507. obj.usedBytes = obj.contents.length
  3508. } catch (e) {
  3509. success = false
  3510. }
  3511. } else {
  3512. throw new Error("Cannot load without read() or XMLHttpRequest.")
  3513. }
  3514. if (!success) ___setErrNo(5);
  3515. return success
  3516. },
  3517. createLazyFile: function(parent, name, url, canRead, canWrite) {
  3518. function LazyUint8Array() {
  3519. this.lengthKnown = false;
  3520. this.chunks = []
  3521. }
  3522. LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
  3523. if (idx > this.length - 1 || idx < 0) {
  3524. return undefined
  3525. }
  3526. var chunkOffset = idx % this.chunkSize;
  3527. var chunkNum = idx / this.chunkSize | 0;
  3528. return this.getter(chunkNum)[chunkOffset]
  3529. };
  3530. LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
  3531. this.getter = getter
  3532. };
  3533. LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
  3534. var xhr = new XMLHttpRequest;
  3535. xhr.open("HEAD", url, false);
  3536. xhr.send(null);
  3537. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3538. var datalength = Number(xhr.getResponseHeader("Content-length"));
  3539. var header;
  3540. var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
  3541. var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
  3542. var chunkSize = 1024 * 1024;
  3543. if (!hasByteServing) chunkSize = datalength;
  3544. var doXHR = function(from, to) {
  3545. if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
  3546. if (to > datalength - 1) throw new Error("only " + datalength + " bytes available! programmer error!");
  3547. var xhr = new XMLHttpRequest;
  3548. xhr.open("GET", url, false);
  3549. if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
  3550. if (typeof Uint8Array != "undefined") xhr.responseType = "arraybuffer";
  3551. if (xhr.overrideMimeType) {
  3552. xhr.overrideMimeType("text/plain; charset=x-user-defined")
  3553. }
  3554. xhr.send(null);
  3555. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3556. if (xhr.response !== undefined) {
  3557. return new Uint8Array(xhr.response || [])
  3558. } else {
  3559. return intArrayFromString(xhr.responseText || "", true)
  3560. }
  3561. };
  3562. var lazyArray = this;
  3563. lazyArray.setDataGetter(function(chunkNum) {
  3564. var start = chunkNum * chunkSize;
  3565. var end = (chunkNum + 1) * chunkSize - 1;
  3566. end = Math.min(end, datalength - 1);
  3567. if (typeof lazyArray.chunks[chunkNum] === "undefined") {
  3568. lazyArray.chunks[chunkNum] = doXHR(start, end)
  3569. }
  3570. if (typeof lazyArray.chunks[chunkNum] === "undefined") throw new Error("doXHR failed!");
  3571. return lazyArray.chunks[chunkNum]
  3572. });
  3573. if (usesGzip || !datalength) {
  3574. chunkSize = datalength = 1;
  3575. datalength = this.getter(0).length;
  3576. chunkSize = datalength;
  3577. console.log("LazyFiles on gzip forces download of the whole file when length is accessed")
  3578. }
  3579. this._length = datalength;
  3580. this._chunkSize = chunkSize;
  3581. this.lengthKnown = true
  3582. };
  3583. if (typeof XMLHttpRequest !== "undefined") {
  3584. if (!ENVIRONMENT_IS_WORKER) throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";
  3585. var lazyArray = new LazyUint8Array;
  3586. Object.defineProperties(lazyArray, {
  3587. length: {
  3588. get: function() {
  3589. if (!this.lengthKnown) {
  3590. this.cacheLength()
  3591. }
  3592. return this._length
  3593. }
  3594. },
  3595. chunkSize: {
  3596. get: function() {
  3597. if (!this.lengthKnown) {
  3598. this.cacheLength()
  3599. }
  3600. return this._chunkSize
  3601. }
  3602. }
  3603. });
  3604. var properties = {
  3605. isDevice: false,
  3606. contents: lazyArray
  3607. }
  3608. } else {
  3609. var properties = {
  3610. isDevice: false,
  3611. url: url
  3612. }
  3613. }
  3614. var node = FS.createFile(parent, name, properties, canRead, canWrite);
  3615. if (properties.contents) {
  3616. node.contents = properties.contents
  3617. } else if (properties.url) {
  3618. node.contents = null;
  3619. node.url = properties.url
  3620. }
  3621. Object.defineProperties(node, {
  3622. usedBytes: {
  3623. get: function() {
  3624. return this.contents.length
  3625. }
  3626. }
  3627. });
  3628. var stream_ops = {};
  3629. var keys = Object.keys(node.stream_ops);
  3630. keys.forEach(function(key) {
  3631. var fn = node.stream_ops[key];
  3632. stream_ops[key] = function forceLoadLazyFile() {
  3633. if (!FS.forceLoadFile(node)) {
  3634. throw new FS.ErrnoError(5)
  3635. }
  3636. return fn.apply(null, arguments)
  3637. }
  3638. });
  3639. stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
  3640. if (!FS.forceLoadFile(node)) {
  3641. throw new FS.ErrnoError(5)
  3642. }
  3643. var contents = stream.node.contents;
  3644. if (position >= contents.length) return 0;
  3645. var size = Math.min(contents.length - position, length);
  3646. if (contents.slice) {
  3647. for (var i = 0; i < size; i++) {
  3648. buffer[offset + i] = contents[position + i]
  3649. }
  3650. } else {
  3651. for (var i = 0; i < size; i++) {
  3652. buffer[offset + i] = contents.get(position + i)
  3653. }
  3654. }
  3655. return size
  3656. };
  3657. node.stream_ops = stream_ops;
  3658. return node
  3659. },
  3660. createPreloadedFile: function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) {
  3661. Browser.init();
  3662. var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
  3663. var dep = getUniqueRunDependency("cp " + fullname);
  3664.  
  3665. function processData(byteArray) {
  3666. function finish(byteArray) {
  3667. if (preFinish) preFinish();
  3668. if (!dontCreateFile) {
  3669. FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn)
  3670. }
  3671. if (onload) onload();
  3672. removeRunDependency(dep)
  3673. }
  3674. var handled = false;
  3675. Module["preloadPlugins"].forEach(function(plugin) {
  3676. if (handled) return;
  3677. if (plugin["canHandle"](fullname)) {
  3678. plugin["handle"](byteArray, fullname, finish, function() {
  3679. if (onerror) onerror();
  3680. removeRunDependency(dep)
  3681. });
  3682. handled = true
  3683. }
  3684. });
  3685. if (!handled) finish(byteArray)
  3686. }
  3687. addRunDependency(dep);
  3688. if (typeof url == "string") {
  3689. Browser.asyncLoad(url, function(byteArray) {
  3690. processData(byteArray)
  3691. }, onerror)
  3692. } else {
  3693. processData(url)
  3694. }
  3695. },
  3696. indexedDB: function() {
  3697. return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB
  3698. },
  3699. DB_NAME: function() {
  3700. return "EM_FS_" + window.location.pathname
  3701. },
  3702. DB_VERSION: 20,
  3703. DB_STORE_NAME: "FILE_DATA",
  3704. saveFilesToDB: function(paths, onload, onerror) {
  3705. onload = onload || function() {};
  3706. onerror = onerror || function() {};
  3707. var indexedDB = FS.indexedDB();
  3708. try {
  3709. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION)
  3710. } catch (e) {
  3711. return onerror(e)
  3712. }
  3713. openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
  3714. console.log("creating db");
  3715. var db = openRequest.result;
  3716. db.createObjectStore(FS.DB_STORE_NAME)
  3717. };
  3718. openRequest.onsuccess = function openRequest_onsuccess() {
  3719. var db = openRequest.result;
  3720. var transaction = db.transaction([FS.DB_STORE_NAME], "readwrite");
  3721. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3722. var ok = 0,
  3723. fail = 0,
  3724. total = paths.length;
  3725.  
  3726. function finish() {
  3727. if (fail == 0) onload();
  3728. else onerror()
  3729. }
  3730. paths.forEach(function(path) {
  3731. var putRequest = files.put(FS.analyzePath(path).object.contents, path);
  3732. putRequest.onsuccess = function putRequest_onsuccess() {
  3733. ok++;
  3734. if (ok + fail == total) finish()
  3735. };
  3736. putRequest.onerror = function putRequest_onerror() {
  3737. fail++;
  3738. if (ok + fail == total) finish()
  3739. }
  3740. });
  3741. transaction.onerror = onerror
  3742. };
  3743. openRequest.onerror = onerror
  3744. },
  3745. loadFilesFromDB: function(paths, onload, onerror) {
  3746. onload = onload || function() {};
  3747. onerror = onerror || function() {};
  3748. var indexedDB = FS.indexedDB();
  3749. try {
  3750. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION)
  3751. } catch (e) {
  3752. return onerror(e)
  3753. }
  3754. openRequest.onupgradeneeded = onerror;
  3755. openRequest.onsuccess = function openRequest_onsuccess() {
  3756. var db = openRequest.result;
  3757. try {
  3758. var transaction = db.transaction([FS.DB_STORE_NAME], "readonly")
  3759. } catch (e) {
  3760. onerror(e);
  3761. return
  3762. }
  3763. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3764. var ok = 0,
  3765. fail = 0,
  3766. total = paths.length;
  3767.  
  3768. function finish() {
  3769. if (fail == 0) onload();
  3770. else onerror()
  3771. }
  3772. paths.forEach(function(path) {
  3773. var getRequest = files.get(path);
  3774. getRequest.onsuccess = function getRequest_onsuccess() {
  3775. if (FS.analyzePath(path).exists) {
  3776. FS.unlink(path)
  3777. }
  3778. FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
  3779. ok++;
  3780. if (ok + fail == total) finish()
  3781. };
  3782. getRequest.onerror = function getRequest_onerror() {
  3783. fail++;
  3784. if (ok + fail == total) finish()
  3785. }
  3786. });
  3787. transaction.onerror = onerror
  3788. };
  3789. openRequest.onerror = onerror
  3790. }
  3791. };
  3792. var ERRNO_CODES = {
  3793. EPERM: 1,
  3794. ENOENT: 2,
  3795. ESRCH: 3,
  3796. EINTR: 4,
  3797. EIO: 5,
  3798. ENXIO: 6,
  3799. E2BIG: 7,
  3800. ENOEXEC: 8,
  3801. EBADF: 9,
  3802. ECHILD: 10,
  3803. EAGAIN: 11,
  3804. EWOULDBLOCK: 11,
  3805. ENOMEM: 12,
  3806. EACCES: 13,
  3807. EFAULT: 14,
  3808. ENOTBLK: 15,
  3809. EBUSY: 16,
  3810. EEXIST: 17,
  3811. EXDEV: 18,
  3812. ENODEV: 19,
  3813. ENOTDIR: 20,
  3814. EISDIR: 21,
  3815. EINVAL: 22,
  3816. ENFILE: 23,
  3817. EMFILE: 24,
  3818. ENOTTY: 25,
  3819. ETXTBSY: 26,
  3820. EFBIG: 27,
  3821. ENOSPC: 28,
  3822. ESPIPE: 29,
  3823. EROFS: 30,
  3824. EMLINK: 31,
  3825. EPIPE: 32,
  3826. EDOM: 33,
  3827. ERANGE: 34,
  3828. ENOMSG: 42,
  3829. EIDRM: 43,
  3830. ECHRNG: 44,
  3831. EL2NSYNC: 45,
  3832. EL3HLT: 46,
  3833. EL3RST: 47,
  3834. ELNRNG: 48,
  3835. EUNATCH: 49,
  3836. ENOCSI: 50,
  3837. EL2HLT: 51,
  3838. EDEADLK: 35,
  3839. ENOLCK: 37,
  3840. EBADE: 52,
  3841. EBADR: 53,
  3842. EXFULL: 54,
  3843. ENOANO: 55,
  3844. EBADRQC: 56,
  3845. EBADSLT: 57,
  3846. EDEADLOCK: 35,
  3847. EBFONT: 59,
  3848. ENOSTR: 60,
  3849. ENODATA: 61,
  3850. ETIME: 62,
  3851. ENOSR: 63,
  3852. ENONET: 64,
  3853. ENOPKG: 65,
  3854. EREMOTE: 66,
  3855. ENOLINK: 67,
  3856. EADV: 68,
  3857. ESRMNT: 69,
  3858. ECOMM: 70,
  3859. EPROTO: 71,
  3860. EMULTIHOP: 72,
  3861. EDOTDOT: 73,
  3862. EBADMSG: 74,
  3863. ENOTUNIQ: 76,
  3864. EBADFD: 77,
  3865. EREMCHG: 78,
  3866. ELIBACC: 79,
  3867. ELIBBAD: 80,
  3868. ELIBSCN: 81,
  3869. ELIBMAX: 82,
  3870. ELIBEXEC: 83,
  3871. ENOSYS: 38,
  3872. ENOTEMPTY: 39,
  3873. ENAMETOOLONG: 36,
  3874. ELOOP: 40,
  3875. EOPNOTSUPP: 95,
  3876. EPFNOSUPPORT: 96,
  3877. ECONNRESET: 104,
  3878. ENOBUFS: 105,
  3879. EAFNOSUPPORT: 97,
  3880. EPROTOTYPE: 91,
  3881. ENOTSOCK: 88,
  3882. ENOPROTOOPT: 92,
  3883. ESHUTDOWN: 108,
  3884. ECONNREFUSED: 111,
  3885. EADDRINUSE: 98,
  3886. ECONNABORTED: 103,
  3887. ENETUNREACH: 101,
  3888. ENETDOWN: 100,
  3889. ETIMEDOUT: 110,
  3890. EHOSTDOWN: 112,
  3891. EHOSTUNREACH: 113,
  3892. EINPROGRESS: 115,
  3893. EALREADY: 114,
  3894. EDESTADDRREQ: 89,
  3895. EMSGSIZE: 90,
  3896. EPROTONOSUPPORT: 93,
  3897. ESOCKTNOSUPPORT: 94,
  3898. EADDRNOTAVAIL: 99,
  3899. ENETRESET: 102,
  3900. EISCONN: 106,
  3901. ENOTCONN: 107,
  3902. ETOOMANYREFS: 109,
  3903. EUSERS: 87,
  3904. EDQUOT: 122,
  3905. ESTALE: 116,
  3906. ENOTSUP: 95,
  3907. ENOMEDIUM: 123,
  3908. EILSEQ: 84,
  3909. EOVERFLOW: 75,
  3910. ECANCELED: 125,
  3911. ENOTRECOVERABLE: 131,
  3912. EOWNERDEAD: 130,
  3913. ESTRPIPE: 86
  3914. };
  3915. var SYSCALLS = {
  3916. DEFAULT_POLLMASK: 5,
  3917. mappings: {},
  3918. umask: 511,
  3919. calculateAt: function(dirfd, path) {
  3920. if (path[0] !== "/") {
  3921. var dir;
  3922. if (dirfd === -100) {
  3923. dir = FS.cwd()
  3924. } else {
  3925. var dirstream = FS.getStream(dirfd);
  3926. if (!dirstream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3927. dir = dirstream.path
  3928. }
  3929. path = PATH.join2(dir, path)
  3930. }
  3931. return path
  3932. },
  3933. doStat: function(func, path, buf) {
  3934. try {
  3935. var stat = func(path)
  3936. } catch (e) {
  3937. if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
  3938. return -ERRNO_CODES.ENOTDIR
  3939. }
  3940. throw e
  3941. }
  3942. HEAP32[buf >> 2] = stat.dev;
  3943. HEAP32[buf + 4 >> 2] = 0;
  3944. HEAP32[buf + 8 >> 2] = stat.ino;
  3945. HEAP32[buf + 12 >> 2] = stat.mode;
  3946. HEAP32[buf + 16 >> 2] = stat.nlink;
  3947. HEAP32[buf + 20 >> 2] = stat.uid;
  3948. HEAP32[buf + 24 >> 2] = stat.gid;
  3949. HEAP32[buf + 28 >> 2] = stat.rdev;
  3950. HEAP32[buf + 32 >> 2] = 0;
  3951. HEAP32[buf + 36 >> 2] = stat.size;
  3952. HEAP32[buf + 40 >> 2] = 4096;
  3953. HEAP32[buf + 44 >> 2] = stat.blocks;
  3954. HEAP32[buf + 48 >> 2] = stat.atime.getTime() / 1e3 | 0;
  3955. HEAP32[buf + 52 >> 2] = 0;
  3956. HEAP32[buf + 56 >> 2] = stat.mtime.getTime() / 1e3 | 0;
  3957. HEAP32[buf + 60 >> 2] = 0;
  3958. HEAP32[buf + 64 >> 2] = stat.ctime.getTime() / 1e3 | 0;
  3959. HEAP32[buf + 68 >> 2] = 0;
  3960. HEAP32[buf + 72 >> 2] = stat.ino;
  3961. return 0
  3962. },
  3963. doMsync: function(addr, stream, len, flags) {
  3964. var buffer = new Uint8Array(HEAPU8.subarray(addr, addr + len));
  3965. FS.msync(stream, buffer, 0, len, flags)
  3966. },
  3967. doMkdir: function(path, mode) {
  3968. path = PATH.normalize(path);
  3969. if (path[path.length - 1] === "/") path = path.substr(0, path.length - 1);
  3970. FS.mkdir(path, mode, 0);
  3971. return 0
  3972. },
  3973. doMknod: function(path, mode, dev) {
  3974. switch (mode & 61440) {
  3975. case 32768:
  3976. case 8192:
  3977. case 24576:
  3978. case 4096:
  3979. case 49152:
  3980. break;
  3981. default:
  3982. return -ERRNO_CODES.EINVAL
  3983. }
  3984. FS.mknod(path, mode, dev);
  3985. return 0
  3986. },
  3987. doReadlink: function(path, buf, bufsize) {
  3988. if (bufsize <= 0) return -ERRNO_CODES.EINVAL;
  3989. var ret = FS.readlink(path);
  3990. var len = Math.min(bufsize, lengthBytesUTF8(ret));
  3991. var endChar = HEAP8[buf + len];
  3992. stringToUTF8(ret, buf, bufsize + 1);
  3993. HEAP8[buf + len] = endChar;
  3994. return len
  3995. },
  3996. doAccess: function(path, amode) {
  3997. if (amode & ~7) {
  3998. return -ERRNO_CODES.EINVAL
  3999. }
  4000. var node;
  4001. var lookup = FS.lookupPath(path, {
  4002. follow: true
  4003. });
  4004. node = lookup.node;
  4005. var perms = "";
  4006. if (amode & 4) perms += "r";
  4007. if (amode & 2) perms += "w";
  4008. if (amode & 1) perms += "x";
  4009. if (perms && FS.nodePermissions(node, perms)) {
  4010. return -ERRNO_CODES.EACCES
  4011. }
  4012. return 0
  4013. },
  4014. doDup: function(path, flags, suggestFD) {
  4015. var suggest = FS.getStream(suggestFD);
  4016. if (suggest) FS.close(suggest);
  4017. return FS.open(path, flags, 0, suggestFD, suggestFD).fd
  4018. },
  4019. doReadv: function(stream, iov, iovcnt, offset) {
  4020. var ret = 0;
  4021. for (var i = 0; i < iovcnt; i++) {
  4022. var ptr = HEAP32[iov + i * 8 >> 2];
  4023. var len = HEAP32[iov + (i * 8 + 4) >> 2];
  4024. var curr = FS.read(stream, HEAP8, ptr, len, offset);
  4025. if (curr < 0) return -1;
  4026. ret += curr;
  4027. if (curr < len) break
  4028. }
  4029. return ret
  4030. },
  4031. doWritev: function(stream, iov, iovcnt, offset) {
  4032. var ret = 0;
  4033. for (var i = 0; i < iovcnt; i++) {
  4034. var ptr = HEAP32[iov + i * 8 >> 2];
  4035. var len = HEAP32[iov + (i * 8 + 4) >> 2];
  4036. var curr = FS.write(stream, HEAP8, ptr, len, offset);
  4037. if (curr < 0) return -1;
  4038. ret += curr
  4039. }
  4040. return ret
  4041. },
  4042. varargs: 0,
  4043. get: function(varargs) {
  4044. SYSCALLS.varargs += 4;
  4045. var ret = HEAP32[SYSCALLS.varargs - 4 >> 2];
  4046. return ret
  4047. },
  4048. getStr: function() {
  4049. var ret = UTF8ToString(SYSCALLS.get());
  4050. return ret
  4051. },
  4052. getStreamFromFD: function() {
  4053. var stream = FS.getStream(SYSCALLS.get());
  4054. if (!stream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  4055. return stream
  4056. },
  4057. getSocketFromFD: function() {
  4058. var socket = SOCKFS.getSocket(SYSCALLS.get());
  4059. if (!socket) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  4060. return socket
  4061. },
  4062. getSocketAddress: function(allowNull) {
  4063. var addrp = SYSCALLS.get(),
  4064. addrlen = SYSCALLS.get();
  4065. if (allowNull && addrp === 0) return null;
  4066. var info = __read_sockaddr(addrp, addrlen);
  4067. if (info.errno) throw new FS.ErrnoError(info.errno);
  4068. info.addr = DNS.lookup_addr(info.addr) || info.addr;
  4069. return info
  4070. },
  4071. get64: function() {
  4072. var low = SYSCALLS.get(),
  4073. high = SYSCALLS.get();
  4074. return low
  4075. },
  4076. getZero: function() {
  4077. SYSCALLS.get()
  4078. }
  4079. };
  4080.  
  4081. function ___syscall125(which, varargs) {
  4082. SYSCALLS.varargs = varargs;
  4083. try {
  4084. return 0
  4085. } catch (e) {
  4086. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4087. return -e.errno
  4088. }
  4089. }
  4090.  
  4091. function ___syscall140(which, varargs) {
  4092. SYSCALLS.varargs = varargs;
  4093. try {
  4094. var stream = SYSCALLS.getStreamFromFD(),
  4095. offset_high = SYSCALLS.get(),
  4096. offset_low = SYSCALLS.get(),
  4097. result = SYSCALLS.get(),
  4098. whence = SYSCALLS.get();
  4099. var offset = offset_low;
  4100. FS.llseek(stream, offset, whence);
  4101. HEAP32[result >> 2] = stream.position;
  4102. if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null;
  4103. return 0
  4104. } catch (e) {
  4105. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4106. return -e.errno
  4107. }
  4108. }
  4109.  
  4110. function ___syscall145(which, varargs) {
  4111. SYSCALLS.varargs = varargs;
  4112. try {
  4113. var stream = SYSCALLS.getStreamFromFD(),
  4114. iov = SYSCALLS.get(),
  4115. iovcnt = SYSCALLS.get();
  4116. return SYSCALLS.doReadv(stream, iov, iovcnt)
  4117. } catch (e) {
  4118. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4119. return -e.errno
  4120. }
  4121. }
  4122.  
  4123. function ___syscall146(which, varargs) {
  4124. SYSCALLS.varargs = varargs;
  4125. try {
  4126. var stream = SYSCALLS.getStreamFromFD(),
  4127. iov = SYSCALLS.get(),
  4128. iovcnt = SYSCALLS.get();
  4129. return SYSCALLS.doWritev(stream, iov, iovcnt)
  4130. } catch (e) {
  4131. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4132. return -e.errno
  4133. }
  4134. }
  4135.  
  4136. function ___syscall192(which, varargs) {
  4137. SYSCALLS.varargs = varargs;
  4138. try {
  4139. var addr = SYSCALLS.get(),
  4140. len = SYSCALLS.get(),
  4141. prot = SYSCALLS.get(),
  4142. flags = SYSCALLS.get(),
  4143. fd = SYSCALLS.get(),
  4144. off = SYSCALLS.get();
  4145. off <<= 12;
  4146. var ptr;
  4147. var allocated = false;
  4148. if (fd === -1) {
  4149. ptr = _memalign(PAGE_SIZE, len);
  4150. if (!ptr) return -ERRNO_CODES.ENOMEM;
  4151. _memset(ptr, 0, len);
  4152. allocated = true
  4153. } else {
  4154. var info = FS.getStream(fd);
  4155. if (!info) return -ERRNO_CODES.EBADF;
  4156. var res = FS.mmap(info, HEAPU8, addr, len, off, prot, flags);
  4157. ptr = res.ptr;
  4158. allocated = res.allocated
  4159. }
  4160. SYSCALLS.mappings[ptr] = {
  4161. malloc: ptr,
  4162. len: len,
  4163. allocated: allocated,
  4164. fd: fd,
  4165. flags: flags
  4166. };
  4167. return ptr
  4168. } catch (e) {
  4169. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4170. return -e.errno
  4171. }
  4172. }
  4173.  
  4174. function ___syscall195(which, varargs) {
  4175. SYSCALLS.varargs = varargs;
  4176. try {
  4177. var path = SYSCALLS.getStr(),
  4178. buf = SYSCALLS.get();
  4179. return SYSCALLS.doStat(FS.stat, path, buf)
  4180. } catch (e) {
  4181. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4182. return -e.errno
  4183. }
  4184. }
  4185.  
  4186. function ___syscall197(which, varargs) {
  4187. SYSCALLS.varargs = varargs;
  4188. try {
  4189. var stream = SYSCALLS.getStreamFromFD(),
  4190. buf = SYSCALLS.get();
  4191. return SYSCALLS.doStat(FS.stat, stream.path, buf)
  4192. } catch (e) {
  4193. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4194. return -e.errno
  4195. }
  4196. }
  4197.  
  4198. function ___syscall221(which, varargs) {
  4199. SYSCALLS.varargs = varargs;
  4200. try {
  4201. var stream = SYSCALLS.getStreamFromFD(),
  4202. cmd = SYSCALLS.get();
  4203. switch (cmd) {
  4204. case 0:
  4205. {
  4206. var arg = SYSCALLS.get();
  4207. if (arg < 0) {
  4208. return -ERRNO_CODES.EINVAL
  4209. }
  4210. var newStream;newStream = FS.open(stream.path, stream.flags, 0, arg);
  4211. return newStream.fd
  4212. }
  4213. case 1:
  4214. case 2:
  4215. return 0;
  4216. case 3:
  4217. return stream.flags;
  4218. case 4:
  4219. {
  4220. var arg = SYSCALLS.get();stream.flags |= arg;
  4221. return 0
  4222. }
  4223. case 12:
  4224. {
  4225. var arg = SYSCALLS.get();
  4226. var offset = 0;HEAP16[arg + offset >> 1] = 2;
  4227. return 0
  4228. }
  4229. case 13:
  4230. case 14:
  4231. return 0;
  4232. case 16:
  4233. case 8:
  4234. return -ERRNO_CODES.EINVAL;
  4235. case 9:
  4236. ___setErrNo(ERRNO_CODES.EINVAL);
  4237. return -1;
  4238. default:
  4239. {
  4240. return -ERRNO_CODES.EINVAL
  4241. }
  4242. }
  4243. } catch (e) {
  4244. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4245. return -e.errno
  4246. }
  4247. }
  4248.  
  4249. function ___syscall5(which, varargs) {
  4250. SYSCALLS.varargs = varargs;
  4251. try {
  4252. var pathname = SYSCALLS.getStr(),
  4253. flags = SYSCALLS.get(),
  4254. mode = SYSCALLS.get();
  4255. var stream = FS.open(pathname, flags, mode);
  4256. return stream.fd
  4257. } catch (e) {
  4258. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4259. return -e.errno
  4260. }
  4261. }
  4262.  
  4263. function ___syscall54(which, varargs) {
  4264. SYSCALLS.varargs = varargs;
  4265. try {
  4266. var stream = SYSCALLS.getStreamFromFD(),
  4267. op = SYSCALLS.get();
  4268. switch (op) {
  4269. case 21509:
  4270. case 21505:
  4271. {
  4272. if (!stream.tty) return -ERRNO_CODES.ENOTTY;
  4273. return 0
  4274. }
  4275. case 21510:
  4276. case 21511:
  4277. case 21512:
  4278. case 21506:
  4279. case 21507:
  4280. case 21508:
  4281. {
  4282. if (!stream.tty) return -ERRNO_CODES.ENOTTY;
  4283. return 0
  4284. }
  4285. case 21519:
  4286. {
  4287. if (!stream.tty) return -ERRNO_CODES.ENOTTY;
  4288. var argp = SYSCALLS.get();HEAP32[argp >> 2] = 0;
  4289. return 0
  4290. }
  4291. case 21520:
  4292. {
  4293. if (!stream.tty) return -ERRNO_CODES.ENOTTY;
  4294. return -ERRNO_CODES.EINVAL
  4295. }
  4296. case 21531:
  4297. {
  4298. var argp = SYSCALLS.get();
  4299. return FS.ioctl(stream, op, argp)
  4300. }
  4301. case 21523:
  4302. {
  4303. if (!stream.tty) return -ERRNO_CODES.ENOTTY;
  4304. return 0
  4305. }
  4306. case 21524:
  4307. {
  4308. if (!stream.tty) return -ERRNO_CODES.ENOTTY;
  4309. return 0
  4310. }
  4311. default:
  4312. abort("bad ioctl syscall " + op)
  4313. }
  4314. } catch (e) {
  4315. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4316. return -e.errno
  4317. }
  4318. }
  4319.  
  4320. function ___syscall6(which, varargs) {
  4321. SYSCALLS.varargs = varargs;
  4322. try {
  4323. var stream = SYSCALLS.getStreamFromFD();
  4324. FS.close(stream);
  4325. return 0
  4326. } catch (e) {
  4327. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4328. return -e.errno
  4329. }
  4330. }
  4331.  
  4332. function ___syscall91(which, varargs) {
  4333. SYSCALLS.varargs = varargs;
  4334. try {
  4335. var addr = SYSCALLS.get(),
  4336. len = SYSCALLS.get();
  4337. var info = SYSCALLS.mappings[addr];
  4338. if (!info) return 0;
  4339. if (len === info.len) {
  4340. var stream = FS.getStream(info.fd);
  4341. SYSCALLS.doMsync(addr, stream, len, info.flags);
  4342. FS.munmap(stream);
  4343. SYSCALLS.mappings[addr] = null;
  4344. if (info.allocated) {
  4345. _free(info.malloc)
  4346. }
  4347. }
  4348. return 0
  4349. } catch (e) {
  4350. if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e);
  4351. return -e.errno
  4352. }
  4353. }
  4354.  
  4355. function ___unlock() {}
  4356.  
  4357. function _emscripten_get_heap_size() {
  4358. return HEAP8.length
  4359. }
  4360.  
  4361. function abortOnCannotGrowMemory(requestedSize) {
  4362. abort("OOM")
  4363. }
  4364.  
  4365. function _emscripten_resize_heap(requestedSize) {
  4366. abortOnCannotGrowMemory(requestedSize)
  4367. }
  4368.  
  4369. function _getenv(name) {
  4370. if (name === 0) return 0;
  4371. name = UTF8ToString(name);
  4372. if (!ENV.hasOwnProperty(name)) return 0;
  4373. if (_getenv.ret) _free(_getenv.ret);
  4374. _getenv.ret = allocateUTF8(ENV[name]);
  4375. return _getenv.ret
  4376. }
  4377.  
  4378. function _emscripten_memcpy_big(dest, src, num) {
  4379. HEAPU8.set(HEAPU8.subarray(src, src + num), dest)
  4380. }
  4381.  
  4382. function _sysconf(name) {
  4383. switch (name) {
  4384. case 30:
  4385. return PAGE_SIZE;
  4386. case 85:
  4387. var maxHeapSize = 2 * 1024 * 1024 * 1024 - 65536;
  4388. maxHeapSize = HEAPU8.length;
  4389. return maxHeapSize / PAGE_SIZE;
  4390. case 132:
  4391. case 133:
  4392. case 12:
  4393. case 137:
  4394. case 138:
  4395. case 15:
  4396. case 235:
  4397. case 16:
  4398. case 17:
  4399. case 18:
  4400. case 19:
  4401. case 20:
  4402. case 149:
  4403. case 13:
  4404. case 10:
  4405. case 236:
  4406. case 153:
  4407. case 9:
  4408. case 21:
  4409. case 22:
  4410. case 159:
  4411. case 154:
  4412. case 14:
  4413. case 77:
  4414. case 78:
  4415. case 139:
  4416. case 80:
  4417. case 81:
  4418. case 82:
  4419. case 68:
  4420. case 67:
  4421. case 164:
  4422. case 11:
  4423. case 29:
  4424. case 47:
  4425. case 48:
  4426. case 95:
  4427. case 52:
  4428. case 51:
  4429. case 46:
  4430. return 200809;
  4431. case 79:
  4432. return 0;
  4433. case 27:
  4434. case 246:
  4435. case 127:
  4436. case 128:
  4437. case 23:
  4438. case 24:
  4439. case 160:
  4440. case 161:
  4441. case 181:
  4442. case 182:
  4443. case 242:
  4444. case 183:
  4445. case 184:
  4446. case 243:
  4447. case 244:
  4448. case 245:
  4449. case 165:
  4450. case 178:
  4451. case 179:
  4452. case 49:
  4453. case 50:
  4454. case 168:
  4455. case 169:
  4456. case 175:
  4457. case 170:
  4458. case 171:
  4459. case 172:
  4460. case 97:
  4461. case 76:
  4462. case 32:
  4463. case 173:
  4464. case 35:
  4465. return -1;
  4466. case 176:
  4467. case 177:
  4468. case 7:
  4469. case 155:
  4470. case 8:
  4471. case 157:
  4472. case 125:
  4473. case 126:
  4474. case 92:
  4475. case 93:
  4476. case 129:
  4477. case 130:
  4478. case 131:
  4479. case 94:
  4480. case 91:
  4481. return 1;
  4482. case 74:
  4483. case 60:
  4484. case 69:
  4485. case 70:
  4486. case 4:
  4487. return 1024;
  4488. case 31:
  4489. case 42:
  4490. case 72:
  4491. return 32;
  4492. case 87:
  4493. case 26:
  4494. case 33:
  4495. return 2147483647;
  4496. case 34:
  4497. case 1:
  4498. return 47839;
  4499. case 38:
  4500. case 36:
  4501. return 99;
  4502. case 43:
  4503. case 37:
  4504. return 2048;
  4505. case 0:
  4506. return 2097152;
  4507. case 3:
  4508. return 65536;
  4509. case 28:
  4510. return 32768;
  4511. case 44:
  4512. return 32767;
  4513. case 75:
  4514. return 16384;
  4515. case 39:
  4516. return 1e3;
  4517. case 89:
  4518. return 700;
  4519. case 71:
  4520. return 256;
  4521. case 40:
  4522. return 255;
  4523. case 2:
  4524. return 100;
  4525. case 180:
  4526. return 64;
  4527. case 25:
  4528. return 20;
  4529. case 5:
  4530. return 16;
  4531. case 6:
  4532. return 6;
  4533. case 73:
  4534. return 4;
  4535. case 84:
  4536. {
  4537. if (typeof navigator === "object") return navigator["hardwareConcurrency"] || 1;
  4538. return 1
  4539. }
  4540. }
  4541. ___setErrNo(22);
  4542. return -1
  4543. }
  4544. FS.staticInit();
  4545. if (ENVIRONMENT_IS_NODE) {
  4546. var fs = require("fs");
  4547. var NODEJS_PATH = require("path");
  4548. NODEFS.staticInit()
  4549. }
  4550.  
  4551. function intArrayFromString(stringy, dontAddNull, length) {
  4552. var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
  4553. var u8array = new Array(len);
  4554. var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
  4555. if (dontAddNull) u8array.length = numBytesWritten;
  4556. return u8array
  4557. }
  4558. var asmGlobalArg = {};
  4559. var asmLibraryArg = {
  4560. "c": abort,
  4561. "b": ___assert_fail,
  4562. "u": ___buildEnvironment,
  4563. "g": ___lock,
  4564. "p": ___map_file,
  4565. "j": ___setErrNo,
  4566. "o": ___syscall125,
  4567. "n": ___syscall140,
  4568. "m": ___syscall145,
  4569. "i": ___syscall146,
  4570. "z": ___syscall192,
  4571. "y": ___syscall195,
  4572. "x": ___syscall197,
  4573. "f": ___syscall221,
  4574. "l": ___syscall5,
  4575. "k": ___syscall54,
  4576. "h": ___syscall6,
  4577. "w": ___syscall91,
  4578. "e": ___unlock,
  4579. "v": _emscripten_get_heap_size,
  4580. "t": _emscripten_memcpy_big,
  4581. "s": _emscripten_resize_heap,
  4582. "d": _getenv,
  4583. "r": _sysconf,
  4584. "q": abortOnCannotGrowMemory,
  4585. "a": DYNAMICTOP_PTR
  4586. };
  4587. var asm = Module["asm"](asmGlobalArg, asmLibraryArg, buffer);
  4588. Module["asm"] = asm;
  4589. var ___emscripten_environ_constructor = Module["___emscripten_environ_constructor"] = function() {
  4590. return Module["asm"]["A"].apply(null, arguments)
  4591. };
  4592. var ___errno_location = Module["___errno_location"] = function() {
  4593. return Module["asm"]["B"].apply(null, arguments)
  4594. };
  4595. var _free = Module["_free"] = function() {
  4596. return Module["asm"]["C"].apply(null, arguments)
  4597. };
  4598. var _hb_aat_layout_feature_type_get_name_id = Module["_hb_aat_layout_feature_type_get_name_id"] = function() {
  4599. return Module["asm"]["D"].apply(null, arguments)
  4600. };
  4601. var _hb_aat_layout_feature_type_get_selector_infos = Module["_hb_aat_layout_feature_type_get_selector_infos"] = function() {
  4602. return Module["asm"]["E"].apply(null, arguments)
  4603. };
  4604. var _hb_aat_layout_get_feature_types = Module["_hb_aat_layout_get_feature_types"] = function() {
  4605. return Module["asm"]["F"].apply(null, arguments)
  4606. };
  4607. var _hb_aat_layout_has_positioning = Module["_hb_aat_layout_has_positioning"] = function() {
  4608. return Module["asm"]["G"].apply(null, arguments)
  4609. };
  4610. var _hb_aat_layout_has_substitution = Module["_hb_aat_layout_has_substitution"] = function() {
  4611. return Module["asm"]["H"].apply(null, arguments)
  4612. };
  4613. var _hb_aat_layout_has_tracking = Module["_hb_aat_layout_has_tracking"] = function() {
  4614. return Module["asm"]["I"].apply(null, arguments)
  4615. };
  4616. var _hb_blob_copy_writable_or_fail = Module["_hb_blob_copy_writable_or_fail"] = function() {
  4617. return Module["asm"]["J"].apply(null, arguments)
  4618. };
  4619. var _hb_blob_create = Module["_hb_blob_create"] = function() {
  4620. return Module["asm"]["K"].apply(null, arguments)
  4621. };
  4622. var _hb_blob_create_from_file = Module["_hb_blob_create_from_file"] = function() {
  4623. return Module["asm"]["L"].apply(null, arguments)
  4624. };
  4625. var _hb_blob_create_sub_blob = Module["_hb_blob_create_sub_blob"] = function() {
  4626. return Module["asm"]["M"].apply(null, arguments)
  4627. };
  4628. var _hb_blob_destroy = Module["_hb_blob_destroy"] = function() {
  4629. return Module["asm"]["N"].apply(null, arguments)
  4630. };
  4631. var _hb_blob_get_data = Module["_hb_blob_get_data"] = function() {
  4632. return Module["asm"]["O"].apply(null, arguments)
  4633. };
  4634. var _hb_blob_get_data_writable = Module["_hb_blob_get_data_writable"] = function() {
  4635. return Module["asm"]["P"].apply(null, arguments)
  4636. };
  4637. var _hb_blob_get_empty = Module["_hb_blob_get_empty"] = function() {
  4638. return Module["asm"]["Q"].apply(null, arguments)
  4639. };
  4640. var _hb_blob_get_length = Module["_hb_blob_get_length"] = function() {
  4641. return Module["asm"]["R"].apply(null, arguments)
  4642. };
  4643. var _hb_blob_get_user_data = Module["_hb_blob_get_user_data"] = function() {
  4644. return Module["asm"]["S"].apply(null, arguments)
  4645. };
  4646. var _hb_blob_is_immutable = Module["_hb_blob_is_immutable"] = function() {
  4647. return Module["asm"]["T"].apply(null, arguments)
  4648. };
  4649. var _hb_blob_make_immutable = Module["_hb_blob_make_immutable"] = function() {
  4650. return Module["asm"]["U"].apply(null, arguments)
  4651. };
  4652. var _hb_blob_reference = Module["_hb_blob_reference"] = function() {
  4653. return Module["asm"]["V"].apply(null, arguments)
  4654. };
  4655. var _hb_blob_set_user_data = Module["_hb_blob_set_user_data"] = function() {
  4656. return Module["asm"]["W"].apply(null, arguments)
  4657. };
  4658. var _hb_buffer_add = Module["_hb_buffer_add"] = function() {
  4659. return Module["asm"]["X"].apply(null, arguments)
  4660. };
  4661. var _hb_buffer_add_codepoints = Module["_hb_buffer_add_codepoints"] = function() {
  4662. return Module["asm"]["Y"].apply(null, arguments)
  4663. };
  4664. var _hb_buffer_add_latin1 = Module["_hb_buffer_add_latin1"] = function() {
  4665. return Module["asm"]["Z"].apply(null, arguments)
  4666. };
  4667. var _hb_buffer_add_utf16 = Module["_hb_buffer_add_utf16"] = function() {
  4668. return Module["asm"]["_"].apply(null, arguments)
  4669. };
  4670. var _hb_buffer_add_utf32 = Module["_hb_buffer_add_utf32"] = function() {
  4671. return Module["asm"]["$"].apply(null, arguments)
  4672. };
  4673. var _hb_buffer_add_utf8 = Module["_hb_buffer_add_utf8"] = function() {
  4674. return Module["asm"]["aa"].apply(null, arguments)
  4675. };
  4676. var _hb_buffer_allocation_successful = Module["_hb_buffer_allocation_successful"] = function() {
  4677. return Module["asm"]["ba"].apply(null, arguments)
  4678. };
  4679. var _hb_buffer_append = Module["_hb_buffer_append"] = function() {
  4680. return Module["asm"]["ca"].apply(null, arguments)
  4681. };
  4682. var _hb_buffer_clear_contents = Module["_hb_buffer_clear_contents"] = function() {
  4683. return Module["asm"]["da"].apply(null, arguments)
  4684. };
  4685. var _hb_buffer_create = Module["_hb_buffer_create"] = function() {
  4686. return Module["asm"]["ea"].apply(null, arguments)
  4687. };
  4688. var _hb_buffer_deserialize_glyphs = Module["_hb_buffer_deserialize_glyphs"] = function() {
  4689. return Module["asm"]["fa"].apply(null, arguments)
  4690. };
  4691. var _hb_buffer_destroy = Module["_hb_buffer_destroy"] = function() {
  4692. return Module["asm"]["ga"].apply(null, arguments)
  4693. };
  4694. var _hb_buffer_diff = Module["_hb_buffer_diff"] = function() {
  4695. return Module["asm"]["ha"].apply(null, arguments)
  4696. };
  4697. var _hb_buffer_get_cluster_level = Module["_hb_buffer_get_cluster_level"] = function() {
  4698. return Module["asm"]["ia"].apply(null, arguments)
  4699. };
  4700. var _hb_buffer_get_content_type = Module["_hb_buffer_get_content_type"] = function() {
  4701. return Module["asm"]["ja"].apply(null, arguments)
  4702. };
  4703. var _hb_buffer_get_direction = Module["_hb_buffer_get_direction"] = function() {
  4704. return Module["asm"]["ka"].apply(null, arguments)
  4705. };
  4706. var _hb_buffer_get_empty = Module["_hb_buffer_get_empty"] = function() {
  4707. return Module["asm"]["la"].apply(null, arguments)
  4708. };
  4709. var _hb_buffer_get_flags = Module["_hb_buffer_get_flags"] = function() {
  4710. return Module["asm"]["ma"].apply(null, arguments)
  4711. };
  4712. var _hb_buffer_get_glyph_infos = Module["_hb_buffer_get_glyph_infos"] = function() {
  4713. return Module["asm"]["na"].apply(null, arguments)
  4714. };
  4715. var _hb_buffer_get_glyph_positions = Module["_hb_buffer_get_glyph_positions"] = function() {
  4716. return Module["asm"]["oa"].apply(null, arguments)
  4717. };
  4718. var _hb_buffer_get_invisible_glyph = Module["_hb_buffer_get_invisible_glyph"] = function() {
  4719. return Module["asm"]["pa"].apply(null, arguments)
  4720. };
  4721. var _hb_buffer_get_language = Module["_hb_buffer_get_language"] = function() {
  4722. return Module["asm"]["qa"].apply(null, arguments)
  4723. };
  4724. var _hb_buffer_get_length = Module["_hb_buffer_get_length"] = function() {
  4725. return Module["asm"]["ra"].apply(null, arguments)
  4726. };
  4727. var _hb_buffer_get_replacement_codepoint = Module["_hb_buffer_get_replacement_codepoint"] = function() {
  4728. return Module["asm"]["sa"].apply(null, arguments)
  4729. };
  4730. var _hb_buffer_get_script = Module["_hb_buffer_get_script"] = function() {
  4731. return Module["asm"]["ta"].apply(null, arguments)
  4732. };
  4733. var _hb_buffer_get_segment_properties = Module["_hb_buffer_get_segment_properties"] = function() {
  4734. return Module["asm"]["ua"].apply(null, arguments)
  4735. };
  4736. var _hb_buffer_get_unicode_funcs = Module["_hb_buffer_get_unicode_funcs"] = function() {
  4737. return Module["asm"]["va"].apply(null, arguments)
  4738. };
  4739. var _hb_buffer_get_user_data = Module["_hb_buffer_get_user_data"] = function() {
  4740. return Module["asm"]["wa"].apply(null, arguments)
  4741. };
  4742. var _hb_buffer_guess_segment_properties = Module["_hb_buffer_guess_segment_properties"] = function() {
  4743. return Module["asm"]["xa"].apply(null, arguments)
  4744. };
  4745. var _hb_buffer_normalize_glyphs = Module["_hb_buffer_normalize_glyphs"] = function() {
  4746. return Module["asm"]["ya"].apply(null, arguments)
  4747. };
  4748. var _hb_buffer_pre_allocate = Module["_hb_buffer_pre_allocate"] = function() {
  4749. return Module["asm"]["za"].apply(null, arguments)
  4750. };
  4751. var _hb_buffer_reference = Module["_hb_buffer_reference"] = function() {
  4752. return Module["asm"]["Aa"].apply(null, arguments)
  4753. };
  4754. var _hb_buffer_reset = Module["_hb_buffer_reset"] = function() {
  4755. return Module["asm"]["Ba"].apply(null, arguments)
  4756. };
  4757. var _hb_buffer_reverse = Module["_hb_buffer_reverse"] = function() {
  4758. return Module["asm"]["Ca"].apply(null, arguments)
  4759. };
  4760. var _hb_buffer_reverse_clusters = Module["_hb_buffer_reverse_clusters"] = function() {
  4761. return Module["asm"]["Da"].apply(null, arguments)
  4762. };
  4763. var _hb_buffer_reverse_range = Module["_hb_buffer_reverse_range"] = function() {
  4764. return Module["asm"]["Ea"].apply(null, arguments)
  4765. };
  4766. var _hb_buffer_serialize_format_from_string = Module["_hb_buffer_serialize_format_from_string"] = function() {
  4767. return Module["asm"]["Fa"].apply(null, arguments)
  4768. };
  4769. var _hb_buffer_serialize_format_to_string = Module["_hb_buffer_serialize_format_to_string"] = function() {
  4770. return Module["asm"]["Ga"].apply(null, arguments)
  4771. };
  4772. var _hb_buffer_serialize_glyphs = Module["_hb_buffer_serialize_glyphs"] = function() {
  4773. return Module["asm"]["Ha"].apply(null, arguments)
  4774. };
  4775. var _hb_buffer_serialize_list_formats = Module["_hb_buffer_serialize_list_formats"] = function() {
  4776. return Module["asm"]["Ia"].apply(null, arguments)
  4777. };
  4778. var _hb_buffer_set_cluster_level = Module["_hb_buffer_set_cluster_level"] = function() {
  4779. return Module["asm"]["Ja"].apply(null, arguments)
  4780. };
  4781. var _hb_buffer_set_content_type = Module["_hb_buffer_set_content_type"] = function() {
  4782. return Module["asm"]["Ka"].apply(null, arguments)
  4783. };
  4784. var _hb_buffer_set_direction = Module["_hb_buffer_set_direction"] = function() {
  4785. return Module["asm"]["La"].apply(null, arguments)
  4786. };
  4787. var _hb_buffer_set_flags = Module["_hb_buffer_set_flags"] = function() {
  4788. return Module["asm"]["Ma"].apply(null, arguments)
  4789. };
  4790. var _hb_buffer_set_invisible_glyph = Module["_hb_buffer_set_invisible_glyph"] = function() {
  4791. return Module["asm"]["Na"].apply(null, arguments)
  4792. };
  4793. var _hb_buffer_set_language = Module["_hb_buffer_set_language"] = function() {
  4794. return Module["asm"]["Oa"].apply(null, arguments)
  4795. };
  4796. var _hb_buffer_set_length = Module["_hb_buffer_set_length"] = function() {
  4797. return Module["asm"]["Pa"].apply(null, arguments)
  4798. };
  4799. var _hb_buffer_set_message_func = Module["_hb_buffer_set_message_func"] = function() {
  4800. return Module["asm"]["Qa"].apply(null, arguments)
  4801. };
  4802. var _hb_buffer_set_replacement_codepoint = Module["_hb_buffer_set_replacement_codepoint"] = function() {
  4803. return Module["asm"]["Ra"].apply(null, arguments)
  4804. };
  4805. var _hb_buffer_set_script = Module["_hb_buffer_set_script"] = function() {
  4806. return Module["asm"]["Sa"].apply(null, arguments)
  4807. };
  4808. var _hb_buffer_set_segment_properties = Module["_hb_buffer_set_segment_properties"] = function() {
  4809. return Module["asm"]["Ta"].apply(null, arguments)
  4810. };
  4811. var _hb_buffer_set_unicode_funcs = Module["_hb_buffer_set_unicode_funcs"] = function() {
  4812. return Module["asm"]["Ua"].apply(null, arguments)
  4813. };
  4814. var _hb_buffer_set_user_data = Module["_hb_buffer_set_user_data"] = function() {
  4815. return Module["asm"]["Va"].apply(null, arguments)
  4816. };
  4817. var _hb_direction_from_string = Module["_hb_direction_from_string"] = function() {
  4818. return Module["asm"]["Wa"].apply(null, arguments)
  4819. };
  4820. var _hb_direction_to_string = Module["_hb_direction_to_string"] = function() {
  4821. return Module["asm"]["Xa"].apply(null, arguments)
  4822. };
  4823. var _hb_face_builder_add_table = Module["_hb_face_builder_add_table"] = function() {
  4824. return Module["asm"]["Ya"].apply(null, arguments)
  4825. };
  4826. var _hb_face_builder_create = Module["_hb_face_builder_create"] = function() {
  4827. return Module["asm"]["Za"].apply(null, arguments)
  4828. };
  4829. var _hb_face_collect_unicodes = Module["_hb_face_collect_unicodes"] = function() {
  4830. return Module["asm"]["_a"].apply(null, arguments)
  4831. };
  4832. var _hb_face_collect_variation_selectors = Module["_hb_face_collect_variation_selectors"] = function() {
  4833. return Module["asm"]["$a"].apply(null, arguments)
  4834. };
  4835. var _hb_face_collect_variation_unicodes = Module["_hb_face_collect_variation_unicodes"] = function() {
  4836. return Module["asm"]["ab"].apply(null, arguments)
  4837. };
  4838. var _hb_face_count = Module["_hb_face_count"] = function() {
  4839. return Module["asm"]["bb"].apply(null, arguments)
  4840. };
  4841. var _hb_face_create = Module["_hb_face_create"] = function() {
  4842. return Module["asm"]["cb"].apply(null, arguments)
  4843. };
  4844. var _hb_face_create_for_tables = Module["_hb_face_create_for_tables"] = function() {
  4845. return Module["asm"]["db"].apply(null, arguments)
  4846. };
  4847. var _hb_face_destroy = Module["_hb_face_destroy"] = function() {
  4848. return Module["asm"]["eb"].apply(null, arguments)
  4849. };
  4850. var _hb_face_get_empty = Module["_hb_face_get_empty"] = function() {
  4851. return Module["asm"]["fb"].apply(null, arguments)
  4852. };
  4853. var _hb_face_get_glyph_count = Module["_hb_face_get_glyph_count"] = function() {
  4854. return Module["asm"]["gb"].apply(null, arguments)
  4855. };
  4856. var _hb_face_get_index = Module["_hb_face_get_index"] = function() {
  4857. return Module["asm"]["hb"].apply(null, arguments)
  4858. };
  4859. var _hb_face_get_table_tags = Module["_hb_face_get_table_tags"] = function() {
  4860. return Module["asm"]["ib"].apply(null, arguments)
  4861. };
  4862. var _hb_face_get_upem = Module["_hb_face_get_upem"] = function() {
  4863. return Module["asm"]["jb"].apply(null, arguments)
  4864. };
  4865. var _hb_face_get_user_data = Module["_hb_face_get_user_data"] = function() {
  4866. return Module["asm"]["kb"].apply(null, arguments)
  4867. };
  4868. var _hb_face_is_immutable = Module["_hb_face_is_immutable"] = function() {
  4869. return Module["asm"]["lb"].apply(null, arguments)
  4870. };
  4871. var _hb_face_make_immutable = Module["_hb_face_make_immutable"] = function() {
  4872. return Module["asm"]["mb"].apply(null, arguments)
  4873. };
  4874. var _hb_face_reference = Module["_hb_face_reference"] = function() {
  4875. return Module["asm"]["nb"].apply(null, arguments)
  4876. };
  4877. var _hb_face_reference_blob = Module["_hb_face_reference_blob"] = function() {
  4878. return Module["asm"]["ob"].apply(null, arguments)
  4879. };
  4880. var _hb_face_reference_table = Module["_hb_face_reference_table"] = function() {
  4881. return Module["asm"]["pb"].apply(null, arguments)
  4882. };
  4883. var _hb_face_set_glyph_count = Module["_hb_face_set_glyph_count"] = function() {
  4884. return Module["asm"]["qb"].apply(null, arguments)
  4885. };
  4886. var _hb_face_set_index = Module["_hb_face_set_index"] = function() {
  4887. return Module["asm"]["rb"].apply(null, arguments)
  4888. };
  4889. var _hb_face_set_upem = Module["_hb_face_set_upem"] = function() {
  4890. return Module["asm"]["sb"].apply(null, arguments)
  4891. };
  4892. var _hb_face_set_user_data = Module["_hb_face_set_user_data"] = function() {
  4893. return Module["asm"]["tb"].apply(null, arguments)
  4894. };
  4895. var _hb_feature_from_string = Module["_hb_feature_from_string"] = function() {
  4896. return Module["asm"]["ub"].apply(null, arguments)
  4897. };
  4898. var _hb_feature_to_string = Module["_hb_feature_to_string"] = function() {
  4899. return Module["asm"]["vb"].apply(null, arguments)
  4900. };
  4901. var _hb_font_add_glyph_origin_for_direction = Module["_hb_font_add_glyph_origin_for_direction"] = function() {
  4902. return Module["asm"]["wb"].apply(null, arguments)
  4903. };
  4904. var _hb_font_create = Module["_hb_font_create"] = function() {
  4905. return Module["asm"]["xb"].apply(null, arguments)
  4906. };
  4907. var _hb_font_create_sub_font = Module["_hb_font_create_sub_font"] = function() {
  4908. return Module["asm"]["yb"].apply(null, arguments)
  4909. };
  4910. var _hb_font_destroy = Module["_hb_font_destroy"] = function() {
  4911. return Module["asm"]["zb"].apply(null, arguments)
  4912. };
  4913. var _hb_font_funcs_create = Module["_hb_font_funcs_create"] = function() {
  4914. return Module["asm"]["Ab"].apply(null, arguments)
  4915. };
  4916. var _hb_font_funcs_destroy = Module["_hb_font_funcs_destroy"] = function() {
  4917. return Module["asm"]["Bb"].apply(null, arguments)
  4918. };
  4919. var _hb_font_funcs_get_empty = Module["_hb_font_funcs_get_empty"] = function() {
  4920. return Module["asm"]["Cb"].apply(null, arguments)
  4921. };
  4922. var _hb_font_funcs_get_user_data = Module["_hb_font_funcs_get_user_data"] = function() {
  4923. return Module["asm"]["Db"].apply(null, arguments)
  4924. };
  4925. var _hb_font_funcs_is_immutable = Module["_hb_font_funcs_is_immutable"] = function() {
  4926. return Module["asm"]["Eb"].apply(null, arguments)
  4927. };
  4928. var _hb_font_funcs_make_immutable = Module["_hb_font_funcs_make_immutable"] = function() {
  4929. return Module["asm"]["Fb"].apply(null, arguments)
  4930. };
  4931. var _hb_font_funcs_reference = Module["_hb_font_funcs_reference"] = function() {
  4932. return Module["asm"]["Gb"].apply(null, arguments)
  4933. };
  4934. var _hb_font_funcs_set_font_h_extents_func = Module["_hb_font_funcs_set_font_h_extents_func"] = function() {
  4935. return Module["asm"]["Hb"].apply(null, arguments)
  4936. };
  4937. var _hb_font_funcs_set_font_v_extents_func = Module["_hb_font_funcs_set_font_v_extents_func"] = function() {
  4938. return Module["asm"]["Ib"].apply(null, arguments)
  4939. };
  4940. var _hb_font_funcs_set_glyph_contour_point_func = Module["_hb_font_funcs_set_glyph_contour_point_func"] = function() {
  4941. return Module["asm"]["Jb"].apply(null, arguments)
  4942. };
  4943. var _hb_font_funcs_set_glyph_extents_func = Module["_hb_font_funcs_set_glyph_extents_func"] = function() {
  4944. return Module["asm"]["Kb"].apply(null, arguments)
  4945. };
  4946. var _hb_font_funcs_set_glyph_from_name_func = Module["_hb_font_funcs_set_glyph_from_name_func"] = function() {
  4947. return Module["asm"]["Lb"].apply(null, arguments)
  4948. };
  4949. var _hb_font_funcs_set_glyph_func = Module["_hb_font_funcs_set_glyph_func"] = function() {
  4950. return Module["asm"]["Mb"].apply(null, arguments)
  4951. };
  4952. var _hb_font_funcs_set_glyph_h_advance_func = Module["_hb_font_funcs_set_glyph_h_advance_func"] = function() {
  4953. return Module["asm"]["Nb"].apply(null, arguments)
  4954. };
  4955. var _hb_font_funcs_set_glyph_h_advances_func = Module["_hb_font_funcs_set_glyph_h_advances_func"] = function() {
  4956. return Module["asm"]["Ob"].apply(null, arguments)
  4957. };
  4958. var _hb_font_funcs_set_glyph_h_kerning_func = Module["_hb_font_funcs_set_glyph_h_kerning_func"] = function() {
  4959. return Module["asm"]["Pb"].apply(null, arguments)
  4960. };
  4961. var _hb_font_funcs_set_glyph_h_origin_func = Module["_hb_font_funcs_set_glyph_h_origin_func"] = function() {
  4962. return Module["asm"]["Qb"].apply(null, arguments)
  4963. };
  4964. var _hb_font_funcs_set_glyph_name_func = Module["_hb_font_funcs_set_glyph_name_func"] = function() {
  4965. return Module["asm"]["Rb"].apply(null, arguments)
  4966. };
  4967. var _hb_font_funcs_set_glyph_v_advance_func = Module["_hb_font_funcs_set_glyph_v_advance_func"] = function() {
  4968. return Module["asm"]["Sb"].apply(null, arguments)
  4969. };
  4970. var _hb_font_funcs_set_glyph_v_advances_func = Module["_hb_font_funcs_set_glyph_v_advances_func"] = function() {
  4971. return Module["asm"]["Tb"].apply(null, arguments)
  4972. };
  4973. var _hb_font_funcs_set_glyph_v_kerning_func = Module["_hb_font_funcs_set_glyph_v_kerning_func"] = function() {
  4974. return Module["asm"]["Ub"].apply(null, arguments)
  4975. };
  4976. var _hb_font_funcs_set_glyph_v_origin_func = Module["_hb_font_funcs_set_glyph_v_origin_func"] = function() {
  4977. return Module["asm"]["Vb"].apply(null, arguments)
  4978. };
  4979. var _hb_font_funcs_set_nominal_glyph_func = Module["_hb_font_funcs_set_nominal_glyph_func"] = function() {
  4980. return Module["asm"]["Wb"].apply(null, arguments)
  4981. };
  4982. var _hb_font_funcs_set_nominal_glyphs_func = Module["_hb_font_funcs_set_nominal_glyphs_func"] = function() {
  4983. return Module["asm"]["Xb"].apply(null, arguments)
  4984. };
  4985. var _hb_font_funcs_set_user_data = Module["_hb_font_funcs_set_user_data"] = function() {
  4986. return Module["asm"]["Yb"].apply(null, arguments)
  4987. };
  4988. var _hb_font_funcs_set_variation_glyph_func = Module["_hb_font_funcs_set_variation_glyph_func"] = function() {
  4989. return Module["asm"]["Zb"].apply(null, arguments)
  4990. };
  4991. var _hb_font_get_empty = Module["_hb_font_get_empty"] = function() {
  4992. return Module["asm"]["_b"].apply(null, arguments)
  4993. };
  4994. var _hb_font_get_extents_for_direction = Module["_hb_font_get_extents_for_direction"] = function() {
  4995. return Module["asm"]["$b"].apply(null, arguments)
  4996. };
  4997. var _hb_font_get_face = Module["_hb_font_get_face"] = function() {
  4998. return Module["asm"]["ac"].apply(null, arguments)
  4999. };
  5000. var _hb_font_get_glyph = Module["_hb_font_get_glyph"] = function() {
  5001. return Module["asm"]["bc"].apply(null, arguments)
  5002. };
  5003. var _hb_font_get_glyph_advance_for_direction = Module["_hb_font_get_glyph_advance_for_direction"] = function() {
  5004. return Module["asm"]["cc"].apply(null, arguments)
  5005. };
  5006. var _hb_font_get_glyph_advances_for_direction = Module["_hb_font_get_glyph_advances_for_direction"] = function() {
  5007. return Module["asm"]["dc"].apply(null, arguments)
  5008. };
  5009. var _hb_font_get_glyph_contour_point = Module["_hb_font_get_glyph_contour_point"] = function() {
  5010. return Module["asm"]["ec"].apply(null, arguments)
  5011. };
  5012. var _hb_font_get_glyph_contour_point_for_origin = Module["_hb_font_get_glyph_contour_point_for_origin"] = function() {
  5013. return Module["asm"]["fc"].apply(null, arguments)
  5014. };
  5015. var _hb_font_get_glyph_extents = Module["_hb_font_get_glyph_extents"] = function() {
  5016. return Module["asm"]["gc"].apply(null, arguments)
  5017. };
  5018. var _hb_font_get_glyph_extents_for_origin = Module["_hb_font_get_glyph_extents_for_origin"] = function() {
  5019. return Module["asm"]["hc"].apply(null, arguments)
  5020. };
  5021. var _hb_font_get_glyph_from_name = Module["_hb_font_get_glyph_from_name"] = function() {
  5022. return Module["asm"]["ic"].apply(null, arguments)
  5023. };
  5024. var _hb_font_get_glyph_h_advance = Module["_hb_font_get_glyph_h_advance"] = function() {
  5025. return Module["asm"]["jc"].apply(null, arguments)
  5026. };
  5027. var _hb_font_get_glyph_h_advances = Module["_hb_font_get_glyph_h_advances"] = function() {
  5028. return Module["asm"]["kc"].apply(null, arguments)
  5029. };
  5030. var _hb_font_get_glyph_h_kerning = Module["_hb_font_get_glyph_h_kerning"] = function() {
  5031. return Module["asm"]["lc"].apply(null, arguments)
  5032. };
  5033. var _hb_font_get_glyph_h_origin = Module["_hb_font_get_glyph_h_origin"] = function() {
  5034. return Module["asm"]["mc"].apply(null, arguments)
  5035. };
  5036. var _hb_font_get_glyph_kerning_for_direction = Module["_hb_font_get_glyph_kerning_for_direction"] = function() {
  5037. return Module["asm"]["nc"].apply(null, arguments)
  5038. };
  5039. var _hb_font_get_glyph_name = Module["_hb_font_get_glyph_name"] = function() {
  5040. return Module["asm"]["oc"].apply(null, arguments)
  5041. };
  5042. var _hb_font_get_glyph_origin_for_direction = Module["_hb_font_get_glyph_origin_for_direction"] = function() {
  5043. return Module["asm"]["pc"].apply(null, arguments)
  5044. };
  5045. var _hb_font_get_glyph_v_advance = Module["_hb_font_get_glyph_v_advance"] = function() {
  5046. return Module["asm"]["qc"].apply(null, arguments)
  5047. };
  5048. var _hb_font_get_glyph_v_advances = Module["_hb_font_get_glyph_v_advances"] = function() {
  5049. return Module["asm"]["rc"].apply(null, arguments)
  5050. };
  5051. var _hb_font_get_glyph_v_kerning = Module["_hb_font_get_glyph_v_kerning"] = function() {
  5052. return Module["asm"]["sc"].apply(null, arguments)
  5053. };
  5054. var _hb_font_get_glyph_v_origin = Module["_hb_font_get_glyph_v_origin"] = function() {
  5055. return Module["asm"]["tc"].apply(null, arguments)
  5056. };
  5057. var _hb_font_get_h_extents = Module["_hb_font_get_h_extents"] = function() {
  5058. return Module["asm"]["uc"].apply(null, arguments)
  5059. };
  5060. var _hb_font_get_nominal_glyph = Module["_hb_font_get_nominal_glyph"] = function() {
  5061. return Module["asm"]["vc"].apply(null, arguments)
  5062. };
  5063. var _hb_font_get_parent = Module["_hb_font_get_parent"] = function() {
  5064. return Module["asm"]["wc"].apply(null, arguments)
  5065. };
  5066. var _hb_font_get_ppem = Module["_hb_font_get_ppem"] = function() {
  5067. return Module["asm"]["xc"].apply(null, arguments)
  5068. };
  5069. var _hb_font_get_ptem = Module["_hb_font_get_ptem"] = function() {
  5070. return Module["asm"]["yc"].apply(null, arguments)
  5071. };
  5072. var _hb_font_get_scale = Module["_hb_font_get_scale"] = function() {
  5073. return Module["asm"]["zc"].apply(null, arguments)
  5074. };
  5075. var _hb_font_get_user_data = Module["_hb_font_get_user_data"] = function() {
  5076. return Module["asm"]["Ac"].apply(null, arguments)
  5077. };
  5078. var _hb_font_get_v_extents = Module["_hb_font_get_v_extents"] = function() {
  5079. return Module["asm"]["Bc"].apply(null, arguments)
  5080. };
  5081. var _hb_font_get_var_coords_normalized = Module["_hb_font_get_var_coords_normalized"] = function() {
  5082. return Module["asm"]["Cc"].apply(null, arguments)
  5083. };
  5084. var _hb_font_get_variation_glyph = Module["_hb_font_get_variation_glyph"] = function() {
  5085. return Module["asm"]["Dc"].apply(null, arguments)
  5086. };
  5087. var _hb_font_glyph_from_string = Module["_hb_font_glyph_from_string"] = function() {
  5088. return Module["asm"]["Ec"].apply(null, arguments)
  5089. };
  5090. var _hb_font_glyph_to_string = Module["_hb_font_glyph_to_string"] = function() {
  5091. return Module["asm"]["Fc"].apply(null, arguments)
  5092. };
  5093. var _hb_font_is_immutable = Module["_hb_font_is_immutable"] = function() {
  5094. return Module["asm"]["Gc"].apply(null, arguments)
  5095. };
  5096. var _hb_font_make_immutable = Module["_hb_font_make_immutable"] = function() {
  5097. return Module["asm"]["Hc"].apply(null, arguments)
  5098. };
  5099. var _hb_font_reference = Module["_hb_font_reference"] = function() {
  5100. return Module["asm"]["Ic"].apply(null, arguments)
  5101. };
  5102. var _hb_font_set_face = Module["_hb_font_set_face"] = function() {
  5103. return Module["asm"]["Jc"].apply(null, arguments)
  5104. };
  5105. var _hb_font_set_funcs = Module["_hb_font_set_funcs"] = function() {
  5106. return Module["asm"]["Kc"].apply(null, arguments)
  5107. };
  5108. var _hb_font_set_funcs_data = Module["_hb_font_set_funcs_data"] = function() {
  5109. return Module["asm"]["Lc"].apply(null, arguments)
  5110. };
  5111. var _hb_font_set_parent = Module["_hb_font_set_parent"] = function() {
  5112. return Module["asm"]["Mc"].apply(null, arguments)
  5113. };
  5114. var _hb_font_set_ppem = Module["_hb_font_set_ppem"] = function() {
  5115. return Module["asm"]["Nc"].apply(null, arguments)
  5116. };
  5117. var _hb_font_set_ptem = Module["_hb_font_set_ptem"] = function() {
  5118. return Module["asm"]["Oc"].apply(null, arguments)
  5119. };
  5120. var _hb_font_set_scale = Module["_hb_font_set_scale"] = function() {
  5121. return Module["asm"]["Pc"].apply(null, arguments)
  5122. };
  5123. var _hb_font_set_user_data = Module["_hb_font_set_user_data"] = function() {
  5124. return Module["asm"]["Qc"].apply(null, arguments)
  5125. };
  5126. var _hb_font_set_var_coords_design = Module["_hb_font_set_var_coords_design"] = function() {
  5127. return Module["asm"]["Rc"].apply(null, arguments)
  5128. };
  5129. var _hb_font_set_var_coords_normalized = Module["_hb_font_set_var_coords_normalized"] = function() {
  5130. return Module["asm"]["Sc"].apply(null, arguments)
  5131. };
  5132. var _hb_font_set_variations = Module["_hb_font_set_variations"] = function() {
  5133. return Module["asm"]["Tc"].apply(null, arguments)
  5134. };
  5135. var _hb_font_subtract_glyph_origin_for_direction = Module["_hb_font_subtract_glyph_origin_for_direction"] = function() {
  5136. return Module["asm"]["Uc"].apply(null, arguments)
  5137. };
  5138. var _hb_glyph_info_get_glyph_flags = Module["_hb_glyph_info_get_glyph_flags"] = function() {
  5139. return Module["asm"]["Vc"].apply(null, arguments)
  5140. };
  5141. var _hb_language_from_string = Module["_hb_language_from_string"] = function() {
  5142. return Module["asm"]["Wc"].apply(null, arguments)
  5143. };
  5144. var _hb_language_get_default = Module["_hb_language_get_default"] = function() {
  5145. return Module["asm"]["Xc"].apply(null, arguments)
  5146. };
  5147. var _hb_language_to_string = Module["_hb_language_to_string"] = function() {
  5148. return Module["asm"]["Yc"].apply(null, arguments)
  5149. };
  5150. var _hb_map_allocation_successful = Module["_hb_map_allocation_successful"] = function() {
  5151. return Module["asm"]["Zc"].apply(null, arguments)
  5152. };
  5153. var _hb_map_clear = Module["_hb_map_clear"] = function() {
  5154. return Module["asm"]["_c"].apply(null, arguments)
  5155. };
  5156. var _hb_map_create = Module["_hb_map_create"] = function() {
  5157. return Module["asm"]["$c"].apply(null, arguments)
  5158. };
  5159. var _hb_map_del = Module["_hb_map_del"] = function() {
  5160. return Module["asm"]["ad"].apply(null, arguments)
  5161. };
  5162. var _hb_map_destroy = Module["_hb_map_destroy"] = function() {
  5163. return Module["asm"]["bd"].apply(null, arguments)
  5164. };
  5165. var _hb_map_get = Module["_hb_map_get"] = function() {
  5166. return Module["asm"]["cd"].apply(null, arguments)
  5167. };
  5168. var _hb_map_get_empty = Module["_hb_map_get_empty"] = function() {
  5169. return Module["asm"]["dd"].apply(null, arguments)
  5170. };
  5171. var _hb_map_get_population = Module["_hb_map_get_population"] = function() {
  5172. return Module["asm"]["ed"].apply(null, arguments)
  5173. };
  5174. var _hb_map_get_user_data = Module["_hb_map_get_user_data"] = function() {
  5175. return Module["asm"]["fd"].apply(null, arguments)
  5176. };
  5177. var _hb_map_has = Module["_hb_map_has"] = function() {
  5178. return Module["asm"]["gd"].apply(null, arguments)
  5179. };
  5180. var _hb_map_is_empty = Module["_hb_map_is_empty"] = function() {
  5181. return Module["asm"]["hd"].apply(null, arguments)
  5182. };
  5183. var _hb_map_reference = Module["_hb_map_reference"] = function() {
  5184. return Module["asm"]["id"].apply(null, arguments)
  5185. };
  5186. var _hb_map_set = Module["_hb_map_set"] = function() {
  5187. return Module["asm"]["jd"].apply(null, arguments)
  5188. };
  5189. var _hb_map_set_user_data = Module["_hb_map_set_user_data"] = function() {
  5190. return Module["asm"]["kd"].apply(null, arguments)
  5191. };
  5192. var _hb_ot_color_glyph_get_layers = Module["_hb_ot_color_glyph_get_layers"] = function() {
  5193. return Module["asm"]["ld"].apply(null, arguments)
  5194. };
  5195. var _hb_ot_color_glyph_reference_png = Module["_hb_ot_color_glyph_reference_png"] = function() {
  5196. return Module["asm"]["md"].apply(null, arguments)
  5197. };
  5198. var _hb_ot_color_glyph_reference_svg = Module["_hb_ot_color_glyph_reference_svg"] = function() {
  5199. return Module["asm"]["nd"].apply(null, arguments)
  5200. };
  5201. var _hb_ot_color_has_layers = Module["_hb_ot_color_has_layers"] = function() {
  5202. return Module["asm"]["od"].apply(null, arguments)
  5203. };
  5204. var _hb_ot_color_has_palettes = Module["_hb_ot_color_has_palettes"] = function() {
  5205. return Module["asm"]["pd"].apply(null, arguments)
  5206. };
  5207. var _hb_ot_color_has_png = Module["_hb_ot_color_has_png"] = function() {
  5208. return Module["asm"]["qd"].apply(null, arguments)
  5209. };
  5210. var _hb_ot_color_has_svg = Module["_hb_ot_color_has_svg"] = function() {
  5211. return Module["asm"]["rd"].apply(null, arguments)
  5212. };
  5213. var _hb_ot_color_palette_color_get_name_id = Module["_hb_ot_color_palette_color_get_name_id"] = function() {
  5214. return Module["asm"]["sd"].apply(null, arguments)
  5215. };
  5216. var _hb_ot_color_palette_get_colors = Module["_hb_ot_color_palette_get_colors"] = function() {
  5217. return Module["asm"]["td"].apply(null, arguments)
  5218. };
  5219. var _hb_ot_color_palette_get_count = Module["_hb_ot_color_palette_get_count"] = function() {
  5220. return Module["asm"]["ud"].apply(null, arguments)
  5221. };
  5222. var _hb_ot_color_palette_get_flags = Module["_hb_ot_color_palette_get_flags"] = function() {
  5223. return Module["asm"]["vd"].apply(null, arguments)
  5224. };
  5225. var _hb_ot_color_palette_get_name_id = Module["_hb_ot_color_palette_get_name_id"] = function() {
  5226. return Module["asm"]["wd"].apply(null, arguments)
  5227. };
  5228. var _hb_ot_font_set_funcs = Module["_hb_ot_font_set_funcs"] = function() {
  5229. return Module["asm"]["xd"].apply(null, arguments)
  5230. };
  5231. var _hb_ot_layout_collect_features = Module["_hb_ot_layout_collect_features"] = function() {
  5232. return Module["asm"]["yd"].apply(null, arguments)
  5233. };
  5234. var _hb_ot_layout_collect_lookups = Module["_hb_ot_layout_collect_lookups"] = function() {
  5235. return Module["asm"]["zd"].apply(null, arguments)
  5236. };
  5237. var _hb_ot_layout_feature_get_characters = Module["_hb_ot_layout_feature_get_characters"] = function() {
  5238. return Module["asm"]["Ad"].apply(null, arguments)
  5239. };
  5240. var _hb_ot_layout_feature_get_lookups = Module["_hb_ot_layout_feature_get_lookups"] = function() {
  5241. return Module["asm"]["Bd"].apply(null, arguments)
  5242. };
  5243. var _hb_ot_layout_feature_get_name_ids = Module["_hb_ot_layout_feature_get_name_ids"] = function() {
  5244. return Module["asm"]["Cd"].apply(null, arguments)
  5245. };
  5246. var _hb_ot_layout_feature_with_variations_get_lookups = Module["_hb_ot_layout_feature_with_variations_get_lookups"] = function() {
  5247. return Module["asm"]["Dd"].apply(null, arguments)
  5248. };
  5249. var _hb_ot_layout_get_attach_points = Module["_hb_ot_layout_get_attach_points"] = function() {
  5250. return Module["asm"]["Ed"].apply(null, arguments)
  5251. };
  5252. var _hb_ot_layout_get_glyph_class = Module["_hb_ot_layout_get_glyph_class"] = function() {
  5253. return Module["asm"]["Fd"].apply(null, arguments)
  5254. };
  5255. var _hb_ot_layout_get_glyphs_in_class = Module["_hb_ot_layout_get_glyphs_in_class"] = function() {
  5256. return Module["asm"]["Gd"].apply(null, arguments)
  5257. };
  5258. var _hb_ot_layout_get_ligature_carets = Module["_hb_ot_layout_get_ligature_carets"] = function() {
  5259. return Module["asm"]["Hd"].apply(null, arguments)
  5260. };
  5261. var _hb_ot_layout_get_size_params = Module["_hb_ot_layout_get_size_params"] = function() {
  5262. return Module["asm"]["Id"].apply(null, arguments)
  5263. };
  5264. var _hb_ot_layout_has_glyph_classes = Module["_hb_ot_layout_has_glyph_classes"] = function() {
  5265. return Module["asm"]["Jd"].apply(null, arguments)
  5266. };
  5267. var _hb_ot_layout_has_positioning = Module["_hb_ot_layout_has_positioning"] = function() {
  5268. return Module["asm"]["Kd"].apply(null, arguments)
  5269. };
  5270. var _hb_ot_layout_has_substitution = Module["_hb_ot_layout_has_substitution"] = function() {
  5271. return Module["asm"]["Ld"].apply(null, arguments)
  5272. };
  5273. var _hb_ot_layout_language_find_feature = Module["_hb_ot_layout_language_find_feature"] = function() {
  5274. return Module["asm"]["Md"].apply(null, arguments)
  5275. };
  5276. var _hb_ot_layout_language_get_feature_indexes = Module["_hb_ot_layout_language_get_feature_indexes"] = function() {
  5277. return Module["asm"]["Nd"].apply(null, arguments)
  5278. };
  5279. var _hb_ot_layout_language_get_feature_tags = Module["_hb_ot_layout_language_get_feature_tags"] = function() {
  5280. return Module["asm"]["Od"].apply(null, arguments)
  5281. };
  5282. var _hb_ot_layout_language_get_required_feature = Module["_hb_ot_layout_language_get_required_feature"] = function() {
  5283. return Module["asm"]["Pd"].apply(null, arguments)
  5284. };
  5285. var _hb_ot_layout_language_get_required_feature_index = Module["_hb_ot_layout_language_get_required_feature_index"] = function() {
  5286. return Module["asm"]["Qd"].apply(null, arguments)
  5287. };
  5288. var _hb_ot_layout_lookup_collect_glyphs = Module["_hb_ot_layout_lookup_collect_glyphs"] = function() {
  5289. return Module["asm"]["Rd"].apply(null, arguments)
  5290. };
  5291. var _hb_ot_layout_lookup_substitute_closure = Module["_hb_ot_layout_lookup_substitute_closure"] = function() {
  5292. return Module["asm"]["Sd"].apply(null, arguments)
  5293. };
  5294. var _hb_ot_layout_lookup_would_substitute = Module["_hb_ot_layout_lookup_would_substitute"] = function() {
  5295. return Module["asm"]["Td"].apply(null, arguments)
  5296. };
  5297. var _hb_ot_layout_lookups_substitute_closure = Module["_hb_ot_layout_lookups_substitute_closure"] = function() {
  5298. return Module["asm"]["Ud"].apply(null, arguments)
  5299. };
  5300. var _hb_ot_layout_script_find_language = Module["_hb_ot_layout_script_find_language"] = function() {
  5301. return Module["asm"]["Vd"].apply(null, arguments)
  5302. };
  5303. var _hb_ot_layout_script_get_language_tags = Module["_hb_ot_layout_script_get_language_tags"] = function() {
  5304. return Module["asm"]["Wd"].apply(null, arguments)
  5305. };
  5306. var _hb_ot_layout_script_select_language = Module["_hb_ot_layout_script_select_language"] = function() {
  5307. return Module["asm"]["Xd"].apply(null, arguments)
  5308. };
  5309. var _hb_ot_layout_table_choose_script = Module["_hb_ot_layout_table_choose_script"] = function() {
  5310. return Module["asm"]["Yd"].apply(null, arguments)
  5311. };
  5312. var _hb_ot_layout_table_find_feature_variations = Module["_hb_ot_layout_table_find_feature_variations"] = function() {
  5313. return Module["asm"]["Zd"].apply(null, arguments)
  5314. };
  5315. var _hb_ot_layout_table_find_script = Module["_hb_ot_layout_table_find_script"] = function() {
  5316. return Module["asm"]["_d"].apply(null, arguments)
  5317. };
  5318. var _hb_ot_layout_table_get_feature_tags = Module["_hb_ot_layout_table_get_feature_tags"] = function() {
  5319. return Module["asm"]["$d"].apply(null, arguments)
  5320. };
  5321. var _hb_ot_layout_table_get_lookup_count = Module["_hb_ot_layout_table_get_lookup_count"] = function() {
  5322. return Module["asm"]["ae"].apply(null, arguments)
  5323. };
  5324. var _hb_ot_layout_table_get_script_tags = Module["_hb_ot_layout_table_get_script_tags"] = function() {
  5325. return Module["asm"]["be"].apply(null, arguments)
  5326. };
  5327. var _hb_ot_layout_table_select_script = Module["_hb_ot_layout_table_select_script"] = function() {
  5328. return Module["asm"]["ce"].apply(null, arguments)
  5329. };
  5330. var _hb_ot_math_get_constant = Module["_hb_ot_math_get_constant"] = function() {
  5331. return Module["asm"]["de"].apply(null, arguments)
  5332. };
  5333. var _hb_ot_math_get_glyph_assembly = Module["_hb_ot_math_get_glyph_assembly"] = function() {
  5334. return Module["asm"]["ee"].apply(null, arguments)
  5335. };
  5336. var _hb_ot_math_get_glyph_italics_correction = Module["_hb_ot_math_get_glyph_italics_correction"] = function() {
  5337. return Module["asm"]["fe"].apply(null, arguments)
  5338. };
  5339. var _hb_ot_math_get_glyph_kerning = Module["_hb_ot_math_get_glyph_kerning"] = function() {
  5340. return Module["asm"]["ge"].apply(null, arguments)
  5341. };
  5342. var _hb_ot_math_get_glyph_top_accent_attachment = Module["_hb_ot_math_get_glyph_top_accent_attachment"] = function() {
  5343. return Module["asm"]["he"].apply(null, arguments)
  5344. };
  5345. var _hb_ot_math_get_glyph_variants = Module["_hb_ot_math_get_glyph_variants"] = function() {
  5346. return Module["asm"]["ie"].apply(null, arguments)
  5347. };
  5348. var _hb_ot_math_get_min_connector_overlap = Module["_hb_ot_math_get_min_connector_overlap"] = function() {
  5349. return Module["asm"]["je"].apply(null, arguments)
  5350. };
  5351. var _hb_ot_math_has_data = Module["_hb_ot_math_has_data"] = function() {
  5352. return Module["asm"]["ke"].apply(null, arguments)
  5353. };
  5354. var _hb_ot_math_is_glyph_extended_shape = Module["_hb_ot_math_is_glyph_extended_shape"] = function() {
  5355. return Module["asm"]["le"].apply(null, arguments)
  5356. };
  5357. var _hb_ot_name_get_utf16 = Module["_hb_ot_name_get_utf16"] = function() {
  5358. return Module["asm"]["me"].apply(null, arguments)
  5359. };
  5360. var _hb_ot_name_get_utf32 = Module["_hb_ot_name_get_utf32"] = function() {
  5361. return Module["asm"]["ne"].apply(null, arguments)
  5362. };
  5363. var _hb_ot_name_get_utf8 = Module["_hb_ot_name_get_utf8"] = function() {
  5364. return Module["asm"]["oe"].apply(null, arguments)
  5365. };
  5366. var _hb_ot_name_list_names = Module["_hb_ot_name_list_names"] = function() {
  5367. return Module["asm"]["pe"].apply(null, arguments)
  5368. };
  5369. var _hb_ot_shape_glyphs_closure = Module["_hb_ot_shape_glyphs_closure"] = function() {
  5370. return Module["asm"]["qe"].apply(null, arguments)
  5371. };
  5372. var _hb_ot_shape_plan_collect_lookups = Module["_hb_ot_shape_plan_collect_lookups"] = function() {
  5373. return Module["asm"]["re"].apply(null, arguments)
  5374. };
  5375. var _hb_ot_tag_from_language = Module["_hb_ot_tag_from_language"] = function() {
  5376. return Module["asm"]["se"].apply(null, arguments)
  5377. };
  5378. var _hb_ot_tag_to_language = Module["_hb_ot_tag_to_language"] = function() {
  5379. return Module["asm"]["te"].apply(null, arguments)
  5380. };
  5381. var _hb_ot_tag_to_script = Module["_hb_ot_tag_to_script"] = function() {
  5382. return Module["asm"]["ue"].apply(null, arguments)
  5383. };
  5384. var _hb_ot_tags_from_script = Module["_hb_ot_tags_from_script"] = function() {
  5385. return Module["asm"]["ve"].apply(null, arguments)
  5386. };
  5387. var _hb_ot_tags_from_script_and_language = Module["_hb_ot_tags_from_script_and_language"] = function() {
  5388. return Module["asm"]["we"].apply(null, arguments)
  5389. };
  5390. var _hb_ot_tags_to_script_and_language = Module["_hb_ot_tags_to_script_and_language"] = function() {
  5391. return Module["asm"]["xe"].apply(null, arguments)
  5392. };
  5393. var _hb_ot_var_find_axis = Module["_hb_ot_var_find_axis"] = function() {
  5394. return Module["asm"]["ye"].apply(null, arguments)
  5395. };
  5396. var _hb_ot_var_find_axis_info = Module["_hb_ot_var_find_axis_info"] = function() {
  5397. return Module["asm"]["ze"].apply(null, arguments)
  5398. };
  5399. var _hb_ot_var_get_axes = Module["_hb_ot_var_get_axes"] = function() {
  5400. return Module["asm"]["Ae"].apply(null, arguments)
  5401. };
  5402. var _hb_ot_var_get_axis_count = Module["_hb_ot_var_get_axis_count"] = function() {
  5403. return Module["asm"]["Be"].apply(null, arguments)
  5404. };
  5405. var _hb_ot_var_get_axis_infos = Module["_hb_ot_var_get_axis_infos"] = function() {
  5406. return Module["asm"]["Ce"].apply(null, arguments)
  5407. };
  5408. var _hb_ot_var_get_named_instance_count = Module["_hb_ot_var_get_named_instance_count"] = function() {
  5409. return Module["asm"]["De"].apply(null, arguments)
  5410. };
  5411. var _hb_ot_var_has_data = Module["_hb_ot_var_has_data"] = function() {
  5412. return Module["asm"]["Ee"].apply(null, arguments)
  5413. };
  5414. var _hb_ot_var_named_instance_get_design_coords = Module["_hb_ot_var_named_instance_get_design_coords"] = function() {
  5415. return Module["asm"]["Fe"].apply(null, arguments)
  5416. };
  5417. var _hb_ot_var_named_instance_get_postscript_name_id = Module["_hb_ot_var_named_instance_get_postscript_name_id"] = function() {
  5418. return Module["asm"]["Ge"].apply(null, arguments)
  5419. };
  5420. var _hb_ot_var_named_instance_get_subfamily_name_id = Module["_hb_ot_var_named_instance_get_subfamily_name_id"] = function() {
  5421. return Module["asm"]["He"].apply(null, arguments)
  5422. };
  5423. var _hb_ot_var_normalize_coords = Module["_hb_ot_var_normalize_coords"] = function() {
  5424. return Module["asm"]["Ie"].apply(null, arguments)
  5425. };
  5426. var _hb_ot_var_normalize_variations = Module["_hb_ot_var_normalize_variations"] = function() {
  5427. return Module["asm"]["Je"].apply(null, arguments)
  5428. };
  5429. var _hb_script_from_iso15924_tag = Module["_hb_script_from_iso15924_tag"] = function() {
  5430. return Module["asm"]["Ke"].apply(null, arguments)
  5431. };
  5432. var _hb_script_from_string = Module["_hb_script_from_string"] = function() {
  5433. return Module["asm"]["Le"].apply(null, arguments)
  5434. };
  5435. var _hb_script_get_horizontal_direction = Module["_hb_script_get_horizontal_direction"] = function() {
  5436. return Module["asm"]["Me"].apply(null, arguments)
  5437. };
  5438. var _hb_script_to_iso15924_tag = Module["_hb_script_to_iso15924_tag"] = function() {
  5439. return Module["asm"]["Ne"].apply(null, arguments)
  5440. };
  5441. var _hb_segment_properties_equal = Module["_hb_segment_properties_equal"] = function() {
  5442. return Module["asm"]["Oe"].apply(null, arguments)
  5443. };
  5444. var _hb_segment_properties_hash = Module["_hb_segment_properties_hash"] = function() {
  5445. return Module["asm"]["Pe"].apply(null, arguments)
  5446. };
  5447. var _hb_set_add = Module["_hb_set_add"] = function() {
  5448. return Module["asm"]["Qe"].apply(null, arguments)
  5449. };
  5450. var _hb_set_add_range = Module["_hb_set_add_range"] = function() {
  5451. return Module["asm"]["Re"].apply(null, arguments)
  5452. };
  5453. var _hb_set_allocation_successful = Module["_hb_set_allocation_successful"] = function() {
  5454. return Module["asm"]["Se"].apply(null, arguments)
  5455. };
  5456. var _hb_set_clear = Module["_hb_set_clear"] = function() {
  5457. return Module["asm"]["Te"].apply(null, arguments)
  5458. };
  5459. var _hb_set_create = Module["_hb_set_create"] = function() {
  5460. return Module["asm"]["Ue"].apply(null, arguments)
  5461. };
  5462. var _hb_set_del = Module["_hb_set_del"] = function() {
  5463. return Module["asm"]["Ve"].apply(null, arguments)
  5464. };
  5465. var _hb_set_del_range = Module["_hb_set_del_range"] = function() {
  5466. return Module["asm"]["We"].apply(null, arguments)
  5467. };
  5468. var _hb_set_destroy = Module["_hb_set_destroy"] = function() {
  5469. return Module["asm"]["Xe"].apply(null, arguments)
  5470. };
  5471. var _hb_set_get_empty = Module["_hb_set_get_empty"] = function() {
  5472. return Module["asm"]["Ye"].apply(null, arguments)
  5473. };
  5474. var _hb_set_get_max = Module["_hb_set_get_max"] = function() {
  5475. return Module["asm"]["Ze"].apply(null, arguments)
  5476. };
  5477. var _hb_set_get_min = Module["_hb_set_get_min"] = function() {
  5478. return Module["asm"]["_e"].apply(null, arguments)
  5479. };
  5480. var _hb_set_get_population = Module["_hb_set_get_population"] = function() {
  5481. return Module["asm"]["$e"].apply(null, arguments)
  5482. };
  5483. var _hb_set_get_user_data = Module["_hb_set_get_user_data"] = function() {
  5484. return Module["asm"]["af"].apply(null, arguments)
  5485. };
  5486. var _hb_set_has = Module["_hb_set_has"] = function() {
  5487. return Module["asm"]["bf"].apply(null, arguments)
  5488. };
  5489. var _hb_set_intersect = Module["_hb_set_intersect"] = function() {
  5490. return Module["asm"]["cf"].apply(null, arguments)
  5491. };
  5492. var _hb_set_invert = Module["_hb_set_invert"] = function() {
  5493. return Module["asm"]["df"].apply(null, arguments)
  5494. };
  5495. var _hb_set_is_empty = Module["_hb_set_is_empty"] = function() {
  5496. return Module["asm"]["ef"].apply(null, arguments)
  5497. };
  5498. var _hb_set_is_equal = Module["_hb_set_is_equal"] = function() {
  5499. return Module["asm"]["ff"].apply(null, arguments)
  5500. };
  5501. var _hb_set_is_subset = Module["_hb_set_is_subset"] = function() {
  5502. return Module["asm"]["gf"].apply(null, arguments)
  5503. };
  5504. var _hb_set_next = Module["_hb_set_next"] = function() {
  5505. return Module["asm"]["hf"].apply(null, arguments)
  5506. };
  5507. var _hb_set_next_range = Module["_hb_set_next_range"] = function() {
  5508. return Module["asm"]["jf"].apply(null, arguments)
  5509. };
  5510. var _hb_set_previous = Module["_hb_set_previous"] = function() {
  5511. return Module["asm"]["kf"].apply(null, arguments)
  5512. };
  5513. var _hb_set_previous_range = Module["_hb_set_previous_range"] = function() {
  5514. return Module["asm"]["lf"].apply(null, arguments)
  5515. };
  5516. var _hb_set_reference = Module["_hb_set_reference"] = function() {
  5517. return Module["asm"]["mf"].apply(null, arguments)
  5518. };
  5519. var _hb_set_set = Module["_hb_set_set"] = function() {
  5520. return Module["asm"]["nf"].apply(null, arguments)
  5521. };
  5522. var _hb_set_set_user_data = Module["_hb_set_set_user_data"] = function() {
  5523. return Module["asm"]["of"].apply(null, arguments)
  5524. };
  5525. var _hb_set_subtract = Module["_hb_set_subtract"] = function() {
  5526. return Module["asm"]["pf"].apply(null, arguments)
  5527. };
  5528. var _hb_set_symmetric_difference = Module["_hb_set_symmetric_difference"] = function() {
  5529. return Module["asm"]["qf"].apply(null, arguments)
  5530. };
  5531. var _hb_set_union = Module["_hb_set_union"] = function() {
  5532. return Module["asm"]["rf"].apply(null, arguments)
  5533. };
  5534. var _hb_shape = Module["_hb_shape"] = function() {
  5535. return Module["asm"]["sf"].apply(null, arguments)
  5536. };
  5537. var _hb_shape_full = Module["_hb_shape_full"] = function() {
  5538. return Module["asm"]["tf"].apply(null, arguments)
  5539. };
  5540. var _hb_shape_list_shapers = Module["_hb_shape_list_shapers"] = function() {
  5541. return Module["asm"]["uf"].apply(null, arguments)
  5542. };
  5543. var _hb_shape_plan_create = Module["_hb_shape_plan_create"] = function() {
  5544. return Module["asm"]["vf"].apply(null, arguments)
  5545. };
  5546. var _hb_shape_plan_create2 = Module["_hb_shape_plan_create2"] = function() {
  5547. return Module["asm"]["wf"].apply(null, arguments)
  5548. };
  5549. var _hb_shape_plan_create_cached = Module["_hb_shape_plan_create_cached"] = function() {
  5550. return Module["asm"]["xf"].apply(null, arguments)
  5551. };
  5552. var _hb_shape_plan_create_cached2 = Module["_hb_shape_plan_create_cached2"] = function() {
  5553. return Module["asm"]["yf"].apply(null, arguments)
  5554. };
  5555. var _hb_shape_plan_destroy = Module["_hb_shape_plan_destroy"] = function() {
  5556. return Module["asm"]["zf"].apply(null, arguments)
  5557. };
  5558. var _hb_shape_plan_execute = Module["_hb_shape_plan_execute"] = function() {
  5559. return Module["asm"]["Af"].apply(null, arguments)
  5560. };
  5561. var _hb_shape_plan_get_empty = Module["_hb_shape_plan_get_empty"] = function() {
  5562. return Module["asm"]["Bf"].apply(null, arguments)
  5563. };
  5564. var _hb_shape_plan_get_shaper = Module["_hb_shape_plan_get_shaper"] = function() {
  5565. return Module["asm"]["Cf"].apply(null, arguments)
  5566. };
  5567. var _hb_shape_plan_get_user_data = Module["_hb_shape_plan_get_user_data"] = function() {
  5568. return Module["asm"]["Df"].apply(null, arguments)
  5569. };
  5570. var _hb_shape_plan_reference = Module["_hb_shape_plan_reference"] = function() {
  5571. return Module["asm"]["Ef"].apply(null, arguments)
  5572. };
  5573. var _hb_shape_plan_set_user_data = Module["_hb_shape_plan_set_user_data"] = function() {
  5574. return Module["asm"]["Ff"].apply(null, arguments)
  5575. };
  5576. var _hb_tag_from_string = Module["_hb_tag_from_string"] = function() {
  5577. return Module["asm"]["Gf"].apply(null, arguments)
  5578. };
  5579. var _hb_tag_to_string = Module["_hb_tag_to_string"] = function() {
  5580. return Module["asm"]["Hf"].apply(null, arguments)
  5581. };
  5582. var _hb_unicode_combining_class = Module["_hb_unicode_combining_class"] = function() {
  5583. return Module["asm"]["If"].apply(null, arguments)
  5584. };
  5585. var _hb_unicode_compose = Module["_hb_unicode_compose"] = function() {
  5586. return Module["asm"]["Jf"].apply(null, arguments)
  5587. };
  5588. var _hb_unicode_decompose = Module["_hb_unicode_decompose"] = function() {
  5589. return Module["asm"]["Kf"].apply(null, arguments)
  5590. };
  5591. var _hb_unicode_decompose_compatibility = Module["_hb_unicode_decompose_compatibility"] = function() {
  5592. return Module["asm"]["Lf"].apply(null, arguments)
  5593. };
  5594. var _hb_unicode_eastasian_width = Module["_hb_unicode_eastasian_width"] = function() {
  5595. return Module["asm"]["Mf"].apply(null, arguments)
  5596. };
  5597. var _hb_unicode_funcs_create = Module["_hb_unicode_funcs_create"] = function() {
  5598. return Module["asm"]["Nf"].apply(null, arguments)
  5599. };
  5600. var _hb_unicode_funcs_destroy = Module["_hb_unicode_funcs_destroy"] = function() {
  5601. return Module["asm"]["Of"].apply(null, arguments)
  5602. };
  5603. var _hb_unicode_funcs_get_default = Module["_hb_unicode_funcs_get_default"] = function() {
  5604. return Module["asm"]["Pf"].apply(null, arguments)
  5605. };
  5606. var _hb_unicode_funcs_get_empty = Module["_hb_unicode_funcs_get_empty"] = function() {
  5607. return Module["asm"]["Qf"].apply(null, arguments)
  5608. };
  5609. var _hb_unicode_funcs_get_parent = Module["_hb_unicode_funcs_get_parent"] = function() {
  5610. return Module["asm"]["Rf"].apply(null, arguments)
  5611. };
  5612. var _hb_unicode_funcs_get_user_data = Module["_hb_unicode_funcs_get_user_data"] = function() {
  5613. return Module["asm"]["Sf"].apply(null, arguments)
  5614. };
  5615. var _hb_unicode_funcs_is_immutable = Module["_hb_unicode_funcs_is_immutable"] = function() {
  5616. return Module["asm"]["Tf"].apply(null, arguments)
  5617. };
  5618. var _hb_unicode_funcs_make_immutable = Module["_hb_unicode_funcs_make_immutable"] = function() {
  5619. return Module["asm"]["Uf"].apply(null, arguments)
  5620. };
  5621. var _hb_unicode_funcs_reference = Module["_hb_unicode_funcs_reference"] = function() {
  5622. return Module["asm"]["Vf"].apply(null, arguments)
  5623. };
  5624. var _hb_unicode_funcs_set_combining_class_func = Module["_hb_unicode_funcs_set_combining_class_func"] = function() {
  5625. return Module["asm"]["Wf"].apply(null, arguments)
  5626. };
  5627. var _hb_unicode_funcs_set_compose_func = Module["_hb_unicode_funcs_set_compose_func"] = function() {
  5628. return Module["asm"]["Xf"].apply(null, arguments)
  5629. };
  5630. var _hb_unicode_funcs_set_decompose_compatibility_func = Module["_hb_unicode_funcs_set_decompose_compatibility_func"] = function() {
  5631. return Module["asm"]["Yf"].apply(null, arguments)
  5632. };
  5633. var _hb_unicode_funcs_set_decompose_func = Module["_hb_unicode_funcs_set_decompose_func"] = function() {
  5634. return Module["asm"]["Zf"].apply(null, arguments)
  5635. };
  5636. var _hb_unicode_funcs_set_eastasian_width_func = Module["_hb_unicode_funcs_set_eastasian_width_func"] = function() {
  5637. return Module["asm"]["_f"].apply(null, arguments)
  5638. };
  5639. var _hb_unicode_funcs_set_general_category_func = Module["_hb_unicode_funcs_set_general_category_func"] = function() {
  5640. return Module["asm"]["$f"].apply(null, arguments)
  5641. };
  5642. var _hb_unicode_funcs_set_mirroring_func = Module["_hb_unicode_funcs_set_mirroring_func"] = function() {
  5643. return Module["asm"]["ag"].apply(null, arguments)
  5644. };
  5645. var _hb_unicode_funcs_set_script_func = Module["_hb_unicode_funcs_set_script_func"] = function() {
  5646. return Module["asm"]["bg"].apply(null, arguments)
  5647. };
  5648. var _hb_unicode_funcs_set_user_data = Module["_hb_unicode_funcs_set_user_data"] = function() {
  5649. return Module["asm"]["cg"].apply(null, arguments)
  5650. };
  5651. var _hb_unicode_general_category = Module["_hb_unicode_general_category"] = function() {
  5652. return Module["asm"]["dg"].apply(null, arguments)
  5653. };
  5654. var _hb_unicode_mirroring = Module["_hb_unicode_mirroring"] = function() {
  5655. return Module["asm"]["eg"].apply(null, arguments)
  5656. };
  5657. var _hb_unicode_script = Module["_hb_unicode_script"] = function() {
  5658. return Module["asm"]["fg"].apply(null, arguments)
  5659. };
  5660. var _hb_variation_from_string = Module["_hb_variation_from_string"] = function() {
  5661. return Module["asm"]["gg"].apply(null, arguments)
  5662. };
  5663. var _hb_variation_to_string = Module["_hb_variation_to_string"] = function() {
  5664. return Module["asm"]["hg"].apply(null, arguments)
  5665. };
  5666. var _hb_version = Module["_hb_version"] = function() {
  5667. return Module["asm"]["ig"].apply(null, arguments)
  5668. };
  5669. var _hb_version_atleast = Module["_hb_version_atleast"] = function() {
  5670. return Module["asm"]["jg"].apply(null, arguments)
  5671. };
  5672. var _hb_version_string = Module["_hb_version_string"] = function() {
  5673. return Module["asm"]["kg"].apply(null, arguments)
  5674. };
  5675. var _malloc = Module["_malloc"] = function() {
  5676. return Module["asm"]["lg"].apply(null, arguments)
  5677. };
  5678. var _memalign = Module["_memalign"] = function() {
  5679. return Module["asm"]["mg"].apply(null, arguments)
  5680. };
  5681. var _memset = Module["_memset"] = function() {
  5682. return Module["asm"]["ng"].apply(null, arguments)
  5683. };
  5684. var stackAlloc = Module["stackAlloc"] = function() {
  5685. return Module["asm"]["pg"].apply(null, arguments)
  5686. };
  5687. var dynCall_vi = Module["dynCall_vi"] = function() {
  5688. return Module["asm"]["og"].apply(null, arguments)
  5689. };
  5690. Module["asm"] = asm;
  5691. Module["then"] = function(func) {
  5692. if (Module["calledRun"]) {
  5693. func(Module)
  5694. } else {
  5695. var old = Module["onRuntimeInitialized"];
  5696. Module["onRuntimeInitialized"] = function() {
  5697. if (old) old();
  5698. func(Module)
  5699. }
  5700. }
  5701. return Module
  5702. };
  5703.  
  5704. function ExitStatus(status) {
  5705. this.name = "ExitStatus";
  5706. this.message = "Program terminated with exit(" + status + ")";
  5707. this.status = status
  5708. }
  5709. ExitStatus.prototype = new Error;
  5710. ExitStatus.prototype.constructor = ExitStatus;
  5711. dependenciesFulfilled = function runCaller() {
  5712. if (!Module["calledRun"]) run();
  5713. if (!Module["calledRun"]) dependenciesFulfilled = runCaller
  5714. };
  5715.  
  5716. function run(args) {
  5717. args = args || Module["arguments"];
  5718. if (runDependencies > 0) {
  5719. return
  5720. }
  5721. preRun();
  5722. if (runDependencies > 0) return;
  5723. if (Module["calledRun"]) return;
  5724.  
  5725. function doRun() {
  5726. if (Module["calledRun"]) return;
  5727. Module["calledRun"] = true;
  5728. if (ABORT) return;
  5729. ensureInitRuntime();
  5730. preMain();
  5731. if (Module["onRuntimeInitialized"]) Module["onRuntimeInitialized"]();
  5732. postRun()
  5733. }
  5734. if (Module["setStatus"]) {
  5735. Module["setStatus"]("Running...");
  5736. setTimeout(function() {
  5737. setTimeout(function() {
  5738. Module["setStatus"]("")
  5739. }, 1);
  5740. doRun()
  5741. }, 1)
  5742. } else {
  5743. doRun()
  5744. }
  5745. }
  5746. Module["run"] = run;
  5747.  
  5748. function abort(what) {
  5749. if (Module["onAbort"]) {
  5750. Module["onAbort"](what)
  5751. }
  5752. if (what !== undefined) {
  5753. out(what);
  5754. err(what);
  5755. what = JSON.stringify(what)
  5756. } else {
  5757. what = ""
  5758. }
  5759. ABORT = true;
  5760. EXITSTATUS = 1;
  5761. throw "abort(" + what + "). Build with -s ASSERTIONS=1 for more info."
  5762. }
  5763. Module["abort"] = abort;
  5764. if (Module["preInit"]) {
  5765. if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
  5766. while (Module["preInit"].length > 0) {
  5767. Module["preInit"].pop()()
  5768. }
  5769. }
  5770. Module["noExitRuntime"] = true;
  5771. run();
  5772.  
  5773.  
  5774. return Module
  5775. }
  5776. );
  5777. })();
  5778. if (typeof exports === 'object' && typeof module === 'object')
  5779. module.exports = Module;
  5780. else if (typeof define === 'function' && define['amd'])
  5781. define([], function() {
  5782. return Module;
  5783. });
  5784. else if (typeof exports === 'object')
  5785. exports["Module"] = Module;
Add Comment
Please, Sign In to add comment