@arcgis/core 4.23.0-next.20211220 → 4.23.0-next.20211224
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/arcade/Feature.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/functions/hash.js +1 -1
- package/arcade/lib/scanner.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0881ce46b10362861f87.js +1 -0
- package/assets/esri/core/workers/chunks/{226b7e0d366f647dc402.js → 0c0a02770eeeb3e28ea1.js} +1 -1
- package/assets/esri/core/workers/chunks/0f04246c1b591a3ac74d.js +1 -0
- package/assets/esri/core/workers/chunks/{f36be00ad918e591a7c8.js → 12df4f05de1262f9940f.js} +1 -1
- package/assets/esri/core/workers/chunks/{94f27f9557e72ca35715.js → 1ac6be0dc25e16c75d06.js} +1 -1
- package/assets/esri/core/workers/chunks/{7682f4e6a50755135b15.js → 1f8110ea12d65ca94b55.js} +1 -1
- package/assets/esri/core/workers/chunks/2025d0fd61a64876c81b.js +1 -0
- package/assets/esri/core/workers/chunks/{acf338d32b92d8eff007.js → 22b09e276c9b9f22f0f8.js} +1 -1
- package/assets/esri/core/workers/chunks/241859d74c0daac62e11.js +1 -0
- package/assets/esri/core/workers/chunks/{0c16a92aadc7ac51eecd.js → 2a39d520b192b8e552b5.js} +1 -1
- package/assets/esri/core/workers/chunks/2f66fcb8670b108af549.js +1 -0
- package/assets/esri/core/workers/chunks/39af317388ecebb4387d.js +1 -0
- package/assets/esri/core/workers/chunks/{61d1db85cc8cf2ef889e.js → 39be2893a7dbdecfd65a.js} +1 -1
- package/assets/esri/core/workers/chunks/3a20f66b0b7d08064e34.js +1 -0
- package/assets/esri/core/workers/chunks/3aa4194dc5497c57647f.js +1 -0
- package/assets/esri/core/workers/chunks/3d5169ea9810d10caf0d.js +1 -0
- package/assets/esri/core/workers/chunks/{1ca2eee7bbcda6bc2c02.js → 411db587521e12c593be.js} +1 -1
- package/assets/esri/core/workers/chunks/445099d037affd139ed0.js +1 -0
- package/assets/esri/core/workers/chunks/45848fecec88ed2da33d.js +1 -0
- package/assets/esri/core/workers/chunks/48d3a3abc53abe6a4017.js +1 -0
- package/assets/esri/core/workers/chunks/4beba242e7540ee3182b.js +1 -0
- package/assets/esri/core/workers/chunks/4bfbf5a34c9207fdcf44.js +1 -0
- package/assets/esri/core/workers/chunks/{8c8203490df85ed14c21.js → 5005b8c1fdd5cb9a4c19.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ae129f8fa03b52df20a.js → 52e4c367c72ea7cc3457.js} +1 -1
- package/assets/esri/core/workers/chunks/615aa2d3ecafe30c80c0.js +1 -0
- package/assets/esri/core/workers/chunks/634b5ccd7a3ac67f855d.js +1 -0
- package/assets/esri/core/workers/chunks/64459604505647e9c714.js +1 -0
- package/assets/esri/core/workers/chunks/653d1550dd1a4867a9fc.js +1 -0
- package/assets/esri/core/workers/chunks/65f73fbbc3c7c60c6d3d.js +1 -0
- package/assets/esri/core/workers/chunks/6e13dab8ec43f7494297.js +1 -0
- package/assets/esri/core/workers/chunks/722a10c65456844d72b9.js +1 -0
- package/assets/esri/core/workers/chunks/7c1b9ae141112a63b446.js +1 -0
- package/assets/esri/core/workers/chunks/803de5097a8a2c4b58a8.js +1 -0
- package/assets/esri/core/workers/chunks/8298231a0fd0129b0d5c.js +1 -0
- package/assets/esri/core/workers/chunks/86783c9b51dde845c24f.js +1 -0
- package/assets/esri/core/workers/chunks/8a250ec51097f16feb66.js +1 -0
- package/assets/esri/core/workers/chunks/{1b1802f2a8131bf31b70.js → 8afae85018491491f773.js} +1 -1
- package/assets/esri/core/workers/chunks/8b322a2a47dfdbb59b45.js +1 -0
- package/assets/esri/core/workers/chunks/8b6ab6202a40fe622833.js +1 -0
- package/assets/esri/core/workers/chunks/8ceac95537638dc9a322.js +1 -0
- package/assets/esri/core/workers/chunks/8f83bebef9174c3f15da.js +1 -0
- package/assets/esri/core/workers/chunks/904332faa22bc0e876cb.js +1 -0
- package/assets/esri/core/workers/chunks/9846098704ee38bf6350.js +1 -0
- package/assets/esri/core/workers/chunks/99f0d896c17dd09cd285.js +1 -0
- package/assets/esri/core/workers/chunks/9b7c51ff3d2b42aa62f5.js +1 -0
- package/assets/esri/core/workers/chunks/{eaa91f08b3533a214855.js → a247ddd84245c81112c8.js} +1 -1
- package/assets/esri/core/workers/chunks/a721342a32541717324d.js +1 -0
- package/assets/esri/core/workers/chunks/ad7e9553d03a43573a54.js +1 -0
- package/assets/esri/core/workers/chunks/af13e534e4160636bd3d.js +1 -0
- package/assets/esri/core/workers/chunks/{31adfb1e6ccbdf943f13.js → b51261a9a9ab62388839.js} +2 -2
- package/assets/esri/core/workers/chunks/b5bb7cfa26b1f0cec67a.js +1 -0
- package/assets/esri/core/workers/chunks/b8666d1a4e4fff7a4703.js +1 -0
- package/assets/esri/core/workers/chunks/b87bc1481a49b38109f4.js +1 -0
- package/assets/esri/core/workers/chunks/{8e39a4f6dd2778c4b760.js → bea1da9e3f878e0e2c83.js} +1 -1
- package/assets/esri/core/workers/chunks/c1b6c31fa3ec1542f996.js +1 -0
- package/assets/esri/core/workers/chunks/c32a4fbdc87225f84019.js +1 -0
- package/assets/esri/core/workers/chunks/ce5ca5e95b2378ec55b9.js +1 -0
- package/assets/esri/core/workers/chunks/d336afd5890dcdbf5341.js +1 -0
- package/assets/esri/core/workers/chunks/d39b7983b68d6e5b404d.js +1 -0
- package/assets/esri/core/workers/chunks/da69e3e5949fe1716e34.js +1 -0
- package/assets/esri/core/workers/chunks/dd63ba77b7e4c3c9c594.js +1 -0
- package/assets/esri/core/workers/chunks/dfa57982d28c9aeb97b9.js +1 -0
- package/assets/esri/core/workers/chunks/{81e35b2c1a2732db7ec8.js → e01812116b27874948f0.js} +1 -1
- package/assets/esri/core/workers/chunks/e5c9d8482b913cf3580a.js +1 -0
- package/assets/esri/core/workers/chunks/ed0297fc61014e848c18.js +1 -0
- package/assets/esri/core/workers/chunks/eeadd92f0bede9fc8745.js +1 -0
- package/assets/esri/core/workers/chunks/f678293de9a6d8f5b5db.js +1 -0
- package/assets/esri/core/workers/chunks/{ff65b56ffdafd796b675.js → fbb67cb6224aed2cce16.js} +1 -1
- package/assets/esri/core/workers/chunks/fc7e31d87555beb63291.js +1 -0
- package/assets/esri/core/workers/chunks/fd3e5d823dc7917f4b8f.js +1 -0
- package/assets/esri/core/workers/chunks/{2af44160ae063b245eca.js → fe0615ba6d368e03c82a.js} +1 -1
- package/assets/esri/core/workers/chunks/ff02295329a8986d0568.js +1 -0
- package/assets/esri/core/workers/chunks/ffaf091c6023225cf5aa.js +1 -0
- package/assets/esri/core/workers/chunks/fff6b0338f06dad0c45d.js +1 -0
- package/chunks/RibbonLine.glsl.js +75 -62
- package/core/AsyncSequence.js +1 -1
- package/core/AsyncUpdate.js +1 -1
- package/core/CollectionFlattener.js +1 -1
- package/core/ObjectStack.js +1 -1
- package/core/VectorStack.js +1 -1
- package/core/jsonMap.js +1 -1
- package/core/lang.js +1 -1
- package/core/libs/rbush/PooledRBush.js +1 -1
- package/core/pbf.js +1 -1
- package/core/sql/StandardizedFunctions.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/geometry/support/MeshTexture.js +1 -1
- package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/buffer.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/bufferview.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/glb.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/interfaces.d.ts +1 -13
- package/layers/PointCloudLayer.js +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/VoxelWasmPerScene.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/mixins/PortalLayer.js +1 -1
- package/layers/support/FetchAssociatedFeatureLayer.js +1 -1
- package/layers/support/Tilemap.js +1 -1
- package/layers/support/rasterDatasets/EphemeralBlockCache.js +1 -1
- package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
- package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItemResource.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/CIMSymbolRasterizer.js +1 -1
- package/symbols/cim/GeometryWalker.js +1 -1
- package/symbols/cim/TextRasterizer.js +1 -1
- package/views/2d/engine/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/flow/FlowGLResources.js +1 -1
- package/views/2d/engine/vectorTiles/GlyphMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
- package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
- package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/Programs.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/VTLMaterialManager.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/sources/resolver.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
- package/views/2d/engine/webgl/ClippingInfo.js +1 -1
- package/views/2d/engine/webgl/GroupContainer.js +1 -1
- package/views/2d/engine/webgl/MaterialManager.js +1 -1
- package/views/2d/engine/webgl/Mesh2D.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
- package/views/2d/engine/webgl/TurboLine.js +1 -1
- package/views/2d/engine/webgl/VertexStream.js +1 -1
- package/views/2d/engine/webgl/WGLBuffers.js +1 -1
- package/views/2d/engine/webgl/animatedFormats/gif.js +1 -1
- package/views/2d/engine/webgl/brushes/BrushClip.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushInfo.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
- package/views/2d/engine/webgl/brushes/raster/BrushRasterBitmap.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/Geometry.js +1 -1
- package/views/2d/engine/webgl/effects/BlendEffect.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightGradient.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightSurfaces.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Bloom.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Blur.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Colorize.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/DRA.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/DropShadow.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/EdgeDetect.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/EdgeEnhance.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Opacity.js +1 -1
- package/views/2d/engine/webgl/shaders/MagnifierPrograms.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/resolver.js +1 -1
- package/views/2d/input/handlers/GamepadNavigation.js +1 -1
- package/views/2d/input/handlers/PinchAction.js +1 -1
- package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
- package/views/2d/layerViewModuleImportUtils.js +1 -1
- package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
- package/views/2d/layers/graphics/GraphicStore.js +1 -1
- package/views/2d/magnifier/MagnifierView2D.js +1 -1
- package/views/2d/webglDeps.js +5 -0
- package/views/3d/environment/CloudsGenerator.js +1 -1
- package/views/3d/environment/NoiseTextureAtlas.js +1 -1
- package/views/3d/environment/PanoramicAtmosphere.js +1 -1
- package/views/3d/environment/SceneViewEnvironment.js +1 -1
- package/views/3d/environment/SimpleAtmosphere.js +1 -1
- package/views/3d/environment/Stars.js +1 -1
- package/views/3d/environment/StarsTechnique.js +1 -1
- package/views/3d/glTF/DefaultLoadingContext.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/input/handlers/DoubleClickZoom.js +1 -1
- package/views/3d/input/handlers/DragRotate.js +1 -1
- package/views/3d/input/handlers/DragZoom.js +1 -1
- package/views/3d/input/handlers/GamepadNavigation.js +1 -1
- package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
- package/views/3d/input/handlers/MouseWheelZoom.js +1 -1
- package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
- package/views/3d/input/handlers/TwoFingerTilt.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/Manipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/snapping/SnapToScene.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/PreserveAspectRatio.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateObjectSymbol3DAdapter.js +1 -1
- package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
- package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/ExtentSet.js +1 -1
- package/views/3d/layers/graphics/GraphicStateTracking.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureLikeLayerView.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFilterVisibility.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphicLikeLayerView.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectStates.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPointSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
- package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
- package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
- package/views/3d/layers/graphics/QueryEngine.js +1 -1
- package/views/3d/layers/i3s/Highlights.js +1 -1
- package/views/3d/layers/i3s/I3SAttributeOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SElevationProvider.js +1 -1
- package/views/3d/layers/i3s/I3SFrameTask.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SLodHandling.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/PointHighlights.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DDebugger.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/layers/support/featureReference.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/GoToOperation.js +1 -1
- package/views/3d/state/SurfaceCollisionConstraint.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/LaserLineRenderer.js +1 -1
- package/views/3d/support/LaserlinePathData.js +1 -1
- package/views/3d/support/PropertiesPool.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/ContentGeometryUpdates.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/support/FBOPool.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
- package/views/3d/webgl-engine/lib/InstanceBufferData.js +1 -1
- package/views/3d/webgl-engine/lib/MagnifierHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/RenderTargetHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/StaticFloat32ArrayObject.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextTexture.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/Util.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/BackedBufferObject.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/RenderInstanceData.js +1 -1
- package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
- package/views/3d/webgl-engine/lib/screenSizePerspectiveUtils.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/StippleTextureRepository.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/MapView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/input/DragEventSeparator.js +1 -1
- package/views/input/ViewEvents.js +1 -1
- package/views/input/gamepad/GamepadSource.js +1 -1
- package/views/input/recognizers/Drag.js +1 -1
- package/views/input/recognizers/PointerClickHoldAndDrag.js +1 -1
- package/views/input/recognizers/SingleAndDoubleClick.js +1 -1
- package/views/input/recognizers/VerticalTwoFingerDrag.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/MoveVertex.js +1 -1
- package/views/interactive/editGeometry/operations/RotateVertex.js +1 -1
- package/views/interactive/editGeometry/operations/ScaleVertex.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/SnappingVisualizer.js +1 -1
- package/views/interactive/snapping/candidates/LineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/WorkerTileTreeDebugger.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/PendingFeatureTile.js +1 -1
- package/views/navigation/FilteredFiniteDifference.js +1 -1
- package/views/overlay/LineOverlayItem.js +1 -1
- package/views/overlay/TextOverlayItem.js +1 -1
- package/views/support/WatchUpdatingTracking.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/views/webgl/BufferObject.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/Measurement.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/views/webgl/ProgramCache.js +1 -1
- package/views/webgl/ProgramTemplate.js +5 -0
- package/views/webgl/Renderbuffer.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/ShaderCompiler.js +1 -1
- package/views/webgl/ShaderTranspiler.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/programUtils.js +1 -1
- package/views/webgl/rasterUtils.js +1 -1
- package/views/webgl/renderState.js +1 -1
- package/views/webgl/testDoublePrecisionArithmetic.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
- package/views/webgl/testSamplerPrecision.js +1 -1
- package/views/webgl/tests/SimpleDraw.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/Editor/BatchCreateWorkflow.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FloorFilter.js +1 -1
- package/widgets/Histogram.js +1 -1
- package/widgets/LineOfSight.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/Sketch/support/OperationHandle.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/widgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/01b1f55629e4fdf38aae.js +0 -1
- package/assets/esri/core/workers/chunks/064e8ce3fbb01f0c9470.js +0 -1
- package/assets/esri/core/workers/chunks/07ae24b044b5060e5ef7.js +0 -1
- package/assets/esri/core/workers/chunks/0acabca5172c14741ce6.js +0 -1
- package/assets/esri/core/workers/chunks/0b805d7f6efc9be2e81f.js +0 -1
- package/assets/esri/core/workers/chunks/24b70ca29b0832e5cee3.js +0 -1
- package/assets/esri/core/workers/chunks/268031d9f3f64e575088.js +0 -1
- package/assets/esri/core/workers/chunks/36e0b1f0a44936be5356.js +0 -1
- package/assets/esri/core/workers/chunks/38b3d708f61087e74f58.js +0 -1
- package/assets/esri/core/workers/chunks/3bcd90e07529d4bbfe22.js +0 -1
- package/assets/esri/core/workers/chunks/3efb0b866cb166cd32c4.js +0 -1
- package/assets/esri/core/workers/chunks/41b266d8dad34dfbcaa2.js +0 -1
- package/assets/esri/core/workers/chunks/428acf2fc3601474bd55.js +0 -1
- package/assets/esri/core/workers/chunks/43b13ed7b05862ee8a5a.js +0 -1
- package/assets/esri/core/workers/chunks/472dfcb0bd67e9b92e8a.js +0 -1
- package/assets/esri/core/workers/chunks/49daac3f403ca2016317.js +0 -1
- package/assets/esri/core/workers/chunks/4dfb18639bded2afb56c.js +0 -1
- package/assets/esri/core/workers/chunks/4fdf44d7a6565955f6da.js +0 -1
- package/assets/esri/core/workers/chunks/52b71cdbc647219fc9ae.js +0 -1
- package/assets/esri/core/workers/chunks/64006963c10a027e16f8.js +0 -1
- package/assets/esri/core/workers/chunks/6d3772e01ee305125b57.js +0 -1
- package/assets/esri/core/workers/chunks/6dc548c6281a26613376.js +0 -1
- package/assets/esri/core/workers/chunks/6e942ba6320aaeecef65.js +0 -1
- package/assets/esri/core/workers/chunks/7284c4ee5f006b7c717d.js +0 -1
- package/assets/esri/core/workers/chunks/73c0274b9513f21fc160.js +0 -1
- package/assets/esri/core/workers/chunks/74a88b08d8accc4ea621.js +0 -1
- package/assets/esri/core/workers/chunks/7696ec05c1b24f5b2de8.js +0 -1
- package/assets/esri/core/workers/chunks/7c81b05c373c4b2e40ce.js +0 -1
- package/assets/esri/core/workers/chunks/802f770d429d5c5ee91d.js +0 -1
- package/assets/esri/core/workers/chunks/87ec12ad9e3f2bbe9010.js +0 -1
- package/assets/esri/core/workers/chunks/8855c0c2f8f89d628fb7.js +0 -1
- package/assets/esri/core/workers/chunks/995743e66f0bfcb3ca37.js +0 -1
- package/assets/esri/core/workers/chunks/9c0aea5d7b8734bf80ef.js +0 -1
- package/assets/esri/core/workers/chunks/a24f22bcdb4f8094e34e.js +0 -1
- package/assets/esri/core/workers/chunks/a25e577a6bc696344bd6.js +0 -1
- package/assets/esri/core/workers/chunks/a5518f538bb81bb28e12.js +0 -1
- package/assets/esri/core/workers/chunks/a5940822088711bbdc7d.js +0 -1
- package/assets/esri/core/workers/chunks/aaf6248deded50fc9920.js +0 -1
- package/assets/esri/core/workers/chunks/abe52cca826b6c286530.js +0 -1
- package/assets/esri/core/workers/chunks/af257fb64ecc80b11703.js +0 -1
- package/assets/esri/core/workers/chunks/af36353bff20253d95ca.js +0 -1
- package/assets/esri/core/workers/chunks/b418cdd47b4be2eccf9e.js +0 -1
- package/assets/esri/core/workers/chunks/b7a93b4eec074dce088b.js +0 -1
- package/assets/esri/core/workers/chunks/ba7208dd095aff2c0524.js +0 -1
- package/assets/esri/core/workers/chunks/bb8ec2e806f772665c27.js +0 -1
- package/assets/esri/core/workers/chunks/c37106652ada18dc7d21.js +0 -1
- package/assets/esri/core/workers/chunks/cb7ae5eff18e52bdedd2.js +0 -1
- package/assets/esri/core/workers/chunks/d97177d1347a87baf4fa.js +0 -1
- package/assets/esri/core/workers/chunks/df1b700567e9d0456b12.js +0 -1
- package/assets/esri/core/workers/chunks/e61598f1b3df8afa8409.js +0 -1
- package/assets/esri/core/workers/chunks/ecab35c2bbe5e0076793.js +0 -1
- package/assets/esri/core/workers/chunks/ee792c73ffb22db68d9f.js +0 -1
- package/assets/esri/core/workers/chunks/f132f6e1356dbc867249.js +0 -1
- package/assets/esri/core/workers/chunks/f360e5972d4a095d24c0.js +0 -1
- package/assets/esri/core/workers/chunks/f5371877f92759ff5c62.js +0 -1
- package/assets/esri/core/workers/chunks/fabc901b07077fa0571d.js +0 -1
- package/assets/esri/core/workers/chunks/fc55129c9fcbefe34ee9.js +0 -1
- package/chunks/builtins.js +0 -5
- package/views/webgl.js +0 -5
package/arcade/Feature.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"./Dictionary.js";import e from"./ImmutableArray.js";import{i,j as s,f as r,s as a,x as o,n,A as l,B as u,C as h,u as f}from"../chunks/languageUtils.js";import{resolve as y}from"../core/promiseUtils.js";import d from"../geometry/Geometry.js";import
|
|
5
|
+
import t from"./Dictionary.js";import e from"./ImmutableArray.js";import{i,j as s,f as r,s as a,x as o,n,A as l,B as u,C as h,u as f}from"../chunks/languageUtils.js";import{resolve as y}from"../core/promiseUtils.js";import d from"../geometry/Geometry.js";import _ from"../geometry/Point.js";import{fromJSON as c}from"../geometry/support/jsonUtils.js";import{esriFieldToJson as m,layerGeometryEsriRestConstants as p}from"./featureset/support/shared.js";import{convertToGeometry as b}from"../layers/graphics/featureConversionUtils.js";import{isSome as g,unwrap as x}from"../core/maybe.js";class F{constructor(){this.declaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._datesfixed=!0,this.immutable=!0,this._datefields=null,this.immutable=!0}static createFromGraphic(t){const e=new F;return e._geometry=g(t.geometry)?t.geometry:null,void 0===t.attributes||null===t.attributes?e.attributes={}:e.attributes=t.attributes,t._sourceLayer?(e._layer=t._sourceLayer,e._datesfixed=!1):t._layer?(e._layer=t._layer,e._datesfixed=!1):t.layer&&"fields"in t.layer?(e._layer=t.layer,e._datesfixed=!1):t.sourceLayer&&"fields"in t.sourceLayer&&(e._layer=t.sourceLayer,e._datesfixed=!1),e}static createFromArcadeFeature(t){const e=new F;return e._datesfixed=t._datesfixed,e.attributes=t.attributes,e._geometry=t._geometry,e._optimizedGeomDefinition=t._optimizedGeomDefinition,t._layer&&(e._layer=t._layer),e}static createFromOptimisedFeature(t,e,i){const s=new F;return s._geometry=t.geometry?{geometry:t.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=t.attributes||{},s._layer=e,s._datesfixed=!1,s}static createFromArcadeDictionary(e){const i=new F;return i.attributes=e.field("attributes"),null!==i.attributes&&i.attributes instanceof t?(i.attributes=i.attributes.attributes,null===i.attributes&&(i.attributes={})):i.attributes={},i._geometry=e.field("geometry"),null!==i._geometry&&(i._geometry instanceof t?i._geometry=F.parseGeometryFromDictionary(i._geometry):i._geometry instanceof d||(i._geometry=null)),i}static createFromGraphicLikeObject(t,e,i=null){const s=new F;return null===e&&(e={}),s.attributes=e,s._geometry=g(t)?t:null,s._layer=i,s._layer&&(s._datesfixed=!1),s._adapter=null,s}repurposeFromGraphicLikeObject(t,e,i=null){null===e&&(e={}),this.attributes=e,this._geometry=t||null,this._layer=i,this._layer?this._datesfixed=!1:this._datesfixed=!0}repurposeFromAdapter(t,e=null){this._adapter=t,this._layer=e}castToText(){if(this._adapter)return this._adapter.castToText();let t="";!1===this._datesfixed&&this._fixDates();for(const o in this.attributes){""!==t&&(t+=",");const n=this.attributes[o];null==n?t+=JSON.stringify(o)+":null":i(n)||s(n)||r(n)?t+=JSON.stringify(o)+":"+JSON.stringify(n):n instanceof d||n instanceof e||n instanceof Array?t+=JSON.stringify(o)+":"+a(n):n instanceof Date?t+=JSON.stringify(o)+":"+JSON.stringify(n):null!==n&&"object"==typeof n&&void 0!==n.castToText&&(t+=JSON.stringify(o)+":"+n.castToText())}return'{"geometry":'+(null===this.geometry()?"null":a(this.geometry()))+',"attributes":{'+t+"}}"}_fixDates(){if(null!==this._datefields)return this._datefields.length>0&&this._fixDateFields(this._datefields),void(this._datesfixed=!0);const t=[];for(let e=0;e<this._layer.fields.length;e++){const i=this._layer.fields[e];"date"!==i.type&&"esriFieldTypeDate"!==i.type||t.push(i.name)}this._datefields=t,t.length>0&&this._fixDateFields(t),this._datesfixed=!0}_fixDateFields(t){this.attributes={...this.attributes};for(let e=0;e<t.length;e++){let i=this.attributes[t[e]];if(null===i);else if(void 0===i){for(const s in this.attributes)if(s.toLowerCase()===t[e].toLowerCase()){i=this.attributes[s],null!==i&&(i instanceof Date||(this.attributes[s]=new Date(i)));break}}else i instanceof Date||(this.attributes[t[e]]=new Date(i))}}geometry(){return this._adapter?this._adapter.geometry():(null===this._geometry||this._geometry instanceof d||(this._optimizedGeomDefinition?(this._geometry=x(c(b(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM))),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=x(c(this._geometry))),this._geometry)}field(t){if(this._adapter)return this._adapter.field(t);!1===this._datesfixed&&this._fixDates();const e=this.attributes[t];if(void 0!==e)return e;const i=t.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new Error("Field not Found : "+t)}_hasFieldDefinition(t){if(null===this._layer)return!1;for(let e=0;e<this._layer.fields.length;e++){if(this._layer.fields[e].name.toLowerCase()===t)return!0}return!1}_field(t){var e;if(this._adapter)return null!=(e=this._adapter.field(t))?e:null;!1===this._datesfixed&&this._fixDates();const i=t.toLowerCase(),s=this.attributes[t];if(void 0!==s)return s;for(const r in this.attributes)if(r.toLowerCase()===i)return this.attributes[r];return null}setField(t,e){if(this.immutable)throw new Error("Feature is Immutable");if(!1===o(e))throw new Error("Illegal Value Assignment to Feature");if(this._adapter)return void this._adapter.setField(t,e);const i=t.toLowerCase();if(void 0===this.attributes[t]){for(const t in this.attributes)if(t.toLowerCase()===i)return void(this.attributes[t]=e);this.attributes[t]=e}else this.attributes[t]=e}hasField(t){if(this._adapter)return this._adapter.hasField(t);const e=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const i in this.attributes)if(i.toLowerCase()===e)return!0;return!!this._hasFieldDefinition(e)}keys(){if(this._adapter)return this._adapter.keys();let t=[];const e={};for(const i in this.attributes)t.push(i),e[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==e[s.name.toLowerCase()]&&t.push(s.name)}return t=t.sort(),t}static parseGeometryFromDictionary(t){const e=F._convertDictionaryToJson(t,!0);return void 0!==e.hasm&&(e.hasM=e.hasm,delete e.hasm),void 0!==e.hasz&&(e.hasZ=e.hasz,delete e.hasz),void 0!==e.spatialreference&&(e.spatialReference=e.spatialreference,delete e.spatialreference),void 0!==e.rings&&(e.rings=this._fixPathArrays(e.rings,!0===e.hasZ,!0===e.hasZ)),void 0!==e.paths&&(e.paths=this._fixPathArrays(e.paths,!0===e.hasZ,!0===e.hasM)),void 0!==e.points&&(e.points=this._fixPointArrays(e.points,!0===e.hasZ,!0===e.hasM)),c(e)}static _fixPathArrays(t,i,s){const r=[];if(t instanceof Array)for(let e=0;e<t.length;e++)r.push(this._fixPointArrays(t[e],i,s));else if(t instanceof e)for(let e=0;e<t.length();e++)r.push(this._fixPointArrays(t.get(e),i,s));return r}static _fixPointArrays(t,i,s){const r=[];if(t instanceof Array)for(let a=0;a<t.length;a++){const o=t[a];o instanceof _?i&&s?r.push([o.x,o.y,o.z,o.m]):i?r.push([o.x,o.y,o.z]):s?r.push([o.x,o.y,o.m]):r.push([o.x,o.y]):o instanceof e?r.push(o.toArray()):r.push(o)}else if(t instanceof e)for(let a=0;a<t.length();a++){const o=t.get(a);o instanceof _?i&&s?r.push([o.x,o.y,o.z,o.m]):i?r.push([o.x,o.y,o.z]):s?r.push([o.x,o.y,o.m]):r.push([o.x,o.y]):o instanceof e?r.push(o.toArray()):r.push(o)}return r}static _convertDictionaryToJson(e,i=!1){const s={};for(const r in e.attributes){let a=e.attributes[r];a instanceof t&&(a=F._convertDictionaryToJson(a)),i?s[r.toLowerCase()]=a:s[r]=a}return s}static parseAttributesFromDictionary(t){const e={};for(const i in t.attributes){const s=t.attributes[i];if(!o(s))throw new Error("Illegal Argument");e[i]=s}return e}static fromJson(t){let e=null;null!==t.geometry&&void 0!==t.geometry&&(e=c(t.geometry));const a={};if(null!==t.attributes&&void 0!==t.attributes)for(const o in t.attributes){const e=t.attributes[o];if(null===e)a[o]=e;else{if(!(r(e)||s(e)||i(e)||n(e)))throw new Error("Illegal Argument");a[o]=e}}return F.createFromGraphicLikeObject(e,a,null)}fullDomain(t,e){if(null===this._layer)return null;if(!this._layer.fields)return null;return l(t,this._layer,this,e)}subtypes(){return null===this._layer?null:this._layer.fields&&this._layer.typeIdField?{subtypeField:this._layer.typeIdField,subtypes:this._layer.types?this._layer.types.map((t=>({name:t.name,code:t.id}))):[]}:null}domainValueLookup(t,e,i){if(null===this._layer)return null;if(!this._layer.fields)return null;const s=l(t,this._layer,this,i);if(void 0===e)try{e=this.field(t)}catch(r){return null}return u(s,e)}gdbVersion(){if(null===this._layer)return"";const t=this._layer.gdbVersion;return void 0===t?"":""===t&&this._layer.capabilities&&this._layer.capabilities.isVersioned?"SDE.DEFAULT":t}domainCodeLookup(t,e,i){if(null===this._layer)return null;if(!this._layer.fields)return null;if(void 0===e){try{e=this.field(t)}catch(r){return null}return e}const s=l(t,this._layer,this,i);return h(s,e)}schema(){if(null===this._layer)return null;if(!this._layer.fields)return null;const t=[];for(const e of this._layer.fields)t.push(m(e));return{objectIdField:this._layer.objectIdField,globalIdField:this._layer.globalIdField,geometryType:void 0===p[this._layer.geometryType]?"":p[this._layer.geometryType],fields:t}}castAsJson(t=null){const e={attributes:{},geometry:!0===(null==t?void 0:t.keepGeometryType)?this.geometry():this.geometry().toJSON()};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(e.attributes[i]=f(s,t))}return e}castAsJsonAsync(t=null,e=null){return y(this.castAsJson(e))}}export{F as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{id as e}from"../kernel.js";import t from"../request.js";import r from"./featureSetCollection.js";import n from"./featureset/actions/AttributeFilter.js";import a from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import i from"./featureset/actions/SpatialFilter.js";import l from"./featureset/actions/Top.js";import o from"./featureset/sources/FeatureLayerDynamic.js";import u from"./featureset/sources/FeatureLayerMemory.js";import c from"./featureset/sources/FeatureLayerRelated.js";import d from"./featureset/support/cache.js";import m from"./featureset/support/FeatureSet.js";import{extractServiceUrl as f}from"./featureset/support/shared.js";import{resolve as h,reject as p,create as y}from"../core/promiseUtils.js";import{WhereClause as L}from"../core/sql/WhereClause.js";import I from"../layers/FeatureLayer.js";import S from"../portal/Portal.js";import _ from"../portal/PortalItem.js";function N(){null===d.applicationCache&&(d.applicationCache=new d)}function F(e,t){if(d.applicationCache){const r=d.applicationCache.getLayerInfo(e);if(r)return r.then((r=>h(new I({url:e,outFields:t,sourceJSON:r}))));const n=new I({url:e,outFields:t});let a=y(((e,t)=>{n.load().then((()=>{e(n.sourceJSON)}),(e=>{t(e)}))}));return d.applicationCache&&(d.applicationCache.setLayerInfo(e,a),a=a.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),a.then((()=>h(n)))}return h(new I({url:e,outFields:t}))}function T(e,t,r,n,a,s=null){return F(e,["*"]).then((e=>h(g(e,t,r,n,a,s))))}function g(e,t=null,r=null,n=!0,a=null,s=null){return!0===e._hasMemorySource()?new u({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s}):new o({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s})}function A(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return h(t)}return h(null)}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function C(e,r){const n="QUERYDATAELEMTS:"+r.toString()+":"+e;if(null!==d.applicationCache){const e=d.applicationCache.getLayerInfo(n);if(null!==e)return e}let a=t(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([r.toString()]),f:"json"}}).then((e=>{if(e.data){const t=e.data;if(t.layerDataElements&&t.layerDataElements[0])return t.layerDataElements[0]}throw new Error("Not Found")}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(n,a),a=a.catch((e=>{throw d.applicationCache.clearLayerInfo(n),e}))),a}function k(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.layers||(t.layers=[]),t.tables||(t.tables=[]),h(t)}return h({layers:[],tables:[]})}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function j(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return k(e).then((n=>{if(r.metadata=n,n.controllerDatasetLayers&&void 0!==n.controllerDatasetLayers.utilityNetworkLayerId&&null!==n.controllerDatasetLayers.utilityNetworkLayerId){if(n.layers)for(const e of n.layers)r.layerNameLkp[e.id]=e.name;if(n.tables)for(const e of n.tables)r.layerNameLkp[e.id]=e.name;const a=n.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=a,C(e,a).then((n=>{if(n){r.queryelem=n,r.queryelem&&r.queryelem.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources?e.edgeSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources?e.junctionSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});return A(e+"/"+a).then((n=>{if(n.systemLayers&&void 0!==n.systemLayers.associationsTableId&&null!==n.systemLayers.associationsTableId){const a=[];return r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),T(e+"/"+n.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null).then((e=>e.load())).then((e=>r.unVersion>=4?(e=e.filter(L.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",e.getFieldsIndex()))).load():e)).then((e=>({lkp:r.lkp,associations:e,unVersion:r.unVersion,terminals:r.terminals})))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}function w(e,t,r,n=null,a=null,s=!0,i=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),T(o,n,a,s,i,l).then((o=>new c({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:n,outFields:a,includeGeometry:s,lrucache:i,interceptor:l})))):null}n.registerAction(),a.registerAction(),s.registerAction(),i.registerAction(),l.registerAction();class O extends r{constructor(e,t=null,r=null,n=null){super(),this._map=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this._instantLayers=[]}makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache,this.interceptor);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetByName(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.layers.find((t=>t instanceof I&&t.title===e));if(a)return this.resolvePromise(this.makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(n){if(n instanceof I)return this.resolvePromise(this.makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e=n.outFields?n:{...n,outFields:["*"]};n._materializedTable=new I(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this.makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetById(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.layers.find((t=>t instanceof I&&t.id===e));if(a)return this.resolvePromise(this.makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>t.id===e));if(n){if(n instanceof I)return this.resolvePromise(this.makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e={...n,outFields:["*"]};n._materializedTable=new I(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this.makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}}class v extends r{constructor(e,t=null,r=null,n=null){super(),this._url=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this.metadata=null,this._instantLayers=[]}get url(){return this._url}makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}_loadMetaData(){return k(this._url).then((e=>(this.metadata=e,e)))}load(){return this._loadMetaData()}clone(){return new v(this._url,this._overridespref,this.lrucache,this.interceptor)}featureSetByName(e,t=!0,r=null){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])t.name===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])t.name===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this.makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}featureSetById(e,t=!0,r=["*"]){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);e=null!=e?e.toString():"";for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this.makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}}function E(e,t,r=null,n=null){return new O(e,t,r,n)}function b(e,t,r=null,n=null){return new v(e,t,r,n)}function D(e,t){if(null===e)return t;return new S({url:e.field("url")})}function q(r,n,a){return e.findCredential(r.restUrl)?"loaded"===r.loadStatus&&""===n&&r.user&&r.user.sourceJSON&&!1===a?h(r.user.sourceJSON):""===n?t(r.restUrl+"/community/self",{responseType:"json",query:{f:"json",...!1===a?{}:{returnUserLicenseTypeExtensions:!0}}}).then((e=>{if(e.data){const t=e.data;if(t&&t.username)return h(t)}return h(null)})):t(r.restUrl+"/community/users/"+n,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.error?null:h(t)}return h(null)})):h(null)}function P(e,t,r,n,a){if(null===e)return null;if(e instanceof I){switch(t){case"datasource":return g(e,a,e.outFields,!0,r,n).getDataSourceFeatureSet();case"parent":case"root":return g(e,a,e.outFields,!0,r,n)}return null}if(e instanceof m)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function G(e,t,r,n,a,s,i,l=null){if(d.applicationCache){const o=d.applicationCache.getLayerInfo(e+":"+s.url);if(o)return o.then((e=>{try{const s=new I({url:f(e.url)+"/"+t,outFields:["*"]});return h(g(s,r,n,a,i,l))}catch(s){return p(s)}}),(e=>p(e)))}return y(((o,u)=>{const c=new _({id:e,portal:s}).load();d.applicationCache&&d.applicationCache.setLayerInfo(e+":"+s.url,c),c.then((e=>{try{const s=new I({url:f(e.url)+"/"+t,outFields:["*"]});o(g(s,r,n,a,i,l))}catch(s){u(s)}}),(t=>{d.applicationCache&&d.applicationCache.clearLayerInfo(e+":"+s.url),u(t)}))}))}export{j as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,G as constructFeatureSetFromPortalItem,w as constructFeatureSetFromRelationship,T as constructFeatureSetFromUrl,P as convertToFeatureSet,E as createFeatureSetCollectionFromMap,b as createFeatureSetCollectionFromService,D as getPortal,N as initialiseMetaDataCache,q as lookupUser};
|
|
5
|
+
import{id as e}from"../kernel.js";import t from"../request.js";import r from"./featureSetCollection.js";import n from"./featureset/actions/AttributeFilter.js";import a from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import i from"./featureset/actions/SpatialFilter.js";import l from"./featureset/actions/Top.js";import o from"./featureset/sources/FeatureLayerDynamic.js";import u from"./featureset/sources/FeatureLayerMemory.js";import c from"./featureset/sources/FeatureLayerRelated.js";import d from"./featureset/support/cache.js";import m from"./featureset/support/FeatureSet.js";import{extractServiceUrl as f}from"./featureset/support/shared.js";import{resolve as h,reject as p,create as y}from"../core/promiseUtils.js";import{WhereClause as L}from"../core/sql/WhereClause.js";import _ from"../layers/FeatureLayer.js";import I from"../portal/Portal.js";import S from"../portal/PortalItem.js";function N(){null===d.applicationCache&&(d.applicationCache=new d)}function F(e,t){if(d.applicationCache){const r=d.applicationCache.getLayerInfo(e);if(r)return r.then((r=>h(new _({url:e,outFields:t,sourceJSON:r}))));const n=new _({url:e,outFields:t});let a=y(((e,t)=>{n.load().then((()=>{e(n.sourceJSON)}),(e=>{t(e)}))}));return d.applicationCache&&(d.applicationCache.setLayerInfo(e,a),a=a.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),a.then((()=>h(n)))}return h(new _({url:e,outFields:t}))}function T(e,t,r,n,a,s=null){return F(e,["*"]).then((e=>h(g(e,t,r,n,a,s))))}function g(e,t=null,r=null,n=!0,a=null,s=null){return!0===e._hasMemorySource()?new u({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s}):new o({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s})}function A(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return h(t)}return h(null)}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function C(e,r){const n="QUERYDATAELEMTS:"+r.toString()+":"+e;if(null!==d.applicationCache){const e=d.applicationCache.getLayerInfo(n);if(null!==e)return e}let a=t(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([r.toString()]),f:"json"}}).then((e=>{if(e.data){const t=e.data;if(t.layerDataElements&&t.layerDataElements[0])return t.layerDataElements[0]}throw new Error("Not Found")}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(n,a),a=a.catch((e=>{throw d.applicationCache.clearLayerInfo(n),e}))),a}function k(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.layers||(t.layers=[]),t.tables||(t.tables=[]),h(t)}return h({layers:[],tables:[]})}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function j(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return k(e).then((n=>{if(r.metadata=n,n.controllerDatasetLayers&&void 0!==n.controllerDatasetLayers.utilityNetworkLayerId&&null!==n.controllerDatasetLayers.utilityNetworkLayerId){if(n.layers)for(const e of n.layers)r.layerNameLkp[e.id]=e.name;if(n.tables)for(const e of n.tables)r.layerNameLkp[e.id]=e.name;const a=n.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=a,C(e,a).then((n=>{if(n){r.queryelem=n,r.queryelem&&r.queryelem.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources?e.edgeSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources?e.junctionSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});return A(e+"/"+a).then((n=>{if(n.systemLayers&&void 0!==n.systemLayers.associationsTableId&&null!==n.systemLayers.associationsTableId){const a=[];return r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),T(e+"/"+n.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null).then((e=>e.load())).then((e=>r.unVersion>=4?(e=e.filter(L.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",e.getFieldsIndex()))).load():e)).then((e=>({lkp:r.lkp,associations:e,unVersion:r.unVersion,terminals:r.terminals})))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}function w(e,t,r,n=null,a=null,s=!0,i=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),T(o,n,a,s,i,l).then((o=>new c({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:n,outFields:a,includeGeometry:s,lrucache:i,interceptor:l})))):null}n.registerAction(),a.registerAction(),s.registerAction(),i.registerAction(),l.registerAction();class O extends r{constructor(e,t=null,r=null,n=null){super(),this._map=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache,this.interceptor);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetByName(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.layers.find((t=>t instanceof _&&t.title===e));if(a)return this.resolvePromise(this._makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(n){if(n instanceof _)return this.resolvePromise(this._makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e=n.outFields?n:{...n,outFields:["*"]};n._materializedTable=new _(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetById(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.layers.find((t=>t instanceof _&&t.id===e));if(a)return this.resolvePromise(this._makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>t.id===e));if(n){if(n instanceof _)return this.resolvePromise(this._makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e={...n,outFields:["*"]};n._materializedTable=new _(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}}class v extends r{constructor(e,t=null,r=null,n=null){super(),this._url=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}_loadMetaData(){return k(this._url).then((e=>(this.metadata=e,e)))}load(){return this._loadMetaData()}clone(){return new v(this._url,this._overridespref,this.lrucache,this.interceptor)}featureSetByName(e,t=!0,r=null){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])t.name===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])t.name===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}featureSetById(e,t=!0,r=["*"]){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);e=null!=e?e.toString():"";for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}}function E(e,t,r=null,n=null){return new O(e,t,r,n)}function b(e,t,r=null,n=null){return new v(e,t,r,n)}function D(e,t){if(null===e)return t;return new I({url:e.field("url")})}function q(r,n,a){return e.findCredential(r.restUrl)?"loaded"===r.loadStatus&&""===n&&r.user&&r.user.sourceJSON&&!1===a?h(r.user.sourceJSON):""===n?t(r.restUrl+"/community/self",{responseType:"json",query:{f:"json",...!1===a?{}:{returnUserLicenseTypeExtensions:!0}}}).then((e=>{if(e.data){const t=e.data;if(t&&t.username)return h(t)}return h(null)})):t(r.restUrl+"/community/users/"+n,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.error?null:h(t)}return h(null)})):h(null)}function P(e,t,r,n,a){if(null===e)return null;if(e instanceof _){switch(t){case"datasource":return g(e,a,e.outFields,!0,r,n).getDataSourceFeatureSet();case"parent":case"root":return g(e,a,e.outFields,!0,r,n)}return null}if(e instanceof m)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function G(e,t,r,n,a,s,i,l=null){if(d.applicationCache){const o=d.applicationCache.getLayerInfo(e+":"+s.url);if(o)return o.then((e=>{try{const s=new _({url:f(e.url)+"/"+t,outFields:["*"]});return h(g(s,r,n,a,i,l))}catch(s){return p(s)}}),(e=>p(e)))}return y(((o,u)=>{const c=new S({id:e,portal:s}).load();d.applicationCache&&d.applicationCache.setLayerInfo(e+":"+s.url,c),c.then((e=>{try{const s=new _({url:f(e.url)+"/"+t,outFields:["*"]});o(g(s,r,n,a,i,l))}catch(s){u(s)}}),(t=>{d.applicationCache&&d.applicationCache.clearLayerInfo(e+":"+s.url),u(t)}))}))}export{j as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,G as constructFeatureSetFromPortalItem,w as constructFeatureSetFromRelationship,T as constructFeatureSetFromUrl,P as convertToFeatureSet,E as createFeatureSetCollectionFromMap,b as createFeatureSetCollectionFromService,D as getPortal,N as initialiseMetaDataCache,q as lookupUser};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{cloneField as a,FeatureServiceDatabaseType as i,layerGeometryEsriConstants as l}from"../support/shared.js";import{reformulateWithoutField as n,toWhereClause as o,translateFunctionToDatabaseSpecific as h,makeToday as u,makeDateString as d,convertIntervalToSql as c,combine as p,scanForField as f}from"../support/sqlUtils.js";import{resolve as g,reject as _}from"../../../core/promiseUtils.js";import{WhereClause as N}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";class m{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class w extends m{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class v extends m{constructor(e,t,r){super(a(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:n(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class C extends m{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,i.Standardised,this.field.name,this.codefield instanceof N?o(this.codefield,i.Standardised):this.codefield,e.parameters);return r.indexOf(C.BADNESS)>=0?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:N.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,s=null,a){let i,l,n,o;switch(e.type){case"interval":return c(this.evaluateNodeToWhereClause(e.value,t,r,s,a),e.qualifier,e.op);case"case_expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,C.BADNESS,a));for(let i=0;i<e.clauses.length;i++)s+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[i].operand,t,r,C.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[i].value,t,r,C.BADNESS,a);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,C.BADNESS,a)),s+=" END ",s}case"param":{const r=a[e.value.toLowerCase()];if("string"==typeof r){return"'"+a[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return d(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(d(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expr_list":l=[];for(const i of e.value)l.push(this.evaluateNodeToWhereClause(i,t,r,s,a));return l;case"unary_expr":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,C.BADNESS,a)+" ) ";case"binary_expr":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NOT NULL )";case"IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o+")) ";case"NOT IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o+")) ";case"BETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"NOTBETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<>":case"=":if("column_ref"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column_ref"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") "}throw new Error("Not Supported Operator "+e.operator);case"null":return"null";case"bool":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return d(e.value,t);case"number":return e.value.toString();case"current_time":return u("date"===e.mode,t);case"column_ref":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":e.column;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,C.BADNESS,a);return h(e.name,s,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof N?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}C.BADNESS="_!!!_BAD_LKP_!!!!";class T extends m{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:n(e,this.field.name,o(this.sql,i.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class E extends r{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new S({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new s(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):g(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(r,a,i,l){const n=[];-1!==a&&void 0===this._featureCache[a]&&n.push(a);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return this._expandPagedSet(r,o,0,0,l).then((()=>this._getFeatures(r,a,i,l)));let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=i&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==a&&n.push(r._known[e]),n.length>=o)));e++);if(0===n.length)return g("success");r=new s([],n,r._ordered,null);const u=Math.min(n.length,i);return this._parent._getFeatures(r,-1,u,l).then((()=>{this._checkCancelled(l);const r=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&r.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(const s of r){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(s);this._featureCache[s.id]=new e({attributes:r,geometry:t(s.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return _(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,a,i){let l=!1;const n=this.reformulateWithoutAdaptions(r);l=n.cannot,r=n.where;let o=!1;if(null!==a){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof w)&&!0===a.scanForField(t.field.name)){if(!(t instanceof v)){a=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}a&&e.length>0&&(a=a.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=p(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,a,i))).then((e=>{let t;return this._checkCancelled(i),t=!0===l?new s(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s(e._candidates.slice(0),e._known.slice(0),!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===f(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}_stat(e,t,r,s,a,i,l){let n=!1,o=this.reformulateWithoutAdaptions(t);return n=o.cannot,t=o.where,o=this.reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,!0===n?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):g({calculated:!1}):this._parent._stat(e,t,r,s,a,i,l).then((n=>!1===n.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:n))}_canDoAggregates(e,t,r,s,a){if(null===this._parent)return g(!1);for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof w))return g(!1);const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this.reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return g(!1);const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this.reformulateWithoutAdaptions(a);return l.cannot?g(!1):(null!==(a=l.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}_getAggregatePagesDataSourceDefinition(e,t,r,s,a,i,l){if(null===this._parent)return _(new Error("Should never be called"));const n=[];for(let h=0;h<t.length;h++){const e=t[h];if(null!==e.workingexpr){const t=this.reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return _(new Error("Should never be called"));const r=e.clone();r.workingexpr=t.where,n.push(r)}else n.push(e)}const o=this.reformulateWithoutAdaptions(a);return o.cannot?_(new Error("Should never be called")):(null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,n,r,s,a,i,l))}}export{E as AdaptedFeatureSet,m as AdaptedField,v as FieldRename,w as OriginalField,T as SqlExpressionAdapted,C as StringToCodeAdapted};
|
|
5
|
+
import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{cloneField as a,FeatureServiceDatabaseType as i,layerGeometryEsriConstants as l}from"../support/shared.js";import{reformulateWithoutField as n,toWhereClause as o,translateFunctionToDatabaseSpecific as h,makeToday as u,makeDateString as d,convertIntervalToSql as c,combine as p,scanForField as f}from"../support/sqlUtils.js";import{resolve as g,reject as _}from"../../../core/promiseUtils.js";import{WhereClause as N}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";class m{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class w extends m{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class v extends m{constructor(e,t,r){super(a(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:n(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class C extends m{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,i.Standardised,this.field.name,this.codefield instanceof N?o(this.codefield,i.Standardised):this.codefield,e.parameters);return r.indexOf(C.BADNESS)>=0?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:N.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,s=null,a){let i,l,n,o;switch(e.type){case"interval":return c(this.evaluateNodeToWhereClause(e.value,t,r,s,a),e.qualifier,e.op);case"case_expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,C.BADNESS,a));for(let i=0;i<e.clauses.length;i++)s+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[i].operand,t,r,C.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[i].value,t,r,C.BADNESS,a);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,C.BADNESS,a)),s+=" END ",s}case"param":{const r=a[e.value.toLowerCase()];if("string"==typeof r){return"'"+a[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return d(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(d(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expr_list":l=[];for(const i of e.value)l.push(this.evaluateNodeToWhereClause(i,t,r,s,a));return l;case"unary_expr":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,C.BADNESS,a)+" ) ";case"binary_expr":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NOT NULL )";case"IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o+")) ";case"NOT IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o+")) ";case"BETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"NOTBETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<>":case"=":if("column_ref"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column_ref"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") "}throw new Error("Not Supported Operator "+e.operator);case"null":return"null";case"bool":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return d(e.value,t);case"number":return e.value.toString();case"current_time":return u("date"===e.mode,t);case"column_ref":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":e.column;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,C.BADNESS,a);return h(e.name,s,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof N?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}C.BADNESS="_!!!_BAD_LKP_!!!!";class T extends m{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:n(e,this.field.name,o(this.sql,i.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class E extends r{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new S({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new s(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):g(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(r,a,i,l){const n=[];-1!==a&&void 0===this._featureCache[a]&&n.push(a);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return this._expandPagedSet(r,o,0,0,l).then((()=>this._getFeatures(r,a,i,l)));let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=i&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==a&&n.push(r._known[e]),n.length>=o)));e++);if(0===n.length)return g("success");r=new s([],n,r._ordered,null);const u=Math.min(n.length,i);return this._parent._getFeatures(r,-1,u,l).then((()=>{this._checkCancelled(l);const r=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&r.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(const s of r){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(s);this._featureCache[s.id]=new e({attributes:r,geometry:t(s.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return _(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,a,i){let l=!1;const n=this._reformulateWithoutAdaptions(r);l=n.cannot,r=n.where;let o=!1;if(null!==a){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof w)&&!0===a.scanForField(t.field.name)){if(!(t instanceof v)){a=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}a&&e.length>0&&(a=a.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=p(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,a,i))).then((e=>{let t;return this._checkCancelled(i),t=!0===l?new s(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s(e._candidates.slice(0),e._known.slice(0),!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===f(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}_stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);return n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,!0===n?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):g({calculated:!1}):this._parent._stat(e,t,r,s,a,i,l).then((n=>!1===n.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:n))}_canDoAggregates(e,t,r,s,a){if(null===this._parent)return g(!1);for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof w))return g(!1);const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return g(!1);const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return l.cannot?g(!1):(null!==(a=l.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}_getAggregatePagesDataSourceDefinition(e,t,r,s,a,i,l){if(null===this._parent)return _(new Error("Should never be called"));const n=[];for(let h=0;h<t.length;h++){const e=t[h];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return _(new Error("Should never be called"));const r=e.clone();r.workingexpr=t.where,n.push(r)}else n.push(e)}const o=this._reformulateWithoutAdaptions(a);return o.cannot?_(new Error("Should never be called")):(null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,n,r,s,a,i,l))}}export{E as AdaptedFeatureSet,m as AdaptedField,v as FieldRename,w as OriginalField,T as SqlExpressionAdapted,C as StringToCodeAdapted};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{U as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as h}from"../support/shared.js";import{isSingleField as c,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{resolve as I,reject as S,create as x}from"../../../core/promiseUtils.js";import{WhereClause as k}from"../../../core/sql/WhereClause.js";import D from"../../../geometry/SpatialReference.js";import A from"../../../layers/support/Field.js";import j from"../../../layers/support/FieldsIndex.js";function C(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class G extends l{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_getSet(e){return null===this._wset?this._getFilteredSet("",null,null,null,e).then((e=>(this._wset=e,this._wset))):I(this._wset)}_isInFeatureSet(){return u.InFeatureSet}nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new j([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof k?i.expression:k.create(i.expression,r),e.typeofstat=C(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof k?i.expression:k.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new D({wkid:4326});this.fields=[];const a=new b;a.field=this.nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=k.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new A;if(s.name=this.nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,c(s.expression)){const e=this._parent.getField(p(s.expression,h.Standardised));if(!e)throw new Error("Field is not present for Aggregation");s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this.convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new A;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new A;let s=null;const n=this._decodedStatsfield[i];n.field=this.nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&c(n.workingexpr)?p(n.workingexpr,h.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new Error("Field is not present for Aggregation");t.type="double"}this.fields.push(t)}}_canDoAggregates(){return I(!1)}_getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?this._expandPagedSet(e,n,0,0,s).then((()=>this._getFeatures(e,t,i,s))):I("success")}_getFilteredSet(e,t,i,s,l){if(""!==e)return I(new o([],[],!0,null));let u=null;const f={ordered:!1,nowhereclause:!1};return this._ensureLoaded().then((()=>{if(null!==i)for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===_(i,this._decodedStatsfield[e].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}return!1===this._candosimplegroupby?I(!1):this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)})).then((e=>{if(e){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;return s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s)),this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField).then((e=>(this._checkCancelled(l),u=!0===f.nowhereclause?new o(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===f.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new o(e._candidates.slice(0),e._known.slice(0),!0===f.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),u)))}let t=this._parent;if(this._adaptedFields.length>0&&(t=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:t,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=t;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}))}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,h.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,h.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}_refineSetBlock(e,t,i){try{if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return this._expandPagedSet(e,this._maxQuery,0,0,i).then((()=>this._refineSetBlock(e,t,i)));this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,I(e)}catch(s){return S(s)}}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}_getPhysicalPage(t,i,s){return!0===t.pagesDefinition.aggregatefeaturesetpagedefinition?x(((e,i)=>{this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]).then((t=>{e(t)}),i)})):this._getAgregagtePhysicalPage(t,i,s).then((t=>{for(const i of t){const t={geometry:i.geometry,attributes:{}};for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i.attributes[e.name];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i.attributes[e.field];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return t.length}))}_sequentialGetPhysicalItem(e,t,i,s){return x(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const l=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:l},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(l){a(l)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}_stat(){return I({calculated:!1})}getFeatureByObjectId(){return I(null)}static registerAction(){l._featuresetFunctions.groupby=function(e,t){return new G({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{G as default};
|
|
5
|
+
import e from"../../../Graphic.js";import{U as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as h}from"../support/shared.js";import{isSingleField as c,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{resolve as I,reject as S,create as x}from"../../../core/promiseUtils.js";import{WhereClause as k}from"../../../core/sql/WhereClause.js";import D from"../../../geometry/SpatialReference.js";import A from"../../../layers/support/Field.js";import j from"../../../layers/support/FieldsIndex.js";function C(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class G extends l{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_getSet(e){return null===this._wset?this._getFilteredSet("",null,null,null,e).then((e=>(this._wset=e,this._wset))):I(this._wset)}_isInFeatureSet(){return u.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new j([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof k?i.expression:k.create(i.expression,r),e.typeofstat=C(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof k?i.expression:k.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new D({wkid:4326});this.fields=[];const a=new b;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=k.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new A;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,c(s.expression)){const e=this._parent.getField(p(s.expression,h.Standardised));if(!e)throw new Error("Field is not present for Aggregation");s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new A;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new A;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&c(n.workingexpr)?p(n.workingexpr,h.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new Error("Field is not present for Aggregation");t.type="double"}this.fields.push(t)}}_canDoAggregates(){return I(!1)}_getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?this._expandPagedSet(e,n,0,0,s).then((()=>this._getFeatures(e,t,i,s))):I("success")}_getFilteredSet(e,t,i,s,l){if(""!==e)return I(new o([],[],!0,null));let u=null;const f={ordered:!1,nowhereclause:!1};return this._ensureLoaded().then((()=>{if(null!==i)for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===_(i,this._decodedStatsfield[e].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}return!1===this._candosimplegroupby?I(!1):this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)})).then((e=>{if(e){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;return s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s)),this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField).then((e=>(this._checkCancelled(l),u=!0===f.nowhereclause?new o(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===f.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new o(e._candidates.slice(0),e._known.slice(0),!0===f.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),u)))}let t=this._parent;if(this._adaptedFields.length>0&&(t=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:t,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=t;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}))}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,h.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,h.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}_refineSetBlock(e,t,i){try{if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return this._expandPagedSet(e,this._maxQuery,0,0,i).then((()=>this._refineSetBlock(e,t,i)));this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,I(e)}catch(s){return S(s)}}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}_getPhysicalPage(t,i,s){return!0===t.pagesDefinition.aggregatefeaturesetpagedefinition?x(((e,i)=>{this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]).then((t=>{e(t)}),i)})):this._getAgregagtePhysicalPage(t,i,s).then((t=>{for(const i of t){const t={geometry:i.geometry,attributes:{}};for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i.attributes[e.name];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i.attributes[e.field];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return t.length}))}_sequentialGetPhysicalItem(e,t,i,s){return x(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const l=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:l},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(l){a(l)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}_stat(){return I({calculated:!1})}getFeatureByObjectId(){return I(null)}static registerAction(){l._featuresetFunctions.groupby=function(e,t){return new G({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{G as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../Dictionary.js";import{d as t,f as r,j as n,t as s,a,b as i}from"../../chunks/languageUtils.js";const c=e=>(t,r,n)=>(n=n||14,+e(t,r).toFixed(n)),o=(e,t)=>e+t,d=(e,t)=>e-t,u=(e,t)=>e*t,_=(e,t)=>e/t,m=(e,t,r)=>c(o)(e,t,r),l=(e,t,r)=>c(d)(e,t,r),h=(e,t,r)=>c(u)(e,t,r),g=(e,t,r)=>c(_)(e,t,r),f=360,w=400,E=2*Math.PI,p=3600,D=3240,A=60,S=60,R=180*p/Math.PI,T=f*A*S,M=90*p,v=180*p,F=270*p,I=String.fromCharCode(7501),U="°";function x(e){if(!1===r(e))throw new Error("Invalid Parameter");return e}function O(e,t){const r=10**t;return Math.round(e*r)/r}function z(e,t){return e%t}function G(e){const t=parseFloat(e.toString().replace(Math.trunc(e).toString(),"0"))*Math.sign(e);if(e<0){return{fraction:t,integer:Math.ceil(e)}}return{fraction:t,integer:Math.floor(e)}}var N,b,H,C;function q(e,t){switch(e){case N.north:return"SHORT"===t?"N":"North";case N.east:return"SHORT"===t?"E":"East";case N.south:return"SHORT"===t?"S":"South";case N.west:return"SHORT"===t?"W":"West"}}function y(e,t,r){for(;e.length<r;)e=t+e;return e}function P(e,t){return e-Math.floor(e/t)*t}function k(e){switch(e){case b.truncated_degrees:case b.decimal_degrees:return f;case b.radians:return E;case b.gradians:return w;case b.seconds:return T;case b.fractional_degree_minutes:return A;case b.fractional_minute_seconds:return S;default:throw new Error("Unnexpected evaluations")}}function L(e){switch(e.toUpperCase().trim()){case"NORTH":case"NORTHAZIMUTH":case"NORTH AZIMUTH":return H.north_azimuth;case"POLAR":return H.polar;case"QUADRANT":return H.quadrant;case"SOUTH":case"SOUTHAZIMUTH":case"SOUTH AZIMUTH":return H.south_azimuth}throw new Error("Unsupported direction type")}function W(e){switch(e.toUpperCase().trim()){case"D":case"DD":case"DECIMALDEGREE":case"DECIMAL DEGREE":case"DEGREE":case"DECIMALDEGREES":case"DECIMAL DEGREES":case"DEGREES":return b.decimal_degrees;case"DMS":case"DEGREESMINUTESSECONDS":case"DEGREES MINUTES SECONDS":return b.degrees_minutes_seconds;case"R":case"RAD":case"RADS":case"RADIAN":case"RADIANS":return b.radians;case"G":case"GON":case"GONS":case"GRAD":case"GRADS":case"GRADIAN":case"GRADIANS":return b.gradians}throw new Error("Unsupported units")}!function(e){e[e.north=0]="north",e[e.east=1]="east",e[e.south=2]="south",e[e.west=3]="west"}(N||(N={})),function(e){e[e.decimal_degrees=1]="decimal_degrees",e[e.seconds=2]="seconds",e[e.degrees_minutes_seconds=3]="degrees_minutes_seconds",e[e.radians=4]="radians",e[e.gradians=5]="gradians",e[e.truncated_degrees=6]="truncated_degrees",e[e.fractional_degree_minutes=7]="fractional_degree_minutes",e[e.fractional_minute_seconds=8]="fractional_minute_seconds"}(b||(b={})),function(e){e[e.north_azimuth=1]="north_azimuth",e[e.polar=2]="polar",e[e.quadrant=3]="quadrant",e[e.south_azimuth=4]="south_azimuth"}(H||(H={})),function(e){e[e.meridian=0]="meridian",e[e.direction=1]="direction"}(C||(C={}));class Z{constructor(e,t,r){this.m_degrees=e,this.m_minutes=t,this.m_seconds=r}get_field(e){switch(e){case b.decimal_degrees:case b.truncated_degrees:return this.m_degrees;case b.fractional_degree_minutes:return this.m_minutes;case b.seconds:case b.fractional_minute_seconds:return this.m_seconds;default:throw new Error("Unnexpected evaluation")}}static seconds_to_DMS(e){const t=G(e).fraction;let r=G(e).integer;const n=Math.floor(r/p);r-=n*p;const s=Math.floor(r/S);return r-=s*S,new Z(n,s,r+t)}static number_to_dms(e){const t=G(e).fraction,r=G(e).integer,n=h(G(100*t).fraction,100),s=G(100*t).integer;return new Z(r,s,n)}format(e,t){let r=O(this.m_seconds,t),n=this.m_minutes,s=this.m_degrees;if(e===b.seconds||e===b.fractional_minute_seconds)S<=r&&(r-=S,++n),A<=n&&(n=0,++s),f<=s&&(s=0);else if(e===b.fractional_degree_minutes)r=0,n=30<=this.m_seconds?this.m_minutes+1:this.m_minutes,s=this.m_degrees,A<=n&&(n=0,++s),f<=s&&(s=0);else if(e===b.decimal_degrees||e===b.truncated_degrees){const e=g(this.m_seconds,p),t=g(this.m_minutes,A);s=Math.round(this.m_degrees+t+e),n=0,r=0}return new Z(s,n,r)}static DMS_to_seconds(e,t,r){return e*p+t*S+r}}class j{constructor(e,t,r){this.meridian=e,this.angle=t,this.direction=r}fetch_azimuth(e){return e===C.meridian?this.meridian:this.direction}}class B{constructor(e){this.m_angle=e}static createFromAngleAndDirection(e,t){return new B(new X(B.convertDirectionFormat(e.extract_angular_units(b.seconds),t,H.north_azimuth)))}getAngle(e){const t=this.m_angle.extract_angular_units(b.seconds);switch(e){case H.north_azimuth:case H.south_azimuth:case H.polar:return new X(B.convertDirectionFormat(t,H.north_azimuth,e));case H.quadrant:{const e=B.seconds_north_azimuth_to_quadrant(t);return new X(e.angle)}}}getMeridian(e){const t=this.m_angle.extract_angular_units(b.seconds);switch(e){case H.north_azimuth:return N.north;case H.south_azimuth:return N.south;case H.polar:return N.east;case H.quadrant:return B.seconds_north_azimuth_to_quadrant(t).meridian}}getDirection(e){const t=this.m_angle.extract_angular_units(b.seconds);switch(e){case H.north_azimuth:return N.east;case H.south_azimuth:return N.west;case H.polar:return N.north;case H.quadrant:return B.seconds_north_azimuth_to_quadrant(t).direction}}static seconds_north_azimuth_to_quadrant(e){const t=e<=M||e>=F?N.north:N.south,r=t===N.north?Math.min(T-e,e):Math.abs(e-v),n=e>v?N.west:N.east;return new j(t,r,n)}static createFromAngleMeridianAndDirection(e,t,r){return new B(new X(B.secondsQuadrantToNorthAzimuth(e.extract_angular_units(b.seconds),t,r)))}static secondsQuadrantToNorthAzimuth(e,t,r){return t===N.north?r===N.east?e:T-e:r===N.east?v-e:v+e}static convertDirectionFormat(e,t,r){let n=0;switch(t){case H.north_azimuth:n=e;break;case H.polar:n=M-e;break;case H.quadrant:throw new Error("Unnexpected evaluation");case H.south_azimuth:n=e+v}let s=0;switch(r){case H.north_azimuth:s=n;break;case H.polar:s=M-n;break;case H.quadrant:throw new Error("Unnexpected evaluation");case H.south_azimuth:s=n-v}return s=z(s,T),s<0?T+s:s}}function Q(e,t,r){let n=null;switch(t){case b.decimal_degrees:n=h(e,p);break;case b.seconds:n=e;break;case b.gradians:n=h(e,D);break;case b.radians:n=h(e,R);break;default:throw new Error("Unnexpected evaluation")}switch(r){case b.decimal_degrees:return g(n,p);case b.seconds:return n;case b.gradians:return g(n,D);case b.radians:return n/R;default:throw new Error("Unnexpected evaluation")}}class X{constructor(e){this.m_seconds=e}static createFromAngleAndUnits(e,t){return new X(Q(e,t,b.seconds))}extract_angular_units(e){return Q(this.m_seconds,b.seconds,V(e))}static createFromDegreesMinutesSeconds(e,t,r){return new X(m(m(h(e,p),h(t,S)),r))}}function V(e){switch(e){case b.decimal_degrees:case b.truncated_degrees:case b.degrees_minutes_seconds:return b.decimal_degrees;case b.gradians:return b.gradians;case b.fractional_degree_minutes:return b.fractional_degree_minutes;case b.radians:return b.radians;case b.seconds:case b.fractional_minute_seconds:return b.seconds}}class J{constructor(e,t,r,n){this.m_view=e,this.m_angle=t,this.m_merdian=r,this.m_direction=n,this.m_dms=null,this.m_formatted_dms=null}static createFromStringAndBearing(e,t,r){return new J(e,t.getAngle(r),t.getMeridian(r),t.getDirection(r))}fetch_angle(){return this.m_angle}fetch_meridian(){return this.m_merdian}fetch_direction(){return this.m_direction}fetch_m_view(){return this.m_view}fetch_dms(){return null===this.m_dms&&this.calculate_dms(),this.m_dms}fetch_formatted_dms(){return null===this.m_formatted_dms&&this.calculate_dms(),this.m_formatted_dms}calculate_dms(){let e=null,t=b.truncated_degrees,r=0;for(let n=0;n<this.m_view.length;n++){const s=this.m_view[n];switch(s){case"m":e=oe(this.m_view,n,s),t=t===b.truncated_degrees?b.fractional_degree_minutes:t,n=e.newpos;continue;case"s":e=oe(this.m_view,n,s),t=b.fractional_minute_seconds,r=r<e.rounding?e.rounding:r,n=e.newpos;continue;default:continue}}this.m_dms=Z.seconds_to_DMS(this.m_angle.extract_angular_units(b.seconds)),this.m_formatted_dms=Z.seconds_to_DMS(this.m_angle.extract_angular_units(b.seconds)).format(t,r)}}function K(e,t,r,n,s){let a=null;switch(t){case b.decimal_degrees:case b.radians:case b.gradians:return a=P(O(e.extract_angular_units(t),n),k(t)),y(a.toFixed(n),"0",r+n+(n>0?1:0));case b.truncated_degrees:case b.fractional_degree_minutes:return a=P(s.fetch_formatted_dms().get_field(t),k(t)),y(a.toFixed(n),"0",r+n+(n>0?1:0));case b.fractional_minute_seconds:return a=P(O(s.fetch_dms().get_field(t),n),k(t)),y(a.toFixed(n),"0",r+n+(n>0?1:0));default:throw new Error("Unnexepected evaluation")}}function Y(e,t,r){if(r===H.quadrant)throw new Error("Conversion error");if(t===b.degrees_minutes_seconds){const t=Z.number_to_dms(e);return B.createFromAngleAndDirection(X.createFromDegreesMinutesSeconds(t.m_degrees,t.m_minutes,t.m_seconds),r)}return B.createFromAngleAndDirection(X.createFromAngleAndUnits(e,V(t)),r)}function $(e){switch(s(e)){case 1:return{first:N.north,second:N.east};case 2:return{first:N.south,second:N.east};case 3:return{first:N.south,second:N.west};case 4:return{first:N.north,second:N.west}}return null}function ee(e){switch(e.toUpperCase().trim()){case"N":case"NORTH":return N.north;case"E":case"EAST":return N.east;case"S":case"SOUTH":return N.south;case"W":case"WEST":return N.west}return null}function te(e){const t=parseFloat(e);if(n(t)){if(isNaN(t))throw new Error("Invalid conversion");return t}throw new Error("Invalid conversion")}function re(e,r,n){const s=n===H.quadrant;let a=null,i=null,c=0,o=0,d=0;if(s){if(e.length<2)throw new Error("Conversion Error");d=1;const r=$(t(e[e.length-1]));if(r?(a=r.first,i=r.second):(c=1,a=ee(t(e[0])),i=ee(t(e[e.length-1]))),null===a||null===i)throw new Error("Invalid Conversion")}switch(r){case b.decimal_degrees:case b.radians:case b.gradians:if(0===e.length)throw new Error("Invalid Conversion");return s?B.createFromAngleMeridianAndDirection(X.createFromAngleAndUnits(te(e[c]),V(r)),a,i):B.createFromAngleAndDirection(X.createFromAngleAndUnits(te(e[c]),V(r)),n);case b.degrees_minutes_seconds:if(o=e.length-d-c,3===o){const t=X.createFromDegreesMinutesSeconds(te(e[c]),te(e[c+1]),te(e[c+2]));return s?B.createFromAngleMeridianAndDirection(t,a,i):B.createFromAngleAndDirection(t,n)}if(1===o){const t=te(e[c]),r=Z.number_to_dms(t),o=X.createFromDegreesMinutesSeconds(r.m_degrees,r.m_minutes,r.m_seconds);return s?B.createFromAngleMeridianAndDirection(o,a,i):B.createFromAngleAndDirection(o,n)}}throw new Error("Conversion Error")}function ne(e){const t=[" ","-","/","'",'"',"\\","^",U,I,"\t","\r","\n","*"];let r="";for(let n=0;n<e.length;n++){const s=e.charAt(n);-1!==t.indexOf(s)?r+="RRSPLITRRSPLITRR":r+=s}return r.split("RRSPLITRRSPLITRR").filter((e=>""!==e))}function se(e,t,c){if(n(e))return Y(s(e),t,c);if(r(e))return re(ne(e),t,c);if(a(e))return re(e,t,c);if(i(e))return re(e.toArray(),t,c);throw new Error("Conversion Error")}function ae(e,t,r){const n=V(r);if(n&&r!==b.degrees_minutes_seconds){return e.getAngle(t).extract_angular_units(n)}throw new Error("Conversion Error")}function ie(e,t,r){const n=e.getAngle(t);if(t===H.quadrant&&r===b.degrees_minutes_seconds){const r=Z.seconds_to_DMS(n.extract_angular_units(b.seconds));return[q(e.getMeridian(t),"SHORT"),r.m_degrees,r.m_minutes,r.m_seconds,q(e.getDirection(t),"SHORT")]}if(r===b.degrees_minutes_seconds){const e=Z.seconds_to_DMS(n.extract_angular_units(b.seconds));return[e.m_degrees,e.m_minutes,e.m_seconds]}return t===H.quadrant?[q(e.getMeridian(t),"SHORT"),n.extract_angular_units(r),q(e.getDirection(t),"SHORT")]:[n.extract_angular_units(r)]}function ce(e,t){let r="";switch(e){case b.decimal_degrees:r=t===H.quadrant?"DD.DD"+U:"DDD.DD"+U;break;case b.degrees_minutes_seconds:r=t===H.quadrant?"dd"+U+" mm' ss\"":"ddd"+U+" mm' ss.ss\"";break;case b.radians:r="R.RR";break;case b.gradians:r="GGG.GG"+I;break;default:throw new Error("Conversion error")}return t===H.quadrant&&(r="p "+r+" b"),r}function oe(e,t,r){const n={padding:0,rounding:0,newpos:t};let s=!1;for(;t<e.length;){const a=e[t];if(a===r)s?n.rounding++:n.padding++,t++;else{if("."!==a)break;s=!0,t++}}return n.newpos=t-1,n}function de(e,t,r){const n={escaped:"",newpos:t};for(t++;t<e.length;){const r=e[t];if(t++,"]"===r)break;n.escaped+=r}return n.newpos=t-1,n}function ue(e,t,r){let n="",s=null,a=null;const i=J.createFromStringAndBearing(t,e,r),c={D:b.decimal_degrees,d:b.truncated_degrees,m:b.fractional_degree_minutes,s:b.fractional_minute_seconds,R:b.radians,G:b.gradians};for(let o=0;o<t.length;o++){const d=t[o];switch(d){case"[":s=de(t,o),n+=s.escaped,o=s.newpos;continue;case"D":case"d":case"m":case"s":case"R":case"G":s=oe(t,o,d),a=e.getAngle(r),n+=K(a,c[d],s.padding,s.rounding,i),o=s.newpos;continue;case"P":case"p":n+=q(i.fetch_meridian(),"p"===d?"SHORT":"LONG");continue;case"B":case"b":n+=q(i.fetch_direction(),"b"===d?"SHORT":"LONG");continue;default:n+=d}}return n}function _e(r,n,s){if(!(n instanceof e))throw new Error("Invalid Parameter");if(!1===n.hasField("directionType"))throw new Error("Invalid Parameter - Missing directionType");if(!1===n.hasField("angleType"))throw new Error("Invalid Parameter - Missing directionType");const a=L(x(n.field("directiontype"))),i=se(r,W(x(n.field("angletype"))),a);if(!(s instanceof e))throw new Error("Invalid Parameter");if(!1===s.hasField("directionType"))throw new Error("Invalid Parameter - Missing directionType");if(!1===s.hasField("outputType"))throw new Error("Invalid Parameter - Missing directionType");const c=L(x(s.field("directiontype"))),o=s.hasField("angleType")?W(x(s.field("angletype"))):null,d=x(s.field("outputType")).toUpperCase().trim();if(!c||!d)throw new Error("Conversion error");if(!(o||"TEXT"===d&&s.hasField("format")))throw new Error("Invalid unit");switch(d){case"VALUE":return c===H.quadrant||o===b.degrees_minutes_seconds?ie(i,c,o):ae(i,c,o);case"TEXT":{let e="";return s.hasField("format")&&(e=t(s.field("format"))),null!==e&&""!==e||(e=ce(o,c)),ue(i,e,c)}default:throw new Error("Invalid Parameter")}}export{_e as convertDirection,m as preciseAdd,g as preciseDivide,l as preciseMinus,h as preciseMultiply};
|
|
5
|
+
import e from"../Dictionary.js";import{d as t,f as r,j as n,t as s,a,b as i}from"../../chunks/languageUtils.js";const c=e=>(t,r,n)=>(n=n||14,+e(t,r).toFixed(n)),o=(e,t)=>e+t,d=(e,t)=>e-t,u=(e,t)=>e*t,m=(e,t)=>e/t,l=(e,t,r)=>c(o)(e,t,r),h=(e,t,r)=>c(d)(e,t,r),g=(e,t,r)=>c(u)(e,t,r),_=(e,t,r)=>c(m)(e,t,r),f=360,w=400,A=2*Math.PI,D=3600,E=3240,p=60,T=60,S=180*D/Math.PI,R=f*p*T,M=90*D,U=180*D,v=270*D,F=String.fromCharCode(7501),I="°";function N(e){if(!1===r(e))throw new Error("Invalid Parameter");return e}function x(e,t){const r=10**t;return Math.round(e*r)/r}function O(e,t){return e%t}function z(e){const t=parseFloat(e.toString().replace(Math.trunc(e).toString(),"0"))*Math.sign(e);if(e<0){return{fraction:t,integer:Math.ceil(e)}}return{fraction:t,integer:Math.floor(e)}}var G,b,H,C;function y(e,t){switch(e){case G.north:return"SHORT"===t?"N":"North";case G.east:return"SHORT"===t?"E":"East";case G.south:return"SHORT"===t?"S":"South";case G.west:return"SHORT"===t?"W":"West"}}function q(e,t,r){for(;e.length<r;)e=t+e;return e}function P(e,t){return e-Math.floor(e/t)*t}function k(e){switch(e){case b.truncated_degrees:case b.decimal_degrees:return f;case b.radians:return A;case b.gradians:return w;case b.seconds:return R;case b.fractional_degree_minutes:return p;case b.fractional_minute_seconds:return T;default:throw new Error("Unnexpected evaluations")}}function L(e){switch(e.toUpperCase().trim()){case"NORTH":case"NORTHAZIMUTH":case"NORTH AZIMUTH":return H.north_azimuth;case"POLAR":return H.polar;case"QUADRANT":return H.quadrant;case"SOUTH":case"SOUTHAZIMUTH":case"SOUTH AZIMUTH":return H.south_azimuth}throw new Error("Unsupported direction type")}function Q(e){switch(e.toUpperCase().trim()){case"D":case"DD":case"DECIMALDEGREE":case"DECIMAL DEGREE":case"DEGREE":case"DECIMALDEGREES":case"DECIMAL DEGREES":case"DEGREES":return b.decimal_degrees;case"DMS":case"DEGREESMINUTESSECONDS":case"DEGREES MINUTES SECONDS":return b.degrees_minutes_seconds;case"R":case"RAD":case"RADS":case"RADIAN":case"RADIANS":return b.radians;case"G":case"GON":case"GONS":case"GRAD":case"GRADS":case"GRADIAN":case"GRADIANS":return b.gradians}throw new Error("Unsupported units")}!function(e){e[e.north=0]="north",e[e.east=1]="east",e[e.south=2]="south",e[e.west=3]="west"}(G||(G={})),function(e){e[e.decimal_degrees=1]="decimal_degrees",e[e.seconds=2]="seconds",e[e.degrees_minutes_seconds=3]="degrees_minutes_seconds",e[e.radians=4]="radians",e[e.gradians=5]="gradians",e[e.truncated_degrees=6]="truncated_degrees",e[e.fractional_degree_minutes=7]="fractional_degree_minutes",e[e.fractional_minute_seconds=8]="fractional_minute_seconds"}(b||(b={})),function(e){e[e.north_azimuth=1]="north_azimuth",e[e.polar=2]="polar",e[e.quadrant=3]="quadrant",e[e.south_azimuth=4]="south_azimuth"}(H||(H={})),function(e){e[e.meridian=0]="meridian",e[e.direction=1]="direction"}(C||(C={}));class W{constructor(e,t,r){this.m_degrees=e,this.m_minutes=t,this.m_seconds=r}getField(e){switch(e){case b.decimal_degrees:case b.truncated_degrees:return this.m_degrees;case b.fractional_degree_minutes:return this.m_minutes;case b.seconds:case b.fractional_minute_seconds:return this.m_seconds;default:throw new Error("Unnexpected evaluation")}}static secondsToDMS(e){const t=z(e).fraction;let r=z(e).integer;const n=Math.floor(r/D);r-=n*D;const s=Math.floor(r/T);return r-=s*T,new W(n,s,r+t)}static numberToDms(e){const t=z(e).fraction,r=z(e).integer,n=g(z(100*t).fraction,100),s=z(100*t).integer;return new W(r,s,n)}format(e,t){let r=x(this.m_seconds,t),n=this.m_minutes,s=this.m_degrees;if(e===b.seconds||e===b.fractional_minute_seconds)T<=r&&(r-=T,++n),p<=n&&(n=0,++s),f<=s&&(s=0);else if(e===b.fractional_degree_minutes)r=0,n=30<=this.m_seconds?this.m_minutes+1:this.m_minutes,s=this.m_degrees,p<=n&&(n=0,++s),f<=s&&(s=0);else if(e===b.decimal_degrees||e===b.truncated_degrees){const e=_(this.m_seconds,D),t=_(this.m_minutes,p);s=Math.round(this.m_degrees+t+e),n=0,r=0}return new W(s,n,r)}static dmsToSeconds(e,t,r){return e*D+t*T+r}}class Z{constructor(e,t,r){this.meridian=e,this.angle=t,this.direction=r}fetchAzimuth(e){return e===C.meridian?this.meridian:this.direction}}class j{constructor(e){this.m_angle=e}static createFromAngleAndDirection(e,t){return new j(new V(j._convertDirectionFormat(e.extractAngularUnits(b.seconds),t,H.north_azimuth)))}getAngle(e){const t=this.m_angle.extractAngularUnits(b.seconds);switch(e){case H.north_azimuth:case H.south_azimuth:case H.polar:return new V(j._convertDirectionFormat(t,H.north_azimuth,e));case H.quadrant:{const e=j.secondsNorthAzimuthToQuadrant(t);return new V(e.angle)}}}getMeridian(e){const t=this.m_angle.extractAngularUnits(b.seconds);switch(e){case H.north_azimuth:return G.north;case H.south_azimuth:return G.south;case H.polar:return G.east;case H.quadrant:return j.secondsNorthAzimuthToQuadrant(t).meridian}}getDirection(e){const t=this.m_angle.extractAngularUnits(b.seconds);switch(e){case H.north_azimuth:return G.east;case H.south_azimuth:return G.west;case H.polar:return G.north;case H.quadrant:return j.secondsNorthAzimuthToQuadrant(t).direction}}static secondsNorthAzimuthToQuadrant(e){const t=e<=M||e>=v?G.north:G.south,r=t===G.north?Math.min(R-e,e):Math.abs(e-U),n=e>U?G.west:G.east;return new Z(t,r,n)}static createFromAngleMeridianAndDirection(e,t,r){return new j(new V(j.secondsQuadrantToNorthAzimuth(e.extractAngularUnits(b.seconds),t,r)))}static secondsQuadrantToNorthAzimuth(e,t,r){return t===G.north?r===G.east?e:R-e:r===G.east?U-e:U+e}static _convertDirectionFormat(e,t,r){let n=0;switch(t){case H.north_azimuth:n=e;break;case H.polar:n=M-e;break;case H.quadrant:throw new Error("Unnexpected evaluation");case H.south_azimuth:n=e+U}let s=0;switch(r){case H.north_azimuth:s=n;break;case H.polar:s=M-n;break;case H.quadrant:throw new Error("Unnexpected evaluation");case H.south_azimuth:s=n-U}return s=O(s,R),s<0?R+s:s}}function B(e,t,r){let n=null;switch(t){case b.decimal_degrees:n=g(e,D);break;case b.seconds:n=e;break;case b.gradians:n=g(e,E);break;case b.radians:n=g(e,S);break;default:throw new Error("Unnexpected evaluation")}switch(r){case b.decimal_degrees:return _(n,D);case b.seconds:return n;case b.gradians:return _(n,E);case b.radians:return n/S;default:throw new Error("Unnexpected evaluation")}}class V{constructor(e){this.m_seconds=e}static createFromAngleAndUnits(e,t){return new V(B(e,t,b.seconds))}extractAngularUnits(e){return B(this.m_seconds,b.seconds,X(e))}static createFromDegreesMinutesSeconds(e,t,r){return new V(l(l(g(e,D),g(t,T)),r))}}function X(e){switch(e){case b.decimal_degrees:case b.truncated_degrees:case b.degrees_minutes_seconds:return b.decimal_degrees;case b.gradians:return b.gradians;case b.fractional_degree_minutes:return b.fractional_degree_minutes;case b.radians:return b.radians;case b.seconds:case b.fractional_minute_seconds:return b.seconds}}class J{constructor(e,t,r,n){this.m_view=e,this.m_angle=t,this.m_merdian=r,this.m_direction=n,this.m_dms=null,this.m_formatted_dms=null}static createFromStringAndBearing(e,t,r){return new J(e,t.getAngle(r),t.getMeridian(r),t.getDirection(r))}fetchAngle(){return this.m_angle}fetchMeridian(){return this.m_merdian}fetchDirection(){return this.m_direction}fetchView(){return this.m_view}fetchDms(){return null===this.m_dms&&this._calculateDms(),this.m_dms}fetchFormattedDms(){return null===this.m_formatted_dms&&this._calculateDms(),this.m_formatted_dms}_calculateDms(){let e=null,t=b.truncated_degrees,r=0;for(let n=0;n<this.m_view.length;n++){const s=this.m_view[n];switch(s){case"m":e=oe(this.m_view,n,s),t=t===b.truncated_degrees?b.fractional_degree_minutes:t,n=e.newpos;continue;case"s":e=oe(this.m_view,n,s),t=b.fractional_minute_seconds,r=r<e.rounding?e.rounding:r,n=e.newpos;continue;default:continue}}this.m_dms=W.secondsToDMS(this.m_angle.extractAngularUnits(b.seconds)),this.m_formatted_dms=W.secondsToDMS(this.m_angle.extractAngularUnits(b.seconds)).format(t,r)}}function K(e,t,r,n,s){let a=null;switch(t){case b.decimal_degrees:case b.radians:case b.gradians:return a=P(x(e.extractAngularUnits(t),n),k(t)),q(a.toFixed(n),"0",r+n+(n>0?1:0));case b.truncated_degrees:case b.fractional_degree_minutes:return a=P(s.fetchFormattedDms().getField(t),k(t)),q(a.toFixed(n),"0",r+n+(n>0?1:0));case b.fractional_minute_seconds:return a=P(x(s.fetchDms().getField(t),n),k(t)),q(a.toFixed(n),"0",r+n+(n>0?1:0));default:throw new Error("Unnexepected evaluation")}}function Y(e,t,r){if(r===H.quadrant)throw new Error("Conversion error");if(t===b.degrees_minutes_seconds){const t=W.numberToDms(e);return j.createFromAngleAndDirection(V.createFromDegreesMinutesSeconds(t.m_degrees,t.m_minutes,t.m_seconds),r)}return j.createFromAngleAndDirection(V.createFromAngleAndUnits(e,X(t)),r)}function $(e){switch(s(e)){case 1:return{first:G.north,second:G.east};case 2:return{first:G.south,second:G.east};case 3:return{first:G.south,second:G.west};case 4:return{first:G.north,second:G.west}}return null}function ee(e){switch(e.toUpperCase().trim()){case"N":case"NORTH":return G.north;case"E":case"EAST":return G.east;case"S":case"SOUTH":return G.south;case"W":case"WEST":return G.west}return null}function te(e){const t=parseFloat(e);if(n(t)){if(isNaN(t))throw new Error("Invalid conversion");return t}throw new Error("Invalid conversion")}function re(e,r,n){const s=n===H.quadrant;let a=null,i=null,c=0,o=0,d=0;if(s){if(e.length<2)throw new Error("Conversion Error");d=1;const r=$(t(e[e.length-1]));if(r?(a=r.first,i=r.second):(c=1,a=ee(t(e[0])),i=ee(t(e[e.length-1]))),null===a||null===i)throw new Error("Invalid Conversion")}switch(r){case b.decimal_degrees:case b.radians:case b.gradians:if(0===e.length)throw new Error("Invalid Conversion");return s?j.createFromAngleMeridianAndDirection(V.createFromAngleAndUnits(te(e[c]),X(r)),a,i):j.createFromAngleAndDirection(V.createFromAngleAndUnits(te(e[c]),X(r)),n);case b.degrees_minutes_seconds:if(o=e.length-d-c,3===o){const t=V.createFromDegreesMinutesSeconds(te(e[c]),te(e[c+1]),te(e[c+2]));return s?j.createFromAngleMeridianAndDirection(t,a,i):j.createFromAngleAndDirection(t,n)}if(1===o){const t=te(e[c]),r=W.numberToDms(t),o=V.createFromDegreesMinutesSeconds(r.m_degrees,r.m_minutes,r.m_seconds);return s?j.createFromAngleMeridianAndDirection(o,a,i):j.createFromAngleAndDirection(o,n)}}throw new Error("Conversion Error")}function ne(e){const t=[" ","-","/","'",'"',"\\","^",I,F,"\t","\r","\n","*"];let r="";for(let n=0;n<e.length;n++){const s=e.charAt(n);-1!==t.indexOf(s)?r+="RRSPLITRRSPLITRR":r+=s}return r.split("RRSPLITRRSPLITRR").filter((e=>""!==e))}function se(e,t,c){if(n(e))return Y(s(e),t,c);if(r(e))return re(ne(e),t,c);if(a(e))return re(e,t,c);if(i(e))return re(e.toArray(),t,c);throw new Error("Conversion Error")}function ae(e,t,r){const n=X(r);if(n&&r!==b.degrees_minutes_seconds){return e.getAngle(t).extractAngularUnits(n)}throw new Error("Conversion Error")}function ie(e,t,r){const n=e.getAngle(t);if(t===H.quadrant&&r===b.degrees_minutes_seconds){const r=W.secondsToDMS(n.extractAngularUnits(b.seconds));return[y(e.getMeridian(t),"SHORT"),r.m_degrees,r.m_minutes,r.m_seconds,y(e.getDirection(t),"SHORT")]}if(r===b.degrees_minutes_seconds){const e=W.secondsToDMS(n.extractAngularUnits(b.seconds));return[e.m_degrees,e.m_minutes,e.m_seconds]}return t===H.quadrant?[y(e.getMeridian(t),"SHORT"),n.extractAngularUnits(r),y(e.getDirection(t),"SHORT")]:[n.extractAngularUnits(r)]}function ce(e,t){let r="";switch(e){case b.decimal_degrees:r=t===H.quadrant?"DD.DD"+I:"DDD.DD"+I;break;case b.degrees_minutes_seconds:r=t===H.quadrant?"dd"+I+" mm' ss\"":"ddd"+I+" mm' ss.ss\"";break;case b.radians:r="R.RR";break;case b.gradians:r="GGG.GG"+F;break;default:throw new Error("Conversion error")}return t===H.quadrant&&(r="p "+r+" b"),r}function oe(e,t,r){const n={padding:0,rounding:0,newpos:t};let s=!1;for(;t<e.length;){const a=e[t];if(a===r)s?n.rounding++:n.padding++,t++;else{if("."!==a)break;s=!0,t++}}return n.newpos=t-1,n}function de(e,t,r){const n={escaped:"",newpos:t};for(t++;t<e.length;){const r=e[t];if(t++,"]"===r)break;n.escaped+=r}return n.newpos=t-1,n}function ue(e,t,r){let n="",s=null,a=null;const i=J.createFromStringAndBearing(t,e,r),c={D:b.decimal_degrees,d:b.truncated_degrees,m:b.fractional_degree_minutes,s:b.fractional_minute_seconds,R:b.radians,G:b.gradians};for(let o=0;o<t.length;o++){const d=t[o];switch(d){case"[":s=de(t,o),n+=s.escaped,o=s.newpos;continue;case"D":case"d":case"m":case"s":case"R":case"G":s=oe(t,o,d),a=e.getAngle(r),n+=K(a,c[d],s.padding,s.rounding,i),o=s.newpos;continue;case"P":case"p":n+=y(i.fetchMeridian(),"p"===d?"SHORT":"LONG");continue;case"B":case"b":n+=y(i.fetchDirection(),"b"===d?"SHORT":"LONG");continue;default:n+=d}}return n}function me(r,n,s){if(!(n instanceof e))throw new Error("Invalid Parameter");if(!1===n.hasField("directionType"))throw new Error("Invalid Parameter - Missing directionType");if(!1===n.hasField("angleType"))throw new Error("Invalid Parameter - Missing directionType");const a=L(N(n.field("directiontype"))),i=se(r,Q(N(n.field("angletype"))),a);if(!(s instanceof e))throw new Error("Invalid Parameter");if(!1===s.hasField("directionType"))throw new Error("Invalid Parameter - Missing directionType");if(!1===s.hasField("outputType"))throw new Error("Invalid Parameter - Missing directionType");const c=L(N(s.field("directiontype"))),o=s.hasField("angleType")?Q(N(s.field("angletype"))):null,d=N(s.field("outputType")).toUpperCase().trim();if(!c||!d)throw new Error("Conversion error");if(!(o||"TEXT"===d&&s.hasField("format")))throw new Error("Invalid unit");switch(d){case"VALUE":return c===H.quadrant||o===b.degrees_minutes_seconds?ie(i,c,o):ae(i,c,o);case"TEXT":{let e="";return s.hasField("format")&&(e=t(s.field("format"))),null!==e&&""!==e||(e=ce(o,c)),ue(i,e,c)}default:throw new Error("Invalid Parameter")}}export{me as convertDirection,l as preciseAdd,_ as preciseDivide,h as preciseMinus,g as preciseMultiply};
|
package/arcade/functions/hash.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const t=2654435761,s=2246822519,n=3266489917,e=668265263,r=374761393;function h(t){const s=[];for(let n=0,e=t.length;n<e;n++){let e=t.charCodeAt(n);e<128?s.push(e):e<2048?s.push(192|e>>6,128|63&e):e<55296||e>=57344?s.push(224|e>>12,128|e>>6&63,128|63&e):(n++,e=65536+((1023&e)<<10|1023&t.charCodeAt(n)),s.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e))}return new Uint8Array(s)}class i{constructor(t){this.seed=t,this.totallen=0,this.bufs=[],this.init()}init(){return this.bufs=[],this.totallen=0,this}updateFloatArray(t){const s=[];for(const n of t)isNaN(n)?s.push("NaN"):n===1/0?s.push("Infinity"):n===-1/0?s.push("-Infinity"):0===n?s.push("0"):s.push(n.toString(16));this.update(h(s.join("")))}updateIntArray(t){const s=Int32Array.from(t);this.update(new Uint8Array(s.buffer))}updateUint8Array(t){this.update(Uint8Array.from(t))}updateWithString(t){return this.update(h(t))}update(t){return this.bufs.push(t),this.totallen+=t.length,this}digest(){const t=new Uint8Array(this.totallen);let s=0;for(const n of this.bufs)t.set(n,s),s+=n.length;return this.init(),this.
|
|
5
|
+
const t=2654435761,s=2246822519,n=3266489917,e=668265263,r=374761393;function h(t){const s=[];for(let n=0,e=t.length;n<e;n++){let e=t.charCodeAt(n);e<128?s.push(e):e<2048?s.push(192|e>>6,128|63&e):e<55296||e>=57344?s.push(224|e>>12,128|e>>6&63,128|63&e):(n++,e=65536+((1023&e)<<10|1023&t.charCodeAt(n)),s.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e))}return new Uint8Array(s)}class i{constructor(t){this.seed=t,this.totallen=0,this.bufs=[],this.init()}init(){return this.bufs=[],this.totallen=0,this}updateFloatArray(t){const s=[];for(const n of t)isNaN(n)?s.push("NaN"):n===1/0?s.push("Infinity"):n===-1/0?s.push("-Infinity"):0===n?s.push("0"):s.push(n.toString(16));this.update(h(s.join("")))}updateIntArray(t){const s=Int32Array.from(t);this.update(new Uint8Array(s.buffer))}updateUint8Array(t){this.update(Uint8Array.from(t))}updateWithString(t){return this.update(h(t))}update(t){return this.bufs.push(t),this.totallen+=t.length,this}digest(){const t=new Uint8Array(this.totallen);let s=0;for(const n of this.bufs)t.set(n,s),s+=n.length;return this.init(),this._xxHash32(t,this.seed)}_xxHash32(h,i=0){const o=h;let u=i+r&4294967295,a=0;if(o.length>=16){const n=[i+t+s&4294967295,i+s&4294967295,i+0&4294967295,i-t&4294967295],e=h,r=e.length-16;let o=0;for(a=0;(4294967280&a)<=r;a+=4){const r=a,h=e[r+0]+(e[r+1]<<8),i=e[r+2]+(e[r+3]<<8),u=h*s+(i*s<<16);let l=n[o]+u&4294967295;l=l<<13|l>>>19;const f=65535&l,p=l>>>16;n[o]=f*t+(p*t<<16)&4294967295,o=o+1&3}u=(n[0]<<1|n[0]>>>31)+(n[1]<<7|n[1]>>>25)+(n[2]<<12|n[2]>>>20)+(n[3]<<18|n[3]>>>14)&4294967295}u=u+h.length&4294967295;const l=h.length-4;for(;a<=l;a+=4){const t=a,s=o[t+0]+(o[t+1]<<8),r=o[t+2]+(o[t+3]<<8);u=u+(s*n+(r*n<<16))&4294967295,u=u<<17|u>>>15,u=(65535&u)*e+((u>>>16)*e<<16)&4294967295}for(;a<o.length;++a){u+=o[a]*r,u=u<<11|u>>>21,u=(65535&u)*t+((u>>>16)*t<<16)&4294967295}return u^=u>>>15,u=((65535&u)*s&4294967295)+((u>>>16)*s<<16),u^=u>>>13,u=((65535&u)*n&4294967295)+((u>>>16)*n<<16),u^=u>>>16,u<0?u+4294967296:u}}export{i as XXH};
|
package/arcade/lib/scanner.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{assert as e}from"./assert.js";import{Character as t}from"./character.js";import{Messages as i}from"./messages.js";import{TokenType as s}from"./token.js";function n(e){return"0123456789abcdef".indexOf(e.toLowerCase())}function r(e){return"01234567".indexOf(e)}class h{constructor(e,t){this.source=e,this.errorHandler=t,this.trackComment=!1,this.isModule=!1,this.length=e.length,this.index=0,this.lineNumber=e.length>0?1:0,this.lineStart=0,this.curlyStack=[]}saveState(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart,curlyStack:this.curlyStack.slice()}}restoreState(e){this.index=e.index,this.lineNumber=e.lineNumber,this.lineStart=e.lineStart,this.curlyStack=e.curlyStack}eof(){return this.index>=this.length}throwUnexpectedToken(e=i.UnexpectedTokenIllegal){return this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,e)}tolerateUnexpectedToken(e=i.UnexpectedTokenIllegal){this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,e)}skipSingleLineComment(e){let i=[],s=0,n=null;for(this.trackComment&&(i=[],s=this.index-e,n={start:{line:this.lineNumber,column:this.index-this.lineStart-e},end:{line:0,column:0}});!this.eof();){const r=this.source.charCodeAt(this.index);if(++this.index,t.isLineTerminator(r)){if(n){n.end={line:this.lineNumber,column:this.index-this.lineStart-1};const t={multiLine:!1,slice:[s+e,this.index-1],range:[s,this.index-1],loc:n};i.push(t)}return 13===r&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,i}}if(n){n.end={line:this.lineNumber,column:this.index-this.lineStart};const t={multiLine:!1,slice:[s+e,this.index],range:[s,this.index],loc:n};i.push(t)}return i}skipMultiLineComment(){const e=[];let i=0,s=null;for(this.trackComment&&(i=this.index-2,s={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{line:0,column:0}});!this.eof();){const n=this.source.charCodeAt(this.index);if(t.isLineTerminator(n))13===n&&10===this.source.charCodeAt(this.index+1)&&++this.index,++this.lineNumber,++this.index,this.lineStart=this.index;else if(42===n){if(47===this.source.charCodeAt(this.index+1)){if(this.index+=2,s){s.end={line:this.lineNumber,column:this.index-this.lineStart};const t={multiLine:!0,slice:[i+2,this.index-2],range:[i,this.index],loc:s};e.push(t)}return e}++this.index}else++this.index}if(s){s.end={line:this.lineNumber,column:this.index-this.lineStart};const t={multiLine:!0,slice:[i+2,this.index],range:[i,this.index],loc:s};e.push(t)}return this.tolerateUnexpectedToken(),e}scanComments(){let e=null;this.trackComment&&(e=[]);let i=0===this.index;for(;!this.eof();){let s=this.source.charCodeAt(this.index);if(t.isWhiteSpace(s))++this.index;else if(t.isLineTerminator(s))++this.index,13===s&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,i=!0;else if(47===s)if(s=this.source.charCodeAt(this.index+1),47===s){this.index+=2;const t=this.skipSingleLineComment(2);e&&(e=e.concat(t)),i=!0}else{if(42!==s)break;{this.index+=2;const t=this.skipMultiLineComment();e&&(e=e.concat(t))}}else if(i&&45===s){if(45!==this.source.charCodeAt(this.index+1)||62!==this.source.charCodeAt(this.index+2))break;{this.index+=3;const t=this.skipSingleLineComment(3);e&&(e=e.concat(t))}}else{if(60!==s||this.isModule)break;if("!--"!==this.source.slice(this.index+1,this.index+4))break;{this.index+=4;const t=this.skipSingleLineComment(4);e&&(e=e.concat(t))}}}return e}isKeyword(e){switch((e=e.toLowerCase()).length){case 2:return"if"===e||"in"===e;case 3:return"var"===e||"for"===e;case 4:return"else"===e;case 5:return"break"===e;case 6:return"return"===e;case 8:return"function"===e||"continue"===e;default:return!1}}codePointAt(e){let t=this.source.charCodeAt(e);if(t>=55296&&t<=56319){const i=this.source.charCodeAt(e+1);if(i>=56320&&i<=57343){t=1024*(t-55296)+i-56320+65536}}return t}scanHexEscape(e){const i="u"===e?4:2;let s=0;for(let r=0;r<i;++r){if(this.eof()||!t.isHexDigit(this.source.charCodeAt(this.index)))return null;s=16*s+n(this.source[this.index++])}return String.fromCharCode(s)}scanUnicodeCodePointEscape(){let e=this.source[this.index],i=0;for("}"===e&&this.throwUnexpectedToken();!this.eof()&&(e=this.source[this.index++],t.isHexDigit(e.charCodeAt(0)));)i=16*i+n(e);return(i>1114111||"}"!==e)&&this.throwUnexpectedToken(),t.fromCodePoint(i)}getIdentifier(){const e=this.index++;for(;!this.eof();){const i=this.source.charCodeAt(this.index);if(92===i)return this.index=e,this.getComplexIdentifier();if(i>=55296&&i<57343)return this.index=e,this.getComplexIdentifier();if(!t.isIdentifierPart(i))break;++this.index}return this.source.slice(e,this.index)}getComplexIdentifier(){let e,i=this.codePointAt(this.index),s=t.fromCodePoint(i);for(this.index+=s.length,92===i&&(117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this.scanUnicodeCodePointEscape()):(e=this.scanHexEscape("u"),null!==e&&"\\"!==e&&t.isIdentifierStart(e.charCodeAt(0))||this.throwUnexpectedToken()),s=e);!this.eof()&&(i=this.codePointAt(this.index),t.isIdentifierPart(i));)e=t.fromCodePoint(i),s+=e,this.index+=e.length,92===i&&(s=s.substr(0,s.length-1),117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this.scanUnicodeCodePointEscape()):(e=this.scanHexEscape("u"),null!==e&&"\\"!==e&&t.isIdentifierPart(e.charCodeAt(0))||this.throwUnexpectedToken()),s+=e);return s}octalToDecimal(e){let i="0"!==e,s=r(e);return!this.eof()&&t.isOctalDigit(this.source.charCodeAt(this.index))&&(i=!0,s=8*s+r(this.source[this.index++]),"0123".indexOf(e)>=0&&!this.eof()&&t.isOctalDigit(this.source.charCodeAt(this.index))&&(s=8*s+r(this.source[this.index++]))),{code:s,octal:i}}scanIdentifier(){let e;const t=this.index,n=92===this.source.charCodeAt(t)?this.getComplexIdentifier():this.getIdentifier();if(e=1===n.length?s.Identifier:this.isKeyword(n)?s.Keyword:"null"===n.toLowerCase()?s.NullLiteral:"true"===n.toLowerCase()||"false"===n.toLowerCase()?s.BooleanLiteral:s.Identifier,e!==s.Identifier&&t+n.length!==this.index){const e=this.index;this.index=t,this.tolerateUnexpectedToken(i.InvalidEscapedReservedWord),this.index=e}return{type:e,value:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}}scanPunctuator(){const e=this.index;let t=this.source[this.index];switch(t){case"(":case"{":"{"===t&&this.curlyStack.push("{"),++this.index;break;case".":case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;case"}":++this.index,this.curlyStack.pop();break;default:t=this.source.substr(this.index,4),">>>="===t?this.index+=4:(t=t.substr(0,3),"==="===t||"!=="===t||">>>"===t||"<<="===t||">>="===t||"**="===t?this.index+=3:(t=t.substr(0,2),"&&"===t||"||"===t||"=="===t||"!="===t||"+="===t||"-="===t||"*="===t||"/="===t||"++"===t||"--"===t||"<<"===t||">>"===t||"&="===t||"|="===t||"^="===t||"%="===t||"<="===t||">="===t||"=>"===t||"**"===t?this.index+=2:(t=this.source[this.index],"<>=!+-*%&|^/".indexOf(t)>=0&&++this.index)))}return this.index===e&&this.throwUnexpectedToken(),{type:s.Punctuator,value:t,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}scanHexLiteral(e){let i="";for(;!this.eof()&&t.isHexDigit(this.source.charCodeAt(this.index));)i+=this.source[this.index++];return 0===i.length&&this.throwUnexpectedToken(),t.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:s.NumericLiteral,value:parseInt("0x"+i,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}scanBinaryLiteral(e){let i="";for(;!this.eof();){const e=this.source[this.index];if("0"!==e&&"1"!==e)break;i+=this.source[this.index++]}if(0===i.length&&this.throwUnexpectedToken(),!this.eof()){const e=this.source.charCodeAt(this.index);(t.isIdentifierStart(e)||t.isDecimalDigit(e))&&this.throwUnexpectedToken()}return{type:s.NumericLiteral,value:parseInt(i,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}scanOctalLiteral(e,i){let n="",r=!1;for(t.isOctalDigit(e.charCodeAt(0))?(r=!0,n="0"+this.source[this.index++]):++this.index;!this.eof()&&t.isOctalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];return r||0!==n.length||this.throwUnexpectedToken(),(t.isIdentifierStart(this.source.charCodeAt(this.index))||t.isDecimalDigit(this.source.charCodeAt(this.index)))&&this.throwUnexpectedToken(),{type:s.NumericLiteral,value:parseInt(n,8),octal:r,lineNumber:this.lineNumber,lineStart:this.lineStart,start:i,end:this.index}}scanNumericLiteral(){const i=this.index;let n=this.source[i];e(t.isDecimalDigit(n.charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point");let r="";if("."!==n){if(r=this.source[this.index++],n=this.source[this.index],"0"===r){if("x"===n||"X"===n)return++this.index,this.scanHexLiteral(i);if("b"===n||"B"===n)return++this.index,this.scanBinaryLiteral(i);if("o"===n||"O"===n)return this.scanOctalLiteral(n,i)}for(;t.isDecimalDigit(this.source.charCodeAt(this.index));)r+=this.source[this.index++];n=this.source[this.index]}if("."===n){for(r+=this.source[this.index++];t.isDecimalDigit(this.source.charCodeAt(this.index));)r+=this.source[this.index++];n=this.source[this.index]}if("e"===n||"E"===n)if(r+=this.source[this.index++],n=this.source[this.index],"+"!==n&&"-"!==n||(r+=this.source[this.index++]),t.isDecimalDigit(this.source.charCodeAt(this.index)))for(;t.isDecimalDigit(this.source.charCodeAt(this.index));)r+=this.source[this.index++];else this.throwUnexpectedToken();return t.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:s.NumericLiteral,value:parseFloat(r),lineNumber:this.lineNumber,lineStart:this.lineStart,start:i,end:this.index}}scanStringLiteral(){const n=this.index;let r=this.source[n];e("'"===r||'"'===r,"String literal must starts with a quote"),++this.index;let h=!1,c="";for(;!this.eof();){let e=this.source[this.index++];if(e===r){r="";break}if("\\"===e)if(e=this.source[this.index++],e&&t.isLineTerminator(e.charCodeAt(0)))++this.lineNumber,"\r"===e&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index;else switch(e){case"u":if("{"===this.source[this.index])++this.index,c+=this.scanUnicodeCodePointEscape();else{const t=this.scanHexEscape(e);null===t&&this.throwUnexpectedToken(),c+=t}break;case"x":{const t=this.scanHexEscape(e);null===t&&this.throwUnexpectedToken(i.InvalidHexEscapeSequence),c+=t;break}case"n":c+="\n";break;case"r":c+="\r";break;case"t":c+="\t";break;case"b":c+="\b";break;case"f":c+="\f";break;case"v":c+="\v";break;case"8":case"9":c+=e,this.tolerateUnexpectedToken();break;default:if(e&&t.isOctalDigit(e.charCodeAt(0))){const t=this.octalToDecimal(e);h=t.octal||h,c+=String.fromCharCode(t.code)}else c+=e}else{if(t.isLineTerminator(e.charCodeAt(0)))break;c+=e}}return""!==r&&(this.index=n,this.throwUnexpectedToken()),{type:s.StringLiteral,value:c,octal:h,lineNumber:this.lineNumber,lineStart:this.lineStart,start:n,end:this.index}}scanTemplate(){let e="",n=!1;const r=this.index,h="`"===this.source[r];let c=!1,o=2;for(++this.index;!this.eof();){let s=this.source[this.index++];if("`"===s){o=1,c=!0,n=!0;break}if("$"===s){if("{"===this.source[this.index]){this.curlyStack.push("${"),++this.index,n=!0;break}e+=s}else if("\\"===s)if(s=this.source[this.index++],t.isLineTerminator(s.charCodeAt(0)))++this.lineNumber,"\r"===s&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index;else switch(s){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"u":if("{"===this.source[this.index])++this.index,e+=this.scanUnicodeCodePointEscape();else{const t=this.index,i=this.scanHexEscape(s);null!==i?e+=i:(this.index=t,e+=s)}break;case"x":{const t=this.scanHexEscape(s);null===t&&this.throwUnexpectedToken(i.InvalidHexEscapeSequence),e+=t;break}case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:"0"===s?(t.isDecimalDigit(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(i.TemplateOctalLiteral),e+="\0"):t.isOctalDigit(s.charCodeAt(0))?this.throwUnexpectedToken(i.TemplateOctalLiteral):e+=s}else t.isLineTerminator(s.charCodeAt(0))?(++this.lineNumber,"\r"===s&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index,e+="\n"):e+=s}return n||this.throwUnexpectedToken(),h||this.curlyStack.pop(),{type:s.Template,value:this.source.slice(r+1,this.index-o),cooked:e,head:h,tail:c,lineNumber:this.lineNumber,lineStart:this.lineStart,start:r,end:this.index}}testRegExp(e,t){const s="";let n=e;t.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,((e,t,n)=>{const r=parseInt(t||n,16);return r>1114111&&this.throwUnexpectedToken(i.InvalidRegExp),r<=65535?String.fromCharCode(r):s})).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,s));try{RegExp(n)}catch(r){this.throwUnexpectedToken(i.InvalidRegExp)}try{return new RegExp(e,t)}catch(h){return null}}scanRegExpBody(){let s=this.source[this.index];e("/"===s,"Regular expression literal must start with a slash");let n=this.source[this.index++],r=!1,h=!1;for(;!this.eof();)if(s=this.source[this.index++],n+=s,"\\"===s)s=this.source[this.index++],t.isLineTerminator(s.charCodeAt(0))&&this.throwUnexpectedToken(i.UnterminatedRegExp),n+=s;else if(t.isLineTerminator(s.charCodeAt(0)))this.throwUnexpectedToken(i.UnterminatedRegExp);else if(r)"]"===s&&(r=!1);else{if("/"===s){h=!0;break}"["===s&&(r=!0)}return h||this.throwUnexpectedToken(i.UnterminatedRegExp),n.substr(1,n.length-2)}scanRegExpFlags(){let e="",i="";for(;!this.eof();){let s=this.source[this.index];if(!t.isIdentifierPart(s.charCodeAt(0)))break;if(++this.index,"\\"!==s||this.eof())i+=s,e+=s;else if(s=this.source[this.index],"u"===s){++this.index;let t=this.index;const s=this.scanHexEscape("u");if(null!==s)for(i+=s,e+="\\u";t<this.index;++t)e+=this.source[t];else this.index=t,i+="u",e+="\\u";this.tolerateUnexpectedToken()}else e+="\\",this.tolerateUnexpectedToken()}return i}scanRegExp(){const e=this.index,t=this.scanRegExpBody(),i=this.scanRegExpFlags(),n=this.testRegExp(t,i);return{type:s.RegularExpression,value:"",pattern:t,flags:i,regex:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}lex(){if(this.eof())return{type:s.EOF,value:"",lineNumber:this.lineNumber,lineStart:this.lineStart,start:this.index,end:this.index};const e=this.source.charCodeAt(this.index);return t.isIdentifierStart(e)?this.scanIdentifier():40===e||41===e||59===e?this.scanPunctuator():39===e||34===e?this.scanStringLiteral():46===e?t.isDecimalDigit(this.source.charCodeAt(this.index+1))?this.scanNumericLiteral():this.scanPunctuator():t.isDecimalDigit(e)?this.scanNumericLiteral():96===e||125===e&&"${"===this.curlyStack[this.curlyStack.length-1]?this.scanTemplate():e>=55296&&e<57343&&t.isIdentifierStart(this.codePointAt(this.index))?this.scanIdentifier():this.scanPunctuator()}}export{h as Scanner};
|
|
5
|
+
import{assert as e}from"./assert.js";import{Character as t}from"./character.js";import{Messages as i}from"./messages.js";import{TokenType as s}from"./token.js";function n(e){return"0123456789abcdef".indexOf(e.toLowerCase())}function r(e){return"01234567".indexOf(e)}class h{constructor(e,t){this.source=e,this.errorHandler=t,this.trackComment=!1,this.isModule=!1,this.length=e.length,this.index=0,this.lineNumber=e.length>0?1:0,this.lineStart=0,this.curlyStack=[]}saveState(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart,curlyStack:this.curlyStack.slice()}}restoreState(e){this.index=e.index,this.lineNumber=e.lineNumber,this.lineStart=e.lineStart,this.curlyStack=e.curlyStack}eof(){return this.index>=this.length}throwUnexpectedToken(e=i.UnexpectedTokenIllegal){return this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,e)}_tolerateUnexpectedToken(e=i.UnexpectedTokenIllegal){this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,e)}_skipSingleLineComment(e){let i=[],s=0,n=null;for(this.trackComment&&(i=[],s=this.index-e,n={start:{line:this.lineNumber,column:this.index-this.lineStart-e},end:{line:0,column:0}});!this.eof();){const r=this.source.charCodeAt(this.index);if(++this.index,t.isLineTerminator(r)){if(n){n.end={line:this.lineNumber,column:this.index-this.lineStart-1};const t={multiLine:!1,slice:[s+e,this.index-1],range:[s,this.index-1],loc:n};i.push(t)}return 13===r&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,i}}if(n){n.end={line:this.lineNumber,column:this.index-this.lineStart};const t={multiLine:!1,slice:[s+e,this.index],range:[s,this.index],loc:n};i.push(t)}return i}_skipMultiLineComment(){const e=[];let i=0,s=null;for(this.trackComment&&(i=this.index-2,s={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{line:0,column:0}});!this.eof();){const n=this.source.charCodeAt(this.index);if(t.isLineTerminator(n))13===n&&10===this.source.charCodeAt(this.index+1)&&++this.index,++this.lineNumber,++this.index,this.lineStart=this.index;else if(42===n){if(47===this.source.charCodeAt(this.index+1)){if(this.index+=2,s){s.end={line:this.lineNumber,column:this.index-this.lineStart};const t={multiLine:!0,slice:[i+2,this.index-2],range:[i,this.index],loc:s};e.push(t)}return e}++this.index}else++this.index}if(s){s.end={line:this.lineNumber,column:this.index-this.lineStart};const t={multiLine:!0,slice:[i+2,this.index],range:[i,this.index],loc:s};e.push(t)}return this._tolerateUnexpectedToken(),e}scanComments(){let e=null;this.trackComment&&(e=[]);let i=0===this.index;for(;!this.eof();){let s=this.source.charCodeAt(this.index);if(t.isWhiteSpace(s))++this.index;else if(t.isLineTerminator(s))++this.index,13===s&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,i=!0;else if(47===s)if(s=this.source.charCodeAt(this.index+1),47===s){this.index+=2;const t=this._skipSingleLineComment(2);e&&(e=e.concat(t)),i=!0}else{if(42!==s)break;{this.index+=2;const t=this._skipMultiLineComment();e&&(e=e.concat(t))}}else if(i&&45===s){if(45!==this.source.charCodeAt(this.index+1)||62!==this.source.charCodeAt(this.index+2))break;{this.index+=3;const t=this._skipSingleLineComment(3);e&&(e=e.concat(t))}}else{if(60!==s||this.isModule)break;if("!--"!==this.source.slice(this.index+1,this.index+4))break;{this.index+=4;const t=this._skipSingleLineComment(4);e&&(e=e.concat(t))}}}return e}_isKeyword(e){switch((e=e.toLowerCase()).length){case 2:return"if"===e||"in"===e;case 3:return"var"===e||"for"===e;case 4:return"else"===e;case 5:return"break"===e;case 6:return"return"===e;case 8:return"function"===e||"continue"===e;default:return!1}}_codePointAt(e){let t=this.source.charCodeAt(e);if(t>=55296&&t<=56319){const i=this.source.charCodeAt(e+1);if(i>=56320&&i<=57343){t=1024*(t-55296)+i-56320+65536}}return t}_scanHexEscape(e){const i="u"===e?4:2;let s=0;for(let r=0;r<i;++r){if(this.eof()||!t.isHexDigit(this.source.charCodeAt(this.index)))return null;s=16*s+n(this.source[this.index++])}return String.fromCharCode(s)}_scanUnicodeCodePointEscape(){let e=this.source[this.index],i=0;for("}"===e&&this.throwUnexpectedToken();!this.eof()&&(e=this.source[this.index++],t.isHexDigit(e.charCodeAt(0)));)i=16*i+n(e);return(i>1114111||"}"!==e)&&this.throwUnexpectedToken(),t.fromCodePoint(i)}_getIdentifier(){const e=this.index++;for(;!this.eof();){const i=this.source.charCodeAt(this.index);if(92===i)return this.index=e,this._getComplexIdentifier();if(i>=55296&&i<57343)return this.index=e,this._getComplexIdentifier();if(!t.isIdentifierPart(i))break;++this.index}return this.source.slice(e,this.index)}_getComplexIdentifier(){let e,i=this._codePointAt(this.index),s=t.fromCodePoint(i);for(this.index+=s.length,92===i&&(117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this._scanUnicodeCodePointEscape()):(e=this._scanHexEscape("u"),null!==e&&"\\"!==e&&t.isIdentifierStart(e.charCodeAt(0))||this.throwUnexpectedToken()),s=e);!this.eof()&&(i=this._codePointAt(this.index),t.isIdentifierPart(i));)e=t.fromCodePoint(i),s+=e,this.index+=e.length,92===i&&(s=s.substr(0,s.length-1),117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this._scanUnicodeCodePointEscape()):(e=this._scanHexEscape("u"),null!==e&&"\\"!==e&&t.isIdentifierPart(e.charCodeAt(0))||this.throwUnexpectedToken()),s+=e);return s}_octalToDecimal(e){let i="0"!==e,s=r(e);return!this.eof()&&t.isOctalDigit(this.source.charCodeAt(this.index))&&(i=!0,s=8*s+r(this.source[this.index++]),"0123".indexOf(e)>=0&&!this.eof()&&t.isOctalDigit(this.source.charCodeAt(this.index))&&(s=8*s+r(this.source[this.index++]))),{code:s,octal:i}}_scanIdentifier(){let e;const t=this.index,n=92===this.source.charCodeAt(t)?this._getComplexIdentifier():this._getIdentifier();if(e=1===n.length?s.Identifier:this._isKeyword(n)?s.Keyword:"null"===n.toLowerCase()?s.NullLiteral:"true"===n.toLowerCase()||"false"===n.toLowerCase()?s.BooleanLiteral:s.Identifier,e!==s.Identifier&&t+n.length!==this.index){const e=this.index;this.index=t,this._tolerateUnexpectedToken(i.InvalidEscapedReservedWord),this.index=e}return{type:e,value:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}}_scanPunctuator(){const e=this.index;let t=this.source[this.index];switch(t){case"(":case"{":"{"===t&&this.curlyStack.push("{"),++this.index;break;case".":case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;case"}":++this.index,this.curlyStack.pop();break;default:t=this.source.substr(this.index,4),">>>="===t?this.index+=4:(t=t.substr(0,3),"==="===t||"!=="===t||">>>"===t||"<<="===t||">>="===t||"**="===t?this.index+=3:(t=t.substr(0,2),"&&"===t||"||"===t||"=="===t||"!="===t||"+="===t||"-="===t||"*="===t||"/="===t||"++"===t||"--"===t||"<<"===t||">>"===t||"&="===t||"|="===t||"^="===t||"%="===t||"<="===t||">="===t||"=>"===t||"**"===t?this.index+=2:(t=this.source[this.index],"<>=!+-*%&|^/".indexOf(t)>=0&&++this.index)))}return this.index===e&&this.throwUnexpectedToken(),{type:s.Punctuator,value:t,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}_scanHexLiteral(e){let i="";for(;!this.eof()&&t.isHexDigit(this.source.charCodeAt(this.index));)i+=this.source[this.index++];return 0===i.length&&this.throwUnexpectedToken(),t.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:s.NumericLiteral,value:parseInt("0x"+i,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}_scanBinaryLiteral(e){let i="";for(;!this.eof();){const e=this.source[this.index];if("0"!==e&&"1"!==e)break;i+=this.source[this.index++]}if(0===i.length&&this.throwUnexpectedToken(),!this.eof()){const e=this.source.charCodeAt(this.index);(t.isIdentifierStart(e)||t.isDecimalDigit(e))&&this.throwUnexpectedToken()}return{type:s.NumericLiteral,value:parseInt(i,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}_scanOctalLiteral(e,i){let n="",r=!1;for(t.isOctalDigit(e.charCodeAt(0))?(r=!0,n="0"+this.source[this.index++]):++this.index;!this.eof()&&t.isOctalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];return r||0!==n.length||this.throwUnexpectedToken(),(t.isIdentifierStart(this.source.charCodeAt(this.index))||t.isDecimalDigit(this.source.charCodeAt(this.index)))&&this.throwUnexpectedToken(),{type:s.NumericLiteral,value:parseInt(n,8),octal:r,lineNumber:this.lineNumber,lineStart:this.lineStart,start:i,end:this.index}}_scanNumericLiteral(){const i=this.index;let n=this.source[i];e(t.isDecimalDigit(n.charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point");let r="";if("."!==n){if(r=this.source[this.index++],n=this.source[this.index],"0"===r){if("x"===n||"X"===n)return++this.index,this._scanHexLiteral(i);if("b"===n||"B"===n)return++this.index,this._scanBinaryLiteral(i);if("o"===n||"O"===n)return this._scanOctalLiteral(n,i)}for(;t.isDecimalDigit(this.source.charCodeAt(this.index));)r+=this.source[this.index++];n=this.source[this.index]}if("."===n){for(r+=this.source[this.index++];t.isDecimalDigit(this.source.charCodeAt(this.index));)r+=this.source[this.index++];n=this.source[this.index]}if("e"===n||"E"===n)if(r+=this.source[this.index++],n=this.source[this.index],"+"!==n&&"-"!==n||(r+=this.source[this.index++]),t.isDecimalDigit(this.source.charCodeAt(this.index)))for(;t.isDecimalDigit(this.source.charCodeAt(this.index));)r+=this.source[this.index++];else this.throwUnexpectedToken();return t.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:s.NumericLiteral,value:parseFloat(r),lineNumber:this.lineNumber,lineStart:this.lineStart,start:i,end:this.index}}_scanStringLiteral(){const n=this.index;let r=this.source[n];e("'"===r||'"'===r,"String literal must starts with a quote"),++this.index;let h=!1,c="";for(;!this.eof();){let e=this.source[this.index++];if(e===r){r="";break}if("\\"===e)if(e=this.source[this.index++],e&&t.isLineTerminator(e.charCodeAt(0)))++this.lineNumber,"\r"===e&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index;else switch(e){case"u":if("{"===this.source[this.index])++this.index,c+=this._scanUnicodeCodePointEscape();else{const t=this._scanHexEscape(e);null===t&&this.throwUnexpectedToken(),c+=t}break;case"x":{const t=this._scanHexEscape(e);null===t&&this.throwUnexpectedToken(i.InvalidHexEscapeSequence),c+=t;break}case"n":c+="\n";break;case"r":c+="\r";break;case"t":c+="\t";break;case"b":c+="\b";break;case"f":c+="\f";break;case"v":c+="\v";break;case"8":case"9":c+=e,this._tolerateUnexpectedToken();break;default:if(e&&t.isOctalDigit(e.charCodeAt(0))){const t=this._octalToDecimal(e);h=t.octal||h,c+=String.fromCharCode(t.code)}else c+=e}else{if(t.isLineTerminator(e.charCodeAt(0)))break;c+=e}}return""!==r&&(this.index=n,this.throwUnexpectedToken()),{type:s.StringLiteral,value:c,octal:h,lineNumber:this.lineNumber,lineStart:this.lineStart,start:n,end:this.index}}_scanTemplate(){let e="",n=!1;const r=this.index,h="`"===this.source[r];let c=!1,o=2;for(++this.index;!this.eof();){let s=this.source[this.index++];if("`"===s){o=1,c=!0,n=!0;break}if("$"===s){if("{"===this.source[this.index]){this.curlyStack.push("${"),++this.index,n=!0;break}e+=s}else if("\\"===s)if(s=this.source[this.index++],t.isLineTerminator(s.charCodeAt(0)))++this.lineNumber,"\r"===s&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index;else switch(s){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"u":if("{"===this.source[this.index])++this.index,e+=this._scanUnicodeCodePointEscape();else{const t=this.index,i=this._scanHexEscape(s);null!==i?e+=i:(this.index=t,e+=s)}break;case"x":{const t=this._scanHexEscape(s);null===t&&this.throwUnexpectedToken(i.InvalidHexEscapeSequence),e+=t;break}case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:"0"===s?(t.isDecimalDigit(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(i.TemplateOctalLiteral),e+="\0"):t.isOctalDigit(s.charCodeAt(0))?this.throwUnexpectedToken(i.TemplateOctalLiteral):e+=s}else t.isLineTerminator(s.charCodeAt(0))?(++this.lineNumber,"\r"===s&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index,e+="\n"):e+=s}return n||this.throwUnexpectedToken(),h||this.curlyStack.pop(),{type:s.Template,value:this.source.slice(r+1,this.index-o),cooked:e,head:h,tail:c,lineNumber:this.lineNumber,lineStart:this.lineStart,start:r,end:this.index}}_testRegExp(e,t){const s="";let n=e;t.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,((e,t,n)=>{const r=parseInt(t||n,16);return r>1114111&&this.throwUnexpectedToken(i.InvalidRegExp),r<=65535?String.fromCharCode(r):s})).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,s));try{RegExp(n)}catch(r){this.throwUnexpectedToken(i.InvalidRegExp)}try{return new RegExp(e,t)}catch(h){return null}}_scanRegExpBody(){let s=this.source[this.index];e("/"===s,"Regular expression literal must start with a slash");let n=this.source[this.index++],r=!1,h=!1;for(;!this.eof();)if(s=this.source[this.index++],n+=s,"\\"===s)s=this.source[this.index++],t.isLineTerminator(s.charCodeAt(0))&&this.throwUnexpectedToken(i.UnterminatedRegExp),n+=s;else if(t.isLineTerminator(s.charCodeAt(0)))this.throwUnexpectedToken(i.UnterminatedRegExp);else if(r)"]"===s&&(r=!1);else{if("/"===s){h=!0;break}"["===s&&(r=!0)}return h||this.throwUnexpectedToken(i.UnterminatedRegExp),n.substr(1,n.length-2)}_scanRegExpFlags(){let e="",i="";for(;!this.eof();){let s=this.source[this.index];if(!t.isIdentifierPart(s.charCodeAt(0)))break;if(++this.index,"\\"!==s||this.eof())i+=s,e+=s;else if(s=this.source[this.index],"u"===s){++this.index;let t=this.index;const s=this._scanHexEscape("u");if(null!==s)for(i+=s,e+="\\u";t<this.index;++t)e+=this.source[t];else this.index=t,i+="u",e+="\\u";this._tolerateUnexpectedToken()}else e+="\\",this._tolerateUnexpectedToken()}return i}scanRegExp(){const e=this.index,t=this._scanRegExpBody(),i=this._scanRegExpFlags(),n=this._testRegExp(t,i);return{type:s.RegularExpression,value:"",pattern:t,flags:i,regex:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}}lex(){if(this.eof())return{type:s.EOF,value:"",lineNumber:this.lineNumber,lineStart:this.lineStart,start:this.index,end:this.index};const e=this.source.charCodeAt(this.index);return t.isIdentifierStart(e)?this._scanIdentifier():40===e||41===e||59===e?this._scanPunctuator():39===e||34===e?this._scanStringLiteral():46===e?t.isDecimalDigit(this.source.charCodeAt(this.index+1))?this._scanNumericLiteral():this._scanPunctuator():t.isDecimalDigit(e)?this._scanNumericLiteral():96===e||125===e&&"${"===this.curlyStack[this.curlyStack.length-1]?this._scanTemplate():e>=55296&&e<57343&&t.isIdentifierStart(this._codePointAt(this.index))?this._scanIdentifier():this._scanPunctuator()}}export{h as Scanner};
|