@baidumap/mapv-three 1.3.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/assets/textures/cloud/stbn.bin +0 -0
- package/dist/assets/textures/weather/thunder.jpg +0 -0
- package/dist/assets/wasm/lanelet.js +3296 -165
- package/dist/assets/wasm/lanelet.wasm +0 -0
- package/dist/assets/workers/{BaiduVectorParser.worker-d550338e.js → BaiduVectorParser.worker-486240e8.js} +977 -930
- package/dist/assets/workers/{CesiumTerrainParser.worker-20119751.js → CesiumTerrainParser.worker-ba35b937.js} +1032 -954
- package/dist/assets/workers/{MVTParser.worker-7dc8b0e4.js → MVTParser.worker-bb80e3b4.js} +755 -699
- package/dist/devtool/panel.js +108 -29
- package/dist/mapvthree.module.js +45540 -46298
- package/dist/mapvthree.umd.js +13 -7
- package/dist/types/Internal.d.ts +2 -0
- package/dist/types/adapters/bmap/Icon.d.ts +18 -0
- package/dist/types/adapters/bmap/InfoWindow.d.ts +124 -0
- package/dist/types/adapters/bmap/Label.d.ts +58 -0
- package/dist/types/adapters/bmap/Map.d.ts +124 -0
- package/dist/types/adapters/bmap/Marker.d.ts +28 -0
- package/dist/types/adapters/bmap/Overlay.d.ts +18 -0
- package/dist/types/adapters/bmap/Pixel.d.ts +1 -0
- package/dist/types/adapters/bmap/Point.d.ts +8 -0
- package/dist/types/adapters/bmap/Size.d.ts +8 -0
- package/dist/types/adapters/bmap/index.d.ts +8 -0
- package/dist/types/adapters/index.d.ts +1 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.open.d.ts +5 -0
- package/dist/types/threejs/controls/PointerLockControls.d.ts +2 -0
- package/dist/types/threejs/geometries/text/ScreenTextGeometry.d.ts +15 -0
- package/dist/types/threejs/loaders/utilities/BatchTableHierarchyExtension.d.ts +4 -4
- package/dist/types/threejs/loaders/utilities/FeatureTable.d.ts +1 -1
- package/dist/types/threejs/materials/effects/LightningBillboardMaterial.d.ts +3 -0
- package/dist/types/threejs/materials/effects/LightningMaterial.d.ts +9 -0
- package/dist/types/threejs/materials/extend/ExtendMeshStandardMaterial.d.ts +1 -0
- package/dist/types/threejs/materials/natural/DynamicSkyMaterial.d.ts +1 -0
- package/dist/types/threejs/materials/natural/StaticSkyMaterial.d.ts +1 -0
- package/dist/types/threejs/materials/natural/VerticalGradientSkyMaterial.d.ts +1 -0
- package/dist/types/threejs/materials/polygon/PolygonMaterial.d.ts +1 -0
- package/dist/types/threejs/materials/text/ScreenTextMaterial.d.ts +25 -0
- package/dist/types/threejs/objects/GeoInstancedMesh.d.ts +1 -0
- package/dist/types/threejs/objects/line/FatLineInternal.d.ts +4 -0
- package/dist/types/threejs/objects/line/Polyline.d.ts +1 -1
- package/dist/types/threejs/objects/point/Icon.d.ts +1 -0
- package/dist/types/threejs/objects/point/Label.d.ts +15 -2
- package/dist/types/threejs/objects/point/label/GeometryBufferBuilder.d.ts +3 -0
- package/dist/types/threejs/objects/point/label/TextBoxCalculator.d.ts +5 -3
- package/dist/types/threejs/objects/text/ScreenText.d.ts +273 -0
- package/dist/types/threejs/objects/text/font-atlas-manager.d.ts +10 -2
- package/dist/types/threejs/objects/text/utils.d.ts +1 -1
- package/dist/types/threemap/3dtiles/HDMap3DTiles.d.ts +26 -0
- package/dist/types/threemap/3dtiles/materials/Default3DTilesMaterialManager.d.ts +51 -3
- package/dist/types/threemap/Engine.d.ts +23 -4
- package/dist/types/threemap/animations/ObjectTracker.d.ts +73 -44
- package/dist/types/threemap/animations/PathTracker.d.ts +92 -24
- package/dist/types/threemap/animations/RotateTracker.d.ts +115 -21
- package/dist/types/threemap/animations/TrackerAbstract.d.ts +15 -11
- package/dist/types/threemap/controls/PointerLockControls.d.ts +8 -2
- package/dist/types/threemap/controls/controller/ColumbusController.d.ts +10 -0
- package/dist/types/threemap/controls/controller/Scene3DController.d.ts +9 -0
- package/dist/types/threemap/controls/editors/Editor.d.ts +3 -0
- package/dist/types/threemap/engine/Clock.d.ts +156 -0
- package/dist/types/threemap/engine/Controller.d.ts +141 -0
- package/dist/types/threemap/engine/Map.d.ts +34 -4
- package/dist/types/threemap/engine/Rendering.d.ts +15 -0
- package/dist/types/threemap/engine/event/EntityProxy.d.ts +1 -0
- package/dist/types/threemap/engine/map/BlankMap.d.ts +1 -1
- package/dist/types/threemap/engine/map/BlankMap3DControl.d.ts +4 -1
- package/dist/types/{threejs → threemap/engine/map}/controls/DraggingMovementAggregator.d.ts +3 -0
- package/dist/types/{threejs → threemap/engine/map}/controls/MapControl3D.d.ts +19 -2
- package/dist/types/{threejs → threemap/engine/map}/controls/PointerMovementAggregator.d.ts +3 -0
- package/dist/types/threemap/engine/map/earth/Earth.d.ts +1 -0
- package/dist/types/threemap/engine/rendering/Collision.d.ts +5 -0
- package/dist/types/threemap/engine/rendering/Label.d.ts +15 -0
- package/dist/types/threemap/engine/rendering/MainNew.d.ts +1 -1
- package/dist/types/threemap/engine/rendering/postprocessing/OpaquePostprocessings.d.ts +1 -1
- package/dist/types/threemap/engine/rendering/postprocessing/SkyAtmospherePass.d.ts +1 -0
- package/dist/types/threemap/engine/rendering/scene/DirectSceneRendering.d.ts +5 -0
- package/dist/types/threemap/mapView/geo/terrainData/QuantizedMeshTerrainData.d.ts +1 -1
- package/dist/types/threemap/mapView/grid/BaiduVectorOfflineGrid.d.ts +5 -0
- package/dist/types/threemap/mapView/map/MapView.d.ts +3 -0
- package/dist/types/threemap/mapView/parser/baidulane/ElementParser.d.ts +86 -0
- package/dist/types/threemap/mapView/parser/baidulane/StyleParser.d.ts +28 -0
- package/dist/types/threemap/mapView/parser/baidulane/constants/index.d.ts +25 -0
- package/dist/types/threemap/mapView/parser/baidulane/constants/types.d.ts +47 -0
- package/dist/types/threemap/mapView/parser/baidulane/core/GeometryBuilder.d.ts +40 -0
- package/dist/types/threemap/mapView/parser/baidulane/core/LayerManager.d.ts +41 -0
- package/dist/types/threemap/mapView/parser/baidulane/core/MaterialFactory.d.ts +71 -0
- package/dist/types/threemap/mapView/parser/baidulane/core/StyleManager.d.ts +50 -0
- package/dist/types/threemap/mapView/parser/baidulane/core/TextureManager.d.ts +65 -0
- package/dist/types/threemap/mapView/parser/baidulane/core/wasmManager.d.ts +18 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Base.d.ts +46 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Building3d.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/FlatSymbol.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/LabelLine.d.ts +36 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Line.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Line3d.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Line3dTexture.d.ts +3 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/LineDash.d.ts +7 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/LineTexture.d.ts +7 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Poi.d.ts +26 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Polygon.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/Polygon3d.d.ts +40 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/PolygonExtrude.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/PolygonExtrudeTexture.d.ts +18 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/PolygonOpacity.d.ts +7 -0
- package/dist/types/threemap/mapView/parser/baidulane/generators/SimplePoint.d.ts +39 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/Background.d.ts +11 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/Base.d.ts +27 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/BridgePier.d.ts +20 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/DebugLine.d.ts +16 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/DebugPoint.d.ts +5 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/DebugPolygon.d.ts +20 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/GaoqingGradient.d.ts +16 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/GaoqingGuide.d.ts +11 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/GaoqingLine.d.ts +11 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/GaoqingPoly.d.ts +15 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/GaoqingRoad.d.ts +13 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/HRegion.d.ts +11 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/LineName.d.ts +48 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/Link.d.ts +10 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/Poi.d.ts +7 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/Poly.d.ts +11 -0
- package/dist/types/threemap/mapView/parser/baidulane/processors/Texture.d.ts +10 -0
- package/dist/types/threemap/mapView/parser/baidulane/utils/color.d.ts +13 -0
- package/dist/types/threemap/mapView/parser/baidulane/utils/coordinate.d.ts +18 -0
- package/dist/types/threemap/mapView/parser/baidulane/utils/geometry.d.ts +3 -0
- package/dist/types/threemap/mapView/parser/baidulane/utils/icon.d.ts +8 -0
- package/dist/types/threemap/mapView/parser/baidulane/utils/merge.d.ts +7 -0
- package/dist/types/threemap/mapView/parser/baidulane/utils/tracer.d.ts +7 -0
- package/dist/types/{util/mapbox.d.ts → threemap/mapView/parser/mapbox/util.d.ts} +1 -1
- package/dist/types/threemap/mapView/surface/GroundSceneRenderer.d.ts +7 -2
- package/dist/types/threemap/mapView/surface/MapSurface.d.ts +2 -0
- package/dist/types/threemap/mapView/surface/strategy/FastTileLoaderStrategy.d.ts +16 -0
- package/dist/types/threemap/mapView/tileProvider/terrain/CesiumTerrainTileProvider.d.ts +3 -0
- package/dist/types/threemap/mapView/tileProvider/vector/BaiduLaneVectorTileProvider.d.ts +7 -0
- package/dist/types/threemap/mapView/tileProvider/vector/BaiduVectorTileProvider.d.ts +3 -0
- package/dist/types/threemap/mapView/tileProvider/vector/MapboxVectorTileProvider.d.ts +6 -10
- package/dist/types/threemap/mapView/utils/createGroundTileMesh.d.ts +2 -1
- package/dist/types/threemap/mapView/utils/projectVertices.d.ts +1 -1
- package/dist/types/threemap/materials/BatchBuildingMaterial.d.ts +9 -11
- package/dist/types/threemap/materials/RoadMarkingMaterial.d.ts +2 -11
- package/dist/types/threemap/materials/TerrainClassificationMaterial.d.ts +9 -7
- package/dist/types/threemap/natural/DynamicSky.d.ts +68 -22
- package/dist/types/threemap/natural/DynamicWeather.d.ts +17 -105
- package/dist/types/threemap/natural/EmptySky.d.ts +48 -62
- package/dist/types/threemap/natural/PhysicalSky.d.ts +220 -0
- package/dist/types/threemap/natural/Rain.d.ts +5 -2
- package/dist/types/threemap/natural/Snow.d.ts +5 -2
- package/dist/types/threemap/natural/StaticSky.d.ts +1 -0
- package/dist/types/threemap/natural/Thunderstorm.d.ts +46 -0
- package/dist/types/threemap/natural/clouds/CascadedShadowMaps.d.ts +31 -0
- package/dist/types/threemap/natural/clouds/CloudLayer.d.ts +19 -0
- package/dist/types/threemap/natural/clouds/CloudLayers.d.ts +13 -0
- package/dist/types/threemap/natural/clouds/CloudShape.d.ts +4 -0
- package/dist/types/threemap/natural/clouds/CloudShapeDetail.d.ts +4 -0
- package/dist/types/threemap/natural/clouds/CloudsEffect.d.ts +173 -0
- package/dist/types/threemap/natural/clouds/CloudsMaterial.d.ts +35 -0
- package/dist/types/threemap/natural/clouds/CloudsPass.d.ts +39 -0
- package/dist/types/threemap/natural/clouds/CloudsPostPass.d.ts +10 -0
- package/dist/types/threemap/natural/clouds/CloudsResolveMaterial.d.ts +13 -0
- package/dist/types/threemap/natural/clouds/DensityProfile.d.ts +10 -0
- package/dist/types/threemap/natural/clouds/LocalWeather.d.ts +4 -0
- package/dist/types/threemap/natural/clouds/PassBase.d.ts +7 -0
- package/dist/types/threemap/natural/clouds/Procedural3DTexture.d.ts +15 -0
- package/dist/types/threemap/natural/clouds/ProceduralTexture.d.ts +15 -0
- package/dist/types/threemap/natural/clouds/ShaderArrayPass.d.ts +3 -0
- package/dist/types/threemap/natural/clouds/ShadowMaterial.d.ts +14 -0
- package/dist/types/threemap/natural/clouds/ShadowPass.d.ts +31 -0
- package/dist/types/threemap/natural/clouds/ShadowResolveMaterial.d.ts +8 -0
- package/dist/types/threemap/natural/clouds/Turbulence.d.ts +4 -0
- package/dist/types/threemap/natural/clouds/bayer.d.ts +2 -0
- package/dist/types/threemap/natural/clouds/constants.d.ts +6 -0
- package/dist/types/threemap/natural/clouds/helpers/FrustumCorners.d.ts +10 -0
- package/dist/types/threemap/natural/clouds/helpers/setArrayRenderTargetLayers.d.ts +1 -0
- package/dist/types/threemap/natural/clouds/helpers/splitFrustum.d.ts +6 -0
- package/dist/types/threemap/natural/clouds/qualityPresets.d.ts +130 -0
- package/dist/types/threemap/natural/clouds/uniforms.d.ts +44 -0
- package/dist/types/threemap/natural/core/ArrayBufferLoader.d.ts +3 -0
- package/dist/types/threemap/natural/core/DataTextureLoader.d.ts +11 -0
- package/dist/types/threemap/natural/core/Ellipsoid.d.ts +17 -0
- package/dist/types/threemap/natural/core/Geodetic.d.ts +23 -0
- package/dist/types/threemap/natural/core/TypedArrayLoader.d.ts +5 -0
- package/dist/types/threemap/natural/core/capabilities.d.ts +1 -0
- package/dist/types/threemap/natural/core/celestialDirections.d.ts +5 -0
- package/dist/types/threemap/natural/core/decorators.d.ts +61 -0
- package/dist/types/threemap/natural/core/defineShorthand.d.ts +2 -0
- package/dist/types/threemap/natural/core/helpers/projectOnEllipsoidSurface.d.ts +1 -0
- package/dist/types/threemap/natural/core/math.d.ts +15 -0
- package/dist/types/threemap/natural/core/requestIdleCallback.d.ts +2 -0
- package/dist/types/threemap/natural/core/resolveIncludes.d.ts +1 -0
- package/dist/types/threemap/natural/core/shaders/index.d.ts +10 -0
- package/dist/types/threemap/natural/core/unrollLoops.d.ts +1 -0
- package/dist/types/threemap/natural/effects/DepthEffect.d.ts +15 -0
- package/dist/types/threemap/natural/effects/DitheringEffect.d.ts +6 -0
- package/dist/types/threemap/natural/effects/DownsampleThresholdMaterial.d.ts +14 -0
- package/dist/types/threemap/natural/effects/GeometryEffect.d.ts +11 -0
- package/dist/types/threemap/natural/effects/GeometryPass.d.ts +6 -0
- package/dist/types/threemap/natural/effects/LensFlareEffect.d.ts +31 -0
- package/dist/types/threemap/natural/effects/LensFlareFeaturesMaterial.d.ts +17 -0
- package/dist/types/threemap/natural/effects/NormalEffect.d.ts +16 -0
- package/dist/types/threemap/natural/effects/createHaldLookupTexture.d.ts +1 -0
- package/dist/types/threemap/natural/effects/index.d.ts +7 -0
- package/dist/types/threemap/natural/effects/setupMaterialsForGeometryPass.d.ts +1 -0
- package/dist/types/threemap/natural/sky/AerialPerspectiveEffect.d.ts +95 -0
- package/dist/types/threemap/natural/sky/AtmosphereMaterialBase.d.ts +40 -0
- package/dist/types/threemap/natural/sky/AtmosphereParameters.d.ts +32 -0
- package/dist/types/threemap/natural/sky/AtmospherePostPass.d.ts +10 -0
- package/dist/types/threemap/natural/sky/PrecomputedTexturesGenerator.d.ts +66 -0
- package/dist/types/threemap/natural/sky/SkyMaterial.d.ts +26 -0
- package/dist/types/threemap/natural/sky/constants.d.ts +14 -0
- package/dist/types/threemap/natural/sky/getAltitudeCorrectionOffset.d.ts +1 -0
- package/dist/types/threemap/overlay/Marker.d.ts +3 -0
- package/dist/types/threemap/services/autoComplete/AutoComplete.d.ts +1 -1
- package/dist/types/threemap/services/boundary/Boundary.d.ts +3 -3
- package/dist/types/threemap/services/common/baiduRequest.d.ts +1 -1
- package/dist/types/threemap/services/configs.d.ts +2 -2
- package/dist/types/threemap/services/district/DistrictLayer.d.ts +3 -3
- package/dist/types/threemap/services/geocoder/Geocoder.d.ts +5 -5
- package/dist/types/threemap/services/localSearch/LocalSearch.d.ts +5 -5
- package/dist/types/threemap/services/routeSearch/DrivingRoute.d.ts +2 -2
- package/dist/types/threemap/services/routeSearch/TransitRoute.d.ts +3 -3
- package/dist/types/threemap/video/VideoConfig.d.ts +2 -2
- package/dist/types/util/graphics/line.d.ts +2 -2
- package/dist/types/util/request.d.ts +1 -1
- package/package.json +6 -3
- /package/dist/types/{threejs → threemap/engine/map}/controls/MapControl.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/color.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/executer/background.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/executer/fill-extrusion.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/executer/fill.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/executer/index.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/executer/line.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/executer/symbol.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/compound_expression.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/assertion.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/at.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/case.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/coalesce.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/coercion.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/collator.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/comparison.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/format.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/image.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/in.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/index.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/index_of.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/interpolate.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/length.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/let.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/literal.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/match.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/number_format.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/slice.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/step.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/var.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/definitions/within.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/evaluation_context.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/expression.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/index.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/is_constant.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/parsing_context.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/parsing_error.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/scope.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/stops.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/types/collator.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/types/formatted.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/types/resolved_image.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/types.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/expression/values.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/feature_filter/index.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/function/convert.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/function/index.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/sourceLayer.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/sprite.d.ts +0 -0
- /package/dist/types/threemap/mapView/{mapbox → parser/mapbox}/style.d.ts +0 -0
|
@@ -495,11 +495,16 @@ function initRuntime() {
|
|
|
495
495
|
|
|
496
496
|
checkStackCookie();
|
|
497
497
|
|
|
498
|
-
//
|
|
498
|
+
// Begin ATINITS hooks
|
|
499
|
+
if (!Module['noFSInit'] && !FS.initialized) FS.init();
|
|
500
|
+
TTY.init();
|
|
501
|
+
// End ATINITS hooks
|
|
499
502
|
|
|
500
503
|
wasmExports['__wasm_call_ctors']();
|
|
501
504
|
|
|
502
|
-
//
|
|
505
|
+
// Begin ATPOSTCTORS hooks
|
|
506
|
+
FS.ignorePermissions = false;
|
|
507
|
+
// End ATPOSTCTORS hooks
|
|
503
508
|
}
|
|
504
509
|
|
|
505
510
|
function postRun() {
|
|
@@ -620,24 +625,6 @@ function abort(what) {
|
|
|
620
625
|
throw e;
|
|
621
626
|
}
|
|
622
627
|
|
|
623
|
-
// show errors on likely calls to FS when it was not included
|
|
624
|
-
var FS = {
|
|
625
|
-
error() {
|
|
626
|
-
abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM');
|
|
627
|
-
},
|
|
628
|
-
init() { FS.error() },
|
|
629
|
-
createDataFile() { FS.error() },
|
|
630
|
-
createPreloadedFile() { FS.error() },
|
|
631
|
-
createLazyFile() { FS.error() },
|
|
632
|
-
open() { FS.error() },
|
|
633
|
-
mkdev() { FS.error() },
|
|
634
|
-
registerDevice() { FS.error() },
|
|
635
|
-
analyzePath() { FS.error() },
|
|
636
|
-
|
|
637
|
-
ErrnoError() { FS.error() },
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
|
|
641
628
|
function createExportWrapper(name, nargs) {
|
|
642
629
|
return (...args) => {
|
|
643
630
|
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
|
|
@@ -996,8 +983,22 @@ var tempI64;
|
|
|
996
983
|
return ___cxa_get_exception_ptr(ptr);
|
|
997
984
|
};
|
|
998
985
|
|
|
986
|
+
|
|
999
987
|
var exceptionLast = 0;
|
|
1000
988
|
|
|
989
|
+
|
|
990
|
+
var ___cxa_end_catch = () => {
|
|
991
|
+
// Clear state flag.
|
|
992
|
+
_setThrew(0, 0);
|
|
993
|
+
assert(exceptionCaught.length > 0);
|
|
994
|
+
// Call destructor if one is registered then clear it.
|
|
995
|
+
var info = exceptionCaught.pop();
|
|
996
|
+
|
|
997
|
+
___cxa_decrement_exception_refcount(info.excPtr);
|
|
998
|
+
exceptionLast = 0; // XXX in decRef?
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
|
|
1001
1002
|
class ExceptionInfo {
|
|
1002
1003
|
// excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it.
|
|
1003
1004
|
constructor(excPtr) {
|
|
@@ -1099,6 +1100,25 @@ var tempI64;
|
|
|
1099
1100
|
|
|
1100
1101
|
|
|
1101
1102
|
|
|
1103
|
+
var ___cxa_rethrow = () => {
|
|
1104
|
+
var info = exceptionCaught.pop();
|
|
1105
|
+
if (!info) {
|
|
1106
|
+
abort('no exception to throw');
|
|
1107
|
+
}
|
|
1108
|
+
var ptr = info.excPtr;
|
|
1109
|
+
if (!info.get_rethrown()) {
|
|
1110
|
+
// Only pop if the corresponding push was through rethrow_primary_exception
|
|
1111
|
+
exceptionCaught.push(info);
|
|
1112
|
+
info.set_rethrown(true);
|
|
1113
|
+
info.set_caught(false);
|
|
1114
|
+
uncaughtExceptionCount++;
|
|
1115
|
+
}
|
|
1116
|
+
exceptionLast = new CppException(ptr);
|
|
1117
|
+
throw exceptionLast;
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1102
1122
|
var ___cxa_throw = (ptr, type, destructor) => {
|
|
1103
1123
|
var info = new ExceptionInfo(ptr);
|
|
1104
1124
|
// Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
|
|
@@ -1108,6 +1128,8 @@ var tempI64;
|
|
|
1108
1128
|
throw exceptionLast;
|
|
1109
1129
|
};
|
|
1110
1130
|
|
|
1131
|
+
var ___cxa_uncaught_exceptions = () => uncaughtExceptionCount;
|
|
1132
|
+
|
|
1111
1133
|
var ___resumeException = (ptr) => {
|
|
1112
1134
|
if (!exceptionLast) {
|
|
1113
1135
|
exceptionLast = new CppException(ptr);
|
|
@@ -1118,6 +1140,134 @@ var tempI64;
|
|
|
1118
1140
|
var __abort_js = () =>
|
|
1119
1141
|
abort('native code called abort()');
|
|
1120
1142
|
|
|
1143
|
+
var structRegistrations = {
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
var runDestructors = (destructors) => {
|
|
1147
|
+
while (destructors.length) {
|
|
1148
|
+
var ptr = destructors.pop();
|
|
1149
|
+
var del = destructors.pop();
|
|
1150
|
+
del(ptr);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
/** @suppress {globalThis} */
|
|
1155
|
+
function readPointer(pointer) {
|
|
1156
|
+
return this.fromWireType(HEAPU32[((pointer)>>2)]);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
var awaitingDependencies = {
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
var registeredTypes = {
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
var typeDependencies = {
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
var InternalError = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
|
|
1169
|
+
var throwInternalError = (message) => { throw new InternalError(message); };
|
|
1170
|
+
var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
|
|
1171
|
+
myTypes.forEach((type) => typeDependencies[type] = dependentTypes);
|
|
1172
|
+
|
|
1173
|
+
function onComplete(typeConverters) {
|
|
1174
|
+
var myTypeConverters = getTypeConverters(typeConverters);
|
|
1175
|
+
if (myTypeConverters.length !== myTypes.length) {
|
|
1176
|
+
throwInternalError('Mismatched type converter count');
|
|
1177
|
+
}
|
|
1178
|
+
for (var i = 0; i < myTypes.length; ++i) {
|
|
1179
|
+
registerType(myTypes[i], myTypeConverters[i]);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
var typeConverters = new Array(dependentTypes.length);
|
|
1184
|
+
var unregisteredTypes = [];
|
|
1185
|
+
var registered = 0;
|
|
1186
|
+
dependentTypes.forEach((dt, i) => {
|
|
1187
|
+
if (registeredTypes.hasOwnProperty(dt)) {
|
|
1188
|
+
typeConverters[i] = registeredTypes[dt];
|
|
1189
|
+
} else {
|
|
1190
|
+
unregisteredTypes.push(dt);
|
|
1191
|
+
if (!awaitingDependencies.hasOwnProperty(dt)) {
|
|
1192
|
+
awaitingDependencies[dt] = [];
|
|
1193
|
+
}
|
|
1194
|
+
awaitingDependencies[dt].push(() => {
|
|
1195
|
+
typeConverters[i] = registeredTypes[dt];
|
|
1196
|
+
++registered;
|
|
1197
|
+
if (registered === unregisteredTypes.length) {
|
|
1198
|
+
onComplete(typeConverters);
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
if (0 === unregisteredTypes.length) {
|
|
1204
|
+
onComplete(typeConverters);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
var __embind_finalize_value_object = (structType) => {
|
|
1208
|
+
var reg = structRegistrations[structType];
|
|
1209
|
+
delete structRegistrations[structType];
|
|
1210
|
+
|
|
1211
|
+
var rawConstructor = reg.rawConstructor;
|
|
1212
|
+
var rawDestructor = reg.rawDestructor;
|
|
1213
|
+
var fieldRecords = reg.fields;
|
|
1214
|
+
var fieldTypes = fieldRecords.map((field) => field.getterReturnType).
|
|
1215
|
+
concat(fieldRecords.map((field) => field.setterArgumentType));
|
|
1216
|
+
whenDependentTypesAreResolved([structType], fieldTypes, (fieldTypes) => {
|
|
1217
|
+
var fields = {};
|
|
1218
|
+
fieldRecords.forEach((field, i) => {
|
|
1219
|
+
var fieldName = field.fieldName;
|
|
1220
|
+
var getterReturnType = fieldTypes[i];
|
|
1221
|
+
var optional = fieldTypes[i].optional;
|
|
1222
|
+
var getter = field.getter;
|
|
1223
|
+
var getterContext = field.getterContext;
|
|
1224
|
+
var setterArgumentType = fieldTypes[i + fieldRecords.length];
|
|
1225
|
+
var setter = field.setter;
|
|
1226
|
+
var setterContext = field.setterContext;
|
|
1227
|
+
fields[fieldName] = {
|
|
1228
|
+
read: (ptr) => getterReturnType.fromWireType(getter(getterContext, ptr)),
|
|
1229
|
+
write: (ptr, o) => {
|
|
1230
|
+
var destructors = [];
|
|
1231
|
+
setter(setterContext, ptr, setterArgumentType.toWireType(destructors, o));
|
|
1232
|
+
runDestructors(destructors);
|
|
1233
|
+
},
|
|
1234
|
+
optional,
|
|
1235
|
+
};
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
return [{
|
|
1239
|
+
name: reg.name,
|
|
1240
|
+
fromWireType: (ptr) => {
|
|
1241
|
+
var rv = {};
|
|
1242
|
+
for (var i in fields) {
|
|
1243
|
+
rv[i] = fields[i].read(ptr);
|
|
1244
|
+
}
|
|
1245
|
+
rawDestructor(ptr);
|
|
1246
|
+
return rv;
|
|
1247
|
+
},
|
|
1248
|
+
toWireType: (destructors, o) => {
|
|
1249
|
+
// todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
|
|
1250
|
+
// assume all fields are present without checking.
|
|
1251
|
+
for (var fieldName in fields) {
|
|
1252
|
+
if (!(fieldName in o) && !fields[fieldName].optional) {
|
|
1253
|
+
throw new TypeError(`Missing field: "${fieldName}"`);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
var ptr = rawConstructor();
|
|
1257
|
+
for (fieldName in fields) {
|
|
1258
|
+
fields[fieldName].write(ptr, o[fieldName]);
|
|
1259
|
+
}
|
|
1260
|
+
if (destructors !== null) {
|
|
1261
|
+
destructors.push(rawDestructor, ptr);
|
|
1262
|
+
}
|
|
1263
|
+
return ptr;
|
|
1264
|
+
},
|
|
1265
|
+
readValueFromPointer: readPointer,
|
|
1266
|
+
destructorFunction: rawDestructor,
|
|
1267
|
+
}];
|
|
1268
|
+
});
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1121
1271
|
var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => {};
|
|
1122
1272
|
|
|
1123
1273
|
var AsciiToString = (ptr) => {
|
|
@@ -1129,14 +1279,8 @@ var tempI64;
|
|
|
1129
1279
|
}
|
|
1130
1280
|
};
|
|
1131
1281
|
|
|
1132
|
-
var awaitingDependencies = {
|
|
1133
|
-
};
|
|
1134
1282
|
|
|
1135
|
-
var registeredTypes = {
|
|
1136
|
-
};
|
|
1137
1283
|
|
|
1138
|
-
var typeDependencies = {
|
|
1139
|
-
};
|
|
1140
1284
|
|
|
1141
1285
|
var BindingError = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }};
|
|
1142
1286
|
var throwBindingError = (message) => { throw new BindingError(message); };
|
|
@@ -1263,8 +1407,6 @@ var tempI64;
|
|
|
1263
1407
|
return registeredInstances[ptr];
|
|
1264
1408
|
};
|
|
1265
1409
|
|
|
1266
|
-
var InternalError = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
|
|
1267
|
-
var throwInternalError = (message) => { throw new InternalError(message); };
|
|
1268
1410
|
|
|
1269
1411
|
var makeClassHandle = (prototype, record) => {
|
|
1270
1412
|
if (!record.ptrType || !record.ptr) {
|
|
@@ -1732,10 +1874,6 @@ var tempI64;
|
|
|
1732
1874
|
}
|
|
1733
1875
|
|
|
1734
1876
|
|
|
1735
|
-
/** @suppress {globalThis} */
|
|
1736
|
-
function readPointer(pointer) {
|
|
1737
|
-
return this.fromWireType(HEAPU32[((pointer)>>2)]);
|
|
1738
|
-
}
|
|
1739
1877
|
|
|
1740
1878
|
var init_RegisteredPointer = () => {
|
|
1741
1879
|
Object.assign(RegisteredPointer.prototype, {
|
|
@@ -1930,46 +2068,6 @@ var tempI64;
|
|
|
1930
2068
|
throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
|
|
1931
2069
|
};
|
|
1932
2070
|
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
|
|
1937
|
-
myTypes.forEach((type) => typeDependencies[type] = dependentTypes);
|
|
1938
|
-
|
|
1939
|
-
function onComplete(typeConverters) {
|
|
1940
|
-
var myTypeConverters = getTypeConverters(typeConverters);
|
|
1941
|
-
if (myTypeConverters.length !== myTypes.length) {
|
|
1942
|
-
throwInternalError('Mismatched type converter count');
|
|
1943
|
-
}
|
|
1944
|
-
for (var i = 0; i < myTypes.length; ++i) {
|
|
1945
|
-
registerType(myTypes[i], myTypeConverters[i]);
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
var typeConverters = new Array(dependentTypes.length);
|
|
1950
|
-
var unregisteredTypes = [];
|
|
1951
|
-
var registered = 0;
|
|
1952
|
-
dependentTypes.forEach((dt, i) => {
|
|
1953
|
-
if (registeredTypes.hasOwnProperty(dt)) {
|
|
1954
|
-
typeConverters[i] = registeredTypes[dt];
|
|
1955
|
-
} else {
|
|
1956
|
-
unregisteredTypes.push(dt);
|
|
1957
|
-
if (!awaitingDependencies.hasOwnProperty(dt)) {
|
|
1958
|
-
awaitingDependencies[dt] = [];
|
|
1959
|
-
}
|
|
1960
|
-
awaitingDependencies[dt].push(() => {
|
|
1961
|
-
typeConverters[i] = registeredTypes[dt];
|
|
1962
|
-
++registered;
|
|
1963
|
-
if (registered === unregisteredTypes.length) {
|
|
1964
|
-
onComplete(typeConverters);
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
}
|
|
1968
|
-
});
|
|
1969
|
-
if (0 === unregisteredTypes.length) {
|
|
1970
|
-
onComplete(typeConverters);
|
|
1971
|
-
}
|
|
1972
|
-
};
|
|
1973
2071
|
var __embind_register_class = (rawType,
|
|
1974
2072
|
rawPointerType,
|
|
1975
2073
|
rawConstPointerType,
|
|
@@ -2089,13 +2187,6 @@ var tempI64;
|
|
|
2089
2187
|
|
|
2090
2188
|
|
|
2091
2189
|
|
|
2092
|
-
var runDestructors = (destructors) => {
|
|
2093
|
-
while (destructors.length) {
|
|
2094
|
-
var ptr = destructors.pop();
|
|
2095
|
-
var del = destructors.pop();
|
|
2096
|
-
del(ptr);
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
2190
|
|
|
2100
2191
|
|
|
2101
2192
|
function usesDestructorStack(argTypes) {
|
|
@@ -3064,6 +3155,49 @@ var tempI64;
|
|
|
3064
3155
|
};
|
|
3065
3156
|
|
|
3066
3157
|
|
|
3158
|
+
|
|
3159
|
+
var __embind_register_value_object = (
|
|
3160
|
+
rawType,
|
|
3161
|
+
name,
|
|
3162
|
+
constructorSignature,
|
|
3163
|
+
rawConstructor,
|
|
3164
|
+
destructorSignature,
|
|
3165
|
+
rawDestructor
|
|
3166
|
+
) => {
|
|
3167
|
+
structRegistrations[rawType] = {
|
|
3168
|
+
name: AsciiToString(name),
|
|
3169
|
+
rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
|
|
3170
|
+
rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
|
|
3171
|
+
fields: [],
|
|
3172
|
+
};
|
|
3173
|
+
};
|
|
3174
|
+
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
var __embind_register_value_object_field = (
|
|
3178
|
+
structType,
|
|
3179
|
+
fieldName,
|
|
3180
|
+
getterReturnType,
|
|
3181
|
+
getterSignature,
|
|
3182
|
+
getter,
|
|
3183
|
+
getterContext,
|
|
3184
|
+
setterArgumentType,
|
|
3185
|
+
setterSignature,
|
|
3186
|
+
setter,
|
|
3187
|
+
setterContext
|
|
3188
|
+
) => {
|
|
3189
|
+
structRegistrations[structType].fields.push({
|
|
3190
|
+
fieldName: AsciiToString(fieldName),
|
|
3191
|
+
getterReturnType,
|
|
3192
|
+
getter: embind__requireFunction(getterSignature, getter),
|
|
3193
|
+
getterContext,
|
|
3194
|
+
setterArgumentType,
|
|
3195
|
+
setter: embind__requireFunction(setterSignature, setter),
|
|
3196
|
+
setterContext,
|
|
3197
|
+
});
|
|
3198
|
+
};
|
|
3199
|
+
|
|
3200
|
+
|
|
3067
3201
|
var __embind_register_void = (rawType, name) => {
|
|
3068
3202
|
name = AsciiToString(name);
|
|
3069
3203
|
registerType(rawType, {
|
|
@@ -3179,6 +3313,60 @@ var tempI64;
|
|
|
3179
3313
|
__emval_decref(handle);
|
|
3180
3314
|
};
|
|
3181
3315
|
|
|
3316
|
+
|
|
3317
|
+
var __tzset_js = (timezone, daylight, std_name, dst_name) => {
|
|
3318
|
+
// TODO: Use (malleable) environment variables instead of system settings.
|
|
3319
|
+
var currentYear = new Date().getFullYear();
|
|
3320
|
+
var winter = new Date(currentYear, 0, 1);
|
|
3321
|
+
var summer = new Date(currentYear, 6, 1);
|
|
3322
|
+
var winterOffset = winter.getTimezoneOffset();
|
|
3323
|
+
var summerOffset = summer.getTimezoneOffset();
|
|
3324
|
+
|
|
3325
|
+
// Local standard timezone offset. Local standard time is not adjusted for
|
|
3326
|
+
// daylight savings. This code uses the fact that getTimezoneOffset returns
|
|
3327
|
+
// a greater value during Standard Time versus Daylight Saving Time (DST).
|
|
3328
|
+
// Thus it determines the expected output during Standard Time, and it
|
|
3329
|
+
// compares whether the output of the given date the same (Standard) or less
|
|
3330
|
+
// (DST).
|
|
3331
|
+
var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
|
|
3332
|
+
|
|
3333
|
+
// timezone is specified as seconds west of UTC ("The external variable
|
|
3334
|
+
// `timezone` shall be set to the difference, in seconds, between
|
|
3335
|
+
// Coordinated Universal Time (UTC) and local standard time."), the same
|
|
3336
|
+
// as returned by stdTimezoneOffset.
|
|
3337
|
+
// See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
|
|
3338
|
+
HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;
|
|
3339
|
+
|
|
3340
|
+
HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);
|
|
3341
|
+
|
|
3342
|
+
var extractZone = (timezoneOffset) => {
|
|
3343
|
+
// Why inverse sign?
|
|
3344
|
+
// Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
|
|
3345
|
+
var sign = timezoneOffset >= 0 ? "-" : "+";
|
|
3346
|
+
|
|
3347
|
+
var absOffset = Math.abs(timezoneOffset)
|
|
3348
|
+
var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
|
|
3349
|
+
var minutes = String(absOffset % 60).padStart(2, "0");
|
|
3350
|
+
|
|
3351
|
+
return `UTC${sign}${hours}${minutes}`;
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
var winterName = extractZone(winterOffset);
|
|
3355
|
+
var summerName = extractZone(summerOffset);
|
|
3356
|
+
assert(winterName);
|
|
3357
|
+
assert(summerName);
|
|
3358
|
+
assert(lengthBytesUTF8(winterName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${winterName})`);
|
|
3359
|
+
assert(lengthBytesUTF8(summerName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${summerName})`);
|
|
3360
|
+
if (summerOffset < winterOffset) {
|
|
3361
|
+
// Northern hemisphere
|
|
3362
|
+
stringToUTF8(winterName, std_name, 17);
|
|
3363
|
+
stringToUTF8(summerName, dst_name, 17);
|
|
3364
|
+
} else {
|
|
3365
|
+
stringToUTF8(winterName, dst_name, 17);
|
|
3366
|
+
stringToUTF8(summerName, std_name, 17);
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3369
|
+
|
|
3182
3370
|
var getHeapMax = () =>
|
|
3183
3371
|
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
3184
3372
|
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
@@ -3258,87 +3446,2793 @@ var tempI64;
|
|
|
3258
3446
|
return false;
|
|
3259
3447
|
};
|
|
3260
3448
|
|
|
3261
|
-
var
|
|
3262
|
-
varargs:undefined,
|
|
3263
|
-
getStr(ptr) {
|
|
3264
|
-
var ret = UTF8ToString(ptr);
|
|
3265
|
-
return ret;
|
|
3266
|
-
},
|
|
3449
|
+
var ENV = {
|
|
3267
3450
|
};
|
|
3268
|
-
var _fd_close = (fd) => {
|
|
3269
|
-
abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
|
|
3270
|
-
};
|
|
3271
|
-
|
|
3272
|
-
var convertI32PairToI53Checked = (lo, hi) => {
|
|
3273
|
-
assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
|
|
3274
|
-
assert(hi === (hi|0)); // hi should be a i32
|
|
3275
|
-
return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
|
|
3276
|
-
};
|
|
3277
|
-
function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
|
|
3278
|
-
var offset = convertI32PairToI53Checked(offset_low, offset_high);
|
|
3279
3451
|
|
|
3452
|
+
var getExecutableName = () => thisProgram || './this.program';
|
|
3453
|
+
var getEnvStrings = () => {
|
|
3454
|
+
if (!getEnvStrings.strings) {
|
|
3455
|
+
// Default values.
|
|
3456
|
+
// Browser language detection #8751
|
|
3457
|
+
var lang = ((typeof navigator == 'object' && navigator.language) || 'C').replace('-', '_') + '.UTF-8';
|
|
3458
|
+
var env = {
|
|
3459
|
+
'USER': 'web_user',
|
|
3460
|
+
'LOGNAME': 'web_user',
|
|
3461
|
+
'PATH': '/',
|
|
3462
|
+
'PWD': '/',
|
|
3463
|
+
'HOME': '/home/web_user',
|
|
3464
|
+
'LANG': lang,
|
|
3465
|
+
'_': getExecutableName()
|
|
3466
|
+
};
|
|
3467
|
+
// Apply the user-provided values, if any.
|
|
3468
|
+
for (var x in ENV) {
|
|
3469
|
+
// x is a key in ENV; if ENV[x] is undefined, that means it was
|
|
3470
|
+
// explicitly set to be so. We allow user code to do that to
|
|
3471
|
+
// force variables with default values to remain unset.
|
|
3472
|
+
if (ENV[x] === undefined) delete env[x];
|
|
3473
|
+
else env[x] = ENV[x];
|
|
3474
|
+
}
|
|
3475
|
+
var strings = [];
|
|
3476
|
+
for (var x in env) {
|
|
3477
|
+
strings.push(`${x}=${env[x]}`);
|
|
3478
|
+
}
|
|
3479
|
+
getEnvStrings.strings = strings;
|
|
3480
|
+
}
|
|
3481
|
+
return getEnvStrings.strings;
|
|
3482
|
+
};
|
|
3280
3483
|
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3484
|
+
var _environ_get = (__environ, environ_buf) => {
|
|
3485
|
+
var bufSize = 0;
|
|
3486
|
+
var envp = 0;
|
|
3487
|
+
for (var string of getEnvStrings()) {
|
|
3488
|
+
var ptr = environ_buf + bufSize;
|
|
3489
|
+
HEAPU32[(((__environ)+(envp))>>2)] = ptr;
|
|
3490
|
+
bufSize += stringToUTF8(string, ptr, Infinity) + 1;
|
|
3491
|
+
envp += 4;
|
|
3492
|
+
}
|
|
3493
|
+
return 0;
|
|
3494
|
+
};
|
|
3284
3495
|
|
|
3285
|
-
var printCharBuffers = [null,[],[]];
|
|
3286
3496
|
|
|
3287
|
-
var
|
|
3288
|
-
var
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
} else {
|
|
3294
|
-
buffer.push(curr);
|
|
3497
|
+
var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
|
|
3498
|
+
var strings = getEnvStrings();
|
|
3499
|
+
HEAPU32[((penviron_count)>>2)] = strings.length;
|
|
3500
|
+
var bufSize = 0;
|
|
3501
|
+
for (var string of strings) {
|
|
3502
|
+
bufSize += lengthBytesUTF8(string) + 1;
|
|
3295
3503
|
}
|
|
3504
|
+
HEAPU32[((penviron_buf_size)>>2)] = bufSize;
|
|
3505
|
+
return 0;
|
|
3296
3506
|
};
|
|
3507
|
+
|
|
3508
|
+
var PATH = {
|
|
3509
|
+
isAbs:(path) => path.charAt(0) === '/',
|
|
3510
|
+
splitPath:(filename) => {
|
|
3511
|
+
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
|
3512
|
+
return splitPathRe.exec(filename).slice(1);
|
|
3513
|
+
},
|
|
3514
|
+
normalizeArray:(parts, allowAboveRoot) => {
|
|
3515
|
+
// if the path tries to go above the root, `up` ends up > 0
|
|
3516
|
+
var up = 0;
|
|
3517
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
|
3518
|
+
var last = parts[i];
|
|
3519
|
+
if (last === '.') {
|
|
3520
|
+
parts.splice(i, 1);
|
|
3521
|
+
} else if (last === '..') {
|
|
3522
|
+
parts.splice(i, 1);
|
|
3523
|
+
up++;
|
|
3524
|
+
} else if (up) {
|
|
3525
|
+
parts.splice(i, 1);
|
|
3526
|
+
up--;
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
// if the path is allowed to go above the root, restore leading ..s
|
|
3530
|
+
if (allowAboveRoot) {
|
|
3531
|
+
for (; up; up--) {
|
|
3532
|
+
parts.unshift('..');
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
return parts;
|
|
3536
|
+
},
|
|
3537
|
+
normalize:(path) => {
|
|
3538
|
+
var isAbsolute = PATH.isAbs(path),
|
|
3539
|
+
trailingSlash = path.slice(-1) === '/';
|
|
3540
|
+
// Normalize the path
|
|
3541
|
+
path = PATH.normalizeArray(path.split('/').filter((p) => !!p), !isAbsolute).join('/');
|
|
3542
|
+
if (!path && !isAbsolute) {
|
|
3543
|
+
path = '.';
|
|
3544
|
+
}
|
|
3545
|
+
if (path && trailingSlash) {
|
|
3546
|
+
path += '/';
|
|
3547
|
+
}
|
|
3548
|
+
return (isAbsolute ? '/' : '') + path;
|
|
3549
|
+
},
|
|
3550
|
+
dirname:(path) => {
|
|
3551
|
+
var result = PATH.splitPath(path),
|
|
3552
|
+
root = result[0],
|
|
3553
|
+
dir = result[1];
|
|
3554
|
+
if (!root && !dir) {
|
|
3555
|
+
// No dirname whatsoever
|
|
3556
|
+
return '.';
|
|
3557
|
+
}
|
|
3558
|
+
if (dir) {
|
|
3559
|
+
// It has a dirname, strip trailing slash
|
|
3560
|
+
dir = dir.slice(0, -1);
|
|
3561
|
+
}
|
|
3562
|
+
return root + dir;
|
|
3563
|
+
},
|
|
3564
|
+
basename:(path) => path && path.match(/([^\/]+|\/)\/*$/)[1],
|
|
3565
|
+
join:(...paths) => PATH.normalize(paths.join('/')),
|
|
3566
|
+
join2:(l, r) => PATH.normalize(l + '/' + r),
|
|
3567
|
+
};
|
|
3568
|
+
|
|
3569
|
+
var initRandomFill = () => {
|
|
3570
|
+
// This block is not needed on v19+ since crypto.getRandomValues is builtin
|
|
3571
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
3572
|
+
var nodeCrypto = require('crypto');
|
|
3573
|
+
return (view) => nodeCrypto.randomFillSync(view);
|
|
3574
|
+
}
|
|
3297
3575
|
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3576
|
+
return (view) => crypto.getRandomValues(view);
|
|
3577
|
+
};
|
|
3578
|
+
var randomFill = (view) => {
|
|
3579
|
+
// Lazily init on the first invocation.
|
|
3580
|
+
(randomFill = initRandomFill())(view);
|
|
3303
3581
|
};
|
|
3304
3582
|
|
|
3305
3583
|
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
var
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3584
|
+
|
|
3585
|
+
var PATH_FS = {
|
|
3586
|
+
resolve:(...args) => {
|
|
3587
|
+
var resolvedPath = '',
|
|
3588
|
+
resolvedAbsolute = false;
|
|
3589
|
+
for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
3590
|
+
var path = (i >= 0) ? args[i] : FS.cwd();
|
|
3591
|
+
// Skip empty and invalid entries
|
|
3592
|
+
if (typeof path != 'string') {
|
|
3593
|
+
throw new TypeError('Arguments to path.resolve must be strings');
|
|
3594
|
+
} else if (!path) {
|
|
3595
|
+
return ''; // an invalid portion invalidates the whole thing
|
|
3596
|
+
}
|
|
3597
|
+
resolvedPath = path + '/' + resolvedPath;
|
|
3598
|
+
resolvedAbsolute = PATH.isAbs(path);
|
|
3315
3599
|
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3600
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
3601
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
3602
|
+
resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter((p) => !!p), !resolvedAbsolute).join('/');
|
|
3603
|
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
|
3604
|
+
},
|
|
3605
|
+
relative:(from, to) => {
|
|
3606
|
+
from = PATH_FS.resolve(from).slice(1);
|
|
3607
|
+
to = PATH_FS.resolve(to).slice(1);
|
|
3608
|
+
function trim(arr) {
|
|
3609
|
+
var start = 0;
|
|
3610
|
+
for (; start < arr.length; start++) {
|
|
3611
|
+
if (arr[start] !== '') break;
|
|
3612
|
+
}
|
|
3613
|
+
var end = arr.length - 1;
|
|
3614
|
+
for (; end >= 0; end--) {
|
|
3615
|
+
if (arr[end] !== '') break;
|
|
3616
|
+
}
|
|
3617
|
+
if (start > end) return [];
|
|
3618
|
+
return arr.slice(start, end - start + 1);
|
|
3619
|
+
}
|
|
3620
|
+
var fromParts = trim(from.split('/'));
|
|
3621
|
+
var toParts = trim(to.split('/'));
|
|
3622
|
+
var length = Math.min(fromParts.length, toParts.length);
|
|
3623
|
+
var samePartsLength = length;
|
|
3624
|
+
for (var i = 0; i < length; i++) {
|
|
3625
|
+
if (fromParts[i] !== toParts[i]) {
|
|
3626
|
+
samePartsLength = i;
|
|
3627
|
+
break;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
var outputParts = [];
|
|
3631
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
|
3632
|
+
outputParts.push('..');
|
|
3633
|
+
}
|
|
3634
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
3635
|
+
return outputParts.join('/');
|
|
3636
|
+
},
|
|
3637
|
+
};
|
|
3327
3638
|
|
|
3328
3639
|
|
|
3329
3640
|
|
|
3641
|
+
var FS_stdin_getChar_buffer = [];
|
|
3330
3642
|
|
|
3331
|
-
var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
|
|
3332
3643
|
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
var
|
|
3336
|
-
var
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3644
|
+
/** @type {function(string, boolean=, number=)} */
|
|
3645
|
+
var intArrayFromString = (stringy, dontAddNull, length) => {
|
|
3646
|
+
var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
|
|
3647
|
+
var u8array = new Array(len);
|
|
3648
|
+
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
3649
|
+
if (dontAddNull) u8array.length = numBytesWritten;
|
|
3650
|
+
return u8array;
|
|
3651
|
+
};
|
|
3652
|
+
var FS_stdin_getChar = () => {
|
|
3653
|
+
if (!FS_stdin_getChar_buffer.length) {
|
|
3654
|
+
var result = null;
|
|
3655
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
3656
|
+
// we will read data by chunks of BUFSIZE
|
|
3657
|
+
var BUFSIZE = 256;
|
|
3658
|
+
var buf = Buffer.alloc(BUFSIZE);
|
|
3659
|
+
var bytesRead = 0;
|
|
3660
|
+
|
|
3661
|
+
// For some reason we must suppress a closure warning here, even though
|
|
3662
|
+
// fd definitely exists on process.stdin, and is even the proper way to
|
|
3663
|
+
// get the fd of stdin,
|
|
3664
|
+
// https://github.com/nodejs/help/issues/2136#issuecomment-523649904
|
|
3665
|
+
// This started to happen after moving this logic out of library_tty.js,
|
|
3666
|
+
// so it is related to the surrounding code in some unclear manner.
|
|
3667
|
+
/** @suppress {missingProperties} */
|
|
3668
|
+
var fd = process.stdin.fd;
|
|
3669
|
+
|
|
3670
|
+
try {
|
|
3671
|
+
bytesRead = fs.readSync(fd, buf, 0, BUFSIZE);
|
|
3672
|
+
} catch(e) {
|
|
3673
|
+
// Cross-platform differences: on Windows, reading EOF throws an
|
|
3674
|
+
// exception, but on other OSes, reading EOF returns 0. Uniformize
|
|
3675
|
+
// behavior by treating the EOF exception to return 0.
|
|
3676
|
+
if (e.toString().includes('EOF')) bytesRead = 0;
|
|
3677
|
+
else throw e;
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
if (bytesRead > 0) {
|
|
3681
|
+
result = buf.slice(0, bytesRead).toString('utf-8');
|
|
3682
|
+
}
|
|
3683
|
+
} else
|
|
3684
|
+
if (typeof window != 'undefined' &&
|
|
3685
|
+
typeof window.prompt == 'function') {
|
|
3686
|
+
// Browser.
|
|
3687
|
+
result = window.prompt('Input: '); // returns null on cancel
|
|
3688
|
+
if (result !== null) {
|
|
3689
|
+
result += '\n';
|
|
3690
|
+
}
|
|
3691
|
+
} else
|
|
3692
|
+
{}
|
|
3693
|
+
if (!result) {
|
|
3694
|
+
return null;
|
|
3695
|
+
}
|
|
3696
|
+
FS_stdin_getChar_buffer = intArrayFromString(result, true);
|
|
3697
|
+
}
|
|
3698
|
+
return FS_stdin_getChar_buffer.shift();
|
|
3699
|
+
};
|
|
3700
|
+
var TTY = {
|
|
3701
|
+
ttys:[],
|
|
3702
|
+
init() {
|
|
3703
|
+
// https://github.com/emscripten-core/emscripten/pull/1555
|
|
3704
|
+
// if (ENVIRONMENT_IS_NODE) {
|
|
3705
|
+
// // currently, FS.init does not distinguish if process.stdin is a file or TTY
|
|
3706
|
+
// // device, it always assumes it's a TTY device. because of this, we're forcing
|
|
3707
|
+
// // process.stdin to UTF8 encoding to at least make stdin reading compatible
|
|
3708
|
+
// // with text files until FS.init can be refactored.
|
|
3709
|
+
// process.stdin.setEncoding('utf8');
|
|
3710
|
+
// }
|
|
3711
|
+
},
|
|
3712
|
+
shutdown() {
|
|
3713
|
+
// https://github.com/emscripten-core/emscripten/pull/1555
|
|
3714
|
+
// if (ENVIRONMENT_IS_NODE) {
|
|
3715
|
+
// // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
|
|
3716
|
+
// // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
|
|
3717
|
+
// // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
|
|
3718
|
+
// // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
|
|
3719
|
+
// // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
|
|
3720
|
+
// process.stdin.pause();
|
|
3721
|
+
// }
|
|
3722
|
+
},
|
|
3723
|
+
register(dev, ops) {
|
|
3724
|
+
TTY.ttys[dev] = { input: [], output: [], ops: ops };
|
|
3725
|
+
FS.registerDevice(dev, TTY.stream_ops);
|
|
3726
|
+
},
|
|
3727
|
+
stream_ops:{
|
|
3728
|
+
open(stream) {
|
|
3729
|
+
var tty = TTY.ttys[stream.node.rdev];
|
|
3730
|
+
if (!tty) {
|
|
3731
|
+
throw new FS.ErrnoError(43);
|
|
3732
|
+
}
|
|
3733
|
+
stream.tty = tty;
|
|
3734
|
+
stream.seekable = false;
|
|
3735
|
+
},
|
|
3736
|
+
close(stream) {
|
|
3737
|
+
// flush any pending line data
|
|
3738
|
+
stream.tty.ops.fsync(stream.tty);
|
|
3739
|
+
},
|
|
3740
|
+
fsync(stream) {
|
|
3741
|
+
stream.tty.ops.fsync(stream.tty);
|
|
3742
|
+
},
|
|
3743
|
+
read(stream, buffer, offset, length, pos /* ignored */) {
|
|
3744
|
+
if (!stream.tty || !stream.tty.ops.get_char) {
|
|
3745
|
+
throw new FS.ErrnoError(60);
|
|
3746
|
+
}
|
|
3747
|
+
var bytesRead = 0;
|
|
3748
|
+
for (var i = 0; i < length; i++) {
|
|
3749
|
+
var result;
|
|
3750
|
+
try {
|
|
3751
|
+
result = stream.tty.ops.get_char(stream.tty);
|
|
3752
|
+
} catch (e) {
|
|
3753
|
+
throw new FS.ErrnoError(29);
|
|
3754
|
+
}
|
|
3755
|
+
if (result === undefined && bytesRead === 0) {
|
|
3756
|
+
throw new FS.ErrnoError(6);
|
|
3757
|
+
}
|
|
3758
|
+
if (result === null || result === undefined) break;
|
|
3759
|
+
bytesRead++;
|
|
3760
|
+
buffer[offset+i] = result;
|
|
3761
|
+
}
|
|
3762
|
+
if (bytesRead) {
|
|
3763
|
+
stream.node.atime = Date.now();
|
|
3764
|
+
}
|
|
3765
|
+
return bytesRead;
|
|
3766
|
+
},
|
|
3767
|
+
write(stream, buffer, offset, length, pos) {
|
|
3768
|
+
if (!stream.tty || !stream.tty.ops.put_char) {
|
|
3769
|
+
throw new FS.ErrnoError(60);
|
|
3770
|
+
}
|
|
3771
|
+
try {
|
|
3772
|
+
for (var i = 0; i < length; i++) {
|
|
3773
|
+
stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
|
|
3774
|
+
}
|
|
3775
|
+
} catch (e) {
|
|
3776
|
+
throw new FS.ErrnoError(29);
|
|
3777
|
+
}
|
|
3778
|
+
if (length) {
|
|
3779
|
+
stream.node.mtime = stream.node.ctime = Date.now();
|
|
3780
|
+
}
|
|
3781
|
+
return i;
|
|
3782
|
+
},
|
|
3783
|
+
},
|
|
3784
|
+
default_tty_ops:{
|
|
3785
|
+
get_char(tty) {
|
|
3786
|
+
return FS_stdin_getChar();
|
|
3787
|
+
},
|
|
3788
|
+
put_char(tty, val) {
|
|
3789
|
+
if (val === null || val === 10) {
|
|
3790
|
+
out(UTF8ArrayToString(tty.output));
|
|
3791
|
+
tty.output = [];
|
|
3792
|
+
} else {
|
|
3793
|
+
if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle.
|
|
3794
|
+
}
|
|
3795
|
+
},
|
|
3796
|
+
fsync(tty) {
|
|
3797
|
+
if (tty.output?.length > 0) {
|
|
3798
|
+
out(UTF8ArrayToString(tty.output));
|
|
3799
|
+
tty.output = [];
|
|
3800
|
+
}
|
|
3801
|
+
},
|
|
3802
|
+
ioctl_tcgets(tty) {
|
|
3803
|
+
// typical setting
|
|
3804
|
+
return {
|
|
3805
|
+
c_iflag: 25856,
|
|
3806
|
+
c_oflag: 5,
|
|
3807
|
+
c_cflag: 191,
|
|
3808
|
+
c_lflag: 35387,
|
|
3809
|
+
c_cc: [
|
|
3810
|
+
0x03, 0x1c, 0x7f, 0x15, 0x04, 0x00, 0x01, 0x00, 0x11, 0x13, 0x1a, 0x00,
|
|
3811
|
+
0x12, 0x0f, 0x17, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
3812
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
3813
|
+
]
|
|
3814
|
+
};
|
|
3815
|
+
},
|
|
3816
|
+
ioctl_tcsets(tty, optional_actions, data) {
|
|
3817
|
+
// currently just ignore
|
|
3818
|
+
return 0;
|
|
3819
|
+
},
|
|
3820
|
+
ioctl_tiocgwinsz(tty) {
|
|
3821
|
+
return [24, 80];
|
|
3822
|
+
},
|
|
3823
|
+
},
|
|
3824
|
+
default_tty1_ops:{
|
|
3825
|
+
put_char(tty, val) {
|
|
3826
|
+
if (val === null || val === 10) {
|
|
3827
|
+
err(UTF8ArrayToString(tty.output));
|
|
3828
|
+
tty.output = [];
|
|
3829
|
+
} else {
|
|
3830
|
+
if (val != 0) tty.output.push(val);
|
|
3831
|
+
}
|
|
3832
|
+
},
|
|
3833
|
+
fsync(tty) {
|
|
3834
|
+
if (tty.output?.length > 0) {
|
|
3835
|
+
err(UTF8ArrayToString(tty.output));
|
|
3836
|
+
tty.output = [];
|
|
3837
|
+
}
|
|
3838
|
+
},
|
|
3839
|
+
},
|
|
3840
|
+
};
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
var mmapAlloc = (size) => {
|
|
3844
|
+
abort('internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported');
|
|
3845
|
+
};
|
|
3846
|
+
var MEMFS = {
|
|
3847
|
+
ops_table:null,
|
|
3848
|
+
mount(mount) {
|
|
3849
|
+
return MEMFS.createNode(null, '/', 16895, 0);
|
|
3850
|
+
},
|
|
3851
|
+
createNode(parent, name, mode, dev) {
|
|
3852
|
+
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
|
|
3853
|
+
// no supported
|
|
3854
|
+
throw new FS.ErrnoError(63);
|
|
3855
|
+
}
|
|
3856
|
+
MEMFS.ops_table ||= {
|
|
3857
|
+
dir: {
|
|
3858
|
+
node: {
|
|
3859
|
+
getattr: MEMFS.node_ops.getattr,
|
|
3860
|
+
setattr: MEMFS.node_ops.setattr,
|
|
3861
|
+
lookup: MEMFS.node_ops.lookup,
|
|
3862
|
+
mknod: MEMFS.node_ops.mknod,
|
|
3863
|
+
rename: MEMFS.node_ops.rename,
|
|
3864
|
+
unlink: MEMFS.node_ops.unlink,
|
|
3865
|
+
rmdir: MEMFS.node_ops.rmdir,
|
|
3866
|
+
readdir: MEMFS.node_ops.readdir,
|
|
3867
|
+
symlink: MEMFS.node_ops.symlink
|
|
3868
|
+
},
|
|
3869
|
+
stream: {
|
|
3870
|
+
llseek: MEMFS.stream_ops.llseek
|
|
3871
|
+
}
|
|
3872
|
+
},
|
|
3873
|
+
file: {
|
|
3874
|
+
node: {
|
|
3875
|
+
getattr: MEMFS.node_ops.getattr,
|
|
3876
|
+
setattr: MEMFS.node_ops.setattr
|
|
3877
|
+
},
|
|
3878
|
+
stream: {
|
|
3879
|
+
llseek: MEMFS.stream_ops.llseek,
|
|
3880
|
+
read: MEMFS.stream_ops.read,
|
|
3881
|
+
write: MEMFS.stream_ops.write,
|
|
3882
|
+
mmap: MEMFS.stream_ops.mmap,
|
|
3883
|
+
msync: MEMFS.stream_ops.msync
|
|
3884
|
+
}
|
|
3885
|
+
},
|
|
3886
|
+
link: {
|
|
3887
|
+
node: {
|
|
3888
|
+
getattr: MEMFS.node_ops.getattr,
|
|
3889
|
+
setattr: MEMFS.node_ops.setattr,
|
|
3890
|
+
readlink: MEMFS.node_ops.readlink
|
|
3891
|
+
},
|
|
3892
|
+
stream: {}
|
|
3893
|
+
},
|
|
3894
|
+
chrdev: {
|
|
3895
|
+
node: {
|
|
3896
|
+
getattr: MEMFS.node_ops.getattr,
|
|
3897
|
+
setattr: MEMFS.node_ops.setattr
|
|
3898
|
+
},
|
|
3899
|
+
stream: FS.chrdev_stream_ops
|
|
3900
|
+
}
|
|
3901
|
+
};
|
|
3902
|
+
var node = FS.createNode(parent, name, mode, dev);
|
|
3903
|
+
if (FS.isDir(node.mode)) {
|
|
3904
|
+
node.node_ops = MEMFS.ops_table.dir.node;
|
|
3905
|
+
node.stream_ops = MEMFS.ops_table.dir.stream;
|
|
3906
|
+
node.contents = {};
|
|
3907
|
+
} else if (FS.isFile(node.mode)) {
|
|
3908
|
+
node.node_ops = MEMFS.ops_table.file.node;
|
|
3909
|
+
node.stream_ops = MEMFS.ops_table.file.stream;
|
|
3910
|
+
node.usedBytes = 0; // The actual number of bytes used in the typed array, as opposed to contents.length which gives the whole capacity.
|
|
3911
|
+
// When the byte data of the file is populated, this will point to either a typed array, or a normal JS array. Typed arrays are preferred
|
|
3912
|
+
// for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size
|
|
3913
|
+
// penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme.
|
|
3914
|
+
node.contents = null;
|
|
3915
|
+
} else if (FS.isLink(node.mode)) {
|
|
3916
|
+
node.node_ops = MEMFS.ops_table.link.node;
|
|
3917
|
+
node.stream_ops = MEMFS.ops_table.link.stream;
|
|
3918
|
+
} else if (FS.isChrdev(node.mode)) {
|
|
3919
|
+
node.node_ops = MEMFS.ops_table.chrdev.node;
|
|
3920
|
+
node.stream_ops = MEMFS.ops_table.chrdev.stream;
|
|
3921
|
+
}
|
|
3922
|
+
node.atime = node.mtime = node.ctime = Date.now();
|
|
3923
|
+
// add the new node to the parent
|
|
3924
|
+
if (parent) {
|
|
3925
|
+
parent.contents[name] = node;
|
|
3926
|
+
parent.atime = parent.mtime = parent.ctime = node.atime;
|
|
3927
|
+
}
|
|
3928
|
+
return node;
|
|
3929
|
+
},
|
|
3930
|
+
getFileDataAsTypedArray(node) {
|
|
3931
|
+
if (!node.contents) return new Uint8Array(0);
|
|
3932
|
+
if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes.
|
|
3933
|
+
return new Uint8Array(node.contents);
|
|
3934
|
+
},
|
|
3935
|
+
expandFileStorage(node, newCapacity) {
|
|
3936
|
+
var prevCapacity = node.contents ? node.contents.length : 0;
|
|
3937
|
+
if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough.
|
|
3938
|
+
// Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity.
|
|
3939
|
+
// For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to
|
|
3940
|
+
// avoid overshooting the allocation cap by a very large margin.
|
|
3941
|
+
var CAPACITY_DOUBLING_MAX = 1024 * 1024;
|
|
3942
|
+
newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) >>> 0);
|
|
3943
|
+
if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding.
|
|
3944
|
+
var oldContents = node.contents;
|
|
3945
|
+
node.contents = new Uint8Array(newCapacity); // Allocate new storage.
|
|
3946
|
+
if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage.
|
|
3947
|
+
},
|
|
3948
|
+
resizeFileStorage(node, newSize) {
|
|
3949
|
+
if (node.usedBytes == newSize) return;
|
|
3950
|
+
if (newSize == 0) {
|
|
3951
|
+
node.contents = null; // Fully decommit when requesting a resize to zero.
|
|
3952
|
+
node.usedBytes = 0;
|
|
3953
|
+
} else {
|
|
3954
|
+
var oldContents = node.contents;
|
|
3955
|
+
node.contents = new Uint8Array(newSize); // Allocate new storage.
|
|
3956
|
+
if (oldContents) {
|
|
3957
|
+
node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage.
|
|
3958
|
+
}
|
|
3959
|
+
node.usedBytes = newSize;
|
|
3960
|
+
}
|
|
3961
|
+
},
|
|
3962
|
+
node_ops:{
|
|
3963
|
+
getattr(node) {
|
|
3964
|
+
var attr = {};
|
|
3965
|
+
// device numbers reuse inode numbers.
|
|
3966
|
+
attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
|
|
3967
|
+
attr.ino = node.id;
|
|
3968
|
+
attr.mode = node.mode;
|
|
3969
|
+
attr.nlink = 1;
|
|
3970
|
+
attr.uid = 0;
|
|
3971
|
+
attr.gid = 0;
|
|
3972
|
+
attr.rdev = node.rdev;
|
|
3973
|
+
if (FS.isDir(node.mode)) {
|
|
3974
|
+
attr.size = 4096;
|
|
3975
|
+
} else if (FS.isFile(node.mode)) {
|
|
3976
|
+
attr.size = node.usedBytes;
|
|
3977
|
+
} else if (FS.isLink(node.mode)) {
|
|
3978
|
+
attr.size = node.link.length;
|
|
3979
|
+
} else {
|
|
3980
|
+
attr.size = 0;
|
|
3981
|
+
}
|
|
3982
|
+
attr.atime = new Date(node.atime);
|
|
3983
|
+
attr.mtime = new Date(node.mtime);
|
|
3984
|
+
attr.ctime = new Date(node.ctime);
|
|
3985
|
+
// NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
|
|
3986
|
+
// but this is not required by the standard.
|
|
3987
|
+
attr.blksize = 4096;
|
|
3988
|
+
attr.blocks = Math.ceil(attr.size / attr.blksize);
|
|
3989
|
+
return attr;
|
|
3990
|
+
},
|
|
3991
|
+
setattr(node, attr) {
|
|
3992
|
+
for (const key of ["mode", "atime", "mtime", "ctime"]) {
|
|
3993
|
+
if (attr[key] != null) {
|
|
3994
|
+
node[key] = attr[key];
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
if (attr.size !== undefined) {
|
|
3998
|
+
MEMFS.resizeFileStorage(node, attr.size);
|
|
3999
|
+
}
|
|
4000
|
+
},
|
|
4001
|
+
lookup(parent, name) {
|
|
4002
|
+
throw new FS.ErrnoError(44);
|
|
4003
|
+
},
|
|
4004
|
+
mknod(parent, name, mode, dev) {
|
|
4005
|
+
return MEMFS.createNode(parent, name, mode, dev);
|
|
4006
|
+
},
|
|
4007
|
+
rename(old_node, new_dir, new_name) {
|
|
4008
|
+
var new_node;
|
|
4009
|
+
try {
|
|
4010
|
+
new_node = FS.lookupNode(new_dir, new_name);
|
|
4011
|
+
} catch (e) {}
|
|
4012
|
+
if (new_node) {
|
|
4013
|
+
if (FS.isDir(old_node.mode)) {
|
|
4014
|
+
// if we're overwriting a directory at new_name, make sure it's empty.
|
|
4015
|
+
for (var i in new_node.contents) {
|
|
4016
|
+
throw new FS.ErrnoError(55);
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
FS.hashRemoveNode(new_node);
|
|
4020
|
+
}
|
|
4021
|
+
// do the internal rewiring
|
|
4022
|
+
delete old_node.parent.contents[old_node.name];
|
|
4023
|
+
new_dir.contents[new_name] = old_node;
|
|
4024
|
+
old_node.name = new_name;
|
|
4025
|
+
new_dir.ctime = new_dir.mtime = old_node.parent.ctime = old_node.parent.mtime = Date.now();
|
|
4026
|
+
},
|
|
4027
|
+
unlink(parent, name) {
|
|
4028
|
+
delete parent.contents[name];
|
|
4029
|
+
parent.ctime = parent.mtime = Date.now();
|
|
4030
|
+
},
|
|
4031
|
+
rmdir(parent, name) {
|
|
4032
|
+
var node = FS.lookupNode(parent, name);
|
|
4033
|
+
for (var i in node.contents) {
|
|
4034
|
+
throw new FS.ErrnoError(55);
|
|
4035
|
+
}
|
|
4036
|
+
delete parent.contents[name];
|
|
4037
|
+
parent.ctime = parent.mtime = Date.now();
|
|
4038
|
+
},
|
|
4039
|
+
readdir(node) {
|
|
4040
|
+
return ['.', '..', ...Object.keys(node.contents)];
|
|
4041
|
+
},
|
|
4042
|
+
symlink(parent, newname, oldpath) {
|
|
4043
|
+
var node = MEMFS.createNode(parent, newname, 0o777 | 40960, 0);
|
|
4044
|
+
node.link = oldpath;
|
|
4045
|
+
return node;
|
|
4046
|
+
},
|
|
4047
|
+
readlink(node) {
|
|
4048
|
+
if (!FS.isLink(node.mode)) {
|
|
4049
|
+
throw new FS.ErrnoError(28);
|
|
4050
|
+
}
|
|
4051
|
+
return node.link;
|
|
4052
|
+
},
|
|
4053
|
+
},
|
|
4054
|
+
stream_ops:{
|
|
4055
|
+
read(stream, buffer, offset, length, position) {
|
|
4056
|
+
var contents = stream.node.contents;
|
|
4057
|
+
if (position >= stream.node.usedBytes) return 0;
|
|
4058
|
+
var size = Math.min(stream.node.usedBytes - position, length);
|
|
4059
|
+
assert(size >= 0);
|
|
4060
|
+
if (size > 8 && contents.subarray) { // non-trivial, and typed array
|
|
4061
|
+
buffer.set(contents.subarray(position, position + size), offset);
|
|
4062
|
+
} else {
|
|
4063
|
+
for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
|
|
4064
|
+
}
|
|
4065
|
+
return size;
|
|
4066
|
+
},
|
|
4067
|
+
write(stream, buffer, offset, length, position, canOwn) {
|
|
4068
|
+
// The data buffer should be a typed array view
|
|
4069
|
+
assert(!(buffer instanceof ArrayBuffer));
|
|
4070
|
+
// If the buffer is located in main memory (HEAP), and if
|
|
4071
|
+
// memory can grow, we can't hold on to references of the
|
|
4072
|
+
// memory buffer, as they may get invalidated. That means we
|
|
4073
|
+
// need to do copy its contents.
|
|
4074
|
+
if (buffer.buffer === HEAP8.buffer) {
|
|
4075
|
+
canOwn = false;
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
if (!length) return 0;
|
|
4079
|
+
var node = stream.node;
|
|
4080
|
+
node.mtime = node.ctime = Date.now();
|
|
4081
|
+
|
|
4082
|
+
if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array?
|
|
4083
|
+
if (canOwn) {
|
|
4084
|
+
assert(position === 0, 'canOwn must imply no weird position inside the file');
|
|
4085
|
+
node.contents = buffer.subarray(offset, offset + length);
|
|
4086
|
+
node.usedBytes = length;
|
|
4087
|
+
return length;
|
|
4088
|
+
} else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data.
|
|
4089
|
+
node.contents = buffer.slice(offset, offset + length);
|
|
4090
|
+
node.usedBytes = length;
|
|
4091
|
+
return length;
|
|
4092
|
+
} else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file?
|
|
4093
|
+
node.contents.set(buffer.subarray(offset, offset + length), position);
|
|
4094
|
+
return length;
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
// Appending to an existing file and we need to reallocate, or source data did not come as a typed array.
|
|
4099
|
+
MEMFS.expandFileStorage(node, position+length);
|
|
4100
|
+
if (node.contents.subarray && buffer.subarray) {
|
|
4101
|
+
// Use typed array write which is available.
|
|
4102
|
+
node.contents.set(buffer.subarray(offset, offset + length), position);
|
|
4103
|
+
} else {
|
|
4104
|
+
for (var i = 0; i < length; i++) {
|
|
4105
|
+
node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not.
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
node.usedBytes = Math.max(node.usedBytes, position + length);
|
|
4109
|
+
return length;
|
|
4110
|
+
},
|
|
4111
|
+
llseek(stream, offset, whence) {
|
|
4112
|
+
var position = offset;
|
|
4113
|
+
if (whence === 1) {
|
|
4114
|
+
position += stream.position;
|
|
4115
|
+
} else if (whence === 2) {
|
|
4116
|
+
if (FS.isFile(stream.node.mode)) {
|
|
4117
|
+
position += stream.node.usedBytes;
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
if (position < 0) {
|
|
4121
|
+
throw new FS.ErrnoError(28);
|
|
4122
|
+
}
|
|
4123
|
+
return position;
|
|
4124
|
+
},
|
|
4125
|
+
mmap(stream, length, position, prot, flags) {
|
|
4126
|
+
if (!FS.isFile(stream.node.mode)) {
|
|
4127
|
+
throw new FS.ErrnoError(43);
|
|
4128
|
+
}
|
|
4129
|
+
var ptr;
|
|
4130
|
+
var allocated;
|
|
4131
|
+
var contents = stream.node.contents;
|
|
4132
|
+
// Only make a new copy when MAP_PRIVATE is specified.
|
|
4133
|
+
if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
|
|
4134
|
+
// We can't emulate MAP_SHARED when the file is not backed by the
|
|
4135
|
+
// buffer we're mapping to (e.g. the HEAP buffer).
|
|
4136
|
+
allocated = false;
|
|
4137
|
+
ptr = contents.byteOffset;
|
|
4138
|
+
} else {
|
|
4139
|
+
allocated = true;
|
|
4140
|
+
ptr = mmapAlloc(length);
|
|
4141
|
+
if (!ptr) {
|
|
4142
|
+
throw new FS.ErrnoError(48);
|
|
4143
|
+
}
|
|
4144
|
+
if (contents) {
|
|
4145
|
+
// Try to avoid unnecessary slices.
|
|
4146
|
+
if (position > 0 || position + length < contents.length) {
|
|
4147
|
+
if (contents.subarray) {
|
|
4148
|
+
contents = contents.subarray(position, position + length);
|
|
4149
|
+
} else {
|
|
4150
|
+
contents = Array.prototype.slice.call(contents, position, position + length);
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
HEAP8.set(contents, ptr);
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
return { ptr, allocated };
|
|
4157
|
+
},
|
|
4158
|
+
msync(stream, buffer, offset, length, mmapFlags) {
|
|
4159
|
+
MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
|
|
4160
|
+
// should we check if bytesWritten and length are the same?
|
|
4161
|
+
return 0;
|
|
4162
|
+
},
|
|
4163
|
+
},
|
|
4164
|
+
};
|
|
4165
|
+
|
|
4166
|
+
var FS_modeStringToFlags = (str) => {
|
|
4167
|
+
var flagModes = {
|
|
4168
|
+
'r': 0,
|
|
4169
|
+
'r+': 2,
|
|
4170
|
+
'w': 512 | 64 | 1,
|
|
4171
|
+
'w+': 512 | 64 | 2,
|
|
4172
|
+
'a': 1024 | 64 | 1,
|
|
4173
|
+
'a+': 1024 | 64 | 2,
|
|
4174
|
+
};
|
|
4175
|
+
var flags = flagModes[str];
|
|
4176
|
+
if (typeof flags == 'undefined') {
|
|
4177
|
+
throw new Error(`Unknown file open mode: ${str}`);
|
|
4178
|
+
}
|
|
4179
|
+
return flags;
|
|
4180
|
+
};
|
|
4181
|
+
|
|
4182
|
+
var FS_getMode = (canRead, canWrite) => {
|
|
4183
|
+
var mode = 0;
|
|
4184
|
+
if (canRead) mode |= 292 | 73;
|
|
4185
|
+
if (canWrite) mode |= 146;
|
|
4186
|
+
return mode;
|
|
4187
|
+
};
|
|
4188
|
+
|
|
4189
|
+
|
|
4190
|
+
|
|
4191
|
+
|
|
4192
|
+
var strError = (errno) => UTF8ToString(_strerror(errno));
|
|
4193
|
+
|
|
4194
|
+
var ERRNO_CODES = {
|
|
4195
|
+
'EPERM': 63,
|
|
4196
|
+
'ENOENT': 44,
|
|
4197
|
+
'ESRCH': 71,
|
|
4198
|
+
'EINTR': 27,
|
|
4199
|
+
'EIO': 29,
|
|
4200
|
+
'ENXIO': 60,
|
|
4201
|
+
'E2BIG': 1,
|
|
4202
|
+
'ENOEXEC': 45,
|
|
4203
|
+
'EBADF': 8,
|
|
4204
|
+
'ECHILD': 12,
|
|
4205
|
+
'EAGAIN': 6,
|
|
4206
|
+
'EWOULDBLOCK': 6,
|
|
4207
|
+
'ENOMEM': 48,
|
|
4208
|
+
'EACCES': 2,
|
|
4209
|
+
'EFAULT': 21,
|
|
4210
|
+
'ENOTBLK': 105,
|
|
4211
|
+
'EBUSY': 10,
|
|
4212
|
+
'EEXIST': 20,
|
|
4213
|
+
'EXDEV': 75,
|
|
4214
|
+
'ENODEV': 43,
|
|
4215
|
+
'ENOTDIR': 54,
|
|
4216
|
+
'EISDIR': 31,
|
|
4217
|
+
'EINVAL': 28,
|
|
4218
|
+
'ENFILE': 41,
|
|
4219
|
+
'EMFILE': 33,
|
|
4220
|
+
'ENOTTY': 59,
|
|
4221
|
+
'ETXTBSY': 74,
|
|
4222
|
+
'EFBIG': 22,
|
|
4223
|
+
'ENOSPC': 51,
|
|
4224
|
+
'ESPIPE': 70,
|
|
4225
|
+
'EROFS': 69,
|
|
4226
|
+
'EMLINK': 34,
|
|
4227
|
+
'EPIPE': 64,
|
|
4228
|
+
'EDOM': 18,
|
|
4229
|
+
'ERANGE': 68,
|
|
4230
|
+
'ENOMSG': 49,
|
|
4231
|
+
'EIDRM': 24,
|
|
4232
|
+
'ECHRNG': 106,
|
|
4233
|
+
'EL2NSYNC': 156,
|
|
4234
|
+
'EL3HLT': 107,
|
|
4235
|
+
'EL3RST': 108,
|
|
4236
|
+
'ELNRNG': 109,
|
|
4237
|
+
'EUNATCH': 110,
|
|
4238
|
+
'ENOCSI': 111,
|
|
4239
|
+
'EL2HLT': 112,
|
|
4240
|
+
'EDEADLK': 16,
|
|
4241
|
+
'ENOLCK': 46,
|
|
4242
|
+
'EBADE': 113,
|
|
4243
|
+
'EBADR': 114,
|
|
4244
|
+
'EXFULL': 115,
|
|
4245
|
+
'ENOANO': 104,
|
|
4246
|
+
'EBADRQC': 103,
|
|
4247
|
+
'EBADSLT': 102,
|
|
4248
|
+
'EDEADLOCK': 16,
|
|
4249
|
+
'EBFONT': 101,
|
|
4250
|
+
'ENOSTR': 100,
|
|
4251
|
+
'ENODATA': 116,
|
|
4252
|
+
'ETIME': 117,
|
|
4253
|
+
'ENOSR': 118,
|
|
4254
|
+
'ENONET': 119,
|
|
4255
|
+
'ENOPKG': 120,
|
|
4256
|
+
'EREMOTE': 121,
|
|
4257
|
+
'ENOLINK': 47,
|
|
4258
|
+
'EADV': 122,
|
|
4259
|
+
'ESRMNT': 123,
|
|
4260
|
+
'ECOMM': 124,
|
|
4261
|
+
'EPROTO': 65,
|
|
4262
|
+
'EMULTIHOP': 36,
|
|
4263
|
+
'EDOTDOT': 125,
|
|
4264
|
+
'EBADMSG': 9,
|
|
4265
|
+
'ENOTUNIQ': 126,
|
|
4266
|
+
'EBADFD': 127,
|
|
4267
|
+
'EREMCHG': 128,
|
|
4268
|
+
'ELIBACC': 129,
|
|
4269
|
+
'ELIBBAD': 130,
|
|
4270
|
+
'ELIBSCN': 131,
|
|
4271
|
+
'ELIBMAX': 132,
|
|
4272
|
+
'ELIBEXEC': 133,
|
|
4273
|
+
'ENOSYS': 52,
|
|
4274
|
+
'ENOTEMPTY': 55,
|
|
4275
|
+
'ENAMETOOLONG': 37,
|
|
4276
|
+
'ELOOP': 32,
|
|
4277
|
+
'EOPNOTSUPP': 138,
|
|
4278
|
+
'EPFNOSUPPORT': 139,
|
|
4279
|
+
'ECONNRESET': 15,
|
|
4280
|
+
'ENOBUFS': 42,
|
|
4281
|
+
'EAFNOSUPPORT': 5,
|
|
4282
|
+
'EPROTOTYPE': 67,
|
|
4283
|
+
'ENOTSOCK': 57,
|
|
4284
|
+
'ENOPROTOOPT': 50,
|
|
4285
|
+
'ESHUTDOWN': 140,
|
|
4286
|
+
'ECONNREFUSED': 14,
|
|
4287
|
+
'EADDRINUSE': 3,
|
|
4288
|
+
'ECONNABORTED': 13,
|
|
4289
|
+
'ENETUNREACH': 40,
|
|
4290
|
+
'ENETDOWN': 38,
|
|
4291
|
+
'ETIMEDOUT': 73,
|
|
4292
|
+
'EHOSTDOWN': 142,
|
|
4293
|
+
'EHOSTUNREACH': 23,
|
|
4294
|
+
'EINPROGRESS': 26,
|
|
4295
|
+
'EALREADY': 7,
|
|
4296
|
+
'EDESTADDRREQ': 17,
|
|
4297
|
+
'EMSGSIZE': 35,
|
|
4298
|
+
'EPROTONOSUPPORT': 66,
|
|
4299
|
+
'ESOCKTNOSUPPORT': 137,
|
|
4300
|
+
'EADDRNOTAVAIL': 4,
|
|
4301
|
+
'ENETRESET': 39,
|
|
4302
|
+
'EISCONN': 30,
|
|
4303
|
+
'ENOTCONN': 53,
|
|
4304
|
+
'ETOOMANYREFS': 141,
|
|
4305
|
+
'EUSERS': 136,
|
|
4306
|
+
'EDQUOT': 19,
|
|
4307
|
+
'ESTALE': 72,
|
|
4308
|
+
'ENOTSUP': 138,
|
|
4309
|
+
'ENOMEDIUM': 148,
|
|
4310
|
+
'EILSEQ': 25,
|
|
4311
|
+
'EOVERFLOW': 61,
|
|
4312
|
+
'ECANCELED': 11,
|
|
4313
|
+
'ENOTRECOVERABLE': 56,
|
|
4314
|
+
'EOWNERDEAD': 62,
|
|
4315
|
+
'ESTRPIPE': 135,
|
|
4316
|
+
};
|
|
4317
|
+
|
|
4318
|
+
var asyncLoad = async (url) => {
|
|
4319
|
+
var arrayBuffer = await readAsync(url);
|
|
4320
|
+
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
|
|
4321
|
+
return new Uint8Array(arrayBuffer);
|
|
4322
|
+
};
|
|
4323
|
+
|
|
4324
|
+
|
|
4325
|
+
var FS_createDataFile = (...args) => FS.createDataFile(...args);
|
|
4326
|
+
|
|
4327
|
+
var getUniqueRunDependency = (id) => {
|
|
4328
|
+
var orig = id;
|
|
4329
|
+
while (1) {
|
|
4330
|
+
if (!runDependencyTracking[id]) return id;
|
|
4331
|
+
id = orig + Math.random();
|
|
4332
|
+
}
|
|
4333
|
+
};
|
|
4334
|
+
|
|
4335
|
+
var preloadPlugins = [];
|
|
4336
|
+
var FS_handledByPreloadPlugin = async (byteArray, fullname) => {
|
|
4337
|
+
// Ensure plugins are ready.
|
|
4338
|
+
if (typeof Browser != 'undefined') Browser.init();
|
|
4339
|
+
|
|
4340
|
+
for (var plugin of preloadPlugins) {
|
|
4341
|
+
if (plugin['canHandle'](fullname)) {
|
|
4342
|
+
assert(plugin['handle'].constructor.name === 'AsyncFunction', 'Filesystem plugin handlers must be async functions (See #24914)')
|
|
4343
|
+
return plugin['handle'](byteArray, fullname);
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
// In no plugin handled this file then return the original/unmodified
|
|
4347
|
+
// byteArray.
|
|
4348
|
+
return byteArray;
|
|
4349
|
+
};
|
|
4350
|
+
var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
|
|
4351
|
+
// TODO we should allow people to just pass in a complete filename instead
|
|
4352
|
+
// of parent and name being that we just join them anyways
|
|
4353
|
+
var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
|
|
4354
|
+
var dep = getUniqueRunDependency(`cp ${fullname}`); // might have several active requests for the same fullname
|
|
4355
|
+
addRunDependency(dep);
|
|
4356
|
+
|
|
4357
|
+
try {
|
|
4358
|
+
var byteArray = url;
|
|
4359
|
+
if (typeof url == 'string') {
|
|
4360
|
+
byteArray = await asyncLoad(url);
|
|
4361
|
+
}
|
|
4362
|
+
|
|
4363
|
+
byteArray = await FS_handledByPreloadPlugin(byteArray, fullname);
|
|
4364
|
+
preFinish?.();
|
|
4365
|
+
if (!dontCreateFile) {
|
|
4366
|
+
FS_createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
|
|
4367
|
+
}
|
|
4368
|
+
} finally {
|
|
4369
|
+
removeRunDependency(dep);
|
|
4370
|
+
}
|
|
4371
|
+
};
|
|
4372
|
+
var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
|
|
4373
|
+
FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
|
|
4374
|
+
};
|
|
4375
|
+
var FS = {
|
|
4376
|
+
root:null,
|
|
4377
|
+
mounts:[],
|
|
4378
|
+
devices:{
|
|
4379
|
+
},
|
|
4380
|
+
streams:[],
|
|
4381
|
+
nextInode:1,
|
|
4382
|
+
nameTable:null,
|
|
4383
|
+
currentPath:"/",
|
|
4384
|
+
initialized:false,
|
|
4385
|
+
ignorePermissions:true,
|
|
4386
|
+
filesystems:null,
|
|
4387
|
+
syncFSRequests:0,
|
|
4388
|
+
readFiles:{
|
|
4389
|
+
},
|
|
4390
|
+
ErrnoError:class extends Error {
|
|
4391
|
+
name = 'ErrnoError';
|
|
4392
|
+
// We set the `name` property to be able to identify `FS.ErrnoError`
|
|
4393
|
+
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
|
|
4394
|
+
// - when using PROXYFS, an error can come from an underlying FS
|
|
4395
|
+
// as different FS objects have their own FS.ErrnoError each,
|
|
4396
|
+
// the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs.
|
|
4397
|
+
// we'll use the reliable test `err.name == "ErrnoError"` instead
|
|
4398
|
+
constructor(errno) {
|
|
4399
|
+
super(runtimeInitialized ? strError(errno) : '');
|
|
4400
|
+
this.errno = errno;
|
|
4401
|
+
for (var key in ERRNO_CODES) {
|
|
4402
|
+
if (ERRNO_CODES[key] === errno) {
|
|
4403
|
+
this.code = key;
|
|
4404
|
+
break;
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
},
|
|
4409
|
+
FSStream:class {
|
|
4410
|
+
shared = {};
|
|
4411
|
+
get object() {
|
|
4412
|
+
return this.node;
|
|
4413
|
+
}
|
|
4414
|
+
set object(val) {
|
|
4415
|
+
this.node = val;
|
|
4416
|
+
}
|
|
4417
|
+
get isRead() {
|
|
4418
|
+
return (this.flags & 2097155) !== 1;
|
|
4419
|
+
}
|
|
4420
|
+
get isWrite() {
|
|
4421
|
+
return (this.flags & 2097155) !== 0;
|
|
4422
|
+
}
|
|
4423
|
+
get isAppend() {
|
|
4424
|
+
return (this.flags & 1024);
|
|
4425
|
+
}
|
|
4426
|
+
get flags() {
|
|
4427
|
+
return this.shared.flags;
|
|
4428
|
+
}
|
|
4429
|
+
set flags(val) {
|
|
4430
|
+
this.shared.flags = val;
|
|
4431
|
+
}
|
|
4432
|
+
get position() {
|
|
4433
|
+
return this.shared.position;
|
|
4434
|
+
}
|
|
4435
|
+
set position(val) {
|
|
4436
|
+
this.shared.position = val;
|
|
4437
|
+
}
|
|
4438
|
+
},
|
|
4439
|
+
FSNode:class {
|
|
4440
|
+
node_ops = {};
|
|
4441
|
+
stream_ops = {};
|
|
4442
|
+
readMode = 292 | 73;
|
|
4443
|
+
writeMode = 146;
|
|
4444
|
+
mounted = null;
|
|
4445
|
+
constructor(parent, name, mode, rdev) {
|
|
4446
|
+
if (!parent) {
|
|
4447
|
+
parent = this; // root node sets parent to itself
|
|
4448
|
+
}
|
|
4449
|
+
this.parent = parent;
|
|
4450
|
+
this.mount = parent.mount;
|
|
4451
|
+
this.id = FS.nextInode++;
|
|
4452
|
+
this.name = name;
|
|
4453
|
+
this.mode = mode;
|
|
4454
|
+
this.rdev = rdev;
|
|
4455
|
+
this.atime = this.mtime = this.ctime = Date.now();
|
|
4456
|
+
}
|
|
4457
|
+
get read() {
|
|
4458
|
+
return (this.mode & this.readMode) === this.readMode;
|
|
4459
|
+
}
|
|
4460
|
+
set read(val) {
|
|
4461
|
+
val ? this.mode |= this.readMode : this.mode &= ~this.readMode;
|
|
4462
|
+
}
|
|
4463
|
+
get write() {
|
|
4464
|
+
return (this.mode & this.writeMode) === this.writeMode;
|
|
4465
|
+
}
|
|
4466
|
+
set write(val) {
|
|
4467
|
+
val ? this.mode |= this.writeMode : this.mode &= ~this.writeMode;
|
|
4468
|
+
}
|
|
4469
|
+
get isFolder() {
|
|
4470
|
+
return FS.isDir(this.mode);
|
|
4471
|
+
}
|
|
4472
|
+
get isDevice() {
|
|
4473
|
+
return FS.isChrdev(this.mode);
|
|
4474
|
+
}
|
|
4475
|
+
},
|
|
4476
|
+
lookupPath(path, opts = {}) {
|
|
4477
|
+
if (!path) {
|
|
4478
|
+
throw new FS.ErrnoError(44);
|
|
4479
|
+
}
|
|
4480
|
+
opts.follow_mount ??= true
|
|
4481
|
+
|
|
4482
|
+
if (!PATH.isAbs(path)) {
|
|
4483
|
+
path = FS.cwd() + '/' + path;
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
// limit max consecutive symlinks to 40 (SYMLOOP_MAX).
|
|
4487
|
+
linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
|
|
4488
|
+
// split the absolute path
|
|
4489
|
+
var parts = path.split('/').filter((p) => !!p);
|
|
4490
|
+
|
|
4491
|
+
// start at the root
|
|
4492
|
+
var current = FS.root;
|
|
4493
|
+
var current_path = '/';
|
|
4494
|
+
|
|
4495
|
+
for (var i = 0; i < parts.length; i++) {
|
|
4496
|
+
var islast = (i === parts.length-1);
|
|
4497
|
+
if (islast && opts.parent) {
|
|
4498
|
+
// stop resolving
|
|
4499
|
+
break;
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
if (parts[i] === '.') {
|
|
4503
|
+
continue;
|
|
4504
|
+
}
|
|
4505
|
+
|
|
4506
|
+
if (parts[i] === '..') {
|
|
4507
|
+
current_path = PATH.dirname(current_path);
|
|
4508
|
+
if (FS.isRoot(current)) {
|
|
4509
|
+
path = current_path + '/' + parts.slice(i + 1).join('/');
|
|
4510
|
+
// We're making progress here, don't let many consecutive ..'s
|
|
4511
|
+
// lead to ELOOP
|
|
4512
|
+
nlinks--;
|
|
4513
|
+
continue linkloop;
|
|
4514
|
+
} else {
|
|
4515
|
+
current = current.parent;
|
|
4516
|
+
}
|
|
4517
|
+
continue;
|
|
4518
|
+
}
|
|
4519
|
+
|
|
4520
|
+
current_path = PATH.join2(current_path, parts[i]);
|
|
4521
|
+
try {
|
|
4522
|
+
current = FS.lookupNode(current, parts[i]);
|
|
4523
|
+
} catch (e) {
|
|
4524
|
+
// if noent_okay is true, suppress a ENOENT in the last component
|
|
4525
|
+
// and return an object with an undefined node. This is needed for
|
|
4526
|
+
// resolving symlinks in the path when creating a file.
|
|
4527
|
+
if ((e?.errno === 44) && islast && opts.noent_okay) {
|
|
4528
|
+
return { path: current_path };
|
|
4529
|
+
}
|
|
4530
|
+
throw e;
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4533
|
+
// jump to the mount's root node if this is a mountpoint
|
|
4534
|
+
if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) {
|
|
4535
|
+
current = current.mounted.root;
|
|
4536
|
+
}
|
|
4537
|
+
|
|
4538
|
+
// by default, lookupPath will not follow a symlink if it is the final path component.
|
|
4539
|
+
// setting opts.follow = true will override this behavior.
|
|
4540
|
+
if (FS.isLink(current.mode) && (!islast || opts.follow)) {
|
|
4541
|
+
if (!current.node_ops.readlink) {
|
|
4542
|
+
throw new FS.ErrnoError(52);
|
|
4543
|
+
}
|
|
4544
|
+
var link = current.node_ops.readlink(current);
|
|
4545
|
+
if (!PATH.isAbs(link)) {
|
|
4546
|
+
link = PATH.dirname(current_path) + '/' + link;
|
|
4547
|
+
}
|
|
4548
|
+
path = link + '/' + parts.slice(i + 1).join('/');
|
|
4549
|
+
continue linkloop;
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
return { path: current_path, node: current };
|
|
4553
|
+
}
|
|
4554
|
+
throw new FS.ErrnoError(32);
|
|
4555
|
+
},
|
|
4556
|
+
getPath(node) {
|
|
4557
|
+
var path;
|
|
4558
|
+
while (true) {
|
|
4559
|
+
if (FS.isRoot(node)) {
|
|
4560
|
+
var mount = node.mount.mountpoint;
|
|
4561
|
+
if (!path) return mount;
|
|
4562
|
+
return mount[mount.length-1] !== '/' ? `${mount}/${path}` : mount + path;
|
|
4563
|
+
}
|
|
4564
|
+
path = path ? `${node.name}/${path}` : node.name;
|
|
4565
|
+
node = node.parent;
|
|
4566
|
+
}
|
|
4567
|
+
},
|
|
4568
|
+
hashName(parentid, name) {
|
|
4569
|
+
var hash = 0;
|
|
4570
|
+
|
|
4571
|
+
for (var i = 0; i < name.length; i++) {
|
|
4572
|
+
hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
|
|
4573
|
+
}
|
|
4574
|
+
return ((parentid + hash) >>> 0) % FS.nameTable.length;
|
|
4575
|
+
},
|
|
4576
|
+
hashAddNode(node) {
|
|
4577
|
+
var hash = FS.hashName(node.parent.id, node.name);
|
|
4578
|
+
node.name_next = FS.nameTable[hash];
|
|
4579
|
+
FS.nameTable[hash] = node;
|
|
4580
|
+
},
|
|
4581
|
+
hashRemoveNode(node) {
|
|
4582
|
+
var hash = FS.hashName(node.parent.id, node.name);
|
|
4583
|
+
if (FS.nameTable[hash] === node) {
|
|
4584
|
+
FS.nameTable[hash] = node.name_next;
|
|
4585
|
+
} else {
|
|
4586
|
+
var current = FS.nameTable[hash];
|
|
4587
|
+
while (current) {
|
|
4588
|
+
if (current.name_next === node) {
|
|
4589
|
+
current.name_next = node.name_next;
|
|
4590
|
+
break;
|
|
4591
|
+
}
|
|
4592
|
+
current = current.name_next;
|
|
4593
|
+
}
|
|
4594
|
+
}
|
|
4595
|
+
},
|
|
4596
|
+
lookupNode(parent, name) {
|
|
4597
|
+
var errCode = FS.mayLookup(parent);
|
|
4598
|
+
if (errCode) {
|
|
4599
|
+
throw new FS.ErrnoError(errCode);
|
|
4600
|
+
}
|
|
4601
|
+
var hash = FS.hashName(parent.id, name);
|
|
4602
|
+
for (var node = FS.nameTable[hash]; node; node = node.name_next) {
|
|
4603
|
+
var nodeName = node.name;
|
|
4604
|
+
if (node.parent.id === parent.id && nodeName === name) {
|
|
4605
|
+
return node;
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4608
|
+
// if we failed to find it in the cache, call into the VFS
|
|
4609
|
+
return FS.lookup(parent, name);
|
|
4610
|
+
},
|
|
4611
|
+
createNode(parent, name, mode, rdev) {
|
|
4612
|
+
assert(typeof parent == 'object')
|
|
4613
|
+
var node = new FS.FSNode(parent, name, mode, rdev);
|
|
4614
|
+
|
|
4615
|
+
FS.hashAddNode(node);
|
|
4616
|
+
|
|
4617
|
+
return node;
|
|
4618
|
+
},
|
|
4619
|
+
destroyNode(node) {
|
|
4620
|
+
FS.hashRemoveNode(node);
|
|
4621
|
+
},
|
|
4622
|
+
isRoot(node) {
|
|
4623
|
+
return node === node.parent;
|
|
4624
|
+
},
|
|
4625
|
+
isMountpoint(node) {
|
|
4626
|
+
return !!node.mounted;
|
|
4627
|
+
},
|
|
4628
|
+
isFile(mode) {
|
|
4629
|
+
return (mode & 61440) === 32768;
|
|
4630
|
+
},
|
|
4631
|
+
isDir(mode) {
|
|
4632
|
+
return (mode & 61440) === 16384;
|
|
4633
|
+
},
|
|
4634
|
+
isLink(mode) {
|
|
4635
|
+
return (mode & 61440) === 40960;
|
|
4636
|
+
},
|
|
4637
|
+
isChrdev(mode) {
|
|
4638
|
+
return (mode & 61440) === 8192;
|
|
4639
|
+
},
|
|
4640
|
+
isBlkdev(mode) {
|
|
4641
|
+
return (mode & 61440) === 24576;
|
|
4642
|
+
},
|
|
4643
|
+
isFIFO(mode) {
|
|
4644
|
+
return (mode & 61440) === 4096;
|
|
4645
|
+
},
|
|
4646
|
+
isSocket(mode) {
|
|
4647
|
+
return (mode & 49152) === 49152;
|
|
4648
|
+
},
|
|
4649
|
+
flagsToPermissionString(flag) {
|
|
4650
|
+
var perms = ['r', 'w', 'rw'][flag & 3];
|
|
4651
|
+
if ((flag & 512)) {
|
|
4652
|
+
perms += 'w';
|
|
4653
|
+
}
|
|
4654
|
+
return perms;
|
|
4655
|
+
},
|
|
4656
|
+
nodePermissions(node, perms) {
|
|
4657
|
+
if (FS.ignorePermissions) {
|
|
4658
|
+
return 0;
|
|
4659
|
+
}
|
|
4660
|
+
// return 0 if any user, group or owner bits are set.
|
|
4661
|
+
if (perms.includes('r') && !(node.mode & 292)) {
|
|
4662
|
+
return 2;
|
|
4663
|
+
} else if (perms.includes('w') && !(node.mode & 146)) {
|
|
4664
|
+
return 2;
|
|
4665
|
+
} else if (perms.includes('x') && !(node.mode & 73)) {
|
|
4666
|
+
return 2;
|
|
4667
|
+
}
|
|
4668
|
+
return 0;
|
|
4669
|
+
},
|
|
4670
|
+
mayLookup(dir) {
|
|
4671
|
+
if (!FS.isDir(dir.mode)) return 54;
|
|
4672
|
+
var errCode = FS.nodePermissions(dir, 'x');
|
|
4673
|
+
if (errCode) return errCode;
|
|
4674
|
+
if (!dir.node_ops.lookup) return 2;
|
|
4675
|
+
return 0;
|
|
4676
|
+
},
|
|
4677
|
+
mayCreate(dir, name) {
|
|
4678
|
+
if (!FS.isDir(dir.mode)) {
|
|
4679
|
+
return 54;
|
|
4680
|
+
}
|
|
4681
|
+
try {
|
|
4682
|
+
var node = FS.lookupNode(dir, name);
|
|
4683
|
+
return 20;
|
|
4684
|
+
} catch (e) {
|
|
4685
|
+
}
|
|
4686
|
+
return FS.nodePermissions(dir, 'wx');
|
|
4687
|
+
},
|
|
4688
|
+
mayDelete(dir, name, isdir) {
|
|
4689
|
+
var node;
|
|
4690
|
+
try {
|
|
4691
|
+
node = FS.lookupNode(dir, name);
|
|
4692
|
+
} catch (e) {
|
|
4693
|
+
return e.errno;
|
|
4694
|
+
}
|
|
4695
|
+
var errCode = FS.nodePermissions(dir, 'wx');
|
|
4696
|
+
if (errCode) {
|
|
4697
|
+
return errCode;
|
|
4698
|
+
}
|
|
4699
|
+
if (isdir) {
|
|
4700
|
+
if (!FS.isDir(node.mode)) {
|
|
4701
|
+
return 54;
|
|
4702
|
+
}
|
|
4703
|
+
if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
|
|
4704
|
+
return 10;
|
|
4705
|
+
}
|
|
4706
|
+
} else {
|
|
4707
|
+
if (FS.isDir(node.mode)) {
|
|
4708
|
+
return 31;
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
return 0;
|
|
4712
|
+
},
|
|
4713
|
+
mayOpen(node, flags) {
|
|
4714
|
+
if (!node) {
|
|
4715
|
+
return 44;
|
|
4716
|
+
}
|
|
4717
|
+
if (FS.isLink(node.mode)) {
|
|
4718
|
+
return 32;
|
|
4719
|
+
} else if (FS.isDir(node.mode)) {
|
|
4720
|
+
if (FS.flagsToPermissionString(flags) !== 'r' // opening for write
|
|
4721
|
+
|| (flags & (512 | 64))) { // TODO: check for O_SEARCH? (== search for dir only)
|
|
4722
|
+
return 31;
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
|
|
4726
|
+
},
|
|
4727
|
+
checkOpExists(op, err) {
|
|
4728
|
+
if (!op) {
|
|
4729
|
+
throw new FS.ErrnoError(err);
|
|
4730
|
+
}
|
|
4731
|
+
return op;
|
|
4732
|
+
},
|
|
4733
|
+
MAX_OPEN_FDS:4096,
|
|
4734
|
+
nextfd() {
|
|
4735
|
+
for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) {
|
|
4736
|
+
if (!FS.streams[fd]) {
|
|
4737
|
+
return fd;
|
|
4738
|
+
}
|
|
4739
|
+
}
|
|
4740
|
+
throw new FS.ErrnoError(33);
|
|
4741
|
+
},
|
|
4742
|
+
getStreamChecked(fd) {
|
|
4743
|
+
var stream = FS.getStream(fd);
|
|
4744
|
+
if (!stream) {
|
|
4745
|
+
throw new FS.ErrnoError(8);
|
|
4746
|
+
}
|
|
4747
|
+
return stream;
|
|
4748
|
+
},
|
|
4749
|
+
getStream:(fd) => FS.streams[fd],
|
|
4750
|
+
createStream(stream, fd = -1) {
|
|
4751
|
+
assert(fd >= -1);
|
|
4752
|
+
|
|
4753
|
+
// clone it, so we can return an instance of FSStream
|
|
4754
|
+
stream = Object.assign(new FS.FSStream(), stream);
|
|
4755
|
+
if (fd == -1) {
|
|
4756
|
+
fd = FS.nextfd();
|
|
4757
|
+
}
|
|
4758
|
+
stream.fd = fd;
|
|
4759
|
+
FS.streams[fd] = stream;
|
|
4760
|
+
return stream;
|
|
4761
|
+
},
|
|
4762
|
+
closeStream(fd) {
|
|
4763
|
+
FS.streams[fd] = null;
|
|
4764
|
+
},
|
|
4765
|
+
dupStream(origStream, fd = -1) {
|
|
4766
|
+
var stream = FS.createStream(origStream, fd);
|
|
4767
|
+
stream.stream_ops?.dup?.(stream);
|
|
4768
|
+
return stream;
|
|
4769
|
+
},
|
|
4770
|
+
doSetAttr(stream, node, attr) {
|
|
4771
|
+
var setattr = stream?.stream_ops.setattr;
|
|
4772
|
+
var arg = setattr ? stream : node;
|
|
4773
|
+
setattr ??= node.node_ops.setattr;
|
|
4774
|
+
FS.checkOpExists(setattr, 63)
|
|
4775
|
+
setattr(arg, attr);
|
|
4776
|
+
},
|
|
4777
|
+
chrdev_stream_ops:{
|
|
4778
|
+
open(stream) {
|
|
4779
|
+
var device = FS.getDevice(stream.node.rdev);
|
|
4780
|
+
// override node's stream ops with the device's
|
|
4781
|
+
stream.stream_ops = device.stream_ops;
|
|
4782
|
+
// forward the open call
|
|
4783
|
+
stream.stream_ops.open?.(stream);
|
|
4784
|
+
},
|
|
4785
|
+
llseek() {
|
|
4786
|
+
throw new FS.ErrnoError(70);
|
|
4787
|
+
},
|
|
4788
|
+
},
|
|
4789
|
+
major:(dev) => ((dev) >> 8),
|
|
4790
|
+
minor:(dev) => ((dev) & 0xff),
|
|
4791
|
+
makedev:(ma, mi) => ((ma) << 8 | (mi)),
|
|
4792
|
+
registerDevice(dev, ops) {
|
|
4793
|
+
FS.devices[dev] = { stream_ops: ops };
|
|
4794
|
+
},
|
|
4795
|
+
getDevice:(dev) => FS.devices[dev],
|
|
4796
|
+
getMounts(mount) {
|
|
4797
|
+
var mounts = [];
|
|
4798
|
+
var check = [mount];
|
|
4799
|
+
|
|
4800
|
+
while (check.length) {
|
|
4801
|
+
var m = check.pop();
|
|
4802
|
+
|
|
4803
|
+
mounts.push(m);
|
|
4804
|
+
|
|
4805
|
+
check.push(...m.mounts);
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4808
|
+
return mounts;
|
|
4809
|
+
},
|
|
4810
|
+
syncfs(populate, callback) {
|
|
4811
|
+
if (typeof populate == 'function') {
|
|
4812
|
+
callback = populate;
|
|
4813
|
+
populate = false;
|
|
4814
|
+
}
|
|
4815
|
+
|
|
4816
|
+
FS.syncFSRequests++;
|
|
4817
|
+
|
|
4818
|
+
if (FS.syncFSRequests > 1) {
|
|
4819
|
+
err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);
|
|
4820
|
+
}
|
|
4821
|
+
|
|
4822
|
+
var mounts = FS.getMounts(FS.root.mount);
|
|
4823
|
+
var completed = 0;
|
|
4824
|
+
|
|
4825
|
+
function doCallback(errCode) {
|
|
4826
|
+
assert(FS.syncFSRequests > 0);
|
|
4827
|
+
FS.syncFSRequests--;
|
|
4828
|
+
return callback(errCode);
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4831
|
+
function done(errCode) {
|
|
4832
|
+
if (errCode) {
|
|
4833
|
+
if (!done.errored) {
|
|
4834
|
+
done.errored = true;
|
|
4835
|
+
return doCallback(errCode);
|
|
4836
|
+
}
|
|
4837
|
+
return;
|
|
4838
|
+
}
|
|
4839
|
+
if (++completed >= mounts.length) {
|
|
4840
|
+
doCallback(null);
|
|
4841
|
+
}
|
|
4842
|
+
};
|
|
4843
|
+
|
|
4844
|
+
// sync all mounts
|
|
4845
|
+
mounts.forEach((mount) => {
|
|
4846
|
+
if (!mount.type.syncfs) {
|
|
4847
|
+
return done(null);
|
|
4848
|
+
}
|
|
4849
|
+
mount.type.syncfs(mount, populate, done);
|
|
4850
|
+
});
|
|
4851
|
+
},
|
|
4852
|
+
mount(type, opts, mountpoint) {
|
|
4853
|
+
if (typeof type == 'string') {
|
|
4854
|
+
// The filesystem was not included, and instead we have an error
|
|
4855
|
+
// message stored in the variable.
|
|
4856
|
+
throw type;
|
|
4857
|
+
}
|
|
4858
|
+
var root = mountpoint === '/';
|
|
4859
|
+
var pseudo = !mountpoint;
|
|
4860
|
+
var node;
|
|
4861
|
+
|
|
4862
|
+
if (root && FS.root) {
|
|
4863
|
+
throw new FS.ErrnoError(10);
|
|
4864
|
+
} else if (!root && !pseudo) {
|
|
4865
|
+
var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
|
|
4866
|
+
|
|
4867
|
+
mountpoint = lookup.path; // use the absolute path
|
|
4868
|
+
node = lookup.node;
|
|
4869
|
+
|
|
4870
|
+
if (FS.isMountpoint(node)) {
|
|
4871
|
+
throw new FS.ErrnoError(10);
|
|
4872
|
+
}
|
|
4873
|
+
|
|
4874
|
+
if (!FS.isDir(node.mode)) {
|
|
4875
|
+
throw new FS.ErrnoError(54);
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
|
|
4879
|
+
var mount = {
|
|
4880
|
+
type,
|
|
4881
|
+
opts,
|
|
4882
|
+
mountpoint,
|
|
4883
|
+
mounts: []
|
|
4884
|
+
};
|
|
4885
|
+
|
|
4886
|
+
// create a root node for the fs
|
|
4887
|
+
var mountRoot = type.mount(mount);
|
|
4888
|
+
mountRoot.mount = mount;
|
|
4889
|
+
mount.root = mountRoot;
|
|
4890
|
+
|
|
4891
|
+
if (root) {
|
|
4892
|
+
FS.root = mountRoot;
|
|
4893
|
+
} else if (node) {
|
|
4894
|
+
// set as a mountpoint
|
|
4895
|
+
node.mounted = mount;
|
|
4896
|
+
|
|
4897
|
+
// add the new mount to the current mount's children
|
|
4898
|
+
if (node.mount) {
|
|
4899
|
+
node.mount.mounts.push(mount);
|
|
4900
|
+
}
|
|
4901
|
+
}
|
|
4902
|
+
|
|
4903
|
+
return mountRoot;
|
|
4904
|
+
},
|
|
4905
|
+
unmount(mountpoint) {
|
|
4906
|
+
var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
|
|
4907
|
+
|
|
4908
|
+
if (!FS.isMountpoint(lookup.node)) {
|
|
4909
|
+
throw new FS.ErrnoError(28);
|
|
4910
|
+
}
|
|
4911
|
+
|
|
4912
|
+
// destroy the nodes for this mount, and all its child mounts
|
|
4913
|
+
var node = lookup.node;
|
|
4914
|
+
var mount = node.mounted;
|
|
4915
|
+
var mounts = FS.getMounts(mount);
|
|
4916
|
+
|
|
4917
|
+
Object.keys(FS.nameTable).forEach((hash) => {
|
|
4918
|
+
var current = FS.nameTable[hash];
|
|
4919
|
+
|
|
4920
|
+
while (current) {
|
|
4921
|
+
var next = current.name_next;
|
|
4922
|
+
|
|
4923
|
+
if (mounts.includes(current.mount)) {
|
|
4924
|
+
FS.destroyNode(current);
|
|
4925
|
+
}
|
|
4926
|
+
|
|
4927
|
+
current = next;
|
|
4928
|
+
}
|
|
4929
|
+
});
|
|
4930
|
+
|
|
4931
|
+
// no longer a mountpoint
|
|
4932
|
+
node.mounted = null;
|
|
4933
|
+
|
|
4934
|
+
// remove this mount from the child mounts
|
|
4935
|
+
var idx = node.mount.mounts.indexOf(mount);
|
|
4936
|
+
assert(idx !== -1);
|
|
4937
|
+
node.mount.mounts.splice(idx, 1);
|
|
4938
|
+
},
|
|
4939
|
+
lookup(parent, name) {
|
|
4940
|
+
return parent.node_ops.lookup(parent, name);
|
|
4941
|
+
},
|
|
4942
|
+
mknod(path, mode, dev) {
|
|
4943
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
4944
|
+
var parent = lookup.node;
|
|
4945
|
+
var name = PATH.basename(path);
|
|
4946
|
+
if (!name) {
|
|
4947
|
+
throw new FS.ErrnoError(28);
|
|
4948
|
+
}
|
|
4949
|
+
if (name === '.' || name === '..') {
|
|
4950
|
+
throw new FS.ErrnoError(20);
|
|
4951
|
+
}
|
|
4952
|
+
var errCode = FS.mayCreate(parent, name);
|
|
4953
|
+
if (errCode) {
|
|
4954
|
+
throw new FS.ErrnoError(errCode);
|
|
4955
|
+
}
|
|
4956
|
+
if (!parent.node_ops.mknod) {
|
|
4957
|
+
throw new FS.ErrnoError(63);
|
|
4958
|
+
}
|
|
4959
|
+
return parent.node_ops.mknod(parent, name, mode, dev);
|
|
4960
|
+
},
|
|
4961
|
+
statfs(path) {
|
|
4962
|
+
return FS.statfsNode(FS.lookupPath(path, {follow: true}).node);
|
|
4963
|
+
},
|
|
4964
|
+
statfsStream(stream) {
|
|
4965
|
+
// We keep a separate statfsStream function because noderawfs overrides
|
|
4966
|
+
// it. In noderawfs, stream.node is sometimes null. Instead, we need to
|
|
4967
|
+
// look at stream.path.
|
|
4968
|
+
return FS.statfsNode(stream.node);
|
|
4969
|
+
},
|
|
4970
|
+
statfsNode(node) {
|
|
4971
|
+
// NOTE: None of the defaults here are true. We're just returning safe and
|
|
4972
|
+
// sane values. Currently nodefs and rawfs replace these defaults,
|
|
4973
|
+
// other file systems leave them alone.
|
|
4974
|
+
var rtn = {
|
|
4975
|
+
bsize: 4096,
|
|
4976
|
+
frsize: 4096,
|
|
4977
|
+
blocks: 1e6,
|
|
4978
|
+
bfree: 5e5,
|
|
4979
|
+
bavail: 5e5,
|
|
4980
|
+
files: FS.nextInode,
|
|
4981
|
+
ffree: FS.nextInode - 1,
|
|
4982
|
+
fsid: 42,
|
|
4983
|
+
flags: 2,
|
|
4984
|
+
namelen: 255,
|
|
4985
|
+
};
|
|
4986
|
+
|
|
4987
|
+
if (node.node_ops.statfs) {
|
|
4988
|
+
Object.assign(rtn, node.node_ops.statfs(node.mount.opts.root));
|
|
4989
|
+
}
|
|
4990
|
+
return rtn;
|
|
4991
|
+
},
|
|
4992
|
+
create(path, mode = 0o666) {
|
|
4993
|
+
mode &= 4095;
|
|
4994
|
+
mode |= 32768;
|
|
4995
|
+
return FS.mknod(path, mode, 0);
|
|
4996
|
+
},
|
|
4997
|
+
mkdir(path, mode = 0o777) {
|
|
4998
|
+
mode &= 511 | 512;
|
|
4999
|
+
mode |= 16384;
|
|
5000
|
+
return FS.mknod(path, mode, 0);
|
|
5001
|
+
},
|
|
5002
|
+
mkdirTree(path, mode) {
|
|
5003
|
+
var dirs = path.split('/');
|
|
5004
|
+
var d = '';
|
|
5005
|
+
for (var dir of dirs) {
|
|
5006
|
+
if (!dir) continue;
|
|
5007
|
+
if (d || PATH.isAbs(path)) d += '/';
|
|
5008
|
+
d += dir;
|
|
5009
|
+
try {
|
|
5010
|
+
FS.mkdir(d, mode);
|
|
5011
|
+
} catch(e) {
|
|
5012
|
+
if (e.errno != 20) throw e;
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
},
|
|
5016
|
+
mkdev(path, mode, dev) {
|
|
5017
|
+
if (typeof dev == 'undefined') {
|
|
5018
|
+
dev = mode;
|
|
5019
|
+
mode = 0o666;
|
|
5020
|
+
}
|
|
5021
|
+
mode |= 8192;
|
|
5022
|
+
return FS.mknod(path, mode, dev);
|
|
5023
|
+
},
|
|
5024
|
+
symlink(oldpath, newpath) {
|
|
5025
|
+
if (!PATH_FS.resolve(oldpath)) {
|
|
5026
|
+
throw new FS.ErrnoError(44);
|
|
5027
|
+
}
|
|
5028
|
+
var lookup = FS.lookupPath(newpath, { parent: true });
|
|
5029
|
+
var parent = lookup.node;
|
|
5030
|
+
if (!parent) {
|
|
5031
|
+
throw new FS.ErrnoError(44);
|
|
5032
|
+
}
|
|
5033
|
+
var newname = PATH.basename(newpath);
|
|
5034
|
+
var errCode = FS.mayCreate(parent, newname);
|
|
5035
|
+
if (errCode) {
|
|
5036
|
+
throw new FS.ErrnoError(errCode);
|
|
5037
|
+
}
|
|
5038
|
+
if (!parent.node_ops.symlink) {
|
|
5039
|
+
throw new FS.ErrnoError(63);
|
|
5040
|
+
}
|
|
5041
|
+
return parent.node_ops.symlink(parent, newname, oldpath);
|
|
5042
|
+
},
|
|
5043
|
+
rename(old_path, new_path) {
|
|
5044
|
+
var old_dirname = PATH.dirname(old_path);
|
|
5045
|
+
var new_dirname = PATH.dirname(new_path);
|
|
5046
|
+
var old_name = PATH.basename(old_path);
|
|
5047
|
+
var new_name = PATH.basename(new_path);
|
|
5048
|
+
// parents must exist
|
|
5049
|
+
var lookup, old_dir, new_dir;
|
|
5050
|
+
|
|
5051
|
+
// let the errors from non existent directories percolate up
|
|
5052
|
+
lookup = FS.lookupPath(old_path, { parent: true });
|
|
5053
|
+
old_dir = lookup.node;
|
|
5054
|
+
lookup = FS.lookupPath(new_path, { parent: true });
|
|
5055
|
+
new_dir = lookup.node;
|
|
5056
|
+
|
|
5057
|
+
if (!old_dir || !new_dir) throw new FS.ErrnoError(44);
|
|
5058
|
+
// need to be part of the same mount
|
|
5059
|
+
if (old_dir.mount !== new_dir.mount) {
|
|
5060
|
+
throw new FS.ErrnoError(75);
|
|
5061
|
+
}
|
|
5062
|
+
// source must exist
|
|
5063
|
+
var old_node = FS.lookupNode(old_dir, old_name);
|
|
5064
|
+
// old path should not be an ancestor of the new path
|
|
5065
|
+
var relative = PATH_FS.relative(old_path, new_dirname);
|
|
5066
|
+
if (relative.charAt(0) !== '.') {
|
|
5067
|
+
throw new FS.ErrnoError(28);
|
|
5068
|
+
}
|
|
5069
|
+
// new path should not be an ancestor of the old path
|
|
5070
|
+
relative = PATH_FS.relative(new_path, old_dirname);
|
|
5071
|
+
if (relative.charAt(0) !== '.') {
|
|
5072
|
+
throw new FS.ErrnoError(55);
|
|
5073
|
+
}
|
|
5074
|
+
// see if the new path already exists
|
|
5075
|
+
var new_node;
|
|
5076
|
+
try {
|
|
5077
|
+
new_node = FS.lookupNode(new_dir, new_name);
|
|
5078
|
+
} catch (e) {
|
|
5079
|
+
// not fatal
|
|
5080
|
+
}
|
|
5081
|
+
// early out if nothing needs to change
|
|
5082
|
+
if (old_node === new_node) {
|
|
5083
|
+
return;
|
|
5084
|
+
}
|
|
5085
|
+
// we'll need to delete the old entry
|
|
5086
|
+
var isdir = FS.isDir(old_node.mode);
|
|
5087
|
+
var errCode = FS.mayDelete(old_dir, old_name, isdir);
|
|
5088
|
+
if (errCode) {
|
|
5089
|
+
throw new FS.ErrnoError(errCode);
|
|
5090
|
+
}
|
|
5091
|
+
// need delete permissions if we'll be overwriting.
|
|
5092
|
+
// need create permissions if new doesn't already exist.
|
|
5093
|
+
errCode = new_node ?
|
|
5094
|
+
FS.mayDelete(new_dir, new_name, isdir) :
|
|
5095
|
+
FS.mayCreate(new_dir, new_name);
|
|
5096
|
+
if (errCode) {
|
|
5097
|
+
throw new FS.ErrnoError(errCode);
|
|
5098
|
+
}
|
|
5099
|
+
if (!old_dir.node_ops.rename) {
|
|
5100
|
+
throw new FS.ErrnoError(63);
|
|
5101
|
+
}
|
|
5102
|
+
if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
|
|
5103
|
+
throw new FS.ErrnoError(10);
|
|
5104
|
+
}
|
|
5105
|
+
// if we are going to change the parent, check write permissions
|
|
5106
|
+
if (new_dir !== old_dir) {
|
|
5107
|
+
errCode = FS.nodePermissions(old_dir, 'w');
|
|
5108
|
+
if (errCode) {
|
|
5109
|
+
throw new FS.ErrnoError(errCode);
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
// remove the node from the lookup hash
|
|
5113
|
+
FS.hashRemoveNode(old_node);
|
|
5114
|
+
// do the underlying fs rename
|
|
5115
|
+
try {
|
|
5116
|
+
old_dir.node_ops.rename(old_node, new_dir, new_name);
|
|
5117
|
+
// update old node (we do this here to avoid each backend
|
|
5118
|
+
// needing to)
|
|
5119
|
+
old_node.parent = new_dir;
|
|
5120
|
+
} catch (e) {
|
|
5121
|
+
throw e;
|
|
5122
|
+
} finally {
|
|
5123
|
+
// add the node back to the hash (in case node_ops.rename
|
|
5124
|
+
// changed its name)
|
|
5125
|
+
FS.hashAddNode(old_node);
|
|
5126
|
+
}
|
|
5127
|
+
},
|
|
5128
|
+
rmdir(path) {
|
|
5129
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
5130
|
+
var parent = lookup.node;
|
|
5131
|
+
var name = PATH.basename(path);
|
|
5132
|
+
var node = FS.lookupNode(parent, name);
|
|
5133
|
+
var errCode = FS.mayDelete(parent, name, true);
|
|
5134
|
+
if (errCode) {
|
|
5135
|
+
throw new FS.ErrnoError(errCode);
|
|
5136
|
+
}
|
|
5137
|
+
if (!parent.node_ops.rmdir) {
|
|
5138
|
+
throw new FS.ErrnoError(63);
|
|
5139
|
+
}
|
|
5140
|
+
if (FS.isMountpoint(node)) {
|
|
5141
|
+
throw new FS.ErrnoError(10);
|
|
5142
|
+
}
|
|
5143
|
+
parent.node_ops.rmdir(parent, name);
|
|
5144
|
+
FS.destroyNode(node);
|
|
5145
|
+
},
|
|
5146
|
+
readdir(path) {
|
|
5147
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
5148
|
+
var node = lookup.node;
|
|
5149
|
+
var readdir = FS.checkOpExists(node.node_ops.readdir, 54);
|
|
5150
|
+
return readdir(node);
|
|
5151
|
+
},
|
|
5152
|
+
unlink(path) {
|
|
5153
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
5154
|
+
var parent = lookup.node;
|
|
5155
|
+
if (!parent) {
|
|
5156
|
+
throw new FS.ErrnoError(44);
|
|
5157
|
+
}
|
|
5158
|
+
var name = PATH.basename(path);
|
|
5159
|
+
var node = FS.lookupNode(parent, name);
|
|
5160
|
+
var errCode = FS.mayDelete(parent, name, false);
|
|
5161
|
+
if (errCode) {
|
|
5162
|
+
// According to POSIX, we should map EISDIR to EPERM, but
|
|
5163
|
+
// we instead do what Linux does (and we must, as we use
|
|
5164
|
+
// the musl linux libc).
|
|
5165
|
+
throw new FS.ErrnoError(errCode);
|
|
5166
|
+
}
|
|
5167
|
+
if (!parent.node_ops.unlink) {
|
|
5168
|
+
throw new FS.ErrnoError(63);
|
|
5169
|
+
}
|
|
5170
|
+
if (FS.isMountpoint(node)) {
|
|
5171
|
+
throw new FS.ErrnoError(10);
|
|
5172
|
+
}
|
|
5173
|
+
parent.node_ops.unlink(parent, name);
|
|
5174
|
+
FS.destroyNode(node);
|
|
5175
|
+
},
|
|
5176
|
+
readlink(path) {
|
|
5177
|
+
var lookup = FS.lookupPath(path);
|
|
5178
|
+
var link = lookup.node;
|
|
5179
|
+
if (!link) {
|
|
5180
|
+
throw new FS.ErrnoError(44);
|
|
5181
|
+
}
|
|
5182
|
+
if (!link.node_ops.readlink) {
|
|
5183
|
+
throw new FS.ErrnoError(28);
|
|
5184
|
+
}
|
|
5185
|
+
return link.node_ops.readlink(link);
|
|
5186
|
+
},
|
|
5187
|
+
stat(path, dontFollow) {
|
|
5188
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
5189
|
+
var node = lookup.node;
|
|
5190
|
+
var getattr = FS.checkOpExists(node.node_ops.getattr, 63);
|
|
5191
|
+
return getattr(node);
|
|
5192
|
+
},
|
|
5193
|
+
fstat(fd) {
|
|
5194
|
+
var stream = FS.getStreamChecked(fd);
|
|
5195
|
+
var node = stream.node;
|
|
5196
|
+
var getattr = stream.stream_ops.getattr;
|
|
5197
|
+
var arg = getattr ? stream : node;
|
|
5198
|
+
getattr ??= node.node_ops.getattr;
|
|
5199
|
+
FS.checkOpExists(getattr, 63)
|
|
5200
|
+
return getattr(arg);
|
|
5201
|
+
},
|
|
5202
|
+
lstat(path) {
|
|
5203
|
+
return FS.stat(path, true);
|
|
5204
|
+
},
|
|
5205
|
+
doChmod(stream, node, mode, dontFollow) {
|
|
5206
|
+
FS.doSetAttr(stream, node, {
|
|
5207
|
+
mode: (mode & 4095) | (node.mode & ~4095),
|
|
5208
|
+
ctime: Date.now(),
|
|
5209
|
+
dontFollow
|
|
5210
|
+
});
|
|
5211
|
+
},
|
|
5212
|
+
chmod(path, mode, dontFollow) {
|
|
5213
|
+
var node;
|
|
5214
|
+
if (typeof path == 'string') {
|
|
5215
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
5216
|
+
node = lookup.node;
|
|
5217
|
+
} else {
|
|
5218
|
+
node = path;
|
|
5219
|
+
}
|
|
5220
|
+
FS.doChmod(null, node, mode, dontFollow);
|
|
5221
|
+
},
|
|
5222
|
+
lchmod(path, mode) {
|
|
5223
|
+
FS.chmod(path, mode, true);
|
|
5224
|
+
},
|
|
5225
|
+
fchmod(fd, mode) {
|
|
5226
|
+
var stream = FS.getStreamChecked(fd);
|
|
5227
|
+
FS.doChmod(stream, stream.node, mode, false);
|
|
5228
|
+
},
|
|
5229
|
+
doChown(stream, node, dontFollow) {
|
|
5230
|
+
FS.doSetAttr(stream, node, {
|
|
5231
|
+
timestamp: Date.now(),
|
|
5232
|
+
dontFollow
|
|
5233
|
+
// we ignore the uid / gid for now
|
|
5234
|
+
});
|
|
5235
|
+
},
|
|
5236
|
+
chown(path, uid, gid, dontFollow) {
|
|
5237
|
+
var node;
|
|
5238
|
+
if (typeof path == 'string') {
|
|
5239
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
5240
|
+
node = lookup.node;
|
|
5241
|
+
} else {
|
|
5242
|
+
node = path;
|
|
5243
|
+
}
|
|
5244
|
+
FS.doChown(null, node, dontFollow);
|
|
5245
|
+
},
|
|
5246
|
+
lchown(path, uid, gid) {
|
|
5247
|
+
FS.chown(path, uid, gid, true);
|
|
5248
|
+
},
|
|
5249
|
+
fchown(fd, uid, gid) {
|
|
5250
|
+
var stream = FS.getStreamChecked(fd);
|
|
5251
|
+
FS.doChown(stream, stream.node, false);
|
|
5252
|
+
},
|
|
5253
|
+
doTruncate(stream, node, len) {
|
|
5254
|
+
if (FS.isDir(node.mode)) {
|
|
5255
|
+
throw new FS.ErrnoError(31);
|
|
5256
|
+
}
|
|
5257
|
+
if (!FS.isFile(node.mode)) {
|
|
5258
|
+
throw new FS.ErrnoError(28);
|
|
5259
|
+
}
|
|
5260
|
+
var errCode = FS.nodePermissions(node, 'w');
|
|
5261
|
+
if (errCode) {
|
|
5262
|
+
throw new FS.ErrnoError(errCode);
|
|
5263
|
+
}
|
|
5264
|
+
FS.doSetAttr(stream, node, {
|
|
5265
|
+
size: len,
|
|
5266
|
+
timestamp: Date.now()
|
|
5267
|
+
});
|
|
5268
|
+
},
|
|
5269
|
+
truncate(path, len) {
|
|
5270
|
+
if (len < 0) {
|
|
5271
|
+
throw new FS.ErrnoError(28);
|
|
5272
|
+
}
|
|
5273
|
+
var node;
|
|
5274
|
+
if (typeof path == 'string') {
|
|
5275
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
5276
|
+
node = lookup.node;
|
|
5277
|
+
} else {
|
|
5278
|
+
node = path;
|
|
5279
|
+
}
|
|
5280
|
+
FS.doTruncate(null, node, len);
|
|
5281
|
+
},
|
|
5282
|
+
ftruncate(fd, len) {
|
|
5283
|
+
var stream = FS.getStreamChecked(fd);
|
|
5284
|
+
if (len < 0 || (stream.flags & 2097155) === 0) {
|
|
5285
|
+
throw new FS.ErrnoError(28);
|
|
5286
|
+
}
|
|
5287
|
+
FS.doTruncate(stream, stream.node, len);
|
|
5288
|
+
},
|
|
5289
|
+
utime(path, atime, mtime) {
|
|
5290
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
5291
|
+
var node = lookup.node;
|
|
5292
|
+
var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
|
|
5293
|
+
setattr(node, {
|
|
5294
|
+
atime: atime,
|
|
5295
|
+
mtime: mtime
|
|
5296
|
+
});
|
|
5297
|
+
},
|
|
5298
|
+
open(path, flags, mode = 0o666) {
|
|
5299
|
+
if (path === "") {
|
|
5300
|
+
throw new FS.ErrnoError(44);
|
|
5301
|
+
}
|
|
5302
|
+
flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags;
|
|
5303
|
+
if ((flags & 64)) {
|
|
5304
|
+
mode = (mode & 4095) | 32768;
|
|
5305
|
+
} else {
|
|
5306
|
+
mode = 0;
|
|
5307
|
+
}
|
|
5308
|
+
var node;
|
|
5309
|
+
var isDirPath;
|
|
5310
|
+
if (typeof path == 'object') {
|
|
5311
|
+
node = path;
|
|
5312
|
+
} else {
|
|
5313
|
+
isDirPath = path.endsWith("/");
|
|
5314
|
+
// noent_okay makes it so that if the final component of the path
|
|
5315
|
+
// doesn't exist, lookupPath returns `node: undefined`. `path` will be
|
|
5316
|
+
// updated to point to the target of all symlinks.
|
|
5317
|
+
var lookup = FS.lookupPath(path, {
|
|
5318
|
+
follow: !(flags & 131072),
|
|
5319
|
+
noent_okay: true
|
|
5320
|
+
});
|
|
5321
|
+
node = lookup.node;
|
|
5322
|
+
path = lookup.path;
|
|
5323
|
+
}
|
|
5324
|
+
// perhaps we need to create the node
|
|
5325
|
+
var created = false;
|
|
5326
|
+
if ((flags & 64)) {
|
|
5327
|
+
if (node) {
|
|
5328
|
+
// if O_CREAT and O_EXCL are set, error out if the node already exists
|
|
5329
|
+
if ((flags & 128)) {
|
|
5330
|
+
throw new FS.ErrnoError(20);
|
|
5331
|
+
}
|
|
5332
|
+
} else if (isDirPath) {
|
|
5333
|
+
throw new FS.ErrnoError(31);
|
|
5334
|
+
} else {
|
|
5335
|
+
// node doesn't exist, try to create it
|
|
5336
|
+
// Ignore the permission bits here to ensure we can `open` this new
|
|
5337
|
+
// file below. We use chmod below the apply the permissions once the
|
|
5338
|
+
// file is open.
|
|
5339
|
+
node = FS.mknod(path, mode | 0o777, 0);
|
|
5340
|
+
created = true;
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
if (!node) {
|
|
5344
|
+
throw new FS.ErrnoError(44);
|
|
5345
|
+
}
|
|
5346
|
+
// can't truncate a device
|
|
5347
|
+
if (FS.isChrdev(node.mode)) {
|
|
5348
|
+
flags &= ~512;
|
|
5349
|
+
}
|
|
5350
|
+
// if asked only for a directory, then this must be one
|
|
5351
|
+
if ((flags & 65536) && !FS.isDir(node.mode)) {
|
|
5352
|
+
throw new FS.ErrnoError(54);
|
|
5353
|
+
}
|
|
5354
|
+
// check permissions, if this is not a file we just created now (it is ok to
|
|
5355
|
+
// create and write to a file with read-only permissions; it is read-only
|
|
5356
|
+
// for later use)
|
|
5357
|
+
if (!created) {
|
|
5358
|
+
var errCode = FS.mayOpen(node, flags);
|
|
5359
|
+
if (errCode) {
|
|
5360
|
+
throw new FS.ErrnoError(errCode);
|
|
5361
|
+
}
|
|
5362
|
+
}
|
|
5363
|
+
// do truncation if necessary
|
|
5364
|
+
if ((flags & 512) && !created) {
|
|
5365
|
+
FS.truncate(node, 0);
|
|
5366
|
+
}
|
|
5367
|
+
// we've already handled these, don't pass down to the underlying vfs
|
|
5368
|
+
flags &= ~(128 | 512 | 131072);
|
|
5369
|
+
|
|
5370
|
+
// register the stream with the filesystem
|
|
5371
|
+
var stream = FS.createStream({
|
|
5372
|
+
node,
|
|
5373
|
+
path: FS.getPath(node), // we want the absolute path to the node
|
|
5374
|
+
flags,
|
|
5375
|
+
seekable: true,
|
|
5376
|
+
position: 0,
|
|
5377
|
+
stream_ops: node.stream_ops,
|
|
5378
|
+
// used by the file family libc calls (fopen, fwrite, ferror, etc.)
|
|
5379
|
+
ungotten: [],
|
|
5380
|
+
error: false
|
|
5381
|
+
});
|
|
5382
|
+
// call the new stream's open function
|
|
5383
|
+
if (stream.stream_ops.open) {
|
|
5384
|
+
stream.stream_ops.open(stream);
|
|
5385
|
+
}
|
|
5386
|
+
if (created) {
|
|
5387
|
+
FS.chmod(node, mode & 0o777);
|
|
5388
|
+
}
|
|
5389
|
+
if (Module['logReadFiles'] && !(flags & 1)) {
|
|
5390
|
+
if (!(path in FS.readFiles)) {
|
|
5391
|
+
FS.readFiles[path] = 1;
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
return stream;
|
|
5395
|
+
},
|
|
5396
|
+
close(stream) {
|
|
5397
|
+
if (FS.isClosed(stream)) {
|
|
5398
|
+
throw new FS.ErrnoError(8);
|
|
5399
|
+
}
|
|
5400
|
+
if (stream.getdents) stream.getdents = null; // free readdir state
|
|
5401
|
+
try {
|
|
5402
|
+
if (stream.stream_ops.close) {
|
|
5403
|
+
stream.stream_ops.close(stream);
|
|
5404
|
+
}
|
|
5405
|
+
} catch (e) {
|
|
5406
|
+
throw e;
|
|
5407
|
+
} finally {
|
|
5408
|
+
FS.closeStream(stream.fd);
|
|
5409
|
+
}
|
|
5410
|
+
stream.fd = null;
|
|
5411
|
+
},
|
|
5412
|
+
isClosed(stream) {
|
|
5413
|
+
return stream.fd === null;
|
|
5414
|
+
},
|
|
5415
|
+
llseek(stream, offset, whence) {
|
|
5416
|
+
if (FS.isClosed(stream)) {
|
|
5417
|
+
throw new FS.ErrnoError(8);
|
|
5418
|
+
}
|
|
5419
|
+
if (!stream.seekable || !stream.stream_ops.llseek) {
|
|
5420
|
+
throw new FS.ErrnoError(70);
|
|
5421
|
+
}
|
|
5422
|
+
if (whence != 0 && whence != 1 && whence != 2) {
|
|
5423
|
+
throw new FS.ErrnoError(28);
|
|
5424
|
+
}
|
|
5425
|
+
stream.position = stream.stream_ops.llseek(stream, offset, whence);
|
|
5426
|
+
stream.ungotten = [];
|
|
5427
|
+
return stream.position;
|
|
5428
|
+
},
|
|
5429
|
+
read(stream, buffer, offset, length, position) {
|
|
5430
|
+
assert(offset >= 0);
|
|
5431
|
+
if (length < 0 || position < 0) {
|
|
5432
|
+
throw new FS.ErrnoError(28);
|
|
5433
|
+
}
|
|
5434
|
+
if (FS.isClosed(stream)) {
|
|
5435
|
+
throw new FS.ErrnoError(8);
|
|
5436
|
+
}
|
|
5437
|
+
if ((stream.flags & 2097155) === 1) {
|
|
5438
|
+
throw new FS.ErrnoError(8);
|
|
5439
|
+
}
|
|
5440
|
+
if (FS.isDir(stream.node.mode)) {
|
|
5441
|
+
throw new FS.ErrnoError(31);
|
|
5442
|
+
}
|
|
5443
|
+
if (!stream.stream_ops.read) {
|
|
5444
|
+
throw new FS.ErrnoError(28);
|
|
5445
|
+
}
|
|
5446
|
+
var seeking = typeof position != 'undefined';
|
|
5447
|
+
if (!seeking) {
|
|
5448
|
+
position = stream.position;
|
|
5449
|
+
} else if (!stream.seekable) {
|
|
5450
|
+
throw new FS.ErrnoError(70);
|
|
5451
|
+
}
|
|
5452
|
+
var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
|
|
5453
|
+
if (!seeking) stream.position += bytesRead;
|
|
5454
|
+
return bytesRead;
|
|
5455
|
+
},
|
|
5456
|
+
write(stream, buffer, offset, length, position, canOwn) {
|
|
5457
|
+
assert(offset >= 0);
|
|
5458
|
+
if (length < 0 || position < 0) {
|
|
5459
|
+
throw new FS.ErrnoError(28);
|
|
5460
|
+
}
|
|
5461
|
+
if (FS.isClosed(stream)) {
|
|
5462
|
+
throw new FS.ErrnoError(8);
|
|
5463
|
+
}
|
|
5464
|
+
if ((stream.flags & 2097155) === 0) {
|
|
5465
|
+
throw new FS.ErrnoError(8);
|
|
5466
|
+
}
|
|
5467
|
+
if (FS.isDir(stream.node.mode)) {
|
|
5468
|
+
throw new FS.ErrnoError(31);
|
|
5469
|
+
}
|
|
5470
|
+
if (!stream.stream_ops.write) {
|
|
5471
|
+
throw new FS.ErrnoError(28);
|
|
5472
|
+
}
|
|
5473
|
+
if (stream.seekable && stream.flags & 1024) {
|
|
5474
|
+
// seek to the end before writing in append mode
|
|
5475
|
+
FS.llseek(stream, 0, 2);
|
|
5476
|
+
}
|
|
5477
|
+
var seeking = typeof position != 'undefined';
|
|
5478
|
+
if (!seeking) {
|
|
5479
|
+
position = stream.position;
|
|
5480
|
+
} else if (!stream.seekable) {
|
|
5481
|
+
throw new FS.ErrnoError(70);
|
|
5482
|
+
}
|
|
5483
|
+
var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
|
|
5484
|
+
if (!seeking) stream.position += bytesWritten;
|
|
5485
|
+
return bytesWritten;
|
|
5486
|
+
},
|
|
5487
|
+
mmap(stream, length, position, prot, flags) {
|
|
5488
|
+
// User requests writing to file (prot & PROT_WRITE != 0).
|
|
5489
|
+
// Checking if we have permissions to write to the file unless
|
|
5490
|
+
// MAP_PRIVATE flag is set. According to POSIX spec it is possible
|
|
5491
|
+
// to write to file opened in read-only mode with MAP_PRIVATE flag,
|
|
5492
|
+
// as all modifications will be visible only in the memory of
|
|
5493
|
+
// the current process.
|
|
5494
|
+
if ((prot & 2) !== 0
|
|
5495
|
+
&& (flags & 2) === 0
|
|
5496
|
+
&& (stream.flags & 2097155) !== 2) {
|
|
5497
|
+
throw new FS.ErrnoError(2);
|
|
5498
|
+
}
|
|
5499
|
+
if ((stream.flags & 2097155) === 1) {
|
|
5500
|
+
throw new FS.ErrnoError(2);
|
|
5501
|
+
}
|
|
5502
|
+
if (!stream.stream_ops.mmap) {
|
|
5503
|
+
throw new FS.ErrnoError(43);
|
|
5504
|
+
}
|
|
5505
|
+
if (!length) {
|
|
5506
|
+
throw new FS.ErrnoError(28);
|
|
5507
|
+
}
|
|
5508
|
+
return stream.stream_ops.mmap(stream, length, position, prot, flags);
|
|
5509
|
+
},
|
|
5510
|
+
msync(stream, buffer, offset, length, mmapFlags) {
|
|
5511
|
+
assert(offset >= 0);
|
|
5512
|
+
if (!stream.stream_ops.msync) {
|
|
5513
|
+
return 0;
|
|
5514
|
+
}
|
|
5515
|
+
return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
|
|
5516
|
+
},
|
|
5517
|
+
ioctl(stream, cmd, arg) {
|
|
5518
|
+
if (!stream.stream_ops.ioctl) {
|
|
5519
|
+
throw new FS.ErrnoError(59);
|
|
5520
|
+
}
|
|
5521
|
+
return stream.stream_ops.ioctl(stream, cmd, arg);
|
|
5522
|
+
},
|
|
5523
|
+
readFile(path, opts = {}) {
|
|
5524
|
+
opts.flags = opts.flags || 0;
|
|
5525
|
+
opts.encoding = opts.encoding || 'binary';
|
|
5526
|
+
if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
|
|
5527
|
+
throw new Error(`Invalid encoding type "${opts.encoding}"`);
|
|
5528
|
+
}
|
|
5529
|
+
var stream = FS.open(path, opts.flags);
|
|
5530
|
+
var stat = FS.stat(path);
|
|
5531
|
+
var length = stat.size;
|
|
5532
|
+
var buf = new Uint8Array(length);
|
|
5533
|
+
FS.read(stream, buf, 0, length, 0);
|
|
5534
|
+
if (opts.encoding === 'utf8') {
|
|
5535
|
+
buf = UTF8ArrayToString(buf);
|
|
5536
|
+
}
|
|
5537
|
+
FS.close(stream);
|
|
5538
|
+
return buf;
|
|
5539
|
+
},
|
|
5540
|
+
writeFile(path, data, opts = {}) {
|
|
5541
|
+
opts.flags = opts.flags || 577;
|
|
5542
|
+
var stream = FS.open(path, opts.flags, opts.mode);
|
|
5543
|
+
if (typeof data == 'string') {
|
|
5544
|
+
data = new Uint8Array(intArrayFromString(data, true));
|
|
5545
|
+
}
|
|
5546
|
+
if (ArrayBuffer.isView(data)) {
|
|
5547
|
+
FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
|
|
5548
|
+
} else {
|
|
5549
|
+
throw new Error('Unsupported data type');
|
|
5550
|
+
}
|
|
5551
|
+
FS.close(stream);
|
|
5552
|
+
},
|
|
5553
|
+
cwd:() => FS.currentPath,
|
|
5554
|
+
chdir(path) {
|
|
5555
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
5556
|
+
if (lookup.node === null) {
|
|
5557
|
+
throw new FS.ErrnoError(44);
|
|
5558
|
+
}
|
|
5559
|
+
if (!FS.isDir(lookup.node.mode)) {
|
|
5560
|
+
throw new FS.ErrnoError(54);
|
|
5561
|
+
}
|
|
5562
|
+
var errCode = FS.nodePermissions(lookup.node, 'x');
|
|
5563
|
+
if (errCode) {
|
|
5564
|
+
throw new FS.ErrnoError(errCode);
|
|
5565
|
+
}
|
|
5566
|
+
FS.currentPath = lookup.path;
|
|
5567
|
+
},
|
|
5568
|
+
createDefaultDirectories() {
|
|
5569
|
+
FS.mkdir('/tmp');
|
|
5570
|
+
FS.mkdir('/home');
|
|
5571
|
+
FS.mkdir('/home/web_user');
|
|
5572
|
+
},
|
|
5573
|
+
createDefaultDevices() {
|
|
5574
|
+
// create /dev
|
|
5575
|
+
FS.mkdir('/dev');
|
|
5576
|
+
// setup /dev/null
|
|
5577
|
+
FS.registerDevice(FS.makedev(1, 3), {
|
|
5578
|
+
read: () => 0,
|
|
5579
|
+
write: (stream, buffer, offset, length, pos) => length,
|
|
5580
|
+
llseek: () => 0,
|
|
5581
|
+
});
|
|
5582
|
+
FS.mkdev('/dev/null', FS.makedev(1, 3));
|
|
5583
|
+
// setup /dev/tty and /dev/tty1
|
|
5584
|
+
// stderr needs to print output using err() rather than out()
|
|
5585
|
+
// so we register a second tty just for it.
|
|
5586
|
+
TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
|
|
5587
|
+
TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
|
|
5588
|
+
FS.mkdev('/dev/tty', FS.makedev(5, 0));
|
|
5589
|
+
FS.mkdev('/dev/tty1', FS.makedev(6, 0));
|
|
5590
|
+
// setup /dev/[u]random
|
|
5591
|
+
// use a buffer to avoid overhead of individual crypto calls per byte
|
|
5592
|
+
var randomBuffer = new Uint8Array(1024), randomLeft = 0;
|
|
5593
|
+
var randomByte = () => {
|
|
5594
|
+
if (randomLeft === 0) {
|
|
5595
|
+
randomFill(randomBuffer);
|
|
5596
|
+
randomLeft = randomBuffer.byteLength;
|
|
5597
|
+
}
|
|
5598
|
+
return randomBuffer[--randomLeft];
|
|
5599
|
+
};
|
|
5600
|
+
FS.createDevice('/dev', 'random', randomByte);
|
|
5601
|
+
FS.createDevice('/dev', 'urandom', randomByte);
|
|
5602
|
+
// we're not going to emulate the actual shm device,
|
|
5603
|
+
// just create the tmp dirs that reside in it commonly
|
|
5604
|
+
FS.mkdir('/dev/shm');
|
|
5605
|
+
FS.mkdir('/dev/shm/tmp');
|
|
5606
|
+
},
|
|
5607
|
+
createSpecialDirectories() {
|
|
5608
|
+
// create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the
|
|
5609
|
+
// name of the stream for fd 6 (see test_unistd_ttyname)
|
|
5610
|
+
FS.mkdir('/proc');
|
|
5611
|
+
var proc_self = FS.mkdir('/proc/self');
|
|
5612
|
+
FS.mkdir('/proc/self/fd');
|
|
5613
|
+
FS.mount({
|
|
5614
|
+
mount() {
|
|
5615
|
+
var node = FS.createNode(proc_self, 'fd', 16895, 73);
|
|
5616
|
+
node.stream_ops = {
|
|
5617
|
+
llseek: MEMFS.stream_ops.llseek,
|
|
5618
|
+
};
|
|
5619
|
+
node.node_ops = {
|
|
5620
|
+
lookup(parent, name) {
|
|
5621
|
+
var fd = +name;
|
|
5622
|
+
var stream = FS.getStreamChecked(fd);
|
|
5623
|
+
var ret = {
|
|
5624
|
+
parent: null,
|
|
5625
|
+
mount: { mountpoint: 'fake' },
|
|
5626
|
+
node_ops: { readlink: () => stream.path },
|
|
5627
|
+
id: fd + 1,
|
|
5628
|
+
};
|
|
5629
|
+
ret.parent = ret; // make it look like a simple root node
|
|
5630
|
+
return ret;
|
|
5631
|
+
},
|
|
5632
|
+
readdir() {
|
|
5633
|
+
return Array.from(FS.streams.entries())
|
|
5634
|
+
.filter(([k, v]) => v)
|
|
5635
|
+
.map(([k, v]) => k.toString());
|
|
5636
|
+
}
|
|
5637
|
+
};
|
|
5638
|
+
return node;
|
|
5639
|
+
}
|
|
5640
|
+
}, {}, '/proc/self/fd');
|
|
5641
|
+
},
|
|
5642
|
+
createStandardStreams(input, output, error) {
|
|
5643
|
+
// TODO deprecate the old functionality of a single
|
|
5644
|
+
// input / output callback and that utilizes FS.createDevice
|
|
5645
|
+
// and instead require a unique set of stream ops
|
|
5646
|
+
|
|
5647
|
+
// by default, we symlink the standard streams to the
|
|
5648
|
+
// default tty devices. however, if the standard streams
|
|
5649
|
+
// have been overwritten we create a unique device for
|
|
5650
|
+
// them instead.
|
|
5651
|
+
if (input) {
|
|
5652
|
+
FS.createDevice('/dev', 'stdin', input);
|
|
5653
|
+
} else {
|
|
5654
|
+
FS.symlink('/dev/tty', '/dev/stdin');
|
|
5655
|
+
}
|
|
5656
|
+
if (output) {
|
|
5657
|
+
FS.createDevice('/dev', 'stdout', null, output);
|
|
5658
|
+
} else {
|
|
5659
|
+
FS.symlink('/dev/tty', '/dev/stdout');
|
|
5660
|
+
}
|
|
5661
|
+
if (error) {
|
|
5662
|
+
FS.createDevice('/dev', 'stderr', null, error);
|
|
5663
|
+
} else {
|
|
5664
|
+
FS.symlink('/dev/tty1', '/dev/stderr');
|
|
5665
|
+
}
|
|
5666
|
+
|
|
5667
|
+
// open default streams for the stdin, stdout and stderr devices
|
|
5668
|
+
var stdin = FS.open('/dev/stdin', 0);
|
|
5669
|
+
var stdout = FS.open('/dev/stdout', 1);
|
|
5670
|
+
var stderr = FS.open('/dev/stderr', 1);
|
|
5671
|
+
assert(stdin.fd === 0, `invalid handle for stdin (${stdin.fd})`);
|
|
5672
|
+
assert(stdout.fd === 1, `invalid handle for stdout (${stdout.fd})`);
|
|
5673
|
+
assert(stderr.fd === 2, `invalid handle for stderr (${stderr.fd})`);
|
|
5674
|
+
},
|
|
5675
|
+
staticInit() {
|
|
5676
|
+
FS.nameTable = new Array(4096);
|
|
5677
|
+
|
|
5678
|
+
FS.mount(MEMFS, {}, '/');
|
|
5679
|
+
|
|
5680
|
+
FS.createDefaultDirectories();
|
|
5681
|
+
FS.createDefaultDevices();
|
|
5682
|
+
FS.createSpecialDirectories();
|
|
5683
|
+
|
|
5684
|
+
FS.filesystems = {
|
|
5685
|
+
'MEMFS': MEMFS,
|
|
5686
|
+
};
|
|
5687
|
+
},
|
|
5688
|
+
init(input, output, error) {
|
|
5689
|
+
assert(!FS.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
|
|
5690
|
+
FS.initialized = true;
|
|
5691
|
+
|
|
5692
|
+
// Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
|
|
5693
|
+
input ??= Module['stdin'];
|
|
5694
|
+
output ??= Module['stdout'];
|
|
5695
|
+
error ??= Module['stderr'];
|
|
5696
|
+
|
|
5697
|
+
FS.createStandardStreams(input, output, error);
|
|
5698
|
+
},
|
|
5699
|
+
quit() {
|
|
5700
|
+
FS.initialized = false;
|
|
5701
|
+
// force-flush all streams, so we get musl std streams printed out
|
|
5702
|
+
_fflush(0);
|
|
5703
|
+
// close all of our streams
|
|
5704
|
+
for (var stream of FS.streams) {
|
|
5705
|
+
if (stream) {
|
|
5706
|
+
FS.close(stream);
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5709
|
+
},
|
|
5710
|
+
findObject(path, dontResolveLastLink) {
|
|
5711
|
+
var ret = FS.analyzePath(path, dontResolveLastLink);
|
|
5712
|
+
if (!ret.exists) {
|
|
5713
|
+
return null;
|
|
5714
|
+
}
|
|
5715
|
+
return ret.object;
|
|
5716
|
+
},
|
|
5717
|
+
analyzePath(path, dontResolveLastLink) {
|
|
5718
|
+
// operate from within the context of the symlink's target
|
|
5719
|
+
try {
|
|
5720
|
+
var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
|
|
5721
|
+
path = lookup.path;
|
|
5722
|
+
} catch (e) {
|
|
5723
|
+
}
|
|
5724
|
+
var ret = {
|
|
5725
|
+
isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
|
|
5726
|
+
parentExists: false, parentPath: null, parentObject: null
|
|
5727
|
+
};
|
|
5728
|
+
try {
|
|
5729
|
+
var lookup = FS.lookupPath(path, { parent: true });
|
|
5730
|
+
ret.parentExists = true;
|
|
5731
|
+
ret.parentPath = lookup.path;
|
|
5732
|
+
ret.parentObject = lookup.node;
|
|
5733
|
+
ret.name = PATH.basename(path);
|
|
5734
|
+
lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
|
|
5735
|
+
ret.exists = true;
|
|
5736
|
+
ret.path = lookup.path;
|
|
5737
|
+
ret.object = lookup.node;
|
|
5738
|
+
ret.name = lookup.node.name;
|
|
5739
|
+
ret.isRoot = lookup.path === '/';
|
|
5740
|
+
} catch (e) {
|
|
5741
|
+
ret.error = e.errno;
|
|
5742
|
+
};
|
|
5743
|
+
return ret;
|
|
5744
|
+
},
|
|
5745
|
+
createPath(parent, path, canRead, canWrite) {
|
|
5746
|
+
parent = typeof parent == 'string' ? parent : FS.getPath(parent);
|
|
5747
|
+
var parts = path.split('/').reverse();
|
|
5748
|
+
while (parts.length) {
|
|
5749
|
+
var part = parts.pop();
|
|
5750
|
+
if (!part) continue;
|
|
5751
|
+
var current = PATH.join2(parent, part);
|
|
5752
|
+
try {
|
|
5753
|
+
FS.mkdir(current);
|
|
5754
|
+
} catch (e) {
|
|
5755
|
+
if (e.errno != 20) throw e;
|
|
5756
|
+
}
|
|
5757
|
+
parent = current;
|
|
5758
|
+
}
|
|
5759
|
+
return current;
|
|
5760
|
+
},
|
|
5761
|
+
createFile(parent, name, properties, canRead, canWrite) {
|
|
5762
|
+
var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name);
|
|
5763
|
+
var mode = FS_getMode(canRead, canWrite);
|
|
5764
|
+
return FS.create(path, mode);
|
|
5765
|
+
},
|
|
5766
|
+
createDataFile(parent, name, data, canRead, canWrite, canOwn) {
|
|
5767
|
+
var path = name;
|
|
5768
|
+
if (parent) {
|
|
5769
|
+
parent = typeof parent == 'string' ? parent : FS.getPath(parent);
|
|
5770
|
+
path = name ? PATH.join2(parent, name) : parent;
|
|
5771
|
+
}
|
|
5772
|
+
var mode = FS_getMode(canRead, canWrite);
|
|
5773
|
+
var node = FS.create(path, mode);
|
|
5774
|
+
if (data) {
|
|
5775
|
+
if (typeof data == 'string') {
|
|
5776
|
+
var arr = new Array(data.length);
|
|
5777
|
+
for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
|
|
5778
|
+
data = arr;
|
|
5779
|
+
}
|
|
5780
|
+
// make sure we can write to the file
|
|
5781
|
+
FS.chmod(node, mode | 146);
|
|
5782
|
+
var stream = FS.open(node, 577);
|
|
5783
|
+
FS.write(stream, data, 0, data.length, 0, canOwn);
|
|
5784
|
+
FS.close(stream);
|
|
5785
|
+
FS.chmod(node, mode);
|
|
5786
|
+
}
|
|
5787
|
+
},
|
|
5788
|
+
createDevice(parent, name, input, output) {
|
|
5789
|
+
var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name);
|
|
5790
|
+
var mode = FS_getMode(!!input, !!output);
|
|
5791
|
+
FS.createDevice.major ??= 64;
|
|
5792
|
+
var dev = FS.makedev(FS.createDevice.major++, 0);
|
|
5793
|
+
// Create a fake device that a set of stream ops to emulate
|
|
5794
|
+
// the old behavior.
|
|
5795
|
+
FS.registerDevice(dev, {
|
|
5796
|
+
open(stream) {
|
|
5797
|
+
stream.seekable = false;
|
|
5798
|
+
},
|
|
5799
|
+
close(stream) {
|
|
5800
|
+
// flush any pending line data
|
|
5801
|
+
if (output?.buffer?.length) {
|
|
5802
|
+
output(10);
|
|
5803
|
+
}
|
|
5804
|
+
},
|
|
5805
|
+
read(stream, buffer, offset, length, pos /* ignored */) {
|
|
5806
|
+
var bytesRead = 0;
|
|
5807
|
+
for (var i = 0; i < length; i++) {
|
|
5808
|
+
var result;
|
|
5809
|
+
try {
|
|
5810
|
+
result = input();
|
|
5811
|
+
} catch (e) {
|
|
5812
|
+
throw new FS.ErrnoError(29);
|
|
5813
|
+
}
|
|
5814
|
+
if (result === undefined && bytesRead === 0) {
|
|
5815
|
+
throw new FS.ErrnoError(6);
|
|
5816
|
+
}
|
|
5817
|
+
if (result === null || result === undefined) break;
|
|
5818
|
+
bytesRead++;
|
|
5819
|
+
buffer[offset+i] = result;
|
|
5820
|
+
}
|
|
5821
|
+
if (bytesRead) {
|
|
5822
|
+
stream.node.atime = Date.now();
|
|
5823
|
+
}
|
|
5824
|
+
return bytesRead;
|
|
5825
|
+
},
|
|
5826
|
+
write(stream, buffer, offset, length, pos) {
|
|
5827
|
+
for (var i = 0; i < length; i++) {
|
|
5828
|
+
try {
|
|
5829
|
+
output(buffer[offset+i]);
|
|
5830
|
+
} catch (e) {
|
|
5831
|
+
throw new FS.ErrnoError(29);
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
if (length) {
|
|
5835
|
+
stream.node.mtime = stream.node.ctime = Date.now();
|
|
5836
|
+
}
|
|
5837
|
+
return i;
|
|
5838
|
+
}
|
|
5839
|
+
});
|
|
5840
|
+
return FS.mkdev(path, mode, dev);
|
|
5841
|
+
},
|
|
5842
|
+
forceLoadFile(obj) {
|
|
5843
|
+
if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
|
|
5844
|
+
if (typeof XMLHttpRequest != 'undefined') {
|
|
5845
|
+
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.");
|
|
5846
|
+
} else { // Command-line.
|
|
5847
|
+
try {
|
|
5848
|
+
obj.contents = readBinary(obj.url);
|
|
5849
|
+
obj.usedBytes = obj.contents.length;
|
|
5850
|
+
} catch (e) {
|
|
5851
|
+
throw new FS.ErrnoError(29);
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
},
|
|
5855
|
+
createLazyFile(parent, name, url, canRead, canWrite) {
|
|
5856
|
+
// Lazy chunked Uint8Array (implements get and length from Uint8Array).
|
|
5857
|
+
// Actual getting is abstracted away for eventual reuse.
|
|
5858
|
+
class LazyUint8Array {
|
|
5859
|
+
lengthKnown = false;
|
|
5860
|
+
chunks = []; // Loaded chunks. Index is the chunk number
|
|
5861
|
+
get(idx) {
|
|
5862
|
+
if (idx > this.length-1 || idx < 0) {
|
|
5863
|
+
return undefined;
|
|
5864
|
+
}
|
|
5865
|
+
var chunkOffset = idx % this.chunkSize;
|
|
5866
|
+
var chunkNum = (idx / this.chunkSize)|0;
|
|
5867
|
+
return this.getter(chunkNum)[chunkOffset];
|
|
5868
|
+
}
|
|
5869
|
+
setDataGetter(getter) {
|
|
5870
|
+
this.getter = getter;
|
|
5871
|
+
}
|
|
5872
|
+
cacheLength() {
|
|
5873
|
+
// Find length
|
|
5874
|
+
var xhr = new XMLHttpRequest();
|
|
5875
|
+
xhr.open('HEAD', url, false);
|
|
5876
|
+
xhr.send(null);
|
|
5877
|
+
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
|
|
5878
|
+
var datalength = Number(xhr.getResponseHeader("Content-length"));
|
|
5879
|
+
var header;
|
|
5880
|
+
var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
|
|
5881
|
+
var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
|
|
5882
|
+
|
|
5883
|
+
var chunkSize = 1024*1024; // Chunk size in bytes
|
|
5884
|
+
|
|
5885
|
+
if (!hasByteServing) chunkSize = datalength;
|
|
5886
|
+
|
|
5887
|
+
// Function to get a range from the remote URL.
|
|
5888
|
+
var doXHR = (from, to) => {
|
|
5889
|
+
if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
|
|
5890
|
+
if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
|
|
5891
|
+
|
|
5892
|
+
// TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
|
|
5893
|
+
var xhr = new XMLHttpRequest();
|
|
5894
|
+
xhr.open('GET', url, false);
|
|
5895
|
+
if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
|
|
5896
|
+
|
|
5897
|
+
// Some hints to the browser that we want binary data.
|
|
5898
|
+
xhr.responseType = 'arraybuffer';
|
|
5899
|
+
if (xhr.overrideMimeType) {
|
|
5900
|
+
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
|
5901
|
+
}
|
|
5902
|
+
|
|
5903
|
+
xhr.send(null);
|
|
5904
|
+
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
|
|
5905
|
+
if (xhr.response !== undefined) {
|
|
5906
|
+
return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
|
|
5907
|
+
}
|
|
5908
|
+
return intArrayFromString(xhr.responseText || '', true);
|
|
5909
|
+
};
|
|
5910
|
+
var lazyArray = this;
|
|
5911
|
+
lazyArray.setDataGetter((chunkNum) => {
|
|
5912
|
+
var start = chunkNum * chunkSize;
|
|
5913
|
+
var end = (chunkNum+1) * chunkSize - 1; // including this byte
|
|
5914
|
+
end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
|
|
5915
|
+
if (typeof lazyArray.chunks[chunkNum] == 'undefined') {
|
|
5916
|
+
lazyArray.chunks[chunkNum] = doXHR(start, end);
|
|
5917
|
+
}
|
|
5918
|
+
if (typeof lazyArray.chunks[chunkNum] == 'undefined') throw new Error('doXHR failed!');
|
|
5919
|
+
return lazyArray.chunks[chunkNum];
|
|
5920
|
+
});
|
|
5921
|
+
|
|
5922
|
+
if (usesGzip || !datalength) {
|
|
5923
|
+
// if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length
|
|
5924
|
+
chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
|
|
5925
|
+
datalength = this.getter(0).length;
|
|
5926
|
+
chunkSize = datalength;
|
|
5927
|
+
out("LazyFiles on gzip forces download of the whole file when length is accessed");
|
|
5928
|
+
}
|
|
5929
|
+
|
|
5930
|
+
this._length = datalength;
|
|
5931
|
+
this._chunkSize = chunkSize;
|
|
5932
|
+
this.lengthKnown = true;
|
|
5933
|
+
}
|
|
5934
|
+
get length() {
|
|
5935
|
+
if (!this.lengthKnown) {
|
|
5936
|
+
this.cacheLength();
|
|
5937
|
+
}
|
|
5938
|
+
return this._length;
|
|
5939
|
+
}
|
|
5940
|
+
get chunkSize() {
|
|
5941
|
+
if (!this.lengthKnown) {
|
|
5942
|
+
this.cacheLength();
|
|
5943
|
+
}
|
|
5944
|
+
return this._chunkSize;
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
if (typeof XMLHttpRequest != 'undefined') {
|
|
5949
|
+
if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
|
|
5950
|
+
var lazyArray = new LazyUint8Array();
|
|
5951
|
+
var properties = { isDevice: false, contents: lazyArray };
|
|
5952
|
+
} else {
|
|
5953
|
+
var properties = { isDevice: false, url: url };
|
|
5954
|
+
}
|
|
5955
|
+
|
|
5956
|
+
var node = FS.createFile(parent, name, properties, canRead, canWrite);
|
|
5957
|
+
// This is a total hack, but I want to get this lazy file code out of the
|
|
5958
|
+
// core of MEMFS. If we want to keep this lazy file concept I feel it should
|
|
5959
|
+
// be its own thin LAZYFS proxying calls to MEMFS.
|
|
5960
|
+
if (properties.contents) {
|
|
5961
|
+
node.contents = properties.contents;
|
|
5962
|
+
} else if (properties.url) {
|
|
5963
|
+
node.contents = null;
|
|
5964
|
+
node.url = properties.url;
|
|
5965
|
+
}
|
|
5966
|
+
// Add a function that defers querying the file size until it is asked the first time.
|
|
5967
|
+
Object.defineProperties(node, {
|
|
5968
|
+
usedBytes: {
|
|
5969
|
+
get: function() { return this.contents.length; }
|
|
5970
|
+
}
|
|
5971
|
+
});
|
|
5972
|
+
// override each stream op with one that tries to force load the lazy file first
|
|
5973
|
+
var stream_ops = {};
|
|
5974
|
+
var keys = Object.keys(node.stream_ops);
|
|
5975
|
+
keys.forEach((key) => {
|
|
5976
|
+
var fn = node.stream_ops[key];
|
|
5977
|
+
stream_ops[key] = (...args) => {
|
|
5978
|
+
FS.forceLoadFile(node);
|
|
5979
|
+
return fn(...args);
|
|
5980
|
+
};
|
|
5981
|
+
});
|
|
5982
|
+
function writeChunks(stream, buffer, offset, length, position) {
|
|
5983
|
+
var contents = stream.node.contents;
|
|
5984
|
+
if (position >= contents.length)
|
|
5985
|
+
return 0;
|
|
5986
|
+
var size = Math.min(contents.length - position, length);
|
|
5987
|
+
assert(size >= 0);
|
|
5988
|
+
if (contents.slice) { // normal array
|
|
5989
|
+
for (var i = 0; i < size; i++) {
|
|
5990
|
+
buffer[offset + i] = contents[position + i];
|
|
5991
|
+
}
|
|
5992
|
+
} else {
|
|
5993
|
+
for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
|
|
5994
|
+
buffer[offset + i] = contents.get(position + i);
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
return size;
|
|
5998
|
+
}
|
|
5999
|
+
// use a custom read function
|
|
6000
|
+
stream_ops.read = (stream, buffer, offset, length, position) => {
|
|
6001
|
+
FS.forceLoadFile(node);
|
|
6002
|
+
return writeChunks(stream, buffer, offset, length, position)
|
|
6003
|
+
};
|
|
6004
|
+
// use a custom mmap function
|
|
6005
|
+
stream_ops.mmap = (stream, length, position, prot, flags) => {
|
|
6006
|
+
FS.forceLoadFile(node);
|
|
6007
|
+
var ptr = mmapAlloc(length);
|
|
6008
|
+
if (!ptr) {
|
|
6009
|
+
throw new FS.ErrnoError(48);
|
|
6010
|
+
}
|
|
6011
|
+
writeChunks(stream, HEAP8, ptr, length, position);
|
|
6012
|
+
return { ptr, allocated: true };
|
|
6013
|
+
};
|
|
6014
|
+
node.stream_ops = stream_ops;
|
|
6015
|
+
return node;
|
|
6016
|
+
},
|
|
6017
|
+
absolutePath() {
|
|
6018
|
+
abort('FS.absolutePath has been removed; use PATH_FS.resolve instead');
|
|
6019
|
+
},
|
|
6020
|
+
createFolder() {
|
|
6021
|
+
abort('FS.createFolder has been removed; use FS.mkdir instead');
|
|
6022
|
+
},
|
|
6023
|
+
createLink() {
|
|
6024
|
+
abort('FS.createLink has been removed; use FS.symlink instead');
|
|
6025
|
+
},
|
|
6026
|
+
joinPath() {
|
|
6027
|
+
abort('FS.joinPath has been removed; use PATH.join instead');
|
|
6028
|
+
},
|
|
6029
|
+
mmapAlloc() {
|
|
6030
|
+
abort('FS.mmapAlloc has been replaced by the top level function mmapAlloc');
|
|
6031
|
+
},
|
|
6032
|
+
standardizePath() {
|
|
6033
|
+
abort('FS.standardizePath has been removed; use PATH.normalize instead');
|
|
6034
|
+
},
|
|
6035
|
+
};
|
|
6036
|
+
|
|
6037
|
+
var SYSCALLS = {
|
|
6038
|
+
DEFAULT_POLLMASK:5,
|
|
6039
|
+
calculateAt(dirfd, path, allowEmpty) {
|
|
6040
|
+
if (PATH.isAbs(path)) {
|
|
6041
|
+
return path;
|
|
6042
|
+
}
|
|
6043
|
+
// relative path
|
|
6044
|
+
var dir;
|
|
6045
|
+
if (dirfd === -100) {
|
|
6046
|
+
dir = FS.cwd();
|
|
6047
|
+
} else {
|
|
6048
|
+
var dirstream = SYSCALLS.getStreamFromFD(dirfd);
|
|
6049
|
+
dir = dirstream.path;
|
|
6050
|
+
}
|
|
6051
|
+
if (path.length == 0) {
|
|
6052
|
+
if (!allowEmpty) {
|
|
6053
|
+
throw new FS.ErrnoError(44);;
|
|
6054
|
+
}
|
|
6055
|
+
return dir;
|
|
6056
|
+
}
|
|
6057
|
+
return dir + '/' + path;
|
|
6058
|
+
},
|
|
6059
|
+
writeStat(buf, stat) {
|
|
6060
|
+
HEAPU32[((buf)>>2)] = stat.dev;
|
|
6061
|
+
HEAPU32[(((buf)+(4))>>2)] = stat.mode;
|
|
6062
|
+
HEAPU32[(((buf)+(8))>>2)] = stat.nlink;
|
|
6063
|
+
HEAPU32[(((buf)+(12))>>2)] = stat.uid;
|
|
6064
|
+
HEAPU32[(((buf)+(16))>>2)] = stat.gid;
|
|
6065
|
+
HEAPU32[(((buf)+(20))>>2)] = stat.rdev;
|
|
6066
|
+
(tempI64 = [stat.size>>>0,(tempDouble = stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);
|
|
6067
|
+
HEAP32[(((buf)+(32))>>2)] = 4096;
|
|
6068
|
+
HEAP32[(((buf)+(36))>>2)] = stat.blocks;
|
|
6069
|
+
var atime = stat.atime.getTime();
|
|
6070
|
+
var mtime = stat.mtime.getTime();
|
|
6071
|
+
var ctime = stat.ctime.getTime();
|
|
6072
|
+
(tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble = Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
|
|
6073
|
+
HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000 * 1000;
|
|
6074
|
+
(tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble = Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);
|
|
6075
|
+
HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000 * 1000;
|
|
6076
|
+
(tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble = Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);
|
|
6077
|
+
HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000 * 1000;
|
|
6078
|
+
(tempI64 = [stat.ino>>>0,(tempDouble = stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);
|
|
6079
|
+
return 0;
|
|
6080
|
+
},
|
|
6081
|
+
writeStatFs(buf, stats) {
|
|
6082
|
+
HEAPU32[(((buf)+(4))>>2)] = stats.bsize;
|
|
6083
|
+
HEAPU32[(((buf)+(60))>>2)] = stats.bsize;
|
|
6084
|
+
(tempI64 = [stats.blocks>>>0,(tempDouble = stats.blocks,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(8))>>2)] = tempI64[0],HEAP32[(((buf)+(12))>>2)] = tempI64[1]);
|
|
6085
|
+
(tempI64 = [stats.bfree>>>0,(tempDouble = stats.bfree,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(16))>>2)] = tempI64[0],HEAP32[(((buf)+(20))>>2)] = tempI64[1]);
|
|
6086
|
+
(tempI64 = [stats.bavail>>>0,(tempDouble = stats.bavail,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);
|
|
6087
|
+
(tempI64 = [stats.files>>>0,(tempDouble = stats.files,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(32))>>2)] = tempI64[0],HEAP32[(((buf)+(36))>>2)] = tempI64[1]);
|
|
6088
|
+
(tempI64 = [stats.ffree>>>0,(tempDouble = stats.ffree,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
|
|
6089
|
+
HEAPU32[(((buf)+(48))>>2)] = stats.fsid;
|
|
6090
|
+
HEAPU32[(((buf)+(64))>>2)] = stats.flags; // ST_NOSUID
|
|
6091
|
+
HEAPU32[(((buf)+(56))>>2)] = stats.namelen;
|
|
6092
|
+
},
|
|
6093
|
+
doMsync(addr, stream, len, flags, offset) {
|
|
6094
|
+
if (!FS.isFile(stream.node.mode)) {
|
|
6095
|
+
throw new FS.ErrnoError(43);
|
|
6096
|
+
}
|
|
6097
|
+
if (flags & 2) {
|
|
6098
|
+
// MAP_PRIVATE calls need not to be synced back to underlying fs
|
|
6099
|
+
return 0;
|
|
6100
|
+
}
|
|
6101
|
+
var buffer = HEAPU8.slice(addr, addr + len);
|
|
6102
|
+
FS.msync(stream, buffer, offset, len, flags);
|
|
6103
|
+
},
|
|
6104
|
+
getStreamFromFD(fd) {
|
|
6105
|
+
var stream = FS.getStreamChecked(fd);
|
|
6106
|
+
return stream;
|
|
6107
|
+
},
|
|
6108
|
+
varargs:undefined,
|
|
6109
|
+
getStr(ptr) {
|
|
6110
|
+
var ret = UTF8ToString(ptr);
|
|
6111
|
+
return ret;
|
|
6112
|
+
},
|
|
6113
|
+
};
|
|
6114
|
+
function _fd_close(fd) {
|
|
6115
|
+
try {
|
|
6116
|
+
|
|
6117
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
6118
|
+
FS.close(stream);
|
|
6119
|
+
return 0;
|
|
6120
|
+
} catch (e) {
|
|
6121
|
+
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
6122
|
+
return e.errno;
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
|
|
6126
|
+
/** @param {number=} offset */
|
|
6127
|
+
var doReadv = (stream, iov, iovcnt, offset) => {
|
|
6128
|
+
var ret = 0;
|
|
6129
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
6130
|
+
var ptr = HEAPU32[((iov)>>2)];
|
|
6131
|
+
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
6132
|
+
iov += 8;
|
|
6133
|
+
var curr = FS.read(stream, HEAP8, ptr, len, offset);
|
|
6134
|
+
if (curr < 0) return -1;
|
|
6135
|
+
ret += curr;
|
|
6136
|
+
if (curr < len) break; // nothing more to read
|
|
6137
|
+
if (typeof offset != 'undefined') {
|
|
6138
|
+
offset += curr;
|
|
6139
|
+
}
|
|
6140
|
+
}
|
|
6141
|
+
return ret;
|
|
6142
|
+
};
|
|
6143
|
+
|
|
6144
|
+
function _fd_read(fd, iov, iovcnt, pnum) {
|
|
6145
|
+
try {
|
|
6146
|
+
|
|
6147
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
6148
|
+
var num = doReadv(stream, iov, iovcnt);
|
|
6149
|
+
HEAPU32[((pnum)>>2)] = num;
|
|
6150
|
+
return 0;
|
|
6151
|
+
} catch (e) {
|
|
6152
|
+
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
6153
|
+
return e.errno;
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
6156
|
+
|
|
6157
|
+
|
|
6158
|
+
var convertI32PairToI53Checked = (lo, hi) => {
|
|
6159
|
+
assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
|
|
6160
|
+
assert(hi === (hi|0)); // hi should be a i32
|
|
6161
|
+
return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
|
|
6162
|
+
};
|
|
6163
|
+
function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
|
|
6164
|
+
var offset = convertI32PairToI53Checked(offset_low, offset_high);
|
|
6165
|
+
|
|
6166
|
+
|
|
6167
|
+
try {
|
|
6168
|
+
|
|
6169
|
+
if (isNaN(offset)) return 61;
|
|
6170
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
6171
|
+
FS.llseek(stream, offset, whence);
|
|
6172
|
+
(tempI64 = [stream.position>>>0,(tempDouble = stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);
|
|
6173
|
+
if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
|
|
6174
|
+
return 0;
|
|
6175
|
+
} catch (e) {
|
|
6176
|
+
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
6177
|
+
return e.errno;
|
|
6178
|
+
}
|
|
6179
|
+
;
|
|
6180
|
+
}
|
|
6181
|
+
|
|
6182
|
+
/** @param {number=} offset */
|
|
6183
|
+
var doWritev = (stream, iov, iovcnt, offset) => {
|
|
6184
|
+
var ret = 0;
|
|
6185
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
6186
|
+
var ptr = HEAPU32[((iov)>>2)];
|
|
6187
|
+
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
6188
|
+
iov += 8;
|
|
6189
|
+
var curr = FS.write(stream, HEAP8, ptr, len, offset);
|
|
6190
|
+
if (curr < 0) return -1;
|
|
6191
|
+
ret += curr;
|
|
6192
|
+
if (curr < len) {
|
|
6193
|
+
// No more space to write.
|
|
6194
|
+
break;
|
|
6195
|
+
}
|
|
6196
|
+
if (typeof offset != 'undefined') {
|
|
6197
|
+
offset += curr;
|
|
6198
|
+
}
|
|
6199
|
+
}
|
|
6200
|
+
return ret;
|
|
6201
|
+
};
|
|
6202
|
+
|
|
6203
|
+
function _fd_write(fd, iov, iovcnt, pnum) {
|
|
6204
|
+
try {
|
|
6205
|
+
|
|
6206
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
6207
|
+
var num = doWritev(stream, iov, iovcnt);
|
|
6208
|
+
HEAPU32[((pnum)>>2)] = num;
|
|
6209
|
+
return 0;
|
|
6210
|
+
} catch (e) {
|
|
6211
|
+
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
6212
|
+
return e.errno;
|
|
6213
|
+
}
|
|
6214
|
+
}
|
|
6215
|
+
|
|
6216
|
+
|
|
6217
|
+
var incrementExceptionRefcount = (ptr) => ___cxa_increment_exception_refcount(ptr);
|
|
6218
|
+
|
|
6219
|
+
var decrementExceptionRefcount = (ptr) => ___cxa_decrement_exception_refcount(ptr);
|
|
6220
|
+
|
|
6221
|
+
|
|
6222
|
+
|
|
6223
|
+
|
|
6224
|
+
|
|
6225
|
+
var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
|
|
6226
|
+
|
|
6227
|
+
var getExceptionMessageCommon = (ptr) => {
|
|
6228
|
+
var sp = stackSave();
|
|
6229
|
+
var type_addr_addr = stackAlloc(4);
|
|
6230
|
+
var message_addr_addr = stackAlloc(4);
|
|
6231
|
+
___get_exception_message(ptr, type_addr_addr, message_addr_addr);
|
|
6232
|
+
var type_addr = HEAPU32[((type_addr_addr)>>2)];
|
|
6233
|
+
var message_addr = HEAPU32[((message_addr_addr)>>2)];
|
|
6234
|
+
var type = UTF8ToString(type_addr);
|
|
6235
|
+
_free(type_addr);
|
|
3342
6236
|
var message;
|
|
3343
6237
|
if (message_addr) {
|
|
3344
6238
|
message = UTF8ToString(message_addr);
|
|
@@ -3351,6 +6245,10 @@ var tempI64;
|
|
|
3351
6245
|
init_ClassHandle();
|
|
3352
6246
|
init_RegisteredPointer();
|
|
3353
6247
|
assert(emval_handles.length === 5 * 2);
|
|
6248
|
+
|
|
6249
|
+
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
6250
|
+
FS.preloadFile = FS_preloadFile;
|
|
6251
|
+
FS.staticInit();;
|
|
3354
6252
|
// End JS library code
|
|
3355
6253
|
|
|
3356
6254
|
// include: postlibrary.js
|
|
@@ -3361,13 +6259,10 @@ assert(emval_handles.length === 5 * 2);
|
|
|
3361
6259
|
|
|
3362
6260
|
// Begin ATMODULES hooks
|
|
3363
6261
|
if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];
|
|
6262
|
+
if (Module['preloadPlugins']) preloadPlugins = Module['preloadPlugins'];
|
|
3364
6263
|
if (Module['print']) out = Module['print'];
|
|
3365
6264
|
if (Module['printErr']) err = Module['printErr'];
|
|
3366
6265
|
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
3367
|
-
|
|
3368
|
-
Module['FS_createDataFile'] = FS.createDataFile;
|
|
3369
|
-
Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
3370
|
-
|
|
3371
6266
|
// End ATMODULES hooks
|
|
3372
6267
|
|
|
3373
6268
|
checkIncomingModuleAPI();
|
|
@@ -3408,7 +6303,6 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3408
6303
|
'zeroMemory',
|
|
3409
6304
|
'exitJS',
|
|
3410
6305
|
'withStackSave',
|
|
3411
|
-
'strError',
|
|
3412
6306
|
'inetPton4',
|
|
3413
6307
|
'inetNtop4',
|
|
3414
6308
|
'inetPton6',
|
|
@@ -3417,7 +6311,6 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3417
6311
|
'writeSockaddr',
|
|
3418
6312
|
'readEmAsmArgs',
|
|
3419
6313
|
'jstoi_q',
|
|
3420
|
-
'getExecutableName',
|
|
3421
6314
|
'autoResumeAudioContext',
|
|
3422
6315
|
'handleException',
|
|
3423
6316
|
'keepRuntimeAlive',
|
|
@@ -3425,12 +6318,9 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3425
6318
|
'runtimeKeepalivePop',
|
|
3426
6319
|
'callUserCallback',
|
|
3427
6320
|
'maybeExit',
|
|
3428
|
-
'asyncLoad',
|
|
3429
6321
|
'asmjsMangle',
|
|
3430
|
-
'mmapAlloc',
|
|
3431
6322
|
'HandleAllocator',
|
|
3432
6323
|
'getNativeTypeSize',
|
|
3433
|
-
'getUniqueRunDependency',
|
|
3434
6324
|
'addOnInit',
|
|
3435
6325
|
'addOnPostCtor',
|
|
3436
6326
|
'addOnPreMain',
|
|
@@ -3447,7 +6337,6 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3447
6337
|
'getFunctionAddress',
|
|
3448
6338
|
'addFunction',
|
|
3449
6339
|
'removeFunction',
|
|
3450
|
-
'intArrayFromString',
|
|
3451
6340
|
'intArrayToString',
|
|
3452
6341
|
'stringToAscii',
|
|
3453
6342
|
'stringToNewUTF8',
|
|
@@ -3496,12 +6385,9 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3496
6385
|
'jsStackTrace',
|
|
3497
6386
|
'getCallstack',
|
|
3498
6387
|
'convertPCtoSourceLocation',
|
|
3499
|
-
'getEnvStrings',
|
|
3500
6388
|
'checkWasiClock',
|
|
3501
6389
|
'wasiRightsToMuslOFlags',
|
|
3502
6390
|
'wasiOFlagsToMuslOFlags',
|
|
3503
|
-
'initRandomFill',
|
|
3504
|
-
'randomFill',
|
|
3505
6391
|
'safeSetTimeout',
|
|
3506
6392
|
'setImmediateWrapped',
|
|
3507
6393
|
'safeRequestAnimationFrame',
|
|
@@ -3519,11 +6405,6 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3519
6405
|
'addDays',
|
|
3520
6406
|
'getSocketFromFD',
|
|
3521
6407
|
'getSocketAddress',
|
|
3522
|
-
'FS_createPreloadedFile',
|
|
3523
|
-
'FS_preloadFile',
|
|
3524
|
-
'FS_modeStringToFlags',
|
|
3525
|
-
'FS_getMode',
|
|
3526
|
-
'FS_stdin_getChar',
|
|
3527
6408
|
'FS_mkdirTree',
|
|
3528
6409
|
'_setNetworkCallback',
|
|
3529
6410
|
'heapObjectForWebGLType',
|
|
@@ -3600,17 +6481,22 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
3600
6481
|
'growMemory',
|
|
3601
6482
|
'ENV',
|
|
3602
6483
|
'ERRNO_CODES',
|
|
6484
|
+
'strError',
|
|
3603
6485
|
'DNS',
|
|
3604
6486
|
'Protocols',
|
|
3605
6487
|
'Sockets',
|
|
3606
6488
|
'timers',
|
|
3607
6489
|
'warnOnce',
|
|
3608
6490
|
'readEmAsmArgsArray',
|
|
6491
|
+
'getExecutableName',
|
|
3609
6492
|
'dynCallLegacy',
|
|
3610
6493
|
'getDynCaller',
|
|
3611
6494
|
'dynCall',
|
|
6495
|
+
'asyncLoad',
|
|
3612
6496
|
'alignMemory',
|
|
6497
|
+
'mmapAlloc',
|
|
3613
6498
|
'wasmTable',
|
|
6499
|
+
'getUniqueRunDependency',
|
|
3614
6500
|
'noExitRuntime',
|
|
3615
6501
|
'addOnPreRun',
|
|
3616
6502
|
'addOnPostRun',
|
|
@@ -3626,6 +6512,7 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
3626
6512
|
'stringToUTF8Array',
|
|
3627
6513
|
'stringToUTF8',
|
|
3628
6514
|
'lengthBytesUTF8',
|
|
6515
|
+
'intArrayFromString',
|
|
3629
6516
|
'AsciiToString',
|
|
3630
6517
|
'UTF16Decoder',
|
|
3631
6518
|
'UTF16ToString',
|
|
@@ -3641,7 +6528,11 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
3641
6528
|
'restoreOldWindowedStyle',
|
|
3642
6529
|
'UNWIND_CACHE',
|
|
3643
6530
|
'ExitStatus',
|
|
3644
|
-
'
|
|
6531
|
+
'getEnvStrings',
|
|
6532
|
+
'doReadv',
|
|
6533
|
+
'doWritev',
|
|
6534
|
+
'initRandomFill',
|
|
6535
|
+
'randomFill',
|
|
3645
6536
|
'emSetImmediate',
|
|
3646
6537
|
'emClearImmediate_deps',
|
|
3647
6538
|
'emClearImmediate',
|
|
@@ -3666,7 +6557,12 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
3666
6557
|
'MONTH_DAYS_LEAP_CUMULATIVE',
|
|
3667
6558
|
'SYSCALLS',
|
|
3668
6559
|
'preloadPlugins',
|
|
6560
|
+
'FS_createPreloadedFile',
|
|
6561
|
+
'FS_preloadFile',
|
|
6562
|
+
'FS_modeStringToFlags',
|
|
6563
|
+
'FS_getMode',
|
|
3669
6564
|
'FS_stdin_getChar_buffer',
|
|
6565
|
+
'FS_stdin_getChar',
|
|
3670
6566
|
'FS_unlink',
|
|
3671
6567
|
'FS_createPath',
|
|
3672
6568
|
'FS_createDevice',
|
|
@@ -3921,6 +6817,11 @@ var ___cxa_get_exception_ptr = makeInvalidEarlyAccess('___cxa_get_exception_ptr'
|
|
|
3921
6817
|
var dynCall_jii = makeInvalidEarlyAccess('dynCall_jii');
|
|
3922
6818
|
var dynCall_viij = makeInvalidEarlyAccess('dynCall_viij');
|
|
3923
6819
|
var dynCall_jiji = makeInvalidEarlyAccess('dynCall_jiji');
|
|
6820
|
+
var dynCall_viijii = makeInvalidEarlyAccess('dynCall_viijii');
|
|
6821
|
+
var dynCall_jiiii = makeInvalidEarlyAccess('dynCall_jiiii');
|
|
6822
|
+
var dynCall_iiiiij = makeInvalidEarlyAccess('dynCall_iiiiij');
|
|
6823
|
+
var dynCall_iiiiijj = makeInvalidEarlyAccess('dynCall_iiiiijj');
|
|
6824
|
+
var dynCall_iiiiiijj = makeInvalidEarlyAccess('dynCall_iiiiiijj');
|
|
3924
6825
|
|
|
3925
6826
|
function assignWasmExports(wasmExports) {
|
|
3926
6827
|
___getTypeName = createExportWrapper('__getTypeName', 1);
|
|
@@ -3946,6 +6847,11 @@ function assignWasmExports(wasmExports) {
|
|
|
3946
6847
|
dynCalls['jii'] = dynCall_jii = createExportWrapper('dynCall_jii', 3);
|
|
3947
6848
|
dynCalls['viij'] = dynCall_viij = createExportWrapper('dynCall_viij', 5);
|
|
3948
6849
|
dynCalls['jiji'] = dynCall_jiji = createExportWrapper('dynCall_jiji', 5);
|
|
6850
|
+
dynCalls['viijii'] = dynCall_viijii = createExportWrapper('dynCall_viijii', 7);
|
|
6851
|
+
dynCalls['jiiii'] = dynCall_jiiii = createExportWrapper('dynCall_jiiii', 5);
|
|
6852
|
+
dynCalls['iiiiij'] = dynCall_iiiiij = createExportWrapper('dynCall_iiiiij', 7);
|
|
6853
|
+
dynCalls['iiiiijj'] = dynCall_iiiiijj = createExportWrapper('dynCall_iiiiijj', 9);
|
|
6854
|
+
dynCalls['iiiiiijj'] = dynCall_iiiiiijj = createExportWrapper('dynCall_iiiiiijj', 10);
|
|
3949
6855
|
}
|
|
3950
6856
|
var wasmImports = {
|
|
3951
6857
|
/** @export */
|
|
@@ -3953,16 +6859,24 @@ var wasmImports = {
|
|
|
3953
6859
|
/** @export */
|
|
3954
6860
|
__cxa_begin_catch: ___cxa_begin_catch,
|
|
3955
6861
|
/** @export */
|
|
6862
|
+
__cxa_end_catch: ___cxa_end_catch,
|
|
6863
|
+
/** @export */
|
|
3956
6864
|
__cxa_find_matching_catch_2: ___cxa_find_matching_catch_2,
|
|
3957
6865
|
/** @export */
|
|
3958
6866
|
__cxa_find_matching_catch_3: ___cxa_find_matching_catch_3,
|
|
3959
6867
|
/** @export */
|
|
6868
|
+
__cxa_rethrow: ___cxa_rethrow,
|
|
6869
|
+
/** @export */
|
|
3960
6870
|
__cxa_throw: ___cxa_throw,
|
|
3961
6871
|
/** @export */
|
|
6872
|
+
__cxa_uncaught_exceptions: ___cxa_uncaught_exceptions,
|
|
6873
|
+
/** @export */
|
|
3962
6874
|
__resumeException: ___resumeException,
|
|
3963
6875
|
/** @export */
|
|
3964
6876
|
_abort_js: __abort_js,
|
|
3965
6877
|
/** @export */
|
|
6878
|
+
_embind_finalize_value_object: __embind_finalize_value_object,
|
|
6879
|
+
/** @export */
|
|
3966
6880
|
_embind_register_bigint: __embind_register_bigint,
|
|
3967
6881
|
/** @export */
|
|
3968
6882
|
_embind_register_bool: __embind_register_bool,
|
|
@@ -3997,6 +6911,10 @@ var wasmImports = {
|
|
|
3997
6911
|
/** @export */
|
|
3998
6912
|
_embind_register_std_wstring: __embind_register_std_wstring,
|
|
3999
6913
|
/** @export */
|
|
6914
|
+
_embind_register_value_object: __embind_register_value_object,
|
|
6915
|
+
/** @export */
|
|
6916
|
+
_embind_register_value_object_field: __embind_register_value_object_field,
|
|
6917
|
+
/** @export */
|
|
4000
6918
|
_embind_register_void: __embind_register_void,
|
|
4001
6919
|
/** @export */
|
|
4002
6920
|
_emval_create_invoker: __emval_create_invoker,
|
|
@@ -4009,18 +6927,50 @@ var wasmImports = {
|
|
|
4009
6927
|
/** @export */
|
|
4010
6928
|
_emval_run_destructors: __emval_run_destructors,
|
|
4011
6929
|
/** @export */
|
|
6930
|
+
_tzset_js: __tzset_js,
|
|
6931
|
+
/** @export */
|
|
4012
6932
|
emscripten_resize_heap: _emscripten_resize_heap,
|
|
4013
6933
|
/** @export */
|
|
6934
|
+
environ_get: _environ_get,
|
|
6935
|
+
/** @export */
|
|
6936
|
+
environ_sizes_get: _environ_sizes_get,
|
|
6937
|
+
/** @export */
|
|
4014
6938
|
fd_close: _fd_close,
|
|
4015
6939
|
/** @export */
|
|
6940
|
+
fd_read: _fd_read,
|
|
6941
|
+
/** @export */
|
|
4016
6942
|
fd_seek: _fd_seek,
|
|
4017
6943
|
/** @export */
|
|
4018
6944
|
fd_write: _fd_write,
|
|
4019
6945
|
/** @export */
|
|
6946
|
+
invoke_diii,
|
|
6947
|
+
/** @export */
|
|
6948
|
+
invoke_fiii,
|
|
6949
|
+
/** @export */
|
|
6950
|
+
invoke_i,
|
|
6951
|
+
/** @export */
|
|
4020
6952
|
invoke_ii,
|
|
4021
6953
|
/** @export */
|
|
4022
6954
|
invoke_iii,
|
|
4023
6955
|
/** @export */
|
|
6956
|
+
invoke_iiii,
|
|
6957
|
+
/** @export */
|
|
6958
|
+
invoke_iiiii,
|
|
6959
|
+
/** @export */
|
|
6960
|
+
invoke_iiiiii,
|
|
6961
|
+
/** @export */
|
|
6962
|
+
invoke_iiiiiii,
|
|
6963
|
+
/** @export */
|
|
6964
|
+
invoke_iiiiiiii,
|
|
6965
|
+
/** @export */
|
|
6966
|
+
invoke_iiiiiiiiiii,
|
|
6967
|
+
/** @export */
|
|
6968
|
+
invoke_iiiiiiiiiiii,
|
|
6969
|
+
/** @export */
|
|
6970
|
+
invoke_iiiiiiiiiiiii,
|
|
6971
|
+
/** @export */
|
|
6972
|
+
invoke_jiiii,
|
|
6973
|
+
/** @export */
|
|
4024
6974
|
invoke_v,
|
|
4025
6975
|
/** @export */
|
|
4026
6976
|
invoke_vi,
|
|
@@ -4029,7 +6979,13 @@ var wasmImports = {
|
|
|
4029
6979
|
/** @export */
|
|
4030
6980
|
invoke_viii,
|
|
4031
6981
|
/** @export */
|
|
4032
|
-
invoke_viiii
|
|
6982
|
+
invoke_viiii,
|
|
6983
|
+
/** @export */
|
|
6984
|
+
invoke_viiiiiii,
|
|
6985
|
+
/** @export */
|
|
6986
|
+
invoke_viiiiiiiiii,
|
|
6987
|
+
/** @export */
|
|
6988
|
+
invoke_viiiiiiiiiiiiiii
|
|
4033
6989
|
};
|
|
4034
6990
|
var wasmExports = await createWasm();
|
|
4035
6991
|
|
|
@@ -4088,6 +7044,28 @@ function invoke_v(index) {
|
|
|
4088
7044
|
}
|
|
4089
7045
|
}
|
|
4090
7046
|
|
|
7047
|
+
function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6) {
|
|
7048
|
+
var sp = stackSave();
|
|
7049
|
+
try {
|
|
7050
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6);
|
|
7051
|
+
} catch(e) {
|
|
7052
|
+
stackRestore(sp);
|
|
7053
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7054
|
+
_setThrew(1, 0);
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
|
|
7058
|
+
function invoke_iiii(index,a1,a2,a3) {
|
|
7059
|
+
var sp = stackSave();
|
|
7060
|
+
try {
|
|
7061
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
7062
|
+
} catch(e) {
|
|
7063
|
+
stackRestore(sp);
|
|
7064
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7065
|
+
_setThrew(1, 0);
|
|
7066
|
+
}
|
|
7067
|
+
}
|
|
7068
|
+
|
|
4091
7069
|
function invoke_viiii(index,a1,a2,a3,a4) {
|
|
4092
7070
|
var sp = stackSave();
|
|
4093
7071
|
try {
|
|
@@ -4099,6 +7077,17 @@ function invoke_viiii(index,a1,a2,a3,a4) {
|
|
|
4099
7077
|
}
|
|
4100
7078
|
}
|
|
4101
7079
|
|
|
7080
|
+
function invoke_iiiiii(index,a1,a2,a3,a4,a5) {
|
|
7081
|
+
var sp = stackSave();
|
|
7082
|
+
try {
|
|
7083
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5);
|
|
7084
|
+
} catch(e) {
|
|
7085
|
+
stackRestore(sp);
|
|
7086
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7087
|
+
_setThrew(1, 0);
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
7090
|
+
|
|
4102
7091
|
function invoke_viii(index,a1,a2,a3) {
|
|
4103
7092
|
var sp = stackSave();
|
|
4104
7093
|
try {
|
|
@@ -4110,6 +7099,138 @@ function invoke_viii(index,a1,a2,a3) {
|
|
|
4110
7099
|
}
|
|
4111
7100
|
}
|
|
4112
7101
|
|
|
7102
|
+
function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7) {
|
|
7103
|
+
var sp = stackSave();
|
|
7104
|
+
try {
|
|
7105
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7);
|
|
7106
|
+
} catch(e) {
|
|
7107
|
+
stackRestore(sp);
|
|
7108
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7109
|
+
_setThrew(1, 0);
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
|
|
7113
|
+
function invoke_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) {
|
|
7114
|
+
var sp = stackSave();
|
|
7115
|
+
try {
|
|
7116
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
|
|
7117
|
+
} catch(e) {
|
|
7118
|
+
stackRestore(sp);
|
|
7119
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7120
|
+
_setThrew(1, 0);
|
|
7121
|
+
}
|
|
7122
|
+
}
|
|
7123
|
+
|
|
7124
|
+
function invoke_iiiii(index,a1,a2,a3,a4) {
|
|
7125
|
+
var sp = stackSave();
|
|
7126
|
+
try {
|
|
7127
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4);
|
|
7128
|
+
} catch(e) {
|
|
7129
|
+
stackRestore(sp);
|
|
7130
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7131
|
+
_setThrew(1, 0);
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
|
|
7135
|
+
function invoke_iiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) {
|
|
7136
|
+
var sp = stackSave();
|
|
7137
|
+
try {
|
|
7138
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
|
|
7139
|
+
} catch(e) {
|
|
7140
|
+
stackRestore(sp);
|
|
7141
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7142
|
+
_setThrew(1, 0);
|
|
7143
|
+
}
|
|
7144
|
+
}
|
|
7145
|
+
|
|
7146
|
+
function invoke_fiii(index,a1,a2,a3) {
|
|
7147
|
+
var sp = stackSave();
|
|
7148
|
+
try {
|
|
7149
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
7150
|
+
} catch(e) {
|
|
7151
|
+
stackRestore(sp);
|
|
7152
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7153
|
+
_setThrew(1, 0);
|
|
7154
|
+
}
|
|
7155
|
+
}
|
|
7156
|
+
|
|
7157
|
+
function invoke_diii(index,a1,a2,a3) {
|
|
7158
|
+
var sp = stackSave();
|
|
7159
|
+
try {
|
|
7160
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
7161
|
+
} catch(e) {
|
|
7162
|
+
stackRestore(sp);
|
|
7163
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7164
|
+
_setThrew(1, 0);
|
|
7165
|
+
}
|
|
7166
|
+
}
|
|
7167
|
+
|
|
7168
|
+
function invoke_i(index) {
|
|
7169
|
+
var sp = stackSave();
|
|
7170
|
+
try {
|
|
7171
|
+
return getWasmTableEntry(index)();
|
|
7172
|
+
} catch(e) {
|
|
7173
|
+
stackRestore(sp);
|
|
7174
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7175
|
+
_setThrew(1, 0);
|
|
7176
|
+
}
|
|
7177
|
+
}
|
|
7178
|
+
|
|
7179
|
+
function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7) {
|
|
7180
|
+
var sp = stackSave();
|
|
7181
|
+
try {
|
|
7182
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7);
|
|
7183
|
+
} catch(e) {
|
|
7184
|
+
stackRestore(sp);
|
|
7185
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7186
|
+
_setThrew(1, 0);
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
|
|
7190
|
+
function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) {
|
|
7191
|
+
var sp = stackSave();
|
|
7192
|
+
try {
|
|
7193
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11);
|
|
7194
|
+
} catch(e) {
|
|
7195
|
+
stackRestore(sp);
|
|
7196
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7197
|
+
_setThrew(1, 0);
|
|
7198
|
+
}
|
|
7199
|
+
}
|
|
7200
|
+
|
|
7201
|
+
function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) {
|
|
7202
|
+
var sp = stackSave();
|
|
7203
|
+
try {
|
|
7204
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
|
|
7205
|
+
} catch(e) {
|
|
7206
|
+
stackRestore(sp);
|
|
7207
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7208
|
+
_setThrew(1, 0);
|
|
7209
|
+
}
|
|
7210
|
+
}
|
|
7211
|
+
|
|
7212
|
+
function invoke_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) {
|
|
7213
|
+
var sp = stackSave();
|
|
7214
|
+
try {
|
|
7215
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15);
|
|
7216
|
+
} catch(e) {
|
|
7217
|
+
stackRestore(sp);
|
|
7218
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7219
|
+
_setThrew(1, 0);
|
|
7220
|
+
}
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7223
|
+
function invoke_jiiii(index,a1,a2,a3,a4) {
|
|
7224
|
+
var sp = stackSave();
|
|
7225
|
+
try {
|
|
7226
|
+
return dynCall_jiiii(index,a1,a2,a3,a4);
|
|
7227
|
+
} catch(e) {
|
|
7228
|
+
stackRestore(sp);
|
|
7229
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
7230
|
+
_setThrew(1, 0);
|
|
7231
|
+
}
|
|
7232
|
+
}
|
|
7233
|
+
|
|
4113
7234
|
|
|
4114
7235
|
// include: postamble.js
|
|
4115
7236
|
// === Auto-generated postamble setup entry stuff ===
|
|
@@ -4194,13 +7315,23 @@ function checkUnflushedContent() {
|
|
|
4194
7315
|
has = true;
|
|
4195
7316
|
}
|
|
4196
7317
|
try { // it doesn't matter if it fails
|
|
4197
|
-
|
|
7318
|
+
_fflush(0);
|
|
7319
|
+
// also flush in the JS FS layer
|
|
7320
|
+
['stdout', 'stderr'].forEach((name) => {
|
|
7321
|
+
var info = FS.analyzePath('/dev/' + name);
|
|
7322
|
+
if (!info) return;
|
|
7323
|
+
var stream = info.object;
|
|
7324
|
+
var rdev = stream.rdev;
|
|
7325
|
+
var tty = TTY.ttys[rdev];
|
|
7326
|
+
if (tty?.output?.length) {
|
|
7327
|
+
has = true;
|
|
7328
|
+
}
|
|
7329
|
+
});
|
|
4198
7330
|
} catch(e) {}
|
|
4199
7331
|
out = oldOut;
|
|
4200
7332
|
err = oldErr;
|
|
4201
7333
|
if (has) {
|
|
4202
7334
|
warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.');
|
|
4203
|
-
warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
|
|
4204
7335
|
}
|
|
4205
7336
|
}
|
|
4206
7337
|
|