@xeokit/xeokit-sdk 2.6.77-slim-rc4 → 2.6.77-slim-rc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +4188 -29
- package/dist/xeokit-sdk.es.js +4188 -30
- package/dist/xeokit-sdk.es5.js +194 -157
- package/dist/xeokit-sdk.min.cjs.js +7 -7
- package/dist/xeokit-sdk.min.es.js +6 -6
- package/dist/xeokit-sdk.min.es5.js +6 -6
- package/package.json +4 -2
- package/src/plugins/CxConverterIFCLoaderPlugin/CxConverterIFCLoaderPlugin.js +81 -81
- package/src/plugins/CxConverterIFCLoaderPlugin/index.js +1 -1
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* xeokit-sdk v2.6.77-slim-
|
|
2
|
+
* xeokit-sdk v2.6.77-slim-rc5
|
|
3
3
|
* Commit: c82f011311ec1e79c79ebb96850b7eb2e0c8d17f
|
|
4
|
-
* Built: 2025-05-
|
|
4
|
+
* Built: 2025-05-27T12:38:00.541Z
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
'use strict';
|
|
@@ -113193,13 +113193,13 @@ function getTableHeader(table) {
|
|
|
113193
113193
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
113194
113194
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
113195
113195
|
const VERSION$6 = "4.3.2" ;
|
|
113196
|
-
const version = VERSION$6[0] >= '0' && VERSION$6[0] <= '9' ? `v${VERSION$6}` : '';
|
|
113196
|
+
const version$1 = VERSION$6[0] >= '0' && VERSION$6[0] <= '9' ? `v${VERSION$6}` : '';
|
|
113197
113197
|
// Make sure we set the global variable
|
|
113198
113198
|
function createLog() {
|
|
113199
113199
|
const log = new Log({ id: 'loaders.gl' });
|
|
113200
113200
|
globalThis.loaders = globalThis.loaders || {};
|
|
113201
113201
|
globalThis.loaders.log = log;
|
|
113202
|
-
globalThis.loaders.version = version;
|
|
113202
|
+
globalThis.loaders.version = version$1;
|
|
113203
113203
|
globalThis.probe = globalThis.probe || {};
|
|
113204
113204
|
globalThis.probe.loaders = log;
|
|
113205
113205
|
return log;
|
|
@@ -114752,7 +114752,7 @@ function isDataURL(url) {
|
|
|
114752
114752
|
* - Supports fetching from Node.js local file system paths
|
|
114753
114753
|
* - Respects pathPrefix and file aliases
|
|
114754
114754
|
*/
|
|
114755
|
-
async function fetchFile(urlOrData, fetchOptions) {
|
|
114755
|
+
async function fetchFile$1(urlOrData, fetchOptions) {
|
|
114756
114756
|
if (typeof urlOrData === 'string') {
|
|
114757
114757
|
const url = resolvePath(urlOrData);
|
|
114758
114758
|
// Support fetching from local file system
|
|
@@ -115582,14 +115582,14 @@ function getFetchFunction(options, context) {
|
|
|
115582
115582
|
}
|
|
115583
115583
|
// options.fetch can be an options object
|
|
115584
115584
|
if (isObject(loaderOptions.fetch)) {
|
|
115585
|
-
return (url) => fetchFile(url, loaderOptions.fetch);
|
|
115585
|
+
return (url) => fetchFile$1(url, loaderOptions.fetch);
|
|
115586
115586
|
}
|
|
115587
115587
|
// else refer to context (from parent loader) if available
|
|
115588
115588
|
if (context?.fetch) {
|
|
115589
115589
|
return context?.fetch;
|
|
115590
115590
|
}
|
|
115591
115591
|
// else return the default fetch function
|
|
115592
|
-
return fetchFile;
|
|
115592
|
+
return fetchFile$1;
|
|
115593
115593
|
}
|
|
115594
115594
|
|
|
115595
115595
|
// loaders.gl
|
|
@@ -117506,7 +117506,7 @@ function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets,
|
|
|
117506
117506
|
}
|
|
117507
117507
|
|
|
117508
117508
|
const EXT_MESH_FEATURES_NAME = 'EXT_mesh_features';
|
|
117509
|
-
const name$
|
|
117509
|
+
const name$b = EXT_MESH_FEATURES_NAME;
|
|
117510
117510
|
async function decode$9(gltfData, options) {
|
|
117511
117511
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
117512
117512
|
decodeExtMeshFeatures(scenegraph, options);
|
|
@@ -117681,14 +117681,14 @@ function createAccessorKey(attributes) {
|
|
|
117681
117681
|
|
|
117682
117682
|
var EXT_mesh_features = /*#__PURE__*/Object.freeze({
|
|
117683
117683
|
__proto__: null,
|
|
117684
|
-
name: name$
|
|
117684
|
+
name: name$b,
|
|
117685
117685
|
decode: decode$9,
|
|
117686
117686
|
encode: encode$5,
|
|
117687
117687
|
createExtMeshFeatures: createExtMeshFeatures
|
|
117688
117688
|
});
|
|
117689
117689
|
|
|
117690
117690
|
const EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';
|
|
117691
|
-
const name$
|
|
117691
|
+
const name$a = EXT_STRUCTURAL_METADATA_NAME;
|
|
117692
117692
|
async function decode$8(gltfData, options) {
|
|
117693
117693
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
117694
117694
|
decodeExtStructuralMetadata(scenegraph, options);
|
|
@@ -118342,7 +118342,7 @@ function createBufferView(typedArray, scenegraph) {
|
|
|
118342
118342
|
|
|
118343
118343
|
var EXT_structural_metadata = /*#__PURE__*/Object.freeze({
|
|
118344
118344
|
__proto__: null,
|
|
118345
|
-
name: name$
|
|
118345
|
+
name: name$a,
|
|
118346
118346
|
decode: decode$8,
|
|
118347
118347
|
encode: encode$4,
|
|
118348
118348
|
createExtStructuralMetadata: createExtStructuralMetadata
|
|
@@ -118350,7 +118350,7 @@ var EXT_structural_metadata = /*#__PURE__*/Object.freeze({
|
|
|
118350
118350
|
|
|
118351
118351
|
/** Extension name */
|
|
118352
118352
|
const EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';
|
|
118353
|
-
const name$
|
|
118353
|
+
const name$9 = EXT_FEATURE_METADATA_NAME;
|
|
118354
118354
|
async function decode$7(gltfData, options) {
|
|
118355
118355
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
118356
118356
|
decodeExtFeatureMetadata(scenegraph, options);
|
|
@@ -118648,7 +118648,7 @@ function processPrimitiveTextures(scenegraph, attributeName, featureTexturePrope
|
|
|
118648
118648
|
|
|
118649
118649
|
var EXT_feature_metadata = /*#__PURE__*/Object.freeze({
|
|
118650
118650
|
__proto__: null,
|
|
118651
|
-
name: name$
|
|
118651
|
+
name: name$9,
|
|
118652
118652
|
decode: decode$7
|
|
118653
118653
|
});
|
|
118654
118654
|
|
|
@@ -119466,7 +119466,7 @@ function decode$6(instance, fun, target, count, size, source, filter) {
|
|
|
119466
119466
|
|
|
119467
119467
|
/** Extension name */
|
|
119468
119468
|
const EXT_MESHOPT_COMPRESSION = 'EXT_meshopt_compression';
|
|
119469
|
-
const name$
|
|
119469
|
+
const name$8 = EXT_MESHOPT_COMPRESSION;
|
|
119470
119470
|
async function decode$5(gltfData, options) {
|
|
119471
119471
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
119472
119472
|
if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {
|
|
@@ -119496,14 +119496,14 @@ async function decodeMeshoptBufferView(scenegraph, bufferView) {
|
|
|
119496
119496
|
|
|
119497
119497
|
var EXT_meshopt_compression = /*#__PURE__*/Object.freeze({
|
|
119498
119498
|
__proto__: null,
|
|
119499
|
-
name: name$
|
|
119499
|
+
name: name$8,
|
|
119500
119500
|
decode: decode$5
|
|
119501
119501
|
});
|
|
119502
119502
|
|
|
119503
119503
|
// GLTF EXTENSION: EXT_TEXTURE_WEBP
|
|
119504
119504
|
const EXT_TEXTURE_WEBP = 'EXT_texture_webp';
|
|
119505
119505
|
/** Extension name */
|
|
119506
|
-
const name$
|
|
119506
|
+
const name$7 = EXT_TEXTURE_WEBP;
|
|
119507
119507
|
/**
|
|
119508
119508
|
* Replaces a texture source reference with the extension texture
|
|
119509
119509
|
* Done in preprocess() to prevent load of default image
|
|
@@ -119531,14 +119531,14 @@ function preprocess$3(gltfData, options) {
|
|
|
119531
119531
|
|
|
119532
119532
|
var EXT_texture_webp = /*#__PURE__*/Object.freeze({
|
|
119533
119533
|
__proto__: null,
|
|
119534
|
-
name: name$
|
|
119534
|
+
name: name$7,
|
|
119535
119535
|
preprocess: preprocess$3
|
|
119536
119536
|
});
|
|
119537
119537
|
|
|
119538
119538
|
// GLTF EXTENSION: KHR_texture_basisu
|
|
119539
119539
|
const KHR_TEXTURE_BASISU = 'KHR_texture_basisu';
|
|
119540
119540
|
/** Extension name */
|
|
119541
|
-
const name$
|
|
119541
|
+
const name$6 = KHR_TEXTURE_BASISU;
|
|
119542
119542
|
/**
|
|
119543
119543
|
* Replaces a texture source reference with the extension texture
|
|
119544
119544
|
* Done in preprocess() to prevent load of default image
|
|
@@ -119560,7 +119560,7 @@ function preprocess$2(gltfData, options) {
|
|
|
119560
119560
|
|
|
119561
119561
|
var KHR_texture_basisu = /*#__PURE__*/Object.freeze({
|
|
119562
119562
|
__proto__: null,
|
|
119563
|
-
name: name$
|
|
119563
|
+
name: name$6,
|
|
119564
119564
|
preprocess: preprocess$2
|
|
119565
119565
|
});
|
|
119566
119566
|
|
|
@@ -120286,7 +120286,7 @@ function toTypedArray(array, ArrayType, convertTypedArrays = false) {
|
|
|
120286
120286
|
// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
120287
120287
|
const KHR_DRACO_MESH_COMPRESSION = 'KHR_draco_mesh_compression';
|
|
120288
120288
|
/** Extension name */
|
|
120289
|
-
const name$
|
|
120289
|
+
const name$5 = KHR_DRACO_MESH_COMPRESSION;
|
|
120290
120290
|
function preprocess$1(gltfData, options, context) {
|
|
120291
120291
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
120292
120292
|
for (const primitive of makeMeshPrimitiveIterator(scenegraph)) {
|
|
@@ -120409,7 +120409,7 @@ function* makeMeshPrimitiveIterator(scenegraph) {
|
|
|
120409
120409
|
|
|
120410
120410
|
var KHR_draco_mesh_compression = /*#__PURE__*/Object.freeze({
|
|
120411
120411
|
__proto__: null,
|
|
120412
|
-
name: name$
|
|
120412
|
+
name: name$5,
|
|
120413
120413
|
preprocess: preprocess$1,
|
|
120414
120414
|
decode: decode$4,
|
|
120415
120415
|
encode: encode$3
|
|
@@ -121896,7 +121896,7 @@ function getIdentityMatrix() {
|
|
|
121896
121896
|
*/
|
|
121897
121897
|
/** Extension name */
|
|
121898
121898
|
const KHR_TEXTURE_TRANSFORM = 'KHR_texture_transform';
|
|
121899
|
-
const name$
|
|
121899
|
+
const name$4 = KHR_TEXTURE_TRANSFORM;
|
|
121900
121900
|
const scratchVector = new Vector3();
|
|
121901
121901
|
const scratchRotationMatrix = new Matrix3();
|
|
121902
121902
|
const scratchScaleMatrix = new Matrix3();
|
|
@@ -122105,13 +122105,13 @@ function makeTransformationMatrix(extensionData) {
|
|
|
122105
122105
|
|
|
122106
122106
|
var KHR_texture_transform = /*#__PURE__*/Object.freeze({
|
|
122107
122107
|
__proto__: null,
|
|
122108
|
-
name: name$
|
|
122108
|
+
name: name$4,
|
|
122109
122109
|
decode: decode$3
|
|
122110
122110
|
});
|
|
122111
122111
|
|
|
122112
122112
|
// GLTF EXTENSION: KHR_lights_punctual
|
|
122113
122113
|
const KHR_LIGHTS_PUNCTUAL = 'KHR_lights_punctual';
|
|
122114
|
-
const name$
|
|
122114
|
+
const name$3 = KHR_LIGHTS_PUNCTUAL;
|
|
122115
122115
|
async function decode$2(gltfData) {
|
|
122116
122116
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
122117
122117
|
const { json } = gltfScenegraph;
|
|
@@ -122163,14 +122163,14 @@ async function encode$2(gltfData) {
|
|
|
122163
122163
|
|
|
122164
122164
|
var KHR_lights_punctual = /*#__PURE__*/Object.freeze({
|
|
122165
122165
|
__proto__: null,
|
|
122166
|
-
name: name$
|
|
122166
|
+
name: name$3,
|
|
122167
122167
|
decode: decode$2,
|
|
122168
122168
|
encode: encode$2
|
|
122169
122169
|
});
|
|
122170
122170
|
|
|
122171
122171
|
// GLTF EXTENSION: KHR_materials_unlit
|
|
122172
122172
|
const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';
|
|
122173
|
-
const name$
|
|
122173
|
+
const name$2 = KHR_MATERIALS_UNLIT;
|
|
122174
122174
|
async function decode$1(gltfData) {
|
|
122175
122175
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
122176
122176
|
const { json } = gltfScenegraph;
|
|
@@ -122208,14 +122208,14 @@ function encode$1(gltfData) {
|
|
|
122208
122208
|
|
|
122209
122209
|
var KHR_materials_unlit = /*#__PURE__*/Object.freeze({
|
|
122210
122210
|
__proto__: null,
|
|
122211
|
-
name: name$
|
|
122211
|
+
name: name$2,
|
|
122212
122212
|
decode: decode$1,
|
|
122213
122213
|
encode: encode$1
|
|
122214
122214
|
});
|
|
122215
122215
|
|
|
122216
122216
|
// GLTF EXTENSION: KHR_techniques_webgl
|
|
122217
122217
|
const KHR_TECHNIQUES_WEBGL = 'KHR_techniques_webgl';
|
|
122218
|
-
const name = KHR_TECHNIQUES_WEBGL;
|
|
122218
|
+
const name$1 = KHR_TECHNIQUES_WEBGL;
|
|
122219
122219
|
async function decode(gltfData) {
|
|
122220
122220
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
122221
122221
|
const { json } = gltfScenegraph;
|
|
@@ -122288,7 +122288,7 @@ function resolveValues(technique, gltfScenegraph) {
|
|
|
122288
122288
|
|
|
122289
122289
|
var KHR_techniques_webgl = /*#__PURE__*/Object.freeze({
|
|
122290
122290
|
__proto__: null,
|
|
122291
|
-
name: name,
|
|
122291
|
+
name: name$1,
|
|
122292
122292
|
decode: decode,
|
|
122293
122293
|
encode: encode
|
|
122294
122294
|
});
|
|
@@ -142880,6 +142880,4164 @@ class WebIFCLoaderPlugin extends Plugin {
|
|
|
142880
142880
|
}
|
|
142881
142881
|
}
|
|
142882
142882
|
|
|
142883
|
+
const name = "@creooxag/cx-converter";
|
|
142884
|
+
const version = "0.0.12-alpha";
|
|
142885
|
+
const description = "";
|
|
142886
|
+
const exports$1 = {
|
|
142887
|
+
".": {
|
|
142888
|
+
types: "./dist/index.d.ts",
|
|
142889
|
+
"import": "./dist/index.mjs",
|
|
142890
|
+
require: "./dist/index.cjs"
|
|
142891
|
+
}
|
|
142892
|
+
};
|
|
142893
|
+
const main = "./dist/index.mjs";
|
|
142894
|
+
const module$1 = "./dist/index.mjs";
|
|
142895
|
+
const types = "./dist/index.d.ts";
|
|
142896
|
+
const typesVersions = {
|
|
142897
|
+
"*": {
|
|
142898
|
+
"*": [
|
|
142899
|
+
"./dist/*",
|
|
142900
|
+
"./dist/index.d.ts"
|
|
142901
|
+
]
|
|
142902
|
+
}
|
|
142903
|
+
};
|
|
142904
|
+
const files = [
|
|
142905
|
+
"dist/"
|
|
142906
|
+
];
|
|
142907
|
+
const scripts = {
|
|
142908
|
+
"clean-dist": "rm -rf ./dist",
|
|
142909
|
+
"clean-cmake": "rm -rf ./cmake-build",
|
|
142910
|
+
"build-wasm-release": "emcmake cmake -S . -B ../cmake-build -DCMAKE_BUILD_TYPE=Release && cmake --build ../cmake-build",
|
|
142911
|
+
"publish-npm": "npm publish --access public",
|
|
142912
|
+
build: "unbuild",
|
|
142913
|
+
dev: "unbuild --stub",
|
|
142914
|
+
lint: "eslint .",
|
|
142915
|
+
start: "esno examples/node/nodeExport.ts",
|
|
142916
|
+
"example-html": "http-server -c-1 -p8237 --cors"
|
|
142917
|
+
};
|
|
142918
|
+
const keywords = [
|
|
142919
|
+
];
|
|
142920
|
+
const devDependencies = {
|
|
142921
|
+
"@types/node": "^22.10.2",
|
|
142922
|
+
esno: "^4.8.0",
|
|
142923
|
+
"fast-glob": "^3.3.2",
|
|
142924
|
+
globals: "^15.8.0",
|
|
142925
|
+
"http-server": "^14.1.1",
|
|
142926
|
+
prettier: "^3.3.3",
|
|
142927
|
+
"prettier-eslint": "^16.3.0",
|
|
142928
|
+
typescript: "^5.7.2",
|
|
142929
|
+
unbuild: "^2.0.0",
|
|
142930
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
142931
|
+
"@eslint/js": "^9.20.0",
|
|
142932
|
+
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
|
142933
|
+
"@typescript-eslint/parser": "^8.24.0",
|
|
142934
|
+
eslint: "^9.20.1",
|
|
142935
|
+
"eslint-config-prettier": "^10.0.1",
|
|
142936
|
+
"eslint-plugin-import": "^2.31.0",
|
|
142937
|
+
"eslint-plugin-prettier": "^5.2.3"
|
|
142938
|
+
};
|
|
142939
|
+
const packageJSON = {
|
|
142940
|
+
name: name,
|
|
142941
|
+
version: version,
|
|
142942
|
+
description: description,
|
|
142943
|
+
exports: exports$1,
|
|
142944
|
+
main: main,
|
|
142945
|
+
module: module$1,
|
|
142946
|
+
types: types,
|
|
142947
|
+
typesVersions: typesVersions,
|
|
142948
|
+
files: files,
|
|
142949
|
+
scripts: scripts,
|
|
142950
|
+
keywords: keywords,
|
|
142951
|
+
devDependencies: devDependencies
|
|
142952
|
+
};
|
|
142953
|
+
|
|
142954
|
+
var __defProp$2 = Object.defineProperty;
|
|
142955
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
142956
|
+
var __publicField$2 = (obj, key, value) => {
|
|
142957
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
142958
|
+
return value;
|
|
142959
|
+
};
|
|
142960
|
+
var IfcDbWasm = (() => {
|
|
142961
|
+
var _scriptName = typeof document === "undefined" ? "" : document.currentScript.src;
|
|
142962
|
+
return async function(moduleArg = {}) {
|
|
142963
|
+
var moduleRtn;
|
|
142964
|
+
var Module = moduleArg;
|
|
142965
|
+
var readyPromiseResolve, readyPromiseReject;
|
|
142966
|
+
var readyPromise = new Promise((resolve, reject) => {
|
|
142967
|
+
readyPromiseResolve = resolve;
|
|
142968
|
+
readyPromiseReject = reject;
|
|
142969
|
+
});
|
|
142970
|
+
var moduleOverrides = Object.assign({}, Module);
|
|
142971
|
+
var arguments_ = [];
|
|
142972
|
+
var thisProgram = "./this.program";
|
|
142973
|
+
var quit_ = (status, toThrow) => {
|
|
142974
|
+
throw toThrow;
|
|
142975
|
+
};
|
|
142976
|
+
var scriptDirectory = "";
|
|
142977
|
+
function locateFile(path) {
|
|
142978
|
+
if (Module["locateFile"]) {
|
|
142979
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
142980
|
+
}
|
|
142981
|
+
return scriptDirectory + path;
|
|
142982
|
+
}
|
|
142983
|
+
var readAsync, readBinary;
|
|
142984
|
+
{
|
|
142985
|
+
if (typeof document != "undefined" && document.currentScript) {
|
|
142986
|
+
scriptDirectory = document.currentScript.src;
|
|
142987
|
+
}
|
|
142988
|
+
if (_scriptName) {
|
|
142989
|
+
scriptDirectory = _scriptName;
|
|
142990
|
+
}
|
|
142991
|
+
if (scriptDirectory.startsWith("blob:")) {
|
|
142992
|
+
scriptDirectory = "";
|
|
142993
|
+
} else {
|
|
142994
|
+
scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
|
|
142995
|
+
}
|
|
142996
|
+
{
|
|
142997
|
+
readAsync = async (url) => {
|
|
142998
|
+
var response = await fetch(url, { credentials: "same-origin" });
|
|
142999
|
+
if (response.ok) {
|
|
143000
|
+
return response.arrayBuffer();
|
|
143001
|
+
}
|
|
143002
|
+
throw new Error(response.status + " : " + response.url);
|
|
143003
|
+
};
|
|
143004
|
+
}
|
|
143005
|
+
}
|
|
143006
|
+
var out = Module["print"] || console.log.bind(console);
|
|
143007
|
+
var err = Module["printErr"] || console.error.bind(console);
|
|
143008
|
+
Object.assign(Module, moduleOverrides);
|
|
143009
|
+
moduleOverrides = null;
|
|
143010
|
+
if (Module["arguments"])
|
|
143011
|
+
arguments_ = Module["arguments"];
|
|
143012
|
+
if (Module["thisProgram"])
|
|
143013
|
+
thisProgram = Module["thisProgram"];
|
|
143014
|
+
var wasmBinary = Module["wasmBinary"];
|
|
143015
|
+
var wasmMemory;
|
|
143016
|
+
var ABORT = false;
|
|
143017
|
+
var EXITSTATUS;
|
|
143018
|
+
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAP64, HEAPU64, HEAPF64;
|
|
143019
|
+
function updateMemoryViews() {
|
|
143020
|
+
var b = wasmMemory.buffer;
|
|
143021
|
+
Module["HEAP8"] = HEAP8 = new Int8Array(b);
|
|
143022
|
+
Module["HEAP16"] = HEAP16 = new Int16Array(b);
|
|
143023
|
+
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
143024
|
+
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
|
|
143025
|
+
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
143026
|
+
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
143027
|
+
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
|
|
143028
|
+
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
|
|
143029
|
+
Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
|
|
143030
|
+
Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
|
|
143031
|
+
}
|
|
143032
|
+
function preRun() {
|
|
143033
|
+
if (Module["preRun"]) {
|
|
143034
|
+
if (typeof Module["preRun"] == "function")
|
|
143035
|
+
Module["preRun"] = [Module["preRun"]];
|
|
143036
|
+
while (Module["preRun"].length) {
|
|
143037
|
+
addOnPreRun(Module["preRun"].shift());
|
|
143038
|
+
}
|
|
143039
|
+
}
|
|
143040
|
+
callRuntimeCallbacks(onPreRuns);
|
|
143041
|
+
}
|
|
143042
|
+
function initRuntime() {
|
|
143043
|
+
if (!Module["noFSInit"] && !FS.initialized)
|
|
143044
|
+
FS.init();
|
|
143045
|
+
wasmExports["V"]();
|
|
143046
|
+
FS.ignorePermissions = false;
|
|
143047
|
+
}
|
|
143048
|
+
function postRun() {
|
|
143049
|
+
if (Module["postRun"]) {
|
|
143050
|
+
if (typeof Module["postRun"] == "function")
|
|
143051
|
+
Module["postRun"] = [Module["postRun"]];
|
|
143052
|
+
while (Module["postRun"].length) {
|
|
143053
|
+
addOnPostRun(Module["postRun"].shift());
|
|
143054
|
+
}
|
|
143055
|
+
}
|
|
143056
|
+
callRuntimeCallbacks(onPostRuns);
|
|
143057
|
+
}
|
|
143058
|
+
var runDependencies = 0;
|
|
143059
|
+
var dependenciesFulfilled = null;
|
|
143060
|
+
function addRunDependency(id) {
|
|
143061
|
+
runDependencies++;
|
|
143062
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
143063
|
+
}
|
|
143064
|
+
function removeRunDependency(id) {
|
|
143065
|
+
runDependencies--;
|
|
143066
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
143067
|
+
if (runDependencies == 0) {
|
|
143068
|
+
if (dependenciesFulfilled) {
|
|
143069
|
+
var callback = dependenciesFulfilled;
|
|
143070
|
+
dependenciesFulfilled = null;
|
|
143071
|
+
callback();
|
|
143072
|
+
}
|
|
143073
|
+
}
|
|
143074
|
+
}
|
|
143075
|
+
function abort(what) {
|
|
143076
|
+
Module["onAbort"]?.(what);
|
|
143077
|
+
what = "Aborted(" + what + ")";
|
|
143078
|
+
err(what);
|
|
143079
|
+
ABORT = true;
|
|
143080
|
+
what += ". Build with -sASSERTIONS for more info.";
|
|
143081
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
143082
|
+
readyPromiseReject(e);
|
|
143083
|
+
throw e;
|
|
143084
|
+
}
|
|
143085
|
+
var wasmBinaryFile;
|
|
143086
|
+
function findWasmBinary() {
|
|
143087
|
+
if (Module["locateFile"]) {
|
|
143088
|
+
return locateFile("ifcdb.wasm");
|
|
143089
|
+
}
|
|
143090
|
+
return new URL("ifcdb.wasm", typeof document === "undefined" ? "" : document.currentScript.src).href;
|
|
143091
|
+
}
|
|
143092
|
+
function getBinarySync(file) {
|
|
143093
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
143094
|
+
return new Uint8Array(wasmBinary);
|
|
143095
|
+
}
|
|
143096
|
+
throw "both async and sync fetching of the wasm failed";
|
|
143097
|
+
}
|
|
143098
|
+
async function getWasmBinary(binaryFile) {
|
|
143099
|
+
if (!wasmBinary) {
|
|
143100
|
+
try {
|
|
143101
|
+
var response = await readAsync(binaryFile);
|
|
143102
|
+
return new Uint8Array(response);
|
|
143103
|
+
} catch {
|
|
143104
|
+
}
|
|
143105
|
+
}
|
|
143106
|
+
return getBinarySync(binaryFile);
|
|
143107
|
+
}
|
|
143108
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
143109
|
+
try {
|
|
143110
|
+
var binary = await getWasmBinary(binaryFile);
|
|
143111
|
+
var instance = await WebAssembly.instantiate(binary, imports);
|
|
143112
|
+
return instance;
|
|
143113
|
+
} catch (reason) {
|
|
143114
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
143115
|
+
abort(reason);
|
|
143116
|
+
}
|
|
143117
|
+
}
|
|
143118
|
+
async function instantiateAsync(binary, binaryFile, imports) {
|
|
143119
|
+
if (!binary && typeof WebAssembly.instantiateStreaming == "function") {
|
|
143120
|
+
try {
|
|
143121
|
+
var response = fetch(binaryFile, { credentials: "same-origin" });
|
|
143122
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
143123
|
+
return instantiationResult;
|
|
143124
|
+
} catch (reason) {
|
|
143125
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
143126
|
+
err("falling back to ArrayBuffer instantiation");
|
|
143127
|
+
}
|
|
143128
|
+
}
|
|
143129
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
143130
|
+
}
|
|
143131
|
+
function getWasmImports() {
|
|
143132
|
+
return { a: wasmImports };
|
|
143133
|
+
}
|
|
143134
|
+
async function createWasm() {
|
|
143135
|
+
function receiveInstance(instance, module) {
|
|
143136
|
+
wasmExports = instance.exports;
|
|
143137
|
+
wasmExports = Asyncify.instrumentWasmExports(wasmExports);
|
|
143138
|
+
wasmMemory = wasmExports["U"];
|
|
143139
|
+
updateMemoryViews();
|
|
143140
|
+
wasmExports["X"];
|
|
143141
|
+
removeRunDependency();
|
|
143142
|
+
return wasmExports;
|
|
143143
|
+
}
|
|
143144
|
+
addRunDependency();
|
|
143145
|
+
function receiveInstantiationResult(result2) {
|
|
143146
|
+
return receiveInstance(result2["instance"]);
|
|
143147
|
+
}
|
|
143148
|
+
var info = getWasmImports();
|
|
143149
|
+
if (Module["instantiateWasm"]) {
|
|
143150
|
+
return new Promise((resolve, reject) => {
|
|
143151
|
+
Module["instantiateWasm"](info, (mod, inst) => {
|
|
143152
|
+
receiveInstance(mod);
|
|
143153
|
+
resolve(mod.exports);
|
|
143154
|
+
});
|
|
143155
|
+
});
|
|
143156
|
+
}
|
|
143157
|
+
wasmBinaryFile ?? (wasmBinaryFile = findWasmBinary());
|
|
143158
|
+
try {
|
|
143159
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
143160
|
+
var exports = receiveInstantiationResult(result);
|
|
143161
|
+
return exports;
|
|
143162
|
+
} catch (e) {
|
|
143163
|
+
readyPromiseReject(e);
|
|
143164
|
+
return Promise.reject(e);
|
|
143165
|
+
}
|
|
143166
|
+
}
|
|
143167
|
+
var ASM_CONSTS = { 191520: () => {
|
|
143168
|
+
console.error("progress callback is not set.");
|
|
143169
|
+
} };
|
|
143170
|
+
class ExitStatus {
|
|
143171
|
+
constructor(status) {
|
|
143172
|
+
__publicField$2(this, "name", "ExitStatus");
|
|
143173
|
+
this.message = `Program terminated with exit(${status})`;
|
|
143174
|
+
this.status = status;
|
|
143175
|
+
}
|
|
143176
|
+
}
|
|
143177
|
+
var callRuntimeCallbacks = (callbacks) => {
|
|
143178
|
+
while (callbacks.length > 0) {
|
|
143179
|
+
callbacks.shift()(Module);
|
|
143180
|
+
}
|
|
143181
|
+
};
|
|
143182
|
+
var onPostRuns = [];
|
|
143183
|
+
var addOnPostRun = (cb) => onPostRuns.unshift(cb);
|
|
143184
|
+
var onPreRuns = [];
|
|
143185
|
+
var addOnPreRun = (cb) => onPreRuns.unshift(cb);
|
|
143186
|
+
var noExitRuntime = Module["noExitRuntime"] || true;
|
|
143187
|
+
class ExceptionInfo {
|
|
143188
|
+
constructor(excPtr) {
|
|
143189
|
+
this.excPtr = excPtr;
|
|
143190
|
+
this.ptr = excPtr - 24;
|
|
143191
|
+
}
|
|
143192
|
+
set_type(type) {
|
|
143193
|
+
HEAPU32[this.ptr + 4 >> 2] = type;
|
|
143194
|
+
}
|
|
143195
|
+
get_type() {
|
|
143196
|
+
return HEAPU32[this.ptr + 4 >> 2];
|
|
143197
|
+
}
|
|
143198
|
+
set_destructor(destructor) {
|
|
143199
|
+
HEAPU32[this.ptr + 8 >> 2] = destructor;
|
|
143200
|
+
}
|
|
143201
|
+
get_destructor() {
|
|
143202
|
+
return HEAPU32[this.ptr + 8 >> 2];
|
|
143203
|
+
}
|
|
143204
|
+
set_caught(caught) {
|
|
143205
|
+
caught = caught ? 1 : 0;
|
|
143206
|
+
HEAP8[this.ptr + 12] = caught;
|
|
143207
|
+
}
|
|
143208
|
+
get_caught() {
|
|
143209
|
+
return HEAP8[this.ptr + 12] != 0;
|
|
143210
|
+
}
|
|
143211
|
+
set_rethrown(rethrown) {
|
|
143212
|
+
rethrown = rethrown ? 1 : 0;
|
|
143213
|
+
HEAP8[this.ptr + 13] = rethrown;
|
|
143214
|
+
}
|
|
143215
|
+
get_rethrown() {
|
|
143216
|
+
return HEAP8[this.ptr + 13] != 0;
|
|
143217
|
+
}
|
|
143218
|
+
init(type, destructor) {
|
|
143219
|
+
this.set_adjusted_ptr(0);
|
|
143220
|
+
this.set_type(type);
|
|
143221
|
+
this.set_destructor(destructor);
|
|
143222
|
+
}
|
|
143223
|
+
set_adjusted_ptr(adjustedPtr) {
|
|
143224
|
+
HEAPU32[this.ptr + 16 >> 2] = adjustedPtr;
|
|
143225
|
+
}
|
|
143226
|
+
get_adjusted_ptr() {
|
|
143227
|
+
return HEAPU32[this.ptr + 16 >> 2];
|
|
143228
|
+
}
|
|
143229
|
+
}
|
|
143230
|
+
var exceptionLast = 0;
|
|
143231
|
+
var ___cxa_throw = (ptr, type, destructor) => {
|
|
143232
|
+
var info = new ExceptionInfo(ptr);
|
|
143233
|
+
info.init(type, destructor);
|
|
143234
|
+
exceptionLast = ptr;
|
|
143235
|
+
throw exceptionLast;
|
|
143236
|
+
};
|
|
143237
|
+
var syscallGetVarargI = () => {
|
|
143238
|
+
var ret = HEAP32[+SYSCALLS.varargs >> 2];
|
|
143239
|
+
SYSCALLS.varargs += 4;
|
|
143240
|
+
return ret;
|
|
143241
|
+
};
|
|
143242
|
+
var syscallGetVarargP = syscallGetVarargI;
|
|
143243
|
+
var PATH = { isAbs: (path) => path.charAt(0) === "/", splitPath: (filename) => {
|
|
143244
|
+
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
|
143245
|
+
return splitPathRe.exec(filename).slice(1);
|
|
143246
|
+
}, normalizeArray: (parts, allowAboveRoot) => {
|
|
143247
|
+
var up = 0;
|
|
143248
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
|
143249
|
+
var last = parts[i];
|
|
143250
|
+
if (last === ".") {
|
|
143251
|
+
parts.splice(i, 1);
|
|
143252
|
+
} else if (last === "..") {
|
|
143253
|
+
parts.splice(i, 1);
|
|
143254
|
+
up++;
|
|
143255
|
+
} else if (up) {
|
|
143256
|
+
parts.splice(i, 1);
|
|
143257
|
+
up--;
|
|
143258
|
+
}
|
|
143259
|
+
}
|
|
143260
|
+
if (allowAboveRoot) {
|
|
143261
|
+
for (; up; up--) {
|
|
143262
|
+
parts.unshift("..");
|
|
143263
|
+
}
|
|
143264
|
+
}
|
|
143265
|
+
return parts;
|
|
143266
|
+
}, normalize: (path) => {
|
|
143267
|
+
var isAbsolute = PATH.isAbs(path), trailingSlash = path.slice(-1) === "/";
|
|
143268
|
+
path = PATH.normalizeArray(path.split("/").filter((p) => !!p), !isAbsolute).join("/");
|
|
143269
|
+
if (!path && !isAbsolute) {
|
|
143270
|
+
path = ".";
|
|
143271
|
+
}
|
|
143272
|
+
if (path && trailingSlash) {
|
|
143273
|
+
path += "/";
|
|
143274
|
+
}
|
|
143275
|
+
return (isAbsolute ? "/" : "") + path;
|
|
143276
|
+
}, dirname: (path) => {
|
|
143277
|
+
var result = PATH.splitPath(path), root = result[0], dir = result[1];
|
|
143278
|
+
if (!root && !dir) {
|
|
143279
|
+
return ".";
|
|
143280
|
+
}
|
|
143281
|
+
if (dir) {
|
|
143282
|
+
dir = dir.slice(0, -1);
|
|
143283
|
+
}
|
|
143284
|
+
return root + dir;
|
|
143285
|
+
}, basename: (path) => path && path.match(/([^\/]+|\/)\/*$/)[1], join: (...paths) => PATH.normalize(paths.join("/")), join2: (l, r) => PATH.normalize(l + "/" + r) };
|
|
143286
|
+
var initRandomFill = () => (view) => crypto.getRandomValues(view);
|
|
143287
|
+
var randomFill = (view) => {
|
|
143288
|
+
(randomFill = initRandomFill())(view);
|
|
143289
|
+
};
|
|
143290
|
+
var PATH_FS = { resolve: (...args) => {
|
|
143291
|
+
var resolvedPath = "", resolvedAbsolute = false;
|
|
143292
|
+
for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
143293
|
+
var path = i >= 0 ? args[i] : FS.cwd();
|
|
143294
|
+
if (typeof path != "string") {
|
|
143295
|
+
throw new TypeError("Arguments to path.resolve must be strings");
|
|
143296
|
+
} else if (!path) {
|
|
143297
|
+
return "";
|
|
143298
|
+
}
|
|
143299
|
+
resolvedPath = path + "/" + resolvedPath;
|
|
143300
|
+
resolvedAbsolute = PATH.isAbs(path);
|
|
143301
|
+
}
|
|
143302
|
+
resolvedPath = PATH.normalizeArray(resolvedPath.split("/").filter((p) => !!p), !resolvedAbsolute).join("/");
|
|
143303
|
+
return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
|
|
143304
|
+
}, relative: (from, to) => {
|
|
143305
|
+
from = PATH_FS.resolve(from).slice(1);
|
|
143306
|
+
to = PATH_FS.resolve(to).slice(1);
|
|
143307
|
+
function trim(arr) {
|
|
143308
|
+
var start = 0;
|
|
143309
|
+
for (; start < arr.length; start++) {
|
|
143310
|
+
if (arr[start] !== "")
|
|
143311
|
+
break;
|
|
143312
|
+
}
|
|
143313
|
+
var end = arr.length - 1;
|
|
143314
|
+
for (; end >= 0; end--) {
|
|
143315
|
+
if (arr[end] !== "")
|
|
143316
|
+
break;
|
|
143317
|
+
}
|
|
143318
|
+
if (start > end)
|
|
143319
|
+
return [];
|
|
143320
|
+
return arr.slice(start, end - start + 1);
|
|
143321
|
+
}
|
|
143322
|
+
var fromParts = trim(from.split("/"));
|
|
143323
|
+
var toParts = trim(to.split("/"));
|
|
143324
|
+
var length = Math.min(fromParts.length, toParts.length);
|
|
143325
|
+
var samePartsLength = length;
|
|
143326
|
+
for (var i = 0; i < length; i++) {
|
|
143327
|
+
if (fromParts[i] !== toParts[i]) {
|
|
143328
|
+
samePartsLength = i;
|
|
143329
|
+
break;
|
|
143330
|
+
}
|
|
143331
|
+
}
|
|
143332
|
+
var outputParts = [];
|
|
143333
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
|
143334
|
+
outputParts.push("..");
|
|
143335
|
+
}
|
|
143336
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
143337
|
+
return outputParts.join("/");
|
|
143338
|
+
} };
|
|
143339
|
+
var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder() : void 0;
|
|
143340
|
+
var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
|
|
143341
|
+
var endIdx = idx + maxBytesToRead;
|
|
143342
|
+
var endPtr = idx;
|
|
143343
|
+
while (heapOrArray[endPtr] && !(endPtr >= endIdx))
|
|
143344
|
+
++endPtr;
|
|
143345
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
143346
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
143347
|
+
}
|
|
143348
|
+
var str = "";
|
|
143349
|
+
while (idx < endPtr) {
|
|
143350
|
+
var u0 = heapOrArray[idx++];
|
|
143351
|
+
if (!(u0 & 128)) {
|
|
143352
|
+
str += String.fromCharCode(u0);
|
|
143353
|
+
continue;
|
|
143354
|
+
}
|
|
143355
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
143356
|
+
if ((u0 & 224) == 192) {
|
|
143357
|
+
str += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
143358
|
+
continue;
|
|
143359
|
+
}
|
|
143360
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
143361
|
+
if ((u0 & 240) == 224) {
|
|
143362
|
+
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
143363
|
+
} else {
|
|
143364
|
+
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
143365
|
+
}
|
|
143366
|
+
if (u0 < 65536) {
|
|
143367
|
+
str += String.fromCharCode(u0);
|
|
143368
|
+
} else {
|
|
143369
|
+
var ch = u0 - 65536;
|
|
143370
|
+
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
143371
|
+
}
|
|
143372
|
+
}
|
|
143373
|
+
return str;
|
|
143374
|
+
};
|
|
143375
|
+
var FS_stdin_getChar_buffer = [];
|
|
143376
|
+
var lengthBytesUTF8 = (str) => {
|
|
143377
|
+
var len = 0;
|
|
143378
|
+
for (var i = 0; i < str.length; ++i) {
|
|
143379
|
+
var c = str.charCodeAt(i);
|
|
143380
|
+
if (c <= 127) {
|
|
143381
|
+
len++;
|
|
143382
|
+
} else if (c <= 2047) {
|
|
143383
|
+
len += 2;
|
|
143384
|
+
} else if (c >= 55296 && c <= 57343) {
|
|
143385
|
+
len += 4;
|
|
143386
|
+
++i;
|
|
143387
|
+
} else {
|
|
143388
|
+
len += 3;
|
|
143389
|
+
}
|
|
143390
|
+
}
|
|
143391
|
+
return len;
|
|
143392
|
+
};
|
|
143393
|
+
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
143394
|
+
if (!(maxBytesToWrite > 0))
|
|
143395
|
+
return 0;
|
|
143396
|
+
var startIdx = outIdx;
|
|
143397
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
143398
|
+
for (var i = 0; i < str.length; ++i) {
|
|
143399
|
+
var u = str.charCodeAt(i);
|
|
143400
|
+
if (u >= 55296 && u <= 57343) {
|
|
143401
|
+
var u1 = str.charCodeAt(++i);
|
|
143402
|
+
u = 65536 + ((u & 1023) << 10) | u1 & 1023;
|
|
143403
|
+
}
|
|
143404
|
+
if (u <= 127) {
|
|
143405
|
+
if (outIdx >= endIdx)
|
|
143406
|
+
break;
|
|
143407
|
+
heap[outIdx++] = u;
|
|
143408
|
+
} else if (u <= 2047) {
|
|
143409
|
+
if (outIdx + 1 >= endIdx)
|
|
143410
|
+
break;
|
|
143411
|
+
heap[outIdx++] = 192 | u >> 6;
|
|
143412
|
+
heap[outIdx++] = 128 | u & 63;
|
|
143413
|
+
} else if (u <= 65535) {
|
|
143414
|
+
if (outIdx + 2 >= endIdx)
|
|
143415
|
+
break;
|
|
143416
|
+
heap[outIdx++] = 224 | u >> 12;
|
|
143417
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
143418
|
+
heap[outIdx++] = 128 | u & 63;
|
|
143419
|
+
} else {
|
|
143420
|
+
if (outIdx + 3 >= endIdx)
|
|
143421
|
+
break;
|
|
143422
|
+
heap[outIdx++] = 240 | u >> 18;
|
|
143423
|
+
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
143424
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
143425
|
+
heap[outIdx++] = 128 | u & 63;
|
|
143426
|
+
}
|
|
143427
|
+
}
|
|
143428
|
+
heap[outIdx] = 0;
|
|
143429
|
+
return outIdx - startIdx;
|
|
143430
|
+
};
|
|
143431
|
+
var intArrayFromString = (stringy, dontAddNull, length) => {
|
|
143432
|
+
var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
|
|
143433
|
+
var u8array = new Array(len);
|
|
143434
|
+
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
143435
|
+
if (dontAddNull)
|
|
143436
|
+
u8array.length = numBytesWritten;
|
|
143437
|
+
return u8array;
|
|
143438
|
+
};
|
|
143439
|
+
var FS_stdin_getChar = () => {
|
|
143440
|
+
if (!FS_stdin_getChar_buffer.length) {
|
|
143441
|
+
var result = null;
|
|
143442
|
+
if (typeof window != "undefined" && typeof window.prompt == "function") {
|
|
143443
|
+
result = window.prompt("Input: ");
|
|
143444
|
+
if (result !== null) {
|
|
143445
|
+
result += "\n";
|
|
143446
|
+
}
|
|
143447
|
+
}
|
|
143448
|
+
if (!result) {
|
|
143449
|
+
return null;
|
|
143450
|
+
}
|
|
143451
|
+
FS_stdin_getChar_buffer = intArrayFromString(result, true);
|
|
143452
|
+
}
|
|
143453
|
+
return FS_stdin_getChar_buffer.shift();
|
|
143454
|
+
};
|
|
143455
|
+
var TTY = { ttys: [], init() {
|
|
143456
|
+
}, shutdown() {
|
|
143457
|
+
}, register(dev, ops) {
|
|
143458
|
+
TTY.ttys[dev] = { input: [], output: [], ops };
|
|
143459
|
+
FS.registerDevice(dev, TTY.stream_ops);
|
|
143460
|
+
}, stream_ops: { open(stream) {
|
|
143461
|
+
var tty = TTY.ttys[stream.node.rdev];
|
|
143462
|
+
if (!tty) {
|
|
143463
|
+
throw new FS.ErrnoError(43);
|
|
143464
|
+
}
|
|
143465
|
+
stream.tty = tty;
|
|
143466
|
+
stream.seekable = false;
|
|
143467
|
+
}, close(stream) {
|
|
143468
|
+
stream.tty.ops.fsync(stream.tty);
|
|
143469
|
+
}, fsync(stream) {
|
|
143470
|
+
stream.tty.ops.fsync(stream.tty);
|
|
143471
|
+
}, read(stream, buffer, offset, length, pos) {
|
|
143472
|
+
if (!stream.tty || !stream.tty.ops.get_char) {
|
|
143473
|
+
throw new FS.ErrnoError(60);
|
|
143474
|
+
}
|
|
143475
|
+
var bytesRead = 0;
|
|
143476
|
+
for (var i = 0; i < length; i++) {
|
|
143477
|
+
var result;
|
|
143478
|
+
try {
|
|
143479
|
+
result = stream.tty.ops.get_char(stream.tty);
|
|
143480
|
+
} catch (e) {
|
|
143481
|
+
throw new FS.ErrnoError(29);
|
|
143482
|
+
}
|
|
143483
|
+
if (result === void 0 && bytesRead === 0) {
|
|
143484
|
+
throw new FS.ErrnoError(6);
|
|
143485
|
+
}
|
|
143486
|
+
if (result === null || result === void 0)
|
|
143487
|
+
break;
|
|
143488
|
+
bytesRead++;
|
|
143489
|
+
buffer[offset + i] = result;
|
|
143490
|
+
}
|
|
143491
|
+
if (bytesRead) {
|
|
143492
|
+
stream.node.atime = Date.now();
|
|
143493
|
+
}
|
|
143494
|
+
return bytesRead;
|
|
143495
|
+
}, write(stream, buffer, offset, length, pos) {
|
|
143496
|
+
if (!stream.tty || !stream.tty.ops.put_char) {
|
|
143497
|
+
throw new FS.ErrnoError(60);
|
|
143498
|
+
}
|
|
143499
|
+
try {
|
|
143500
|
+
for (var i = 0; i < length; i++) {
|
|
143501
|
+
stream.tty.ops.put_char(stream.tty, buffer[offset + i]);
|
|
143502
|
+
}
|
|
143503
|
+
} catch (e) {
|
|
143504
|
+
throw new FS.ErrnoError(29);
|
|
143505
|
+
}
|
|
143506
|
+
if (length) {
|
|
143507
|
+
stream.node.mtime = stream.node.ctime = Date.now();
|
|
143508
|
+
}
|
|
143509
|
+
return i;
|
|
143510
|
+
} }, default_tty_ops: { get_char(tty) {
|
|
143511
|
+
return FS_stdin_getChar();
|
|
143512
|
+
}, put_char(tty, val) {
|
|
143513
|
+
if (val === null || val === 10) {
|
|
143514
|
+
out(UTF8ArrayToString(tty.output));
|
|
143515
|
+
tty.output = [];
|
|
143516
|
+
} else {
|
|
143517
|
+
if (val != 0)
|
|
143518
|
+
tty.output.push(val);
|
|
143519
|
+
}
|
|
143520
|
+
}, fsync(tty) {
|
|
143521
|
+
if (tty.output?.length > 0) {
|
|
143522
|
+
out(UTF8ArrayToString(tty.output));
|
|
143523
|
+
tty.output = [];
|
|
143524
|
+
}
|
|
143525
|
+
}, ioctl_tcgets(tty) {
|
|
143526
|
+
return { c_iflag: 25856, c_oflag: 5, c_cflag: 191, c_lflag: 35387, c_cc: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
|
|
143527
|
+
}, ioctl_tcsets(tty, optional_actions, data) {
|
|
143528
|
+
return 0;
|
|
143529
|
+
}, ioctl_tiocgwinsz(tty) {
|
|
143530
|
+
return [24, 80];
|
|
143531
|
+
} }, default_tty1_ops: { put_char(tty, val) {
|
|
143532
|
+
if (val === null || val === 10) {
|
|
143533
|
+
err(UTF8ArrayToString(tty.output));
|
|
143534
|
+
tty.output = [];
|
|
143535
|
+
} else {
|
|
143536
|
+
if (val != 0)
|
|
143537
|
+
tty.output.push(val);
|
|
143538
|
+
}
|
|
143539
|
+
}, fsync(tty) {
|
|
143540
|
+
if (tty.output?.length > 0) {
|
|
143541
|
+
err(UTF8ArrayToString(tty.output));
|
|
143542
|
+
tty.output = [];
|
|
143543
|
+
}
|
|
143544
|
+
} } };
|
|
143545
|
+
var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
|
|
143546
|
+
var mmapAlloc = (size) => {
|
|
143547
|
+
abort();
|
|
143548
|
+
};
|
|
143549
|
+
var MEMFS = { ops_table: null, mount(mount) {
|
|
143550
|
+
return MEMFS.createNode(null, "/", 16895, 0);
|
|
143551
|
+
}, createNode(parent, name, mode, dev) {
|
|
143552
|
+
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
|
|
143553
|
+
throw new FS.ErrnoError(63);
|
|
143554
|
+
}
|
|
143555
|
+
MEMFS.ops_table || (MEMFS.ops_table = { dir: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr, lookup: MEMFS.node_ops.lookup, mknod: MEMFS.node_ops.mknod, rename: MEMFS.node_ops.rename, unlink: MEMFS.node_ops.unlink, rmdir: MEMFS.node_ops.rmdir, readdir: MEMFS.node_ops.readdir, symlink: MEMFS.node_ops.symlink }, stream: { llseek: MEMFS.stream_ops.llseek } }, file: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr }, stream: { llseek: MEMFS.stream_ops.llseek, read: MEMFS.stream_ops.read, write: MEMFS.stream_ops.write, allocate: MEMFS.stream_ops.allocate, mmap: MEMFS.stream_ops.mmap, msync: MEMFS.stream_ops.msync } }, link: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr, readlink: MEMFS.node_ops.readlink }, stream: {} }, chrdev: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr }, stream: FS.chrdev_stream_ops } });
|
|
143556
|
+
var node = FS.createNode(parent, name, mode, dev);
|
|
143557
|
+
if (FS.isDir(node.mode)) {
|
|
143558
|
+
node.node_ops = MEMFS.ops_table.dir.node;
|
|
143559
|
+
node.stream_ops = MEMFS.ops_table.dir.stream;
|
|
143560
|
+
node.contents = {};
|
|
143561
|
+
} else if (FS.isFile(node.mode)) {
|
|
143562
|
+
node.node_ops = MEMFS.ops_table.file.node;
|
|
143563
|
+
node.stream_ops = MEMFS.ops_table.file.stream;
|
|
143564
|
+
node.usedBytes = 0;
|
|
143565
|
+
node.contents = null;
|
|
143566
|
+
} else if (FS.isLink(node.mode)) {
|
|
143567
|
+
node.node_ops = MEMFS.ops_table.link.node;
|
|
143568
|
+
node.stream_ops = MEMFS.ops_table.link.stream;
|
|
143569
|
+
} else if (FS.isChrdev(node.mode)) {
|
|
143570
|
+
node.node_ops = MEMFS.ops_table.chrdev.node;
|
|
143571
|
+
node.stream_ops = MEMFS.ops_table.chrdev.stream;
|
|
143572
|
+
}
|
|
143573
|
+
node.atime = node.mtime = node.ctime = Date.now();
|
|
143574
|
+
if (parent) {
|
|
143575
|
+
parent.contents[name] = node;
|
|
143576
|
+
parent.atime = parent.mtime = parent.ctime = node.atime;
|
|
143577
|
+
}
|
|
143578
|
+
return node;
|
|
143579
|
+
}, getFileDataAsTypedArray(node) {
|
|
143580
|
+
if (!node.contents)
|
|
143581
|
+
return new Uint8Array(0);
|
|
143582
|
+
if (node.contents.subarray)
|
|
143583
|
+
return node.contents.subarray(0, node.usedBytes);
|
|
143584
|
+
return new Uint8Array(node.contents);
|
|
143585
|
+
}, expandFileStorage(node, newCapacity) {
|
|
143586
|
+
var prevCapacity = node.contents ? node.contents.length : 0;
|
|
143587
|
+
if (prevCapacity >= newCapacity)
|
|
143588
|
+
return;
|
|
143589
|
+
var CAPACITY_DOUBLING_MAX = 1024 * 1024;
|
|
143590
|
+
newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0);
|
|
143591
|
+
if (prevCapacity != 0)
|
|
143592
|
+
newCapacity = Math.max(newCapacity, 256);
|
|
143593
|
+
var oldContents = node.contents;
|
|
143594
|
+
node.contents = new Uint8Array(newCapacity);
|
|
143595
|
+
if (node.usedBytes > 0)
|
|
143596
|
+
node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
|
|
143597
|
+
}, resizeFileStorage(node, newSize) {
|
|
143598
|
+
if (node.usedBytes == newSize)
|
|
143599
|
+
return;
|
|
143600
|
+
if (newSize == 0) {
|
|
143601
|
+
node.contents = null;
|
|
143602
|
+
node.usedBytes = 0;
|
|
143603
|
+
} else {
|
|
143604
|
+
var oldContents = node.contents;
|
|
143605
|
+
node.contents = new Uint8Array(newSize);
|
|
143606
|
+
if (oldContents) {
|
|
143607
|
+
node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
|
|
143608
|
+
}
|
|
143609
|
+
node.usedBytes = newSize;
|
|
143610
|
+
}
|
|
143611
|
+
}, node_ops: { getattr(node) {
|
|
143612
|
+
var attr = {};
|
|
143613
|
+
attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
|
|
143614
|
+
attr.ino = node.id;
|
|
143615
|
+
attr.mode = node.mode;
|
|
143616
|
+
attr.nlink = 1;
|
|
143617
|
+
attr.uid = 0;
|
|
143618
|
+
attr.gid = 0;
|
|
143619
|
+
attr.rdev = node.rdev;
|
|
143620
|
+
if (FS.isDir(node.mode)) {
|
|
143621
|
+
attr.size = 4096;
|
|
143622
|
+
} else if (FS.isFile(node.mode)) {
|
|
143623
|
+
attr.size = node.usedBytes;
|
|
143624
|
+
} else if (FS.isLink(node.mode)) {
|
|
143625
|
+
attr.size = node.link.length;
|
|
143626
|
+
} else {
|
|
143627
|
+
attr.size = 0;
|
|
143628
|
+
}
|
|
143629
|
+
attr.atime = new Date(node.atime);
|
|
143630
|
+
attr.mtime = new Date(node.mtime);
|
|
143631
|
+
attr.ctime = new Date(node.ctime);
|
|
143632
|
+
attr.blksize = 4096;
|
|
143633
|
+
attr.blocks = Math.ceil(attr.size / attr.blksize);
|
|
143634
|
+
return attr;
|
|
143635
|
+
}, setattr(node, attr) {
|
|
143636
|
+
for (const key of ["mode", "atime", "mtime", "ctime"]) {
|
|
143637
|
+
if (attr[key] != null) {
|
|
143638
|
+
node[key] = attr[key];
|
|
143639
|
+
}
|
|
143640
|
+
}
|
|
143641
|
+
if (attr.size !== void 0) {
|
|
143642
|
+
MEMFS.resizeFileStorage(node, attr.size);
|
|
143643
|
+
}
|
|
143644
|
+
}, lookup(parent, name) {
|
|
143645
|
+
throw MEMFS.doesNotExistError;
|
|
143646
|
+
}, mknod(parent, name, mode, dev) {
|
|
143647
|
+
return MEMFS.createNode(parent, name, mode, dev);
|
|
143648
|
+
}, rename(old_node, new_dir, new_name) {
|
|
143649
|
+
var new_node;
|
|
143650
|
+
try {
|
|
143651
|
+
new_node = FS.lookupNode(new_dir, new_name);
|
|
143652
|
+
} catch (e) {
|
|
143653
|
+
}
|
|
143654
|
+
if (new_node) {
|
|
143655
|
+
if (FS.isDir(old_node.mode)) {
|
|
143656
|
+
for (var i in new_node.contents) {
|
|
143657
|
+
throw new FS.ErrnoError(55);
|
|
143658
|
+
}
|
|
143659
|
+
}
|
|
143660
|
+
FS.hashRemoveNode(new_node);
|
|
143661
|
+
}
|
|
143662
|
+
delete old_node.parent.contents[old_node.name];
|
|
143663
|
+
new_dir.contents[new_name] = old_node;
|
|
143664
|
+
old_node.name = new_name;
|
|
143665
|
+
new_dir.ctime = new_dir.mtime = old_node.parent.ctime = old_node.parent.mtime = Date.now();
|
|
143666
|
+
}, unlink(parent, name) {
|
|
143667
|
+
delete parent.contents[name];
|
|
143668
|
+
parent.ctime = parent.mtime = Date.now();
|
|
143669
|
+
}, rmdir(parent, name) {
|
|
143670
|
+
var node = FS.lookupNode(parent, name);
|
|
143671
|
+
for (var i in node.contents) {
|
|
143672
|
+
throw new FS.ErrnoError(55);
|
|
143673
|
+
}
|
|
143674
|
+
delete parent.contents[name];
|
|
143675
|
+
parent.ctime = parent.mtime = Date.now();
|
|
143676
|
+
}, readdir(node) {
|
|
143677
|
+
return [".", "..", ...Object.keys(node.contents)];
|
|
143678
|
+
}, symlink(parent, newname, oldpath) {
|
|
143679
|
+
var node = MEMFS.createNode(parent, newname, 511 | 40960, 0);
|
|
143680
|
+
node.link = oldpath;
|
|
143681
|
+
return node;
|
|
143682
|
+
}, readlink(node) {
|
|
143683
|
+
if (!FS.isLink(node.mode)) {
|
|
143684
|
+
throw new FS.ErrnoError(28);
|
|
143685
|
+
}
|
|
143686
|
+
return node.link;
|
|
143687
|
+
} }, stream_ops: { read(stream, buffer, offset, length, position) {
|
|
143688
|
+
var contents = stream.node.contents;
|
|
143689
|
+
if (position >= stream.node.usedBytes)
|
|
143690
|
+
return 0;
|
|
143691
|
+
var size = Math.min(stream.node.usedBytes - position, length);
|
|
143692
|
+
if (size > 8 && contents.subarray) {
|
|
143693
|
+
buffer.set(contents.subarray(position, position + size), offset);
|
|
143694
|
+
} else {
|
|
143695
|
+
for (var i = 0; i < size; i++)
|
|
143696
|
+
buffer[offset + i] = contents[position + i];
|
|
143697
|
+
}
|
|
143698
|
+
return size;
|
|
143699
|
+
}, write(stream, buffer, offset, length, position, canOwn) {
|
|
143700
|
+
if (buffer.buffer === HEAP8.buffer) {
|
|
143701
|
+
canOwn = false;
|
|
143702
|
+
}
|
|
143703
|
+
if (!length)
|
|
143704
|
+
return 0;
|
|
143705
|
+
var node = stream.node;
|
|
143706
|
+
node.mtime = node.ctime = Date.now();
|
|
143707
|
+
if (buffer.subarray && (!node.contents || node.contents.subarray)) {
|
|
143708
|
+
if (canOwn) {
|
|
143709
|
+
node.contents = buffer.subarray(offset, offset + length);
|
|
143710
|
+
node.usedBytes = length;
|
|
143711
|
+
return length;
|
|
143712
|
+
} else if (node.usedBytes === 0 && position === 0) {
|
|
143713
|
+
node.contents = buffer.slice(offset, offset + length);
|
|
143714
|
+
node.usedBytes = length;
|
|
143715
|
+
return length;
|
|
143716
|
+
} else if (position + length <= node.usedBytes) {
|
|
143717
|
+
node.contents.set(buffer.subarray(offset, offset + length), position);
|
|
143718
|
+
return length;
|
|
143719
|
+
}
|
|
143720
|
+
}
|
|
143721
|
+
MEMFS.expandFileStorage(node, position + length);
|
|
143722
|
+
if (node.contents.subarray && buffer.subarray) {
|
|
143723
|
+
node.contents.set(buffer.subarray(offset, offset + length), position);
|
|
143724
|
+
} else {
|
|
143725
|
+
for (var i = 0; i < length; i++) {
|
|
143726
|
+
node.contents[position + i] = buffer[offset + i];
|
|
143727
|
+
}
|
|
143728
|
+
}
|
|
143729
|
+
node.usedBytes = Math.max(node.usedBytes, position + length);
|
|
143730
|
+
return length;
|
|
143731
|
+
}, llseek(stream, offset, whence) {
|
|
143732
|
+
var position = offset;
|
|
143733
|
+
if (whence === 1) {
|
|
143734
|
+
position += stream.position;
|
|
143735
|
+
} else if (whence === 2) {
|
|
143736
|
+
if (FS.isFile(stream.node.mode)) {
|
|
143737
|
+
position += stream.node.usedBytes;
|
|
143738
|
+
}
|
|
143739
|
+
}
|
|
143740
|
+
if (position < 0) {
|
|
143741
|
+
throw new FS.ErrnoError(28);
|
|
143742
|
+
}
|
|
143743
|
+
return position;
|
|
143744
|
+
}, allocate(stream, offset, length) {
|
|
143745
|
+
MEMFS.expandFileStorage(stream.node, offset + length);
|
|
143746
|
+
stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
|
|
143747
|
+
}, mmap(stream, length, position, prot, flags) {
|
|
143748
|
+
if (!FS.isFile(stream.node.mode)) {
|
|
143749
|
+
throw new FS.ErrnoError(43);
|
|
143750
|
+
}
|
|
143751
|
+
var ptr;
|
|
143752
|
+
var allocated;
|
|
143753
|
+
var contents = stream.node.contents;
|
|
143754
|
+
if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
|
|
143755
|
+
allocated = false;
|
|
143756
|
+
ptr = contents.byteOffset;
|
|
143757
|
+
} else {
|
|
143758
|
+
allocated = true;
|
|
143759
|
+
ptr = mmapAlloc();
|
|
143760
|
+
if (!ptr) {
|
|
143761
|
+
throw new FS.ErrnoError(48);
|
|
143762
|
+
}
|
|
143763
|
+
if (contents) {
|
|
143764
|
+
if (position > 0 || position + length < contents.length) {
|
|
143765
|
+
if (contents.subarray) {
|
|
143766
|
+
contents = contents.subarray(position, position + length);
|
|
143767
|
+
} else {
|
|
143768
|
+
contents = Array.prototype.slice.call(contents, position, position + length);
|
|
143769
|
+
}
|
|
143770
|
+
}
|
|
143771
|
+
HEAP8.set(contents, ptr);
|
|
143772
|
+
}
|
|
143773
|
+
}
|
|
143774
|
+
return { ptr, allocated };
|
|
143775
|
+
}, msync(stream, buffer, offset, length, mmapFlags) {
|
|
143776
|
+
MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
|
|
143777
|
+
return 0;
|
|
143778
|
+
} } };
|
|
143779
|
+
var asyncLoad = async (url) => {
|
|
143780
|
+
var arrayBuffer = await readAsync(url);
|
|
143781
|
+
return new Uint8Array(arrayBuffer);
|
|
143782
|
+
};
|
|
143783
|
+
asyncLoad.isAsync = true;
|
|
143784
|
+
var FS_createDataFile = (parent, name, fileData, canRead, canWrite, canOwn) => {
|
|
143785
|
+
FS.createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
|
|
143786
|
+
};
|
|
143787
|
+
var preloadPlugins = Module["preloadPlugins"] || [];
|
|
143788
|
+
var FS_handledByPreloadPlugin = (byteArray, fullname, finish, onerror) => {
|
|
143789
|
+
if (typeof Browser != "undefined")
|
|
143790
|
+
Browser.init();
|
|
143791
|
+
var handled = false;
|
|
143792
|
+
preloadPlugins.forEach((plugin) => {
|
|
143793
|
+
if (handled)
|
|
143794
|
+
return;
|
|
143795
|
+
if (plugin["canHandle"](fullname)) {
|
|
143796
|
+
plugin["handle"](byteArray, fullname, finish, onerror);
|
|
143797
|
+
handled = true;
|
|
143798
|
+
}
|
|
143799
|
+
});
|
|
143800
|
+
return handled;
|
|
143801
|
+
};
|
|
143802
|
+
var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
|
|
143803
|
+
var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
|
|
143804
|
+
function processData(byteArray) {
|
|
143805
|
+
function finish(byteArray2) {
|
|
143806
|
+
preFinish?.();
|
|
143807
|
+
if (!dontCreateFile) {
|
|
143808
|
+
FS_createDataFile(parent, name, byteArray2, canRead, canWrite, canOwn);
|
|
143809
|
+
}
|
|
143810
|
+
onload?.();
|
|
143811
|
+
removeRunDependency();
|
|
143812
|
+
}
|
|
143813
|
+
if (FS_handledByPreloadPlugin(byteArray, fullname, finish, () => {
|
|
143814
|
+
onerror?.();
|
|
143815
|
+
removeRunDependency();
|
|
143816
|
+
})) {
|
|
143817
|
+
return;
|
|
143818
|
+
}
|
|
143819
|
+
finish(byteArray);
|
|
143820
|
+
}
|
|
143821
|
+
addRunDependency();
|
|
143822
|
+
if (typeof url == "string") {
|
|
143823
|
+
asyncLoad(url).then(processData, onerror);
|
|
143824
|
+
} else {
|
|
143825
|
+
processData(url);
|
|
143826
|
+
}
|
|
143827
|
+
};
|
|
143828
|
+
var FS_modeStringToFlags = (str) => {
|
|
143829
|
+
var flagModes = { r: 0, "r+": 2, w: 512 | 64 | 1, "w+": 512 | 64 | 2, a: 1024 | 64 | 1, "a+": 1024 | 64 | 2 };
|
|
143830
|
+
var flags = flagModes[str];
|
|
143831
|
+
if (typeof flags == "undefined") {
|
|
143832
|
+
throw new Error(`Unknown file open mode: ${str}`);
|
|
143833
|
+
}
|
|
143834
|
+
return flags;
|
|
143835
|
+
};
|
|
143836
|
+
var FS_getMode = (canRead, canWrite) => {
|
|
143837
|
+
var mode = 0;
|
|
143838
|
+
if (canRead)
|
|
143839
|
+
mode |= 292 | 73;
|
|
143840
|
+
if (canWrite)
|
|
143841
|
+
mode |= 146;
|
|
143842
|
+
return mode;
|
|
143843
|
+
};
|
|
143844
|
+
var FS = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: false, ignorePermissions: true, ErrnoError: class {
|
|
143845
|
+
constructor(errno) {
|
|
143846
|
+
__publicField$2(this, "name", "ErrnoError");
|
|
143847
|
+
this.errno = errno;
|
|
143848
|
+
}
|
|
143849
|
+
}, filesystems: null, syncFSRequests: 0, readFiles: {}, FSStream: class {
|
|
143850
|
+
constructor() {
|
|
143851
|
+
__publicField$2(this, "shared", {});
|
|
143852
|
+
}
|
|
143853
|
+
get object() {
|
|
143854
|
+
return this.node;
|
|
143855
|
+
}
|
|
143856
|
+
set object(val) {
|
|
143857
|
+
this.node = val;
|
|
143858
|
+
}
|
|
143859
|
+
get isRead() {
|
|
143860
|
+
return (this.flags & 2097155) !== 1;
|
|
143861
|
+
}
|
|
143862
|
+
get isWrite() {
|
|
143863
|
+
return (this.flags & 2097155) !== 0;
|
|
143864
|
+
}
|
|
143865
|
+
get isAppend() {
|
|
143866
|
+
return this.flags & 1024;
|
|
143867
|
+
}
|
|
143868
|
+
get flags() {
|
|
143869
|
+
return this.shared.flags;
|
|
143870
|
+
}
|
|
143871
|
+
set flags(val) {
|
|
143872
|
+
this.shared.flags = val;
|
|
143873
|
+
}
|
|
143874
|
+
get position() {
|
|
143875
|
+
return this.shared.position;
|
|
143876
|
+
}
|
|
143877
|
+
set position(val) {
|
|
143878
|
+
this.shared.position = val;
|
|
143879
|
+
}
|
|
143880
|
+
}, FSNode: class {
|
|
143881
|
+
constructor(parent, name, mode, rdev) {
|
|
143882
|
+
__publicField$2(this, "node_ops", {});
|
|
143883
|
+
__publicField$2(this, "stream_ops", {});
|
|
143884
|
+
__publicField$2(this, "readMode", 292 | 73);
|
|
143885
|
+
__publicField$2(this, "writeMode", 146);
|
|
143886
|
+
__publicField$2(this, "mounted", null);
|
|
143887
|
+
if (!parent) {
|
|
143888
|
+
parent = this;
|
|
143889
|
+
}
|
|
143890
|
+
this.parent = parent;
|
|
143891
|
+
this.mount = parent.mount;
|
|
143892
|
+
this.id = FS.nextInode++;
|
|
143893
|
+
this.name = name;
|
|
143894
|
+
this.mode = mode;
|
|
143895
|
+
this.rdev = rdev;
|
|
143896
|
+
this.atime = this.mtime = this.ctime = Date.now();
|
|
143897
|
+
}
|
|
143898
|
+
get read() {
|
|
143899
|
+
return (this.mode & this.readMode) === this.readMode;
|
|
143900
|
+
}
|
|
143901
|
+
set read(val) {
|
|
143902
|
+
val ? this.mode |= this.readMode : this.mode &= ~this.readMode;
|
|
143903
|
+
}
|
|
143904
|
+
get write() {
|
|
143905
|
+
return (this.mode & this.writeMode) === this.writeMode;
|
|
143906
|
+
}
|
|
143907
|
+
set write(val) {
|
|
143908
|
+
val ? this.mode |= this.writeMode : this.mode &= ~this.writeMode;
|
|
143909
|
+
}
|
|
143910
|
+
get isFolder() {
|
|
143911
|
+
return FS.isDir(this.mode);
|
|
143912
|
+
}
|
|
143913
|
+
get isDevice() {
|
|
143914
|
+
return FS.isChrdev(this.mode);
|
|
143915
|
+
}
|
|
143916
|
+
}, lookupPath(path, opts = {}) {
|
|
143917
|
+
if (!path) {
|
|
143918
|
+
throw new FS.ErrnoError(44);
|
|
143919
|
+
}
|
|
143920
|
+
opts.follow_mount ?? (opts.follow_mount = true);
|
|
143921
|
+
if (!PATH.isAbs(path)) {
|
|
143922
|
+
path = FS.cwd() + "/" + path;
|
|
143923
|
+
}
|
|
143924
|
+
linkloop:
|
|
143925
|
+
for (var nlinks = 0; nlinks < 40; nlinks++) {
|
|
143926
|
+
var parts = path.split("/").filter((p) => !!p);
|
|
143927
|
+
var current = FS.root;
|
|
143928
|
+
var current_path = "/";
|
|
143929
|
+
for (var i = 0; i < parts.length; i++) {
|
|
143930
|
+
var islast = i === parts.length - 1;
|
|
143931
|
+
if (islast && opts.parent) {
|
|
143932
|
+
break;
|
|
143933
|
+
}
|
|
143934
|
+
if (parts[i] === ".") {
|
|
143935
|
+
continue;
|
|
143936
|
+
}
|
|
143937
|
+
if (parts[i] === "..") {
|
|
143938
|
+
current_path = PATH.dirname(current_path);
|
|
143939
|
+
current = current.parent;
|
|
143940
|
+
continue;
|
|
143941
|
+
}
|
|
143942
|
+
current_path = PATH.join2(current_path, parts[i]);
|
|
143943
|
+
try {
|
|
143944
|
+
current = FS.lookupNode(current, parts[i]);
|
|
143945
|
+
} catch (e) {
|
|
143946
|
+
if (e?.errno === 44 && islast && opts.noent_okay) {
|
|
143947
|
+
return { path: current_path };
|
|
143948
|
+
}
|
|
143949
|
+
throw e;
|
|
143950
|
+
}
|
|
143951
|
+
if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) {
|
|
143952
|
+
current = current.mounted.root;
|
|
143953
|
+
}
|
|
143954
|
+
if (FS.isLink(current.mode) && (!islast || opts.follow)) {
|
|
143955
|
+
if (!current.node_ops.readlink) {
|
|
143956
|
+
throw new FS.ErrnoError(52);
|
|
143957
|
+
}
|
|
143958
|
+
var link = current.node_ops.readlink(current);
|
|
143959
|
+
if (!PATH.isAbs(link)) {
|
|
143960
|
+
link = PATH.dirname(current_path) + "/" + link;
|
|
143961
|
+
}
|
|
143962
|
+
path = link + "/" + parts.slice(i + 1).join("/");
|
|
143963
|
+
continue linkloop;
|
|
143964
|
+
}
|
|
143965
|
+
}
|
|
143966
|
+
return { path: current_path, node: current };
|
|
143967
|
+
}
|
|
143968
|
+
throw new FS.ErrnoError(32);
|
|
143969
|
+
}, getPath(node) {
|
|
143970
|
+
var path;
|
|
143971
|
+
while (true) {
|
|
143972
|
+
if (FS.isRoot(node)) {
|
|
143973
|
+
var mount = node.mount.mountpoint;
|
|
143974
|
+
if (!path)
|
|
143975
|
+
return mount;
|
|
143976
|
+
return mount[mount.length - 1] !== "/" ? `${mount}/${path}` : mount + path;
|
|
143977
|
+
}
|
|
143978
|
+
path = path ? `${node.name}/${path}` : node.name;
|
|
143979
|
+
node = node.parent;
|
|
143980
|
+
}
|
|
143981
|
+
}, hashName(parentid, name) {
|
|
143982
|
+
var hash = 0;
|
|
143983
|
+
for (var i = 0; i < name.length; i++) {
|
|
143984
|
+
hash = (hash << 5) - hash + name.charCodeAt(i) | 0;
|
|
143985
|
+
}
|
|
143986
|
+
return (parentid + hash >>> 0) % FS.nameTable.length;
|
|
143987
|
+
}, hashAddNode(node) {
|
|
143988
|
+
var hash = FS.hashName(node.parent.id, node.name);
|
|
143989
|
+
node.name_next = FS.nameTable[hash];
|
|
143990
|
+
FS.nameTable[hash] = node;
|
|
143991
|
+
}, hashRemoveNode(node) {
|
|
143992
|
+
var hash = FS.hashName(node.parent.id, node.name);
|
|
143993
|
+
if (FS.nameTable[hash] === node) {
|
|
143994
|
+
FS.nameTable[hash] = node.name_next;
|
|
143995
|
+
} else {
|
|
143996
|
+
var current = FS.nameTable[hash];
|
|
143997
|
+
while (current) {
|
|
143998
|
+
if (current.name_next === node) {
|
|
143999
|
+
current.name_next = node.name_next;
|
|
144000
|
+
break;
|
|
144001
|
+
}
|
|
144002
|
+
current = current.name_next;
|
|
144003
|
+
}
|
|
144004
|
+
}
|
|
144005
|
+
}, lookupNode(parent, name) {
|
|
144006
|
+
var errCode = FS.mayLookup(parent);
|
|
144007
|
+
if (errCode) {
|
|
144008
|
+
throw new FS.ErrnoError(errCode);
|
|
144009
|
+
}
|
|
144010
|
+
var hash = FS.hashName(parent.id, name);
|
|
144011
|
+
for (var node = FS.nameTable[hash]; node; node = node.name_next) {
|
|
144012
|
+
var nodeName = node.name;
|
|
144013
|
+
if (node.parent.id === parent.id && nodeName === name) {
|
|
144014
|
+
return node;
|
|
144015
|
+
}
|
|
144016
|
+
}
|
|
144017
|
+
return FS.lookup(parent, name);
|
|
144018
|
+
}, createNode(parent, name, mode, rdev) {
|
|
144019
|
+
var node = new FS.FSNode(parent, name, mode, rdev);
|
|
144020
|
+
FS.hashAddNode(node);
|
|
144021
|
+
return node;
|
|
144022
|
+
}, destroyNode(node) {
|
|
144023
|
+
FS.hashRemoveNode(node);
|
|
144024
|
+
}, isRoot(node) {
|
|
144025
|
+
return node === node.parent;
|
|
144026
|
+
}, isMountpoint(node) {
|
|
144027
|
+
return !!node.mounted;
|
|
144028
|
+
}, isFile(mode) {
|
|
144029
|
+
return (mode & 61440) === 32768;
|
|
144030
|
+
}, isDir(mode) {
|
|
144031
|
+
return (mode & 61440) === 16384;
|
|
144032
|
+
}, isLink(mode) {
|
|
144033
|
+
return (mode & 61440) === 40960;
|
|
144034
|
+
}, isChrdev(mode) {
|
|
144035
|
+
return (mode & 61440) === 8192;
|
|
144036
|
+
}, isBlkdev(mode) {
|
|
144037
|
+
return (mode & 61440) === 24576;
|
|
144038
|
+
}, isFIFO(mode) {
|
|
144039
|
+
return (mode & 61440) === 4096;
|
|
144040
|
+
}, isSocket(mode) {
|
|
144041
|
+
return (mode & 49152) === 49152;
|
|
144042
|
+
}, flagsToPermissionString(flag) {
|
|
144043
|
+
var perms = ["r", "w", "rw"][flag & 3];
|
|
144044
|
+
if (flag & 512) {
|
|
144045
|
+
perms += "w";
|
|
144046
|
+
}
|
|
144047
|
+
return perms;
|
|
144048
|
+
}, nodePermissions(node, perms) {
|
|
144049
|
+
if (FS.ignorePermissions) {
|
|
144050
|
+
return 0;
|
|
144051
|
+
}
|
|
144052
|
+
if (perms.includes("r") && !(node.mode & 292)) {
|
|
144053
|
+
return 2;
|
|
144054
|
+
} else if (perms.includes("w") && !(node.mode & 146)) {
|
|
144055
|
+
return 2;
|
|
144056
|
+
} else if (perms.includes("x") && !(node.mode & 73)) {
|
|
144057
|
+
return 2;
|
|
144058
|
+
}
|
|
144059
|
+
return 0;
|
|
144060
|
+
}, mayLookup(dir) {
|
|
144061
|
+
if (!FS.isDir(dir.mode))
|
|
144062
|
+
return 54;
|
|
144063
|
+
var errCode = FS.nodePermissions(dir, "x");
|
|
144064
|
+
if (errCode)
|
|
144065
|
+
return errCode;
|
|
144066
|
+
if (!dir.node_ops.lookup)
|
|
144067
|
+
return 2;
|
|
144068
|
+
return 0;
|
|
144069
|
+
}, mayCreate(dir, name) {
|
|
144070
|
+
if (!FS.isDir(dir.mode)) {
|
|
144071
|
+
return 54;
|
|
144072
|
+
}
|
|
144073
|
+
try {
|
|
144074
|
+
var node = FS.lookupNode(dir, name);
|
|
144075
|
+
return 20;
|
|
144076
|
+
} catch (e) {
|
|
144077
|
+
}
|
|
144078
|
+
return FS.nodePermissions(dir, "wx");
|
|
144079
|
+
}, mayDelete(dir, name, isdir) {
|
|
144080
|
+
var node;
|
|
144081
|
+
try {
|
|
144082
|
+
node = FS.lookupNode(dir, name);
|
|
144083
|
+
} catch (e) {
|
|
144084
|
+
return e.errno;
|
|
144085
|
+
}
|
|
144086
|
+
var errCode = FS.nodePermissions(dir, "wx");
|
|
144087
|
+
if (errCode) {
|
|
144088
|
+
return errCode;
|
|
144089
|
+
}
|
|
144090
|
+
if (isdir) {
|
|
144091
|
+
if (!FS.isDir(node.mode)) {
|
|
144092
|
+
return 54;
|
|
144093
|
+
}
|
|
144094
|
+
if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
|
|
144095
|
+
return 10;
|
|
144096
|
+
}
|
|
144097
|
+
} else {
|
|
144098
|
+
if (FS.isDir(node.mode)) {
|
|
144099
|
+
return 31;
|
|
144100
|
+
}
|
|
144101
|
+
}
|
|
144102
|
+
return 0;
|
|
144103
|
+
}, mayOpen(node, flags) {
|
|
144104
|
+
if (!node) {
|
|
144105
|
+
return 44;
|
|
144106
|
+
}
|
|
144107
|
+
if (FS.isLink(node.mode)) {
|
|
144108
|
+
return 32;
|
|
144109
|
+
} else if (FS.isDir(node.mode)) {
|
|
144110
|
+
if (FS.flagsToPermissionString(flags) !== "r" || flags & (512 | 64)) {
|
|
144111
|
+
return 31;
|
|
144112
|
+
}
|
|
144113
|
+
}
|
|
144114
|
+
return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
|
|
144115
|
+
}, checkOpExists(op, err2) {
|
|
144116
|
+
if (!op) {
|
|
144117
|
+
throw new FS.ErrnoError(err2);
|
|
144118
|
+
}
|
|
144119
|
+
return op;
|
|
144120
|
+
}, MAX_OPEN_FDS: 4096, nextfd() {
|
|
144121
|
+
for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) {
|
|
144122
|
+
if (!FS.streams[fd]) {
|
|
144123
|
+
return fd;
|
|
144124
|
+
}
|
|
144125
|
+
}
|
|
144126
|
+
throw new FS.ErrnoError(33);
|
|
144127
|
+
}, getStreamChecked(fd) {
|
|
144128
|
+
var stream = FS.getStream(fd);
|
|
144129
|
+
if (!stream) {
|
|
144130
|
+
throw new FS.ErrnoError(8);
|
|
144131
|
+
}
|
|
144132
|
+
return stream;
|
|
144133
|
+
}, getStream: (fd) => FS.streams[fd], createStream(stream, fd = -1) {
|
|
144134
|
+
stream = Object.assign(new FS.FSStream(), stream);
|
|
144135
|
+
if (fd == -1) {
|
|
144136
|
+
fd = FS.nextfd();
|
|
144137
|
+
}
|
|
144138
|
+
stream.fd = fd;
|
|
144139
|
+
FS.streams[fd] = stream;
|
|
144140
|
+
return stream;
|
|
144141
|
+
}, closeStream(fd) {
|
|
144142
|
+
FS.streams[fd] = null;
|
|
144143
|
+
}, dupStream(origStream, fd = -1) {
|
|
144144
|
+
var stream = FS.createStream(origStream, fd);
|
|
144145
|
+
stream.stream_ops?.dup?.(stream);
|
|
144146
|
+
return stream;
|
|
144147
|
+
}, doSetAttr(stream, node, attr) {
|
|
144148
|
+
var setattr = stream?.stream_ops.setattr;
|
|
144149
|
+
var arg = setattr ? stream : node;
|
|
144150
|
+
setattr ?? (setattr = node.node_ops.setattr);
|
|
144151
|
+
FS.checkOpExists(setattr, 63);
|
|
144152
|
+
setattr(arg, attr);
|
|
144153
|
+
}, chrdev_stream_ops: { open(stream) {
|
|
144154
|
+
var device = FS.getDevice(stream.node.rdev);
|
|
144155
|
+
stream.stream_ops = device.stream_ops;
|
|
144156
|
+
stream.stream_ops.open?.(stream);
|
|
144157
|
+
}, llseek() {
|
|
144158
|
+
throw new FS.ErrnoError(70);
|
|
144159
|
+
} }, major: (dev) => dev >> 8, minor: (dev) => dev & 255, makedev: (ma, mi) => ma << 8 | mi, registerDevice(dev, ops) {
|
|
144160
|
+
FS.devices[dev] = { stream_ops: ops };
|
|
144161
|
+
}, getDevice: (dev) => FS.devices[dev], getMounts(mount) {
|
|
144162
|
+
var mounts = [];
|
|
144163
|
+
var check = [mount];
|
|
144164
|
+
while (check.length) {
|
|
144165
|
+
var m = check.pop();
|
|
144166
|
+
mounts.push(m);
|
|
144167
|
+
check.push(...m.mounts);
|
|
144168
|
+
}
|
|
144169
|
+
return mounts;
|
|
144170
|
+
}, syncfs(populate, callback) {
|
|
144171
|
+
if (typeof populate == "function") {
|
|
144172
|
+
callback = populate;
|
|
144173
|
+
populate = false;
|
|
144174
|
+
}
|
|
144175
|
+
FS.syncFSRequests++;
|
|
144176
|
+
if (FS.syncFSRequests > 1) {
|
|
144177
|
+
err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);
|
|
144178
|
+
}
|
|
144179
|
+
var mounts = FS.getMounts(FS.root.mount);
|
|
144180
|
+
var completed = 0;
|
|
144181
|
+
function doCallback(errCode) {
|
|
144182
|
+
FS.syncFSRequests--;
|
|
144183
|
+
return callback(errCode);
|
|
144184
|
+
}
|
|
144185
|
+
function done(errCode) {
|
|
144186
|
+
if (errCode) {
|
|
144187
|
+
if (!done.errored) {
|
|
144188
|
+
done.errored = true;
|
|
144189
|
+
return doCallback(errCode);
|
|
144190
|
+
}
|
|
144191
|
+
return;
|
|
144192
|
+
}
|
|
144193
|
+
if (++completed >= mounts.length) {
|
|
144194
|
+
doCallback(null);
|
|
144195
|
+
}
|
|
144196
|
+
}
|
|
144197
|
+
mounts.forEach((mount) => {
|
|
144198
|
+
if (!mount.type.syncfs) {
|
|
144199
|
+
return done(null);
|
|
144200
|
+
}
|
|
144201
|
+
mount.type.syncfs(mount, populate, done);
|
|
144202
|
+
});
|
|
144203
|
+
}, mount(type, opts, mountpoint) {
|
|
144204
|
+
var root = mountpoint === "/";
|
|
144205
|
+
var pseudo = !mountpoint;
|
|
144206
|
+
var node;
|
|
144207
|
+
if (root && FS.root) {
|
|
144208
|
+
throw new FS.ErrnoError(10);
|
|
144209
|
+
} else if (!root && !pseudo) {
|
|
144210
|
+
var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
|
|
144211
|
+
mountpoint = lookup.path;
|
|
144212
|
+
node = lookup.node;
|
|
144213
|
+
if (FS.isMountpoint(node)) {
|
|
144214
|
+
throw new FS.ErrnoError(10);
|
|
144215
|
+
}
|
|
144216
|
+
if (!FS.isDir(node.mode)) {
|
|
144217
|
+
throw new FS.ErrnoError(54);
|
|
144218
|
+
}
|
|
144219
|
+
}
|
|
144220
|
+
var mount = { type, opts, mountpoint, mounts: [] };
|
|
144221
|
+
var mountRoot = type.mount(mount);
|
|
144222
|
+
mountRoot.mount = mount;
|
|
144223
|
+
mount.root = mountRoot;
|
|
144224
|
+
if (root) {
|
|
144225
|
+
FS.root = mountRoot;
|
|
144226
|
+
} else if (node) {
|
|
144227
|
+
node.mounted = mount;
|
|
144228
|
+
if (node.mount) {
|
|
144229
|
+
node.mount.mounts.push(mount);
|
|
144230
|
+
}
|
|
144231
|
+
}
|
|
144232
|
+
return mountRoot;
|
|
144233
|
+
}, unmount(mountpoint) {
|
|
144234
|
+
var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
|
|
144235
|
+
if (!FS.isMountpoint(lookup.node)) {
|
|
144236
|
+
throw new FS.ErrnoError(28);
|
|
144237
|
+
}
|
|
144238
|
+
var node = lookup.node;
|
|
144239
|
+
var mount = node.mounted;
|
|
144240
|
+
var mounts = FS.getMounts(mount);
|
|
144241
|
+
Object.keys(FS.nameTable).forEach((hash) => {
|
|
144242
|
+
var current = FS.nameTable[hash];
|
|
144243
|
+
while (current) {
|
|
144244
|
+
var next = current.name_next;
|
|
144245
|
+
if (mounts.includes(current.mount)) {
|
|
144246
|
+
FS.destroyNode(current);
|
|
144247
|
+
}
|
|
144248
|
+
current = next;
|
|
144249
|
+
}
|
|
144250
|
+
});
|
|
144251
|
+
node.mounted = null;
|
|
144252
|
+
var idx = node.mount.mounts.indexOf(mount);
|
|
144253
|
+
node.mount.mounts.splice(idx, 1);
|
|
144254
|
+
}, lookup(parent, name) {
|
|
144255
|
+
return parent.node_ops.lookup(parent, name);
|
|
144256
|
+
}, mknod(path, mode, dev) {
|
|
144257
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
144258
|
+
var parent = lookup.node;
|
|
144259
|
+
var name = PATH.basename(path);
|
|
144260
|
+
if (!name) {
|
|
144261
|
+
throw new FS.ErrnoError(28);
|
|
144262
|
+
}
|
|
144263
|
+
if (name === "." || name === "..") {
|
|
144264
|
+
throw new FS.ErrnoError(20);
|
|
144265
|
+
}
|
|
144266
|
+
var errCode = FS.mayCreate(parent, name);
|
|
144267
|
+
if (errCode) {
|
|
144268
|
+
throw new FS.ErrnoError(errCode);
|
|
144269
|
+
}
|
|
144270
|
+
if (!parent.node_ops.mknod) {
|
|
144271
|
+
throw new FS.ErrnoError(63);
|
|
144272
|
+
}
|
|
144273
|
+
return parent.node_ops.mknod(parent, name, mode, dev);
|
|
144274
|
+
}, statfs(path) {
|
|
144275
|
+
return FS.statfsNode(FS.lookupPath(path, { follow: true }).node);
|
|
144276
|
+
}, statfsStream(stream) {
|
|
144277
|
+
return FS.statfsNode(stream.node);
|
|
144278
|
+
}, statfsNode(node) {
|
|
144279
|
+
var rtn = { bsize: 4096, frsize: 4096, blocks: 1e6, bfree: 5e5, bavail: 5e5, files: FS.nextInode, ffree: FS.nextInode - 1, fsid: 42, flags: 2, namelen: 255 };
|
|
144280
|
+
if (node.node_ops.statfs) {
|
|
144281
|
+
Object.assign(rtn, node.node_ops.statfs(node.mount.opts.root));
|
|
144282
|
+
}
|
|
144283
|
+
return rtn;
|
|
144284
|
+
}, create(path, mode = 438) {
|
|
144285
|
+
mode &= 4095;
|
|
144286
|
+
mode |= 32768;
|
|
144287
|
+
return FS.mknod(path, mode, 0);
|
|
144288
|
+
}, mkdir(path, mode = 511) {
|
|
144289
|
+
mode &= 511 | 512;
|
|
144290
|
+
mode |= 16384;
|
|
144291
|
+
return FS.mknod(path, mode, 0);
|
|
144292
|
+
}, mkdirTree(path, mode) {
|
|
144293
|
+
var dirs = path.split("/");
|
|
144294
|
+
var d = "";
|
|
144295
|
+
for (var i = 0; i < dirs.length; ++i) {
|
|
144296
|
+
if (!dirs[i])
|
|
144297
|
+
continue;
|
|
144298
|
+
d += "/" + dirs[i];
|
|
144299
|
+
try {
|
|
144300
|
+
FS.mkdir(d, mode);
|
|
144301
|
+
} catch (e) {
|
|
144302
|
+
if (e.errno != 20)
|
|
144303
|
+
throw e;
|
|
144304
|
+
}
|
|
144305
|
+
}
|
|
144306
|
+
}, mkdev(path, mode, dev) {
|
|
144307
|
+
if (typeof dev == "undefined") {
|
|
144308
|
+
dev = mode;
|
|
144309
|
+
mode = 438;
|
|
144310
|
+
}
|
|
144311
|
+
mode |= 8192;
|
|
144312
|
+
return FS.mknod(path, mode, dev);
|
|
144313
|
+
}, symlink(oldpath, newpath) {
|
|
144314
|
+
if (!PATH_FS.resolve(oldpath)) {
|
|
144315
|
+
throw new FS.ErrnoError(44);
|
|
144316
|
+
}
|
|
144317
|
+
var lookup = FS.lookupPath(newpath, { parent: true });
|
|
144318
|
+
var parent = lookup.node;
|
|
144319
|
+
if (!parent) {
|
|
144320
|
+
throw new FS.ErrnoError(44);
|
|
144321
|
+
}
|
|
144322
|
+
var newname = PATH.basename(newpath);
|
|
144323
|
+
var errCode = FS.mayCreate(parent, newname);
|
|
144324
|
+
if (errCode) {
|
|
144325
|
+
throw new FS.ErrnoError(errCode);
|
|
144326
|
+
}
|
|
144327
|
+
if (!parent.node_ops.symlink) {
|
|
144328
|
+
throw new FS.ErrnoError(63);
|
|
144329
|
+
}
|
|
144330
|
+
return parent.node_ops.symlink(parent, newname, oldpath);
|
|
144331
|
+
}, rename(old_path, new_path) {
|
|
144332
|
+
var old_dirname = PATH.dirname(old_path);
|
|
144333
|
+
var new_dirname = PATH.dirname(new_path);
|
|
144334
|
+
var old_name = PATH.basename(old_path);
|
|
144335
|
+
var new_name = PATH.basename(new_path);
|
|
144336
|
+
var lookup, old_dir, new_dir;
|
|
144337
|
+
lookup = FS.lookupPath(old_path, { parent: true });
|
|
144338
|
+
old_dir = lookup.node;
|
|
144339
|
+
lookup = FS.lookupPath(new_path, { parent: true });
|
|
144340
|
+
new_dir = lookup.node;
|
|
144341
|
+
if (!old_dir || !new_dir)
|
|
144342
|
+
throw new FS.ErrnoError(44);
|
|
144343
|
+
if (old_dir.mount !== new_dir.mount) {
|
|
144344
|
+
throw new FS.ErrnoError(75);
|
|
144345
|
+
}
|
|
144346
|
+
var old_node = FS.lookupNode(old_dir, old_name);
|
|
144347
|
+
var relative = PATH_FS.relative(old_path, new_dirname);
|
|
144348
|
+
if (relative.charAt(0) !== ".") {
|
|
144349
|
+
throw new FS.ErrnoError(28);
|
|
144350
|
+
}
|
|
144351
|
+
relative = PATH_FS.relative(new_path, old_dirname);
|
|
144352
|
+
if (relative.charAt(0) !== ".") {
|
|
144353
|
+
throw new FS.ErrnoError(55);
|
|
144354
|
+
}
|
|
144355
|
+
var new_node;
|
|
144356
|
+
try {
|
|
144357
|
+
new_node = FS.lookupNode(new_dir, new_name);
|
|
144358
|
+
} catch (e) {
|
|
144359
|
+
}
|
|
144360
|
+
if (old_node === new_node) {
|
|
144361
|
+
return;
|
|
144362
|
+
}
|
|
144363
|
+
var isdir = FS.isDir(old_node.mode);
|
|
144364
|
+
var errCode = FS.mayDelete(old_dir, old_name, isdir);
|
|
144365
|
+
if (errCode) {
|
|
144366
|
+
throw new FS.ErrnoError(errCode);
|
|
144367
|
+
}
|
|
144368
|
+
errCode = new_node ? FS.mayDelete(new_dir, new_name, isdir) : FS.mayCreate(new_dir, new_name);
|
|
144369
|
+
if (errCode) {
|
|
144370
|
+
throw new FS.ErrnoError(errCode);
|
|
144371
|
+
}
|
|
144372
|
+
if (!old_dir.node_ops.rename) {
|
|
144373
|
+
throw new FS.ErrnoError(63);
|
|
144374
|
+
}
|
|
144375
|
+
if (FS.isMountpoint(old_node) || new_node && FS.isMountpoint(new_node)) {
|
|
144376
|
+
throw new FS.ErrnoError(10);
|
|
144377
|
+
}
|
|
144378
|
+
if (new_dir !== old_dir) {
|
|
144379
|
+
errCode = FS.nodePermissions(old_dir, "w");
|
|
144380
|
+
if (errCode) {
|
|
144381
|
+
throw new FS.ErrnoError(errCode);
|
|
144382
|
+
}
|
|
144383
|
+
}
|
|
144384
|
+
FS.hashRemoveNode(old_node);
|
|
144385
|
+
try {
|
|
144386
|
+
old_dir.node_ops.rename(old_node, new_dir, new_name);
|
|
144387
|
+
old_node.parent = new_dir;
|
|
144388
|
+
} catch (e) {
|
|
144389
|
+
throw e;
|
|
144390
|
+
} finally {
|
|
144391
|
+
FS.hashAddNode(old_node);
|
|
144392
|
+
}
|
|
144393
|
+
}, rmdir(path) {
|
|
144394
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
144395
|
+
var parent = lookup.node;
|
|
144396
|
+
var name = PATH.basename(path);
|
|
144397
|
+
var node = FS.lookupNode(parent, name);
|
|
144398
|
+
var errCode = FS.mayDelete(parent, name, true);
|
|
144399
|
+
if (errCode) {
|
|
144400
|
+
throw new FS.ErrnoError(errCode);
|
|
144401
|
+
}
|
|
144402
|
+
if (!parent.node_ops.rmdir) {
|
|
144403
|
+
throw new FS.ErrnoError(63);
|
|
144404
|
+
}
|
|
144405
|
+
if (FS.isMountpoint(node)) {
|
|
144406
|
+
throw new FS.ErrnoError(10);
|
|
144407
|
+
}
|
|
144408
|
+
parent.node_ops.rmdir(parent, name);
|
|
144409
|
+
FS.destroyNode(node);
|
|
144410
|
+
}, readdir(path) {
|
|
144411
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
144412
|
+
var node = lookup.node;
|
|
144413
|
+
var readdir = FS.checkOpExists(node.node_ops.readdir, 54);
|
|
144414
|
+
return readdir(node);
|
|
144415
|
+
}, unlink(path) {
|
|
144416
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
144417
|
+
var parent = lookup.node;
|
|
144418
|
+
if (!parent) {
|
|
144419
|
+
throw new FS.ErrnoError(44);
|
|
144420
|
+
}
|
|
144421
|
+
var name = PATH.basename(path);
|
|
144422
|
+
var node = FS.lookupNode(parent, name);
|
|
144423
|
+
var errCode = FS.mayDelete(parent, name, false);
|
|
144424
|
+
if (errCode) {
|
|
144425
|
+
throw new FS.ErrnoError(errCode);
|
|
144426
|
+
}
|
|
144427
|
+
if (!parent.node_ops.unlink) {
|
|
144428
|
+
throw new FS.ErrnoError(63);
|
|
144429
|
+
}
|
|
144430
|
+
if (FS.isMountpoint(node)) {
|
|
144431
|
+
throw new FS.ErrnoError(10);
|
|
144432
|
+
}
|
|
144433
|
+
parent.node_ops.unlink(parent, name);
|
|
144434
|
+
FS.destroyNode(node);
|
|
144435
|
+
}, readlink(path) {
|
|
144436
|
+
var lookup = FS.lookupPath(path);
|
|
144437
|
+
var link = lookup.node;
|
|
144438
|
+
if (!link) {
|
|
144439
|
+
throw new FS.ErrnoError(44);
|
|
144440
|
+
}
|
|
144441
|
+
if (!link.node_ops.readlink) {
|
|
144442
|
+
throw new FS.ErrnoError(28);
|
|
144443
|
+
}
|
|
144444
|
+
return link.node_ops.readlink(link);
|
|
144445
|
+
}, stat(path, dontFollow) {
|
|
144446
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
144447
|
+
var node = lookup.node;
|
|
144448
|
+
var getattr = FS.checkOpExists(node.node_ops.getattr, 63);
|
|
144449
|
+
return getattr(node);
|
|
144450
|
+
}, fstat(fd) {
|
|
144451
|
+
var stream = FS.getStreamChecked(fd);
|
|
144452
|
+
var node = stream.node;
|
|
144453
|
+
var getattr = stream.stream_ops.getattr;
|
|
144454
|
+
var arg = getattr ? stream : node;
|
|
144455
|
+
getattr ?? (getattr = node.node_ops.getattr);
|
|
144456
|
+
FS.checkOpExists(getattr, 63);
|
|
144457
|
+
return getattr(arg);
|
|
144458
|
+
}, lstat(path) {
|
|
144459
|
+
return FS.stat(path, true);
|
|
144460
|
+
}, doChmod(stream, node, mode, dontFollow) {
|
|
144461
|
+
FS.doSetAttr(stream, node, { mode: mode & 4095 | node.mode & ~4095, ctime: Date.now(), dontFollow });
|
|
144462
|
+
}, chmod(path, mode, dontFollow) {
|
|
144463
|
+
var node;
|
|
144464
|
+
if (typeof path == "string") {
|
|
144465
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
144466
|
+
node = lookup.node;
|
|
144467
|
+
} else {
|
|
144468
|
+
node = path;
|
|
144469
|
+
}
|
|
144470
|
+
FS.doChmod(null, node, mode, dontFollow);
|
|
144471
|
+
}, lchmod(path, mode) {
|
|
144472
|
+
FS.chmod(path, mode, true);
|
|
144473
|
+
}, fchmod(fd, mode) {
|
|
144474
|
+
var stream = FS.getStreamChecked(fd);
|
|
144475
|
+
FS.doChmod(stream, stream.node, mode, false);
|
|
144476
|
+
}, doChown(stream, node, dontFollow) {
|
|
144477
|
+
FS.doSetAttr(stream, node, { timestamp: Date.now(), dontFollow });
|
|
144478
|
+
}, chown(path, uid, gid, dontFollow) {
|
|
144479
|
+
var node;
|
|
144480
|
+
if (typeof path == "string") {
|
|
144481
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
144482
|
+
node = lookup.node;
|
|
144483
|
+
} else {
|
|
144484
|
+
node = path;
|
|
144485
|
+
}
|
|
144486
|
+
FS.doChown(null, node, dontFollow);
|
|
144487
|
+
}, lchown(path, uid, gid) {
|
|
144488
|
+
FS.chown(path, uid, gid, true);
|
|
144489
|
+
}, fchown(fd, uid, gid) {
|
|
144490
|
+
var stream = FS.getStreamChecked(fd);
|
|
144491
|
+
FS.doChown(stream, stream.node, false);
|
|
144492
|
+
}, doTruncate(stream, node, len) {
|
|
144493
|
+
if (FS.isDir(node.mode)) {
|
|
144494
|
+
throw new FS.ErrnoError(31);
|
|
144495
|
+
}
|
|
144496
|
+
if (!FS.isFile(node.mode)) {
|
|
144497
|
+
throw new FS.ErrnoError(28);
|
|
144498
|
+
}
|
|
144499
|
+
var errCode = FS.nodePermissions(node, "w");
|
|
144500
|
+
if (errCode) {
|
|
144501
|
+
throw new FS.ErrnoError(errCode);
|
|
144502
|
+
}
|
|
144503
|
+
FS.doSetAttr(stream, node, { size: len, timestamp: Date.now() });
|
|
144504
|
+
}, truncate(path, len) {
|
|
144505
|
+
if (len < 0) {
|
|
144506
|
+
throw new FS.ErrnoError(28);
|
|
144507
|
+
}
|
|
144508
|
+
var node;
|
|
144509
|
+
if (typeof path == "string") {
|
|
144510
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
144511
|
+
node = lookup.node;
|
|
144512
|
+
} else {
|
|
144513
|
+
node = path;
|
|
144514
|
+
}
|
|
144515
|
+
FS.doTruncate(null, node, len);
|
|
144516
|
+
}, ftruncate(fd, len) {
|
|
144517
|
+
var stream = FS.getStreamChecked(fd);
|
|
144518
|
+
if (len < 0 || (stream.flags & 2097155) === 0) {
|
|
144519
|
+
throw new FS.ErrnoError(28);
|
|
144520
|
+
}
|
|
144521
|
+
FS.doTruncate(stream, stream.node, len);
|
|
144522
|
+
}, utime(path, atime, mtime) {
|
|
144523
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
144524
|
+
var node = lookup.node;
|
|
144525
|
+
var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
|
|
144526
|
+
setattr(node, { atime, mtime });
|
|
144527
|
+
}, open(path, flags, mode = 438) {
|
|
144528
|
+
if (path === "") {
|
|
144529
|
+
throw new FS.ErrnoError(44);
|
|
144530
|
+
}
|
|
144531
|
+
flags = typeof flags == "string" ? FS_modeStringToFlags(flags) : flags;
|
|
144532
|
+
if (flags & 64) {
|
|
144533
|
+
mode = mode & 4095 | 32768;
|
|
144534
|
+
} else {
|
|
144535
|
+
mode = 0;
|
|
144536
|
+
}
|
|
144537
|
+
var node;
|
|
144538
|
+
var isDirPath;
|
|
144539
|
+
if (typeof path == "object") {
|
|
144540
|
+
node = path;
|
|
144541
|
+
} else {
|
|
144542
|
+
isDirPath = path.endsWith("/");
|
|
144543
|
+
var lookup = FS.lookupPath(path, { follow: !(flags & 131072), noent_okay: true });
|
|
144544
|
+
node = lookup.node;
|
|
144545
|
+
path = lookup.path;
|
|
144546
|
+
}
|
|
144547
|
+
var created = false;
|
|
144548
|
+
if (flags & 64) {
|
|
144549
|
+
if (node) {
|
|
144550
|
+
if (flags & 128) {
|
|
144551
|
+
throw new FS.ErrnoError(20);
|
|
144552
|
+
}
|
|
144553
|
+
} else if (isDirPath) {
|
|
144554
|
+
throw new FS.ErrnoError(31);
|
|
144555
|
+
} else {
|
|
144556
|
+
node = FS.mknod(path, mode | 511, 0);
|
|
144557
|
+
created = true;
|
|
144558
|
+
}
|
|
144559
|
+
}
|
|
144560
|
+
if (!node) {
|
|
144561
|
+
throw new FS.ErrnoError(44);
|
|
144562
|
+
}
|
|
144563
|
+
if (FS.isChrdev(node.mode)) {
|
|
144564
|
+
flags &= ~512;
|
|
144565
|
+
}
|
|
144566
|
+
if (flags & 65536 && !FS.isDir(node.mode)) {
|
|
144567
|
+
throw new FS.ErrnoError(54);
|
|
144568
|
+
}
|
|
144569
|
+
if (!created) {
|
|
144570
|
+
var errCode = FS.mayOpen(node, flags);
|
|
144571
|
+
if (errCode) {
|
|
144572
|
+
throw new FS.ErrnoError(errCode);
|
|
144573
|
+
}
|
|
144574
|
+
}
|
|
144575
|
+
if (flags & 512 && !created) {
|
|
144576
|
+
FS.truncate(node, 0);
|
|
144577
|
+
}
|
|
144578
|
+
flags &= ~(128 | 512 | 131072);
|
|
144579
|
+
var stream = FS.createStream({ node, path: FS.getPath(node), flags, seekable: true, position: 0, stream_ops: node.stream_ops, ungotten: [], error: false });
|
|
144580
|
+
if (stream.stream_ops.open) {
|
|
144581
|
+
stream.stream_ops.open(stream);
|
|
144582
|
+
}
|
|
144583
|
+
if (created) {
|
|
144584
|
+
FS.chmod(node, mode & 511);
|
|
144585
|
+
}
|
|
144586
|
+
if (Module["logReadFiles"] && !(flags & 1)) {
|
|
144587
|
+
if (!(path in FS.readFiles)) {
|
|
144588
|
+
FS.readFiles[path] = 1;
|
|
144589
|
+
}
|
|
144590
|
+
}
|
|
144591
|
+
return stream;
|
|
144592
|
+
}, close(stream) {
|
|
144593
|
+
if (FS.isClosed(stream)) {
|
|
144594
|
+
throw new FS.ErrnoError(8);
|
|
144595
|
+
}
|
|
144596
|
+
if (stream.getdents)
|
|
144597
|
+
stream.getdents = null;
|
|
144598
|
+
try {
|
|
144599
|
+
if (stream.stream_ops.close) {
|
|
144600
|
+
stream.stream_ops.close(stream);
|
|
144601
|
+
}
|
|
144602
|
+
} catch (e) {
|
|
144603
|
+
throw e;
|
|
144604
|
+
} finally {
|
|
144605
|
+
FS.closeStream(stream.fd);
|
|
144606
|
+
}
|
|
144607
|
+
stream.fd = null;
|
|
144608
|
+
}, isClosed(stream) {
|
|
144609
|
+
return stream.fd === null;
|
|
144610
|
+
}, llseek(stream, offset, whence) {
|
|
144611
|
+
if (FS.isClosed(stream)) {
|
|
144612
|
+
throw new FS.ErrnoError(8);
|
|
144613
|
+
}
|
|
144614
|
+
if (!stream.seekable || !stream.stream_ops.llseek) {
|
|
144615
|
+
throw new FS.ErrnoError(70);
|
|
144616
|
+
}
|
|
144617
|
+
if (whence != 0 && whence != 1 && whence != 2) {
|
|
144618
|
+
throw new FS.ErrnoError(28);
|
|
144619
|
+
}
|
|
144620
|
+
stream.position = stream.stream_ops.llseek(stream, offset, whence);
|
|
144621
|
+
stream.ungotten = [];
|
|
144622
|
+
return stream.position;
|
|
144623
|
+
}, read(stream, buffer, offset, length, position) {
|
|
144624
|
+
if (length < 0 || position < 0) {
|
|
144625
|
+
throw new FS.ErrnoError(28);
|
|
144626
|
+
}
|
|
144627
|
+
if (FS.isClosed(stream)) {
|
|
144628
|
+
throw new FS.ErrnoError(8);
|
|
144629
|
+
}
|
|
144630
|
+
if ((stream.flags & 2097155) === 1) {
|
|
144631
|
+
throw new FS.ErrnoError(8);
|
|
144632
|
+
}
|
|
144633
|
+
if (FS.isDir(stream.node.mode)) {
|
|
144634
|
+
throw new FS.ErrnoError(31);
|
|
144635
|
+
}
|
|
144636
|
+
if (!stream.stream_ops.read) {
|
|
144637
|
+
throw new FS.ErrnoError(28);
|
|
144638
|
+
}
|
|
144639
|
+
var seeking = typeof position != "undefined";
|
|
144640
|
+
if (!seeking) {
|
|
144641
|
+
position = stream.position;
|
|
144642
|
+
} else if (!stream.seekable) {
|
|
144643
|
+
throw new FS.ErrnoError(70);
|
|
144644
|
+
}
|
|
144645
|
+
var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
|
|
144646
|
+
if (!seeking)
|
|
144647
|
+
stream.position += bytesRead;
|
|
144648
|
+
return bytesRead;
|
|
144649
|
+
}, write(stream, buffer, offset, length, position, canOwn) {
|
|
144650
|
+
if (length < 0 || position < 0) {
|
|
144651
|
+
throw new FS.ErrnoError(28);
|
|
144652
|
+
}
|
|
144653
|
+
if (FS.isClosed(stream)) {
|
|
144654
|
+
throw new FS.ErrnoError(8);
|
|
144655
|
+
}
|
|
144656
|
+
if ((stream.flags & 2097155) === 0) {
|
|
144657
|
+
throw new FS.ErrnoError(8);
|
|
144658
|
+
}
|
|
144659
|
+
if (FS.isDir(stream.node.mode)) {
|
|
144660
|
+
throw new FS.ErrnoError(31);
|
|
144661
|
+
}
|
|
144662
|
+
if (!stream.stream_ops.write) {
|
|
144663
|
+
throw new FS.ErrnoError(28);
|
|
144664
|
+
}
|
|
144665
|
+
if (stream.seekable && stream.flags & 1024) {
|
|
144666
|
+
FS.llseek(stream, 0, 2);
|
|
144667
|
+
}
|
|
144668
|
+
var seeking = typeof position != "undefined";
|
|
144669
|
+
if (!seeking) {
|
|
144670
|
+
position = stream.position;
|
|
144671
|
+
} else if (!stream.seekable) {
|
|
144672
|
+
throw new FS.ErrnoError(70);
|
|
144673
|
+
}
|
|
144674
|
+
var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
|
|
144675
|
+
if (!seeking)
|
|
144676
|
+
stream.position += bytesWritten;
|
|
144677
|
+
return bytesWritten;
|
|
144678
|
+
}, allocate(stream, offset, length) {
|
|
144679
|
+
if (FS.isClosed(stream)) {
|
|
144680
|
+
throw new FS.ErrnoError(8);
|
|
144681
|
+
}
|
|
144682
|
+
if (offset < 0 || length <= 0) {
|
|
144683
|
+
throw new FS.ErrnoError(28);
|
|
144684
|
+
}
|
|
144685
|
+
if ((stream.flags & 2097155) === 0) {
|
|
144686
|
+
throw new FS.ErrnoError(8);
|
|
144687
|
+
}
|
|
144688
|
+
if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
|
|
144689
|
+
throw new FS.ErrnoError(43);
|
|
144690
|
+
}
|
|
144691
|
+
if (!stream.stream_ops.allocate) {
|
|
144692
|
+
throw new FS.ErrnoError(138);
|
|
144693
|
+
}
|
|
144694
|
+
stream.stream_ops.allocate(stream, offset, length);
|
|
144695
|
+
}, mmap(stream, length, position, prot, flags) {
|
|
144696
|
+
if ((prot & 2) !== 0 && (flags & 2) === 0 && (stream.flags & 2097155) !== 2) {
|
|
144697
|
+
throw new FS.ErrnoError(2);
|
|
144698
|
+
}
|
|
144699
|
+
if ((stream.flags & 2097155) === 1) {
|
|
144700
|
+
throw new FS.ErrnoError(2);
|
|
144701
|
+
}
|
|
144702
|
+
if (!stream.stream_ops.mmap) {
|
|
144703
|
+
throw new FS.ErrnoError(43);
|
|
144704
|
+
}
|
|
144705
|
+
if (!length) {
|
|
144706
|
+
throw new FS.ErrnoError(28);
|
|
144707
|
+
}
|
|
144708
|
+
return stream.stream_ops.mmap(stream, length, position, prot, flags);
|
|
144709
|
+
}, msync(stream, buffer, offset, length, mmapFlags) {
|
|
144710
|
+
if (!stream.stream_ops.msync) {
|
|
144711
|
+
return 0;
|
|
144712
|
+
}
|
|
144713
|
+
return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
|
|
144714
|
+
}, ioctl(stream, cmd, arg) {
|
|
144715
|
+
if (!stream.stream_ops.ioctl) {
|
|
144716
|
+
throw new FS.ErrnoError(59);
|
|
144717
|
+
}
|
|
144718
|
+
return stream.stream_ops.ioctl(stream, cmd, arg);
|
|
144719
|
+
}, readFile(path, opts = {}) {
|
|
144720
|
+
opts.flags = opts.flags || 0;
|
|
144721
|
+
opts.encoding = opts.encoding || "binary";
|
|
144722
|
+
if (opts.encoding !== "utf8" && opts.encoding !== "binary") {
|
|
144723
|
+
throw new Error(`Invalid encoding type "${opts.encoding}"`);
|
|
144724
|
+
}
|
|
144725
|
+
var ret;
|
|
144726
|
+
var stream = FS.open(path, opts.flags);
|
|
144727
|
+
var stat = FS.stat(path);
|
|
144728
|
+
var length = stat.size;
|
|
144729
|
+
var buf = new Uint8Array(length);
|
|
144730
|
+
FS.read(stream, buf, 0, length, 0);
|
|
144731
|
+
if (opts.encoding === "utf8") {
|
|
144732
|
+
ret = UTF8ArrayToString(buf);
|
|
144733
|
+
} else if (opts.encoding === "binary") {
|
|
144734
|
+
ret = buf;
|
|
144735
|
+
}
|
|
144736
|
+
FS.close(stream);
|
|
144737
|
+
return ret;
|
|
144738
|
+
}, writeFile(path, data, opts = {}) {
|
|
144739
|
+
opts.flags = opts.flags || 577;
|
|
144740
|
+
var stream = FS.open(path, opts.flags, opts.mode);
|
|
144741
|
+
if (typeof data == "string") {
|
|
144742
|
+
var buf = new Uint8Array(lengthBytesUTF8(data) + 1);
|
|
144743
|
+
var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
|
|
144744
|
+
FS.write(stream, buf, 0, actualNumBytes, void 0, opts.canOwn);
|
|
144745
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
144746
|
+
FS.write(stream, data, 0, data.byteLength, void 0, opts.canOwn);
|
|
144747
|
+
} else {
|
|
144748
|
+
throw new Error("Unsupported data type");
|
|
144749
|
+
}
|
|
144750
|
+
FS.close(stream);
|
|
144751
|
+
}, cwd: () => FS.currentPath, chdir(path) {
|
|
144752
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
144753
|
+
if (lookup.node === null) {
|
|
144754
|
+
throw new FS.ErrnoError(44);
|
|
144755
|
+
}
|
|
144756
|
+
if (!FS.isDir(lookup.node.mode)) {
|
|
144757
|
+
throw new FS.ErrnoError(54);
|
|
144758
|
+
}
|
|
144759
|
+
var errCode = FS.nodePermissions(lookup.node, "x");
|
|
144760
|
+
if (errCode) {
|
|
144761
|
+
throw new FS.ErrnoError(errCode);
|
|
144762
|
+
}
|
|
144763
|
+
FS.currentPath = lookup.path;
|
|
144764
|
+
}, createDefaultDirectories() {
|
|
144765
|
+
FS.mkdir("/tmp");
|
|
144766
|
+
FS.mkdir("/home");
|
|
144767
|
+
FS.mkdir("/home/web_user");
|
|
144768
|
+
}, createDefaultDevices() {
|
|
144769
|
+
FS.mkdir("/dev");
|
|
144770
|
+
FS.registerDevice(FS.makedev(1, 3), { read: () => 0, write: (stream, buffer, offset, length, pos) => length, llseek: () => 0 });
|
|
144771
|
+
FS.mkdev("/dev/null", FS.makedev(1, 3));
|
|
144772
|
+
TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
|
|
144773
|
+
TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
|
|
144774
|
+
FS.mkdev("/dev/tty", FS.makedev(5, 0));
|
|
144775
|
+
FS.mkdev("/dev/tty1", FS.makedev(6, 0));
|
|
144776
|
+
var randomBuffer = new Uint8Array(1024), randomLeft = 0;
|
|
144777
|
+
var randomByte = () => {
|
|
144778
|
+
if (randomLeft === 0) {
|
|
144779
|
+
randomFill(randomBuffer);
|
|
144780
|
+
randomLeft = randomBuffer.byteLength;
|
|
144781
|
+
}
|
|
144782
|
+
return randomBuffer[--randomLeft];
|
|
144783
|
+
};
|
|
144784
|
+
FS.createDevice("/dev", "random", randomByte);
|
|
144785
|
+
FS.createDevice("/dev", "urandom", randomByte);
|
|
144786
|
+
FS.mkdir("/dev/shm");
|
|
144787
|
+
FS.mkdir("/dev/shm/tmp");
|
|
144788
|
+
}, createSpecialDirectories() {
|
|
144789
|
+
FS.mkdir("/proc");
|
|
144790
|
+
var proc_self = FS.mkdir("/proc/self");
|
|
144791
|
+
FS.mkdir("/proc/self/fd");
|
|
144792
|
+
FS.mount({ mount() {
|
|
144793
|
+
var node = FS.createNode(proc_self, "fd", 16895, 73);
|
|
144794
|
+
node.stream_ops = { llseek: MEMFS.stream_ops.llseek };
|
|
144795
|
+
node.node_ops = { lookup(parent, name) {
|
|
144796
|
+
var fd = +name;
|
|
144797
|
+
var stream = FS.getStreamChecked(fd);
|
|
144798
|
+
var ret = { parent: null, mount: { mountpoint: "fake" }, node_ops: { readlink: () => stream.path }, id: fd + 1 };
|
|
144799
|
+
ret.parent = ret;
|
|
144800
|
+
return ret;
|
|
144801
|
+
}, readdir() {
|
|
144802
|
+
return Array.from(FS.streams.entries()).filter(([k, v]) => v).map(([k, v]) => k.toString());
|
|
144803
|
+
} };
|
|
144804
|
+
return node;
|
|
144805
|
+
} }, {}, "/proc/self/fd");
|
|
144806
|
+
}, createStandardStreams(input, output, error) {
|
|
144807
|
+
if (input) {
|
|
144808
|
+
FS.createDevice("/dev", "stdin", input);
|
|
144809
|
+
} else {
|
|
144810
|
+
FS.symlink("/dev/tty", "/dev/stdin");
|
|
144811
|
+
}
|
|
144812
|
+
if (output) {
|
|
144813
|
+
FS.createDevice("/dev", "stdout", null, output);
|
|
144814
|
+
} else {
|
|
144815
|
+
FS.symlink("/dev/tty", "/dev/stdout");
|
|
144816
|
+
}
|
|
144817
|
+
if (error) {
|
|
144818
|
+
FS.createDevice("/dev", "stderr", null, error);
|
|
144819
|
+
} else {
|
|
144820
|
+
FS.symlink("/dev/tty1", "/dev/stderr");
|
|
144821
|
+
}
|
|
144822
|
+
FS.open("/dev/stdin", 0);
|
|
144823
|
+
FS.open("/dev/stdout", 1);
|
|
144824
|
+
FS.open("/dev/stderr", 1);
|
|
144825
|
+
}, staticInit() {
|
|
144826
|
+
FS.nameTable = new Array(4096);
|
|
144827
|
+
FS.mount(MEMFS, {}, "/");
|
|
144828
|
+
FS.createDefaultDirectories();
|
|
144829
|
+
FS.createDefaultDevices();
|
|
144830
|
+
FS.createSpecialDirectories();
|
|
144831
|
+
FS.filesystems = { MEMFS };
|
|
144832
|
+
}, init(input, output, error) {
|
|
144833
|
+
FS.initialized = true;
|
|
144834
|
+
input ?? (input = Module["stdin"]);
|
|
144835
|
+
output ?? (output = Module["stdout"]);
|
|
144836
|
+
error ?? (error = Module["stderr"]);
|
|
144837
|
+
FS.createStandardStreams(input, output, error);
|
|
144838
|
+
}, quit() {
|
|
144839
|
+
FS.initialized = false;
|
|
144840
|
+
for (var i = 0; i < FS.streams.length; i++) {
|
|
144841
|
+
var stream = FS.streams[i];
|
|
144842
|
+
if (!stream) {
|
|
144843
|
+
continue;
|
|
144844
|
+
}
|
|
144845
|
+
FS.close(stream);
|
|
144846
|
+
}
|
|
144847
|
+
}, findObject(path, dontResolveLastLink) {
|
|
144848
|
+
var ret = FS.analyzePath(path, dontResolveLastLink);
|
|
144849
|
+
if (!ret.exists) {
|
|
144850
|
+
return null;
|
|
144851
|
+
}
|
|
144852
|
+
return ret.object;
|
|
144853
|
+
}, analyzePath(path, dontResolveLastLink) {
|
|
144854
|
+
try {
|
|
144855
|
+
var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
|
|
144856
|
+
path = lookup.path;
|
|
144857
|
+
} catch (e) {
|
|
144858
|
+
}
|
|
144859
|
+
var ret = { isRoot: false, exists: false, error: 0, name: null, path: null, object: null, parentExists: false, parentPath: null, parentObject: null };
|
|
144860
|
+
try {
|
|
144861
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
144862
|
+
ret.parentExists = true;
|
|
144863
|
+
ret.parentPath = lookup.path;
|
|
144864
|
+
ret.parentObject = lookup.node;
|
|
144865
|
+
ret.name = PATH.basename(path);
|
|
144866
|
+
lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
|
|
144867
|
+
ret.exists = true;
|
|
144868
|
+
ret.path = lookup.path;
|
|
144869
|
+
ret.object = lookup.node;
|
|
144870
|
+
ret.name = lookup.node.name;
|
|
144871
|
+
ret.isRoot = lookup.path === "/";
|
|
144872
|
+
} catch (e) {
|
|
144873
|
+
ret.error = e.errno;
|
|
144874
|
+
}
|
|
144875
|
+
return ret;
|
|
144876
|
+
}, createPath(parent, path, canRead, canWrite) {
|
|
144877
|
+
parent = typeof parent == "string" ? parent : FS.getPath(parent);
|
|
144878
|
+
var parts = path.split("/").reverse();
|
|
144879
|
+
while (parts.length) {
|
|
144880
|
+
var part = parts.pop();
|
|
144881
|
+
if (!part)
|
|
144882
|
+
continue;
|
|
144883
|
+
var current = PATH.join2(parent, part);
|
|
144884
|
+
try {
|
|
144885
|
+
FS.mkdir(current);
|
|
144886
|
+
} catch (e) {
|
|
144887
|
+
}
|
|
144888
|
+
parent = current;
|
|
144889
|
+
}
|
|
144890
|
+
return current;
|
|
144891
|
+
}, createFile(parent, name, properties, canRead, canWrite) {
|
|
144892
|
+
var path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
|
|
144893
|
+
var mode = FS_getMode(canRead, canWrite);
|
|
144894
|
+
return FS.create(path, mode);
|
|
144895
|
+
}, createDataFile(parent, name, data, canRead, canWrite, canOwn) {
|
|
144896
|
+
var path = name;
|
|
144897
|
+
if (parent) {
|
|
144898
|
+
parent = typeof parent == "string" ? parent : FS.getPath(parent);
|
|
144899
|
+
path = name ? PATH.join2(parent, name) : parent;
|
|
144900
|
+
}
|
|
144901
|
+
var mode = FS_getMode(canRead, canWrite);
|
|
144902
|
+
var node = FS.create(path, mode);
|
|
144903
|
+
if (data) {
|
|
144904
|
+
if (typeof data == "string") {
|
|
144905
|
+
var arr = new Array(data.length);
|
|
144906
|
+
for (var i = 0, len = data.length; i < len; ++i)
|
|
144907
|
+
arr[i] = data.charCodeAt(i);
|
|
144908
|
+
data = arr;
|
|
144909
|
+
}
|
|
144910
|
+
FS.chmod(node, mode | 146);
|
|
144911
|
+
var stream = FS.open(node, 577);
|
|
144912
|
+
FS.write(stream, data, 0, data.length, 0, canOwn);
|
|
144913
|
+
FS.close(stream);
|
|
144914
|
+
FS.chmod(node, mode);
|
|
144915
|
+
}
|
|
144916
|
+
}, createDevice(parent, name, input, output) {
|
|
144917
|
+
var _a;
|
|
144918
|
+
var path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
|
|
144919
|
+
var mode = FS_getMode(!!input, !!output);
|
|
144920
|
+
(_a = FS.createDevice).major ?? (_a.major = 64);
|
|
144921
|
+
var dev = FS.makedev(FS.createDevice.major++, 0);
|
|
144922
|
+
FS.registerDevice(dev, { open(stream) {
|
|
144923
|
+
stream.seekable = false;
|
|
144924
|
+
}, close(stream) {
|
|
144925
|
+
if (output?.buffer?.length) {
|
|
144926
|
+
output(10);
|
|
144927
|
+
}
|
|
144928
|
+
}, read(stream, buffer, offset, length, pos) {
|
|
144929
|
+
var bytesRead = 0;
|
|
144930
|
+
for (var i = 0; i < length; i++) {
|
|
144931
|
+
var result;
|
|
144932
|
+
try {
|
|
144933
|
+
result = input();
|
|
144934
|
+
} catch (e) {
|
|
144935
|
+
throw new FS.ErrnoError(29);
|
|
144936
|
+
}
|
|
144937
|
+
if (result === void 0 && bytesRead === 0) {
|
|
144938
|
+
throw new FS.ErrnoError(6);
|
|
144939
|
+
}
|
|
144940
|
+
if (result === null || result === void 0)
|
|
144941
|
+
break;
|
|
144942
|
+
bytesRead++;
|
|
144943
|
+
buffer[offset + i] = result;
|
|
144944
|
+
}
|
|
144945
|
+
if (bytesRead) {
|
|
144946
|
+
stream.node.atime = Date.now();
|
|
144947
|
+
}
|
|
144948
|
+
return bytesRead;
|
|
144949
|
+
}, write(stream, buffer, offset, length, pos) {
|
|
144950
|
+
for (var i = 0; i < length; i++) {
|
|
144951
|
+
try {
|
|
144952
|
+
output(buffer[offset + i]);
|
|
144953
|
+
} catch (e) {
|
|
144954
|
+
throw new FS.ErrnoError(29);
|
|
144955
|
+
}
|
|
144956
|
+
}
|
|
144957
|
+
if (length) {
|
|
144958
|
+
stream.node.mtime = stream.node.ctime = Date.now();
|
|
144959
|
+
}
|
|
144960
|
+
return i;
|
|
144961
|
+
} });
|
|
144962
|
+
return FS.mkdev(path, mode, dev);
|
|
144963
|
+
}, forceLoadFile(obj) {
|
|
144964
|
+
if (obj.isDevice || obj.isFolder || obj.link || obj.contents)
|
|
144965
|
+
return true;
|
|
144966
|
+
if (typeof XMLHttpRequest != "undefined") {
|
|
144967
|
+
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.");
|
|
144968
|
+
} else {
|
|
144969
|
+
try {
|
|
144970
|
+
obj.contents = readBinary(obj.url);
|
|
144971
|
+
obj.usedBytes = obj.contents.length;
|
|
144972
|
+
} catch (e) {
|
|
144973
|
+
throw new FS.ErrnoError(29);
|
|
144974
|
+
}
|
|
144975
|
+
}
|
|
144976
|
+
}, createLazyFile(parent, name, url, canRead, canWrite) {
|
|
144977
|
+
class LazyUint8Array {
|
|
144978
|
+
constructor() {
|
|
144979
|
+
__publicField$2(this, "lengthKnown", false);
|
|
144980
|
+
__publicField$2(this, "chunks", []);
|
|
144981
|
+
}
|
|
144982
|
+
get(idx) {
|
|
144983
|
+
if (idx > this.length - 1 || idx < 0) {
|
|
144984
|
+
return void 0;
|
|
144985
|
+
}
|
|
144986
|
+
var chunkOffset = idx % this.chunkSize;
|
|
144987
|
+
var chunkNum = idx / this.chunkSize | 0;
|
|
144988
|
+
return this.getter(chunkNum)[chunkOffset];
|
|
144989
|
+
}
|
|
144990
|
+
setDataGetter(getter) {
|
|
144991
|
+
this.getter = getter;
|
|
144992
|
+
}
|
|
144993
|
+
cacheLength() {
|
|
144994
|
+
var xhr = new XMLHttpRequest();
|
|
144995
|
+
xhr.open("HEAD", url, false);
|
|
144996
|
+
xhr.send(null);
|
|
144997
|
+
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304))
|
|
144998
|
+
throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
|
|
144999
|
+
var datalength = Number(xhr.getResponseHeader("Content-length"));
|
|
145000
|
+
var header;
|
|
145001
|
+
var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
|
|
145002
|
+
var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
|
|
145003
|
+
var chunkSize = 1024 * 1024;
|
|
145004
|
+
if (!hasByteServing)
|
|
145005
|
+
chunkSize = datalength;
|
|
145006
|
+
var doXHR = (from, to) => {
|
|
145007
|
+
if (from > to)
|
|
145008
|
+
throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
|
|
145009
|
+
if (to > datalength - 1)
|
|
145010
|
+
throw new Error("only " + datalength + " bytes available! programmer error!");
|
|
145011
|
+
var xhr2 = new XMLHttpRequest();
|
|
145012
|
+
xhr2.open("GET", url, false);
|
|
145013
|
+
if (datalength !== chunkSize)
|
|
145014
|
+
xhr2.setRequestHeader("Range", "bytes=" + from + "-" + to);
|
|
145015
|
+
xhr2.responseType = "arraybuffer";
|
|
145016
|
+
if (xhr2.overrideMimeType) {
|
|
145017
|
+
xhr2.overrideMimeType("text/plain; charset=x-user-defined");
|
|
145018
|
+
}
|
|
145019
|
+
xhr2.send(null);
|
|
145020
|
+
if (!(xhr2.status >= 200 && xhr2.status < 300 || xhr2.status === 304))
|
|
145021
|
+
throw new Error("Couldn't load " + url + ". Status: " + xhr2.status);
|
|
145022
|
+
if (xhr2.response !== void 0) {
|
|
145023
|
+
return new Uint8Array(xhr2.response || []);
|
|
145024
|
+
}
|
|
145025
|
+
return intArrayFromString(xhr2.responseText || "", true);
|
|
145026
|
+
};
|
|
145027
|
+
var lazyArray2 = this;
|
|
145028
|
+
lazyArray2.setDataGetter((chunkNum) => {
|
|
145029
|
+
var start = chunkNum * chunkSize;
|
|
145030
|
+
var end = (chunkNum + 1) * chunkSize - 1;
|
|
145031
|
+
end = Math.min(end, datalength - 1);
|
|
145032
|
+
if (typeof lazyArray2.chunks[chunkNum] == "undefined") {
|
|
145033
|
+
lazyArray2.chunks[chunkNum] = doXHR(start, end);
|
|
145034
|
+
}
|
|
145035
|
+
if (typeof lazyArray2.chunks[chunkNum] == "undefined")
|
|
145036
|
+
throw new Error("doXHR failed!");
|
|
145037
|
+
return lazyArray2.chunks[chunkNum];
|
|
145038
|
+
});
|
|
145039
|
+
if (usesGzip || !datalength) {
|
|
145040
|
+
chunkSize = datalength = 1;
|
|
145041
|
+
datalength = this.getter(0).length;
|
|
145042
|
+
chunkSize = datalength;
|
|
145043
|
+
out("LazyFiles on gzip forces download of the whole file when length is accessed");
|
|
145044
|
+
}
|
|
145045
|
+
this._length = datalength;
|
|
145046
|
+
this._chunkSize = chunkSize;
|
|
145047
|
+
this.lengthKnown = true;
|
|
145048
|
+
}
|
|
145049
|
+
get length() {
|
|
145050
|
+
if (!this.lengthKnown) {
|
|
145051
|
+
this.cacheLength();
|
|
145052
|
+
}
|
|
145053
|
+
return this._length;
|
|
145054
|
+
}
|
|
145055
|
+
get chunkSize() {
|
|
145056
|
+
if (!this.lengthKnown) {
|
|
145057
|
+
this.cacheLength();
|
|
145058
|
+
}
|
|
145059
|
+
return this._chunkSize;
|
|
145060
|
+
}
|
|
145061
|
+
}
|
|
145062
|
+
if (typeof XMLHttpRequest != "undefined") {
|
|
145063
|
+
throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";
|
|
145064
|
+
var lazyArray = new LazyUint8Array();
|
|
145065
|
+
var properties = { isDevice: false, contents: lazyArray };
|
|
145066
|
+
} else {
|
|
145067
|
+
var properties = { isDevice: false, url };
|
|
145068
|
+
}
|
|
145069
|
+
var node = FS.createFile(parent, name, properties, canRead, canWrite);
|
|
145070
|
+
if (properties.contents) {
|
|
145071
|
+
node.contents = properties.contents;
|
|
145072
|
+
} else if (properties.url) {
|
|
145073
|
+
node.contents = null;
|
|
145074
|
+
node.url = properties.url;
|
|
145075
|
+
}
|
|
145076
|
+
Object.defineProperties(node, { usedBytes: { get: function() {
|
|
145077
|
+
return this.contents.length;
|
|
145078
|
+
} } });
|
|
145079
|
+
var stream_ops = {};
|
|
145080
|
+
var keys = Object.keys(node.stream_ops);
|
|
145081
|
+
keys.forEach((key) => {
|
|
145082
|
+
var fn = node.stream_ops[key];
|
|
145083
|
+
stream_ops[key] = (...args) => {
|
|
145084
|
+
FS.forceLoadFile(node);
|
|
145085
|
+
return fn(...args);
|
|
145086
|
+
};
|
|
145087
|
+
});
|
|
145088
|
+
function writeChunks(stream, buffer, offset, length, position) {
|
|
145089
|
+
var contents = stream.node.contents;
|
|
145090
|
+
if (position >= contents.length)
|
|
145091
|
+
return 0;
|
|
145092
|
+
var size = Math.min(contents.length - position, length);
|
|
145093
|
+
if (contents.slice) {
|
|
145094
|
+
for (var i = 0; i < size; i++) {
|
|
145095
|
+
buffer[offset + i] = contents[position + i];
|
|
145096
|
+
}
|
|
145097
|
+
} else {
|
|
145098
|
+
for (var i = 0; i < size; i++) {
|
|
145099
|
+
buffer[offset + i] = contents.get(position + i);
|
|
145100
|
+
}
|
|
145101
|
+
}
|
|
145102
|
+
return size;
|
|
145103
|
+
}
|
|
145104
|
+
stream_ops.read = (stream, buffer, offset, length, position) => {
|
|
145105
|
+
FS.forceLoadFile(node);
|
|
145106
|
+
return writeChunks(stream, buffer, offset, length, position);
|
|
145107
|
+
};
|
|
145108
|
+
stream_ops.mmap = (stream, length, position, prot, flags) => {
|
|
145109
|
+
FS.forceLoadFile(node);
|
|
145110
|
+
var ptr = mmapAlloc();
|
|
145111
|
+
if (!ptr) {
|
|
145112
|
+
throw new FS.ErrnoError(48);
|
|
145113
|
+
}
|
|
145114
|
+
writeChunks(stream, HEAP8, ptr, length, position);
|
|
145115
|
+
return { ptr, allocated: true };
|
|
145116
|
+
};
|
|
145117
|
+
node.stream_ops = stream_ops;
|
|
145118
|
+
return node;
|
|
145119
|
+
} };
|
|
145120
|
+
var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
|
|
145121
|
+
var SYSCALLS = { DEFAULT_POLLMASK: 5, calculateAt(dirfd, path, allowEmpty) {
|
|
145122
|
+
if (PATH.isAbs(path)) {
|
|
145123
|
+
return path;
|
|
145124
|
+
}
|
|
145125
|
+
var dir;
|
|
145126
|
+
if (dirfd === -100) {
|
|
145127
|
+
dir = FS.cwd();
|
|
145128
|
+
} else {
|
|
145129
|
+
var dirstream = SYSCALLS.getStreamFromFD(dirfd);
|
|
145130
|
+
dir = dirstream.path;
|
|
145131
|
+
}
|
|
145132
|
+
if (path.length == 0) {
|
|
145133
|
+
if (!allowEmpty) {
|
|
145134
|
+
throw new FS.ErrnoError(44);
|
|
145135
|
+
}
|
|
145136
|
+
return dir;
|
|
145137
|
+
}
|
|
145138
|
+
return dir + "/" + path;
|
|
145139
|
+
}, writeStat(buf, stat) {
|
|
145140
|
+
HEAP32[buf >> 2] = stat.dev;
|
|
145141
|
+
HEAP32[buf + 4 >> 2] = stat.mode;
|
|
145142
|
+
HEAPU32[buf + 8 >> 2] = stat.nlink;
|
|
145143
|
+
HEAP32[buf + 12 >> 2] = stat.uid;
|
|
145144
|
+
HEAP32[buf + 16 >> 2] = stat.gid;
|
|
145145
|
+
HEAP32[buf + 20 >> 2] = stat.rdev;
|
|
145146
|
+
HEAP64[buf + 24 >> 3] = BigInt(stat.size);
|
|
145147
|
+
HEAP32[buf + 32 >> 2] = 4096;
|
|
145148
|
+
HEAP32[buf + 36 >> 2] = stat.blocks;
|
|
145149
|
+
var atime = stat.atime.getTime();
|
|
145150
|
+
var mtime = stat.mtime.getTime();
|
|
145151
|
+
var ctime = stat.ctime.getTime();
|
|
145152
|
+
HEAP64[buf + 40 >> 3] = BigInt(Math.floor(atime / 1e3));
|
|
145153
|
+
HEAPU32[buf + 48 >> 2] = atime % 1e3 * 1e3 * 1e3;
|
|
145154
|
+
HEAP64[buf + 56 >> 3] = BigInt(Math.floor(mtime / 1e3));
|
|
145155
|
+
HEAPU32[buf + 64 >> 2] = mtime % 1e3 * 1e3 * 1e3;
|
|
145156
|
+
HEAP64[buf + 72 >> 3] = BigInt(Math.floor(ctime / 1e3));
|
|
145157
|
+
HEAPU32[buf + 80 >> 2] = ctime % 1e3 * 1e3 * 1e3;
|
|
145158
|
+
HEAP64[buf + 88 >> 3] = BigInt(stat.ino);
|
|
145159
|
+
return 0;
|
|
145160
|
+
}, writeStatFs(buf, stats) {
|
|
145161
|
+
HEAP32[buf + 4 >> 2] = stats.bsize;
|
|
145162
|
+
HEAP32[buf + 40 >> 2] = stats.bsize;
|
|
145163
|
+
HEAP32[buf + 8 >> 2] = stats.blocks;
|
|
145164
|
+
HEAP32[buf + 12 >> 2] = stats.bfree;
|
|
145165
|
+
HEAP32[buf + 16 >> 2] = stats.bavail;
|
|
145166
|
+
HEAP32[buf + 20 >> 2] = stats.files;
|
|
145167
|
+
HEAP32[buf + 24 >> 2] = stats.ffree;
|
|
145168
|
+
HEAP32[buf + 28 >> 2] = stats.fsid;
|
|
145169
|
+
HEAP32[buf + 44 >> 2] = stats.flags;
|
|
145170
|
+
HEAP32[buf + 36 >> 2] = stats.namelen;
|
|
145171
|
+
}, doMsync(addr, stream, len, flags, offset) {
|
|
145172
|
+
if (!FS.isFile(stream.node.mode)) {
|
|
145173
|
+
throw new FS.ErrnoError(43);
|
|
145174
|
+
}
|
|
145175
|
+
if (flags & 2) {
|
|
145176
|
+
return 0;
|
|
145177
|
+
}
|
|
145178
|
+
var buffer = HEAPU8.slice(addr, addr + len);
|
|
145179
|
+
FS.msync(stream, buffer, offset, len, flags);
|
|
145180
|
+
}, getStreamFromFD(fd) {
|
|
145181
|
+
var stream = FS.getStreamChecked(fd);
|
|
145182
|
+
return stream;
|
|
145183
|
+
}, varargs: void 0, getStr(ptr) {
|
|
145184
|
+
var ret = UTF8ToString(ptr);
|
|
145185
|
+
return ret;
|
|
145186
|
+
} };
|
|
145187
|
+
function ___syscall_fcntl64(fd, cmd, varargs) {
|
|
145188
|
+
SYSCALLS.varargs = varargs;
|
|
145189
|
+
try {
|
|
145190
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
145191
|
+
switch (cmd) {
|
|
145192
|
+
case 0: {
|
|
145193
|
+
var arg = syscallGetVarargI();
|
|
145194
|
+
if (arg < 0) {
|
|
145195
|
+
return -28;
|
|
145196
|
+
}
|
|
145197
|
+
while (FS.streams[arg]) {
|
|
145198
|
+
arg++;
|
|
145199
|
+
}
|
|
145200
|
+
var newStream;
|
|
145201
|
+
newStream = FS.dupStream(stream, arg);
|
|
145202
|
+
return newStream.fd;
|
|
145203
|
+
}
|
|
145204
|
+
case 1:
|
|
145205
|
+
case 2:
|
|
145206
|
+
return 0;
|
|
145207
|
+
case 3:
|
|
145208
|
+
return stream.flags;
|
|
145209
|
+
case 4: {
|
|
145210
|
+
var arg = syscallGetVarargI();
|
|
145211
|
+
stream.flags |= arg;
|
|
145212
|
+
return 0;
|
|
145213
|
+
}
|
|
145214
|
+
case 12: {
|
|
145215
|
+
var arg = syscallGetVarargP();
|
|
145216
|
+
var offset = 0;
|
|
145217
|
+
HEAP16[arg + offset >> 1] = 2;
|
|
145218
|
+
return 0;
|
|
145219
|
+
}
|
|
145220
|
+
case 13:
|
|
145221
|
+
case 14:
|
|
145222
|
+
return 0;
|
|
145223
|
+
}
|
|
145224
|
+
return -28;
|
|
145225
|
+
} catch (e) {
|
|
145226
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145227
|
+
throw e;
|
|
145228
|
+
return -e.errno;
|
|
145229
|
+
}
|
|
145230
|
+
}
|
|
145231
|
+
function ___syscall_ioctl(fd, op, varargs) {
|
|
145232
|
+
SYSCALLS.varargs = varargs;
|
|
145233
|
+
try {
|
|
145234
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
145235
|
+
switch (op) {
|
|
145236
|
+
case 21509: {
|
|
145237
|
+
if (!stream.tty)
|
|
145238
|
+
return -59;
|
|
145239
|
+
return 0;
|
|
145240
|
+
}
|
|
145241
|
+
case 21505: {
|
|
145242
|
+
if (!stream.tty)
|
|
145243
|
+
return -59;
|
|
145244
|
+
if (stream.tty.ops.ioctl_tcgets) {
|
|
145245
|
+
var termios = stream.tty.ops.ioctl_tcgets(stream);
|
|
145246
|
+
var argp = syscallGetVarargP();
|
|
145247
|
+
HEAP32[argp >> 2] = termios.c_iflag || 0;
|
|
145248
|
+
HEAP32[argp + 4 >> 2] = termios.c_oflag || 0;
|
|
145249
|
+
HEAP32[argp + 8 >> 2] = termios.c_cflag || 0;
|
|
145250
|
+
HEAP32[argp + 12 >> 2] = termios.c_lflag || 0;
|
|
145251
|
+
for (var i = 0; i < 32; i++) {
|
|
145252
|
+
HEAP8[argp + i + 17] = termios.c_cc[i] || 0;
|
|
145253
|
+
}
|
|
145254
|
+
return 0;
|
|
145255
|
+
}
|
|
145256
|
+
return 0;
|
|
145257
|
+
}
|
|
145258
|
+
case 21510:
|
|
145259
|
+
case 21511:
|
|
145260
|
+
case 21512: {
|
|
145261
|
+
if (!stream.tty)
|
|
145262
|
+
return -59;
|
|
145263
|
+
return 0;
|
|
145264
|
+
}
|
|
145265
|
+
case 21506:
|
|
145266
|
+
case 21507:
|
|
145267
|
+
case 21508: {
|
|
145268
|
+
if (!stream.tty)
|
|
145269
|
+
return -59;
|
|
145270
|
+
if (stream.tty.ops.ioctl_tcsets) {
|
|
145271
|
+
var argp = syscallGetVarargP();
|
|
145272
|
+
var c_iflag = HEAP32[argp >> 2];
|
|
145273
|
+
var c_oflag = HEAP32[argp + 4 >> 2];
|
|
145274
|
+
var c_cflag = HEAP32[argp + 8 >> 2];
|
|
145275
|
+
var c_lflag = HEAP32[argp + 12 >> 2];
|
|
145276
|
+
var c_cc = [];
|
|
145277
|
+
for (var i = 0; i < 32; i++) {
|
|
145278
|
+
c_cc.push(HEAP8[argp + i + 17]);
|
|
145279
|
+
}
|
|
145280
|
+
return stream.tty.ops.ioctl_tcsets(stream.tty, op, { c_iflag, c_oflag, c_cflag, c_lflag, c_cc });
|
|
145281
|
+
}
|
|
145282
|
+
return 0;
|
|
145283
|
+
}
|
|
145284
|
+
case 21519: {
|
|
145285
|
+
if (!stream.tty)
|
|
145286
|
+
return -59;
|
|
145287
|
+
var argp = syscallGetVarargP();
|
|
145288
|
+
HEAP32[argp >> 2] = 0;
|
|
145289
|
+
return 0;
|
|
145290
|
+
}
|
|
145291
|
+
case 21520: {
|
|
145292
|
+
if (!stream.tty)
|
|
145293
|
+
return -59;
|
|
145294
|
+
return -28;
|
|
145295
|
+
}
|
|
145296
|
+
case 21531: {
|
|
145297
|
+
var argp = syscallGetVarargP();
|
|
145298
|
+
return FS.ioctl(stream, op, argp);
|
|
145299
|
+
}
|
|
145300
|
+
case 21523: {
|
|
145301
|
+
if (!stream.tty)
|
|
145302
|
+
return -59;
|
|
145303
|
+
if (stream.tty.ops.ioctl_tiocgwinsz) {
|
|
145304
|
+
var winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
|
|
145305
|
+
var argp = syscallGetVarargP();
|
|
145306
|
+
HEAP16[argp >> 1] = winsize[0];
|
|
145307
|
+
HEAP16[argp + 2 >> 1] = winsize[1];
|
|
145308
|
+
}
|
|
145309
|
+
return 0;
|
|
145310
|
+
}
|
|
145311
|
+
case 21524: {
|
|
145312
|
+
if (!stream.tty)
|
|
145313
|
+
return -59;
|
|
145314
|
+
return 0;
|
|
145315
|
+
}
|
|
145316
|
+
case 21515: {
|
|
145317
|
+
if (!stream.tty)
|
|
145318
|
+
return -59;
|
|
145319
|
+
return 0;
|
|
145320
|
+
}
|
|
145321
|
+
default:
|
|
145322
|
+
return -28;
|
|
145323
|
+
}
|
|
145324
|
+
} catch (e) {
|
|
145325
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145326
|
+
throw e;
|
|
145327
|
+
return -e.errno;
|
|
145328
|
+
}
|
|
145329
|
+
}
|
|
145330
|
+
function ___syscall_openat(dirfd, path, flags, varargs) {
|
|
145331
|
+
SYSCALLS.varargs = varargs;
|
|
145332
|
+
try {
|
|
145333
|
+
path = SYSCALLS.getStr(path);
|
|
145334
|
+
path = SYSCALLS.calculateAt(dirfd, path);
|
|
145335
|
+
var mode = varargs ? syscallGetVarargI() : 0;
|
|
145336
|
+
return FS.open(path, flags, mode).fd;
|
|
145337
|
+
} catch (e) {
|
|
145338
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145339
|
+
throw e;
|
|
145340
|
+
return -e.errno;
|
|
145341
|
+
}
|
|
145342
|
+
}
|
|
145343
|
+
function ___syscall_renameat(olddirfd, oldpath, newdirfd, newpath) {
|
|
145344
|
+
try {
|
|
145345
|
+
oldpath = SYSCALLS.getStr(oldpath);
|
|
145346
|
+
newpath = SYSCALLS.getStr(newpath);
|
|
145347
|
+
oldpath = SYSCALLS.calculateAt(olddirfd, oldpath);
|
|
145348
|
+
newpath = SYSCALLS.calculateAt(newdirfd, newpath);
|
|
145349
|
+
FS.rename(oldpath, newpath);
|
|
145350
|
+
return 0;
|
|
145351
|
+
} catch (e) {
|
|
145352
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145353
|
+
throw e;
|
|
145354
|
+
return -e.errno;
|
|
145355
|
+
}
|
|
145356
|
+
}
|
|
145357
|
+
function ___syscall_rmdir(path) {
|
|
145358
|
+
try {
|
|
145359
|
+
path = SYSCALLS.getStr(path);
|
|
145360
|
+
FS.rmdir(path);
|
|
145361
|
+
return 0;
|
|
145362
|
+
} catch (e) {
|
|
145363
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145364
|
+
throw e;
|
|
145365
|
+
return -e.errno;
|
|
145366
|
+
}
|
|
145367
|
+
}
|
|
145368
|
+
function ___syscall_stat64(path, buf) {
|
|
145369
|
+
try {
|
|
145370
|
+
path = SYSCALLS.getStr(path);
|
|
145371
|
+
return SYSCALLS.writeStat(buf, FS.stat(path));
|
|
145372
|
+
} catch (e) {
|
|
145373
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145374
|
+
throw e;
|
|
145375
|
+
return -e.errno;
|
|
145376
|
+
}
|
|
145377
|
+
}
|
|
145378
|
+
function ___syscall_unlinkat(dirfd, path, flags) {
|
|
145379
|
+
try {
|
|
145380
|
+
path = SYSCALLS.getStr(path);
|
|
145381
|
+
path = SYSCALLS.calculateAt(dirfd, path);
|
|
145382
|
+
if (flags === 0) {
|
|
145383
|
+
FS.unlink(path);
|
|
145384
|
+
} else if (flags === 512) {
|
|
145385
|
+
FS.rmdir(path);
|
|
145386
|
+
} else {
|
|
145387
|
+
abort("Invalid flags passed to unlinkat");
|
|
145388
|
+
}
|
|
145389
|
+
return 0;
|
|
145390
|
+
} catch (e) {
|
|
145391
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
145392
|
+
throw e;
|
|
145393
|
+
return -e.errno;
|
|
145394
|
+
}
|
|
145395
|
+
}
|
|
145396
|
+
var __abort_js = () => abort("");
|
|
145397
|
+
var structRegistrations = {};
|
|
145398
|
+
var runDestructors = (destructors) => {
|
|
145399
|
+
while (destructors.length) {
|
|
145400
|
+
var ptr = destructors.pop();
|
|
145401
|
+
var del = destructors.pop();
|
|
145402
|
+
del(ptr);
|
|
145403
|
+
}
|
|
145404
|
+
};
|
|
145405
|
+
function readPointer(pointer) {
|
|
145406
|
+
return this["fromWireType"](HEAPU32[pointer >> 2]);
|
|
145407
|
+
}
|
|
145408
|
+
var awaitingDependencies = {};
|
|
145409
|
+
var registeredTypes = {};
|
|
145410
|
+
var typeDependencies = {};
|
|
145411
|
+
var InternalError;
|
|
145412
|
+
var throwInternalError = (message) => {
|
|
145413
|
+
throw new InternalError(message);
|
|
145414
|
+
};
|
|
145415
|
+
var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
|
|
145416
|
+
myTypes.forEach((type) => typeDependencies[type] = dependentTypes);
|
|
145417
|
+
function onComplete(typeConverters2) {
|
|
145418
|
+
var myTypeConverters = getTypeConverters(typeConverters2);
|
|
145419
|
+
if (myTypeConverters.length !== myTypes.length) {
|
|
145420
|
+
throwInternalError("Mismatched type converter count");
|
|
145421
|
+
}
|
|
145422
|
+
for (var i = 0; i < myTypes.length; ++i) {
|
|
145423
|
+
registerType(myTypes[i], myTypeConverters[i]);
|
|
145424
|
+
}
|
|
145425
|
+
}
|
|
145426
|
+
var typeConverters = new Array(dependentTypes.length);
|
|
145427
|
+
var unregisteredTypes = [];
|
|
145428
|
+
var registered = 0;
|
|
145429
|
+
dependentTypes.forEach((dt, i) => {
|
|
145430
|
+
if (registeredTypes.hasOwnProperty(dt)) {
|
|
145431
|
+
typeConverters[i] = registeredTypes[dt];
|
|
145432
|
+
} else {
|
|
145433
|
+
unregisteredTypes.push(dt);
|
|
145434
|
+
if (!awaitingDependencies.hasOwnProperty(dt)) {
|
|
145435
|
+
awaitingDependencies[dt] = [];
|
|
145436
|
+
}
|
|
145437
|
+
awaitingDependencies[dt].push(() => {
|
|
145438
|
+
typeConverters[i] = registeredTypes[dt];
|
|
145439
|
+
++registered;
|
|
145440
|
+
if (registered === unregisteredTypes.length) {
|
|
145441
|
+
onComplete(typeConverters);
|
|
145442
|
+
}
|
|
145443
|
+
});
|
|
145444
|
+
}
|
|
145445
|
+
});
|
|
145446
|
+
if (0 === unregisteredTypes.length) {
|
|
145447
|
+
onComplete(typeConverters);
|
|
145448
|
+
}
|
|
145449
|
+
};
|
|
145450
|
+
var __embind_finalize_value_object = (structType) => {
|
|
145451
|
+
var reg = structRegistrations[structType];
|
|
145452
|
+
delete structRegistrations[structType];
|
|
145453
|
+
var rawConstructor = reg.rawConstructor;
|
|
145454
|
+
var rawDestructor = reg.rawDestructor;
|
|
145455
|
+
var fieldRecords = reg.fields;
|
|
145456
|
+
var fieldTypes = fieldRecords.map((field) => field.getterReturnType).concat(fieldRecords.map((field) => field.setterArgumentType));
|
|
145457
|
+
whenDependentTypesAreResolved([structType], fieldTypes, (fieldTypes2) => {
|
|
145458
|
+
var fields = {};
|
|
145459
|
+
fieldRecords.forEach((field, i) => {
|
|
145460
|
+
var fieldName = field.fieldName;
|
|
145461
|
+
var getterReturnType = fieldTypes2[i];
|
|
145462
|
+
var getter = field.getter;
|
|
145463
|
+
var getterContext = field.getterContext;
|
|
145464
|
+
var setterArgumentType = fieldTypes2[i + fieldRecords.length];
|
|
145465
|
+
var setter = field.setter;
|
|
145466
|
+
var setterContext = field.setterContext;
|
|
145467
|
+
fields[fieldName] = { read: (ptr) => getterReturnType["fromWireType"](getter(getterContext, ptr)), write: (ptr, o) => {
|
|
145468
|
+
var destructors = [];
|
|
145469
|
+
setter(setterContext, ptr, setterArgumentType["toWireType"](destructors, o));
|
|
145470
|
+
runDestructors(destructors);
|
|
145471
|
+
} };
|
|
145472
|
+
});
|
|
145473
|
+
return [{ name: reg.name, fromWireType: (ptr) => {
|
|
145474
|
+
var rv = {};
|
|
145475
|
+
for (var i in fields) {
|
|
145476
|
+
rv[i] = fields[i].read(ptr);
|
|
145477
|
+
}
|
|
145478
|
+
rawDestructor(ptr);
|
|
145479
|
+
return rv;
|
|
145480
|
+
}, toWireType: (destructors, o) => {
|
|
145481
|
+
for (var fieldName in fields) {
|
|
145482
|
+
if (!(fieldName in o)) {
|
|
145483
|
+
throw new TypeError(`Missing field: "${fieldName}"`);
|
|
145484
|
+
}
|
|
145485
|
+
}
|
|
145486
|
+
var ptr = rawConstructor();
|
|
145487
|
+
for (fieldName in fields) {
|
|
145488
|
+
fields[fieldName].write(ptr, o[fieldName]);
|
|
145489
|
+
}
|
|
145490
|
+
if (destructors !== null) {
|
|
145491
|
+
destructors.push(rawDestructor, ptr);
|
|
145492
|
+
}
|
|
145493
|
+
return ptr;
|
|
145494
|
+
}, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction: rawDestructor }];
|
|
145495
|
+
});
|
|
145496
|
+
};
|
|
145497
|
+
var embindRepr = (v) => {
|
|
145498
|
+
if (v === null) {
|
|
145499
|
+
return "null";
|
|
145500
|
+
}
|
|
145501
|
+
var t = typeof v;
|
|
145502
|
+
if (t === "object" || t === "array" || t === "function") {
|
|
145503
|
+
return v.toString();
|
|
145504
|
+
} else {
|
|
145505
|
+
return "" + v;
|
|
145506
|
+
}
|
|
145507
|
+
};
|
|
145508
|
+
var embind_init_charCodes = () => {
|
|
145509
|
+
var codes = new Array(256);
|
|
145510
|
+
for (var i = 0; i < 256; ++i) {
|
|
145511
|
+
codes[i] = String.fromCharCode(i);
|
|
145512
|
+
}
|
|
145513
|
+
embind_charCodes = codes;
|
|
145514
|
+
};
|
|
145515
|
+
var embind_charCodes;
|
|
145516
|
+
var readLatin1String = (ptr) => {
|
|
145517
|
+
var ret = "";
|
|
145518
|
+
var c = ptr;
|
|
145519
|
+
while (HEAPU8[c]) {
|
|
145520
|
+
ret += embind_charCodes[HEAPU8[c++]];
|
|
145521
|
+
}
|
|
145522
|
+
return ret;
|
|
145523
|
+
};
|
|
145524
|
+
var BindingError;
|
|
145525
|
+
var throwBindingError = (message) => {
|
|
145526
|
+
throw new BindingError(message);
|
|
145527
|
+
};
|
|
145528
|
+
function sharedRegisterType(rawType, registeredInstance, options = {}) {
|
|
145529
|
+
var name = registeredInstance.name;
|
|
145530
|
+
if (!rawType) {
|
|
145531
|
+
throwBindingError(`type "${name}" must have a positive integer typeid pointer`);
|
|
145532
|
+
}
|
|
145533
|
+
if (registeredTypes.hasOwnProperty(rawType)) {
|
|
145534
|
+
if (options.ignoreDuplicateRegistrations) {
|
|
145535
|
+
return;
|
|
145536
|
+
} else {
|
|
145537
|
+
throwBindingError(`Cannot register type '${name}' twice`);
|
|
145538
|
+
}
|
|
145539
|
+
}
|
|
145540
|
+
registeredTypes[rawType] = registeredInstance;
|
|
145541
|
+
delete typeDependencies[rawType];
|
|
145542
|
+
if (awaitingDependencies.hasOwnProperty(rawType)) {
|
|
145543
|
+
var callbacks = awaitingDependencies[rawType];
|
|
145544
|
+
delete awaitingDependencies[rawType];
|
|
145545
|
+
callbacks.forEach((cb) => cb());
|
|
145546
|
+
}
|
|
145547
|
+
}
|
|
145548
|
+
function registerType(rawType, registeredInstance, options = {}) {
|
|
145549
|
+
return sharedRegisterType(rawType, registeredInstance, options);
|
|
145550
|
+
}
|
|
145551
|
+
var integerReadValueFromPointer = (name, width, signed) => {
|
|
145552
|
+
switch (width) {
|
|
145553
|
+
case 1:
|
|
145554
|
+
return signed ? (pointer) => HEAP8[pointer] : (pointer) => HEAPU8[pointer];
|
|
145555
|
+
case 2:
|
|
145556
|
+
return signed ? (pointer) => HEAP16[pointer >> 1] : (pointer) => HEAPU16[pointer >> 1];
|
|
145557
|
+
case 4:
|
|
145558
|
+
return signed ? (pointer) => HEAP32[pointer >> 2] : (pointer) => HEAPU32[pointer >> 2];
|
|
145559
|
+
case 8:
|
|
145560
|
+
return signed ? (pointer) => HEAP64[pointer >> 3] : (pointer) => HEAPU64[pointer >> 3];
|
|
145561
|
+
default:
|
|
145562
|
+
throw new TypeError(`invalid integer width (${width}): ${name}`);
|
|
145563
|
+
}
|
|
145564
|
+
};
|
|
145565
|
+
var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => {
|
|
145566
|
+
name = readLatin1String(name);
|
|
145567
|
+
var isUnsignedType = name.indexOf("u") != -1;
|
|
145568
|
+
registerType(primitiveType, { name, fromWireType: (value) => value, toWireType: function(destructors, value) {
|
|
145569
|
+
if (typeof value != "bigint" && typeof value != "number") {
|
|
145570
|
+
throw new TypeError(`Cannot convert "${embindRepr(value)}" to ${this.name}`);
|
|
145571
|
+
}
|
|
145572
|
+
if (typeof value == "number") {
|
|
145573
|
+
value = BigInt(value);
|
|
145574
|
+
}
|
|
145575
|
+
return value;
|
|
145576
|
+
}, argPackAdvance: GenericWireTypeSize, readValueFromPointer: integerReadValueFromPointer(name, size, !isUnsignedType), destructorFunction: null });
|
|
145577
|
+
};
|
|
145578
|
+
var GenericWireTypeSize = 8;
|
|
145579
|
+
var __embind_register_bool = (rawType, name, trueValue, falseValue) => {
|
|
145580
|
+
name = readLatin1String(name);
|
|
145581
|
+
registerType(rawType, { name, fromWireType: function(wt) {
|
|
145582
|
+
return !!wt;
|
|
145583
|
+
}, toWireType: function(destructors, o) {
|
|
145584
|
+
return o ? trueValue : falseValue;
|
|
145585
|
+
}, argPackAdvance: GenericWireTypeSize, readValueFromPointer: function(pointer) {
|
|
145586
|
+
return this["fromWireType"](HEAPU8[pointer]);
|
|
145587
|
+
}, destructorFunction: null });
|
|
145588
|
+
};
|
|
145589
|
+
var emval_freelist = [];
|
|
145590
|
+
var emval_handles = [];
|
|
145591
|
+
var __emval_decref = (handle) => {
|
|
145592
|
+
if (handle > 9 && 0 === --emval_handles[handle + 1]) {
|
|
145593
|
+
emval_handles[handle] = void 0;
|
|
145594
|
+
emval_freelist.push(handle);
|
|
145595
|
+
}
|
|
145596
|
+
};
|
|
145597
|
+
var count_emval_handles = () => emval_handles.length / 2 - 5 - emval_freelist.length;
|
|
145598
|
+
var init_emval = () => {
|
|
145599
|
+
emval_handles.push(0, 1, void 0, 1, null, 1, true, 1, false, 1);
|
|
145600
|
+
Module["count_emval_handles"] = count_emval_handles;
|
|
145601
|
+
};
|
|
145602
|
+
var Emval = { toValue: (handle) => {
|
|
145603
|
+
if (!handle) {
|
|
145604
|
+
throwBindingError("Cannot use deleted val. handle = " + handle);
|
|
145605
|
+
}
|
|
145606
|
+
return emval_handles[handle];
|
|
145607
|
+
}, toHandle: (value) => {
|
|
145608
|
+
switch (value) {
|
|
145609
|
+
case void 0:
|
|
145610
|
+
return 2;
|
|
145611
|
+
case null:
|
|
145612
|
+
return 4;
|
|
145613
|
+
case true:
|
|
145614
|
+
return 6;
|
|
145615
|
+
case false:
|
|
145616
|
+
return 8;
|
|
145617
|
+
default: {
|
|
145618
|
+
const handle = emval_freelist.pop() || emval_handles.length;
|
|
145619
|
+
emval_handles[handle] = value;
|
|
145620
|
+
emval_handles[handle + 1] = 1;
|
|
145621
|
+
return handle;
|
|
145622
|
+
}
|
|
145623
|
+
}
|
|
145624
|
+
} };
|
|
145625
|
+
var EmValType = { name: "emscripten::val", fromWireType: (handle) => {
|
|
145626
|
+
var rv = Emval.toValue(handle);
|
|
145627
|
+
__emval_decref(handle);
|
|
145628
|
+
return rv;
|
|
145629
|
+
}, toWireType: (destructors, value) => Emval.toHandle(value), argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction: null };
|
|
145630
|
+
var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
|
|
145631
|
+
var floatReadValueFromPointer = (name, width) => {
|
|
145632
|
+
switch (width) {
|
|
145633
|
+
case 4:
|
|
145634
|
+
return function(pointer) {
|
|
145635
|
+
return this["fromWireType"](HEAPF32[pointer >> 2]);
|
|
145636
|
+
};
|
|
145637
|
+
case 8:
|
|
145638
|
+
return function(pointer) {
|
|
145639
|
+
return this["fromWireType"](HEAPF64[pointer >> 3]);
|
|
145640
|
+
};
|
|
145641
|
+
default:
|
|
145642
|
+
throw new TypeError(`invalid float width (${width}): ${name}`);
|
|
145643
|
+
}
|
|
145644
|
+
};
|
|
145645
|
+
var __embind_register_float = (rawType, name, size) => {
|
|
145646
|
+
name = readLatin1String(name);
|
|
145647
|
+
registerType(rawType, { name, fromWireType: (value) => value, toWireType: (destructors, value) => value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: floatReadValueFromPointer(name, size), destructorFunction: null });
|
|
145648
|
+
};
|
|
145649
|
+
var createNamedFunction = (name, body) => Object.defineProperty(body, "name", { value: name });
|
|
145650
|
+
function usesDestructorStack(argTypes) {
|
|
145651
|
+
for (var i = 1; i < argTypes.length; ++i) {
|
|
145652
|
+
if (argTypes[i] !== null && argTypes[i].destructorFunction === void 0) {
|
|
145653
|
+
return true;
|
|
145654
|
+
}
|
|
145655
|
+
}
|
|
145656
|
+
return false;
|
|
145657
|
+
}
|
|
145658
|
+
function newFunc(constructor, argumentList) {
|
|
145659
|
+
if (!(constructor instanceof Function)) {
|
|
145660
|
+
throw new TypeError(`new_ called with constructor type ${typeof constructor} which is not a function`);
|
|
145661
|
+
}
|
|
145662
|
+
var dummy = createNamedFunction(constructor.name || "unknownFunctionName", function() {
|
|
145663
|
+
});
|
|
145664
|
+
dummy.prototype = constructor.prototype;
|
|
145665
|
+
var obj = new dummy();
|
|
145666
|
+
var r = constructor.apply(obj, argumentList);
|
|
145667
|
+
return r instanceof Object ? r : obj;
|
|
145668
|
+
}
|
|
145669
|
+
function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
|
|
145670
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
145671
|
+
var argCount = argTypes.length - 2;
|
|
145672
|
+
var argsList = [];
|
|
145673
|
+
var argsListWired = ["fn"];
|
|
145674
|
+
if (isClassMethodFunc) {
|
|
145675
|
+
argsListWired.push("thisWired");
|
|
145676
|
+
}
|
|
145677
|
+
for (var i = 0; i < argCount; ++i) {
|
|
145678
|
+
argsList.push(`arg${i}`);
|
|
145679
|
+
argsListWired.push(`arg${i}Wired`);
|
|
145680
|
+
}
|
|
145681
|
+
argsList = argsList.join(",");
|
|
145682
|
+
argsListWired = argsListWired.join(",");
|
|
145683
|
+
var invokerFnBody = `return function (${argsList}) {
|
|
145684
|
+
`;
|
|
145685
|
+
if (needsDestructorStack) {
|
|
145686
|
+
invokerFnBody += "var destructors = [];\n";
|
|
145687
|
+
}
|
|
145688
|
+
var dtorStack = needsDestructorStack ? "destructors" : "null";
|
|
145689
|
+
var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
145690
|
+
if (isClassMethodFunc) {
|
|
145691
|
+
invokerFnBody += `var thisWired = classParam['toWireType'](${dtorStack}, this);
|
|
145692
|
+
`;
|
|
145693
|
+
}
|
|
145694
|
+
for (var i = 0; i < argCount; ++i) {
|
|
145695
|
+
invokerFnBody += `var arg${i}Wired = argType${i}['toWireType'](${dtorStack}, arg${i});
|
|
145696
|
+
`;
|
|
145697
|
+
args1.push(`argType${i}`);
|
|
145698
|
+
}
|
|
145699
|
+
invokerFnBody += (returns || isAsync ? "var rv = " : "") + `invoker(${argsListWired});
|
|
145700
|
+
`;
|
|
145701
|
+
var returnVal = returns ? "rv" : "";
|
|
145702
|
+
args1.push("Asyncify");
|
|
145703
|
+
invokerFnBody += `function onDone(${returnVal}) {
|
|
145704
|
+
`;
|
|
145705
|
+
if (needsDestructorStack) {
|
|
145706
|
+
invokerFnBody += "runDestructors(destructors);\n";
|
|
145707
|
+
} else {
|
|
145708
|
+
for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) {
|
|
145709
|
+
var paramName = i === 1 ? "thisWired" : "arg" + (i - 2) + "Wired";
|
|
145710
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
145711
|
+
invokerFnBody += `${paramName}_dtor(${paramName});
|
|
145712
|
+
`;
|
|
145713
|
+
args1.push(`${paramName}_dtor`);
|
|
145714
|
+
}
|
|
145715
|
+
}
|
|
145716
|
+
}
|
|
145717
|
+
if (returns) {
|
|
145718
|
+
invokerFnBody += "var ret = retType['fromWireType'](rv);\nreturn ret;\n";
|
|
145719
|
+
}
|
|
145720
|
+
invokerFnBody += "}\n";
|
|
145721
|
+
invokerFnBody += `return Asyncify.currData ? Asyncify.whenDone().then(onDone) : onDone(${returnVal});
|
|
145722
|
+
`;
|
|
145723
|
+
invokerFnBody += "}\n";
|
|
145724
|
+
return [args1, invokerFnBody];
|
|
145725
|
+
}
|
|
145726
|
+
var runAndAbortIfError = (func) => {
|
|
145727
|
+
try {
|
|
145728
|
+
return func();
|
|
145729
|
+
} catch (e) {
|
|
145730
|
+
abort(e);
|
|
145731
|
+
}
|
|
145732
|
+
};
|
|
145733
|
+
var handleException = (e) => {
|
|
145734
|
+
if (e instanceof ExitStatus || e == "unwind") {
|
|
145735
|
+
return EXITSTATUS;
|
|
145736
|
+
}
|
|
145737
|
+
quit_(1, e);
|
|
145738
|
+
};
|
|
145739
|
+
var runtimeKeepaliveCounter = 0;
|
|
145740
|
+
var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
145741
|
+
var _proc_exit = (code) => {
|
|
145742
|
+
EXITSTATUS = code;
|
|
145743
|
+
if (!keepRuntimeAlive()) {
|
|
145744
|
+
Module["onExit"]?.(code);
|
|
145745
|
+
ABORT = true;
|
|
145746
|
+
}
|
|
145747
|
+
quit_(code, new ExitStatus(code));
|
|
145748
|
+
};
|
|
145749
|
+
var exitJS = (status, implicit) => {
|
|
145750
|
+
EXITSTATUS = status;
|
|
145751
|
+
_proc_exit(status);
|
|
145752
|
+
};
|
|
145753
|
+
var _exit = exitJS;
|
|
145754
|
+
var maybeExit = () => {
|
|
145755
|
+
if (!keepRuntimeAlive()) {
|
|
145756
|
+
try {
|
|
145757
|
+
_exit(EXITSTATUS);
|
|
145758
|
+
} catch (e) {
|
|
145759
|
+
handleException(e);
|
|
145760
|
+
}
|
|
145761
|
+
}
|
|
145762
|
+
};
|
|
145763
|
+
var callUserCallback = (func) => {
|
|
145764
|
+
if (ABORT) {
|
|
145765
|
+
return;
|
|
145766
|
+
}
|
|
145767
|
+
try {
|
|
145768
|
+
func();
|
|
145769
|
+
maybeExit();
|
|
145770
|
+
} catch (e) {
|
|
145771
|
+
handleException(e);
|
|
145772
|
+
}
|
|
145773
|
+
};
|
|
145774
|
+
var Asyncify = { instrumentWasmImports(imports) {
|
|
145775
|
+
var importPattern = /^(invoke_.*|__asyncjs__.*)$/;
|
|
145776
|
+
for (let [x, original] of Object.entries(imports)) {
|
|
145777
|
+
if (typeof original == "function") {
|
|
145778
|
+
original.isAsync || importPattern.test(x);
|
|
145779
|
+
}
|
|
145780
|
+
}
|
|
145781
|
+
}, instrumentWasmExports(exports) {
|
|
145782
|
+
var ret = {};
|
|
145783
|
+
for (let [x, original] of Object.entries(exports)) {
|
|
145784
|
+
if (typeof original == "function") {
|
|
145785
|
+
ret[x] = (...args) => {
|
|
145786
|
+
Asyncify.exportCallStack.push(x);
|
|
145787
|
+
try {
|
|
145788
|
+
return original(...args);
|
|
145789
|
+
} finally {
|
|
145790
|
+
if (!ABORT) {
|
|
145791
|
+
Asyncify.exportCallStack.pop();
|
|
145792
|
+
Asyncify.maybeStopUnwind();
|
|
145793
|
+
}
|
|
145794
|
+
}
|
|
145795
|
+
};
|
|
145796
|
+
} else {
|
|
145797
|
+
ret[x] = original;
|
|
145798
|
+
}
|
|
145799
|
+
}
|
|
145800
|
+
return ret;
|
|
145801
|
+
}, State: { Normal: 0, Unwinding: 1, Rewinding: 2, Disabled: 3 }, state: 0, StackSize: 4096, currData: null, handleSleepReturnValue: 0, exportCallStack: [], callStackNameToId: {}, callStackIdToName: {}, callStackId: 0, asyncPromiseHandlers: null, sleepCallbacks: [], getCallStackId(funcName) {
|
|
145802
|
+
var id = Asyncify.callStackNameToId[funcName];
|
|
145803
|
+
if (id === void 0) {
|
|
145804
|
+
id = Asyncify.callStackId++;
|
|
145805
|
+
Asyncify.callStackNameToId[funcName] = id;
|
|
145806
|
+
Asyncify.callStackIdToName[id] = funcName;
|
|
145807
|
+
}
|
|
145808
|
+
return id;
|
|
145809
|
+
}, maybeStopUnwind() {
|
|
145810
|
+
if (Asyncify.currData && Asyncify.state === Asyncify.State.Unwinding && Asyncify.exportCallStack.length === 0) {
|
|
145811
|
+
Asyncify.state = Asyncify.State.Normal;
|
|
145812
|
+
runAndAbortIfError(_asyncify_stop_unwind);
|
|
145813
|
+
if (typeof Fibers != "undefined") {
|
|
145814
|
+
Fibers.trampoline();
|
|
145815
|
+
}
|
|
145816
|
+
}
|
|
145817
|
+
}, whenDone() {
|
|
145818
|
+
return new Promise((resolve, reject) => {
|
|
145819
|
+
Asyncify.asyncPromiseHandlers = { resolve, reject };
|
|
145820
|
+
});
|
|
145821
|
+
}, allocateData() {
|
|
145822
|
+
var ptr = _malloc(12 + Asyncify.StackSize);
|
|
145823
|
+
Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize);
|
|
145824
|
+
Asyncify.setDataRewindFunc(ptr);
|
|
145825
|
+
return ptr;
|
|
145826
|
+
}, setDataHeader(ptr, stack, stackSize) {
|
|
145827
|
+
HEAPU32[ptr >> 2] = stack;
|
|
145828
|
+
HEAPU32[ptr + 4 >> 2] = stack + stackSize;
|
|
145829
|
+
}, setDataRewindFunc(ptr) {
|
|
145830
|
+
var bottomOfCallStack = Asyncify.exportCallStack[0];
|
|
145831
|
+
var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
|
|
145832
|
+
HEAP32[ptr + 8 >> 2] = rewindId;
|
|
145833
|
+
}, getDataRewindFuncName(ptr) {
|
|
145834
|
+
var id = HEAP32[ptr + 8 >> 2];
|
|
145835
|
+
var name = Asyncify.callStackIdToName[id];
|
|
145836
|
+
return name;
|
|
145837
|
+
}, getDataRewindFunc(name) {
|
|
145838
|
+
var func = wasmExports[name];
|
|
145839
|
+
return func;
|
|
145840
|
+
}, doRewind(ptr) {
|
|
145841
|
+
var name = Asyncify.getDataRewindFuncName(ptr);
|
|
145842
|
+
var func = Asyncify.getDataRewindFunc(name);
|
|
145843
|
+
return func();
|
|
145844
|
+
}, handleSleep(startAsync) {
|
|
145845
|
+
if (ABORT)
|
|
145846
|
+
return;
|
|
145847
|
+
if (Asyncify.state === Asyncify.State.Normal) {
|
|
145848
|
+
var reachedCallback = false;
|
|
145849
|
+
var reachedAfterCallback = false;
|
|
145850
|
+
startAsync((handleSleepReturnValue = 0) => {
|
|
145851
|
+
if (ABORT)
|
|
145852
|
+
return;
|
|
145853
|
+
Asyncify.handleSleepReturnValue = handleSleepReturnValue;
|
|
145854
|
+
reachedCallback = true;
|
|
145855
|
+
if (!reachedAfterCallback) {
|
|
145856
|
+
return;
|
|
145857
|
+
}
|
|
145858
|
+
Asyncify.state = Asyncify.State.Rewinding;
|
|
145859
|
+
runAndAbortIfError(() => _asyncify_start_rewind(Asyncify.currData));
|
|
145860
|
+
if (typeof MainLoop != "undefined" && MainLoop.func) {
|
|
145861
|
+
MainLoop.resume();
|
|
145862
|
+
}
|
|
145863
|
+
var asyncWasmReturnValue, isError = false;
|
|
145864
|
+
try {
|
|
145865
|
+
asyncWasmReturnValue = Asyncify.doRewind(Asyncify.currData);
|
|
145866
|
+
} catch (err2) {
|
|
145867
|
+
asyncWasmReturnValue = err2;
|
|
145868
|
+
isError = true;
|
|
145869
|
+
}
|
|
145870
|
+
var handled = false;
|
|
145871
|
+
if (!Asyncify.currData) {
|
|
145872
|
+
var asyncPromiseHandlers = Asyncify.asyncPromiseHandlers;
|
|
145873
|
+
if (asyncPromiseHandlers) {
|
|
145874
|
+
Asyncify.asyncPromiseHandlers = null;
|
|
145875
|
+
(isError ? asyncPromiseHandlers.reject : asyncPromiseHandlers.resolve)(asyncWasmReturnValue);
|
|
145876
|
+
handled = true;
|
|
145877
|
+
}
|
|
145878
|
+
}
|
|
145879
|
+
if (isError && !handled) {
|
|
145880
|
+
throw asyncWasmReturnValue;
|
|
145881
|
+
}
|
|
145882
|
+
});
|
|
145883
|
+
reachedAfterCallback = true;
|
|
145884
|
+
if (!reachedCallback) {
|
|
145885
|
+
Asyncify.state = Asyncify.State.Unwinding;
|
|
145886
|
+
Asyncify.currData = Asyncify.allocateData();
|
|
145887
|
+
if (typeof MainLoop != "undefined" && MainLoop.func) {
|
|
145888
|
+
MainLoop.pause();
|
|
145889
|
+
}
|
|
145890
|
+
runAndAbortIfError(() => _asyncify_start_unwind(Asyncify.currData));
|
|
145891
|
+
}
|
|
145892
|
+
} else if (Asyncify.state === Asyncify.State.Rewinding) {
|
|
145893
|
+
Asyncify.state = Asyncify.State.Normal;
|
|
145894
|
+
runAndAbortIfError(_asyncify_stop_rewind);
|
|
145895
|
+
_free(Asyncify.currData);
|
|
145896
|
+
Asyncify.currData = null;
|
|
145897
|
+
Asyncify.sleepCallbacks.forEach(callUserCallback);
|
|
145898
|
+
} else {
|
|
145899
|
+
abort(`invalid state: ${Asyncify.state}`);
|
|
145900
|
+
}
|
|
145901
|
+
return Asyncify.handleSleepReturnValue;
|
|
145902
|
+
}, handleAsync(startAsync) {
|
|
145903
|
+
return Asyncify.handleSleep((wakeUp) => {
|
|
145904
|
+
startAsync().then(wakeUp);
|
|
145905
|
+
});
|
|
145906
|
+
} };
|
|
145907
|
+
function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, isAsync) {
|
|
145908
|
+
var argCount = argTypes.length;
|
|
145909
|
+
if (argCount < 2) {
|
|
145910
|
+
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
145911
|
+
}
|
|
145912
|
+
var isClassMethodFunc = argTypes[1] !== null && classType !== null;
|
|
145913
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
145914
|
+
var returns = argTypes[0].name !== "void";
|
|
145915
|
+
var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
145916
|
+
for (var i = 0; i < argCount - 2; ++i) {
|
|
145917
|
+
closureArgs.push(argTypes[i + 2]);
|
|
145918
|
+
}
|
|
145919
|
+
closureArgs.push(Asyncify);
|
|
145920
|
+
if (!needsDestructorStack) {
|
|
145921
|
+
for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) {
|
|
145922
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
145923
|
+
closureArgs.push(argTypes[i].destructorFunction);
|
|
145924
|
+
}
|
|
145925
|
+
}
|
|
145926
|
+
}
|
|
145927
|
+
let [args, invokerFnBody] = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
|
|
145928
|
+
args.push(invokerFnBody);
|
|
145929
|
+
var invokerFn = newFunc(Function, args)(...closureArgs);
|
|
145930
|
+
return createNamedFunction(humanName, invokerFn);
|
|
145931
|
+
}
|
|
145932
|
+
var ensureOverloadTable = (proto, methodName, humanName) => {
|
|
145933
|
+
if (void 0 === proto[methodName].overloadTable) {
|
|
145934
|
+
var prevFunc = proto[methodName];
|
|
145935
|
+
proto[methodName] = function(...args) {
|
|
145936
|
+
if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
|
|
145937
|
+
throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
|
|
145938
|
+
}
|
|
145939
|
+
return proto[methodName].overloadTable[args.length].apply(this, args);
|
|
145940
|
+
};
|
|
145941
|
+
proto[methodName].overloadTable = [];
|
|
145942
|
+
proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
|
|
145943
|
+
}
|
|
145944
|
+
};
|
|
145945
|
+
var exposePublicSymbol = (name, value, numArguments) => {
|
|
145946
|
+
if (Module.hasOwnProperty(name)) {
|
|
145947
|
+
if (void 0 === numArguments || void 0 !== Module[name].overloadTable && void 0 !== Module[name].overloadTable[numArguments]) {
|
|
145948
|
+
throwBindingError(`Cannot register public name '${name}' twice`);
|
|
145949
|
+
}
|
|
145950
|
+
ensureOverloadTable(Module, name, name);
|
|
145951
|
+
if (Module[name].overloadTable.hasOwnProperty(numArguments)) {
|
|
145952
|
+
throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
|
|
145953
|
+
}
|
|
145954
|
+
Module[name].overloadTable[numArguments] = value;
|
|
145955
|
+
} else {
|
|
145956
|
+
Module[name] = value;
|
|
145957
|
+
Module[name].argCount = numArguments;
|
|
145958
|
+
}
|
|
145959
|
+
};
|
|
145960
|
+
var heap32VectorToArray = (count, firstElement) => {
|
|
145961
|
+
var array = [];
|
|
145962
|
+
for (var i = 0; i < count; i++) {
|
|
145963
|
+
array.push(HEAPU32[firstElement + i * 4 >> 2]);
|
|
145964
|
+
}
|
|
145965
|
+
return array;
|
|
145966
|
+
};
|
|
145967
|
+
var replacePublicSymbol = (name, value, numArguments) => {
|
|
145968
|
+
if (!Module.hasOwnProperty(name)) {
|
|
145969
|
+
throwInternalError("Replacing nonexistent public symbol");
|
|
145970
|
+
}
|
|
145971
|
+
if (void 0 !== Module[name].overloadTable && void 0 !== numArguments) {
|
|
145972
|
+
Module[name].overloadTable[numArguments] = value;
|
|
145973
|
+
} else {
|
|
145974
|
+
Module[name] = value;
|
|
145975
|
+
Module[name].argCount = numArguments;
|
|
145976
|
+
}
|
|
145977
|
+
};
|
|
145978
|
+
var dynCallLegacy = (sig, ptr, args) => {
|
|
145979
|
+
sig = sig.replace(/p/g, "i");
|
|
145980
|
+
var f = Module["dynCall_" + sig];
|
|
145981
|
+
return f(ptr, ...args);
|
|
145982
|
+
};
|
|
145983
|
+
var dynCall = (sig, ptr, args = []) => {
|
|
145984
|
+
var rtn = dynCallLegacy(sig, ptr, args);
|
|
145985
|
+
return rtn;
|
|
145986
|
+
};
|
|
145987
|
+
var getDynCaller = (sig, ptr) => (...args) => dynCall(sig, ptr, args);
|
|
145988
|
+
var embind__requireFunction = (signature, rawFunction) => {
|
|
145989
|
+
signature = readLatin1String(signature);
|
|
145990
|
+
function makeDynCaller() {
|
|
145991
|
+
return getDynCaller(signature, rawFunction);
|
|
145992
|
+
}
|
|
145993
|
+
var fp = makeDynCaller();
|
|
145994
|
+
if (typeof fp != "function") {
|
|
145995
|
+
throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`);
|
|
145996
|
+
}
|
|
145997
|
+
return fp;
|
|
145998
|
+
};
|
|
145999
|
+
var extendError = (baseErrorType, errorName) => {
|
|
146000
|
+
var errorClass = createNamedFunction(errorName, function(message) {
|
|
146001
|
+
this.name = errorName;
|
|
146002
|
+
this.message = message;
|
|
146003
|
+
var stack = new Error(message).stack;
|
|
146004
|
+
if (stack !== void 0) {
|
|
146005
|
+
this.stack = this.toString() + "\n" + stack.replace(/^Error(:[^\n]*)?\n/, "");
|
|
146006
|
+
}
|
|
146007
|
+
});
|
|
146008
|
+
errorClass.prototype = Object.create(baseErrorType.prototype);
|
|
146009
|
+
errorClass.prototype.constructor = errorClass;
|
|
146010
|
+
errorClass.prototype.toString = function() {
|
|
146011
|
+
if (this.message === void 0) {
|
|
146012
|
+
return this.name;
|
|
146013
|
+
} else {
|
|
146014
|
+
return `${this.name}: ${this.message}`;
|
|
146015
|
+
}
|
|
146016
|
+
};
|
|
146017
|
+
return errorClass;
|
|
146018
|
+
};
|
|
146019
|
+
var UnboundTypeError;
|
|
146020
|
+
var getTypeName = (type) => {
|
|
146021
|
+
var ptr = ___getTypeName(type);
|
|
146022
|
+
var rv = readLatin1String(ptr);
|
|
146023
|
+
_free(ptr);
|
|
146024
|
+
return rv;
|
|
146025
|
+
};
|
|
146026
|
+
var throwUnboundTypeError = (message, types) => {
|
|
146027
|
+
var unboundTypes = [];
|
|
146028
|
+
var seen = {};
|
|
146029
|
+
function visit(type) {
|
|
146030
|
+
if (seen[type]) {
|
|
146031
|
+
return;
|
|
146032
|
+
}
|
|
146033
|
+
if (registeredTypes[type]) {
|
|
146034
|
+
return;
|
|
146035
|
+
}
|
|
146036
|
+
if (typeDependencies[type]) {
|
|
146037
|
+
typeDependencies[type].forEach(visit);
|
|
146038
|
+
return;
|
|
146039
|
+
}
|
|
146040
|
+
unboundTypes.push(type);
|
|
146041
|
+
seen[type] = true;
|
|
146042
|
+
}
|
|
146043
|
+
types.forEach(visit);
|
|
146044
|
+
throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([", "]));
|
|
146045
|
+
};
|
|
146046
|
+
var getFunctionName = (signature) => {
|
|
146047
|
+
signature = signature.trim();
|
|
146048
|
+
const argsIndex = signature.indexOf("(");
|
|
146049
|
+
if (argsIndex === -1)
|
|
146050
|
+
return signature;
|
|
146051
|
+
return signature.slice(0, argsIndex);
|
|
146052
|
+
};
|
|
146053
|
+
var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync, isNonnullReturn) => {
|
|
146054
|
+
var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
146055
|
+
name = readLatin1String(name);
|
|
146056
|
+
name = getFunctionName(name);
|
|
146057
|
+
rawInvoker = embind__requireFunction(signature, rawInvoker);
|
|
146058
|
+
exposePublicSymbol(name, function() {
|
|
146059
|
+
throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes);
|
|
146060
|
+
}, argCount - 1);
|
|
146061
|
+
whenDependentTypesAreResolved([], argTypes, (argTypes2) => {
|
|
146062
|
+
var invokerArgsArray = [argTypes2[0], null].concat(argTypes2.slice(1));
|
|
146063
|
+
replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn, isAsync), argCount - 1);
|
|
146064
|
+
return [];
|
|
146065
|
+
});
|
|
146066
|
+
};
|
|
146067
|
+
var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => {
|
|
146068
|
+
name = readLatin1String(name);
|
|
146069
|
+
var fromWireType = (value) => value;
|
|
146070
|
+
if (minRange === 0) {
|
|
146071
|
+
var bitshift = 32 - 8 * size;
|
|
146072
|
+
fromWireType = (value) => value << bitshift >>> bitshift;
|
|
146073
|
+
}
|
|
146074
|
+
var isUnsignedType = name.includes("unsigned");
|
|
146075
|
+
var checkAssertions = (value, toTypeName) => {
|
|
146076
|
+
};
|
|
146077
|
+
var toWireType;
|
|
146078
|
+
if (isUnsignedType) {
|
|
146079
|
+
toWireType = function(destructors, value) {
|
|
146080
|
+
checkAssertions(value, this.name);
|
|
146081
|
+
return value >>> 0;
|
|
146082
|
+
};
|
|
146083
|
+
} else {
|
|
146084
|
+
toWireType = function(destructors, value) {
|
|
146085
|
+
checkAssertions(value, this.name);
|
|
146086
|
+
return value;
|
|
146087
|
+
};
|
|
146088
|
+
}
|
|
146089
|
+
registerType(primitiveType, { name, fromWireType, toWireType, argPackAdvance: GenericWireTypeSize, readValueFromPointer: integerReadValueFromPointer(name, size, minRange !== 0), destructorFunction: null });
|
|
146090
|
+
};
|
|
146091
|
+
var __embind_register_memory_view = (rawType, dataTypeIndex, name) => {
|
|
146092
|
+
var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array];
|
|
146093
|
+
var TA = typeMapping[dataTypeIndex];
|
|
146094
|
+
function decodeMemoryView(handle) {
|
|
146095
|
+
var size = HEAPU32[handle >> 2];
|
|
146096
|
+
var data = HEAPU32[handle + 4 >> 2];
|
|
146097
|
+
return new TA(HEAP8.buffer, data, size);
|
|
146098
|
+
}
|
|
146099
|
+
name = readLatin1String(name);
|
|
146100
|
+
registerType(rawType, { name, fromWireType: decodeMemoryView, argPackAdvance: GenericWireTypeSize, readValueFromPointer: decodeMemoryView }, { ignoreDuplicateRegistrations: true });
|
|
146101
|
+
};
|
|
146102
|
+
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
146103
|
+
var __embind_register_std_string = (rawType, name) => {
|
|
146104
|
+
name = readLatin1String(name);
|
|
146105
|
+
registerType(rawType, { name, fromWireType(value) {
|
|
146106
|
+
var length = HEAPU32[value >> 2];
|
|
146107
|
+
var payload = value + 4;
|
|
146108
|
+
var str;
|
|
146109
|
+
var i; {
|
|
146110
|
+
var decodeStartPtr = payload;
|
|
146111
|
+
for (var i = 0; i <= length; ++i) {
|
|
146112
|
+
var currentBytePtr = payload + i;
|
|
146113
|
+
if (i == length || HEAPU8[currentBytePtr] == 0) {
|
|
146114
|
+
var maxRead = currentBytePtr - decodeStartPtr;
|
|
146115
|
+
var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
|
|
146116
|
+
if (str === void 0) {
|
|
146117
|
+
str = stringSegment;
|
|
146118
|
+
} else {
|
|
146119
|
+
str += String.fromCharCode(0);
|
|
146120
|
+
str += stringSegment;
|
|
146121
|
+
}
|
|
146122
|
+
decodeStartPtr = currentBytePtr + 1;
|
|
146123
|
+
}
|
|
146124
|
+
}
|
|
146125
|
+
}
|
|
146126
|
+
_free(value);
|
|
146127
|
+
return str;
|
|
146128
|
+
}, toWireType(destructors, value) {
|
|
146129
|
+
if (value instanceof ArrayBuffer) {
|
|
146130
|
+
value = new Uint8Array(value);
|
|
146131
|
+
}
|
|
146132
|
+
var length;
|
|
146133
|
+
var valueIsOfTypeString = typeof value == "string";
|
|
146134
|
+
if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
|
|
146135
|
+
throwBindingError("Cannot pass non-string to std::string");
|
|
146136
|
+
}
|
|
146137
|
+
if (valueIsOfTypeString) {
|
|
146138
|
+
length = lengthBytesUTF8(value);
|
|
146139
|
+
} else {
|
|
146140
|
+
length = value.length;
|
|
146141
|
+
}
|
|
146142
|
+
var base = _malloc(4 + length + 1);
|
|
146143
|
+
var ptr = base + 4;
|
|
146144
|
+
HEAPU32[base >> 2] = length;
|
|
146145
|
+
if (valueIsOfTypeString) {
|
|
146146
|
+
stringToUTF8(value, ptr, length + 1);
|
|
146147
|
+
} else {
|
|
146148
|
+
if (valueIsOfTypeString) {
|
|
146149
|
+
for (var i = 0; i < length; ++i) {
|
|
146150
|
+
var charCode = value.charCodeAt(i);
|
|
146151
|
+
if (charCode > 255) {
|
|
146152
|
+
_free(base);
|
|
146153
|
+
throwBindingError("String has UTF-16 code units that do not fit in 8 bits");
|
|
146154
|
+
}
|
|
146155
|
+
HEAPU8[ptr + i] = charCode;
|
|
146156
|
+
}
|
|
146157
|
+
} else {
|
|
146158
|
+
for (var i = 0; i < length; ++i) {
|
|
146159
|
+
HEAPU8[ptr + i] = value[i];
|
|
146160
|
+
}
|
|
146161
|
+
}
|
|
146162
|
+
}
|
|
146163
|
+
if (destructors !== null) {
|
|
146164
|
+
destructors.push(_free, base);
|
|
146165
|
+
}
|
|
146166
|
+
return base;
|
|
146167
|
+
}, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction(ptr) {
|
|
146168
|
+
_free(ptr);
|
|
146169
|
+
} });
|
|
146170
|
+
};
|
|
146171
|
+
var UTF16Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : void 0;
|
|
146172
|
+
var UTF16ToString = (ptr, maxBytesToRead) => {
|
|
146173
|
+
var endPtr = ptr;
|
|
146174
|
+
var idx = endPtr >> 1;
|
|
146175
|
+
var maxIdx = idx + maxBytesToRead / 2;
|
|
146176
|
+
while (!(idx >= maxIdx) && HEAPU16[idx])
|
|
146177
|
+
++idx;
|
|
146178
|
+
endPtr = idx << 1;
|
|
146179
|
+
if (endPtr - ptr > 32 && UTF16Decoder)
|
|
146180
|
+
return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
|
|
146181
|
+
var str = "";
|
|
146182
|
+
for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
|
|
146183
|
+
var codeUnit = HEAP16[ptr + i * 2 >> 1];
|
|
146184
|
+
if (codeUnit == 0)
|
|
146185
|
+
break;
|
|
146186
|
+
str += String.fromCharCode(codeUnit);
|
|
146187
|
+
}
|
|
146188
|
+
return str;
|
|
146189
|
+
};
|
|
146190
|
+
var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
|
|
146191
|
+
maxBytesToWrite ?? (maxBytesToWrite = 2147483647);
|
|
146192
|
+
if (maxBytesToWrite < 2)
|
|
146193
|
+
return 0;
|
|
146194
|
+
maxBytesToWrite -= 2;
|
|
146195
|
+
var startPtr = outPtr;
|
|
146196
|
+
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
146197
|
+
for (var i = 0; i < numCharsToWrite; ++i) {
|
|
146198
|
+
var codeUnit = str.charCodeAt(i);
|
|
146199
|
+
HEAP16[outPtr >> 1] = codeUnit;
|
|
146200
|
+
outPtr += 2;
|
|
146201
|
+
}
|
|
146202
|
+
HEAP16[outPtr >> 1] = 0;
|
|
146203
|
+
return outPtr - startPtr;
|
|
146204
|
+
};
|
|
146205
|
+
var lengthBytesUTF16 = (str) => str.length * 2;
|
|
146206
|
+
var UTF32ToString = (ptr, maxBytesToRead) => {
|
|
146207
|
+
var i = 0;
|
|
146208
|
+
var str = "";
|
|
146209
|
+
while (!(i >= maxBytesToRead / 4)) {
|
|
146210
|
+
var utf32 = HEAP32[ptr + i * 4 >> 2];
|
|
146211
|
+
if (utf32 == 0)
|
|
146212
|
+
break;
|
|
146213
|
+
++i;
|
|
146214
|
+
if (utf32 >= 65536) {
|
|
146215
|
+
var ch = utf32 - 65536;
|
|
146216
|
+
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
146217
|
+
} else {
|
|
146218
|
+
str += String.fromCharCode(utf32);
|
|
146219
|
+
}
|
|
146220
|
+
}
|
|
146221
|
+
return str;
|
|
146222
|
+
};
|
|
146223
|
+
var stringToUTF32 = (str, outPtr, maxBytesToWrite) => {
|
|
146224
|
+
maxBytesToWrite ?? (maxBytesToWrite = 2147483647);
|
|
146225
|
+
if (maxBytesToWrite < 4)
|
|
146226
|
+
return 0;
|
|
146227
|
+
var startPtr = outPtr;
|
|
146228
|
+
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
146229
|
+
for (var i = 0; i < str.length; ++i) {
|
|
146230
|
+
var codeUnit = str.charCodeAt(i);
|
|
146231
|
+
if (codeUnit >= 55296 && codeUnit <= 57343) {
|
|
146232
|
+
var trailSurrogate = str.charCodeAt(++i);
|
|
146233
|
+
codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023;
|
|
146234
|
+
}
|
|
146235
|
+
HEAP32[outPtr >> 2] = codeUnit;
|
|
146236
|
+
outPtr += 4;
|
|
146237
|
+
if (outPtr + 4 > endPtr)
|
|
146238
|
+
break;
|
|
146239
|
+
}
|
|
146240
|
+
HEAP32[outPtr >> 2] = 0;
|
|
146241
|
+
return outPtr - startPtr;
|
|
146242
|
+
};
|
|
146243
|
+
var lengthBytesUTF32 = (str) => {
|
|
146244
|
+
var len = 0;
|
|
146245
|
+
for (var i = 0; i < str.length; ++i) {
|
|
146246
|
+
var codeUnit = str.charCodeAt(i);
|
|
146247
|
+
if (codeUnit >= 55296 && codeUnit <= 57343)
|
|
146248
|
+
++i;
|
|
146249
|
+
len += 4;
|
|
146250
|
+
}
|
|
146251
|
+
return len;
|
|
146252
|
+
};
|
|
146253
|
+
var __embind_register_std_wstring = (rawType, charSize, name) => {
|
|
146254
|
+
name = readLatin1String(name);
|
|
146255
|
+
var decodeString, encodeString, readCharAt, lengthBytesUTF;
|
|
146256
|
+
if (charSize === 2) {
|
|
146257
|
+
decodeString = UTF16ToString;
|
|
146258
|
+
encodeString = stringToUTF16;
|
|
146259
|
+
lengthBytesUTF = lengthBytesUTF16;
|
|
146260
|
+
readCharAt = (pointer) => HEAPU16[pointer >> 1];
|
|
146261
|
+
} else if (charSize === 4) {
|
|
146262
|
+
decodeString = UTF32ToString;
|
|
146263
|
+
encodeString = stringToUTF32;
|
|
146264
|
+
lengthBytesUTF = lengthBytesUTF32;
|
|
146265
|
+
readCharAt = (pointer) => HEAPU32[pointer >> 2];
|
|
146266
|
+
}
|
|
146267
|
+
registerType(rawType, { name, fromWireType: (value) => {
|
|
146268
|
+
var length = HEAPU32[value >> 2];
|
|
146269
|
+
var str;
|
|
146270
|
+
var decodeStartPtr = value + 4;
|
|
146271
|
+
for (var i = 0; i <= length; ++i) {
|
|
146272
|
+
var currentBytePtr = value + 4 + i * charSize;
|
|
146273
|
+
if (i == length || readCharAt(currentBytePtr) == 0) {
|
|
146274
|
+
var maxReadBytes = currentBytePtr - decodeStartPtr;
|
|
146275
|
+
var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
|
|
146276
|
+
if (str === void 0) {
|
|
146277
|
+
str = stringSegment;
|
|
146278
|
+
} else {
|
|
146279
|
+
str += String.fromCharCode(0);
|
|
146280
|
+
str += stringSegment;
|
|
146281
|
+
}
|
|
146282
|
+
decodeStartPtr = currentBytePtr + charSize;
|
|
146283
|
+
}
|
|
146284
|
+
}
|
|
146285
|
+
_free(value);
|
|
146286
|
+
return str;
|
|
146287
|
+
}, toWireType: (destructors, value) => {
|
|
146288
|
+
if (!(typeof value == "string")) {
|
|
146289
|
+
throwBindingError(`Cannot pass non-string to C++ string type ${name}`);
|
|
146290
|
+
}
|
|
146291
|
+
var length = lengthBytesUTF(value);
|
|
146292
|
+
var ptr = _malloc(4 + length + charSize);
|
|
146293
|
+
HEAPU32[ptr >> 2] = length / charSize;
|
|
146294
|
+
encodeString(value, ptr + 4, length + charSize);
|
|
146295
|
+
if (destructors !== null) {
|
|
146296
|
+
destructors.push(_free, ptr);
|
|
146297
|
+
}
|
|
146298
|
+
return ptr;
|
|
146299
|
+
}, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction(ptr) {
|
|
146300
|
+
_free(ptr);
|
|
146301
|
+
} });
|
|
146302
|
+
};
|
|
146303
|
+
var __embind_register_value_object = (rawType, name, constructorSignature, rawConstructor, destructorSignature, rawDestructor) => {
|
|
146304
|
+
structRegistrations[rawType] = { name: readLatin1String(name), rawConstructor: embind__requireFunction(constructorSignature, rawConstructor), rawDestructor: embind__requireFunction(destructorSignature, rawDestructor), fields: [] };
|
|
146305
|
+
};
|
|
146306
|
+
var __embind_register_value_object_field = (structType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) => {
|
|
146307
|
+
structRegistrations[structType].fields.push({ fieldName: readLatin1String(fieldName), getterReturnType, getter: embind__requireFunction(getterSignature, getter), getterContext, setterArgumentType, setter: embind__requireFunction(setterSignature, setter), setterContext });
|
|
146308
|
+
};
|
|
146309
|
+
var __embind_register_void = (rawType, name) => {
|
|
146310
|
+
name = readLatin1String(name);
|
|
146311
|
+
registerType(rawType, { isVoid: true, name, argPackAdvance: 0, fromWireType: () => void 0, toWireType: (destructors, o) => void 0 });
|
|
146312
|
+
};
|
|
146313
|
+
var requireRegisteredType = (rawType, humanName) => {
|
|
146314
|
+
var impl = registeredTypes[rawType];
|
|
146315
|
+
if (void 0 === impl) {
|
|
146316
|
+
throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
|
|
146317
|
+
}
|
|
146318
|
+
return impl;
|
|
146319
|
+
};
|
|
146320
|
+
var emval_returnValue = (returnType, destructorsRef, handle) => {
|
|
146321
|
+
var destructors = [];
|
|
146322
|
+
var result = returnType["toWireType"](destructors, handle);
|
|
146323
|
+
if (destructors.length) {
|
|
146324
|
+
HEAPU32[destructorsRef >> 2] = Emval.toHandle(destructors);
|
|
146325
|
+
}
|
|
146326
|
+
return result;
|
|
146327
|
+
};
|
|
146328
|
+
var __emval_as = (handle, returnType, destructorsRef) => {
|
|
146329
|
+
handle = Emval.toValue(handle);
|
|
146330
|
+
returnType = requireRegisteredType(returnType, "emval::as");
|
|
146331
|
+
return emval_returnValue(returnType, destructorsRef, handle);
|
|
146332
|
+
};
|
|
146333
|
+
var emval_methodCallers = [];
|
|
146334
|
+
var __emval_call = (caller, handle, destructorsRef, args) => {
|
|
146335
|
+
caller = emval_methodCallers[caller];
|
|
146336
|
+
handle = Emval.toValue(handle);
|
|
146337
|
+
return caller(null, handle, destructorsRef, args);
|
|
146338
|
+
};
|
|
146339
|
+
var emval_symbols = {};
|
|
146340
|
+
var getStringOrSymbol = (address) => {
|
|
146341
|
+
var symbol = emval_symbols[address];
|
|
146342
|
+
if (symbol === void 0) {
|
|
146343
|
+
return readLatin1String(address);
|
|
146344
|
+
}
|
|
146345
|
+
return symbol;
|
|
146346
|
+
};
|
|
146347
|
+
var emval_get_global = () => {
|
|
146348
|
+
if (typeof globalThis == "object") {
|
|
146349
|
+
return globalThis;
|
|
146350
|
+
}
|
|
146351
|
+
return (/* @__PURE__ */ function() {
|
|
146352
|
+
return Function;
|
|
146353
|
+
}())("return this")();
|
|
146354
|
+
};
|
|
146355
|
+
var __emval_get_global = (name) => {
|
|
146356
|
+
if (name === 0) {
|
|
146357
|
+
return Emval.toHandle(emval_get_global());
|
|
146358
|
+
} else {
|
|
146359
|
+
name = getStringOrSymbol(name);
|
|
146360
|
+
return Emval.toHandle(emval_get_global()[name]);
|
|
146361
|
+
}
|
|
146362
|
+
};
|
|
146363
|
+
var emval_addMethodCaller = (caller) => {
|
|
146364
|
+
var id = emval_methodCallers.length;
|
|
146365
|
+
emval_methodCallers.push(caller);
|
|
146366
|
+
return id;
|
|
146367
|
+
};
|
|
146368
|
+
var emval_lookupTypes = (argCount, argTypes) => {
|
|
146369
|
+
var a = new Array(argCount);
|
|
146370
|
+
for (var i = 0; i < argCount; ++i) {
|
|
146371
|
+
a[i] = requireRegisteredType(HEAPU32[argTypes + i * 4 >> 2], "parameter " + i);
|
|
146372
|
+
}
|
|
146373
|
+
return a;
|
|
146374
|
+
};
|
|
146375
|
+
var __emval_get_method_caller = (argCount, argTypes, kind) => {
|
|
146376
|
+
var types = emval_lookupTypes(argCount, argTypes);
|
|
146377
|
+
var retType = types.shift();
|
|
146378
|
+
argCount--;
|
|
146379
|
+
var functionBody = `return function (obj, func, destructorsRef, args) {
|
|
146380
|
+
`;
|
|
146381
|
+
var offset = 0;
|
|
146382
|
+
var argsList = [];
|
|
146383
|
+
if (kind === 0) {
|
|
146384
|
+
argsList.push("obj");
|
|
146385
|
+
}
|
|
146386
|
+
var params = ["retType"];
|
|
146387
|
+
var args = [retType];
|
|
146388
|
+
for (var i = 0; i < argCount; ++i) {
|
|
146389
|
+
argsList.push("arg" + i);
|
|
146390
|
+
params.push("argType" + i);
|
|
146391
|
+
args.push(types[i]);
|
|
146392
|
+
functionBody += ` var arg${i} = argType${i}.readValueFromPointer(args${offset ? "+" + offset : ""});
|
|
146393
|
+
`;
|
|
146394
|
+
offset += types[i].argPackAdvance;
|
|
146395
|
+
}
|
|
146396
|
+
var invoker = kind === 1 ? "new func" : "func.call";
|
|
146397
|
+
functionBody += ` var rv = ${invoker}(${argsList.join(", ")});
|
|
146398
|
+
`;
|
|
146399
|
+
if (!retType.isVoid) {
|
|
146400
|
+
params.push("emval_returnValue");
|
|
146401
|
+
args.push(emval_returnValue);
|
|
146402
|
+
functionBody += " return emval_returnValue(retType, destructorsRef, rv);\n";
|
|
146403
|
+
}
|
|
146404
|
+
functionBody += "};\n";
|
|
146405
|
+
params.push(functionBody);
|
|
146406
|
+
var invokerFunction = newFunc(Function, params)(...args);
|
|
146407
|
+
var functionName = `methodCaller<(${types.map((t) => t.name).join(", ")}) => ${retType.name}>`;
|
|
146408
|
+
return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
|
|
146409
|
+
};
|
|
146410
|
+
var __emval_incref = (handle) => {
|
|
146411
|
+
if (handle > 9) {
|
|
146412
|
+
emval_handles[handle + 1] += 1;
|
|
146413
|
+
}
|
|
146414
|
+
};
|
|
146415
|
+
var __emval_is_string = (handle) => {
|
|
146416
|
+
handle = Emval.toValue(handle);
|
|
146417
|
+
return typeof handle == "string";
|
|
146418
|
+
};
|
|
146419
|
+
var __emval_run_destructors = (handle) => {
|
|
146420
|
+
var destructors = Emval.toValue(handle);
|
|
146421
|
+
runDestructors(destructors);
|
|
146422
|
+
__emval_decref(handle);
|
|
146423
|
+
};
|
|
146424
|
+
var __emval_take_value = (type, arg) => {
|
|
146425
|
+
type = requireRegisteredType(type, "_emval_take_value");
|
|
146426
|
+
var v = type["readValueFromPointer"](arg);
|
|
146427
|
+
return Emval.toHandle(v);
|
|
146428
|
+
};
|
|
146429
|
+
var isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
146430
|
+
var MONTH_DAYS_LEAP_CUMULATIVE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
|
|
146431
|
+
var MONTH_DAYS_REGULAR_CUMULATIVE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
|
146432
|
+
var ydayFromDate = (date) => {
|
|
146433
|
+
var leap = isLeapYear(date.getFullYear());
|
|
146434
|
+
var monthDaysCumulative = leap ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE;
|
|
146435
|
+
var yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1;
|
|
146436
|
+
return yday;
|
|
146437
|
+
};
|
|
146438
|
+
var INT53_MAX = 9007199254740992;
|
|
146439
|
+
var INT53_MIN = -9007199254740992;
|
|
146440
|
+
var bigintToI53Checked = (num) => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num);
|
|
146441
|
+
function __localtime_js(time, tmPtr) {
|
|
146442
|
+
time = bigintToI53Checked(time);
|
|
146443
|
+
var date = new Date(time * 1e3);
|
|
146444
|
+
HEAP32[tmPtr >> 2] = date.getSeconds();
|
|
146445
|
+
HEAP32[tmPtr + 4 >> 2] = date.getMinutes();
|
|
146446
|
+
HEAP32[tmPtr + 8 >> 2] = date.getHours();
|
|
146447
|
+
HEAP32[tmPtr + 12 >> 2] = date.getDate();
|
|
146448
|
+
HEAP32[tmPtr + 16 >> 2] = date.getMonth();
|
|
146449
|
+
HEAP32[tmPtr + 20 >> 2] = date.getFullYear() - 1900;
|
|
146450
|
+
HEAP32[tmPtr + 24 >> 2] = date.getDay();
|
|
146451
|
+
var yday = ydayFromDate(date) | 0;
|
|
146452
|
+
HEAP32[tmPtr + 28 >> 2] = yday;
|
|
146453
|
+
HEAP32[tmPtr + 36 >> 2] = -(date.getTimezoneOffset() * 60);
|
|
146454
|
+
var start = new Date(date.getFullYear(), 0, 1);
|
|
146455
|
+
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
|
|
146456
|
+
var winterOffset = start.getTimezoneOffset();
|
|
146457
|
+
var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
|
|
146458
|
+
HEAP32[tmPtr + 32 >> 2] = dst;
|
|
146459
|
+
}
|
|
146460
|
+
var __mktime_js = function(tmPtr) {
|
|
146461
|
+
var ret = (() => {
|
|
146462
|
+
var date = new Date(HEAP32[tmPtr + 20 >> 2] + 1900, HEAP32[tmPtr + 16 >> 2], HEAP32[tmPtr + 12 >> 2], HEAP32[tmPtr + 8 >> 2], HEAP32[tmPtr + 4 >> 2], HEAP32[tmPtr >> 2], 0);
|
|
146463
|
+
var dst = HEAP32[tmPtr + 32 >> 2];
|
|
146464
|
+
var guessedOffset = date.getTimezoneOffset();
|
|
146465
|
+
var start = new Date(date.getFullYear(), 0, 1);
|
|
146466
|
+
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
|
|
146467
|
+
var winterOffset = start.getTimezoneOffset();
|
|
146468
|
+
var dstOffset = Math.min(winterOffset, summerOffset);
|
|
146469
|
+
if (dst < 0) {
|
|
146470
|
+
HEAP32[tmPtr + 32 >> 2] = Number(summerOffset != winterOffset && dstOffset == guessedOffset);
|
|
146471
|
+
} else if (dst > 0 != (dstOffset == guessedOffset)) {
|
|
146472
|
+
var nonDstOffset = Math.max(winterOffset, summerOffset);
|
|
146473
|
+
var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
|
|
146474
|
+
date.setTime(date.getTime() + (trueOffset - guessedOffset) * 6e4);
|
|
146475
|
+
}
|
|
146476
|
+
HEAP32[tmPtr + 24 >> 2] = date.getDay();
|
|
146477
|
+
var yday = ydayFromDate(date) | 0;
|
|
146478
|
+
HEAP32[tmPtr + 28 >> 2] = yday;
|
|
146479
|
+
HEAP32[tmPtr >> 2] = date.getSeconds();
|
|
146480
|
+
HEAP32[tmPtr + 4 >> 2] = date.getMinutes();
|
|
146481
|
+
HEAP32[tmPtr + 8 >> 2] = date.getHours();
|
|
146482
|
+
HEAP32[tmPtr + 12 >> 2] = date.getDate();
|
|
146483
|
+
HEAP32[tmPtr + 16 >> 2] = date.getMonth();
|
|
146484
|
+
HEAP32[tmPtr + 20 >> 2] = date.getYear();
|
|
146485
|
+
var timeMs = date.getTime();
|
|
146486
|
+
if (isNaN(timeMs)) {
|
|
146487
|
+
return -1;
|
|
146488
|
+
}
|
|
146489
|
+
return timeMs / 1e3;
|
|
146490
|
+
})();
|
|
146491
|
+
return BigInt(ret);
|
|
146492
|
+
};
|
|
146493
|
+
var __tzset_js = (timezone, daylight, std_name, dst_name) => {
|
|
146494
|
+
var currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
146495
|
+
var winter = new Date(currentYear, 0, 1);
|
|
146496
|
+
var summer = new Date(currentYear, 6, 1);
|
|
146497
|
+
var winterOffset = winter.getTimezoneOffset();
|
|
146498
|
+
var summerOffset = summer.getTimezoneOffset();
|
|
146499
|
+
var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
|
|
146500
|
+
HEAPU32[timezone >> 2] = stdTimezoneOffset * 60;
|
|
146501
|
+
HEAP32[daylight >> 2] = Number(winterOffset != summerOffset);
|
|
146502
|
+
var extractZone = (timezoneOffset) => {
|
|
146503
|
+
var sign = timezoneOffset >= 0 ? "-" : "+";
|
|
146504
|
+
var absOffset = Math.abs(timezoneOffset);
|
|
146505
|
+
var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
|
|
146506
|
+
var minutes = String(absOffset % 60).padStart(2, "0");
|
|
146507
|
+
return `UTC${sign}${hours}${minutes}`;
|
|
146508
|
+
};
|
|
146509
|
+
var winterName = extractZone(winterOffset);
|
|
146510
|
+
var summerName = extractZone(summerOffset);
|
|
146511
|
+
if (summerOffset < winterOffset) {
|
|
146512
|
+
stringToUTF8(winterName, std_name, 17);
|
|
146513
|
+
stringToUTF8(summerName, dst_name, 17);
|
|
146514
|
+
} else {
|
|
146515
|
+
stringToUTF8(winterName, dst_name, 17);
|
|
146516
|
+
stringToUTF8(summerName, std_name, 17);
|
|
146517
|
+
}
|
|
146518
|
+
};
|
|
146519
|
+
var _emscripten_get_now = () => performance.now();
|
|
146520
|
+
var _emscripten_date_now = () => Date.now();
|
|
146521
|
+
var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
|
|
146522
|
+
function _clock_time_get(clk_id, ignored_precision, ptime) {
|
|
146523
|
+
if (!checkWasiClock(clk_id)) {
|
|
146524
|
+
return 28;
|
|
146525
|
+
}
|
|
146526
|
+
var now;
|
|
146527
|
+
if (clk_id === 0) {
|
|
146528
|
+
now = _emscripten_date_now();
|
|
146529
|
+
} else {
|
|
146530
|
+
now = _emscripten_get_now();
|
|
146531
|
+
}
|
|
146532
|
+
var nsec = Math.round(now * 1e3 * 1e3);
|
|
146533
|
+
HEAP64[ptime >> 3] = BigInt(nsec);
|
|
146534
|
+
return 0;
|
|
146535
|
+
}
|
|
146536
|
+
var readEmAsmArgsArray = [];
|
|
146537
|
+
var readEmAsmArgs = (sigPtr, buf) => {
|
|
146538
|
+
readEmAsmArgsArray.length = 0;
|
|
146539
|
+
var ch;
|
|
146540
|
+
while (ch = HEAPU8[sigPtr++]) {
|
|
146541
|
+
var wide = ch != 105;
|
|
146542
|
+
wide &= ch != 112;
|
|
146543
|
+
buf += wide && buf % 8 ? 4 : 0;
|
|
146544
|
+
readEmAsmArgsArray.push(ch == 112 ? HEAPU32[buf >> 2] : ch == 106 ? HEAP64[buf >> 3] : ch == 105 ? HEAP32[buf >> 2] : HEAPF64[buf >> 3]);
|
|
146545
|
+
buf += wide ? 8 : 4;
|
|
146546
|
+
}
|
|
146547
|
+
return readEmAsmArgsArray;
|
|
146548
|
+
};
|
|
146549
|
+
var runEmAsmFunction = (code, sigPtr, argbuf) => {
|
|
146550
|
+
var args = readEmAsmArgs(sigPtr, argbuf);
|
|
146551
|
+
return ASM_CONSTS[code](...args);
|
|
146552
|
+
};
|
|
146553
|
+
var _emscripten_asm_const_int = (code, sigPtr, argbuf) => runEmAsmFunction(code, sigPtr, argbuf);
|
|
146554
|
+
var getHeapMax = () => 2147483648;
|
|
146555
|
+
var _emscripten_get_heap_max = () => getHeapMax();
|
|
146556
|
+
var growMemory = (size) => {
|
|
146557
|
+
var b = wasmMemory.buffer;
|
|
146558
|
+
var pages = (size - b.byteLength + 65535) / 65536 | 0;
|
|
146559
|
+
try {
|
|
146560
|
+
wasmMemory.grow(pages);
|
|
146561
|
+
updateMemoryViews();
|
|
146562
|
+
return 1;
|
|
146563
|
+
} catch (e) {
|
|
146564
|
+
}
|
|
146565
|
+
};
|
|
146566
|
+
var _emscripten_resize_heap = (requestedSize) => {
|
|
146567
|
+
var oldSize = HEAPU8.length;
|
|
146568
|
+
requestedSize >>>= 0;
|
|
146569
|
+
var maxHeapSize = getHeapMax();
|
|
146570
|
+
if (requestedSize > maxHeapSize) {
|
|
146571
|
+
return false;
|
|
146572
|
+
}
|
|
146573
|
+
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
|
|
146574
|
+
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
|
|
146575
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
146576
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
146577
|
+
var replacement = growMemory(newSize);
|
|
146578
|
+
if (replacement) {
|
|
146579
|
+
return true;
|
|
146580
|
+
}
|
|
146581
|
+
}
|
|
146582
|
+
return false;
|
|
146583
|
+
};
|
|
146584
|
+
var safeSetTimeout = (func, timeout) => setTimeout(() => {
|
|
146585
|
+
callUserCallback(func);
|
|
146586
|
+
}, timeout);
|
|
146587
|
+
var _emscripten_sleep = (ms) => Asyncify.handleSleep((wakeUp) => safeSetTimeout(wakeUp, ms));
|
|
146588
|
+
_emscripten_sleep.isAsync = true;
|
|
146589
|
+
var ENV = {};
|
|
146590
|
+
var getExecutableName = () => thisProgram || "./this.program";
|
|
146591
|
+
var getEnvStrings = () => {
|
|
146592
|
+
if (!getEnvStrings.strings) {
|
|
146593
|
+
var lang = (typeof navigator == "object" && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8";
|
|
146594
|
+
var env = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: lang, _: getExecutableName() };
|
|
146595
|
+
for (var x in ENV) {
|
|
146596
|
+
if (ENV[x] === void 0)
|
|
146597
|
+
delete env[x];
|
|
146598
|
+
else
|
|
146599
|
+
env[x] = ENV[x];
|
|
146600
|
+
}
|
|
146601
|
+
var strings = [];
|
|
146602
|
+
for (var x in env) {
|
|
146603
|
+
strings.push(`${x}=${env[x]}`);
|
|
146604
|
+
}
|
|
146605
|
+
getEnvStrings.strings = strings;
|
|
146606
|
+
}
|
|
146607
|
+
return getEnvStrings.strings;
|
|
146608
|
+
};
|
|
146609
|
+
var stringToAscii = (str, buffer) => {
|
|
146610
|
+
for (var i = 0; i < str.length; ++i) {
|
|
146611
|
+
HEAP8[buffer++] = str.charCodeAt(i);
|
|
146612
|
+
}
|
|
146613
|
+
HEAP8[buffer] = 0;
|
|
146614
|
+
};
|
|
146615
|
+
var _environ_get = (__environ, environ_buf) => {
|
|
146616
|
+
var bufSize = 0;
|
|
146617
|
+
getEnvStrings().forEach((string, i) => {
|
|
146618
|
+
var ptr = environ_buf + bufSize;
|
|
146619
|
+
HEAPU32[__environ + i * 4 >> 2] = ptr;
|
|
146620
|
+
stringToAscii(string, ptr);
|
|
146621
|
+
bufSize += string.length + 1;
|
|
146622
|
+
});
|
|
146623
|
+
return 0;
|
|
146624
|
+
};
|
|
146625
|
+
var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
|
|
146626
|
+
var strings = getEnvStrings();
|
|
146627
|
+
HEAPU32[penviron_count >> 2] = strings.length;
|
|
146628
|
+
var bufSize = 0;
|
|
146629
|
+
strings.forEach((string) => bufSize += string.length + 1);
|
|
146630
|
+
HEAPU32[penviron_buf_size >> 2] = bufSize;
|
|
146631
|
+
return 0;
|
|
146632
|
+
};
|
|
146633
|
+
function _fd_close(fd) {
|
|
146634
|
+
try {
|
|
146635
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
146636
|
+
FS.close(stream);
|
|
146637
|
+
return 0;
|
|
146638
|
+
} catch (e) {
|
|
146639
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
146640
|
+
throw e;
|
|
146641
|
+
return e.errno;
|
|
146642
|
+
}
|
|
146643
|
+
}
|
|
146644
|
+
var doReadv = (stream, iov, iovcnt, offset) => {
|
|
146645
|
+
var ret = 0;
|
|
146646
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
146647
|
+
var ptr = HEAPU32[iov >> 2];
|
|
146648
|
+
var len = HEAPU32[iov + 4 >> 2];
|
|
146649
|
+
iov += 8;
|
|
146650
|
+
var curr = FS.read(stream, HEAP8, ptr, len, offset);
|
|
146651
|
+
if (curr < 0)
|
|
146652
|
+
return -1;
|
|
146653
|
+
ret += curr;
|
|
146654
|
+
if (curr < len)
|
|
146655
|
+
break;
|
|
146656
|
+
if (typeof offset != "undefined") {
|
|
146657
|
+
offset += curr;
|
|
146658
|
+
}
|
|
146659
|
+
}
|
|
146660
|
+
return ret;
|
|
146661
|
+
};
|
|
146662
|
+
function _fd_read(fd, iov, iovcnt, pnum) {
|
|
146663
|
+
try {
|
|
146664
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
146665
|
+
var num = doReadv(stream, iov, iovcnt);
|
|
146666
|
+
HEAPU32[pnum >> 2] = num;
|
|
146667
|
+
return 0;
|
|
146668
|
+
} catch (e) {
|
|
146669
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
146670
|
+
throw e;
|
|
146671
|
+
return e.errno;
|
|
146672
|
+
}
|
|
146673
|
+
}
|
|
146674
|
+
function _fd_seek(fd, offset, whence, newOffset) {
|
|
146675
|
+
offset = bigintToI53Checked(offset);
|
|
146676
|
+
try {
|
|
146677
|
+
if (isNaN(offset))
|
|
146678
|
+
return 61;
|
|
146679
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
146680
|
+
FS.llseek(stream, offset, whence);
|
|
146681
|
+
HEAP64[newOffset >> 3] = BigInt(stream.position);
|
|
146682
|
+
if (stream.getdents && offset === 0 && whence === 0)
|
|
146683
|
+
stream.getdents = null;
|
|
146684
|
+
return 0;
|
|
146685
|
+
} catch (e) {
|
|
146686
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
146687
|
+
throw e;
|
|
146688
|
+
return e.errno;
|
|
146689
|
+
}
|
|
146690
|
+
}
|
|
146691
|
+
var doWritev = (stream, iov, iovcnt, offset) => {
|
|
146692
|
+
var ret = 0;
|
|
146693
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
146694
|
+
var ptr = HEAPU32[iov >> 2];
|
|
146695
|
+
var len = HEAPU32[iov + 4 >> 2];
|
|
146696
|
+
iov += 8;
|
|
146697
|
+
var curr = FS.write(stream, HEAP8, ptr, len, offset);
|
|
146698
|
+
if (curr < 0)
|
|
146699
|
+
return -1;
|
|
146700
|
+
ret += curr;
|
|
146701
|
+
if (curr < len) {
|
|
146702
|
+
break;
|
|
146703
|
+
}
|
|
146704
|
+
if (typeof offset != "undefined") {
|
|
146705
|
+
offset += curr;
|
|
146706
|
+
}
|
|
146707
|
+
}
|
|
146708
|
+
return ret;
|
|
146709
|
+
};
|
|
146710
|
+
function _fd_write(fd, iov, iovcnt, pnum) {
|
|
146711
|
+
try {
|
|
146712
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
146713
|
+
var num = doWritev(stream, iov, iovcnt);
|
|
146714
|
+
HEAPU32[pnum >> 2] = num;
|
|
146715
|
+
return 0;
|
|
146716
|
+
} catch (e) {
|
|
146717
|
+
if (typeof FS == "undefined" || !(e.name === "ErrnoError"))
|
|
146718
|
+
throw e;
|
|
146719
|
+
return e.errno;
|
|
146720
|
+
}
|
|
146721
|
+
}
|
|
146722
|
+
var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
|
|
146723
|
+
var stringToUTF8OnStack = (str) => {
|
|
146724
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
146725
|
+
var ret = stackAlloc(size);
|
|
146726
|
+
stringToUTF8(str, ret, size);
|
|
146727
|
+
return ret;
|
|
146728
|
+
};
|
|
146729
|
+
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
146730
|
+
FS.staticInit();
|
|
146731
|
+
MEMFS.doesNotExistError = new FS.ErrnoError(44);
|
|
146732
|
+
MEMFS.doesNotExistError.stack = "<generic error, no stack>";
|
|
146733
|
+
InternalError = Module["InternalError"] = class InternalError extends Error {
|
|
146734
|
+
constructor(message) {
|
|
146735
|
+
super(message);
|
|
146736
|
+
this.name = "InternalError";
|
|
146737
|
+
}
|
|
146738
|
+
};
|
|
146739
|
+
embind_init_charCodes();
|
|
146740
|
+
BindingError = Module["BindingError"] = class BindingError extends Error {
|
|
146741
|
+
constructor(message) {
|
|
146742
|
+
super(message);
|
|
146743
|
+
this.name = "BindingError";
|
|
146744
|
+
}
|
|
146745
|
+
};
|
|
146746
|
+
init_emval();
|
|
146747
|
+
UnboundTypeError = Module["UnboundTypeError"] = extendError(Error, "UnboundTypeError");
|
|
146748
|
+
var wasmImports = { a: ___cxa_throw, j: ___syscall_fcntl64, G: ___syscall_ioctl, H: ___syscall_openat, s: ___syscall_renameat, y: ___syscall_rmdir, v: ___syscall_stat64, z: ___syscall_unlinkat, t: __abort_js, L: __embind_finalize_value_object, m: __embind_register_bigint, R: __embind_register_bool, P: __embind_register_emval, l: __embind_register_float, f: __embind_register_function, c: __embind_register_integer, b: __embind_register_memory_view, Q: __embind_register_std_string, g: __embind_register_std_wstring, O: __embind_register_value_object, M: __embind_register_value_object_field, S: __embind_register_void, N: __emval_as, d: __emval_call, q: __emval_decref, F: __emval_get_global, e: __emval_get_method_caller, o: __emval_incref, T: __emval_is_string, n: __emval_run_destructors, p: __emval_take_value, A: __localtime_js, B: __mktime_js, C: __tzset_js, J: _clock_time_get, K: _emscripten_asm_const_int, I: _emscripten_date_now, r: _emscripten_get_heap_max, u: _emscripten_resize_heap, k: _emscripten_sleep, w: _environ_get, x: _environ_sizes_get, h: _fd_close, E: _fd_read, D: _fd_seek, i: _fd_write };
|
|
146749
|
+
var wasmExports = await createWasm();
|
|
146750
|
+
wasmExports["V"];
|
|
146751
|
+
var ___getTypeName = wasmExports["W"];
|
|
146752
|
+
var _malloc = wasmExports["Y"];
|
|
146753
|
+
var _free = wasmExports["Z"];
|
|
146754
|
+
var _main = Module["_main"] = wasmExports["_"];
|
|
146755
|
+
var __emscripten_stack_alloc = wasmExports["$"];
|
|
146756
|
+
Module["dynCall_vi"] = wasmExports["aa"];
|
|
146757
|
+
Module["dynCall_ii"] = wasmExports["ba"];
|
|
146758
|
+
Module["dynCall_viiii"] = wasmExports["ca"];
|
|
146759
|
+
Module["dynCall_vii"] = wasmExports["da"];
|
|
146760
|
+
Module["dynCall_iii"] = wasmExports["ea"];
|
|
146761
|
+
Module["dynCall_iijii"] = wasmExports["fa"];
|
|
146762
|
+
Module["dynCall_iiii"] = wasmExports["ga"];
|
|
146763
|
+
Module["dynCall_iiiii"] = wasmExports["ha"];
|
|
146764
|
+
Module["dynCall_iiiiiiiii"] = wasmExports["ia"];
|
|
146765
|
+
Module["dynCall_iiiiii"] = wasmExports["ja"];
|
|
146766
|
+
Module["dynCall_v"] = wasmExports["ka"];
|
|
146767
|
+
Module["dynCall_viii"] = wasmExports["la"];
|
|
146768
|
+
Module["dynCall_viiiiiii"] = wasmExports["ma"];
|
|
146769
|
+
Module["dynCall_diiii"] = wasmExports["na"];
|
|
146770
|
+
Module["dynCall_viif"] = wasmExports["oa"];
|
|
146771
|
+
Module["dynCall_i"] = wasmExports["pa"];
|
|
146772
|
+
Module["dynCall_fii"] = wasmExports["qa"];
|
|
146773
|
+
Module["dynCall_jiji"] = wasmExports["ra"];
|
|
146774
|
+
Module["dynCall_iidiiii"] = wasmExports["sa"];
|
|
146775
|
+
Module["dynCall_viijii"] = wasmExports["ta"];
|
|
146776
|
+
Module["dynCall_iiiiiii"] = wasmExports["ua"];
|
|
146777
|
+
Module["dynCall_iiiiij"] = wasmExports["va"];
|
|
146778
|
+
Module["dynCall_iiiiid"] = wasmExports["wa"];
|
|
146779
|
+
Module["dynCall_iiiiijj"] = wasmExports["xa"];
|
|
146780
|
+
Module["dynCall_iiiiiiii"] = wasmExports["ya"];
|
|
146781
|
+
Module["dynCall_iiiiiijj"] = wasmExports["za"];
|
|
146782
|
+
Module["dynCall_viiiiii"] = wasmExports["Aa"];
|
|
146783
|
+
Module["dynCall_viiiii"] = wasmExports["Ba"];
|
|
146784
|
+
var _asyncify_start_unwind = wasmExports["Ca"];
|
|
146785
|
+
var _asyncify_stop_unwind = wasmExports["Da"];
|
|
146786
|
+
var _asyncify_start_rewind = wasmExports["Ea"];
|
|
146787
|
+
var _asyncify_stop_rewind = wasmExports["Fa"];
|
|
146788
|
+
function callMain(args = []) {
|
|
146789
|
+
var entryFunction = _main;
|
|
146790
|
+
args.unshift(thisProgram);
|
|
146791
|
+
var argc = args.length;
|
|
146792
|
+
var argv = stackAlloc((argc + 1) * 4);
|
|
146793
|
+
var argv_ptr = argv;
|
|
146794
|
+
args.forEach((arg) => {
|
|
146795
|
+
HEAPU32[argv_ptr >> 2] = stringToUTF8OnStack(arg);
|
|
146796
|
+
argv_ptr += 4;
|
|
146797
|
+
});
|
|
146798
|
+
HEAPU32[argv_ptr >> 2] = 0;
|
|
146799
|
+
try {
|
|
146800
|
+
var ret = entryFunction(argc, argv);
|
|
146801
|
+
exitJS(ret, true);
|
|
146802
|
+
return ret;
|
|
146803
|
+
} catch (e) {
|
|
146804
|
+
return handleException(e);
|
|
146805
|
+
}
|
|
146806
|
+
}
|
|
146807
|
+
function run(args = arguments_) {
|
|
146808
|
+
if (runDependencies > 0) {
|
|
146809
|
+
dependenciesFulfilled = run;
|
|
146810
|
+
return;
|
|
146811
|
+
}
|
|
146812
|
+
preRun();
|
|
146813
|
+
if (runDependencies > 0) {
|
|
146814
|
+
dependenciesFulfilled = run;
|
|
146815
|
+
return;
|
|
146816
|
+
}
|
|
146817
|
+
function doRun() {
|
|
146818
|
+
Module["calledRun"] = true;
|
|
146819
|
+
if (ABORT)
|
|
146820
|
+
return;
|
|
146821
|
+
initRuntime();
|
|
146822
|
+
readyPromiseResolve(Module);
|
|
146823
|
+
Module["onRuntimeInitialized"]?.();
|
|
146824
|
+
var noInitialRun = Module["noInitialRun"] || true;
|
|
146825
|
+
if (!noInitialRun)
|
|
146826
|
+
callMain(args);
|
|
146827
|
+
postRun();
|
|
146828
|
+
}
|
|
146829
|
+
if (Module["setStatus"]) {
|
|
146830
|
+
Module["setStatus"]("Running...");
|
|
146831
|
+
setTimeout(() => {
|
|
146832
|
+
setTimeout(() => Module["setStatus"](""), 1);
|
|
146833
|
+
doRun();
|
|
146834
|
+
}, 1);
|
|
146835
|
+
} else {
|
|
146836
|
+
doRun();
|
|
146837
|
+
}
|
|
146838
|
+
}
|
|
146839
|
+
if (Module["preInit"]) {
|
|
146840
|
+
if (typeof Module["preInit"] == "function")
|
|
146841
|
+
Module["preInit"] = [Module["preInit"]];
|
|
146842
|
+
while (Module["preInit"].length > 0) {
|
|
146843
|
+
Module["preInit"].pop()();
|
|
146844
|
+
}
|
|
146845
|
+
}
|
|
146846
|
+
run();
|
|
146847
|
+
moduleRtn = readyPromise;
|
|
146848
|
+
return moduleRtn;
|
|
146849
|
+
};
|
|
146850
|
+
})();
|
|
146851
|
+
|
|
146852
|
+
var __defProp$1 = Object.defineProperty;
|
|
146853
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
146854
|
+
var __publicField$1 = (obj, key, value) => {
|
|
146855
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
146856
|
+
return value;
|
|
146857
|
+
};
|
|
146858
|
+
const cdnUrl = `https://cdn.jsdelivr.net/npm/@creooxag/cx-converter@${packageJSON.version}/dist/`;
|
|
146859
|
+
const defaultUrlPrefix = "./";
|
|
146860
|
+
const _IfcWasmConverterLoader = class _IfcWasmConverterLoader {
|
|
146861
|
+
constructor() {
|
|
146862
|
+
__publicField$1(this, "module");
|
|
146863
|
+
}
|
|
146864
|
+
static async getInstance(userUrlPrefix) {
|
|
146865
|
+
let urlPrefix = defaultUrlPrefix;
|
|
146866
|
+
if (userUrlPrefix) {
|
|
146867
|
+
urlPrefix = userUrlPrefix == "remote" ? cdnUrl : userUrlPrefix;
|
|
146868
|
+
}
|
|
146869
|
+
if (!_IfcWasmConverterLoader.instance) {
|
|
146870
|
+
_IfcWasmConverterLoader.instance = new _IfcWasmConverterLoader();
|
|
146871
|
+
var Module = {
|
|
146872
|
+
locateFile: function(path) {
|
|
146873
|
+
const fullPath = urlPrefix + path;
|
|
146874
|
+
if (path.endsWith(".wasm")) {
|
|
146875
|
+
console.log(`Loading wasm file from ${fullPath}`);
|
|
146876
|
+
return fullPath;
|
|
146877
|
+
}
|
|
146878
|
+
return path;
|
|
146879
|
+
}
|
|
146880
|
+
};
|
|
146881
|
+
try {
|
|
146882
|
+
_IfcWasmConverterLoader.instance.module = await IfcDbWasm(Module);
|
|
146883
|
+
} catch (error) {
|
|
146884
|
+
console.error("Error on wasm import:", error);
|
|
146885
|
+
}
|
|
146886
|
+
}
|
|
146887
|
+
return _IfcWasmConverterLoader.instance;
|
|
146888
|
+
}
|
|
146889
|
+
static async getModule(userUrlPrefix) {
|
|
146890
|
+
return (await _IfcWasmConverterLoader.getInstance(userUrlPrefix)).module;
|
|
146891
|
+
}
|
|
146892
|
+
};
|
|
146893
|
+
__publicField$1(_IfcWasmConverterLoader, "instance");
|
|
146894
|
+
let IfcWasmConverterLoader = _IfcWasmConverterLoader;
|
|
146895
|
+
|
|
146896
|
+
async function ifc2gltf(ifcData, params) {
|
|
146897
|
+
const inputOptionsString = params.inputOptions ? params.inputOptions : JSON.stringify(inputOptionsDefault);
|
|
146898
|
+
const loadOptions = {
|
|
146899
|
+
"maxFileSizeInMegaBytes": 1e3
|
|
146900
|
+
};
|
|
146901
|
+
let resolveCallbackGltf = void 0;
|
|
146902
|
+
let resolveCallbackMetadata = void 0;
|
|
146903
|
+
const url = params.remote ? "remote" : params.urlPath;
|
|
146904
|
+
const module = await IfcWasmConverterLoader.getModule(url);
|
|
146905
|
+
if (params.progressCallback)
|
|
146906
|
+
module.setProgressCallback(params.progressCallback);
|
|
146907
|
+
else
|
|
146908
|
+
module.setProgressCallback((progress) => {
|
|
146909
|
+
console.log(`Progress: ${progress}`);
|
|
146910
|
+
});
|
|
146911
|
+
if (params.progressTextCallback)
|
|
146912
|
+
module.setProgressTextCallback(params.progressTextCallback);
|
|
146913
|
+
else
|
|
146914
|
+
module.setProgressTextCallback((progressText) => {
|
|
146915
|
+
console.log(`Progress text: ${progressText}`);
|
|
146916
|
+
});
|
|
146917
|
+
module.setInputOptions(inputOptionsString);
|
|
146918
|
+
const promiseGltf = new Promise((resolve) => {
|
|
146919
|
+
resolveCallbackGltf = resolve;
|
|
146920
|
+
});
|
|
146921
|
+
const promiseMetadata = new Promise((resolve) => {
|
|
146922
|
+
resolveCallbackMetadata = resolve;
|
|
146923
|
+
});
|
|
146924
|
+
if (resolveCallbackGltf)
|
|
146925
|
+
module.setGltfCompleteCallback(resolveCallbackGltf);
|
|
146926
|
+
if (resolveCallbackMetadata)
|
|
146927
|
+
module.setMetaDataCompleteCallback(resolveCallbackMetadata);
|
|
146928
|
+
module.loadModel(ifcData, loadOptions);
|
|
146929
|
+
await Promise.all([promiseGltf, promiseMetadata]);
|
|
146930
|
+
const gltf = await module.getGeometry();
|
|
146931
|
+
const uint8Array = await module.getMetaData();
|
|
146932
|
+
const decoder = new TextDecoder();
|
|
146933
|
+
const metaStr = decoder.decode(uint8Array);
|
|
146934
|
+
const metaData = await JSON.parse(metaStr);
|
|
146935
|
+
return { gltf, metaData };
|
|
146936
|
+
}
|
|
146937
|
+
const inputOptionsDefault = {
|
|
146938
|
+
"inputParameters": {
|
|
146939
|
+
"exportPropertySets": "yes",
|
|
146940
|
+
"exportIfcPropertyTypes": "yes",
|
|
146941
|
+
"exportIfcValueTypes": "yes",
|
|
146942
|
+
"exportPolylines": "yes",
|
|
146943
|
+
"excludeGeometryForIfcTypes": ["IfcOpeningElement"],
|
|
146944
|
+
"excludeGUIDs": [""],
|
|
146945
|
+
"exportOnlyGUIDs": [""],
|
|
146946
|
+
"centerModelAtOrigin": "yes",
|
|
146947
|
+
"ignoreProfileRadius": "yes",
|
|
146948
|
+
"enableGltfCompression": "yes",
|
|
146949
|
+
"enableGltfQuantization": "no",
|
|
146950
|
+
"exportNormals": "no",
|
|
146951
|
+
"numPointsPerCircle": 18,
|
|
146952
|
+
"licenceKey": "",
|
|
146953
|
+
// JSON above is copied from default input config file. Changes applied here:
|
|
146954
|
+
"loadingPriorityTypes": ["IFCWALL", "IFCSLAB", "IFCWINDOW", "IFCROOF", "IFCFURNISHINGELEMENT", "IFCAIRTERMINAL"]
|
|
146955
|
+
//[ "IfcOpeningElement" ],
|
|
146956
|
+
}
|
|
146957
|
+
};
|
|
146958
|
+
|
|
146959
|
+
/**
|
|
146960
|
+
* Fetches a file from the given URL and returns its contents as text.
|
|
146961
|
+
*
|
|
146962
|
+
* @param {string} url - The URL to fetch the file from.
|
|
146963
|
+
* @returns {Promise<string>} A promise that resolves to the file contents.
|
|
146964
|
+
* @private
|
|
146965
|
+
*/
|
|
146966
|
+
async function fetchFile(url) {
|
|
146967
|
+
try {
|
|
146968
|
+
const response = await fetch(url);
|
|
146969
|
+
if (!response.ok) {
|
|
146970
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
146971
|
+
}
|
|
146972
|
+
return response.text();
|
|
146973
|
+
} catch (error) {
|
|
146974
|
+
console.error('Error fetching file:', error);
|
|
146975
|
+
}
|
|
146976
|
+
}
|
|
146977
|
+
|
|
146978
|
+
/**
|
|
146979
|
+
* {@link Viewer} plugin that uses [CxConverter](https://github.com/Creoox/cxconverter) to load BIM models directly from IFC files, using its WebAssembly buid from [npm package](https://www.npmjs.com/package/@creooxag/cx-converter).
|
|
146980
|
+
*
|
|
146981
|
+
* ## Overview
|
|
146982
|
+
* The WebAssembly build of CxConverter is still in alfa stage, so it may not work as expected. This documentation will be updated as the library and the plugin evolve. The example below shows how to use the plugin:
|
|
146983
|
+
* ````javascript
|
|
146984
|
+
* import { CxConverterIFCLoaderPlugin, Viewer } from "../../dist/xeokit-sdk.es.js";
|
|
146985
|
+
* const cxConverterIFCLoaderPlugin = new CxConverterIFCLoaderPlugin(viewer);
|
|
146986
|
+
*
|
|
146987
|
+
* const sceneModel = await cxConverterIFCLoaderPlugin.load({
|
|
146988
|
+
* src: "../../assets/models/ifc/Duplex.ifc"
|
|
146989
|
+
* });
|
|
146990
|
+
* ````
|
|
146991
|
+
See the code in action [here](https://xeokit.github.io/xeokit-sdk/examples/buildings/#cxConverterIFC_vbo_Duplex).
|
|
146992
|
+
*/
|
|
146993
|
+
|
|
146994
|
+
class CxConverterIFCLoaderPlugin extends Plugin {
|
|
146995
|
+
/**
|
|
146996
|
+
* @constructor
|
|
146997
|
+
* @param {Viewer} viewer The Viewer.
|
|
146998
|
+
* @param {Object} [cfg={}] Plugin configuration.
|
|
146999
|
+
*/
|
|
147000
|
+
constructor(viewer, cfg = {}) {
|
|
147001
|
+
super("ifcLoader", viewer, cfg);
|
|
147002
|
+
|
|
147003
|
+
/**
|
|
147004
|
+
* The GLTFLoaderPlugin used internally to load the converted GLTF.
|
|
147005
|
+
* @type {GLTFLoaderPlugin}
|
|
147006
|
+
*/
|
|
147007
|
+
this.gltfLoader = new GLTFLoaderPlugin(this.viewer);
|
|
147008
|
+
}
|
|
147009
|
+
|
|
147010
|
+
/**
|
|
147011
|
+
* Loads an IFC model from the given source.
|
|
147012
|
+
*
|
|
147013
|
+
* @param {Object} [params={}] Loading parameters.
|
|
147014
|
+
* @param {string} params.src Path to an IFC file.
|
|
147015
|
+
* @param {Function} [params.progressCallback] Callback to track loading progress.
|
|
147016
|
+
* @param {Function} [params.progressTextCallback] Callback to track loading progress with text updates.
|
|
147017
|
+
* @returns {Promise<SceneModel>} A promise that resolves to the loaded SceneModel.
|
|
147018
|
+
*/
|
|
147019
|
+
async load(params = {}) {
|
|
147020
|
+
if (!params.src) {
|
|
147021
|
+
this.error("load() param expected: src");
|
|
147022
|
+
}
|
|
147023
|
+
const data = await fetchFile(params.src);
|
|
147024
|
+
const { gltf, metaData } = await ifc2gltf(
|
|
147025
|
+
data,
|
|
147026
|
+
{
|
|
147027
|
+
remote: true,
|
|
147028
|
+
progressCallback: params.progressCallback,
|
|
147029
|
+
progressTextCallback: params.progressTextCallback
|
|
147030
|
+
}
|
|
147031
|
+
);
|
|
147032
|
+
const sceneModel = this.gltfLoader.load({
|
|
147033
|
+
id: "myModel",
|
|
147034
|
+
gltf: gltf,
|
|
147035
|
+
metaModelJSON: metaData
|
|
147036
|
+
});
|
|
147037
|
+
return sceneModel;
|
|
147038
|
+
}
|
|
147039
|
+
}
|
|
147040
|
+
|
|
142883
147041
|
/**
|
|
142884
147042
|
* Default data access strategy for {@link LASLoaderPlugin}.
|
|
142885
147043
|
*/
|
|
@@ -166372,6 +170530,7 @@ exports.Configs = Configs;
|
|
|
166372
170530
|
exports.ContextMenu = ContextMenu;
|
|
166373
170531
|
exports.CubicBezierCurve = CubicBezierCurve;
|
|
166374
170532
|
exports.Curve = Curve;
|
|
170533
|
+
exports.CxConverterIFCLoaderPlugin = CxConverterIFCLoaderPlugin;
|
|
166375
170534
|
exports.DefaultLoadingManager = DefaultLoadingManager;
|
|
166376
170535
|
exports.DepthFormat = DepthFormat;
|
|
166377
170536
|
exports.DepthStencilFormat = DepthStencilFormat;
|