@arcgis/core 4.34.0-next.15 → 4.34.0-next.17
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/analysis/Analysis.js +1 -1
- package/analysis/AreaMeasurementAnalysis.js +1 -1
- package/analysis/DimensionAnalysis.js +1 -1
- package/analysis/DimensionSimpleStyle.js +1 -1
- package/analysis/DirectLineMeasurementAnalysis.js +1 -1
- package/analysis/LengthDimension.js +1 -1
- package/analysis/LineOfSightAnalysis.js +1 -1
- package/analysis/SliceAnalysis.js +1 -1
- package/analysis/SlicePlane.js +1 -1
- package/analysis/ViewshedAnalysis.js +1 -1
- package/applications/Components/sanitizerUtils.d.ts +3 -0
- package/applications/Components/sanitizerUtils.js +5 -0
- package/applications/MapViewer/layerUtils.d.ts +3 -0
- package/applications/MapViewer/layerUtils.js +5 -0
- package/applications/SceneViewer/layerUtils.d.ts +2 -2
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{a08ce98672ab94d19613.js → 04e558a970c6a77f243e.js} +1 -1
- package/assets/esri/core/workers/chunks/0d99579d8cdeddc0fc9c.js +1 -0
- package/assets/esri/core/workers/chunks/1443520c9fb23381f8d5.js +1 -0
- package/assets/esri/core/workers/chunks/1a7570bd2b79194ff94b.js +42 -0
- package/assets/esri/core/workers/chunks/{0ed4ec00ef16aa58a33d.js → 254c4f7e277ae9915dce.js} +1 -1
- package/assets/esri/core/workers/chunks/2d51d0a24cdc89bafa1c.js +1 -0
- package/assets/esri/core/workers/chunks/2d89e354eeadadca4f7f.js +1 -0
- package/assets/esri/core/workers/chunks/3f8cc157b65a9d570921.js +1 -0
- package/assets/esri/core/workers/chunks/{2254989ca3ff3960f2fe.js → 400a4c9fa62964f8fa1d.js} +1 -1
- package/assets/esri/core/workers/chunks/{58f403f956b7b3467344.js → 42da01bd3f401a017c0f.js} +1 -1
- package/assets/esri/core/workers/chunks/445ddf57d2f503a0b98b.js +1 -0
- package/assets/esri/core/workers/chunks/513dc2467e9b8b8c6df4.js +1 -0
- package/assets/esri/core/workers/chunks/52239e958a82ebcd2e7a.js +1 -0
- package/assets/esri/core/workers/chunks/{e980a81c4d1e05f07141.js → 53e43798d08ad2075c1f.js} +1 -1
- package/assets/esri/core/workers/chunks/55ce214a10fb6fc2e901.js +1 -0
- package/assets/esri/core/workers/chunks/{a6bcae413e62cd879b46.js → 5859e425c9bca96b6c80.js} +1 -1
- package/assets/esri/core/workers/chunks/5bfccd5dffda74740aa4.js +1 -0
- package/assets/esri/core/workers/chunks/66c8816e91e3f9e214d4.js +346 -0
- package/assets/esri/core/workers/chunks/{948c5454881e661c3bdc.js → 78a57f5aeb277b84b3da.js} +1 -1
- package/assets/esri/core/workers/chunks/7c56740cac444419e5b4.js +1 -0
- package/assets/esri/core/workers/chunks/{7f14d6cb754c7e94748c.js → 827919fe23e06e40a330.js} +139 -115
- package/assets/esri/core/workers/chunks/8599df135928d73da4a3.js +1 -0
- package/assets/esri/core/workers/chunks/87986f31061c426e761b.js +1 -0
- package/assets/esri/core/workers/chunks/{7ae88c141a5d85e5bb88.js → 87a743df7d8556d5e253.js} +1 -1
- package/assets/esri/core/workers/chunks/8855f1a6224ffbd0bb66.js +1 -0
- package/assets/esri/core/workers/chunks/885e8e90dfe5dbd5053d.js +1 -0
- package/assets/esri/core/workers/chunks/93e66d9c49eaeb503bff.js +1 -0
- package/assets/esri/core/workers/chunks/974c6b0e3a1f1dd523fa.js +1 -0
- package/assets/esri/core/workers/chunks/aeabe203da7bcdd580cf.js +1 -0
- package/assets/esri/core/workers/chunks/beb01d400f1aa089d2dc.js +1 -0
- package/assets/esri/core/workers/chunks/c1a72e1dbd1ba7b41965.js +1 -0
- package/assets/esri/core/workers/chunks/c4065934637b820cad5b.js +1 -0
- package/assets/esri/core/workers/chunks/cc1328cacc4ac07eb548.js +1 -0
- package/assets/esri/core/workers/chunks/{05f2133f05f86266d8c7.js → d2139307f62ea8bf999a.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f58da371633967a61ca.js → ddb66fe6fcd0764daa7a.js} +1 -1
- package/assets/esri/core/workers/chunks/{70e5848aa372475fc8fa.js → eac7af86166c09c6a9be.js} +1 -1
- package/assets/esri/core/workers/chunks/{243eb8a317333ec2715b.js → f3e179b48bca50c94538.js} +1 -1
- package/assets/esri/core/workers/chunks/{7317346ed8d7c5bb859d.js → f537a02dc2fc9e6435a2.js} +1 -1
- package/assets/esri/core/workers/chunks/{7e1906d35a764f7f10b0.js → fe1129f03476825a7344.js} +1 -1
- package/chunks/DefaultMaterial.glsl.js +30 -28
- package/chunks/RealisticTree.glsl.js +25 -22
- package/chunks/aiServices.js +1 -1
- package/config.js +1 -1
- package/core/LRUCache.js +1 -1
- package/core/MemCache.js +1 -1
- package/core/arrayUtils.js +1 -1
- package/core/urlUtils.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/core/workers/WorkerHandle.js +1 -1
- package/interfaces.d.ts +69 -25
- package/kernel.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/layers/support/fetchService.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/package.json +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/wasmToDataModelFactories.js +1 -1
- package/rest/support/TranslateParameters.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/WaterSymbol3DLayer.js +1 -1
- package/symbols/support/jsonUtils.js +1 -1
- package/symbols/support/symbolUtils.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Slice/SliceController.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/RouteLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/graphicUtils.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/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/layers/support/makeScheduleFunction.js +1 -1
- package/views/3d/layers/support/symbolColorUtils.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/StreamDataLoader.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstanceColor.glsl.js +11 -0
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/MaskedColor.glsl.js +18 -0
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +40 -26
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +35 -24
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +12 -8
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js +3 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js +26 -8
- package/views/3d/webgl-engine/core/shaderModules/Float2BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float2DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float2PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float3BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float3DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4sPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatBindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatDrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatsPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix3DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix3PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4sPassUniform.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
- package/views/3d/webgl-engine/lib/Program.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/analysis/analysisViewUtils.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/components/PendingFeatureList.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/LineOfSight/LineOfSightTarget.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/support/ItemList.js +1 -1
- package/widgets/support/SelectionList/FeatureItem.js +1 -1
- package/widgets/support/SelectionList/LayerItem.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/widgets/support/symbolPreviewUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0dbb350ce651bc236ec8.js +0 -1
- package/assets/esri/core/workers/chunks/0ff6f15d46d7ddf6fe4d.js +0 -1
- package/assets/esri/core/workers/chunks/1f559f1e7f0bc0f4bf20.js +0 -346
- package/assets/esri/core/workers/chunks/462cc6966d060be59c7c.js +0 -1
- package/assets/esri/core/workers/chunks/4a805e7a57d25c4b595f.js +0 -66
- package/assets/esri/core/workers/chunks/58f92100b1b2343111c6.js +0 -1
- package/assets/esri/core/workers/chunks/5dcc8fa321f0a7c49f36.js +0 -1
- package/assets/esri/core/workers/chunks/5e539ce4751bcfa57145.js +0 -1
- package/assets/esri/core/workers/chunks/6194636638b0439fccd8.js +0 -1
- package/assets/esri/core/workers/chunks/622c0552ca3cd674d46c.js +0 -1
- package/assets/esri/core/workers/chunks/632d1a1287dde980479e.js +0 -1
- package/assets/esri/core/workers/chunks/64f5f27e7c5649d79cbc.js +0 -1
- package/assets/esri/core/workers/chunks/658e82c9b722852e02d0.js +0 -1
- package/assets/esri/core/workers/chunks/679d7baea233faf3fdbc.js +0 -1
- package/assets/esri/core/workers/chunks/7aef81778155be373d3e.js +0 -1
- package/assets/esri/core/workers/chunks/8b93cd4132934b0d7d39.js +0 -1
- package/assets/esri/core/workers/chunks/95507ff0a243e451b99e.js +0 -1
- package/assets/esri/core/workers/chunks/97b69fec3e87f11210ba.js +0 -1
- package/assets/esri/core/workers/chunks/a250a5c6e055e33bd25c.js +0 -1
- package/assets/esri/core/workers/chunks/b4273381dc069f4e1fa2.js +0 -1
- package/assets/esri/core/workers/chunks/b72137c63b7f2a525d9e.js +0 -1
- package/assets/esri/core/workers/chunks/c2264451d12f1fbaad22.js +0 -1
- package/assets/esri/core/workers/chunks/c6c86cbe65a58c3093ae.js +0 -1
- package/assets/esri/core/workers/chunks/fe3703ec198cbfebec30.js +0 -1
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{Offset as o}from"../views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js";import{isColorOrColorEmission as r}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as i}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as a}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{
|
|
5
|
+
import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{Offset as o}from"../views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js";import{isColorOrColorEmission as r}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as i}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as a}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{InstanceColor as l}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/InstanceColor.glsl.js";import{InstancedDoublePrecision as t}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{MaskedColorDefinition as s,CreateMaskedFromNaNColor as n}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/MaskedColor.glsl.js";import{NormalAttribute as d}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{SymbolColor as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js";import{TextureCoordinateAttribute as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as m}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VerticalOffset as b}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{DefaultMaterialAuxiliaryPasses as v}from"../views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import{EvaluateAmbientOcclusion as p}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as w,addAmbientBoostFactor as u,addLightingGlobalFactor as h}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as f,addMainLightIntensity as y}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{PhysicallyBasedRendering as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import{PBRMode as C,PhysicallyBasedRenderingParameters as L}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapPass as j,ReadShadowMapDraw as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{terrainDepthTest as O}from"../views/3d/webgl-engine/core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import{VisualVariables as P}from"../views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as S}from"../views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import{MixExternalColor as A}from"../views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js";import{addProjViewLocalOrigin as E,addCameraPosition as F}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float3PassUniform as N}from"../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{Float4PassUniform as D}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as $}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as V,If as I}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Texture2DPassUniform as T}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{VertexAttribute as k}from"../views/3d/webgl-engine/lib/VertexAttribute.js";import{colorMixModes as B}from"../views/3d/webgl-engine/materials/internal/MaterialUtil.js";import{outputColorHighlightOID as R}from"../views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js";import{ShaderBuilder as _}from"../views/webgl/ShaderBuilder.js";import{alphaCutoff as z}from"../webscene/support/AlphaCutoff.js";function U(U){const G=new _,{attributes:W,vertex:H,fragment:q,varyings:J}=G,{output:K,offsetBackfaces:Q,pbrMode:X,snowCover:Y,spherical:Z,hasBloom:ee}=U,oe=X===C.Normal||X===C.Schematic;if(E(H,U),W.add(k.POSITION,"vec3"),J.add("vpos","vec3",{invariant:!0}),G.include(P,U),G.include(t,U),G.include(b,U),G.include(O,U),r(K)&&(F(G.vertex,U),G.include(d,U),G.include(a,U),Q&&G.include(o),J.add("vNormalWorld","vec3"),J.add("localvpos","vec3",{invariant:!0}),G.include(g,U),G.include(e,U),G.include(c,U),G.include(l,U),G.include(m,U),H.include(s),H.include(n),H.uniforms.add(new D("externalColor",(e=>e.externalColor),{supportsNaN:!0})),J.add("vcolorExt","vec4"),H.main.add(V`
|
|
6
6
|
forwardNormalizedVertexColor();
|
|
7
|
-
vcolorExt = externalColor;
|
|
8
|
-
${F(q,"vcolorExt *= instanceColor * 0.003921568627451;")}
|
|
9
|
-
vcolorExt *= vvColor();
|
|
10
|
-
vcolorExt *= getSymbolColor();
|
|
11
|
-
forwardColorMixMode();
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
MaskedColor maskedColorExt =
|
|
9
|
+
applySymbolColor(applyVVColor(applyInstanceColor(createMaskedFromNaNColor(externalColor))));
|
|
10
|
+
|
|
11
|
+
vcolorExt = maskedColorExt.color;
|
|
12
|
+
forwardColorMixMode(maskedColorExt.mask);
|
|
13
|
+
|
|
14
|
+
bool alphaCut = opacityMixMode != ${V.int(B.ignore)} && vcolorExt.a < ${V.float(z)};
|
|
14
15
|
vpos = getVertexInLocalOriginSpace();
|
|
15
16
|
localvpos = vpos - view[3].xyz;
|
|
16
17
|
vpos = subtractOrigin(vpos);
|
|
@@ -20,15 +21,16 @@ import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/
|
|
|
20
21
|
|
|
21
22
|
forwardViewPosDepth((view * vec4(vpos, 1.0)).xyz);
|
|
22
23
|
forwardLinearDepth();
|
|
24
|
+
|
|
23
25
|
forwardTextureCoordinates();
|
|
24
26
|
|
|
25
27
|
gl_Position = alphaCut ? vec4(1e38, 1e38, 1e38, 1.0) :
|
|
26
|
-
${
|
|
27
|
-
`)),r(
|
|
28
|
+
${I(Q,"offsetBackfacingClipPosition(basePosition, vpos, vNormalWorld, cameraPosition);","basePosition;")}
|
|
29
|
+
`)),r(K)){const{hasColorTexture:e,hasColorTextureTransform:o,receiveShadows:r}=U;G.include(w,U),q.include(p,U),G.include(S,U),G.include(U.instancedDoublePrecision?j:M,U),q.include(i,U),G.include(R,U),F(q,U),f(q),u(q),h(q),q.uniforms.add(H.uniforms.get("localOrigin"),H.uniforms.get("view"),new N("ambient",(e=>e.ambient)),new N("diffuse",(e=>e.diffuse)),new $("opacity",(e=>e.opacity)),new $("layerOpacity",(e=>e.layerOpacity))),e&&q.uniforms.add(new T("tex",(e=>e.texture))),G.include(L,U),q.include(x,U),q.include(A),y(q),q.main.add(V`
|
|
28
30
|
discardBySlice(vpos);
|
|
29
31
|
discardByTerrainDepth();
|
|
30
32
|
vec4 texColor = ${e?`texture(tex, ${o?"colorUV":"vuv0"})`:" vec4(1.0)"};
|
|
31
|
-
${
|
|
33
|
+
${I(e,`${I(U.textureAlphaPremultiplied,"texColor.rgb /= texColor.a;")}\n discardOrAdjustAlpha(texColor);`)}
|
|
32
34
|
vec3 viewDirection = normalize(vpos - cameraPosition);
|
|
33
35
|
applyPBRFactors();
|
|
34
36
|
float ssao = evaluateAmbientOcclusionInverse();
|
|
@@ -36,13 +38,14 @@ import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/
|
|
|
36
38
|
|
|
37
39
|
float additionalAmbientScale = additionalDirectedAmbientLight(vpos + localOrigin);
|
|
38
40
|
vec3 additionalLight = ssao * mainLightIntensity * additionalAmbientScale * ambientBoostFactor * lightingGlobalFactor;
|
|
39
|
-
float shadow = ${r?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":
|
|
41
|
+
float shadow = ${r?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":Z?"lightingGlobalFactor * (1.0 - additionalAmbientScale)":"0.0"};
|
|
40
42
|
vec3 matColor = max(ambient, diffuse);
|
|
41
|
-
${
|
|
42
|
-
float opacity_ = layerOpacity * mixExternalOpacity(vColor.a * opacity, texColor.a, vcolorExt.a,
|
|
43
|
-
float opacity_ = layerOpacity * mixExternalOpacity(opacity, texColor.a, vcolorExt.a,
|
|
44
|
-
|
|
45
|
-
${
|
|
43
|
+
${U.hasVertexColors?V`vec3 albedo = mixExternalColor(vColor.rgb * matColor, texColor.rgb, vcolorExt.rgb, colorMixMode);
|
|
44
|
+
float opacity_ = layerOpacity * mixExternalOpacity(vColor.a * opacity, texColor.a, vcolorExt.a, opacityMixMode);`:V`vec3 albedo = mixExternalColor(matColor, texColor.rgb, vcolorExt.rgb, colorMixMode);
|
|
45
|
+
float opacity_ = layerOpacity * mixExternalOpacity(opacity, texColor.a, vcolorExt.a, opacityMixMode);`}
|
|
46
|
+
|
|
47
|
+
${I(Y,"albedo = mix(albedo, vec3(1), 0.9);")}
|
|
48
|
+
${V`vec3 shadingNormal = normalize(vNormalWorld);
|
|
46
49
|
albedo *= 1.2;
|
|
47
50
|
vec3 viewForward = vec3(view[0][2], view[1][2], view[2][2]);
|
|
48
51
|
float alignmentLightView = clamp(dot(viewForward, -mainLightDirection), 0.0, 1.0);
|
|
@@ -50,10 +53,10 @@ import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/
|
|
|
50
53
|
float treeRadialFalloff = vColor.r;
|
|
51
54
|
float backLightFactor = 0.5 * treeRadialFalloff * alignmentLightView * transmittance * (1.0 - shadow);
|
|
52
55
|
additionalLight += backLightFactor * mainLightIntensity;`}
|
|
53
|
-
${
|
|
54
|
-
${
|
|
55
|
-
${
|
|
56
|
-
vec4 emission = ${
|
|
57
|
-
vec3 shadedColor = evaluateSceneLightingPBR(shadingNormal, albedo, shadow, 1.0 - ssao, additionalLight, viewDirection, normalGround, mrr, emission, additionalAmbientIrradiance)
|
|
56
|
+
${I(oe,`vec3 normalGround = ${Z?"normalize(vpos + localOrigin)":"vec3(0.0, 0.0, 1.0)"};`)}
|
|
57
|
+
${oe?V`float additionalAmbientIrradiance = additionalAmbientIrradianceFactor * mainLightIntensity[2];
|
|
58
|
+
${I(Y,V`mrr = applySnowToMRR(mrr, 1.0)`)}
|
|
59
|
+
vec4 emission = ${Y||ee?"vec4(0.0)":"getEmissions(albedo)"};
|
|
60
|
+
vec3 shadedColor = evaluateSceneLightingPBR(shadingNormal, albedo, shadow, 1.0 - ssao, additionalLight, viewDirection, normalGround, mrr, emission, additionalAmbientIrradiance);`:V`vec3 shadedColor = evaluateSceneLighting(shadingNormal, albedo, shadow, 1.0 - ssao, additionalLight);`}
|
|
58
61
|
vec4 finalColor = vec4(shadedColor, opacity_);
|
|
59
|
-
outputColorHighlightOID(finalColor, vpos, albedo ${
|
|
62
|
+
outputColorHighlightOID(finalColor, vpos, albedo ${I(Y,", 1.0")});`)}return G.include(v,U),G}const G=Object.freeze(Object.defineProperty({__proto__:null,build:U},Symbol.toStringTag,{value:"Module"}));export{G as R,U as b};
|
package/chunks/aiServices.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as t}from"../arcade/arcadeEnvironment.js";import e from"../arcade/Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"../arcade/executionError.js";import{B as n,j as o,L as a}from"./languageUtils.js";import i from"../core/Error.js";import c from"../core/Logger.js";import{getOrCreateMapValue as l}from"../core/MapUtils.js";import u from"../portal/Portal.js";import{translate as h}from"../rest/translate.js";import m from"../rest/support/TranslateContent.js";import f from"../rest/support/TranslateParameters.js";import p from"../rest/support/TranslateResult.js";import{isString as
|
|
5
|
+
import{toSymbolId as t}from"../arcade/arcadeEnvironment.js";import e from"../arcade/Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"../arcade/executionError.js";import{B as n,j as o,L as a}from"./languageUtils.js";import i from"../core/Error.js";import c from"../core/Logger.js";import{getOrCreateMapValue as l}from"../core/MapUtils.js";import u from"../portal/Portal.js";import{translate as h}from"../rest/translate.js";import m from"../rest/support/TranslateContent.js";import f from"../rest/support/TranslateParameters.js";import p from"../rest/support/TranslateResult.js";import{isString as _,isArray as d}from"../support/guards.js";class g{constructor(t,e){this.portal=t,this._debugLog=e}async translate(t){this.portal.loaded||await this.portal.load();const e=this.portal.helperServices?.aiUtilityServices;if(null==e)return{success:!1};const s=e.url+e.translateUtility;try{t.requestSource??="arcade";return{success:!0,results:(await h(s,t,{authMode:"no-prompt"})).map((t=>t.toJSON()))}}catch(r){return null!=this._debugLog&&(r instanceof Error||r instanceof i)&&this._debugLog(`TranslateText error: ${r.message}`),c.getLogger("esri.arcade.functions.aiServices").error(r),{success:!1}}}}class y{constructor(t,e,s){this._parameters=t,this._maxTotalContentSize=e,this._maxContentsLength=s,this._requests=[],this._normalizedContents=new Map,this._contentsTotalSize=0}tryAdd(t){const e=new Set(t.filter((t=>!this._normalizedContents.has(t.text))).map((t=>t.text)));if(this._requests.length+e.size>this._maxContentsLength)return null;let s=0;for(const n of e)s+=n.length;if((s+this._contentsTotalSize)*(this._parameters.to.length??1)>this._maxTotalContentSize)return null;const r=this._requests.length;for(const{key:n,text:o}of t)l(this._normalizedContents,o,(()=>[])).push({batchIdx:r,key:n});return this._requests.push(t),this._contentsTotalSize+=s,r}async send(t){const e=[],s=[];let r=0;for(const[i,c]of this._normalizedContents)e.push(new m({key:String(r++),text:i})),s.push(c);const n=new f(this._parameters);n.contents=e;const o=await t.translate(n);if(!o.success)return Array.from(this._requests,(()=>o));const a=Array.from(this._requests,(()=>({success:!0,results:[]})));for(const i of o.results){const t=Number(i.key);for(const e of s[t])a[e.batchIdx].results.push({...i,key:e.key})}return a}}function w(t){const e=[...new Set(t.to)].sort(),s=t.from??null,r=t.portalUrl,n=t.translator,o=t.apiKey??null;return JSON.stringify([e,s,r,n,o])}async function x(t,e,s){try{return(await t.yieldFor(s))[e]}catch{return{success:!1}}}class S{constructor(t,e,{maxTotalContentSize:s=5e4,maxContentsLength:r=1e3}={}){this._executor=t,this._service=e,this._openBatches=new Map,this._maxTotalContentSize=s,this._maxContentsLength=r}create(t){return{translate:async e=>{const s=w(e),{contents:r,to:n,from:o,translator:a,portalUrl:i,apiKey:c}=e;if(null==n)return{success:!1};if(null==r||r.every((t=>0===t.text.length)))return{success:!1};const l=this._openBatches.get(s);if(null!=l){const e=l.data.tryAdd(r);if(null!=e)return await x(t,e,l);l.send()}const u=new y({to:n,from:o,translator:a,portalUrl:i,apiKey:c},this._maxTotalContentSize,this._maxContentsLength),h=u.tryAdd(r);if(null!=h){const e=this._executor.openBatch(u,{open:t=>{this._openBatches.set(s,t)},execute:t=>t.send(this._service),close:t=>{this._openBatches.get(s)===t&&this._openBatches.delete(s)}});return await x(t,h,e)}return await this._service.translate(e)}}}}function T(i){"async"===i.mode&&(i.functions[t("TranslateText")]=function(t,c){return i.standardFunctionAsync(t,c,(async(t,i,c)=>{if(n(c,2,3,t,i),!_(c[0])&&!d(c[0])&&!o(c[0]))throw new s(t,r.InvalidParameter,i);const l=a(c[0]);if(!_(c[1])&&!d(c[1])&&!o(c[1]))throw new s(t,r.InvalidParameter,i);const h=a(c[1]);let y=null;if(c.length>=3){if(!_(c[2]))throw new s(t,r.InvalidParameter,i);y=c[2]}const x=l.map(((t,e)=>new m({key:String(e),text:t}))),S=t.services?.portal??u.getDefault(),T=new f({to:h,contents:x,from:y,portalUrl:S.restUrl.replace(/\/sharing\/rest$/,"")}),v=new Map;let C=null;if(null!=t.lrucache){const e=t.lrucache;C??=w(T),T.contents=T.contents?.filter((t=>{const s=e.getCachedTranslation(C,t.text);return null==s||(v.set(t.key,{...s,key:t.key,text:t.text}),!1)}))}if(T.contents?.length){const n=t.services?.translation??new g(S,t.console),o=await n.translate(T);if(!o.success)return new e({__proto__:null,success:!1});for(const e of o.results){const n=T.contents?.find((t=>t.key===e.key))?.text;if(null==n)throw new s(null,r.NeverReach,null);v.set(e.key,e),null!=t.lrucache&&(C??=w(T),t.lrucache.setCachedTranslation(C,n,{detectedLanguage:e.detectedLanguage,translation:e.translation}))}}const j=Array.from(x,(n=>{const o=p.fromJSON(v.get(n.key));if(null==o)throw new s(null,r.NeverReach,null);return o.text=n.text,e.convertJsonToArcade(o.toJSON(),t.timeZone??"system",!0)}));return new e({__proto__:null,success:!0,results:j})}))})}const v=Object.freeze(Object.defineProperty({__proto__:null,BatchTranslationServiceFactory:S,PortalTranslationService:g,getTranslateParametersKey:w,registerFunctions:T},Symbol.toStringTag,{value:"Module"}));export{v as A,S as B,g as P,w as g,T as r};
|
package/config.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.34.0-next.
|
|
5
|
+
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.34.0-next.17";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
|
package/core/LRUCache.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{MemCacheStorage as t}from"./MemCache.js";class e{constructor(e,s){this.removeFunc=s,this._storage=new t,this.id="",this.name="",this.size=0,this._storage.maxSize=e,this._storage.register(this)}destroy(){this._storage.deregister(this),this._storage.destroy()}put(t,e,s=1){this._storage.put(this,t,e,s,1)}pop(t){return this._storage.pop(this,t)}get(t){return this._storage.get(this,t)}clear(){this._storage.clearAll()}get maxSize(){return this._storage.maxSize}set maxSize(t){this._storage.maxSize=t}resetHitRate(){}}export{e as LRUCache};
|
|
5
|
+
import{MemCacheStorage as t}from"./MemCache.js";class e{constructor(e,s){this.removeFunc=s,this._storage=new t,this.id="",this.name="",this.size=0,this._storage.maxSize=e,this._storage.register(this)}destroy(){this._storage.deregister(this),this._storage.destroy(),this._storage=null}put(t,e,s=1){this._storage.put(this,t,e,s,1)}pop(t){return this._storage.pop(this,t)}get(t){return this._storage.get(this,t)}clear(){this._storage.clearAll()}get maxSize(){return this._storage.maxSize}set maxSize(t){this._storage.maxSize=t}resetHitRate(){}}export{e as LRUCache};
|
package/core/MemCache.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const t=-3,i=t-1;var s;!function(t){t[t.ALL=0]="ALL",t[t.SOME=1]="SOME"}(s||(s={}));class e{constructor(t,i,s,e=0){this.name=t,this._storage=i,this.removeFunc=s,this._defaultPriority=e,this.id=`${r++}${_}`,this.size=0,this._hit=0,this._miss=0,this._storage.register(this)}destroy(){this._storage.deregister(this),this._storage=null}get hitRate(){return this._hit/(this._hit+this._miss)}get storageSize(){return this._storage.size}getSize(t){return this._storage.getSize(this,t)}set maxSize(t){this._storage.setMaxSize(this,t)}resetHitRate(){this._hit=this._miss=0}put(t,i,s=this._defaultPriority){this._storage.put(this,t,i,i.cachedMemory,s)}pop(t){const i=this._storage.pop(this,t);return void 0===i?++this._miss:++this._hit,i}get(t){const i=this._storage.get(this,t);return void 0===i?++this._miss:++this._hit,i}peek(t){return this._storage.peek(this,t)}updateSize(t,i){this._storage.updateSize(this,t,i,i.cachedMemory)}clear(){this._storage.clear(this)}clearAll(){this._storage.clearAll()}*[Symbol.iterator](){yield*this._storage.values(this)}get performanceInfo(){return this._storage.performanceInfo}resetStats(){this._storage.resetStats()}}class h{get size(){return this._size}constructor(t=10485760){this._maxSize=t,this._db=new Map,this._size=0,this._hit=0,this._miss=0,this._users=new Map,this._sizeLimits=new Map}destroy(){this.clearAll(),this._sizeLimits.clear(),this._users.clear()}register(t){this._users.set(t.id.slice(0,-1),t)}deregister(t){this.clear(t),this._sizeLimits.delete(t),this._users.delete(t.id.slice(0,-1))}get maxSize(){return this._maxSize}set maxSize(t){this._maxSize=Math.max(t,-1),this._checkSize()}getSize(t,i){const s=this._db.get(t.id+i);return s?.size??0}put(e,h,r,_,n){h=e.id+h;const a=this._db.get(h);if(a&&(this._size-=a.size,e.size-=a.size,this._db.delete(h),a.entry!==r&&this._notifyRemove(h,a.entry,a.size,s.ALL)),_>this._maxSize)return void this._notifyRemove(h,r,_,s.ALL);if(void 0===r)return void console.warn("Refusing to cache undefined entry ");if(!_||_<0)return console.warn(`Refusing to cache entry with size ${_} for key ${h}`),void this._notifyRemove(h,r,0,s.ALL);const c=1+Math.max(n,i)-t;this._db.set(h,new o(r,_,c)),this._size+=_,e.size+=_,this._checkSize()}updateSize(t,i,e,h){i=t.id+i;const r=this._db.get(i);if(r&&r.entry===e){for(this._size-=r.size,t.size-=r.size;h>this._maxSize;){const t=this._notifyRemove(i,e,h,s.SOME);if(!(null!=t&&t>0))return void this._db.delete(i);h=t}r.size=h,this._size+=h,t.size+=h,this._checkSize()}}pop(t,i){i=t.id+i;const s=this._db.get(i);if(s)return this._size-=s.size,t.size-=s.size,this._db.delete(i),++this._hit,s.entry;++this._miss}get(t,i){i=t.id+i;const s=this._db.get(i);if(void 0!==s)return this._db.delete(i),s.lives=s.lifetime,this._db.set(i,s),++this._hit,s.entry;++this._miss}peek(t,i){const s=this._db.get(t.id+i);return s?++this._hit:++this._miss,s?.entry}get performanceInfo(){const i={Size:Math.round(this._size/1048576)+"/"+Math.round(this._maxSize/1048576)+"MB","Hit rate":Math.round(100*this._getHitRate())+"%",Entries:this._db.size.toString()},s={},e=new Array;this._db.forEach(((t,i)=>{const h=t.lifetime;e[h]=(e[h]||0)+t.size,this._users.forEach((e=>{const{id:h,name:r}=e;if(i.startsWith(h)){const i=s[r]||0;s[r]=i+t.size}}))}));const h={};this._users.forEach((t=>{const i=t.name;if("hitRate"in t&&"number"==typeof t.hitRate&&!isNaN(t.hitRate)&&t.hitRate>0){const e=s[i]||0;s[i]=e,h[i]=Math.round(100*t.hitRate)+"%"}else h[i]="0%"}));const r=Object.keys(s);r.sort(((t,i)=>s[i]-s[t])),r.forEach((t=>i[t]=Math.round(s[t]/2**20)+"MB / "+h[t]));for(let o=e.length-1;o>=0;--o){const s=e[o];s&&(i["Priority "+(o+t-1)]=Math.round(s/this._size*100)+"%")}return i}resetStats(){this._hit=this._miss=0,this._users.forEach((t=>t.resetHitRate()))}clear(t){const i=t.id;this._db.forEach(((t,e)=>{e.startsWith(i)&&(this._size-=t.size,this._db.delete(e),this._notifyRemove(e,t.entry,t.size,s.ALL))})),t.size=0}clearAll(){this._db.forEach(((t,i)=>this._notifyRemove(i,t.entry,t.size,s.ALL))),this._users.forEach((t=>t.size=0)),this._size=0,this._db.clear()}*values(t){for(const[i,s]of this._db)i.startsWith(t.id)&&(yield s.entry)}_getHitRate(){return this._hit/(this._hit+this._miss)}_notifyRemove(t,i,s,e){const h=this._users.get(t.split(_)[0])?.removeFunc,r=h?.(i,e,s);return"number"==typeof r?r:null}_checkSize(){this._sizeLimits.forEach(((t,i)=>this._checkSizeLimits(t,i))),this._checkSizeLimits(this.maxSize)}setMaxSize(t,i){null==i||i<=0?this._sizeLimits.delete(t):this._sizeLimits.set(t,i)}_checkSizeLimits(t,i){const s=i??this;if(s.size<=t)return;const e=i?.id;let h=!0;for(;h;){h=!1;for(const[r,o]of this._db)if(0===o.lifetime&&(!e||r.startsWith(e))){const e=i??this._users.get(r.split(_)[0]);if(this._purgeItem(r,o,e),s.size<=.9*t)return;h||=this._db.has(r)}}for(const[r,o]of this._db)if(!e||r.startsWith(e)){const e=i??this._users.get(r.split(_)[0]);if(this._purgeItem(r,o,e),s.size<=.9*t)return}}_purgeItem(t,i,e){if(this._db.delete(t),i.lives<=1){this._size-=i.size,e&&(e.size-=i.size);const h=this._notifyRemove(t,i.entry,i.size,s.SOME);null!=h&&h>0&&(this._size+=h,e&&(e.size+=h),i.lives=i.lifetime,i.size=h,this._db.set(t,i))}else--i.lives,this._db.set(t,i)}}let r=0;class o{constructor(t,i,s){this.entry=t,this.size=i,this.lifetime=s,this.lives=s}}const _=":";export{e as MemCache,h as MemCacheStorage,t as MinPriority,i as NoPriority,s as RemoveMode};
|
|
5
|
+
const t=-3,i=t-1;var s;!function(t){t[t.ALL=0]="ALL",t[t.SOME=1]="SOME"}(s||(s={}));class e{constructor(t,i,s,e=0){this.name=t,this._storage=i,this.removeFunc=s,this._defaultPriority=e,this.id=`${r++}${_}`,this.size=0,this._hit=0,this._miss=0,this._storage.register(this)}destroy(){this._storage.deregister(this),this._storage=null}get hitRate(){return this._hit/(this._hit+this._miss)}get storageSize(){return this._storage.size}getSize(t){return this._storage.getSize(this,t)}set maxSize(t){this._storage.setMaxSize(this,t)}resetHitRate(){this._hit=this._miss=0}put(t,i,s=this._defaultPriority){this._storage.put(this,t,i,i.cachedMemory,s)}pop(t){const i=this._storage.pop(this,t);return void 0===i?++this._miss:++this._hit,i}get(t){const i=this._storage.get(this,t);return void 0===i?++this._miss:++this._hit,i}peek(t){return this._storage.peek(this,t)}updateSize(t,i){this._storage.updateSize(this,t,i,i.cachedMemory)}clear(){this._storage.clear(this)}clearAll(){this._storage.clearAll()}*[Symbol.iterator](){yield*this._storage.values(this)}get performanceInfo(){return this._storage.performanceInfo}resetStats(){this._storage.resetStats()}}class h{get size(){return this._size}constructor(t=10485760){this._maxSize=t,this._db=new Map,this._size=0,this._hit=0,this._miss=0,this._users=new Map,this._sizeLimits=new Map}destroy(){this.clearAll(),this._sizeLimits.clear(),this._users.clear(),this._db=null}register(t){this._users.set(t.id.slice(0,-1),t)}deregister(t){this.clear(t),this._sizeLimits.delete(t),this._users.delete(t.id.slice(0,-1))}get maxSize(){return this._maxSize}set maxSize(t){this._maxSize=Math.max(t,-1),this._checkSize()}getSize(t,i){const s=this._db.get(t.id+i);return s?.size??0}put(e,h,r,_,n){h=e.id+h;const a=this._db.get(h);if(a&&(this._size-=a.size,e.size-=a.size,this._db.delete(h),a.entry!==r&&this._notifyRemove(h,a.entry,a.size,s.ALL)),_>this._maxSize)return void this._notifyRemove(h,r,_,s.ALL);if(void 0===r)return void console.warn("Refusing to cache undefined entry ");if(!_||_<0)return console.warn(`Refusing to cache entry with size ${_} for key ${h}`),void this._notifyRemove(h,r,0,s.ALL);const c=1+Math.max(n,i)-t;this._db.set(h,new o(r,_,c)),this._size+=_,e.size+=_,this._checkSize()}updateSize(t,i,e,h){i=t.id+i;const r=this._db.get(i);if(r&&r.entry===e){for(this._size-=r.size,t.size-=r.size;h>this._maxSize;){const t=this._notifyRemove(i,e,h,s.SOME);if(!(null!=t&&t>0))return void this._db.delete(i);h=t}r.size=h,this._size+=h,t.size+=h,this._checkSize()}}pop(t,i){i=t.id+i;const s=this._db.get(i);if(s)return this._size-=s.size,t.size-=s.size,this._db.delete(i),++this._hit,s.entry;++this._miss}get(t,i){i=t.id+i;const s=this._db.get(i);if(void 0!==s)return this._db.delete(i),s.lives=s.lifetime,this._db.set(i,s),++this._hit,s.entry;++this._miss}peek(t,i){const s=this._db.get(t.id+i);return s?++this._hit:++this._miss,s?.entry}get performanceInfo(){const i={Size:Math.round(this._size/1048576)+"/"+Math.round(this._maxSize/1048576)+"MB","Hit rate":Math.round(100*this._getHitRate())+"%",Entries:this._db.size.toString()},s={},e=new Array;this._db.forEach(((t,i)=>{const h=t.lifetime;e[h]=(e[h]||0)+t.size,this._users.forEach((e=>{const{id:h,name:r}=e;if(i.startsWith(h)){const i=s[r]||0;s[r]=i+t.size}}))}));const h={};this._users.forEach((t=>{const i=t.name;if("hitRate"in t&&"number"==typeof t.hitRate&&!isNaN(t.hitRate)&&t.hitRate>0){const e=s[i]||0;s[i]=e,h[i]=Math.round(100*t.hitRate)+"%"}else h[i]="0%"}));const r=Object.keys(s);r.sort(((t,i)=>s[i]-s[t])),r.forEach((t=>i[t]=Math.round(s[t]/2**20)+"MB / "+h[t]));for(let o=e.length-1;o>=0;--o){const s=e[o];s&&(i["Priority "+(o+t-1)]=Math.round(s/this._size*100)+"%")}return i}resetStats(){this._hit=this._miss=0,this._users.forEach((t=>t.resetHitRate()))}clear(t){const i=t.id;this._db.forEach(((t,e)=>{e.startsWith(i)&&(this._size-=t.size,this._db.delete(e),this._notifyRemove(e,t.entry,t.size,s.ALL))})),t.size=0}clearAll(){this._db.forEach(((t,i)=>this._notifyRemove(i,t.entry,t.size,s.ALL))),this._users.forEach((t=>t.size=0)),this._size=0,this._db.clear()}*values(t){for(const[i,s]of this._db)i.startsWith(t.id)&&(yield s.entry)}_getHitRate(){return this._hit/(this._hit+this._miss)}_notifyRemove(t,i,s,e){const h=this._users.get(t.split(_)[0])?.removeFunc,r=h?.(i,e,s);return"number"==typeof r?r:null}_checkSize(){this._sizeLimits.forEach(((t,i)=>this._checkSizeLimits(t,i))),this._checkSizeLimits(this.maxSize)}setMaxSize(t,i){null==i||i<=0?this._sizeLimits.delete(t):this._sizeLimits.set(t,i)}_checkSizeLimits(t,i){const s=i??this;if(s.size<=t)return;const e=i?.id;let h=!0;for(;h;){h=!1;for(const[r,o]of this._db)if(0===o.lifetime&&(!e||r.startsWith(e))){const e=i??this._users.get(r.split(_)[0]);if(this._purgeItem(r,o,e),s.size<=.9*t)return;h||=this._db.has(r)}}for(const[r,o]of this._db)if(!e||r.startsWith(e)){const e=i??this._users.get(r.split(_)[0]);if(this._purgeItem(r,o,e),s.size<=.9*t)return}}_purgeItem(t,i,e){if(this._db.delete(t),i.lives<=1){this._size-=i.size,e&&(e.size-=i.size);const h=this._notifyRemove(t,i.entry,i.size,s.SOME);null!=h&&h>0&&(this._size+=h,e&&(e.size+=h),i.lives=i.lifetime,i.size=h,this._db.set(t,i))}else--i.lives,this._db.set(t,i)}}let r=0;class o{constructor(t,i,s){this.entry=t,this.size=i,this.lifetime=s,this.lives=s}}const _=":";export{e as MemCache,h as MemCacheStorage,t as MinPriority,i as NoPriority,s as RemoveMode};
|
package/core/arrayUtils.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toConst as t}from"./compilerUtils.js";import n from"./RandomLCG.js";const e=1.5,r=1/e,o=.5;function l(t,n){if(!n)return t;for(const e of n)t.push(e);return t}function u(t){return t}function f(t,n=u){if(!t||0===t.length)return;let e=t[0],r=n(e);for(let o=1;o<t.length;++o){const l=t[o],u=Number(n(l));u>r&&(r=u,e=l)}return e}function i(t,n=u){return f(t,(t=>-n(t)))}function c(t,n){return n?t.filter(((t,e,r)=>r.findIndex(n.bind(null,t))===e)):Array.from(new Set(t))}function s(t,n,e,r,o,l,u){if(null==t&&null==r)return!0;n=Math.max(0,n),o=Math.max(0,o),e=Math.max(0,e<0?(t?.length??0)+e:e),l=Math.max(0,l<0?(r?.length??0)+l:l);const f=e-n;if(null==t||null==r||f!==l-o)return!1;if(u){for(let i=0;i<f;i++)if(!u(t[n+i],r[o+i]))return!1}else for(let i=0;i<f;i++)if(t[n+i]!==r[o+i])return!1;return!0}function h(t,n,e){return s(t,0,t?.length??0,n,0,n?.length??0,e)}function a(t,n){let e=t.length!==n.length;e&&(t.length=n.length);for(let r=0;r<n.length;++r)t[r]!==n[r]&&(t[r]=n[r],e=!0);return e}function
|
|
5
|
+
import{toConst as t}from"./compilerUtils.js";import n from"./RandomLCG.js";const e=1.5,r=1/e,o=.5;function l(t,n){if(!n)return t;for(const e of n)t.push(e);return t}function u(t){return t}function f(t,n=u){if(!t||0===t.length)return;let e=t[0],r=n(e);for(let o=1;o<t.length;++o){const l=t[o],u=Number(n(l));u>r&&(r=u,e=l)}return e}function i(t,n=u){return f(t,(t=>-n(t)))}function c(t,n){return n?t.filter(((t,e,r)=>r.findIndex(n.bind(null,t))===e)):Array.from(new Set(t))}function s(t,n,e,r,o,l,u){if(null==t&&null==r)return!0;n=Math.max(0,n),o=Math.max(0,o),e=Math.max(0,e<0?(t?.length??0)+e:e),l=Math.max(0,l<0?(r?.length??0)+l:l);const f=e-n;if(null==t||null==r||f!==l-o)return!1;if(u){for(let i=0;i<f;i++)if(!u(t[n+i],r[o+i]))return!1}else for(let i=0;i<f;i++)if(t[n+i]!==r[o+i])return!1;return!0}function h(t,n,e){return s(t,0,t?.length??0,n,0,n?.length??0,e)}function a(t,n){let e=t.length!==n.length;e&&(t.length=n.length);for(let r=0;r<n.length;++r)t[r]!==n[r]&&(t[r]=n[r],e=!0);return e}function d(t,n,e){let r,o;return e?(r=n.filter((n=>!t.some((t=>e(t,n))))),o=t.filter((t=>!n.some((n=>e(n,t)))))):(r=n.filter((n=>!t.includes(n))),o=t.filter((t=>!n.includes(t)))),{added:r,removed:o}}function g(t,n,e){return t&&n?e?t.filter((t=>n.findIndex((n=>e(t,n)))>-1)):t.filter((t=>n.includes(t))):[]}function m(t){return t&&"number"==typeof t.length}function p(t,n){const e=t.length;if(0===e)return[];const r=[];for(let o=0;o<e;o+=n)r.push(t.slice(o,o+n));return r}function M(t,n){void 0===n&&(n=t,t=0);const e=new Array(n-t);for(let r=t;r<n;r++)e[r-t]=r;return e}function x(t,n,e){const r=t.length;let o=0,l=r-1;for(;o<l;){const e=o+Math.floor((l-o)/2);n>t[e]?o=e+1:l=e}const u=t[o];return e?n>=t[r-1]?-1:u===n?o:o-1:u===n?o:-1}class w{constructor(){this.last=0}}const b=new w;function y(t,n,e,r){r=r||b;const o=Math.max(0,r.last-10);for(let u=o;u<e;++u)if(t[u]===n)return r.last=u,u;const l=Math.min(o,e);for(let u=0;u<l;++u)if(t[u]===n)return r.last=u,u;return-1}function S(n,e,r,o){const l=r??n.length,u=y(n,t(e),l,o);if(-1!==u)return n[u]=n[l-1],null==r&&n.pop(),e}const j=new Set;function v(t,n,e=t.length,r=n.length,o,l){if(0===r||0===e)return e;j.clear();for(let f=0;f<r;++f)j.add(n[f]);o=o||b;const u=Math.max(0,o.last-10);for(let f=u;f<e;++f)if(j.has(t[f])&&(l?.push(t[f]),j.delete(t[f]),t[f]=t[e-1],--e,--f,0===j.size||0===e))return j.clear(),e;for(let f=0;f<u;++f)if(j.has(t[f])&&(l?.push(t[f]),j.delete(t[f]),t[f]=t[e-1],--e,--f,0===j.size||0===e))return j.clear(),e;return j.clear(),e}function z(t,n){let e=0;for(let r=0;r<t.length;++r){const o=t[r];n(o,r)&&(t[e]=o,e++)}t.length=e}function A(t,n,e){const r=t.length;if(n>=r)return t.slice();const o=I(e),l=new Set,u=[];for(;u.length<n;){const n=Math.floor(o()*r);l.has(n)||(l.add(n),u.push(t[n]))}return u}function I(t){return t?(C.seed=t,()=>C.getFloat()):Math.random}const C=new n;function F(t,n){if(!t)return t;const e=I(n);for(let r=t.length-1;r>0;r--){const n=Math.floor(e()*(r+1)),o=t[r];t[r]=t[n],t[n]=o}return t}function G(t,n){const e=t.indexOf(n);return-1!==e?(t.splice(e,1),n):null}function L(t,n){return null!=t}function N(t,...n){for(const e of n)null!=e&&t.push(e);return t.length}function O(t,n){return t.reduce(((t,e)=>n(e)?t+1:t),0)}const R=[];export{w as PositionHint,l as addMany,x as binaryIndexOf,O as countIf,d as difference,R as emptyArray,h as equals,z as filterInPlace,I as getRandomNumberGenerator,y as indexOf,g as intersect,m as isArrayLike,L as isSome,f as max,i as min,A as pickRandom,N as pushIfSome,M as range,e as reallocGrowthFactor,r as reallocShrinkFactor,o as reallocShrinkThreshold,G as remove,S as removeUnordered,v as removeUnorderedMany,F as shuffle,s as sliceEquals,p as splitIntoChunks,c as unique,a as update};
|
package/core/urlUtils.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../config.js";import{isSome as n}from"./arrayUtils.js";import e from"./Error.js";import r from"./Logger.js";import{isSerializable as o}from"./support/jsonUtils.js";import{parseKnownArcGISOnlineDomain as s}from"../portal/support/urlUtils.js";import{base64ToArrayBuffer as i,arrayBufferToBase64 as u}from"../support/base64Utils.js";const l=()=>r.getLogger("esri.core.urlUtils"),c=t.request,f="esri/config: esriConfig.request.proxyUrl is not set.",a=/^\s*[a-z][a-z0-9-+.]*:(?![0-9])/i,p=/^\s*http:/i,h=/^\s*https:/i,d=/^\s*file:/i,m=/:\d+$/,y=/^https?:\/\/[^/]+\.arcgis.com\/sharing(\/|$)/i,g=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"),$=new RegExp("^((([^[:]+):)?([^@]+)@)?(\\[([^\\]]+)\\]|([^[:]*))(:([0-9]+))?$");class x{constructor(t=""){this.uri=t,this.scheme=null,this.authority=null,this.path=null,this.query=null,this.fragment=null,this.user=null,this.password=null,this.host=null,this.port=null;let n=this.uri.match(g);this.scheme=n[2]||(n[1]?"":null),this.authority=n[4]||(n[3]?"":null),this.path=n[5],this.query=n[7]||(n[6]?"":null),this.fragment=n[9]||(n[8]?"":null),null!=this.authority&&(n=this.authority.match($),this.user=n[3]||null,this.password=n[4]||null,this.host=n[6]||n[7],this.port=n[9]||null)}toString(){return this.uri}}const w={},U=new x(t.applicationUrl);let O=U;const R=b();let q=R;const C=()=>O,j=()=>q;function b(){const t=O.path,n=t.slice(0,t.lastIndexOf("/")+1);return`${`${O.scheme}://${O.host}${null!=O.port?`:${O.port}`:""}`}${n}`}const L={setAppUrl:t=>O=t,setAppBaseUrl:t=>q=t,restoreUrls:()=>{O=U,q=R}};function I(t){if(!t)return null;const n={path:null,query:null},e=new x(t),r=t.indexOf("?");return null===e.query?n.path=t:(n.path=t.slice(0,r),n.query=A(e.query)),e.fragment&&(n.hash=e.fragment,null===e.query&&(n.path=n.path.slice(0,n.path.length-(e.fragment.length+1)))),n}function A(t){const n=t.split("&"),e={};for(const r of n){if(!r)continue;const t=r.indexOf("=");let n,o;t<0?(n=decodeURIComponent(r),o=""):(n=decodeURIComponent(r.slice(0,t)),o=decodeURIComponent(r.slice(t+1)));let s=e[n];"string"==typeof s&&(s=e[n]=[s]),Array.isArray(s)?s.push(o):e[n]=o}return e}function v(t,n){return t?n&&"function"==typeof n?Object.keys(t).map((e=>encodeURIComponent(e)+"="+encodeURIComponent(n(e,t[e])))).join("&"):Object.keys(t).map((e=>{const r=t[e];if(null==r)return"";const s=encodeURIComponent(e)+"=",i=n?.[e];return i?s+encodeURIComponent(i(r)):Array.isArray(r)?r.map((t=>o(t)?s+encodeURIComponent(JSON.stringify(t)):s+encodeURIComponent(t))).join("&"):o(r)?s+encodeURIComponent(JSON.stringify(r)):s+encodeURIComponent(r)})).filter((t=>t)).join("&"):""}function P(t=!1){let n,r=c.proxyUrl;if("string"==typeof t){n=dt(t);const e=T(t);e&&(r=e.proxyUrl)}else n=!!t;if(!r)throw l().warn(f),new e("urlUtils:proxy-not-set",f);n&&wt()&&(r=$t(r));return I(r)}function k(t,n=!1){const e=T(t);let r,o;if(e){const t=S(e.proxyUrl);r=t.path,o=t.query?A(t.query):null}else if(n){const n=P(t);r=n.path,o=n.query}if(r){const n=I(t);t=r+"?"+n.path;const e=v({...o,...n.query});e&&(t=`${t}?${e}`)}return t}const E={path:"",query:""};function S(t){const n=t.indexOf("?");return-1!==n?(E.path=t.slice(0,n),E.query=t.slice(n+1)):(E.path=t,E.query=null),E}function B(t){return t=(t=Ut(t=Ct(t=S(t).path),!0)).toLowerCase()}function H(t){const n={proxyUrl:t.proxyUrl,urlPrefix:B(t.urlPrefix)},e=c.proxyRules,r=n.urlPrefix;let o=e.length;for(let s=0;s<e.length;s++){const t=e[s].urlPrefix;if(0===r.indexOf(t)){if(r.length===t.length)return-1;o=s;break}0===t.indexOf(r)&&(o=s+1)}return e.splice(o,0,n),o}function T(t){const n=c.proxyRules,e=B(t);for(let r=0;r<n.length;r++)if(0===e.indexOf(n[r].urlPrefix))return n[r]}function W(t,n){if(!t||!n)return!1;t=J(t),n=J(n);const e=s(t),r=s(n);return null!=e&&null!=r?e.portalHostname===r.portalHostname:null==e&&null==r&&F(t,n,!0)}function z(t,n){if(!t||!n)return!1;t=J(t),n=J(n);const e=s(t),r=s(n);return null!=e&&null!=r&&e.portalHostname===r.portalHostname}function D(t,n){return t=J(t),n=J(n),Ut(t)===Ut(n)}function J(t){const n=(t=K(t)).indexOf("/sharing");return n>0?t.slice(0,n):t.replace(/\/+$/,"")}function N(t,n=c.interceptors){const e=n=>n instanceof RegExp?n.test(t):"string"==typeof n?t.startsWith(n):null==n;if(n)for(const r of n)if(Array.isArray(r.urls)){if(r.urls.some(e))return r}else if(e(r.urls))return r;return null}function F(t,n,e=!1){if(!t||!n)return!1;const r=Pt(t),o=Pt(n);return!(!e&&r.scheme!==o.scheme)&&(null!=r.host&&null!=o.host&&(r.host.toLowerCase()===o.host.toLowerCase()&&r.port===o.port))}function M(t){if("string"==typeof t){if(!Y(t))return!0;t=Pt(t)}if(F(t,O))return!0;const n=c.trustedServers||[];for(let e=0;e<n.length;e++){const r=Q(n[e]);for(let n=0;n<r.length;n++)if(F(t,r[n]))return!0}return!1}function Q(t){return w[t]||(ht(t)||pt(t)?w[t]=[new x(_(t))]:w[t]=[new x(`http://${t}`),new x(`https://${t}`)]),w[t]}function _(t,n=q,e){return pt(t)?e?.preserveProtocolRelative?t:"http"===O.scheme&&O.authority===X(t).slice(2)?`http:${t}`:`https:${t}`:ht(t)?t:V("/"===t[0]?Ot(n):n,t)}function G(t,n=q,e){if(null==t||!Y(t))return t;const r=K(t),o=r.toLowerCase(),s=K(n).toLowerCase().replace(/\/+$/,""),i=e?K(e).toLowerCase().replace(/\/+$/,""):null;if(i&&0!==s.indexOf(i))return t;const u=(t,n,e)=>-1===(e=t.indexOf(n,e))?t.length:e;let l=u(o,"/",o.indexOf("//")+2),c=-1;for(;o.slice(0,l+1)===s.slice(0,l)+"/"&&(c=l+1,l!==o.length);)l=u(o,"/",l+1);if(-1===c)return t;if(i&&c<i.length)return t;t=r.slice(c);const f=s.slice(c-1).replaceAll(/[^/]+/g,"").length;if(f>0)for(let a=0;a<f;a++)t=`../${t}`;else t=`./${t}`;return t}function K(t){return t=It(t=Lt(t=bt(t=_(t=t.trim()))))}function V(...t){const e=t.filter(n);if(!e?.length)return;const r=[];if(Y(e[0])){const t=e[0],n=t.indexOf("//");-1!==n&&(r.push(t.slice(0,n+1)),yt(e[0])&&(r[0]+="/"),e[0]=t.slice(n+2))}else"/"===e[0][0]&&r.push("");const o=e.reduce(((t,n)=>n?t.concat(n.split("/")):t),[]);for(let n=0;n<o.length;n++){const t=o[n];".."===t&&r.length>0&&".."!==r[r.length-1]?r.pop():(!t&&n===o.length-1||t&&("."!==t||0===r.length))&&r.push(t)}return r.join("/")}function X(t,n=!1){if(null==t||Z(t)||tt(t))return null;let e=t.indexOf("://");if(-1===e&&pt(t))e=2;else{if(-1===e)return null;e+=3}const r=t.indexOf("/",e);return-1!==r&&(t=t.slice(0,r)),n&&(t=Ut(t,!0)),t}function Y(t){return pt(t)||ht(t)}function Z(t){return null!=t&&"blob:"===t.slice(0,5)}function tt(t){return null!=t&&"data:"===t.slice(0,5)}function nt(t){const n=ot(t);return n?.isBase64?i(n.data):null}function et(t){return u(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}const rt=/^data:(.*?)(;base64)?,(.*)$/;function ot(t){const n=t.match(rt);if(!n)return null;const[,e,r,o]=n;return{mediaType:e,isBase64:!!r,data:o}}function st(t){return t.isBase64?`data:${t.mediaType};base64,${t.data}`:`data:${t.mediaType},${t.data}`}async function it(t){return(await fetch(t)).blob()}function ut(t){const n=nt(t);if(!n)return null;const e=ot(t);return new Blob([n],{type:e.mediaType})}function lt(t,n){ft(t,n)}function ct(t,n){at(t,n)}function ft(t,n){const e=ut(t);return!!e&&at(e,n)}function at(t,n){if(!t)return!1;const e=document.createElement("a");if(!("download"in e))return!1;const r=URL.createObjectURL(t);return e.download=n,e.href=r,e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(r),!0}function pt(t){return null!=t&&"/"===t[0]&&"/"===t[1]}function ht(t){return null!=t&&a.test(t)}function dt(t){return null!=t&&h.test(t)||"https"===O.scheme&&pt(t)}function mt(t){return null!=t&&p.test(t)||"http"===O.scheme&&pt(t)}function yt(t){return null!=t&&d.test(t)}function gt(t){return pt(t)?`http:${t}`:t.replace(h,"http:")}function $t(t){return pt(t)?`https:${t}`:t.replace(p,"https:")}function xt(){return"http"===O.scheme}function wt(){return"https"===O.scheme}function Ut(t,n=!1){return pt(t)?t.slice(2):(t=t.replace(a,""),n&&t.length>1&&"/"===t[0]&&"/"===t[1]&&(t=t.slice(2)),t)}function Ot(t){const n=t.indexOf("//"),e=t.indexOf("/",n+2);return-1===e?t:t.slice(0,e)}function Rt(t){let n=0;if(Y(t)){const e=t.indexOf("//");-1!==e&&(n=e+2)}const e=t.lastIndexOf("/");return e<n?t:t.slice(0,e+1)}function qt(t,n){if(!t)return"";const e=I(t).path.replace(/\/+$/,""),r=e.slice(e.lastIndexOf("/")+1);if(!n?.length)return r;const o=new RegExp(`\\.(${n.join("|")})$`,"i");return r.replace(o,"")}function Ct(t){return t.endsWith("/")?t:`${t}/`}function jt(t){return t.replace(/\/+$/,"")}function bt(t){if(/^https?:\/\//i.test(t)){const n=S(t);t=(t=n.path.replaceAll(/\/{2,}/g,"/")).replace("/","//"),n.query&&(t+=`?${n.query}`)}return t}function Lt(t){return t.replace(/^(https?:\/\/)(arcgis\.com)/i,"$1www.$2")}function It(t){const n=c.httpsDomains;if(!mt(t))return t;const e=t.indexOf("/",7);let r;if(r=-1===e?t:t.slice(0,e),r=r.toLowerCase().slice(7),m.test(r)){if(!r.endsWith(":80"))return t;r=r.slice(0,-3),t=t.replace(":80","")}return xt()&&r===O.authority&&!y.test(t)||(wt()&&r===O.authority||n&&n.some((t=>r===t||r.endsWith(`.${t}`)))||wt()&&!T(t))&&(t=$t(t)),t}function At(t,n,e){if(!(n&&e&&t&&Y(t)))return t;const r=t.indexOf("//"),o=t.indexOf("/",r+2),s=t.indexOf(":",r+2),i=Math.min(o<0?t.length:o,s<0?t.length:s);if(t.slice(r+2,i).toLowerCase()!==n.toLowerCase())return t;return`${t.slice(0,r+2)}${e}${t.slice(i)}`}function vt(t,n){const e=new URL(t);return e.host=n,e.port&&!m.test(n)&&(e.port=""),e.toString()}function Pt(t){return"string"==typeof t?new x(_(t)):(t.scheme||(t.scheme=O.scheme),t)}function kt(t){return Jt.test(t)}function Et(t,n){const e=I(t),r=Object.keys(e.query||{});return r.length>0&&n&&n.warn("removeQueryParameters()",`Url query parameters are not supported, the following parameters have been removed: ${r.join(", ")}.`),e.path}function St(t,n,e){const r=I(t),o=r.query||{};return o[n]=String(e),`${r.path}?${v(o)}`}function Bt(t,n){if(!n)return t;const e=I(t),r=e.query||{};for(const[s,i]of Object.entries(n))null!=i&&(r[s]=i);const o=v(r);return o?`${e.path}?${o}`:e.path}function Ht(t,n){const{path:e,query:r}=I(t);if(!r)return t;delete r[n];const o=v(r);return o?`${e}?${o}`:e}function Tt(t){if(null==t)return null;const n=t.match(Dt);return n?n[2]:null}function Wt(t){if(null==t)return null;const n=t.match(Dt);return n?{path:n[1],extension:n[2]}:{path:t,extension:null}}async function zt(t){if("string"==typeof t){return ot(t)??{data:t}}return new Promise(((n,e)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>n(ot(r.result)),r.onerror=t=>e(t)}))}const Dt=/([^.]*)\.([^/]*)$/,Jt=/(^data:image\/svg|\.svg$)/i;export{x as Url,k as addProxy,H as addProxyRule,St as addQueryParameter,Bt as addQueryParameters,et as base64UrlEncode,it as blobUrlToBlob,At as changeDomain,vt as changeHost,ot as dataComponents,nt as dataToArrayBuffer,ut as dataToBlob,ct as downloadBlobAsFile,lt as downloadDataAsFile,Ct as ensureTrailingSlash,j as getAppBaseUrl,C as getAppUrl,qt as getFilename,N as getInterceptor,X as getOrigin,Tt as getPathExtension,T as getProxyRule,P as getProxyUrl,ht as hasProtocol,z as hasSameCanonicalArcGISOnlinePortal,W as hasSameCanonicalPortal,F as hasSameOrigin,D as hasSamePortal,Y as isAbsolute,wt as isAppHTTPS,Z as isBlobProtocol,tt as isDataProtocol,dt as isHTTPSProtocol,pt as isProtocolRelative,kt as isSVG,M as isTrustedServer,V as join,_ as makeAbsolute,st as makeData,G as makeRelative,K as normalize,v as objectToQuery,zt as parseData,A as queryToObject,Rt as removeFile,Ht as removeQueryParameter,Et as removeQueryParameters,jt as removeTrailingSlash,Wt as splitPathExtension,L as test,gt as toHTTP,$t as toHTTPS,w as trustedServersUrlCache,I as urlToObject};
|
|
5
|
+
import t from"../config.js";import{isSome as n}from"./arrayUtils.js";import e from"./Error.js";import r from"./Logger.js";import{isSerializable as o}from"./support/jsonUtils.js";import{parseKnownArcGISOnlineDomain as s}from"../portal/support/urlUtils.js";import{base64ToArrayBuffer as i,arrayBufferToBase64 as u}from"../support/base64Utils.js";const l=()=>r.getLogger("esri.core.urlUtils"),c=t.request,f="esri/config: esriConfig.request.proxyUrl is not set.",a=/^\s*[a-z][a-z0-9-+.]*:(?![0-9])/i,p=/^\s*http:/i,h=/^\s*https:/i,d=/^\s*file:/i,m=/:\d+$/,y=/^https?:\/\/[^/]+\.arcgis.com\/sharing(\/|$)/i,g=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"),$=new RegExp("^((([^[:]+):)?([^@]+)@)?(\\[([^\\]]+)\\]|([^[:]*))(:([0-9]+))?$");class x{constructor(t=""){this.uri=t,this.scheme=null,this.authority=null,this.path=null,this.query=null,this.fragment=null,this.user=null,this.password=null,this.host=null,this.port=null;let n=this.uri.match(g);this.scheme=n[2]||(n[1]?"":null),this.authority=n[4]||(n[3]?"":null),this.path=n[5],this.query=n[7]||(n[6]?"":null),this.fragment=n[9]||(n[8]?"":null),null!=this.authority&&(n=this.authority.match($),this.user=n[3]||null,this.password=n[4]||null,this.host=n[6]||n[7],this.port=n[9]||null)}toString(){return this.uri}}const w={},U=new x(t.applicationUrl);let O=U;const R=b();let q=R;const C=()=>O,j=()=>q;function b(){const t=O.path,n=t.slice(0,t.lastIndexOf("/")+1);return`${`${O.scheme}://${O.host}${null!=O.port?`:${O.port}`:""}`}${n}`}const L={setAppUrl:t=>O=t,setAppBaseUrl:t=>q=t,restoreUrls:()=>{O=U,q=R}};function I(t){if(!t)return null;const n={path:null,query:null},e=new x(t),r=t.indexOf("?");return null===e.query?n.path=t:(n.path=t.slice(0,r),n.query=A(e.query)),e.fragment&&(n.hash=e.fragment,null===e.query&&(n.path=n.path.slice(0,n.path.length-(e.fragment.length+1)))),n}function A(t){const n=t.split("&"),e={};for(const r of n){if(!r)continue;const t=r.indexOf("=");let n,o;t<0?(n=decodeURIComponent(r),o=""):(n=decodeURIComponent(r.slice(0,t)),o=decodeURIComponent(r.slice(t+1)));let s=e[n];"string"==typeof s&&(s=e[n]=[s]),Array.isArray(s)?s.push(o):e[n]=o}return e}function v(t,n){return t?n&&"function"==typeof n?Object.keys(t).map((e=>encodeURIComponent(e)+"="+encodeURIComponent(n(e,t[e])))).join("&"):Object.keys(t).map((e=>{const r=t[e];if(null==r)return"";const s=encodeURIComponent(e)+"=",i=n?.[e];return i?s+encodeURIComponent(i(r)):Array.isArray(r)?r.map((t=>o(t)?s+encodeURIComponent(JSON.stringify(t)):s+encodeURIComponent(t))).join("&"):o(r)?s+encodeURIComponent(JSON.stringify(r)):s+encodeURIComponent(r)})).filter((t=>t)).join("&"):""}function P(t=!1){let n,r=c.proxyUrl;if("string"==typeof t){n=dt(t);const e=T(t);e&&(r=e.proxyUrl)}else n=!!t;if(!r)throw l().warn(f),new e("urlUtils:proxy-not-set",f);n&&wt()&&(r=$t(r));return I(r)}function k(t,n=!1){const e=T(t);let r,o;if(e){const t=S(e.proxyUrl);r=t.path,o=t.query?A(t.query):null}else if(n){const n=P(t);r=n.path,o=n.query}if(r){const n=I(t);t=r+"?"+n.path;const e=v({...o,...n.query});e&&(t=`${t}?${e}`)}return t}const E={path:"",query:""};function S(t){const n=t.indexOf("?");return-1!==n?(E.path=t.slice(0,n),E.query=t.slice(n+1)):(E.path=t,E.query=null),E}function B(t){return t=(t=Ut(t=Ct(t=S(t).path),!0)).toLowerCase()}function H(t){const n={proxyUrl:t.proxyUrl,urlPrefix:B(t.urlPrefix)},e=c.proxyRules,r=n.urlPrefix;let o=e.length;for(let s=0;s<e.length;s++){const t=e[s].urlPrefix;if(0===r.indexOf(t)){if(r.length===t.length)return-1;o=s;break}0===t.indexOf(r)&&(o=s+1)}return e.splice(o,0,n),o}function T(t){const n=c.proxyRules,e=B(t);for(let r=0;r<n.length;r++)if(0===e.indexOf(n[r].urlPrefix))return n[r]}function W(t,n){if(!t||!n)return!1;t=J(t),n=J(n);const e=s(t),r=s(n);return null!=e&&null!=r?e.portalHostname===r.portalHostname:null==e&&null==r&&F(t,n,!0)}function z(t,n){if(!t||!n)return!1;t=J(t),n=J(n);const e=s(t),r=s(n);return null!=e&&null!=r&&e.portalHostname===r.portalHostname}function D(t,n){return t=J(t),n=J(n),Ut(t)===Ut(n)}function J(t){const n=(t=K(t)).indexOf("/sharing");return n>0?t.slice(0,n):t.replace(/\/+$/,"")}function N(t,n=c.interceptors){const e=n=>n instanceof RegExp?n.test(t):"string"==typeof n?t.startsWith(n):null==n;if(n)for(const r of n)if(Array.isArray(r.urls)){if(r.urls.some(e))return r}else if(e(r.urls))return r;return null}function F(t,n,e=!1){if(!t||!n)return!1;const r=kt(t),o=kt(n);return!(!e&&r.scheme!==o.scheme)&&(null!=r.host&&null!=o.host&&(r.host.toLowerCase()===o.host.toLowerCase()&&r.port===o.port))}function M(t){if("string"==typeof t){if(!Y(t))return!0;t=kt(t)}if(F(t,O))return!0;const n=c.trustedServers||[];for(let e=0;e<n.length;e++){const r=Q(n[e]);for(let n=0;n<r.length;n++)if(F(t,r[n]))return!0}return!1}function Q(t){return w[t]||(ht(t)||pt(t)?w[t]=[new x(_(t))]:w[t]=[new x(`http://${t}`),new x(`https://${t}`)]),w[t]}function _(t,n=q,e){return pt(t)?e?.preserveProtocolRelative?t:"http"===O.scheme&&O.authority===X(t).slice(2)?`http:${t}`:`https:${t}`:ht(t)?t:V("/"===t[0]?Ot(n):n,t)}function G(t,n=q,e){if(null==t||!Y(t))return t;const r=K(t),o=r.toLowerCase(),s=K(n).toLowerCase().replace(/\/+$/,""),i=e?K(e).toLowerCase().replace(/\/+$/,""):null;if(i&&0!==s.indexOf(i))return t;const u=(t,n,e)=>-1===(e=t.indexOf(n,e))?t.length:e;let l=u(o,"/",o.indexOf("//")+2),c=-1;for(;o.slice(0,l+1)===s.slice(0,l)+"/"&&(c=l+1,l!==o.length);)l=u(o,"/",l+1);if(-1===c)return t;if(i&&c<i.length)return t;t=r.slice(c);const f=s.slice(c-1).replaceAll(/[^/]+/g,"").length;if(f>0)for(let a=0;a<f;a++)t=`../${t}`;else t=`./${t}`;return t}function K(t){return t=It(t=Lt(t=bt(t=_(t=t.trim()))))}function V(...t){const e=t.filter(n);if(!e?.length)return;const r=[];if(Y(e[0])){const t=e[0],n=t.indexOf("//");-1!==n&&(r.push(t.slice(0,n+1)),yt(e[0])&&(r[0]+="/"),e[0]=t.slice(n+2))}else"/"===e[0][0]&&r.push("");const o=e.reduce(((t,n)=>n?t.concat(n.split("/")):t),[]);for(let n=0;n<o.length;n++){const t=o[n];".."===t&&r.length>0&&".."!==r[r.length-1]?r.pop():(!t&&n===o.length-1||t&&("."!==t||0===r.length))&&r.push(t)}return r.join("/")}function X(t,n=!1){if(null==t||Z(t)||tt(t))return null;let e=t.indexOf("://");if(-1===e&&pt(t))e=2;else{if(-1===e)return null;e+=3}const r=t.indexOf("/",e);return-1!==r&&(t=t.slice(0,r)),n&&(t=Ut(t,!0)),t}function Y(t){return pt(t)||ht(t)}function Z(t){return null!=t&&"blob:"===t.slice(0,5)}function tt(t){return null!=t&&"data:"===t.slice(0,5)}function nt(t){const n=ot(t);return n?.isBase64?i(n.data):null}function et(t){return u(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}const rt=/^data:(.*?)(;base64)?,(.*)$/;function ot(t){const n=t.match(rt);if(!n)return null;const[,e,r,o]=n;return{mediaType:e,isBase64:!!r,data:o}}function st(t){return t.isBase64?`data:${t.mediaType};base64,${t.data}`:`data:${t.mediaType},${t.data}`}async function it(t){return(await fetch(t)).blob()}function ut(t){const n=nt(t);if(!n)return null;const e=ot(t);return new Blob([n],{type:e.mediaType})}function lt(t,n){ft(t,n)}function ct(t,n){at(t,n)}function ft(t,n){const e=ut(t);return!!e&&at(e,n)}function at(t,n){if(!t)return!1;const e=document.createElement("a");if(!("download"in e))return!1;const r=URL.createObjectURL(t);return e.download=n,e.href=r,e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(r),!0}function pt(t){return null!=t&&"/"===t[0]&&"/"===t[1]}function ht(t){return null!=t&&a.test(t)}function dt(t){return null!=t&&h.test(t)||"https"===O.scheme&&pt(t)}function mt(t){return null!=t&&p.test(t)||"http"===O.scheme&&pt(t)}function yt(t){return null!=t&&d.test(t)}function gt(t){return pt(t)?`http:${t}`:t.replace(h,"http:")}function $t(t){return pt(t)?`https:${t}`:t.replace(p,"https:")}function xt(){return"http"===O.scheme}function wt(){return"https"===O.scheme}function Ut(t,n=!1){return pt(t)?t.slice(2):(t=t.replace(a,""),n&&t.length>1&&"/"===t[0]&&"/"===t[1]&&(t=t.slice(2)),t)}function Ot(t){const n=t.indexOf("//"),e=t.indexOf("/",n+2);return-1===e?t:t.slice(0,e)}function Rt(t){let n=0;if(Y(t)){const e=t.indexOf("//");-1!==e&&(n=e+2)}const e=t.lastIndexOf("/");return e<n?t:t.slice(0,e+1)}function qt(t,n){if(!t)return"";const e=I(t).path.replace(/\/+$/,""),r=e.slice(e.lastIndexOf("/")+1);if(!n?.length)return r;const o=new RegExp(`\\.(${n.join("|")})$`,"i");return r.replace(o,"")}function Ct(t){return t.endsWith("/")?t:`${t}/`}function jt(t){return t.replace(/\/+$/,"")}function bt(t){if(/^https?:\/\//i.test(t)){const n=S(t);t=(t=n.path.replaceAll(/\/{2,}/g,"/")).replace("/","//"),n.query&&(t+=`?${n.query}`)}return t}function Lt(t){return t.replace(/^(https?:\/\/)(arcgis\.com)/i,"$1www.$2")}function It(t){const n=c.httpsDomains;if(!mt(t))return t;const e=t.indexOf("/",7);let r;if(r=-1===e?t:t.slice(0,e),r=r.toLowerCase().slice(7),m.test(r)){if(!r.endsWith(":80"))return t;r=r.slice(0,-3),t=t.replace(":80","")}return xt()&&r===O.authority&&!y.test(t)||(wt()&&r===O.authority||n&&n.some((t=>r===t||r.endsWith(`.${t}`)))||wt()&&!T(t))&&(t=$t(t)),t}function At(t,n,e){if(!(n&&e&&t&&Y(t)))return t;const r=t.indexOf("//"),o=t.indexOf("/",r+2),s=t.indexOf(":",r+2),i=Math.min(o<0?t.length:o,s<0?t.length:s);if(t.slice(r+2,i).toLowerCase()!==n.toLowerCase())return t;return`${t.slice(0,r+2)}${e}${t.slice(i)}`}function vt(t,n){const e=new URL(t);return e.host=n,e.port&&!m.test(n)&&(e.port=""),e.toString()}function Pt(t){return new URL(t).host}function kt(t){return"string"==typeof t?new x(_(t)):(t.scheme||(t.scheme=O.scheme),t)}function Et(t){return Nt.test(t)}function St(t,n){const e=I(t),r=Object.keys(e.query||{});return r.length>0&&n&&n.warn("removeQueryParameters()",`Url query parameters are not supported, the following parameters have been removed: ${r.join(", ")}.`),e.path}function Bt(t,n,e){const r=I(t),o=r.query||{};return o[n]=String(e),`${r.path}?${v(o)}`}function Ht(t,n){if(!n)return t;const e=I(t),r=e.query||{};for(const[s,i]of Object.entries(n))null!=i&&(r[s]=i);const o=v(r);return o?`${e.path}?${o}`:e.path}function Tt(t,n){const{path:e,query:r}=I(t);if(!r)return t;delete r[n];const o=v(r);return o?`${e}?${o}`:e}function Wt(t){if(null==t)return null;const n=t.match(Jt);return n?n[2]:null}function zt(t){if(null==t)return null;const n=t.match(Jt);return n?{path:n[1],extension:n[2]}:{path:t,extension:null}}async function Dt(t){if("string"==typeof t){return ot(t)??{data:t}}return new Promise(((n,e)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>n(ot(r.result)),r.onerror=t=>e(t)}))}const Jt=/([^.]*)\.([^/]*)$/,Nt=/(^data:image\/svg|\.svg$)/i;export{x as Url,k as addProxy,H as addProxyRule,Bt as addQueryParameter,Ht as addQueryParameters,et as base64UrlEncode,it as blobUrlToBlob,At as changeDomain,vt as changeHost,ot as dataComponents,nt as dataToArrayBuffer,ut as dataToBlob,ct as downloadBlobAsFile,lt as downloadDataAsFile,Ct as ensureTrailingSlash,j as getAppBaseUrl,C as getAppUrl,qt as getFilename,Pt as getHost,N as getInterceptor,X as getOrigin,Wt as getPathExtension,T as getProxyRule,P as getProxyUrl,ht as hasProtocol,z as hasSameCanonicalArcGISOnlinePortal,W as hasSameCanonicalPortal,F as hasSameOrigin,D as hasSamePortal,Y as isAbsolute,wt as isAppHTTPS,Z as isBlobProtocol,tt as isDataProtocol,dt as isHTTPSProtocol,pt as isProtocolRelative,Et as isSVG,M as isTrustedServer,V as join,_ as makeAbsolute,st as makeData,G as makeRelative,K as normalize,v as objectToQuery,Dt as parseData,A as queryToObject,Rt as removeFile,Tt as removeQueryParameter,St as removeQueryParameters,jt as removeTrailingSlash,zt as splitPathExtension,L as test,gt as toHTTP,$t as toHTTPS,w as trustedServersUrlCache,I as urlToObject};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fullVersion as e}from"../../kernel.js";import s from"../Error.js";import{on as t}from"../events.js";import{makeHandle as o}from"../handleUtils.js";import{removeMaybe as
|
|
5
|
+
import{fullVersion as e}from"../../kernel.js";import s from"../Error.js";import{on as t}from"../events.js";import{makeHandle as o}from"../handleUtils.js";import{removeMaybe as i}from"../maybe.js";import{isAborted as n,createAbortError as r,onAbort as l,isPromiseLike as h,isAbortError as a}from"../promiseUtils.js";import{createInvokeProxy as c}from"./InvokeHandler.js";import{registry as p}from"./registry.js";import{MessageType as _,portClosedErrorName as u,newJobId as d,receiveMessage as b,toInvokeError as m,postMessage as g}from"./utils.js";import{commitHash as v,buildDate as f}from"../../support/revision.js";const{CLOSE:M,ABORT:k,INVOKE:y,RESPONSE:j,OPEN_PORT:I,ON:J}=_,w=2;class O{constructor(e){this._invoke=e,this._timer=null,this._cancelledJobIds=new Set,this._invokeMessages=[],this._timer=null,this._process=this._process.bind(this)}push(e){e.type===_.ABORT?this._cancelledJobIds.add(e.jobId):(this._invokeMessages.push(e),null===this._timer&&(this._timer=setTimeout(this._process,0)))}clear(){this._invokeMessages.length=0,this._cancelledJobIds.clear(),this._timer=null}_process(){this._timer=null;for(const e of this._invokeMessages)this._cancelledJobIds.has(e.jobId)||this._invoke(e);this._cancelledJobIds.clear(),this._invokeMessages.length=0}}class E{static{this.kernelInfo={buildDate:f,fullVersion:e,revision:v}}static{this.clients=new Map}static connect(e,s){const t=new MessageChannel;let o;o="function"==typeof e?new e:"default"in e&&"function"==typeof e.default?new e.default:e;const i=new E(t.port1,{channel:t,client:o,schedule:s});return"object"==typeof o&&"remoteClient"in o&&(o.remoteClient=i),E.clients.set(i,o),t.port2}static loadWorker(e){const s=p[e];return s?s():Promise.resolve(null)}constructor(e,s,t,o){this._port=e,this._jobQueue=t,this._lowPriorityJobQueue=o,this._outJobs=new Map,this._inJobs=new Map,this._invokeQueue=new O((e=>this._onInvokeMessage(e))),this._client=s.client,this._onMessage=this._onMessage.bind(this),this._channel=s.channel,this._schedule=s.schedule,this._port.addEventListener("message",this._onMessage),this._port.start()}close(){this._post({type:M}),this._close()}isBusy(){return this._outJobs.size>0}invoke(e,s,t){return this.apply(e,[s],t)}apply(e,t,o){const h=o?.signal,a=o?.transferList;if(!this._port)return Promise.reject(new s(u,`Cannot call invoke('${e}'), port is closed`,{methodName:e,data:t}));const c=d();return new Promise(((s,o)=>{if(n(h))return this._processWork(),void o(r());const p=l(h,(()=>{const e=this._outJobs.get(c);e&&(this._outJobs.delete(c),this._processWork(),i(e.abortHandle),this._post({type:k,jobId:c}),o(r()))})),_={resolve:s,reject:o,abortHandle:p,debugInfo:e};this._outJobs.set(c,_),this._post({type:y,jobId:c,methodName:e,abortable:null!=h},t,a)}))}createInvokeProxy(e){return c(this,e)}on(e,s){const t=new MessageChannel;function i(e){s(e.data)}return this._port.postMessage({type:_.ON,eventType:e,port:t.port2},[t.port2]),t.port1.addEventListener("message",i),t.port1.start(),o((()=>{t.port1.postMessage({type:_.CLOSE}),t.port1.close(),t.port1.removeEventListener("message",i)}))}jobAdded(){this._processWork()}openPort(){const e=new MessageChannel;return this._post({type:I,port:e.port2}),e.port1}_processWork(){if(this._outJobs.size>=w)return;const e=this._jobQueue?.pop()??this._lowPriorityJobQueue?.pop();if(!e)return;const{methodName:s,data:t,invokeOptions:o,resolver:i}=e;this.apply(s,t,o).then((e=>i.resolve(e))).catch((e=>i.reject(e)))}_close(){this._channel&&(this._channel=void 0),this._port.removeEventListener("message",this._onMessage),this._port.close(),this._outJobs.forEach((e=>{i(e.abortHandle),e.reject(r(`Worker closing, aborting job calling '${e.debugInfo}'`))})),this._inJobs.clear(),this._outJobs.clear(),this._invokeQueue.clear(),this._port=null,this._client=null,this._schedule=null,this._onMessage=null,this._channel=null,this._jobQueue=void 0,this._invokeQueue=void 0,this._lowPriorityJobQueue=void 0}_onMessage(e){null!=this._schedule?this._schedule((()=>this._processMessage(e,!0))):this._processMessage(e,!1)}_processMessage(e,s){const t=b(e);if(t)switch(t.type){case j:this._onResponseMessage(t);break;case y:s?this._onInvokeMessage(t):this._invokeQueue.push(t);break;case k:this._onAbortMessage(t);break;case M:this._onCloseMessage();break;case I:this._onOpenPortMessage(t);break;case J:this._onOnMessage(t)}}_onAbortMessage(e){const s=this._inJobs,t=e.jobId,o=s.get(t);this._invokeQueue.push(e),o&&(o.controller&&o.controller.abort(),s.delete(t))}_onCloseMessage(){const e=this._client;this._close(),e&&"destroy"in e&&E.clients.get(this)===e&&e.destroy(),E.clients.delete(this),e?.remoteClient&&(e.remoteClient=null)}_onInvokeMessage(e){const{methodName:s,jobId:t,data:o=[],abortable:i}=e,n=i?new AbortController:null,r=this._inJobs;let l,c=this._client,p=c[s];try{if(!p&&s&&s.includes(".")){const e=s.split(".");for(let s=0;s<e.length-1;s++)c=c[e[s]],p=c[e[s+1]]}if("function"!=typeof p)throw new TypeError(`${s} is not a function`);o.push({client:this,signal:n?n.signal:null}),l=p.apply(c,o)}catch(_){return void this._post({type:j,jobId:t,error:m(_)})}h(l)?(r.set(t,{controller:n,promise:l}),l.then((e=>{r.has(t)&&(r.delete(t),this._post({type:j,jobId:t},e))}),(e=>{r.has(t)&&(r.delete(t),a(e)||this._post({type:j,jobId:t,error:m(e||{message:`Error encountered at method ${s}`})}))}))):this._post({type:j,jobId:t},l)}_onOpenPortMessage(e){new E(e.port,{client:this._client})}_onOnMessage(e){const{port:s}=e,o=this._client.on(e.eventType,(e=>{s.postMessage(e)})),i=t(e.port,"message",(e=>{const t=b(e);t?.type===_.CLOSE&&(i.remove(),o.remove(),s.close())}))}_onResponseMessage(e){const{jobId:t,error:o,data:n}=e,r=this._outJobs;if(!r.has(t))return;const l=r.get(t);r.delete(t),this._processWork(),i(l.abortHandle),o?l.reject(s.fromJSON(JSON.parse(o))):l.resolve(n)}_post(e,s,t){return g(this._port,e,s,t)}}export{E 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{remove as e}from"../arrayUtils.js";import{makeHandle as t}from"../handleUtils.js";import s from"../Logger.js";import{throwIfAborted as r}from"../promiseUtils.js";import{open as i}from"./workers.js";class
|
|
5
|
+
import{remove as e}from"../arrayUtils.js";import{makeHandle as t}from"../handleUtils.js";import s from"../Logger.js";import{throwIfAborted as r}from"../promiseUtils.js";import{open as i}from"./workers.js";class o{constructor(e,t,r,o,h={}){this._mainMethod=t,this._transferLists=r,this._listeners=[],this._promise=i(e,{...h,schedule:o}).then((e=>{if(void 0===this._thread){this._thread=e,this._promise=null,h.hasInitialize&&this.broadcast({},"initialize");for(const e of this._listeners)this._connectListener(e)}else e.close()})),this._promise.catch((t=>s.getLogger("esri.core.workers.WorkerHandle").error(`Failed to initialize ${e} worker: ${t}`)))}on(s,r){const i={removed:!1,eventName:s,callback:r,threadHandle:null};return this._listeners.push(i),this._connectListener(i),t((()=>{i.removed=!0,e(this._listeners,i),this._thread&&null!=i.threadHandle&&i.threadHandle.remove()}))}destroy(){this._thread&&(this._thread.close(),this._thread=null),this._promise=null,this._listeners.length=0,this._transferLists={}}invoke(e,t,s){return this.invokeMethod(this._mainMethod,e,t,s)}invokeMethod(e,t,s,i){if(this._thread){const r=this._transferLists[e],o=r?r(t):[];return this._thread.invoke(e,t,{transferList:o,signal:s,priority:i})}return this._promise?this._promise.then((()=>(r(s),this.invokeMethod(e,t,s)))):Promise.reject(null)}broadcast(e,t){return this._thread?Promise.all(this._thread.broadcast(t,e)).then(h):this._promise?this._promise.then((()=>this.broadcast(e,t))):Promise.reject()}get promise(){return this._promise}_connectListener(e){this._thread&&this._thread.on(e.eventName,e.callback).then((t=>{e.removed||(e.threadHandle=t)}))}}function h(){}export{o as WorkerHandle};
|