@arcgis/core 5.1.0-next.11 → 5.1.0-next.13
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/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/008887a8014b61f837ae.js +1 -0
- package/assets/esri/core/workers/chunks/04f82b740325e3388d23.js +1 -0
- package/assets/esri/core/workers/chunks/09cf8aed89a1ea1f8b28.js +1 -0
- package/assets/esri/core/workers/chunks/{ff2412c5be1ad4edb458.js → 0b59e5be22139387bd84.js} +1 -1
- package/assets/esri/core/workers/chunks/0bf742d48f434c4c575f.js +1 -0
- package/assets/esri/core/workers/chunks/0c8a676599821b9871c2.js +1 -0
- package/assets/esri/core/workers/chunks/11882cbb28710e5f9fc5.js +1 -0
- package/assets/esri/core/workers/chunks/{f0e7207fd2c899b9fe9f.js → 12fd2e26e949d90abfbd.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c5e834c2d243fc369fe.js → 18b0776aef1536867ab8.js} +1 -1
- package/assets/esri/core/workers/chunks/{72ab3ed37ac4da355710.js → 1aa2187597f7c4adb67f.js} +1 -1
- package/assets/esri/core/workers/chunks/2216264b22a605a0f1ce.js +1 -0
- package/assets/esri/core/workers/chunks/22d12c309af9c19a1a48.js +1 -0
- package/assets/esri/core/workers/chunks/{aefc089928ada18bc4d4.js → 2762149a922275136171.js} +2 -2
- package/assets/esri/core/workers/chunks/27aa21da934ecaca381a.js +1 -0
- package/assets/esri/core/workers/chunks/{a5d3dcb490686430c81d.js → 27c8dea6154eb8c36fed.js} +1 -1
- package/assets/esri/core/workers/chunks/27d60fd727e9a68973f6.js +1 -0
- package/assets/esri/core/workers/chunks/{8fbfdd154413a2140180.js → 2a3e82a230b7ee4dfd55.js} +1 -1
- package/assets/esri/core/workers/chunks/{5aab1db039b2b61c6c6b.js → 2bb7bb7901bd343201fc.js} +1 -1
- package/assets/esri/core/workers/chunks/2d1a772abd730b61854f.js +1 -0
- package/assets/esri/core/workers/chunks/2d67ab4927a968d5c8d4.js +1 -0
- package/assets/esri/core/workers/chunks/{ee2ae61fc747b5f9827b.js → 2e7d4a437717606bc39c.js} +1 -1
- package/assets/esri/core/workers/chunks/{02f03297491eef26f113.js → 34207774bc371e95ba3c.js} +1 -1
- package/assets/esri/core/workers/chunks/360b3499e2a671c309ce.js +1 -0
- package/assets/esri/core/workers/chunks/3b0cfe3db8d90e02d6c6.js +1 -0
- package/assets/esri/core/workers/chunks/3d78e9b3c97c0ce21d16.js +1 -0
- package/assets/esri/core/workers/chunks/4550b7620932cd6de20e.js +1 -0
- package/assets/esri/core/workers/chunks/{f3022255054e8d09c38b.js → 455fbddd814e4681f0c0.js} +1 -1
- package/assets/esri/core/workers/chunks/{3db4938b3f89b9b8234e.js → 4742a8c19b86a5f859f0.js} +1 -1
- package/assets/esri/core/workers/chunks/58cf3d35771b87bd74e5.js +1 -0
- package/assets/esri/core/workers/chunks/{d84af069f1057044c879.js → 5c12a9b0db317620dce2.js} +1 -1
- package/assets/esri/core/workers/chunks/65ad8838911a6d71816b.js +1 -0
- package/assets/esri/core/workers/chunks/{7a85e08cb968586f8d74.js → 72acfb74fd9ab9bae923.js} +2 -2
- package/assets/esri/core/workers/chunks/79ee97609f72e4cf989c.js +1 -0
- package/assets/esri/core/workers/chunks/{fba30f2e1d6b364aae79.js → 7b1964255722e756eba3.js} +1 -1
- package/assets/esri/core/workers/chunks/7e6309bfed6692e8d2d7.js +2 -0
- package/assets/esri/core/workers/chunks/804c31973f7d116523cb.js +1 -0
- package/assets/esri/core/workers/chunks/{dc65843654dc25bd8f97.js → 8177e95596b71bf020aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{afffb40cce91e135f092.js → 8374658d17f69bde6b08.js} +1 -1
- package/assets/esri/core/workers/chunks/879e8439a513cb333b61.js +1 -0
- package/assets/esri/core/workers/chunks/{ca767f0e3aa559b13699.js → 90aeef17af12cfbecb36.js} +1 -1
- package/assets/esri/core/workers/chunks/{4bd98d025bcd713eddca.js → 91858b02da40ff251ab2.js} +2 -2
- package/assets/esri/core/workers/chunks/{3114cbf7298239e1269d.js → 956237a2baa30760c256.js} +1 -1
- package/assets/esri/core/workers/chunks/a027da22acdaa6d6baa3.js +1 -0
- package/assets/esri/core/workers/chunks/{c064025d0dc69bb44f0d.js → a115984b794a7f90b2c0.js} +1 -1
- package/assets/esri/core/workers/chunks/a3e8b7185d63a0f85931.js +1 -0
- package/assets/esri/core/workers/chunks/{6be2dc8331ecf944efdc.js → a5af20f3d484d2d3bafe.js} +1 -1
- package/assets/esri/core/workers/chunks/b0b24fb60a21b995b348.js +1 -0
- package/assets/esri/core/workers/chunks/b6e155b42a4a423139e7.js +1 -0
- package/assets/esri/core/workers/chunks/{fb57a07b76580dcdde46.js → bc9997d15ec0a86793c6.js} +1 -1
- package/assets/esri/core/workers/chunks/{4a571a1e897c8ad359c4.js → bf2bfc0d78be8c185d58.js} +1 -1
- package/assets/esri/core/workers/chunks/bf9b2aa2e67ca746ec7c.js +1 -0
- package/assets/esri/core/workers/chunks/c9babe86c00ae69e63ee.js +2 -0
- package/assets/esri/core/workers/chunks/{da40c63408affee86ac4.js → d0d1378e714ff0e43e26.js} +1 -1
- package/assets/esri/core/workers/chunks/{940185f10c2b16612b66.js → d3416e6da0c1cbb53b3a.js} +1 -1
- package/assets/esri/core/workers/chunks/d9c1e1ec5c56f09fb82f.js +1 -0
- package/assets/esri/core/workers/chunks/d9dc3962535616a06e2f.js +1 -0
- package/assets/esri/core/workers/chunks/{4ee618a256b06221ea8f.js → da5deed75e1a170a49b3.js} +8 -8
- package/assets/esri/core/workers/chunks/{bb75ec3727b7ecabca6f.js → e4eb14952b7660feecc7.js} +1 -1
- package/assets/esri/core/workers/chunks/eaf5d55060ffc55aac39.js +1 -0
- package/assets/esri/core/workers/chunks/{9bcf8241c6b4aa42b1c5.js → ed78e19b1e400c0db309.js} +1 -1
- package/assets/esri/core/workers/chunks/f0b8de5b3cfbe9223df6.js +1 -0
- package/assets/esri/core/workers/chunks/fcf6a47f44c917490deb.js +1 -0
- package/assets/esri/core/workers/chunks/fd5a5b05a1551cdb8c87.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -0
- package/assets/esri/themes/base/widgets/_Grid.scss +8 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.js +1 -1
- package/core/Logger.js +1 -1
- package/core/Version.js +1 -1
- package/core/deprecate.js +1 -1
- package/core/has.js +1 -1
- package/core/iteratorUtils.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/sql/WhereGrammar.js +1 -1
- package/core/sql/sqlVisitor.js +2 -0
- package/core/sql/writeUtils.js +2 -0
- package/core/sql.d.ts +2 -3
- package/core/sql.js +1 -1
- package/kernel.js +1 -1
- package/layers/ImageryLayer.d.ts +1 -1
- package/layers/MapImageLayer.d.ts +1 -1
- package/layers/TileLayer.d.ts +1 -1
- package/layers/WebTileLayer.d.ts +1 -1
- package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/capabilities.js +1 -1
- package/layers/support/relativeTimeQueryUtils.js +2 -0
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/networks/support/jsonTypes.d.ts +2 -2
- package/package.json +2 -2
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/rest/print.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/Symbol3DEmissive.d.ts +9 -9
- package/symbols/support/Symbol3DMaterial.d.ts +8 -8
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
- package/views/3d/analysis/ShadowCast/ShadowCastTooltip.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/webgl/ManagedFBOResource.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
- package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/parts/renderUtils.js +1 -1
- package/views/Attribution.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/SelectionManager.d.ts +242 -0
- package/views/View.d.ts +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
- package/views/draw/plugins/CircularArcSegmentPlugin.js +2 -0
- package/views/draw/support/EditSession.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/draw/support/managers/TooltipManager.js +1 -1
- package/views/selection/types.d.ts +140 -0
- package/views/support/selectionUtils.js +1 -1
- package/views/ui/DefaultUI.d.ts +5 -12
- package/views/ui/DefaultUI.js +1 -1
- package/views/ui/types.d.ts +1 -1
- package/webscene/SunLighting.d.ts +20 -2
- package/webscene/VirtualLighting.d.ts +20 -2
- package/webscene/support/schemaValidator.js +1 -1
- package/webscene/support/versionUtils.js +1 -1
- package/widgets/Attribution/AttributionViewModel.d.ts +1 -1
- package/widgets/Attribution.d.ts +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +48 -0
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor.d.ts +35 -0
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable.d.ts +9 -3
- package/widgets/FeatureTable.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
- package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +1 -1
- package/widgets/OrientedImageryViewer/support/geometryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/support/urlUtils.js +1 -1
- package/widgets/OrientedImageryViewer/utils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
- package/widgets/Sketch/SketchViewModel.d.ts +14 -15
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/OperationHandle.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/Sketch/support/sketchUtils.js +1 -1
- package/widgets/Sketch.d.ts +37 -0
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/012992dc3910466ed207.js +0 -1
- package/assets/esri/core/workers/chunks/0485ae33a8b327974751.js +0 -1
- package/assets/esri/core/workers/chunks/0994c12d01fe6f74350e.js +0 -1
- package/assets/esri/core/workers/chunks/13b104cc7925d4423aad.js +0 -1
- package/assets/esri/core/workers/chunks/147d0f7a2e471442c95c.js +0 -2
- package/assets/esri/core/workers/chunks/1a11ac1a34614132fabc.js +0 -1
- package/assets/esri/core/workers/chunks/1f613c599eff3b16c1d2.js +0 -1
- package/assets/esri/core/workers/chunks/2431a5480f0d22f00e00.js +0 -1
- package/assets/esri/core/workers/chunks/319226db47849acbe321.js +0 -1
- package/assets/esri/core/workers/chunks/360dd5cd63d132b5c7d5.js +0 -2
- package/assets/esri/core/workers/chunks/3e4c5cc24bdc1c807125.js +0 -1
- package/assets/esri/core/workers/chunks/504e6868445419b7680e.js +0 -1
- package/assets/esri/core/workers/chunks/545d801c4ba6f49df726.js +0 -1
- package/assets/esri/core/workers/chunks/71879de16a936a079362.js +0 -1
- package/assets/esri/core/workers/chunks/733d4ddb937c51ef3aed.js +0 -1
- package/assets/esri/core/workers/chunks/7352b4129f4875a053b0.js +0 -1
- package/assets/esri/core/workers/chunks/768ee8d940b5eb353ec3.js +0 -1
- package/assets/esri/core/workers/chunks/8556d06f522914e71bb8.js +0 -1
- package/assets/esri/core/workers/chunks/863873ffbed0cbbdfb9b.js +0 -1
- package/assets/esri/core/workers/chunks/88fe7d75dc3b619b8543.js +0 -1
- package/assets/esri/core/workers/chunks/8ac7a552189143ab4f91.js +0 -1
- package/assets/esri/core/workers/chunks/8ba1c7919e898ef4557f.js +0 -1
- package/assets/esri/core/workers/chunks/944b6d230a93add78c0d.js +0 -1
- package/assets/esri/core/workers/chunks/a37a003da59bdaf7ec0e.js +0 -1
- package/assets/esri/core/workers/chunks/ad688eee6a9f2be6df4a.js +0 -1
- package/assets/esri/core/workers/chunks/c0ae85f9c2dbe8611499.js +0 -1
- package/assets/esri/core/workers/chunks/c0cb0c22ee7fd91855cb.js +0 -1
- package/assets/esri/core/workers/chunks/c88101cb8301f095d037.js +0 -1
- package/assets/esri/core/workers/chunks/cb1b16f8bf7c135e14f7.js +0 -1
- package/assets/esri/core/workers/chunks/cc245eb1c5aaaac5916e.js +0 -1
- package/assets/esri/core/workers/chunks/e03bf0ca545dce221ea0.js +0 -1
- package/assets/esri/core/workers/chunks/e880d7738155a4de4b0e.js +0 -1
- package/assets/esri/core/workers/chunks/fb4bcf366ba1b51668f6.js +0 -1
- package/assets/esri/core/workers/chunks/fb58f3ea98bf5e8cf8dd.js +0 -1
- package/views/3d/webgl/utils.js +0 -2
- /package/assets/esri/core/workers/chunks/{aefc089928ada18bc4d4.js.LICENSE.txt → 2762149a922275136171.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{7a85e08cb968586f8d74.js.LICENSE.txt → 72acfb74fd9ab9bae923.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{360dd5cd63d132b5c7d5.js.LICENSE.txt → 7e6309bfed6692e8d2d7.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{4bd98d025bcd713eddca.js.LICENSE.txt → 91858b02da40ff251ab2.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{147d0f7a2e471442c95c.js.LICENSE.txt → c9babe86c00ae69e63ee.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{nextHighestPowerOfTwo as t}from"../../../../../core/mathUtils.js";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{copy as r,invert as o,transpose as s}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as a}from"../../../support/buffer/glUtil.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{getMaxItemCount as i,getMaxByteSize as u}from"../../lib/TextureBackedBuffer/TextureBackedBufferUtils.js";import{TextureBuffer as c}from"../../lib/TextureBackedBuffer/TextureBuffer.js";import{bufferRangePool as m}from"./BufferRange.js";import{DrawCommand as g}from"./DrawCommand.js";import{BaseInstanceData as l}from"./PerBaseInstanceData.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";class y{constructor(t,e){this._rctx=e;const r=t.createBufferWriter();this._bufferWriter=r,this._vaoCache=e.getVaoCache(a(r.layout));const o=["geometry"];"textureBufferLayout"in r&&null!=r.textureBufferLayout&&o.push("texture"),this.targetBuffers=o}maxElements(t){if("texture"===t){const t=this._targetLayout("texture");return null==t?0:i(this._rctx,t)}return Math.floor(x/this._targetStrideBytes(t))}_targetStrideBytes(t){return this._targetLayout(t)?.stride??0}_targetLayout(t){return"geometry"===t?this._bufferWriter.layout:"baseInstance"===t?this._bufferWriter.baseInstanceLayout:this._bufferWriter.textureBufferLayout}evaluateBufferAllocation(t,e,r,o){const s=this._targetStrideBytes("geometry"),n=e.reduce((t,{geometry:e})=>t+this.vertexElementCount(e),0),a=r.reduce((t,{geometry:e})=>t+this.vertexElementCount(e),0),f=Math.min((t+n-a)*s,x),i=o.vao?.buffer("geometry"),u=i?.sizeBytes??0;return f>b&&f<u/2?0:f>u?1:2}deleteBuffer(t){if(t.isInstanced)return t.instancedCommandVAOs?.dispose(),t.vao?.buffer("geometry")?.dispose(),t.vao?.disposeVAOOnly(),void(t.vao=null);this._vaoCache.deleteVao(t.vao),t.vaoEndElement=0,t.textureBuffer=e(t.textureBuffer),t.textureEndElement=0}createBaseInstanceData(t){const{_bufferWriter:e}=this;if(null==t||null==e.baseInstanceLayout||null==e.writeBaseInstance||null==e.elementCountBaseInstance)return null;const r=this._targetLayout("baseInstance"),o=e.elementCountBaseInstance(t.attributes),s=o*r.stride,n=new h(this._rctx,a(r));n.setSize(Math.ceil(s));const f=S(s),i=r.createView(f.buffer);e.writeBaseInstance(t.attributes,i),n.setSubData(f,0,0,s);const u=new g;return u.first=0,u.count=o,new l(t,n,u)}_allocateInstanceBuffer(t){const e=this._bufferWriter.layout,r=t*this._targetStrideBytes("geometry"),o=new h(this._rctx,a(e,1));return o.setSize(v(r)),o}_createInstancedVao(t,e){return new f(this._rctx,new Map([["baseInstance",t],["geometry",e]]))}reallocateBuffer(t,e,r){if(this.deleteBuffer(e),null!=t){const o=t.baseInstanceBuffer,s=this._allocateInstanceBuffer(r.geometry);e.vao=this._createInstancedVao(o,s)}else{const t=r.geometry*this._targetStrideBytes("geometry");e.vao=this._vaoCache.newVao(v(t))}const o=this._targetLayout("texture");if(null!=o){const t=v(r.texture*o.stride),s=Math.ceil(t/o.stride);e.textureBuffer=new c(this._rctx,o,s)}e.vaoEndElement=Math.floor((e.vao?.getByteLength("geometry")??0)/this._targetStrideBytes("geometry")),e.textureEndElement=e.textureBuffer?.itemCount??0}elementCount(t,e){const{attributes:r}=t;return"geometry"===e?this._bufferWriter.elementCount(r):"baseInstance"===e?this._bufferWriter.elementCountBaseInstance?.(r)??0:this._bufferWriter.elementCountTextureBuffer?.(r)??0}vertexElementCount(t){return this._bufferWriter.elementCount(t.attributes)}textureElementCount(t){return this._bufferWriter.elementCountTextureBuffer?.(t.attributes)??0}canGrow(t,e){const r=this.targetBuffers.map(r=>this._evaluateTargetBufferGrowth(r,t,e));return r.every(({canGrow:t})=>t)&&r.some(({needsToGrow:t})=>t)}_evaluateTargetBufferGrowth(t,e,r){const o=this._targetLayout(t),s=e.getTargetBuffer(t);if(null==o||null==s)return{needsToGrow:null!=o,canGrow:!0};return{needsToGrow:r[t]*o.stride>s.sizeBytes,canGrow:"geometry"===t?s.sizeBytes<v(x-b):s.sizeBytes<u(this._rctx,o)}}clearHoles(t,e){for(const r of this.targetBuffers){const o=this._targetStrideBytes(r),s=t[r],n=s.reduce((t,e)=>Math.max(t,e.numElements),0)*o,a=S(n);a.fill(0,0,n);for(const t of s)this._setTargetSubData(r,e,o,t,a)}}clearHolesMetal(t,e,r){const{targetBuffers:o}=this,s={};let n=0;for(const i of o){const t=e[i].numElements*this._targetStrideBytes(i);s[i]=n,n+=t}const a=S(n);a.fill(0,0,n);const f={};for(const i of o)f[i]=this._targetLayout(i)?.createView(a.buffer,s[i]);for(const i of t){const t=i.targetRanges.geometry;if(!(t.from>=e.geometry.from&&t.to<=e.geometry.to))continue;const r={};for(const s of o)r[s]=i.targetRanges[s].from-e[s].from;this._writeGeometry(i.geometry,f,r,i.targetRanges)}for(const i of o)this._setTargetSubData(i,r,this._targetStrideBytes(i),e[i],a,s[i])}writeRandomInstances(t,e,r){const{targetBuffers:o}=this,s={},n={},a={},f={};let i=0;for(const g of o)s[g]=t[g]*this._targetStrideBytes(g),n[g]=i,a[g]=0,f[g]=m.acquire(0,0),i+=s[g];const u=S(i),c={};for(const m of o)c[m]=this._targetLayout(m)?.createView(u.buffer,n[m]);for(const m of e){for(const t of o){const e=m.targetRanges[t],o=f[t];o.to===e.from||(o.numElements>0&&this._setTargetSubData(t,r,this._targetStrideBytes(t),f[t],u,n[t]),o.from=e.from,a[t]=0)}this._writeGeometry(m.geometry,c,a,m.targetRanges);for(const t of o){const e=m.targetRanges[t];a[t]+=e.numElements,f[t].to=e.to}}for(const g of o){const t=f[g];t.numElements>0&&this._setTargetSubData(g,r,this._targetStrideBytes(g),t,u,n[g]),m.release(f[g])}}writeInstanceRangeMetal(t,e,r){const{targetBuffers:o}=this,s={},n={};let a=0;for(const u of o)s[u]=t[u].numElements*this._targetStrideBytes(u),n[u]=a,a+=s[u];const f=S(a),i={};for(const u of o)i[u]=this._targetLayout(u)?.createView(f.buffer,n[u]);f.fill(0,0,a);for(const u of e){const e=u.targetRanges.geometry;if(!(e.from>=t.geometry.from&&e.to<=t.geometry.to))continue;const r={},s={};for(const n of o){const e=u.targetRanges[n];r[n]=e.from-t[n].from,s[n]=e}this._writeGeometry(u.geometry,i,r,s)}for(const u of o)t[u].numElements>0&&this._setTargetSubData(u,r,this._targetStrideBytes(u),t[u],f,n[u])}rebuildInstances(t,e,r){const{targetBuffers:o}=this,s={},n={},a={};let f=0;for(const c of o)s[c]=t[c]*this._targetStrideBytes(c),n[c]=f,f+=s[c],a[c]=0;const i=S(f),u={};for(const c of o)u[c]=this._targetLayout(c)?.createView(i.buffer,n[c]);for(const c of e){const t={},e={};for(const r of o){t[r]=a[r],a[r]+=this.elementCount(c.geometry.geometry,r);const o=c.targetRanges[r];o.from=t[r],o.to=a[r],e[r]=o}this._writeGeometry(c.geometry,u,t,e)}for(const c of o){const t=m.acquire(0,a[c]);this._setTargetSubData(c,r,this._targetStrideBytes(c),t,i,n[c]),m.release(t)}return a}updateInstance(t,e){const{targetBuffers:r}=this,o={},s={};let n=0;for(const
|
|
2
|
+
import{nextHighestPowerOfTwo as t}from"../../../../../core/mathUtils.js";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{copy as r,invert as o,transpose as s}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as a}from"../../../support/buffer/glUtil.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{getMaxItemCount as i,getMaxByteSize as u}from"../../lib/TextureBackedBuffer/TextureBackedBufferUtils.js";import{TextureBuffer as c}from"../../lib/TextureBackedBuffer/TextureBuffer.js";import{bufferRangePool as m}from"./BufferRange.js";import{DrawCommand as g}from"./DrawCommand.js";import{BaseInstanceData as l}from"./PerBaseInstanceData.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";class y{constructor(t,e){this._rctx=e;const r=t.createBufferWriter();this._bufferWriter=r,this._vaoCache=e.getVaoCache(a(r.layout));const o=["geometry"];"textureBufferLayout"in r&&null!=r.textureBufferLayout&&o.push("texture"),this.targetBuffers=o}maxElements(t){if("texture"===t){const t=this._targetLayout("texture");return null==t?0:i(this._rctx,t)}return Math.floor(x/this._targetStrideBytes(t))}_targetStrideBytes(t){return this._targetLayout(t)?.stride??0}_targetLayout(t){return"geometry"===t?this._bufferWriter.layout:"baseInstance"===t?this._bufferWriter.baseInstanceLayout:this._bufferWriter.textureBufferLayout}evaluateBufferAllocation(t,e,r,o){const s=this._targetStrideBytes("geometry"),n=e.reduce((t,{geometry:e})=>t+this.vertexElementCount(e),0),a=r.reduce((t,{geometry:e})=>t+this.vertexElementCount(e),0),f=Math.min((t+n-a)*s,x),i=o.vao?.buffer("geometry"),u=i?.sizeBytes??0;return f>b&&f<u/2?0:f>u?1:2}deleteBuffer(t){if(t.isInstanced)return t.instancedCommandVAOs?.dispose(),t.vao?.buffer("geometry")?.dispose(),t.vao?.disposeVAOOnly(),void(t.vao=null);this._vaoCache.deleteVao(t.vao),t.vaoEndElement=0,t.textureBuffer=e(t.textureBuffer),t.textureEndElement=0}createBaseInstanceData(t){const{_bufferWriter:e}=this;if(null==t||null==e.baseInstanceLayout||null==e.writeBaseInstance||null==e.elementCountBaseInstance)return null;const r=this._targetLayout("baseInstance"),o=e.elementCountBaseInstance(t.attributes),s=o*r.stride,n=new h(this._rctx,a(r));n.setSize(Math.ceil(s));const f=S(s),i=r.createView(f.buffer);e.writeBaseInstance(t.attributes,i),n.setSubData(f,0,0,s);const u=new g;return u.first=0,u.count=o,new l(t,n,u)}_allocateInstanceBuffer(t){const e=this._bufferWriter.layout,r=t*this._targetStrideBytes("geometry"),o=new h(this._rctx,a(e,1));return o.setSize(v(r)),o}_createInstancedVao(t,e){return new f(this._rctx,new Map([["baseInstance",t],["geometry",e]]))}reallocateBuffer(t,e,r){if(this.deleteBuffer(e),null!=t){const o=t.baseInstanceBuffer,s=this._allocateInstanceBuffer(r.geometry);e.vao=this._createInstancedVao(o,s)}else{const t=r.geometry*this._targetStrideBytes("geometry");e.vao=this._vaoCache.newVao(v(t))}const o=this._targetLayout("texture");if(null!=o){const t=v(r.texture*o.stride),s=Math.ceil(t/o.stride);e.textureBuffer=new c(this._rctx,o,s)}e.vaoEndElement=Math.floor((e.vao?.getByteLength("geometry")??0)/this._targetStrideBytes("geometry")),e.textureEndElement=e.textureBuffer?.itemCount??0}elementCount(t,e){const{attributes:r}=t;return"geometry"===e?this._bufferWriter.elementCount(r):"baseInstance"===e?this._bufferWriter.elementCountBaseInstance?.(r)??0:this._bufferWriter.elementCountTextureBuffer?.(r)??0}vertexElementCount(t){return this._bufferWriter.elementCount(t.attributes)}textureElementCount(t){return this._bufferWriter.elementCountTextureBuffer?.(t.attributes)??0}canGrow(t,e){const r=this.targetBuffers.map(r=>this._evaluateTargetBufferGrowth(r,t,e));return r.every(({canGrow:t})=>t)&&r.some(({needsToGrow:t})=>t)}_evaluateTargetBufferGrowth(t,e,r){const o=this._targetLayout(t),s=e.getTargetBuffer(t);if(null==o||null==s)return{needsToGrow:null!=o,canGrow:!0};return{needsToGrow:r[t]*o.stride>s.sizeBytes,canGrow:"geometry"===t?s.sizeBytes<v(x-b):s.sizeBytes<u(this._rctx,o)}}clearHoles(t,e){for(const r of this.targetBuffers){const o=this._targetStrideBytes(r),s=t[r],n=s.reduce((t,e)=>Math.max(t,e.numElements),0)*o,a=S(n);a.fill(0,0,n);for(const t of s)this._setTargetSubData(r,e,o,t,a)}}clearHolesMetal(t,e,r){const{targetBuffers:o}=this,s={};let n=0;for(const i of o){const t=e[i].numElements*this._targetStrideBytes(i);s[i]=n,n+=t}const a=S(n);a.fill(0,0,n);const f={};for(const i of o)f[i]=this._targetLayout(i)?.createView(a.buffer,s[i]);for(const i of t){const t=i.targetRanges.geometry;if(!(t.from>=e.geometry.from&&t.to<=e.geometry.to))continue;const r={};for(const s of o)r[s]=i.targetRanges[s].from-e[s].from;this._writeGeometry(i.geometry,f,r,i.targetRanges)}for(const i of o)this._setTargetSubData(i,r,this._targetStrideBytes(i),e[i],a,s[i])}writeRandomInstances(t,e,r){const{targetBuffers:o}=this,s={},n={},a={},f={};let i=0;for(const g of o)s[g]=t[g]*this._targetStrideBytes(g),n[g]=i,a[g]=0,f[g]=m.acquire(0,0),i+=s[g];const u=S(i),c={};for(const m of o)c[m]=this._targetLayout(m)?.createView(u.buffer,n[m]);for(const m of e){for(const t of o){const e=m.targetRanges[t],o=f[t];o.to===e.from||(o.numElements>0&&this._setTargetSubData(t,r,this._targetStrideBytes(t),f[t],u,n[t]),o.from=e.from,a[t]=0)}this._writeGeometry(m.geometry,c,a,m.targetRanges);for(const t of o){const e=m.targetRanges[t];a[t]+=e.numElements,f[t].to=e.to}}for(const g of o){const t=f[g];t.numElements>0&&this._setTargetSubData(g,r,this._targetStrideBytes(g),t,u,n[g]),m.release(f[g])}}writeInstanceRangeMetal(t,e,r){const{targetBuffers:o}=this,s={},n={};let a=0;for(const u of o)s[u]=t[u].numElements*this._targetStrideBytes(u),n[u]=a,a+=s[u];const f=S(a),i={};for(const u of o)i[u]=this._targetLayout(u)?.createView(f.buffer,n[u]);f.fill(0,0,a);for(const u of e){const e=u.targetRanges.geometry;if(!(e.from>=t.geometry.from&&e.to<=t.geometry.to))continue;const r={},s={};for(const n of o){const e=u.targetRanges[n];r[n]=e.from-t[n].from,s[n]=e}this._writeGeometry(u.geometry,i,r,s)}for(const u of o)t[u].numElements>0&&this._setTargetSubData(u,r,this._targetStrideBytes(u),t[u],f,n[u])}rebuildInstances(t,e,r){const{targetBuffers:o}=this,s={},n={},a={};let f=0;for(const c of o)s[c]=t[c]*this._targetStrideBytes(c),n[c]=f,f+=s[c],a[c]=0;const i=S(f),u={};for(const c of o)u[c]=this._targetLayout(c)?.createView(i.buffer,n[c]);for(const c of e){const t={},e={};for(const r of o){t[r]=a[r],a[r]+=this.elementCount(c.geometry.geometry,r);const o=c.targetRanges[r];o.from=t[r],o.to=a[r],e[r]=o}this._writeGeometry(c.geometry,u,t,e)}for(const c of o){const t=m.acquire(0,a[c]);this._setTargetSubData(c,r,this._targetStrideBytes(c),t,i,n[c]),m.release(t)}return a}updateInstance(t,e){const{targetBuffers:r}=this,o={},s={};let n=0;for(const u of r){const e=this._targetStrideBytes(u);o[u]=this.elementCount(t.geometry.geometry,u)*e,s[u]=n,n+=o[u]}const a=S(n),f={},i={};for(const u of r)i[u]=0,f[u]=this._targetLayout(u)?.createView(a.buffer,s[u]);this._writeGeometry(t.geometry,f,i,t.targetRanges);for(const u of r)this._setTargetSubData(u,e,this._targetStrideBytes(u),t.targetRanges[u],a,s[u])}updateInstancesMetal(t){const{targetBuffers:e}=this;for(const[r,o]of t){const t={};for(const r of e)t[r]=m.acquire(1/0,-1/0);for(const r of o)for(const o of e){const e=t[o],s=r.targetRanges[o];e.from=Math.min(e.from,s.from),e.to=Math.max(e.to,s.to)}this.writeInstanceRangeMetal(t,r.instances.values(),r);for(const r of e)m.release(t[r])}}_writeGeometry(t,e,n,a){const{_bufferWriter:f}=this;null!=f&&(r(B,t.transformation),B[12]-=t.localOrigin.vec3[0],B[13]-=t.localOrigin.vec3[1],B[14]-=t.localOrigin.vec3[2],o(_,B),s(_,_),f.write(B,_,t.geometry.attributes,t.geometry.olidColor,e.geometry,n.geometry,a.texture),null!=e.texture&&f.writeTextureBuffer&&f.writeTextureBuffer(B,_,t.geometry.attributes,e.texture,n.texture))}_setTargetSubData(t,e,r,o,s,n=0){if("geometry"===t){const a=e.getTargetBuffer(t);a?.setSubData(s,o.from*r,n,o.numElements*r)}else if("texture"===t){const r=e.getTargetBuffer(t);r?.setSubData(s.buffer,o.from,n,o.numElements)}}static prune(){w=new Uint8Array(b)}}const B=n(),_=n(),b=262144,d=1024,x=16777216;let w=new Uint8Array(b);function S(t){return w.byteLength<t&&(w=new Uint8Array(t)),w}function v(e){return e<=d?d:e<b?t(e):Math.max(Math.min(Math.ceil(1.5*e/b)*b,x),e)}export{y as VaoWriter};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{createResolver as e}from"../../../../core/promiseUtils.js";import{clone as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{resampleHermite as r}from"../../../support/screenshotUtils.js";import{DataType as s}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as i}from"../../../webgl/FramebufferObject.js";import{createEmptyImageData as n}from"../../../../core/imageUtils.js";class o{constructor(e,t){this.parameters=e,this.fbos=t}}class a{constructor(e,t,r){this._rctx=e,this._renderFunctions=t,this._forceCameraHook=r,this.supersample=!0,this._screenshotQueue=new Array}destroy(){this._rctx=null}async takeScreenshot(t){await this._renderFunctions.prepareOverlay(),this._renderFunctions.requestRenderScene(0);const r=e();return this._screenshotQueue.push({settings:t,resolver:r}),r.promise}update(e,t){for(const r of this._screenshotQueue){if(null==this._rctx){r.resolver.reject();continue}const s={...r.settings,pixelRatio:r.settings.pixelRatio*e.parameters.camera.pixelRatio},i=this._renderScreenshot(e,s,t);r.resolver(i)}this._screenshotQueue.length=0}_renderScreenshotOverlay(e,t,r){e.width=t.width,e.height=t.height;const s=e.getContext("2d",{willReadFrequently:!0}),i=r.pixelRatio;return s.save(),s.translate(0,t.height),s.scale(1,-1),r.region&&s.translate(-r.region.x,-r.region.y),s.scale(i,i),t=this._renderFunctions.renderOverlay(e,r.disableDecorations,t),s.restore(),t}_readbackScreenshot(e,t){return e.resample?this._readbackScreenshotResampled({...e,resample:e.resample},t):this._readbackScreenshotImmediate(e,t)}_readbackScreenshotResampled(e,t){const{framebufferWidth:i,framebufferHeight:o,region:a,resample:h}=e,c=this._ensureScreenshotEncodeCanvas();let l=n(i,o,c);this._rctx.gl.readPixels(0,0,i,o,6408,s.UNSIGNED_BYTE,new Uint8Array(l.data.buffer)),t(),l=this._renderScreenshotOverlay(c,l,{...e,region:void 0});const d=n(a.width,a.height,c);return r(l,d,!0,h.region.x,o-(h.region.y+h.region.height),h.region.width,h.region.height)}_readbackScreenshotImmediate(e,t){const{framebufferHeight:r,region:i}=e,o=this._ensureScreenshotEncodeCanvas(),a=n(i.width,i.height,o);return this._rctx.gl.readPixels(i.x,r-(i.y+i.height),i.width,i.height,6408,s.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),t(),this._renderScreenshotOverlay(o,a,e)}_renderScreenshot(e,r,s){const n=e.parameters.camera,{framebufferWidth:o,framebufferHeight:a,ignorePadding:h,pixelRatio:c,disableDecorations:l,olidColor:d}=r,f={width:o,height:a};i(f,Math.min(this._rctx.parameters.maxTextureSize,this._rctx.parameters.maxRenderbufferSize));let u=!1;const m=f.width!==n.fullWidth||f.height!==n.fullHeight,g=h&&n.pixelRatio!==c,_=m||l||g||d;let p=null,b=null;if(_){const e=n.clone();if(h){const r=t(e.padding);for(let t=0;t<4;t++)r[t]=Math.round(r[t]/e.pixelRatio*c);e.padding=r}e.fullWidth=f.width,e.fullHeight=f.height,e.pixelRatio=c;const r=n.fovX-e.fovX,i=n.fovY-e.fovY;r<0&&r<i?e.fovX=n.fovX:i<0&&i<r&&(e.fovY=n.fovY);const o={camera:e,contentCamera:e,mode:2,alignPixelEnabled:!0,contentPixelRatio:e.pixelRatio};this._forceCameraHook(o),u=!0;const a=this._renderFunctions.renderScene(o,s,d?2:1,l);b=a.
|
|
2
|
+
import{createResolver as e}from"../../../../core/promiseUtils.js";import{clone as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{resampleHermite as r}from"../../../support/screenshotUtils.js";import{DataType as s}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as i}from"../../../webgl/FramebufferObject.js";import{createEmptyImageData as n}from"../../../../core/imageUtils.js";class o{constructor(e,t){this.parameters=e,this.fbos=t}}class a{constructor(e,t,r){this._rctx=e,this._renderFunctions=t,this._forceCameraHook=r,this.supersample=!0,this._screenshotQueue=new Array}destroy(){this._rctx=null}async takeScreenshot(t){await this._renderFunctions.prepareOverlay(),this._renderFunctions.requestRenderScene(0);const r=e();return this._screenshotQueue.push({settings:t,resolver:r}),r.promise}update(e,t){for(const r of this._screenshotQueue){if(null==this._rctx){r.resolver.reject();continue}const s={...r.settings,pixelRatio:r.settings.pixelRatio*e.parameters.camera.pixelRatio},i=this._renderScreenshot(e,s,t);r.resolver(i)}this._screenshotQueue.length=0}_renderScreenshotOverlay(e,t,r){e.width=t.width,e.height=t.height;const s=e.getContext("2d",{willReadFrequently:!0}),i=r.pixelRatio;return s.save(),s.translate(0,t.height),s.scale(1,-1),r.region&&s.translate(-r.region.x,-r.region.y),s.scale(i,i),t=this._renderFunctions.renderOverlay(e,r.disableDecorations,t),s.restore(),t}_readbackScreenshot(e,t){return e.resample?this._readbackScreenshotResampled({...e,resample:e.resample},t):this._readbackScreenshotImmediate(e,t)}_readbackScreenshotResampled(e,t){const{framebufferWidth:i,framebufferHeight:o,region:a,resample:h}=e,c=this._ensureScreenshotEncodeCanvas();let l=n(i,o,c);this._rctx.gl.readPixels(0,0,i,o,6408,s.UNSIGNED_BYTE,new Uint8Array(l.data.buffer)),t(),l=this._renderScreenshotOverlay(c,l,{...e,region:void 0});const d=n(a.width,a.height,c);return r(l,d,!0,h.region.x,o-(h.region.y+h.region.height),h.region.width,h.region.height)}_readbackScreenshotImmediate(e,t){const{framebufferHeight:r,region:i}=e,o=this._ensureScreenshotEncodeCanvas(),a=n(i.width,i.height,o);return this._rctx.gl.readPixels(i.x,r-(i.y+i.height),i.width,i.height,6408,s.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),t(),this._renderScreenshotOverlay(o,a,e)}_renderScreenshot(e,r,s){const n=e.parameters.camera,{framebufferWidth:o,framebufferHeight:a,ignorePadding:h,pixelRatio:c,disableDecorations:l,olidColor:d}=r,f={width:o,height:a};i(f,Math.min(this._rctx.parameters.maxTextureSize,this._rctx.parameters.maxRenderbufferSize));let u=!1;const m=f.width!==n.fullWidth||f.height!==n.fullHeight,g=h&&n.pixelRatio!==c,_=m||l||g||d;let p=null,b=null;if(_){const e=n.clone();if(h){const r=t(e.padding);for(let t=0;t<4;t++)r[t]=Math.round(r[t]/e.pixelRatio*c);e.padding=r}e.fullWidth=f.width,e.fullHeight=f.height,e.pixelRatio=c;const r=n.fovX-e.fovX,i=n.fovY-e.fovY;r<0&&r<i?e.fovX=n.fovX:i<0&&i<r&&(e.fovY=n.fovY);const o={camera:e,contentCamera:e,mode:2,alignPixelEnabled:!0,contentPixelRatio:e.pixelRatio};this._forceCameraHook(o),u=!0;const a=this._renderFunctions.renderScene(o,s,d?2:1,l);b=a.color,p=a.olid}const x=()=>{this._rctx.bindFramebuffer(null),b?.release()};this._rctx.bindFramebuffer(b?.fbo);const v=this._readbackScreenshot(r,x);let S=null;if(d){const e=()=>{this._rctx.bindFramebuffer(null),p?.release()};this._rctx.bindFramebuffer(p?.fbo),S=this._readbackScreenshot(r,e),this._rctx.bindFramebuffer(null)}if(_&&!this._rctx.contextAttributes.alpha)for(let t=3;t<v.data.length;t+=4)v.data[t]=255;if(S&&!this._rctx.contextAttributes.alpha)for(let t=3;t<S.data.length;t+=4)S.data[t]=255;return u&&this._forceCameraHook(e.parameters),[v,S]}_ensureScreenshotEncodeCanvas(){return this._screenshotEncodeCanvas??=document.createElement("canvas"),this._screenshotEncodeCanvas}}export{o as ScreenshotContext,a as ScreenshotManager};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
function
|
|
2
|
+
function o(){const o=globalThis.require?.modules;if(o){const s=Object.keys(o);for(const t of s)t.includes(".glsl")&&delete o[t]}}class s{constructor(o,s){this.color=o,this.olid=s}}export{s as RenderSceneResult,o as removeLoadedShaderModules};
|
package/views/Attribution.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../core/Accessor.js";import{makeHandle as s}from"../core/handleUtils.js";import{isActivationKey as i}from"../core/keyboard.js";import{watch as o,initial as r}from"../core/reactiveUtils.js";import{renderingSanitizer as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../core/Accessor.js";import{makeHandle as s}from"../core/handleUtils.js";import{isActivationKey as i}from"../core/keyboard.js";import{watch as o,initial as r}from"../core/reactiveUtils.js";import{renderingSanitizer as n}from"../core/sanitizerUtils.js";import{addFrameTask as a}from"../core/scheduling.js";import{property as h,subclass as c}from"../core/accessorSupport/decorators.js";import{getCalciteModeClassName as d,setCalciteModeClass as l}from"../support/modeUtils.js";import{globalCss as p}from"../widgets/support/globalCss.js";const u="esri-attribution",_={poweredBy:`${u}__powered-by`,sources:`${u}__sources`,sourcesOpen:`${u}__sources--open`,link:`${u}__link`};let m=class extends t{constructor(e){super(e),this._previousSourceHeight=0,this._opened=!1,this._overflowing=!1,this._changeSet=new Set,this.height=0,this._toggleState=()=>{(this._opened||this._overflowing)&&(this._opened=!this._opened,this._invalidate("opened"))},this.surface=document.createElement("div"),this._task=a({render:()=>{this._update(),this._task.pause(),this._changeSet.clear()}}),this.addHandles(this._task)}appendBefore(e,t){e.insertBefore(this.surface,t),this._invalidate("mode")}initialize(){const e=document.createElement("div");e.setAttribute("dir","ltr"),e.classList.add("esri-widget","esri-view-attribution","esri-attribution"),this._set("surface",e);const t=new ResizeObserver(()=>{this.height=e.clientHeight});t.observe(e),this.addHandles(s(()=>t.disconnect())),e.innerHTML=`\n <div class="${_.sources}"></div>\n <div class="${_.poweredBy}">\n Powered by\n <a class="${_.link}" href="https://www.esri.com/" rel="noreferrer" target="_blank">Esri</a>\n </div>`,this.addHandles([this.surface,o(()=>this.attributionItems,()=>this._invalidate("attributionItems"),r),o(()=>this.mode,()=>this._invalidate("mode"),r)]);const n=e.querySelector(`.${_.sources}`);this._previousSourceHeight=n.clientHeight;const a=new ResizeObserver(()=>{this._invalidate("overflow")});a.observe(n),this.addHandles(s(()=>a.disconnect()));const h=new MutationObserver(()=>{this._invalidate("overflow")});h.observe(n,{childList:!0,subtree:!0,characterData:!0}),this.addHandles(s(()=>h.disconnect())),n.onclick=this._toggleState,n.onkeydown=e=>{i(e.key)&&(e.preventDefault(),this._toggleState())}}_invalidate(e){this._changeSet.add(e),this._task.resume()}_update(){const e=this.surface.querySelector(`.${_.sources}`);if(this._changeSet.has("overflow")){const{clientHeight:t,clientWidth:s,scrollWidth:i}=e,o=t<this._previousSourceHeight;this._previousSourceHeight=t,this._opened?o&&(this._opened=!1):o||(this._overflowing=i>s)}if(this._changeSet.has("overflow")||this._changeSet.has("opened")){const t=this._opened||this._overflowing,s=t?"0":"";e.setAttribute("tabindex",s),e.classList.toggle(p.interactive,t),e.classList.toggle(_.sourcesOpen,this._opened)}this._changeSet.has("attributionItems")&&(e.innerHTML=n.sanitize(this.attributionItems?.map(e=>e.text).join(" | ")??"")),this._changeSet.has("mode")&&(this.surface.classList.remove(d("light"),d("dark")),this.mode?this.surface.classList.add(d(this.mode)):l(this.surface))}};e([h()],m.prototype,"attributionItems",void 0),e([h()],m.prototype,"height",void 0),e([h({type:["dark","light"]})],m.prototype,"mode",void 0),e([h({readOnly:!0})],m.prototype,"surface",void 0),m=e([c("esri.views.Attribution")],m);export{m as Attribution};
|
package/views/DOMContainer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{byId as e,reparent as i}from"../core/domUtils.js";import{on as s}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as d,syncAndInitial as l}from"../core/reactiveUtils.js";import{addFrameTask as u}from"../core/scheduling.js";import{property as c,subclass as p}from"../core/accessorSupport/decorators.js";import{Attribution as m}from"./Attribution.js";import f from"./overlay/ViewOverlay.js";const _=[0,0];function y(t){const e=(t.ownerDocument||window.document).defaultView,i=t.getBoundingClientRect();return _[0]=i.left+(e?.pageXOffset??0),_[1]=i.top+(e?.pageYOffset??0),_}function g(t){t&&(t.textContent="",t.parentNode&&t.parentNode.removeChild(t))}const v="test"===process.env.NODE_ENV,b=v?0:16,w=v?0:750,C=v?0:512,H=2,O=_=>{const v=_;let O=class extends v{constructor(...t){super(...t),this._freqInfo={freq:b,time:w},this._overlayRenderTaskHandle=null,this.aria={},this.attributionMode=null,this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h(()=>this.cursor,t=>{const{surface:e}=this;e&&e.setAttribute("data-cursor",t)}),h(()=>this.navigating,t=>{const{surface:e}=this;e&&e.setAttribute("data-navigating",t.toString())}),h(()=>[this.aria,this.surface],()=>this._updateAria(),{initial:!0})])}initialize(){const t=this;this.addHandles([h(()=>this.ui,(t,e)=>this._handleUIChange(t,e),d),t.on("focus",()=>this.notifyChange("focused")),t.on("blur",()=>this.notifyChange("focused"))])}destroy(){this.destroyed||(this.ui?.destroy(),this.container=null)}get attributionHeight(){return this._attribution?.height??0}get container(){return this._get("container")??null}set container(t){const s=this._get("container"),r=e(t);if(r||"string"!=typeof t||n.getLogger(this).error("#container",`element with id '${t}' not found`),s===r)return;if(this._stopMeasuring(),this.removeHandles("container"),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this._attribution=o(this._attribution),this.root&&(g(this.root),this._set("root",null)),this.userContent&&(i(this.userContent,s),g(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const d=document.createElement("div");d.className="esri-view-user-storage",i(r,d),r.appendChild(d),this._set("userContent",d);const c=document.createElement("div");c.className="esri-view-root",r.insertBefore(c,r.firstChild),this._set("root",c);const p=document.createElement("div");p.className="esri-view-surface",p.setAttribute("role","application"),p.tabIndex=0,c.appendChild(p),this._set("surface",p);const _=new f;c.appendChild(_.surface),this._set("overlay",_),this.addHandles(h(()=>_.needsRender,t=>{t&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=u({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}),"container"),this.addHandles([h(()=>({visible:this.attributionVisible&&this.ready,items:this.attributionItems,mode:this.attributionMode}),({visible:t,items:e,mode:i})=>{t?(this._attribution||(this._attribution=new m({attributionItems:this.attributionItems,mode:this.attributionMode}),this._attribution.
|
|
2
|
+
import{__decorate as t}from"tslib";import{byId as e,reparent as i}from"../core/domUtils.js";import{on as s}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as d,syncAndInitial as l}from"../core/reactiveUtils.js";import{addFrameTask as u}from"../core/scheduling.js";import{property as c,subclass as p}from"../core/accessorSupport/decorators.js";import{Attribution as m}from"./Attribution.js";import f from"./overlay/ViewOverlay.js";const _=[0,0];function y(t){const e=(t.ownerDocument||window.document).defaultView,i=t.getBoundingClientRect();return _[0]=i.left+(e?.pageXOffset??0),_[1]=i.top+(e?.pageYOffset??0),_}function g(t){t&&(t.textContent="",t.parentNode&&t.parentNode.removeChild(t))}const v="test"===process.env.NODE_ENV,b=v?0:16,w=v?0:750,C=v?0:512,H=2,O=_=>{const v=_;let O=class extends v{constructor(...t){super(...t),this._freqInfo={freq:b,time:w},this._overlayRenderTaskHandle=null,this.aria={},this.attributionMode=null,this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h(()=>this.cursor,t=>{const{surface:e}=this;e&&e.setAttribute("data-cursor",t)}),h(()=>this.navigating,t=>{const{surface:e}=this;e&&e.setAttribute("data-navigating",t.toString())}),h(()=>[this.aria,this.surface],()=>this._updateAria(),{initial:!0})])}initialize(){const t=this;this.addHandles([h(()=>this.ui,(t,e)=>this._handleUIChange(t,e),d),t.on("focus",()=>this.notifyChange("focused")),t.on("blur",()=>this.notifyChange("focused"))])}destroy(){this.destroyed||(this.ui?.destroy(),this.container=null)}get attributionHeight(){return this._attribution?.height??0}get container(){return this._get("container")??null}set container(t){const s=this._get("container"),r=e(t);if(r||"string"!=typeof t||n.getLogger(this).error("#container",`element with id '${t}' not found`),s===r)return;if(this._stopMeasuring(),this.removeHandles("container"),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this._attribution=o(this._attribution),this.root&&(g(this.root),this._set("root",null)),this.userContent&&(i(this.userContent,s),g(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const d=document.createElement("div");d.className="esri-view-user-storage",i(r,d),r.appendChild(d),this._set("userContent",d);const c=document.createElement("div");c.className="esri-view-root",r.insertBefore(c,r.firstChild),this._set("root",c);const p=document.createElement("div");p.className="esri-view-surface",p.setAttribute("role","application"),p.tabIndex=0,c.appendChild(p),this._set("surface",p);const _=new f;c.appendChild(_.surface),this._set("overlay",_),this.addHandles(h(()=>_.needsRender,t=>{t&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=u({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}),"container"),this.addHandles([h(()=>({visible:this.attributionVisible&&this.ready,items:this.attributionItems,mode:this.attributionMode}),({visible:t,items:e,mode:i})=>{t?(this._attribution||(this._attribution=new m({attributionItems:this.attributionItems,mode:this.attributionMode}),this._attribution.appendBefore(c,this.ui.container)),this._attribution.attributionItems=e,this._attribution.mode=i):this._attribution=o(this._attribution)},l)],"container"),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const t=document.activeElement===this.surface;return document.hasFocus()&&t}get size(){return[this.width,this.height]}get ui(){return this._get("ui")}set ui(t){const e=this._get("ui");e!==t&&e?.destroy(),this._set("ui",t)}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(t,e,i){const s=this.position;return t-=s?s[0]:0,e-=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}containerToPage(t,e,i){const s=this.position;return t+=s?s[0]:0,e+=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}_updateAria(){const{surface:t,aria:e}=this;t&&(t.ariaLabelledByElements=e?.labelledByElements??null,t.ariaDescribedByElements=e?.describedByElements??null,t.ariaLabel=e?.label??null,t.ariaDescription=e?.description??null)}_handleUIChange(t,e){this.removeHandles("ui"),e&&e!==t&&e.destroy(),t&&(t.view=this,this.addHandles(h(()=>this.root,e=>{if(e){const i=document.createElement("div");e.insertBefore(i,this._attribution?.surface??null),t.container=i}else t.container=null},d),"ui")),this._set("ui",t)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const t=this._freqInfo;t.freq=b,t.time=w;const e=u({prepare:t=>{const i=this._measure(),s=this._freqInfo;if(s.time+=t.deltaTime,i&&(s.freq=b,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const r=this._position();s.freq=r||i?b:Math.min(w,s.freq*H),!i&&s.freq>=C&&(e.pause(),this._get("resizing")&&this._set("resizing",!1))}}),i=new ResizeObserver(i=>{t.freq=b,t.time=w,e.resume()});null!=this.container&&i.observe(this.container);const n=r(()=>i.disconnect());this.addHandles([s(window,"resize",()=>{t.freq=b,t.time=w,e.resume()}),n,e],"measuring"),this._measure(),this._position()}_measure(){const t=this.container,e=t?t.clientWidth:0,i=t?t.clientHeight:0;if(0===e||0===i)return this.suspended||this._set("suspended",!0),!1;const s=this.width,r=this.height;if(e===s&&i===r)return this.suspended&&this._set("suspended",!1),!1;this._set("width",e),this._set("height",i),this.suspended&&this._set("suspended",!1);return this.emit("resize",{oldWidth:s,oldHeight:r,width:e,height:i}),!0}_position(){const t=this.container,e=this.position,i=t&&y(t);return!!i&&((!e||i[0]!==e[0]||i[1]!==e[1])&&(this._set("position",[i[0],i[1]]),!0))}forceDOMReadyCycle(){}};return t([c()],O.prototype,"_attribution",void 0),t([c()],O.prototype,"aria",void 0),t([c()],O.prototype,"attributionHeight",null),t([c()],O.prototype,"attributionMode",void 0),t([c()],O.prototype,"container",null),t([c({readOnly:!0})],O.prototype,"focused",null),t([c({readOnly:!0})],O.prototype,"height",void 0),t([c()],O.prototype,"messagesCommon",void 0),t([c({type:f})],O.prototype,"overlay",void 0),t([c({readOnly:!0})],O.prototype,"position",void 0),t([c({readOnly:!0})],O.prototype,"resizing",void 0),t([c({readOnly:!0})],O.prototype,"root",void 0),t([c({value:null,readOnly:!0})],O.prototype,"size",null),t([c({readOnly:!0})],O.prototype,"surface",void 0),t([c({readOnly:!0})],O.prototype,"suspended",void 0),t([c({nonNullable:!0})],O.prototype,"ui",null),t([c({readOnly:!0})],O.prototype,"userContent",void 0),t([c({readOnly:!0})],O.prototype,"width",void 0),t([c()],O.prototype,"widthBreakpoint",void 0),O=t([p("esri.views.DOMContainer")],O),O};export{O as DOMContainer};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import type Graphic from "../Graphic.js";
|
|
2
|
+
import type Collection from "../core/Collection.js";
|
|
3
|
+
import type GraphicsLayer from "../layers/GraphicsLayer.js";
|
|
4
|
+
import type View from "./View.js";
|
|
5
|
+
import type { EventedAccessor } from "../core/Evented.js";
|
|
6
|
+
import type { QueryProperties } from "../rest/support/Query.js";
|
|
7
|
+
import type { ObjectId } from "./types.js";
|
|
8
|
+
import type { LayerFeatureSet, LayerSelectionChange, SelectableLayer, SelectableLayerWithObjectIds, SelectionIdentifier, LayerSelection } from "./selection/types.js";
|
|
9
|
+
|
|
10
|
+
export interface SelectionManagerProperties extends Partial<Pick<SelectionManager, "highlightEnabled" | "highlightName" | "view">> {
|
|
11
|
+
/**
|
|
12
|
+
* A collection of selectable layers managed by the selection manager. Use `syncSources` to automatically populate this collection from the layers and tables in a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
|
|
13
|
+
*
|
|
14
|
+
* > [!CAUTION]
|
|
15
|
+
* > When setting the sources property to an external Collection or array, the selection
|
|
16
|
+
* > manager adds its contents to an internal Collection.
|
|
17
|
+
* > Therefore, when the `SelectionManager` is destroyed, this internal `sources`
|
|
18
|
+
* > Collection is always destroyed.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Create a selection manager and set its view.
|
|
22
|
+
* // Then, add a layer to its sources.
|
|
23
|
+
* const selectionManager = new SelectionManager({
|
|
24
|
+
* view,
|
|
25
|
+
* sources: [featureLayer]
|
|
26
|
+
* });
|
|
27
|
+
* @example
|
|
28
|
+
* // Later, if you want to add more layers, you can do so like this:
|
|
29
|
+
* selectionManager.sources.add(anotherFeatureLayer);
|
|
30
|
+
* // Or, if you want to replace the existing sources with a new set of layers:
|
|
31
|
+
* selectionManager.sources = [differentFeatureLayer];
|
|
32
|
+
* @see [syncSources](#syncSources)
|
|
33
|
+
*/
|
|
34
|
+
sources?: Collection<SelectableLayer> | SelectableLayer[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @since 5.0 */
|
|
38
|
+
export interface SelectionManagerEvents {
|
|
39
|
+
/** @since 5.0 */
|
|
40
|
+
"selection-change": {
|
|
41
|
+
view: View | null | undefined;
|
|
42
|
+
changes: LayerSelectionChange[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A selection manager controls the selection of features in layers and tables within a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) to help manage feature selection. It can be wired up to listen for edits made to selectable layers and have the selection update accordingly.
|
|
48
|
+
*
|
|
49
|
+
* @since 5.0
|
|
50
|
+
* @beta
|
|
51
|
+
* @example
|
|
52
|
+
* // Create a selection manager and set its view.
|
|
53
|
+
* // Then, add a layer to its sources.
|
|
54
|
+
* const selectionManager = new SelectionManager({
|
|
55
|
+
* view,
|
|
56
|
+
* sources: [featureLayer]
|
|
57
|
+
* });
|
|
58
|
+
* // Select the features in the layer with specified Object IDs.
|
|
59
|
+
* selectionManager.replace(featureLayer, [1, 2, 3]);
|
|
60
|
+
*/
|
|
61
|
+
export default class SelectionManager extends EventedAccessor {
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
* Do not directly reference this property.
|
|
65
|
+
* Use EventNames and EventTypes helpers from \@arcgis/core/Evented
|
|
66
|
+
*/
|
|
67
|
+
"@eventTypes": SelectionManagerEvents;
|
|
68
|
+
constructor(properties?: SelectionManagerProperties);
|
|
69
|
+
/** The total number of selected features across all sources. */
|
|
70
|
+
get count(): number;
|
|
71
|
+
/** Returns `true` if at least one source has an active selection. */
|
|
72
|
+
get hasSelection(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Indicates whether to display a visual representation of the selection with a highlight.
|
|
75
|
+
*
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
accessor highlightEnabled: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The [highlights name](https://developers.arcgis.com/javascript/latest/references/core/views/support/HighlightOptions/#name) to use when specifying a set of [highlight options](https://developers.arcgis.com/javascript/latest/references/core/views/support/HighlightOptions/).
|
|
81
|
+
*
|
|
82
|
+
* @default "default"
|
|
83
|
+
* @see [MapView.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#highlights)
|
|
84
|
+
* @see [HighlightOptions](https://developers.arcgis.com/javascript/latest/references/core/views/support/HighlightOptions/)
|
|
85
|
+
*/
|
|
86
|
+
accessor highlightName: string;
|
|
87
|
+
/** A read-only copy of the selection. To modify selections, use [add](#add), [replace](#replace), [remove](#remove), or [toggle](#toggle). */
|
|
88
|
+
get selections(): LayerSelection[];
|
|
89
|
+
/**
|
|
90
|
+
* A collection of selectable layers managed by the selection manager. Use `syncSources` to automatically populate this collection from the layers and tables in a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
|
|
91
|
+
*
|
|
92
|
+
* > [!CAUTION]
|
|
93
|
+
* > When setting the sources property to an external Collection or array, the selection
|
|
94
|
+
* > manager adds its contents to an internal Collection.
|
|
95
|
+
* > Therefore, when the `SelectionManager` is destroyed, this internal `sources`
|
|
96
|
+
* > Collection is always destroyed.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* // Create a selection manager and set its view.
|
|
100
|
+
* // Then, add a layer to its sources.
|
|
101
|
+
* const selectionManager = new SelectionManager({
|
|
102
|
+
* view,
|
|
103
|
+
* sources: [featureLayer]
|
|
104
|
+
* });
|
|
105
|
+
* @example
|
|
106
|
+
* // Later, if you want to add more layers, you can do so like this:
|
|
107
|
+
* selectionManager.sources.add(anotherFeatureLayer);
|
|
108
|
+
* // Or, if you want to replace the existing sources with a new set of layers:
|
|
109
|
+
* selectionManager.sources = [differentFeatureLayer];
|
|
110
|
+
* @see [syncSources](#syncSources)
|
|
111
|
+
*/
|
|
112
|
+
get sources(): Collection<SelectableLayer>;
|
|
113
|
+
set sources(value: Collection<SelectableLayer> | SelectableLayer[]);
|
|
114
|
+
/**
|
|
115
|
+
* Indicates whether the selection manager is currently updating the view's visualization of selections.
|
|
116
|
+
*
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
get updating(): boolean;
|
|
120
|
+
/** A reference to the [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/), or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). This property must be set if wanting to highlight a corresponding feature within the map when a row is selected. In addition, setting the `view` is required if working with [layer views](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/). */
|
|
121
|
+
accessor view: View | null | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Adds features to the current selection. It does not replace the existing selection.
|
|
124
|
+
*
|
|
125
|
+
* @param layer - The selectable layer to which to add the selection. This must be a layer with graphics in the [sources](#sources).
|
|
126
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) to add to the current selection.
|
|
127
|
+
*/
|
|
128
|
+
add(layer: GraphicsLayer, selection: Graphic[]): void;
|
|
129
|
+
/**
|
|
130
|
+
* Adds features to the current selection. It does not replace the existing selection.
|
|
131
|
+
*
|
|
132
|
+
* @param layer - The selectable layer to which to add the selection. This must be a layer with object IDs in the [sources](#sources).
|
|
133
|
+
* @param selection - An array of features, ie. [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to add to the current selection.
|
|
134
|
+
*/
|
|
135
|
+
add(layer: SelectableLayerWithObjectIds, selection: ObjectId[]): void;
|
|
136
|
+
/**
|
|
137
|
+
* Adds features to the current selection. It does not replace the existing selection.
|
|
138
|
+
*
|
|
139
|
+
* @param layer - The selectable layer to which to add the selection. This must be a layer in the [sources](#sources). It can be a layer with graphics or object IDs.
|
|
140
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) or [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to add to the current selection.
|
|
141
|
+
*/
|
|
142
|
+
add(layer: SelectableLayer, selection: SelectionIdentifier[]): void;
|
|
143
|
+
/** Clears all selections from all layers. */
|
|
144
|
+
clear(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Queries the selected features for one or more layers. It uses the
|
|
147
|
+
* current selection identifiers to fetch feature data from
|
|
148
|
+
* the layer which may include attributes, geometry, etc. depending on the layer's capabilities and the supplied `queryParams`.
|
|
149
|
+
*
|
|
150
|
+
* @param includeLayers - Specifies the layer from which to fetch features. If not provided, all layers with active selections are queried.
|
|
151
|
+
* @param queryParams - If supplied, it may include any supplemental parameters to thin out the feature results. The object IDs will also be part of the generated query.
|
|
152
|
+
* @param queryTarget - If `"layer"`, applies all queries to the layer itself rather than the layer view. This can be used to bypass any client-side filtering that may be applied within the layer view. Note that not all layers support querying on the layer itself, so this option should be used with caution. If a layer does not support querying on the layer itself, the query will automatically be applied to the layer view instead.
|
|
153
|
+
* @returns A promise that resolves to an array of [LayerFeatureSet](https://developers.arcgis.com/javascript/latest/references/core/views/selection/types/#LayerFeatureSet), which includes the layer and the resulting features for that layer.
|
|
154
|
+
* @name getSelectedFeatures
|
|
155
|
+
*/
|
|
156
|
+
getSelectedFeatures(includeLayers: SelectableLayerWithObjectIds[] | undefined, queryParams: QueryProperties | undefined, queryTarget?: "layerView" | "layer"): Promise<LayerFeatureSet[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Gets the active selection for the provided layer. If the layer is not part of the [sources](#sources) or has no active selection, this method returns `undefined`. Otherwise, it returns an array of selected features, which can be either [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) or [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] depending on the layer's capabilities. To retrieve the full graphic representations of selected features from a layer that supports only object ID selection, use the [getSelectedFeatures](#getSelectedFeatures) method. This method queries the layer using the selected object IDs and returns the corresponding feature graphics.
|
|
159
|
+
*
|
|
160
|
+
* @param target - The selectable layer that provides the selected features. This must be a layer with graphics in the [sources](#sources).
|
|
161
|
+
* @returns Returns an array of [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/)s representing the selected features.
|
|
162
|
+
*/
|
|
163
|
+
getSelection(target: GraphicsLayer): Graphic[] | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* @param target - The selectable layer that provides the selected features. This must be a layer with object IDs in the [sources](#sources).
|
|
166
|
+
* @returns Returns an array of [ObjectId's](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId) representing the selected features.
|
|
167
|
+
*/
|
|
168
|
+
getSelection(target: SelectableLayerWithObjectIds): ObjectId[] | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* @param target - The selectable layer that provides the selected features.This must be a layer in the [sources](#sources). It can be a layer with graphics or object IDs.
|
|
171
|
+
* @returns Returns an array of selected features represented as either [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) or [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] dependent upon the layer's capabilities.
|
|
172
|
+
*/
|
|
173
|
+
getSelection(target: SelectableLayer): SelectionIdentifier[] | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* Removes the provided features from the current selection for the provided layer.
|
|
176
|
+
*
|
|
177
|
+
* @param target - The selectable layer from which to remove the selection. This must be a layer with graphics in the [sources](#sources).
|
|
178
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) to remove from the current selection.
|
|
179
|
+
*/
|
|
180
|
+
remove(target: GraphicsLayer, selection: Graphic[]): void;
|
|
181
|
+
/**
|
|
182
|
+
* @param target - The selectable layer from which to remove the selection. This must be a layer with object IDs in the [sources](#sources).
|
|
183
|
+
* @param selection - An array of features, ie. [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to remove from the current selection.
|
|
184
|
+
*/
|
|
185
|
+
remove(target: SelectableLayerWithObjectIds, selection: ObjectId[]): void;
|
|
186
|
+
/**
|
|
187
|
+
* @param target - The selectable layer from which to remove the selection. This must be a layer in the [sources](#sources). It can be a layer with graphics or object IDs.
|
|
188
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) or [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to remove from the current selection.
|
|
189
|
+
*/
|
|
190
|
+
remove(target: SelectableLayer, selection: SelectionIdentifier[]): void;
|
|
191
|
+
/**
|
|
192
|
+
* Replaces the current selection for the provided layer with the provided features.
|
|
193
|
+
*
|
|
194
|
+
* @param layer - The selectable layer for which to replace the selection. This must be a layer with graphics in the [sources](#sources).
|
|
195
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) to set as the current selection.
|
|
196
|
+
*/
|
|
197
|
+
replace(layer: GraphicsLayer, selection: Graphic[]): void;
|
|
198
|
+
/**
|
|
199
|
+
* @param layer - The selectable layer for which to replace the selection. This must be a layer with object IDs in the [sources](#sources).
|
|
200
|
+
* @param selection - An array of features, ie. [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to set as the current selection.
|
|
201
|
+
*/
|
|
202
|
+
replace(layer: SelectableLayerWithObjectIds, selection: ObjectId[]): void;
|
|
203
|
+
/**
|
|
204
|
+
* @param layer - The selectable layer for which to replace the selection. This must be a layer in the [sources](#sources). It can be a layer with graphics or object IDs.
|
|
205
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) or [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to set as the current selection.
|
|
206
|
+
*/
|
|
207
|
+
replace(layer: SelectableLayer, selection: SelectionIdentifier[]): void;
|
|
208
|
+
/**
|
|
209
|
+
* A convenience method to synchronize the [sources](#sources) with the layers and tables in the provided view. This is useful when layers or tables have been added or removed from the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/). This method is not applicable if [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) is not provided with the view.
|
|
210
|
+
*
|
|
211
|
+
* @see [sources](#sources)
|
|
212
|
+
* @example
|
|
213
|
+
* // Add a layer to the view's map after the selection manager has already been created
|
|
214
|
+
* // and synced with the existing layers.
|
|
215
|
+
* // Then, call syncSources to update the selection manager with the new layer.
|
|
216
|
+
* const selectionManager = new SelectionManager({
|
|
217
|
+
* view: someView
|
|
218
|
+
* });
|
|
219
|
+
* someView.map.add(featureLayer);
|
|
220
|
+
* selectionManager.syncSources();
|
|
221
|
+
*/
|
|
222
|
+
syncSources(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Toggles selection for the provided features within the provided layer's selection set.
|
|
225
|
+
* If a given feature is part of the current set it will be removed, otherwise it will be added.
|
|
226
|
+
* This method is designed to make it easy to toggle features in/out of the selected set in response to a query or UI event.
|
|
227
|
+
*
|
|
228
|
+
* @param layer - The selectable layer for which to toggle the selection. This must be a layer with graphics in the [sources](#sources).
|
|
229
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) to toggle within the current selection.
|
|
230
|
+
*/
|
|
231
|
+
toggle(layer: GraphicsLayer, selection: Graphic[]): void;
|
|
232
|
+
/**
|
|
233
|
+
* @param layer - The selectable layer for which to toggle the selection. This must be a layer with object IDs in the [sources](#sources).
|
|
234
|
+
* @param selection - An array of features, ie. [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to toggle within the current selection.
|
|
235
|
+
*/
|
|
236
|
+
toggle(layer: SelectableLayerWithObjectIds, selection: ObjectId[]): void;
|
|
237
|
+
/**
|
|
238
|
+
* @param layer - The selectable layer for which to toggle the selection. This must be a layer in the [sources](#sources). It can be a layer with graphics or object IDs.
|
|
239
|
+
* @param selection - An array of features, ie. [Graphic[]](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) or [ObjectId](https://developers.arcgis.com/javascript/latest/references/core/views/types/#ObjectId)[] to toggle within the current selection.
|
|
240
|
+
*/
|
|
241
|
+
toggle(layer: SelectableLayer, selection: SelectionIdentifier[]): void;
|
|
242
|
+
}
|
package/views/View.d.ts
CHANGED
|
@@ -331,7 +331,7 @@ export default abstract class View<TLayerView extends LayerView = LayerView> ext
|
|
|
331
331
|
* >
|
|
332
332
|
* > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content.
|
|
333
333
|
* > For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/terms/attribution/) documentation.
|
|
334
|
-
* > For information
|
|
334
|
+
* > For information, see the [Terms of Use documentation](https://developers.arcgis.com/documentation/terms-of-use/).
|
|
335
335
|
*
|
|
336
336
|
* @default true
|
|
337
337
|
* @since 5.0
|
package/views/draw/DrawTool.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e,__addDisposableResource as t,__disposeResources as a}from"tslib";import{disposable as n}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{when as s,initial as d,on as l,sync as p,watch as c}from"../../core/reactiveUtils.js";import{screenPointEqual as g,createScreenPoint as u}from"../../core/screenUtils.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as M}from"../../core/support/UpdatingHandles.js";import{createSnappingVisualizer as y}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as f,markHandled as _,getPointerType as w}from"./support/drawToolUtils.js";import{PluginContext as C}from"./support/PluginContext.js";import{viewEventToCommand as H}from"./support/input/drawToolInput.js";import{EditSessionManager as x}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as S}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as b}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as P}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as k}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as T}from"./support/managers/SurfaceManager.js";import{TooltipManager as O}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as j}from"../input/InputManager.js";import{createCoordinateHelper as I}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as A}from"../interactive/InteractiveToolBase.js";import{KeyBindings as V,mediaKeys as E,sketchKeys as U,advancedSketchKeys as D,tooltipKeys as L}from"../interactive/keybindings.js";import{isInputModeAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";const G=Symbol();let Z=class extends A{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._snappingVisualizer=null,this._updatingHandles=new M,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new P,this.globalStateManager=new S({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new x({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new k({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null}initialize(){const{view:e}=this;this.interactiveHandleManager=new b({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new O({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(s(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(y(e,t).then(e=>this._snappingVisualizer=e))},d)),this.addHandles([s(()=>this.view,e=>{this.surfaceManager?.destroy(),this.surfaceManager=new T({spatialReference:this.coordinateHelper.spatialReference,excludedGraphicsLayer:null,defaultZ:this.defaultZ,hasZ:this.hasZ,view:e,elevationInfo:this.elevationInfo,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},d),s(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),l(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},p),l(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},p),l(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),a=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:a,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:a,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:a,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=o(this.surfaceManager),this.interactiveHandleManager=o(this.interactiveHandleManager),this.tooltipManager=o(this.tooltipManager)}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:a,directionOptions:n,view:i}=this;return t&&a&&i?{defaultZ:e,directionOptions:n,editGeometryOperations:t,sketchOptions:a,view:i,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;return{coordinateHelper:e,viewingMode:"3d"===t?.type&&"global"===t.viewingMode?1:2}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating}get coordinateHelper(){return I(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get geometry(){return this.editSessionManager.outputGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){return this.lastScreenPosition?this.view.toMap(this.lastScreenPosition):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:a,snappingManager:n,interactiveHandleManager:i,_snappingVisualizer:r,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:d},view:l}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:a,interactiveHandleManager:i,snappingManager:n,snappingVisualizer:r,pointerType:"mouse",hasZ:s,defaultZ:o,view:l,drawAtFixedElevation:d}}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;e&&t.complete(e),0===t.pluginStack.length&&(this.emit("complete"),this.view?.activeTool===this&&(this.view.activeTool=null))}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}replaceLeaf(e){const t=this.lifecycleManager;t.updating?i.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){return this._guardCommand({action:"undo"},()=>this.editSessionManager.undo())}redo(){return this._guardCommand({action:"redo"},()=>this.editSessionManager.redo())}executeCommand(e){return this._handleCommand(e)}addPromise(e){return this._updatingHandles.addPromise(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.addHandles([c(()=>this.geometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e}),this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?f(e):null})},d),c(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:g}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const a=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&a&&this.emit("cursor-update",{updated:a.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:a.part.index,vertexIndex:a.index,coordinates:a.pos}]})},p),this._keybindings.register(e,j.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&h(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],G)}onDeactivate(){super.onDeactivate(),this.removeHandles(G),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=H(e);t&&this._handleCommand(t)}async _handleCommand(e){if(this.lifecycleManager.updating)i.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>(_(e),this._updatingHandles.addPromise(this._commitNext())));case"vertex-add-and-finish-part":return await this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(_(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&_(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&R(t.info)&&(await t.enterInputMode(),_(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,a=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==a?.captureMode&&"capture-when-engaged"!==a?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&_(e):_(e)}async _handleVertexAddAndFinishPartCommand(e){this._before(e)||(_(e),await this._updatingHandles.addPromise(this._commitNext().then(async()=>{this.finishPart()})))}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:w(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions())}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&_(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:w(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=w(e.originalEvent),a=this._updateLastScreenPosition(e),n=this.interactiveHandleManager?.findHandleByManipulator(a);"touch"===t&&n&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const i=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=i??r??n;o&&!n&&_(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(a,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===w(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(a,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===w(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(a,{...this.movementCommandContext,pointerType:w(e.originalEvent)})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(a,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t);this.editable&&a&&(this._before(e)||(_(e),await this._updatingHandles.addPromise(a.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:w(e.originalEvent)}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new V,t=(t,a)=>{e.addToggle(t,e=>this._handleCommand({action:a,originalEvent:e,enabled:"key-down"===e.type}))},a=(t,a)=>{e.add(t,e=>this._handleCommand({action:a,originalEvent:e}))};return t(E.preserveAspectRatio,"constraint-aspect"),t(U.center,"constraint-center"),a(D.toggleFollowManipulator,"toggle-manipulator-follow"),a(U.undo,"undo"),a(U.redo,"redo"),a(U.complete,"complete"),a(U.vertexAdd,"vertex-add"),a({key:L.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}async _commitNext(){const e={stack:[],error:void 0,hasError:!1};try{const a=this.mostDownstreamPlugin;if(!a)return;let i=!1;const r=this.editGeometryOperations;t(e,r?n(r.on("vertex-add",()=>i=!0)):null,!1);a.completeStep?a.completeStep():this.complete(a),i&&this.tooltipManager?.unlockOnVertexPlacement()}catch(i){e.error=i,e.hasError=!0}finally{a(e)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=u(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const a=r(this._pluginContexts,e,()=>new C({drawTool:this,plugin:e,session:t}));return a.session=t,a}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,a){return this._before(e)?a?.():t()}};e([m()],Z.prototype,"_snappingVisualizer",void 0),e([m()],Z.prototype,"_tooltipDependencies",null),e([m()],Z.prototype,"_editSessionManagerContext",null),e([m({constructOnly:!0,nonNullable:!0})],Z.prototype,"view",void 0),e([m()],Z.prototype,"automaticManipulatorSelection",void 0),e([m()],Z.prototype,"updating",null),e([m()],Z.prototype,"coordinateHelper",null),e([m()],Z.prototype,"editGeometry",null),e([m()],Z.prototype,"editGeometryOperations",null),e([m()],Z.prototype,"geometry",null),e([m()],Z.prototype,"snappingManager",void 0),e([m()],Z.prototype,"sketchOptions",void 0),e([m()],Z.prototype,"elevationInfo",void 0),e([m()],Z.prototype,"hasZ",void 0),e([m()],Z.prototype,"defaultZ",void 0),e([m()],Z.prototype,"directionOptions",void 0),e([m()],Z.prototype,"canUndo",null),e([m()],Z.prototype,"canRedo",null),e([m()],Z.prototype,"pluginStack",null),e([m()],Z.prototype,"mostDownstreamPlugin",null),e([m()],Z.prototype,"mostUpstreamPlugin",null),e([m()],Z.prototype,"lastScreenPosition",void 0),e([m()],Z.prototype,"positionOfLastUserInput",null),e([m()],Z.prototype,"tooltipManager",void 0),e([m()],Z.prototype,"measurementManager",void 0),e([m()],Z.prototype,"globalStateManager",void 0),e([m()],Z.prototype,"editSessionManager",void 0),e([m()],Z.prototype,"lifecycleManager",void 0),e([m()],Z.prototype,"surfaceManager",void 0),e([m()],Z.prototype,"interactiveHandleManager",void 0),e([m()],Z.prototype,"renderer",void 0),e([m()],Z.prototype,"movementCommandContext",null),Z=e([v("esri.views.draw.DrawTool")],Z);export{Z as DrawTool};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as a}from"tslib";import{disposable as i}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{when as s,initial as d,on as l,sync as p,watch as c}from"../../core/reactiveUtils.js";import{screenPointEqual as g,createScreenPoint as u}from"../../core/screenUtils.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as M}from"../../core/support/UpdatingHandles.js";import{createSnappingVisualizer as y}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as f,markHandled as _,getPointerType as w}from"./support/drawToolUtils.js";import{PluginContext as C}from"./support/PluginContext.js";import{viewEventToCommand as H}from"./support/input/drawToolInput.js";import{EditSessionManager as x}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as S}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as b}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as P}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as T}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as k}from"./support/managers/SurfaceManager.js";import{TooltipManager as I}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as O}from"../input/InputManager.js";import{createCoordinateHelper as j}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as A}from"../interactive/InteractiveToolBase.js";import{KeyBindings as V,mediaKeys as E,sketchKeys as U,advancedSketchKeys as D,tooltipKeys as L}from"../interactive/keybindings.js";import{isInputModeAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";const G=Symbol();let Z=class extends A{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._snappingVisualizer=null,this._updatingHandles=new M,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new P,this.globalStateManager=new S({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new x({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new T({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null}initialize(){const{view:e}=this;this.interactiveHandleManager=new b({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new I({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(s(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(y(e,t).then(e=>this._snappingVisualizer=e))},d)),this.addHandles([s(()=>this.view,e=>{this.surfaceManager?.destroy(),this.surfaceManager=new k({spatialReference:this.coordinateHelper.spatialReference,excludedGraphicsLayer:null,defaultZ:this.defaultZ,hasZ:this.hasZ,view:e,elevationInfo:this.elevationInfo,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},d),s(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),l(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},p),l(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},p),l(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),a=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:a,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:a,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:a,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=o(this.surfaceManager),this.interactiveHandleManager=o(this.interactiveHandleManager),this.tooltipManager=o(this.tooltipManager)}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:a,directionOptions:i,view:n}=this;return t&&a&&n?{defaultZ:e,directionOptions:i,editGeometryOperations:t,sketchOptions:a,view:n,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;return{coordinateHelper:e,viewingMode:"3d"===t?.type&&"global"===t.viewingMode?1:2}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating}get coordinateHelper(){return j(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get geometry(){return this.editSessionManager.outputGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){return this.lastScreenPosition?this.view.toMap(this.lastScreenPosition):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:a,snappingManager:i,interactiveHandleManager:n,_snappingVisualizer:r,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:d},view:l}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:a,interactiveHandleManager:n,snappingManager:i,snappingVisualizer:r,pointerType:"mouse",hasZ:s,defaultZ:o,view:l,drawAtFixedElevation:d}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;e&&t.complete(e),0===t.pluginStack.length&&(this.emit("complete",{geometry:this.geometry,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null))}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}replaceLeaf(e){const t=this.lifecycleManager;t.updating?n.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._guardCommand({action:"undo"},()=>this.editSessionManager.undo())}redo(){this._guardCommand({action:"redo"},()=>this.editSessionManager.redo())}executeCommand(e){return this._handleCommand(e)}addPromise(e){return this._updatingHandles.addPromise(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.addHandles([c(()=>this.geometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e}),this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?f(e):null})},d),s(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:g}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const a=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&a&&this.emit("cursor-update",{updated:a.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:a.part.index,vertexIndex:a.index,coordinates:a.pos}]})},p),this._keybindings.register(e,O.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&h(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],G)}onDeactivate(){super.onDeactivate(),this.removeHandles(G),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=H(e);t&&this._handleCommand(t)}async _handleCommand(e){if(this.lifecycleManager.updating)n.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{_(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(_(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&_(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&R(t.info)&&(await t.enterInputMode(),_(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,a=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==a?.captureMode&&"capture-when-engaged"!==a?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&_(e):_(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(_(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:w(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions())}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&_(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:w(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=w(e.originalEvent),a=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.findHandleByManipulator(a);"touch"===t&&i&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const n=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=n??r??i;o&&!i&&_(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(a,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===w(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(a,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===w(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(a,{...this.movementCommandContext,pointerType:w(e.originalEvent)})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(a,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t);this.editable&&a&&(this._before(e)||(_(e),await this._updatingHandles.addPromise(a.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:w(e.originalEvent)}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new V,t=(t,a)=>{e.addToggle(t,e=>this._handleCommand({action:a,originalEvent:e,enabled:"key-down"===e.type}))},a=(t,a)=>{e.add(t,e=>this._handleCommand({action:a,originalEvent:e}))};return t(E.preserveAspectRatio,"constraint-aspect"),t(U.center,"constraint-center"),a(D.toggleFollowManipulator,"toggle-manipulator-follow"),a(U.undo,"undo"),a(U.redo,"redo"),a(U.complete,"complete"),a(U.vertexAdd,"vertex-add"),a({key:L.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const a={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;let n=!1;const r=this.editGeometryOperations;e(a,r?i(r.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){a.error=n,a.hasError=!0}finally{t(a)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=u(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const a=r(this._pluginContexts,e,()=>new C({drawTool:this,plugin:e,session:t}));return a.session=t,a}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,a){return this._before(e)?a?.():t()}};a([m()],Z.prototype,"_snappingVisualizer",void 0),a([m()],Z.prototype,"_tooltipDependencies",null),a([m()],Z.prototype,"_editSessionManagerContext",null),a([m({constructOnly:!0,nonNullable:!0})],Z.prototype,"view",void 0),a([m()],Z.prototype,"automaticManipulatorSelection",void 0),a([m()],Z.prototype,"updating",null),a([m()],Z.prototype,"coordinateHelper",null),a([m()],Z.prototype,"editGeometry",null),a([m()],Z.prototype,"editGeometryOperations",null),a([m()],Z.prototype,"geometry",null),a([m()],Z.prototype,"snappingManager",void 0),a([m()],Z.prototype,"sketchOptions",void 0),a([m()],Z.prototype,"elevationInfo",void 0),a([m()],Z.prototype,"hasZ",void 0),a([m()],Z.prototype,"defaultZ",void 0),a([m()],Z.prototype,"directionOptions",void 0),a([m()],Z.prototype,"canUndo",null),a([m()],Z.prototype,"canRedo",null),a([m()],Z.prototype,"pluginStack",null),a([m()],Z.prototype,"mostDownstreamPlugin",null),a([m()],Z.prototype,"mostUpstreamPlugin",null),a([m()],Z.prototype,"lastScreenPosition",void 0),a([m()],Z.prototype,"positionOfLastUserInput",null),a([m()],Z.prototype,"tooltipManager",void 0),a([m()],Z.prototype,"measurementManager",void 0),a([m()],Z.prototype,"globalStateManager",void 0),a([m()],Z.prototype,"editSessionManager",void 0),a([m()],Z.prototype,"lifecycleManager",void 0),a([m()],Z.prototype,"surfaceManager",void 0),a([m()],Z.prototype,"interactiveHandleManager",void 0),a([m()],Z.prototype,"renderer",void 0),a([m()],Z.prototype,"movementCommandContext",null),a([m()],Z.prototype,"tooltip",null),a([m()],Z.prototype,"activeTooltipInfo",null),Z=a([v("esri.views.draw.DrawTool")],Z);export{Z as DrawTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{isSome as e}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import{watch as i,initial as r}from"../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../core/accessorSupport/decorators.js";import p from"../../../geometry/Point.js";import l from"../../../geometry/Polyline.js";import{isBezierCurve as c}from"../../../geometry/support/curves/curveUtils.js";import{PluginBase as h}from"./PluginBase.js";const d=Symbol("left-vertex"),u=Symbol("right-vertex"),_=Symbol("cp1"),P=Symbol("cp2"),m=Symbol("endpoint"),f=Symbol("anchor");let y=class extends h{constructor(){super(...arguments),this._controlPoint1LineId=Symbol(),this._controlPoint2LineId=Symbol(),this._mirroredCp2VisualId=Symbol(),this.enableSplineBehavior=!0,this.state="placing-anchor"}get
|
|
2
|
+
import{__decorate as t}from"tslib";import{isSome as e}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import{watch as i,initial as r}from"../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../core/accessorSupport/decorators.js";import p from"../../../geometry/Point.js";import l from"../../../geometry/Polyline.js";import{isBezierCurve as c}from"../../../geometry/support/curves/curveUtils.js";import{PluginBase as h}from"./PluginBase.js";const d=Symbol("left-vertex"),u=Symbol("right-vertex"),_=Symbol("cp1"),P=Symbol("cp2"),m=Symbol("endpoint"),f=Symbol("anchor");let y=class extends h{constructor(){super(...arguments),this._controlPoint1LineId=Symbol(),this._controlPoint2LineId=Symbol(),this._mirroredCp2VisualId=Symbol(),this.enableSplineBehavior=!0,this.state="placing-anchor"}get test(){return{computeCurve:this._computeCurve.bind(this),recomputeAndApply:this._recomputeAndApply.bind(this),cp1LineSymbol:this._controlPoint1LineId,cp2LineSymbol:this._controlPoint2LineId,controlPointId:this._mirroredCp2VisualId}}start(t,e){super.start(t,e);const o=t.session;o.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=o.getInformationAboutPoint(-1,-1)?.point;let n=e?.state;if(!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,o.appendOrReplacePoint(d,this.leftAnchor),o?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(n="placing-control-point-1",this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?n??"placing-control-point-1":"placing-anchor",this.controlPoint1=e?.controlPoint1,this.endPoint=e?.endPoint,this.controlPoint2=e?.controlPoint2,this.enableSplineBehavior&&"placing-control-point-1"===this.state&&!n){const t=o.getInformationAboutPoint(-1,-1);if(t?.curveInfo&&c(t.curveInfo)){const[e,n]=t.curveInfo.b[2],{spatialReference:i}=t.point,r=new p({x:e,y:n,spatialReference:i}),s=g(t.point,r);this.controlPoint1=s,o?.pushUndoStep(this._captureState()),this.state="placing-endpoint",o?.pushUndoStep(this._captureState())}}this.addHandles([i(()=>this._anchorCursor?.outputMapPosition,t=>{t&&(this.leftAnchor=this.ownPlacedLeftAnchor=t,this._session?.appendOrReplacePoint(d,t))}),i(()=>this._cp1Cursor?.outputMapPosition,t=>{t&&(this.controlPoint1=t,this._recomputeAndApply())}),i(()=>this._endpointCursor?.outputMapPosition,t=>{t&&(this.endPoint=t,this._recomputeAndApply())}),i(()=>this._cp2Cursor?.outputMapPosition,t=>{t&&(this.controlPoint2=t,this._recomputeAndApply())})],this._ownHandlesKey),this._applyState(this.state),this._setupRendering(t)}completeStep(){if(this._isComplete)return;const t=this._session?.peekUndoStep();if(t){const e=this._captureState();t&&t.state===e?.state&&(t.controlPoint1=e.controlPoint1,t.controlPoint2=e.controlPoint2,t.endPoint=e.endPoint,t.leftAnchor=e.leftAnchor)}else this._session?.pushUndoStep(this._captureState());try{switch(this._session.preserveSharedRedoAfterOperation=!1,this.state){case"placing-anchor":this._applyState(this.state="placing-control-point-1");break;case"placing-control-point-1":this._applyState(this.state="placing-endpoint");break;case"placing-endpoint":this._applyState(this.state="placing-control-point-2");break;case"placing-control-point-2":this._context?.requestComplete()}}finally{this._session.preserveSharedRedoAfterOperation=!0}this._session?.pushUndoStep(this._captureState())}beforeAttachPlugin(t){return{useStandaloneSession:!0}}suspend(){return this._captureState()}_applyState(t){const e=this._session;if(!e)throw new o("drawTool:invalid-state","Bezier: attempted to apply state while context invalid");switch(e.automaticRestart=!1,this.removeHandles(_),this.removeHandles(m),this.removeHandles(P),this.removeHandles(f),t){case"placing-anchor":e.automaticRestart=!0,this._setupAnchorCursor();break;case"placing-control-point-1":{const{ownPlacedLeftAnchor:t}=this;e.automaticRestart=!t,t&&e.groupGeometryChanges(),this._setupCP1Cursor();break}case"placing-endpoint":this._setupCP1Cursor(),this._setupEndpointCursor();break;case"placing-control-point-2":this._setupCP1Cursor(),this._setupEndpointCursor(),this._setupCP2Cursor()}}_setupAnchorCursor(){this._anchorCursor=this._context.createInteractiveHandle({defaultCaptureMode:"capture-always",inputMapPosition:this._context.positionOfLastUserInput,role:"primary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._anchorCursor&&(this._context?.removeInteractiveHandle(this._anchorCursor),this._anchorCursor=null)}),f)}_setupCP1Cursor(){const t="placing-control-point-1"===this.state?"capture-always":"grabbable-object";this._cp1Cursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.controlPoint1,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._cp1Cursor&&(this._context?.removeInteractiveHandle(this._cp1Cursor),this._cp1Cursor=null)}),_)}_setupEndpointCursor(){const t="placing-endpoint"===this.state?"capture-always":"grabbable-object";this._endpointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.endPoint??this.controlPoint1,role:"primary",selfSnappingEnabled:!0,snappingEnabled:!0}),this.addHandles(n(()=>{this._endpointCursor&&(this._context?.removeInteractiveHandle(this._endpointCursor),this._endpointCursor=null)}),m)}_setupCP2Cursor(){const t="placing-control-point-2"===this.state?"capture-always":"grabbable-object";this._cp2Cursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.controlPoint2??this.endPoint??this._context.positionOfLastUserInput,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._cp2Cursor&&(this._context?.removeInteractiveHandle(this._cp2Cursor),this._cp2Cursor=null)}),P)}_computeCurve(){const{leftAnchor:t,controlPoint1:e,endPoint:o,controlPoint2:n,state:i}=this;return t?"placing-control-point-1"===i&&e?C(e,e,e):"placing-endpoint"===i&&e&&o?C(o,e,o):e&&o&&n?C(o,e,n,{flipControlPoint2:!0}):null:null}_recomputeAndApply(){const t=this._computeCurve();t&&this._session?.appendOrReplaceCurve(u,t)}_setupRendering(t){t.addOrUpdateVisual(this._controlPoint1LineId,{role:"constructionLine",state:"idle"}),t.addOrUpdateVisual(this._controlPoint2LineId,{role:"constructionLine",state:"idle"}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{role:"controlPoint",state:"idle"}),this.addHandles([i(()=>[this.controlPoint1,this.controlPoint2,this.endPoint,this.leftAnchor],([e,o,n,i])=>{const{state:r}=this;if(i&&e&&"placing-control-point-1"!==r&&"placing-anchor"!==r){const o=new l({paths:[[[i.x,i.y],[e.x,e.y]]],spatialReference:i.spatialReference});t.addOrUpdateVisual(this._controlPoint1LineId,{geometry:o})}else t.addOrUpdateVisual(this._controlPoint1LineId,{geometry:null});if(o&&n&&i){const e=g(n,o),i=new l({paths:[[[o.x,o.y],[e.x,e.y]]],spatialReference:o.spatialReference});t.addOrUpdateVisual(this._controlPoint2LineId,{geometry:i}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{geometry:e})}else t.addOrUpdateVisual(this._controlPoint2LineId,{geometry:null}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{geometry:null})},r)],this._ownHandlesKey)}_captureState(){const{state:t,controlPoint1:e,controlPoint2:o,endPoint:n,leftAnchor:i,ownPlacedLeftAnchor:r}=this;return{state:t,controlPoint1:e,endPoint:n,controlPoint2:o,leftAnchor:i,ownPlacedLeftAnchor:r}}};function C(t,o,n,i){const r=[t.x,t.y,t.z,t.m].filter(e),s=i?.flipControlPoint2?g(t,n):n;return{b:[r,[o.x,o.y],[s.x,s.y]]}}function g(t,e){const{x:o,y:n,spatialReference:i}=t,{x:r,y:s}=e;return new p({x:o+(o-r),y:n+(n-s),spatialReference:i})}t([s()],y.prototype,"_anchorCursor",void 0),t([s()],y.prototype,"_cp1Cursor",void 0),t([s()],y.prototype,"_endpointCursor",void 0),t([s()],y.prototype,"_cp2Cursor",void 0),t([s()],y.prototype,"enableSplineBehavior",void 0),t([s()],y.prototype,"state",void 0),t([s()],y.prototype,"controlPoint1",void 0),t([s()],y.prototype,"controlPoint2",void 0),t([s()],y.prototype,"endPoint",void 0),t([s()],y.prototype,"leftAnchor",void 0),t([s()],y.prototype,"ownPlacedLeftAnchor",void 0),y=t([a("esri.views.draw.plugins.BezierSegmentPlugin")],y);export{y as BezierSegmentPlugin,C as createBezier,g as mirrorControlPoint};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{property as o,subclass as n}from"../../../core/accessorSupport/decorators.js";import{geometryToCoordinates as s}from"../../../geometry/support/coordsUtils.js";import{PluginBase as a}from"./PluginBase.js";const p=Symbol("left-anchor-vertex"),c=Symbol("right-vertex"),h=Symbol("anchor"),l=Symbol("endpoint"),d=Symbol("interior-point");let u=class extends a{constructor(){super(...arguments),this.arcDrawingMode="interior-first",this.state="placing-anchor"}get test(){return{state:this.state,captureState:()=>this._captureState()}}start(t,e){super.start(t,e);const i=t.session;i.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=i.getInformationAboutPoint(-1,-1)?.point;let o=e?.state;!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,i.appendOrReplacePoint(p,this.leftAnchor),i?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(o=this._getNextState("placing-anchor"),this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?o??this._getNextState("placing-anchor"):"placing-anchor",this.interiorPoint=e?.interiorPoint,this.endpoint=e?.endpoint,this.addHandles([r(()=>this._anchorCursor?.outputMapPosition,t=>{t&&(this.leftAnchor=this.ownPlacedLeftAnchor=t,this._session?.appendOrReplacePoint(p,t))}),r(()=>this._interiorPointCursor?.outputMapPosition,t=>{t&&(this.interiorPoint=t,this._recomputeAndApply())}),r(()=>this._endpointCursor?.outputMapPosition,t=>{t&&(this.endpoint=t,this._recomputeAndApply())})],this._ownHandlesKey),this._applyState(this.state)}async completeStep(){if(this._isComplete)return;const t=this._session?.peekUndoStep();if(t){const e=this._captureState();t&&t.state===e.state&&(t.leftAnchor=e.leftAnchor,t.interiorPoint=e.interiorPoint,t.endpoint=e.endpoint)}else this._session?.pushUndoStep(this._captureState());"placing-anchor"===this.state&&this.ownPlacedLeftAnchor&&this._session?.groupGeometryChanges();try{this._session.preserveSharedRedoAfterOperation=!1;const t=this._getNextState(this.state);null===t?this._context?.requestComplete():this._applyState(this.state=t)}finally{this._session.preserveSharedRedoAfterOperation=!0}this._session?.pushUndoStep(this._captureState())}beforeAttachPlugin(t){return{useStandaloneSession:!0}}suspend(){return this._captureState()}_applyState(t){const i=this._session;if(!i)throw new e("drawTool:invalid-state","Circular Arc: attempted to apply state while context invalid");this.removeHandles(h),this.removeHandles(l),this.removeHandles(d),i.automaticRestart=this._computeAutomaticRestart(),"placing-anchor"!==t?("placing-interior"!==t&&"interior-first"!==this.arcDrawingMode||this._setupInteriorPointCursor(),"placing-endpoint"!==t&&"end-first"!==this.arcDrawingMode||this._setupEndpointCursor()):this._setupAnchorCursor()}_setupAnchorCursor(){this._anchorCursor=this._context.createInteractiveHandle({defaultCaptureMode:"capture-always",inputMapPosition:this._context.positionOfLastUserInput,role:"primary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(i(()=>{this._anchorCursor&&(this._context?.removeInteractiveHandle(this._anchorCursor),this._anchorCursor=null)}),h)}_setupInteriorPointCursor(){const t="placing-interior"===this.state?"capture-always":"grabbable-object";this._interiorPointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.interiorPoint??this.endpoint,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(i(()=>{this._interiorPointCursor&&(this._context?.removeInteractiveHandle(this._interiorPointCursor),this._interiorPointCursor=null)}),d)}_setupEndpointCursor(){const t="placing-endpoint"===this.state?"capture-always":"grabbable-object";this._endpointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.endpoint??this.interiorPoint,role:"primary",selfSnappingEnabled:!0,snappingEnabled:!0}),this.addHandles(i(()=>{this._endpointCursor&&(this._context?.removeInteractiveHandle(this._endpointCursor),this._endpointCursor=null)}),l)}_captureState(){const{state:t,endpoint:e,interiorPoint:i,leftAnchor:r,ownPlacedLeftAnchor:o}=this;return{state:t,endpoint:e,interiorPoint:i,leftAnchor:r,ownPlacedLeftAnchor:o}}_computeAutomaticRestart(){return"placing-anchor"===this.state||("placing-interior"===this.state?"interior-first"===this.arcDrawingMode&&!this.ownPlacedLeftAnchor:"end-first"===this.arcDrawingMode&&!this.ownPlacedLeftAnchor)}_makeCurve(){const{interiorPoint:t,endpoint:e}=this;if(!t&&!e)return null;const i=e??t,r=s(t??e);return{c:[s(i),_(r)]}}_recomputeAndApply(){const t=this._makeCurve();t&&this._session?.appendOrReplaceCurve(c,t)}_getNextState(t){switch(t){case"placing-anchor":return"interior-first"===this.arcDrawingMode?"placing-interior":"placing-endpoint";case"placing-interior":return"interior-first"===this.arcDrawingMode?"placing-endpoint":null;case"placing-endpoint":return"end-first"===this.arcDrawingMode?"placing-interior":null}}};function _(t){return 2===t.length?t:[t[0]??0,t[1]??0]}t([o()],u.prototype,"_anchorCursor",void 0),t([o()],u.prototype,"_endpointCursor",void 0),t([o()],u.prototype,"_interiorPointCursor",void 0),t([o()],u.prototype,"arcDrawingMode",void 0),t([o()],u.prototype,"interiorPoint",void 0),t([o()],u.prototype,"endpoint",void 0),t([o()],u.prototype,"leftAnchor",void 0),t([o()],u.prototype,"ownPlacedLeftAnchor",void 0),t([o()],u.prototype,"state",void 0),u=t([n("esri.views.draw.plugins.CircularArcSegmentPlugin")],u);export{u as CircularArcSegmentPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as r}from"tslib";import o from"../../../core/Collection.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{disposable as s}from"../../../core/handleUtils.js";import n from"../../../core/ReactiveSet.js";import{deleteMany as a,addMany as p}from"../../../core/SetUtils.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{isCoordinate as h}from"../../../geometry/support/curves/curveUtils.js";import{UndoGroup as l}from"../../interactive/editGeometry/operations/UndoGroup.js";let y=class extends i{constructor(e){super(e),this._vertexRegistry=new Map,this._partRegistry=new Map,this._reverseVertexRegistry=new WeakMap,this._reversePartRegistry=new WeakMap,this.plugin=null,this.stepUndoStack=new o,this.stepRedoStack=new o,this.startingVertex=null,this.endVertex=null,this.vertices=new Set,this.operations=new n,this.undoneOperations=new Set,this.automaticRestart=!0,this.preserveSharedRedoAfterOperation=!1}get firstPointAddedBySession(){const{startingVertex:e}=this;return e?this._toVertexInfo(e):null}get lastPointAddedBySession(){const{endVertex:e}=this;return e?this._toVertexInfo(e):null}pushUndoStep(e){this.editGeometryOperations.resetRedoStack(),this.stepUndoStack.push(e??{}),this.stepRedoStack.length=0}peekUndoStep(){return this.stepUndoStack.at(-1)}restoreState(e){if(!e)return;const{undoSteps:t,redoSteps:r,automaticRestart:o}=e;void 0!==o&&(this.automaticRestart=o),t&&this.stepUndoStack.addMany(t),r&&this.stepRedoStack.addMany(r)}getInformationAboutPoint(e,t){const{parts:r,allVertices:o,coordinateHelper:i}=this.editGeometryOperations.data;if(!r.length||!o.length)return null;const s=r.at(t??-1),n=s?.vertices.at(e);if(!n)return null;const a=n.leftSegment?.toCurveOrCoordinate(),p=a&&!h(a)?a:void 0;return{point:i.vectorToPoint(n.pos),curveInfo:p,partIndex:n.part.index,pointIndex:n.index}}appendOrReplacePoint(e,t,r){const o=this.editGeometryOperations.data.coordinateHelper.pointToVector(t);this.appendOrReplaceCurve(e,o,r)}appendOrReplaceCurve(e,t,r){const o=e?this._vertexRegistry.get(e):null;if(o&&!r?.forceAppend)return this._applyInternal(()=>this.editGeometryOperations.setVertexPosition(o,t)),void this.notifyChange("endVertex");const i=this._applyInternal(()=>this.editGeometryOperations.appendVertex(t,this.editGeometryOperations.data.parts.at(-1),"polygon"===this.editGeometryOperations.data.type));if(!i)return;this.notifyChange("endVertex");const s=i.addedVertices.at(-1);s&&e&&(this._vertexRegistry.set(e,s),this._reverseVertexRegistry.set(s,e))}appendOrReplacePart(e,t,r){const o=e?this._partRegistry.get(e):null,i=o&&this.editGeometryOperations.data.parts.includes(o)?o:null,s=this._applyInternal(()=>this.editGeometryOperations.addOrUpdatePart(t,r?.forceAppend?null:i));if(!s)return;this.notifyChange("endVertex"),this.notifyChange("startingVertex");const n=s.addedVertices.at(-1)?.part;n&&e&&(this._partRegistry.set(e,n),this._reversePartRegistry.set(n,e))}groupGeometryChanges(e){const{operations:t}=this;try{this.editGeometryOperations.disableDefaultRedoBehavior=this.preserveSharedRedoAfterOperation;const r=this.editGeometryOperations.groupOperations(r=>t.has(r)&&(e||!(r instanceof l)));if(r){const{group:e,operations:o}=r;a(t,o),t.add(e)}}finally{this.editGeometryOperations.disableDefaultRedoBehavior=!1}}generatePreviewGeometry(e){const{endVertex:t,startingVertex:r,editGeometryOperations:o}=this,i=e.includeAutomaticConnection?r?.leftSegment?.leftVertex??r:r,s=this._resolveVertex(e?.firstIncludedPoint,i),n=this._resolveVertex(e?.lastIncludedPoint,t);return s||n?o?.data?.getPartialGeometry(s,n,e.geometryType):null}complete(){this.emit("completed",{})}sessionIsOperatingOnSameGeometry(e){return this.editGeometryOperations===e?.editGeometryOperations}eraseLastOperation(){const e=this.editGeometryOperations.lastOperation;if(!e||!this.operations.has(e))return;this._applyInternal(()=>this.editGeometryOperations.undo(),"undo")&&(this.notifyChange("endVertex"),this.notifyChange("startingVertex"))}syncVertices(e){const{vertices:t}=this,r=[];if(e)for(const s of e){const{addedVertices:e,removedVertices:o,addedParts:i,removedParts:n}=s;if(o){a(t,o);for(const e of o){const t=this._reverseVertexRegistry.get(e);t&&this._vertexRegistry.delete(t)}}if(e){p(t,e),r.push(...e);for(const t of e){const e=this._reverseVertexRegistry.get(t);e&&this._vertexRegistry.set(e,t)}}if(i)for(const t of i){const e=this._reversePartRegistry.get(t);e&&this._partRegistry.set(e,t)}if(n)for(const t of n){const e=this._reversePartRegistry.get(t);e&&this._partRegistry.delete(e)}}let o=null,i=null;for(const s of t)(!o||s.part.index<o.part.index||s.part.index===o.part.index&&s.index<=o.index)&&(o=s),(!i||s.part.index>i.part.index||s.part.index===i.part.index&&s.index>i.index)&&(i=s);return this.startingVertex=o,this.endVertex=i,r}mergeSession(e){this?.sessionIsOperatingOnSameGeometry(e)&&(p(this.vertices,e.vertices),p(this.operations,e.operations),p(this.undoneOperations,e.undoneOperations),this.syncVertices())}_applyInternal(e,t="apply"){let r=null;const o={session:this,blockApply:void 0};if(this.emit("before-apply-operation",o),o.blockApply)return null;const{editGeometryOperations:i}=this,s=u(i,()=>{try{i.disableDefaultRedoBehavior=this.automaticRestart||this.preserveSharedRedoAfterOperation||"undo"===t,r=e()}finally{i.disableDefaultRedoBehavior=!1}});r&&i.undoHas(r)&&"apply"===t&&this.operations.add(r);const n=this.syncVertices(s);return{operation:r,addedVertices:n}}_toVertexInfo(e){const t=e.leftSegment?.toCurveOrCoordinate(),r=!t||h(t)?void 0:t,o=e.part.index,i=e.index;return{point:this.editGeometryOperations.data.coordinateHelper.vectorToPoint(e.pos),curveInfo:r,partIndex:o,pointIndex:i}}_resolveVertex(e,t){return void 0!==e?.partIndex&&void 0!==e.pointIndex?this.editGeometryOperations.data.parts.at(e.partIndex)?.vertices.at(e.pointIndex)??null:t}};function u(r,o){const i={stack:[],error:void 0,hasError:!1};try{const t=[];e(i,s(r.data.on("change",e=>t.push(e))),!1);return o(),t}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}r([d()],y.prototype,"plugin",void 0),r([d()],y.prototype,"stepUndoStack",void 0),r([d()],y.prototype,"stepRedoStack",void 0),r([d()],y.prototype,"startingVertex",void 0),r([d()],y.prototype,"endVertex",void 0),r([d({constructOnly:!0})],y.prototype,"editGeometryOperations",void 0),r([d()],y.prototype,"vertices",void 0),r([d()],y.prototype,"operations",void 0),r([d()],y.prototype,"undoneOperations",void 0),r([d()],y.prototype,"firstPointAddedBySession",null),r([d()],y.prototype,"lastPointAddedBySession",null),r([d()],y.prototype,"automaticRestart",void 0),r([d()],y.prototype,"preserveSharedRedoAfterOperation",void 0),y=r([c("esri.views.draw.support.EditSession")],y);export{y as EditSession,u as captureGeometryChangeEvents};
|