@arcgis/core 4.32.0-next.20241219 → 4.32.0-next.20241220

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.
Files changed (123) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0da2aaca3f0b4fe910e3.js → 015285436ca965f94e17.js} +1 -1
  3. package/assets/esri/core/workers/chunks/2c084c0c324e3af56424.js +1 -0
  4. package/assets/esri/core/workers/chunks/5a0eb9dfe668cf290462.js +1 -0
  5. package/assets/esri/core/workers/chunks/69efc716991a407c3d23.js +1 -0
  6. package/assets/esri/core/workers/chunks/{fb43c44a7d6b61f31e75.js → 94432e04de01ee7adc0e.js} +1 -1
  7. package/assets/esri/core/workers/chunks/95af4dee29eb196b8ada.js +1 -0
  8. package/assets/esri/core/workers/chunks/{80ac74da0b0e45e74beb.js → 9a498f2c007f4d78d4dd.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{eddab4dc706e75c6637f.js → bff74200a0df0950cf08.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{8f2ffb6944c9028d3bea.js → c08cb75c3eef6c45f604.js} +1 -1
  11. package/assets/esri/core/workers/chunks/dce55e7f76adecc055c3.js +1 -0
  12. package/assets/esri/core/workers/chunks/f2cdb7be3fd65f65c30b.js +1 -0
  13. package/assets/esri/themes/base/widgets/_FeatureTable.scss +3 -3
  14. package/assets/esri/themes/dark/main.css +1 -1
  15. package/assets/esri/themes/light/main.css +1 -1
  16. package/assets/esri/themes/light/view.css +1 -1
  17. package/chunks/OperatorProject.js +1 -1
  18. package/chunks/QuadraticBezier.js +1 -1
  19. package/geometry/operators/affineTransformOperator.js +1 -1
  20. package/geometry/operators/alphaShapeOperator.js +1 -1
  21. package/geometry/operators/areaOperator.js +1 -1
  22. package/geometry/operators/autoCompleteOperator.js +1 -1
  23. package/geometry/operators/boundaryOperator.js +1 -1
  24. package/geometry/operators/bufferOperator.js +1 -1
  25. package/geometry/operators/centroidOperator.js +1 -1
  26. package/geometry/operators/clipOperator.js +1 -1
  27. package/geometry/operators/containsOperator.js +1 -1
  28. package/geometry/operators/convexHullOperator.js +1 -1
  29. package/geometry/operators/crossesOperator.js +1 -1
  30. package/geometry/operators/cutOperator.js +1 -1
  31. package/geometry/operators/densifyOperator.js +1 -1
  32. package/geometry/operators/differenceOperator.js +1 -1
  33. package/geometry/operators/disjointOperator.js +1 -1
  34. package/geometry/operators/distanceOperator.js +1 -1
  35. package/geometry/operators/equalsOperator.js +1 -1
  36. package/geometry/operators/extendOperator.js +1 -1
  37. package/geometry/operators/generalizeOperator.js +1 -1
  38. package/geometry/operators/geodesicBufferOperator.js +1 -1
  39. package/geometry/operators/geodesicProximityOperator.js +1 -1
  40. package/geometry/operators/geodeticAreaOperator.js +1 -1
  41. package/geometry/operators/geodeticDensifyOperator.js +1 -1
  42. package/geometry/operators/geodeticDistanceOperator.js +1 -1
  43. package/geometry/operators/geodeticLengthOperator.js +1 -1
  44. package/geometry/operators/graphicBufferOperator.js +1 -1
  45. package/geometry/operators/integrateOperator.js +1 -1
  46. package/geometry/operators/intersectionOperator.js +1 -1
  47. package/geometry/operators/intersectsOperator.js +1 -1
  48. package/geometry/operators/isNearOperator.js +1 -1
  49. package/geometry/operators/labelPointOperator.js +1 -1
  50. package/geometry/operators/lengthOperator.js +1 -1
  51. package/geometry/operators/linesToPolygonsOperator.js +1 -1
  52. package/geometry/operators/locateBetweenOperator.js +1 -1
  53. package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
  54. package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
  55. package/geometry/operators/offsetOperator.js +1 -1
  56. package/geometry/operators/overlapsOperator.js +1 -1
  57. package/geometry/operators/polygonOverlayOperator.js +1 -1
  58. package/geometry/operators/polygonSlicerOperator.js +1 -1
  59. package/geometry/operators/projectOperator.js +1 -1
  60. package/geometry/operators/proximityOperator.js +1 -1
  61. package/geometry/operators/relateOperator.js +1 -1
  62. package/geometry/operators/reshapeOperator.js +1 -1
  63. package/geometry/operators/simplifyOperator.js +1 -1
  64. package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
  65. package/geometry/operators/symmetricDifferenceOperator.js +1 -1
  66. package/geometry/operators/touchesOperator.js +1 -1
  67. package/geometry/operators/unionOperator.js +1 -1
  68. package/geometry/operators/withinOperator.js +1 -1
  69. package/interfaces.d.ts +53 -4
  70. package/layers/graphics/OptimizedFeature.js +1 -1
  71. package/layers/graphics/sources/geojson/geojson.js +1 -1
  72. package/layers/support/Sublayer.js +1 -1
  73. package/layers/support/domainUtils.js +1 -1
  74. package/layers/support/fieldUtils.js +1 -1
  75. package/package.json +1 -1
  76. package/rest/query/operations/pbfOptimizedFeatureSet.js +1 -1
  77. package/support/revision.js +1 -1
  78. package/views/2d/engine/webgl/mesh/factories/ResourceProxy.js +1 -1
  79. package/views/2d/input/MapViewInputManager.js +1 -1
  80. package/views/2d/input/handlers/KeyRotate.js +1 -1
  81. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  82. package/views/2d/layers/features/FeatureContainer.js +1 -1
  83. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  84. package/views/2d/layers/features/Processor.js +1 -1
  85. package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
  86. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  87. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  88. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  89. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  90. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  91. package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
  92. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +5 -0
  93. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  94. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  95. package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
  96. package/views/2d/layers/support/DebouncedFeatureOverride.js +5 -0
  97. package/views/2d/layers/support/FeatureCommandQueue.js +1 -1
  98. package/views/3d/input/SceneInputManager.js +1 -1
  99. package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
  100. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  101. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  102. package/views/layers/FeatureLayerView.js +1 -1
  103. package/widgets/FeatureTable/FieldColumn.js +1 -1
  104. package/widgets/Features/FeaturesViewModel.js +1 -1
  105. package/widgets/Features.js +1 -1
  106. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  107. package/widgets/OrientedImageryViewer/adapters/sketch/DigitizationAdapter.js +1 -1
  108. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  109. package/widgets/OrientedImageryViewer/digitizationUtils.js +1 -1
  110. package/widgets/OrientedImageryViewer.js +1 -1
  111. package/widgets/Popup.js +1 -1
  112. package/widgets/ShadowCast.js +1 -1
  113. package/widgets/support/forms/formUtils.js +1 -1
  114. package/assets/esri/core/workers/chunks/3ef5002b21b1a5b97e11.js +0 -1
  115. package/assets/esri/core/workers/chunks/5786b190ad3e2d933245.js +0 -1
  116. package/assets/esri/core/workers/chunks/84d26c6c805f5855ffd3.js +0 -1
  117. package/assets/esri/core/workers/chunks/8f2f2d497b875e2b4139.js +0 -1
  118. package/assets/esri/core/workers/chunks/a4c8b773283ea8f0e256.js +0 -1
  119. package/assets/esri/core/workers/chunks/fce1158755f959730602.js +0 -1
  120. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +0 -5
  121. package/views/3d/input/handlers/SingleKey.js +0 -5
  122. package/views/3d/input/handlers/SingleKeyResetHeading.js +0 -5
  123. package/views/3d/input/handlers/SingleKeyResetTilt.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{getMetersPerVerticalUnitForSR as e}from"../../../core/unitUtils.js";import{equals as t}from"../../../geometry/support/spatialReferenceUtils.js";import{hasGeometry as r,OptimizedFeature as o}from"../../../layers/graphics/OptimizedFeature.js";import i from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";const n=["esriGeometryPoint","esriGeometryMultipoint","esriGeometryPolyline","esriGeometryPolygon"];class a{constructor(e){this._options=e,this.geometryTypes=n,this._coordinatePtr=0,this._vertexDimension=0}createFeatureResult(){return new i}prepareFeatures(e){this._vertexDimension=2,e.hasZ&&this._vertexDimension++,e.hasM&&this._vertexDimension++}finishFeatureResult(o){if(!o?.features||!o.hasZ||!this._options.sourceSpatialReference||!o.spatialReference||t(o.spatialReference,this._options.sourceSpatialReference)||o.spatialReference.vcsWkid)return;const i=e(this._options.sourceSpatialReference)/e(o.spatialReference);if(1!==i)for(const e of o.features){if(!r(e))continue;const t=e.geometry.coords;for(let e=2;e<t.length;e+=3)t[e]*=i}}addFeature(e,t){e.features.push(t)}createFeature(){return new o}createSpatialReference(){return{wkid:0}}createGeometry(){return new s}addField(e,t){e.fields.push(t)}allocateCoordinates(e){e.coords.length=e.lengths.reduce(((e,t)=>e+t),0)*this._vertexDimension,this._coordinatePtr=0}addCoordinate(e,t){e.coords[this._coordinatePtr++]=t}addCoordinatePoint(e,t){e.coords.push(t)}addLength(e,t){e.lengths.push(t)}addQueryGeometry(e,t){e.queryGeometry=t.queryGeometry,e.queryGeometryType=t.queryGeometryType}createPointGeometry(){return new s}}export{a as OptimizedFeatureSetParserContext,n as optimizedGeometryTypes};
5
+ import{getMetersPerVerticalUnitForSR as e}from"../../../core/unitUtils.js";import{equals as t}from"../../../geometry/support/spatialReferenceUtils.js";import{hasGeometry as r,OptimizedFeature as o}from"../../../layers/graphics/OptimizedFeature.js";import i from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";const n=["esriGeometryPoint","esriGeometryMultipoint","esriGeometryPolyline","esriGeometryPolygon"];class a{constructor(e){this._options=e,this.geometryTypes=n,this._coordinatePtr=0,this._vertexDimension=0}createFeatureResult(){return new i}prepareFeatures(e){this._vertexDimension=2,e.hasZ&&this._vertexDimension++,e.hasM&&this._vertexDimension++}finishFeatureResult(o){if(!o?.features||!o.hasZ||!this._options.sourceSpatialReference||!o.spatialReference||t(o.spatialReference,this._options.sourceSpatialReference)||o.spatialReference.vcsWkid)return;const i=e(this._options.sourceSpatialReference)/e(o.spatialReference);if(1!==i)for(const e of o.features){if(!r(e))continue;const t=e.geometry.coords;for(let e=2;e<t.length;e+=3)t[e]*=i}}addFeature(e,t){e.features.push(t)}createFeature(){return new o(null,{},null,0)}createSpatialReference(){return{wkid:0}}createGeometry(){return new s}addField(e,t){e.fields.push(t)}allocateCoordinates(e){e.coords.length=e.lengths.reduce(((e,t)=>e+t),0)*this._vertexDimension,this._coordinatePtr=0}addCoordinate(e,t){e.coords[this._coordinatePtr++]=t}addCoordinatePoint(e,t){e.coords.push(t)}addLength(e,t){e.lengths.push(t)}addQueryGeometry(e,t){e.queryGeometry=t.queryGeometry,e.queryGeometryType=t.queryGeometryType}createPointGeometry(){return new s}}export{a as OptimizedFeatureSetParserContext,n as optimizedGeometryTypes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const f="20241219",b="24cf0bafb4d9dfff669fcb3f0fc80d458b7b15a4";export{f as buildDate,b as commitHash};
5
+ const c="20241220",b="71bcf4dd5c83009937c33220ba9765f643881234";export{c as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{numericHash as e}from"../../../../../../core/string.js";import{discardUrlIfHasUrlHash as t}from"../../Utils.js";import{AResourceProxy as r}from"../../shaderGraph/techniques/mesh/AResourceProxy.js";class s extends r{constructor(e){super(),this._fetcher=e,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destroy(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(r){const s=t(r.resource),o=e(JSON.stringify(s));return this._pendingIds.has(o)||(this._pendingIds.add(o),this._pendingRequests.push({...r,resourceId:o})),o}async fetchEnqueuedResources(){const e=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const t=await this._fetcher.fetch(e,this._abortOptions);for(let r=0;r<t.length;r++){const s=e[r].resourceId;this._resourceIdToResource.set(s,t[r])}}async fetchResourceImmediate(e){const t=await this._fetcher.fetch([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return t[0]}async fetchDictionaryResourceImmediate(e){const t=await this._fetcher.fetchDictionary([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return t[0]}getResource(e){return this._resourceIdToResource.get(e)}}export{s as ResourceProxy};
5
+ import{numericHash as e}from"../../../../../../core/string.js";import{discardUrlIfHasUrlHash as t}from"../../Utils.js";import{AResourceProxy as r}from"../../shaderGraph/techniques/mesh/AResourceProxy.js";class s extends r{constructor(e){super(),this._fetcher=e,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destroy(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(r){const s=t(r.resource),o=e(JSON.stringify(s));return this._pendingIds.has(o)||(this._pendingIds.add(o),this._pendingRequests.push({...r,resourceId:o})),o}async fetchEnqueuedResources(){const e=this._pendingRequests;if(this._pendingIds.clear(),this._pendingRequests=[],0===e.length)return;const t=await this._fetcher.fetch(e,this._abortOptions);for(let r=0;r<t.length;r++){const s=e[r].resourceId;this._resourceIdToResource.set(s,t[r])}}async fetchResourceImmediate(e){const t=await this._fetcher.fetch([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return t[0]}async fetchDictionaryResourceImmediate(e){const t=await this._fetcher.fetchDictionary([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return t[0]}getResource(e){return this._resourceIdToResource.get(e)}}export{s as ResourceProxy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as i,watch as r,initial as n}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{DoubleClickZoom as c}from"./handlers/DoubleClickZoom.js";import{DoubleTapDragZoom as p}from"./handlers/DoubleTapDragZoom.js";import{DragPan as m}from"./handlers/DragPan.js";import{DragRotate as l}from"./handlers/DragRotate.js";import{GamepadNavigation as u}from"./handlers/GamepadNavigation.js";import{KeyPan as w}from"./handlers/KeyPan.js";import{KeyRotate as h}from"./handlers/KeyRotate.js";import{KeyZoom as d}from"./handlers/KeyZoom.js";import{MouseWheelZoom as v}from"./handlers/MouseWheelZoom.js";import{PinchRotateAndZoom as g}from"./handlers/PinchAction.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as j,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{DoubleTapDrag as D}from"../../input/recognizers/DoubleTapDrag.js";import{Drag as A}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as M}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as P}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as b}from"../../input/recognizers/SingleAndDoubleClick.js";const T={counter:"Control",pan:{left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown"},zoom:{zoomIn:["=","+"],zoomOut:["-","_"]},rotate:{clockwiseOption1:"a",clockwiseOption2:"A",counterClockwiseOption1:"d",counterClockwiseOption2:"D",resetOption1:"n",resetOption2:"N"}};let z=class extends t{initialize(){const e=()=>this.view?.ready;this.addHandles([i((()=>!e()),(()=>this._disconnect())),i(e,(()=>this._connect()))])}destroy(){this._disconnect()}get latestPointerType(){return this._inputManager?.latestPointerType}get latestPointerLocation(){return this._inputManager?.latestPointerLocation}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}isModifierKeyDown(e){return this._inputManager?.isModifierKeyDown(e)??!1}_disconnect(){this.view.viewEvents.disconnect(),this._inputManager=o(this._inputManager)}_connect(){const e=this.view.surface,t=new f(e,this.view.input),o=[new M,new P,new b,new A(this.view.navigation),new D],i=new j({eventSource:t,recognizers:o});i.installHandlers("prevent-context-menu",[new _],y.INTERNAL),i.installHandlers("navigation",[new g(this.view),new u(this.view),new v(this.view),new c(this.view),new c(this.view,[T.counter]),new m(this.view,"primary"),new w(this.view,T.pan),new d(this.view,T.zoom),new h(this.view,T.rotate),new l(this.view,"secondary"),new p(this.view,"touch")],y.INTERNAL),this.view.viewEvents.connect(i),this._source=t,this._inputManager=i,r((()=>this.view?.navigation?.browserTouchPanEnabled),(e=>{this._source&&(this._source.browserTouchPanningEnabled=!e)}),n)}get test(){}};e([s()],z.prototype,"view",void 0),e([s()],z.prototype,"latestPointerType",null),e([s()],z.prototype,"latestPointerLocation",null),e([s()],z.prototype,"multiTouchActive",null),z=e([a("esri.views.2d.input.MapViewInputManager")],z);const k=z;export{k as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as r,watch as i,initial as n}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{DoubleClickZoom as c}from"./handlers/DoubleClickZoom.js";import{DoubleTapDragZoom as p}from"./handlers/DoubleTapDragZoom.js";import{DragPan as m}from"./handlers/DragPan.js";import{DragRotate as u}from"./handlers/DragRotate.js";import{GamepadNavigation as l}from"./handlers/GamepadNavigation.js";import{KeyPan as h}from"./handlers/KeyPan.js";import{KeyRotate as w}from"./handlers/KeyRotate.js";import{KeyZoom as d}from"./handlers/KeyZoom.js";import{MouseWheelZoom as v}from"./handlers/MouseWheelZoom.js";import{PinchRotateAndZoom as g}from"./handlers/PinchAction.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as j,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{DoubleTapDrag as D}from"../../input/recognizers/DoubleTapDrag.js";import{Drag as A}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as M}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as P}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as b}from"../../input/recognizers/SingleAndDoubleClick.js";const T={counter:"Control",pan:{left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown"},zoom:{zoomIn:["=","+"],zoomOut:["-","_"]},rotate:{clockwise:["a","A"],counterClockwise:["d","D"],reset:["n","N"]}};let z=class extends t{initialize(){const e=()=>this.view?.ready;this.addHandles([r((()=>!e()),(()=>this._disconnect())),r(e,(()=>this._connect()))])}destroy(){this._disconnect()}get latestPointerType(){return this._inputManager?.latestPointerType}get latestPointerLocation(){return this._inputManager?.latestPointerLocation}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}isModifierKeyDown(e){return this._inputManager?.isModifierKeyDown(e)??!1}_disconnect(){this.view.viewEvents.disconnect(),this._inputManager=o(this._inputManager)}_connect(){const e=this.view.surface,t=new f(e,this.view.input),o=[new M,new P,new b,new A(this.view.navigation),new D],r=new j({eventSource:t,recognizers:o});r.installHandlers("prevent-context-menu",[new _],y.INTERNAL),r.installHandlers("navigation",[new g(this.view),new l(this.view),new v(this.view),new c(this.view),new c(this.view,[T.counter]),new m(this.view,"primary"),new h(this.view,T.pan),new d(this.view,T.zoom),new w(this.view,T.rotate),new u(this.view,"secondary"),new p(this.view,"touch")],y.INTERNAL),this.view.viewEvents.connect(r),this._source=t,this._inputManager=r,i((()=>this.view?.navigation?.browserTouchPanEnabled),(e=>{this._source&&(this._source.browserTouchPanningEnabled=!e)}),n)}get test(){}};e([s()],z.prototype,"view",void 0),e([s()],z.prototype,"latestPointerType",null),e([s()],z.prototype,"latestPointerLocation",null),e([s()],z.prototype,"multiTouchActive",null),z=e([a("esri.views.2d.input.MapViewInputManager")],z);const C=z;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{InputHandler as e}from"../../../input/InputHandler.js";import{onVisibilityChange as i}from"../../../input/VisibilityChange.js";class t extends e{constructor(e,t,s){super(!0),this.view=e,this.keys=t,this._pressed=!1,this._keyToDirection={[t.clockwiseOption1]:"clockwise",[t.clockwiseOption2]:"clockwise",[t.counterClockwiseOption1]:"counterClockwise",[t.counterClockwiseOption2]:"counterClockwise",[t.resetOption1]:"reset",[t.resetOption2]:"reset"},this.registerIncoming("key-down",s,(e=>this._handleKeyDown(e))),this.registerIncoming("key-up",s,(e=>this._handleKeyUp(e))),this.registerIncoming("blur",s,(()=>this._handleStop())),this._visibilityHandle=i((e=>e?null:this._handleStop()))}onUninstall(){this._visibilityHandle?.remove(),this._handleStop()}_handleKeyDown(e){e.data.repeat||this._handleKey(e,!0)}_handleKeyUp(e){this._handleKey(e,!1)}_handleStop(){this._pressed&&(this._pressed=!1,this.view.mapViewNavigation.stop())}_handleKey(e,i){const t=e.modifiers;if(t.size>0&&!t.has("Shift")||!this.view.constraints.rotationEnabled)return;const s=this._keyToDirection[e.data.key];if(this._pressed=null!=s,this._pressed){if(e.preventDefault(),i)switch(this.view.mapViewNavigation.begin(),s){case"clockwise":this.view.mapViewNavigation.continuousRotateClockwise();break;case"counterClockwise":this.view.mapViewNavigation.continuousRotateCounterclockwise();break;case"reset":this.view.mapViewNavigation.resetRotation()}else this._pressed=!1,this.view.mapViewNavigation.stop();e.stopPropagation()}}}export{t as KeyRotate};
5
+ import{InputHandler as e}from"../../../input/InputHandler.js";import{onVisibilityChange as i}from"../../../input/VisibilityChange.js";class t extends e{constructor(e,t,s){super(!0),this.view=e,this.keys=t,this._keyToDirection=new Map,this._pressed=!1,this._addKeysMapping(t),this.registerIncoming("key-down",s,(e=>this._handleKeyDown(e))),this.registerIncoming("key-up",s,(e=>this._handleKeyUp(e))),this.registerIncoming("blur",s,(()=>this._handleStop())),this._visibilityHandle=i((e=>e?null:this._handleStop()))}onUninstall(){this._visibilityHandle?.remove(),this._handleStop()}_addKeysMapping(e){this._addKeyMapping(e.clockwise,"clockwise"),this._addKeyMapping(e.counterClockwise,"counterClockwise"),this._addKeyMapping(e.reset,"reset")}_addKeyMapping(e,i){for(const t of e)this._keyToDirection.set(t,i)}_handleKeyDown(e){e.data.repeat||this._handleKey(e,!0)}_handleKeyUp(e){this._handleKey(e,!1)}_handleStop(){this._pressed&&(this._pressed=!1,this.view.mapViewNavigation.stop())}_handleKey(e,i){const t=e.modifiers;if(t.size>0&&!t.has("Shift")||!this.view.constraints.rotationEnabled)return;const s=this._keyToDirection.get(e.data.key);if(this._pressed=null!=s,this._pressed){if(e.preventDefault(),i)switch(this.view.mapViewNavigation.begin(),s){case"clockwise":this.view.mapViewNavigation.continuousRotateClockwise();break;case"counterClockwise":this.view.mapViewNavigation.continuousRotateCounterclockwise();break;case"reset":this.view.mapViewNavigation.resetRotation()}else this._pressed=!1,this.view.mapViewNavigation.stop();e.stopPropagation()}}}export{t as KeyRotate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{notDeepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as b}from"../../../layers/graphics/featureConversionUtils.js";import A from"../../../layers/support/FeatureFilter.js";import{checkCurrentUserSupport as F}from"../../../layers/support/featureLayerUtils.js";import{packFields as S}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as E}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as x}from"../../../layers/support/timeSupport.js";import j from"../../../rest/support/AggregateFeatureSet.js";import C from"../../../rest/support/FeatureSet.js";import V from"../../../rest/support/Query.js";import{LayerView2DMixin as U}from"./LayerView2D.js";import{FeatureContainer as k}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as q}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as R}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as Q}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as I}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as O}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as L}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as T}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{ParquetLayerAdapter as H}from"./features/layerAdapters/ParquetLayerAdapter.js";import{StreamLayerAdapter as W}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as M}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as D}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import N from"./support/FeatureCommandQueue.js";import{handleNoEngineError as J}from"./support/handleNoEngineError.js";import{HighlightCounter as G}from"./support/HighlightCounter.js";import{toJSONGeometryType as $}from"./support/util.js";import{FeatureTileSubscriptionManager as z}from"../tiling/FeatureTileSubscriptionManager.js";import B from"../../layers/FeatureLayerView.js";import Z from"../../layers/LayerView.js";import K from"../../layers/RefreshableLayerView.js";import X from"../../../geometry/Extent.js";function Y(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const ee=4294967294;let te=class extends(B(K(U(Z)))){constructor(){super(...arguments),this._commandsQueue=new N({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new G,this._lastAvailableFields=[],this._lastTargetState=null,this.eventLog=new R,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new v}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransition()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===E(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await q(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view?.featuresTilingScheme?.tileInfo?.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(c()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&!this.suspended&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new O(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new O(this.layer);case"parquet":return new H(this.layer);case"subtype-group":return new M(this.layer);case"ogc-feature":return new T(this.layer);case"stream":return new W(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new L(this.layer);case"catalog-footprint":return new Q(this.layer);default:a(this.layer)}return null}get timeExtent(){return x(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="default"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return J(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return J(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return J(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=C.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await J(r,{features:[]}),s=C.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await J(r,{features:[]}),s=j.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return J(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return J(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return J(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return J(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return J(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return J(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await J(r,{count:0,extent:null});return{count:i.count,extent:X.fromJSON(i.extent)}}async queryAttributeBins(e,t){const r=(await this.getWorker()).features.executeAttributeBinsQuery(e.toJSON(),t),i=await J(r,{features:[]});return C.fromJSON(i)}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;this.view.animation&&!this._lastTargetState&&(this._lastTargetState=e.state.clone()),!this.view.animation&&this._lastTargetState&&(this._lastTargetState=null);const t=this._subscriptionManager.update(e.targetState,this._lastTargetState);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new k(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new z({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),d(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,viewTimeExtent:this.view.timeExtent,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())})),f((()=>this.visible),(e=>{this.view.labelManager.requestUpdate()}))]),"stream"!==this.layer.type&&"parquet"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this.featureContainer=null,this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),d(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("dataUpdating",e.data)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:async t=>{if(has("esri-2d-stabilize-glyphs")){const r=[];for(const i of t)r.push(await e.view.stage.painter.textureManager.rasterizeItem(i));return r}return Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t))))},fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await D(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=V.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=V.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this._getEffectiveEdit(e);return t?this._commandsQueue.push(t).catch(y):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%ee+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%ee+1}_getEffectiveEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,r=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),i=t&&this.availableFields.includes(t);if(r&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null;const s=this.layer,a=e.historicMoment?.getTime()??null,n="layerId"in s&&e.editedFeatures?.find((e=>e.layerId===s.layerId));if(n&&this._canEditByFeature(n)){const e=!1,r=!1,i=$(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>b(t,i,e,r))),c=u.map((t=>b(t.current,i,e,r)));return{type:"edit-by-feature",added:h,removed:o.map((e=>"attributes"in e?{globalId:t?e.attributes[t]:null,objectId:l?e.attributes[l]:null}:e)),updated:c,historicMoment:a}}return{type:"edit-by-id",added:e.addedFeatures,updated:e.updatedFeatures,removed:e.deletedFeatures,historicMoment:a}}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every((e=>this.view.spatialReference.equals(e.geometry?.spatialReference)))&&r.every((e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference)))}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await Promise.allSettled([this._updateRequiredFields(),F(this.layer)]),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransition(),this.featureContainer.restartAllAnimations(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doEdit(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onEdits(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=Y(this._lastAvailableFields,e);return this._lastAvailableFields=t,S(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[re(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone,timeExtent:this.view.timeExtent}}_addHighlights(e,t){this._highlightCounter.addGroup(e,t),this._commandsQueue.push({type:"highlight"})}_removeHighlights(e,t){this._highlightCounter.deleteGroup(e,t),this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightGroups(i),r=this._getHighlightBits(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function re(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new A,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new A).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],te.prototype,"_commandsQueue",void 0),e([w()],te.prototype,"_sourceRefreshVersion",void 0),e([w()],te.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],te.prototype,"_pipelineUpdating",void 0),e([w({readOnly:!0})],te.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],te.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],te.prototype,"hasFullGeometries",null),e([w()],te.prototype,"featureEffectView",void 0),e([w()],te.prototype,"labelingCollisionInfos",null),e([w()],te.prototype,"layerAdapter",null),e([w({readOnly:!0})],te.prototype,"timeExtent",null),e([w()],te.prototype,"updating",void 0),te=e([_("esri.views.2d.layers.FeatureLayerView2D")],te);const ie=te;export{ie as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{notDeepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as d,ignoreAbortErrors as p,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as v}from"../../../core/support/UpdatingHandles.js";import b from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as F}from"../../../layers/graphics/featureConversionUtils.js";import A from"../../../layers/support/FeatureFilter.js";import{checkCurrentUserSupport as S}from"../../../layers/support/featureLayerUtils.js";import{packFields as j}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as x}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as E}from"../../../layers/support/timeSupport.js";import I from"../../../rest/support/AggregateFeatureSet.js";import U from"../../../rest/support/FeatureSet.js";import k from"../../../rest/support/Query.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import{FeatureContainer as V}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as q}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as R}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as O}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as Q}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as L}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as W}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as H}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{ParquetLayerAdapter as T}from"./features/layerAdapters/ParquetLayerAdapter.js";import{StreamLayerAdapter as M}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as D}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as N}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import G from"./support/FeatureCommandQueue.js";import{handleNoEngineError as J}from"./support/handleNoEngineError.js";import{HighlightCounter as $}from"./support/HighlightCounter.js";import{toJSONGeometryType as z}from"./support/util.js";import{FeatureTileSubscriptionManager as B}from"../tiling/FeatureTileSubscriptionManager.js";import Z from"../../layers/FeatureLayerView.js";import K from"../../layers/LayerView.js";import X from"../../layers/RefreshableLayerView.js";import Y from"../../../geometry/Extent.js";function ee(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const te=4294967294;let re=class extends(Z(X(C(K)))){constructor(){super(...arguments),this._commandsQueue=new G({process:e=>{switch(e.type){case"override":return this._doOverride(e.message);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new $,this._lastAvailableFields=[],this._lastTargetState=null,this.eventLog=new R,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._editUpdatingHandles=new v,this._fields=null,this._sourceUpdating=!1,this.featureEffectView=new b}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=d(),p(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransition()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===x(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await q(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view?.featuresTilingScheme?.tileInfo?.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(c()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get dataUpdating(){return this._sourceUpdating||this._editUpdatingHandles.updating}get hasAllFeatures(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&!this.suspended&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new L(this.layer):new Q(this.layer);case"geojson":case"csv":case"wfs":return new L(this.layer);case"parquet":return new T(this.layer);case"subtype-group":return new D(this.layer);case"ogc-feature":return new H(this.layer);case"stream":return new M(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new W(this.layer);case"catalog-footprint":return new O(this.layer);default:a(this.layer)}return null}get timeExtent(){return E(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="default"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return J(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return J(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return J(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=U.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await J(r,{features:[]}),s=U.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await J(r,{features:[]}),s=I.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return J(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return J(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return J(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return J(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return J(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return J(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await J(r,{count:0,extent:null});return{count:i.count,extent:Y.fromJSON(i.extent)}}async queryAttributeBins(e,t){const r=(await this.getWorker()).features.executeAttributeBinsQuery(e.toJSON(),t),i=await J(r,{features:[]});return U.fromJSON(i)}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;this.view.animation&&!this._lastTargetState&&(this._lastTargetState=e.state.clone()),!this.view.animation&&this._lastTargetState&&(this._lastTargetState=null);const t=this._subscriptionManager.update(e.targetState,this._lastTargetState);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),p(this._updatingHandles.addPromise(this._workerAttached.promise)),p(this._attachProxy()),this.featureContainer=new V(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new B({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),p(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,viewTimeExtent:this.view.timeExtent,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())})),f((()=>this.visible),(e=>{this.view.labelManager.requestUpdate()}))]),"stream"!==this.layer.type&&"parquet"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._editUpdatingHandles.addPromise(this._edit(e)))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this.featureContainer=null,this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=d(),p(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("_sourceUpdating",e.source)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:async t=>{if(has("esri-2d-stabilize-glyphs")){const r=[];for(const i of t)r.push(await e.view.stage.painter.textureManager.rasterizeItem(i));return r}return Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t))))},fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await N(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=k.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=k.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this.layer,r=e.historicMoment?.getTime()??null,i="layerId"in t&&e.editedFeatures?.find((e=>e.layerId===t.layerId));if(i&&this._canEditByFeature(i)){const{adds:e,deletes:t,updates:s}=i.editedFeatures,a=this.layer.objectIdField,o=s.map((e=>e.current)),n=t.map((e=>"attributes"in e?{objectId:a?e.attributes[a]:null}:e)),u=await this._resolveIdenifiers(n);return this.addOverrides({added:e,updated:o,removed:u,historicMoment:r,isWeak:!0})}const[s,a,o]=await Promise.all([this._resolveIdenifiers(e.addedFeatures),this._resolveIdenifiers(e.updatedFeatures),this._resolveIdenifiers(e.deletedFeatures)]),n=[...s,...a];return this._commandsQueue.push({type:"override-by-id",updates:n,removed:o,historicMoment:r,isWeak:!0}).catch(y)}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%te+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%te+1}async _resolveIdenifiers(e){const t=[],r=[];for(const a of e)null==a.objectId||-1===a.objectId?null==a.globalId?u.getLogger(this).warn("mapview-apply-edits","A feature identifier must contain either a GlobalId or ObjectId. Ignoring",{identifier:a}):r.push(a.globalId):t.push(a.objectId);const i="globalIdField"in this.layer&&this.layer.globalIdField,s=i&&this.availableFields.includes(i);if(r.length&&!s)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${i} to be included the layer's outFields for updates to be reflected on the map`)),t;if(r.length){const e=await this._workerProxy.pipeline.getObjectIdsFromGlobalIds(r);for(const r of e)t.push(r)}return t}async addOverrides(e){const t=!1,r=!1,i=z(this.layer.geometryType),s=this.layer.objectIdField,a=[];for(const n of e.added){const e=F(n,i,t,r,s);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.updated){const e=F(n,i,t,r,s);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.removed)if(null==n)throw new o("featurelayerview:bad-override","Tried to remove an invalid objectId",{objectId:n});return this._commandsQueue.push({type:"override",updates:a,removed:e.removed,release:[],isWeak:e.isWeak??!1,historicMoment:e.historicMoment??null})}async removeOverrides(e){for(const t of e)if(null==t)throw new o("featurelayerview:bad-override","Tried to remove an override for an invalid objectId",{objectId:t});return this._commandsQueue.push({type:"override",updates:[],removed:[],release:e,isWeak:!1,historicMoment:null})}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every((e=>this.view.spatialReference.equals(e.geometry?.spatialReference)))&&r.every((e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference)))}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await Promise.allSettled([this._updateRequiredFields(),S(this.layer)]),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransition(),this.featureContainer.restartAllAnimations(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doOverride(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onOverride(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=ee(this._lastAvailableFields,e);return this._lastAvailableFields=t,j(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[ie(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone,timeExtent:this.view.timeExtent}}_addHighlights(e,t){this._highlightCounter.addGroup(e,t),this._commandsQueue.push({type:"highlight"})}_removeHighlights(e,t){this._highlightCounter.deleteGroup(e,t),this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightGroups(i),r=this._getHighlightBits(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function ie(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new A,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new A).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],re.prototype,"_commandsQueue",void 0),e([w()],re.prototype,"_sourceRefreshVersion",void 0),e([w()],re.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],re.prototype,"_pipelineUpdating",void 0),e([w()],re.prototype,"_sourceUpdating",void 0),e([w({readOnly:!0})],re.prototype,"dataUpdating",null),e([w({readOnly:!0})],re.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],re.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],re.prototype,"hasFullGeometries",null),e([w()],re.prototype,"featureEffectView",void 0),e([w()],re.prototype,"labelingCollisionInfos",null),e([w()],re.prototype,"layerAdapter",null),e([w({readOnly:!0})],re.prototype,"timeExtent",null),e([w()],re.prototype,"updating",void 0),re=e([_("esri.views.2d.layers.FeatureLayerView2D")],re);const se=re;export{se as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as r}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as i,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js";import{Techniques as h}from"../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{TechniqueType as d}from"../../engine/webgl/shaderGraph/techniques/TechniqueType.js";import{RenderState as l}from"./RenderState.js";import{renderHighlight as u}from"../support/util.js";class c{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class p extends r{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),this._renderState){const e=Array.from(this._renderState.tiles()).filter((e=>e.needsUpload));if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._subscriptions.get(t.key.id)?.end(),this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this.requestRender())}for(const t of this.children)t.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case i.MAP:return this._renderMapPhase(e);case i.HIGHLIGHT:return this._renderHighlightPhase(e);case i.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight()}get _layer(){return this._layerView.layer}_getHeatmapInstance(e){if(null==this._instanceStore||!(e.drawPhase&h.heatmap.drawPhase))return null;for(const t of this._instanceStore.values())if(_(t))return t;return null}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter((e=>this._visibleTiles.has(e.key.id))):[]}updateAttributeView(e){this.requestRender(),this.attributeView.requestUpdate(e),this.hasLabels&&this._layerView.view.labelManager.requestUpdate()}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new c(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new l((()=>this._stage),(e=>this._subscriptions.get(e)?.version),e,this.tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const r of t)s.set(r.fieldName,{minValue:r.minValue,maxValue:r.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this.requestRender()}swapRenderState(){this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState&&this._renderState.flush(),this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){e(s);const r=t.inner;if(!this._subscriptions.has(r.id))return;const i=this._subscriptions.get(r.id);if(i.version!==r.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${r.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${r.id}] FeatureContainer - Dropping message, outdated version]`,r)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==r.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${r.version}]`),n.enqueueUpdate(t),this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find((({x:t,y:s})=>t===e.x&&s===e.y));const r=t();return s?s.resolvers.push(r):(s={x:e.x,y:e.y,resolvers:[r]},this._hitTestsRequests.push(s)),this.requestRender(),r.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const r of this.children)if(r.getSortKeys(t).forEach(((e,t)=>s.set(t,e))),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,r=e.state.scale;r<=(t||1/0)&&r>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){if(null==this._getHeatmapInstance(e))super.setStencilReference(e);else for(const t of this.children)t.stencilRef=h.heatmap.getStencilReference(t)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&u(e,!1,(e=>{this._renderFeatures(e,n.Highlight)}))}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,r=t.getBoundFramebufferObject(),a=t.getViewport(),o=e.passOptions,h=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=i.HITTEST;const{distance:d,smallSymbolDistance:l}=e.passOptions,u=Math.max(d,l);for(const i of this.children)i.visible&&i.containsScreenPoint(e.state,e.passOptions.position,2*u)&&this._renderTile(i,e,n.All);s.draw(e),s.unbind(),t.bindFramebuffer(r),t.restoreViewport(a),e.passOptions=o,e.drawPhase=h}_renderFeatures(e,t){const s=this._getHeatmapInstance(e);null!=s?this._renderHeatmapFeatures(e,t,s):this._renderGeometryFeatures(e,t)}_renderGeometryFeatures(e,t){for(const s of this.children)s.visible&&this._renderTile(s,e,t)}_renderHeatmapFeatures(e,t,s){for(const r of this.children)r.visible&&this._renderTile(r,e,t,d.Heatmap);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,r){const i=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,n=e.getDisplayList(this._instanceStore,i);t.selection=s,n?.render(t,r)}}function _(e){return e.techniqueRef.type===d.Heatmap}export{p as FeatureContainer};
5
+ import has from"../../../../core/has.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as r}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as i,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js";import{Techniques as h}from"../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{TechniqueType as d}from"../../engine/webgl/shaderGraph/techniques/TechniqueType.js";import{RenderState as l}from"./RenderState.js";import{renderHighlight as u}from"../support/util.js";class c{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class p extends r{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),this._renderState){const e=Array.from(this._renderState.tiles()).filter((e=>e.needsUpload));if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._subscriptions.get(t.key.id)?.end(),this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this.requestRender())}for(const t of this.children)t.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case i.MAP:return this._renderMapPhase(e);case i.HIGHLIGHT:return this._renderHighlightPhase(e);case i.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight()}get _layer(){return this._layerView.layer}_getHeatmapInstance(e){if(null==this._instanceStore||!(e.drawPhase&h.heatmap.drawPhase))return null;for(const t of this._instanceStore.values())if(_(t))return t;return null}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter((e=>this._visibleTiles.has(e.key.id))):[]}updateAttributeView(e){this.requestRender(),this.attributeView.requestUpdate(e),this.hasLabels&&this._layerView.view.labelManager.requestUpdate()}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new c(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new l((()=>this._stage),(e=>this._subscriptions.get(e)?.version),e,this.tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const r of t)s.set(r.fieldName,{minValue:r.minValue,maxValue:r.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this._renderState?.flush(),this.requestRender()}swapRenderState(){this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState&&this._renderState.flush(),this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){e(s);const r=t.inner;if(!this._subscriptions.has(r.id))return;const i=this._subscriptions.get(r.id);if(i.version!==r.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${r.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${r.id}] FeatureContainer - Dropping message, outdated version]`,r)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==r.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${r.version}]`),n.enqueueUpdate(t),this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find((({x:t,y:s})=>t===e.x&&s===e.y));const r=t();return s?s.resolvers.push(r):(s={x:e.x,y:e.y,resolvers:[r]},this._hitTestsRequests.push(s)),this.requestRender(),r.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const r of this.children)if(r.getSortKeys(t).forEach(((e,t)=>s.set(t,e))),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,r=e.state.scale;r<=(t||1/0)&&r>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){if(null==this._getHeatmapInstance(e))super.setStencilReference(e);else for(const t of this.children)t.stencilRef=h.heatmap.getStencilReference(t)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&u(e,!1,(e=>{this._renderFeatures(e,n.Highlight)}))}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,r=t.getBoundFramebufferObject(),a=t.getViewport(),o=e.passOptions,h=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=i.HITTEST;const{distance:d,smallSymbolDistance:l}=e.passOptions,u=Math.max(d,l);for(const i of this.children)i.visible&&i.containsScreenPoint(e.state,e.passOptions.position,2*u)&&this._renderTile(i,e,n.All);s.draw(e),s.unbind(),t.bindFramebuffer(r),t.restoreViewport(a),e.passOptions=o,e.drawPhase=h}_renderFeatures(e,t){const s=this._getHeatmapInstance(e);null!=s?this._renderHeatmapFeatures(e,t,s):this._renderGeometryFeatures(e,t)}_renderGeometryFeatures(e,t){for(const s of this.children)s.visible&&this._renderTile(s,e,t)}_renderHeatmapFeatures(e,t,s){for(const r of this.children)r.visible&&this._renderTile(r,e,t,d.Heatmap);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,r){const i=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,n=e.getDisplayList(this._instanceStore,i);t.selection=s,n?.render(t,r)}}function _(e){return e.techniqueRef.type===d.Heatmap}export{p as FeatureContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{handlesGroup as t}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{nextTick as s}from"../../../../core/nextTick.js";import{throwIfNotAbortError as i,createResolver as r,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import n from"../../../../core/RandomLCG.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{ignoreConnectionErrors as d}from"../../../../core/workers/utils.js";import c from"../../../../layers/support/TileInfo.js";import p from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{tileSize as l}from"../../engine/webgl/definitions.js";import{PipelineConnectionHandlers as h}from"./PipelineConnectionHandlers.js";import g from"./Processor.js";import{FeatureSource as _}from"./sources/FeatureSource.js";import{FeatureTileSubscription as b}from"./sources/FeatureTileSubscription.js";import{Tile as f}from"./support/Tile.js";class m{constructor(e){this.inner=e,this.resolver=r()}}class y{constructor(){this._aggregateAdapter={getFeatureObjectIds:e=>this._processor.getFeatureObjectIdsForAggregate(e)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor?.destroy(),this._source?.destroy(),this._handles?.remove(),this._updateLocalEditsRequest=null,this._tileInfoView=null}onAttach(e){has("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const s=this._connection,i=c.fromJSON(e.tileInfoJSON);this._tileInfoView=new p(i),this._source=new _(e.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),s),this._processor=new g(s,this._source),this._handles=t([u((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),o(this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){has("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(e){this._connection=new h(e)}get features(){const t=this._source?.queryEngine;if(!t)throw new e("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new e("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(e){return this._processor.getDisplayFeatures(e)}getDisplayIds(e){return this._processor.getDisplayIds(e)}async updateSchema(e,t){return has("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new m({schema:e,version:t}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(e){const t=new m(e);return this._updateSubscriptionRequests.push(t),this._requestUpdate(),t.resolver.promise}updateHighlight(e){const t=new m(e);return this._updateHighlightRequests.push(t),this._requestUpdate(),t.resolver.promise}async addParquetFile(e){return this._source.addParquetFile(e)}async onEdits(t){if(null!=this._updateLocalEditsRequest)throw new e("InternalError - Already processing an edit");this._updateLocalEditsRequest=new m(t);const s=this._updateLocalEditsRequest.resolver.promise;return this._requestUpdate(),s}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(e,t){return this.features.executeQuery(e,t)}async queryHeatmapStatistics(e){const t=Math.round(a(e.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof e.fieldOffset,o=e.fieldOffset??0,n=Array.from(this._subscriptions.values()),u=this._source.chunks(),d=t**2,c=3/(Math.PI*d),p=2*t,h=Math.ceil(l/p);for(const a of n){const t=a.tile,n=new Float64Array(h*h);for(const s of u){const i=s.getTileReader(t);if(!i)continue;const u=i.getCursor();for(;u.next();){let t=1;if(null!=e.field){const s=u.readAttribute(e.field);t=r?-1*+s:+s+o}const s=u.readXForDisplay()/p,i=u.readYForDisplay()/p,a=Math.floor(s),l=Math.floor(i);if(a<0||l<0||a>=h||l>=h)continue;const g=((.5+a-s)*p)**2+((.5+l-i)*p)**2;if(g>d)continue;const _=t*(c*(1-g/d)**2);n[l+a*h]+=_}}for(let e=0;e<n.length;e++)s=Math.min(s,n[e]),i=Math.max(i,n[e])}return{max:i,min:s}}async getSampleFeatures(e){const t=this._source.chunks();if(t.reduce(((e,t)=>e+t.size()),0)<=e.minFeatureCount){if(!this._source.updateTracking.updating){const e=[];return this._source.store.forEachUnsafe((t=>e.push(t.readLegacyFeatureWorldSpace()))),e}return null}const s=new Set,i=[],r=t.map((e=>e.reader.getCursor())),o=new n,u=3*e.sampleSize;for(let n=0;n<u&&i.length<e.sampleSize;n++){const e=r[o.getIntRange(0,t.length-1)];if(0===e.getSize())continue;const n=o.getIntRange(0,e.getSize()-1);e.setIndex(n);const u=e.getObjectId();s.has(u)||(s.add(u),i.push(e.readLegacyFeatureWorldSpace()))}return i.length>=e.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,s((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=d(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(e){const t=e.tileId;if(this._subscriptions.has(t))return;has("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.subscribe`);const s=new f(this._tileInfoView,t),i=new b(s,e.version);this._subscriptions.set(t,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(e){const t=this._subscriptions.get(e);t&&(has("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.unsubscribe`),t.abort(),this._source.onUnsubscribe(t),this._processor.onUnsubscribe(t),this._subscriptions.delete(t.key.id))}async _doUpdate(){if(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const e=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const t of e)this._doUpdateSubscriptions(t.inner),t.resolver.resolve()}const e=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=e){const{schema:t,version:s}=e.inner;await this._doUpdateSchema(t,s)}const t=this._updateLocalEditsRequest;if(this._updateLocalEditsRequest=null,null!=t){has("esri-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",t.inner);const e=await this._source.getLocalEdit(t.inner);await this._processor.applyLocalEdit(e),this._source.applyLocalEdit(e),has("esri-2d-update-debug")&&console.debug("Pipeline.endEditOverride",t.inner)}if(this._updateHighlightRequests.length){const e=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const t of e)this._processor.updateHighlight(t.inner),t.resolver.resolve()}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(r){i(r)}null!=t&&t.resolver.resolve(),null!=e&&e.resolver.resolve(),this._updateRequested?(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})):(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(e,t){has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateStart`,{schema:e});const s={tileInfo:this._tileInfoView?.tileInfo},i=await this._source.update(e,t),r=Array.from(this._subscriptions.values());await this._processor.update(e,t,s,i,r),has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateEnd`)}_doUpdateSubscriptions(e){has("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",e);for(const t of e.subscribe)this._subscribe(t);for(const t of e.unsubscribe)this._unsubscribe(t)}}export{y as default};
5
+ import e from"../../../../core/Error.js";import{handlesGroup as t}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{nextTick as s}from"../../../../core/nextTick.js";import{throwIfNotAbortError as i,createResolver as r,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import n from"../../../../core/RandomLCG.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{ignoreConnectionErrors as d}from"../../../../core/workers/utils.js";import c from"../../../../layers/support/TileInfo.js";import p from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{tileSize as l}from"../../engine/webgl/definitions.js";import{PipelineConnectionHandlers as h}from"./PipelineConnectionHandlers.js";import g from"./Processor.js";import{FeatureSource as _}from"./sources/FeatureSource.js";import{FeatureTileSubscription as b}from"./sources/FeatureTileSubscription.js";import{Tile as f}from"./support/Tile.js";class m{constructor(e){this.inner=e,this.resolver=r()}}class y{constructor(){this._aggregateAdapter={getFeatureObjectIds:e=>this._processor.getFeatureObjectIdsForAggregate(e)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor?.destroy(),this._source?.destroy(),this._handles?.remove(),this._updateOverridesRequest=null,this._tileInfoView=null}onAttach(e){has("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const s=this._connection,i=c.fromJSON(e.tileInfoJSON);this._tileInfoView=new p(i),this._source=new _(e.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),s),this._processor=new g(s,this._source),this._handles=t([u((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),o(this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){has("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(e){this._connection=new h(e)}get features(){const t=this._source?.queryEngine;if(!t)throw new e("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new e("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(e){return this._processor.getDisplayFeatures(e)}getDisplayIds(e){return this._processor.getDisplayIds(e)}getObjectIdsFromGlobalIds(e){return this._source.getObjectIdsFromGlobalIds(e)}async updateSchema(e,t){return has("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new m({schema:e,version:t}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(e){const t=new m(e);return this._updateSubscriptionRequests.push(t),this._requestUpdate(),t.resolver.promise}updateHighlight(e){const t=new m(e);return this._updateHighlightRequests.push(t),this._requestUpdate(),t.resolver.promise}async addParquetFile(e){return this._source.addParquetFile(e)}async onOverride(t){if(null!=this._updateOverridesRequest)throw new e("InternalError - Already processing an edit");this._updateOverridesRequest=new m(t);const s=this._updateOverridesRequest.resolver.promise;return this._requestUpdate(),s}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(e,t){return this.features.executeQuery(e,t)}async queryHeatmapStatistics(e){const t=Math.round(a(e.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof e.fieldOffset,o=e.fieldOffset??0,n=Array.from(this._subscriptions.values()),u=this._source.chunks(),d=t**2,c=3/(Math.PI*d),p=2*t,h=Math.ceil(l/p);for(const a of n){const t=a.tile,n=new Float64Array(h*h);for(const s of u){const i=s.getTileReader(t);if(!i)continue;const u=i.getCursor();for(;u.next();){let t=1;if(null!=e.field){const s=u.readAttribute(e.field);t=r?-1*+s:+s+o}const s=u.readXForDisplay()/p,i=u.readYForDisplay()/p,a=Math.floor(s),l=Math.floor(i);if(a<0||l<0||a>=h||l>=h)continue;const g=((.5+a-s)*p)**2+((.5+l-i)*p)**2;if(g>d)continue;const _=t*(c*(1-g/d)**2);n[l+a*h]+=_}}for(let e=0;e<n.length;e++)s=Math.min(s,n[e]),i=Math.max(i,n[e])}return{max:i,min:s}}async getSampleFeatures(e){const t=this._source.chunks();if(t.reduce(((e,t)=>e+t.size()),0)<=e.minFeatureCount){if(!this._source.updateTracking.updating){const e=[];return this._source.store.forEachUnsafe((t=>e.push(t.readLegacyFeatureWorldSpace()))),e}return null}const s=new Set,i=[],r=t.map((e=>e.reader.getCursor())),o=new n,u=3*e.sampleSize;for(let n=0;n<u&&i.length<e.sampleSize;n++){const e=r[o.getIntRange(0,t.length-1)];if(0===e.getSize())continue;const n=o.getIntRange(0,e.getSize()-1);e.setIndex(n);const u=e.getObjectId();s.has(u)||(s.add(u),i.push(e.readLegacyFeatureWorldSpace()))}return i.length>=e.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,s((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=d(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(e){const t=e.tileId;if(this._subscriptions.has(t))return;has("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.subscribe`);const s=new f(this._tileInfoView,t),i=new b(s,e.version);this._subscriptions.set(t,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(e){const t=this._subscriptions.get(e);t&&(has("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.unsubscribe`),t.abort(),this._source.onUnsubscribe(t),this._processor.onUnsubscribe(t),this._subscriptions.delete(t.key.id))}async _doUpdate(){if(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const e=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const t of e)this._doUpdateSubscriptions(t.inner),t.resolver.resolve()}const e=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=e){const{schema:t,version:s}=e.inner;await this._doUpdateSchema(t,s)}const t=this._updateOverridesRequest;if(this._updateOverridesRequest=null,null!=t){has("esri-2d-update-debug")&&console.debug("Pipeline.applyOverride",t.inner);const e=await this._source.normalizeOverrides(t.inner);null!=e.historicMoment&&this._source.unsafeSetQueryHistoricMoment(e.historicMoment),this._source.applyOverride(e),has("esri-2d-update-debug")&&console.debug("Pipeline.endOverride",t.inner)}if(this._updateHighlightRequests.length){const e=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const t of e)this._processor.updateHighlight(t.inner),t.resolver.resolve()}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{const e=this._source.takeOverrideUpdate();null!=e&&this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesStart"),await this._processor.applyOverrideUpdate(e),has("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesEnd")),this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(r){i(r)}null!=t&&t.resolver.resolve(),null!=e&&e.resolver.resolve(),this._updateRequested?(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0})):(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(e,t){has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateStart`,{schema:e});const s={tileInfo:this._tileInfoView?.tileInfo},i=await this._source.update(e,t),r=Array.from(this._subscriptions.values());await this._processor.update(e,t,s,i,r),has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateEnd`)}_doUpdateSubscriptions(e){has("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",e);for(const t of e.subscribe)this._subscribe(t);for(const t of e.unsubscribe)this._unsubscribe(t)}}export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{notDeepEqual as e}from"../../../../core/object.js";import{throwIfNotAbortError as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{diff as i}from"../../../../core/accessorSupport/diffUtils.js";import{ignoreConnectionErrors as a}from"../../../../core/workers/utils.js";import o from"../../../../geometry/SpatialReference.js";import{MultiTileMeshData as n}from"../../engine/webgl/mesh/MultiTileMeshData.js";import{FeatureMeshFactory as c}from"../../engine/webgl/mesh/factories/FeatureMeshFactory.js";import{ResourceProxy as h}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{MeshWriterRegistry as u}from"../../engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js";import{MatcherContext as g}from"../../engine/webgl/util/MatcherContext.js";import{ProcessorTileMessageQueue as p}from"./ProcessorTileMessageQueue.js";import{BinningStrategy as d}from"./processor/BinningStrategy.js";import{ClusterStrategy as y}from"./processor/ClusterStrategy.js";import{FeatureUpdateStrategy as _}from"./processor/FeatureUpdateStrategy.js";import{AttributeStore as l}from"./support/AttributeStore.js";import{ComputedAttributeStorage as m}from"./support/ComputedAttributeStorage.js";class f{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._registry=new u,this._proxy=new h({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new l({isLocal:!1,update:t=>a(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destroy(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getDisplayIds(t){const e={};return this._strategy?(this._strategy.displayMap(t,(t=>t),((t,s,r)=>{e[r]=t})),e):e}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,s,r,a,n){const h=t.processor,u=e(this._schema?.storage,h.storage),p=e(this._schema?.mesh.properties,h.mesh.properties),d=e(this._schema?.mesh.factory,h.mesh.factory),y=e(this._schema?.mesh.strategy,h.mesh.strategy),_=b(this._schema?.expressionProperties,h.expressionProperties),l=_.some((t=>this._attributeStore.hasArcadeDependency(t))),f=_.some((t=>this._factory?.hasArcadeDependency(t)??!1)),S=_.some((t=>this._strategy?.hasArcadeDependency(t)))||this._strategy?.isAggregate&&l,j=f||S,I=p||d||y;if(!(u||I||(f||l||S))&&!a)return;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:i(this._schema,h),schema:h}),this._schema=h;const x=o.fromJSON(this._source.service.outSpatialReference),v=new m({fields:this._source.metadata.fieldsIndex,spatialReference:x});if((u||I||l)&&(await this._attributeStore.update(h.storage,v,this._source.metadata,x,s),this._strategy?.invalidateAttributeData(w(h))),!a&&!I&&!j)return;(y||p||j)&&await this._updateStrategy(h.mesh.strategy,x,n,w(h)),this._updateSortKey(v,"sortKey"in h.mesh.properties?h.mesh.properties.sortKey:null);const M=new g(v,this._proxy,r,this._registry);return(d||"dictionary"===h.mesh.factory.symbology.type)&&(this._factory=await c.create(M,h.mesh.factory)),this._invalidate(),this._version=s,this._connection.container.updateRenderState(this._version)}async applyLocalEdit(t){if(!this._strategy)return;const e=this._strategy.applyLocalEdit(t);for await(const r of e)try{await this._process(r)}catch(s){}}async updateChunks(){this._strategy?.beforeUpdateChunks(),await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],r=new Map;for await(const a of t){let t=r.get(a.id);null==t&&(t=new p({concurrency:16,process:t=>this._process(t)}),r.set(a.id,t));const i=t.push(a).catch((t=>s(t)));e.push(i)}try{await Promise.all(e)}catch(i){}has("esri-2d-update-debug")&&console.log("SendUpdates"),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,r){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new _(this._source,this._attributeStore,r);break;case"binning":this._strategy=await d.create(t,e,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await y.create(this._connection,t,e,this._source,this._attributeStore,r)}for(const i of s)this._strategy.onSubscribe(i)}async _updateSortKey(e,s){if(this._sortInfo=t(this._sortInfo?.computed),null!=s){const t=s.byRenderer?null:await e.createComputedField(s);this._sortInfo={...s,computed:t}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if(has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),r(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(w(this._schema))),i=e.tile.tileInfoView.getLODInfoAt(e.tile.key),{message:a,transferList:o}=s.serialize(i),n={objectIdMap:null,inner:t.createMessage(a,this._version,this._attributeStore.epoch)};if(this._schema?.mesh.properties.returnMeshObjectId){n.objectIdMap={};const e=t.reader?.getCursor();if(e)for(;e.next();)n.objectIdMap[e.getDisplayId()]=e.getObjectId()}if(r(e.signal),await this._connection.container.onMessage(n,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(w(this._schema));for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,r=t.reader?.getCursor(),i=r?.getSize()??0,a=s.tileInfoView.tileInfo.isWrappable,o=s.tileInfoView.tileInfo.spatialReference.isWGS84,c=new n(s.key,this._strategy.enablePixelBuffering,a,o,i);if(!r)return c;const h=s.createArcadeEvaluationOptions(w(this._schema));for(;r.next();){const t=this._getSortKeyValue(r,e);c.entityStart(r.getDisplayId(),t),this._factory.write(c,this._proxy,r,h,s.level),c.entityEnd()}return c}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,a=i?this._factory.getSortKey(t,e):s?.read(t,e);return null==a||isNaN(a)?0:a*("asc"===r?-1:1)}}function b(t,e){const s=[];return t?.timeExtent?.start===e.timeExtent?.start&&t?.timeExtent?.end===e.timeExtent?.end||s.push("timeProperties"),s}function w(t){const{timeZone:e}=t?.mesh.properties??{},{timeExtent:s}=t?.expressionProperties??{};return{timeZone:e,timeExtent:s}}export{f as default};
5
+ import has from"../../../../core/has.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../core/object.js";import{throwIfNotAbortError as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{diff as i}from"../../../../core/accessorSupport/diffUtils.js";import{ignoreConnectionErrors as a}from"../../../../core/workers/utils.js";import o from"../../../../geometry/SpatialReference.js";import{MultiTileMeshData as n}from"../../engine/webgl/mesh/MultiTileMeshData.js";import{FeatureMeshFactory as c}from"../../engine/webgl/mesh/factories/FeatureMeshFactory.js";import{ResourceProxy as h}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{MeshWriterRegistry as u}from"../../engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js";import{MatcherContext as p}from"../../engine/webgl/util/MatcherContext.js";import{ProcessorTileMessageQueue as g}from"./ProcessorTileMessageQueue.js";import{BinningStrategy as d}from"./processor/BinningStrategy.js";import{ClusterStrategy as y}from"./processor/ClusterStrategy.js";import{FeatureUpdateStrategy as _}from"./processor/FeatureUpdateStrategy.js";import{AttributeStore as l}from"./support/AttributeStore.js";import{ComputedAttributeStorage as m}from"./support/ComputedAttributeStorage.js";class f{constructor(e,t){this._connection=e,this._source=t,this._version=1,this._registry=new u,this._proxy=new h({fetch:(e,t)=>this._connection.layerView.fetch(e,t),fetchDictionary:(e,t)=>this._connection.layerView.fetchDictionary(e,t)}),this._attributeStore=new l({isLocal:!1,update:e=>a(this._connection.container.updateAttributeView(e))})}destroy(){this._proxy.destroy(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(e){return this._strategy?this._strategy.getDisplayFeatures(e):{features:[],aggregates:[]}}getDisplayIds(e){const t={};return this._strategy?(this._strategy.displayMap(e,(e=>e),((e,s,r)=>{t[r]=e})),t):t}getFeatureObjectIdsForAggregate(e){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(e):[]}onSubscribe(e){this._strategy?.onSubscribe(e)}onUnsubscribe(e){this._strategy?.onUnsubscribe(e)}async update(e,s,r,a,n){const h=e.processor,u=t(this._schema?.storage,h.storage),g=t(this._schema?.mesh.properties,h.mesh.properties),d=t(this._schema?.mesh.factory,h.mesh.factory),y=t(this._schema?.mesh.strategy,h.mesh.strategy),_=b(this._schema?.expressionProperties,h.expressionProperties),l=_.some((e=>this._attributeStore.hasArcadeDependency(e))),f=_.some((e=>this._factory?.hasArcadeDependency(e)??!1)),S=_.some((e=>this._strategy?.hasArcadeDependency(e)))||this._strategy?.isAggregate&&l,j=f||S,I=g||d||y;if(!(u||I||(f||l||S))&&!a)return;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:i(this._schema,h),schema:h}),this._schema=h;const x=o.fromJSON(this._source.service.outSpatialReference),v=new m({fields:this._source.metadata.fieldsIndex,spatialReference:x});if((u||I||l)&&(await this._attributeStore.update(h.storage,v,this._source.metadata,x,s),this._strategy?.invalidateAttributeData(w(h))),!a&&!I&&!j)return;(y||g||j)&&await this._updateStrategy(h.mesh.strategy,x,n,w(h)),this._updateSortKey(v,"sortKey"in h.mesh.properties?h.mesh.properties.sortKey:null);const M=new p(v,this._proxy,r,this._registry);return(d||"dictionary"===h.mesh.factory.symbology.type)&&(this._factory=await c.create(M,h.mesh.factory)),this._invalidate(),this._version=s,this._connection.container.updateRenderState(this._version)}async applyOverrideUpdate(e){if(!this._strategy)return;const t=this._strategy.applyOverrideUpdate(e);for await(const r of t)try{await this._process(r)}catch(s){}}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(e){this._strategy?.removeChunks(e),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:e}){if(!this._strategy)return void this._attributeStore.setHighlight(e.map((({objectId:e,highlightFlags:t})=>({objectId:e,highlightFlags:t,displayId:-1}))),e);const t=this._strategy.displayMap(e,(({objectId:e})=>e),((e,{highlightFlags:t},s)=>({objectId:s,displayId:e,highlightFlags:t})));this._attributeStore.setHighlight(t,e)}async _doUpdateChunks(){if(!this._strategy)return;const e=this._strategy.updateChunks(),t=[],r=new Map;for await(const a of e){let e=r.get(a.id);null==e&&(e=new g({concurrency:16,process:e=>this._process(e)}),r.set(a.id,e));const i=e.push(a).catch((e=>s(e)));t.push(i)}try{await Promise.all(t)}catch(i){}has("esri-2d-update-debug")&&console.log("SendUpdates"),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(e,t,s,r){switch(this._strategy?.destroy(),e.type){case"feature":this._strategy=new _(this._source,this._attributeStore,r);break;case"binning":this._strategy=await d.create(e,t,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await y.create(this._connection,e,t,this._source,this._attributeStore,r)}for(const i of s)this._strategy.onSubscribe(i)}async _updateSortKey(t,s){if(this._sortInfo=e(this._sortInfo?.computed),null!=s){const e=s.byRenderer?null:await t.createComputedField(s);this._sortInfo={...s,computed:e}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(e){const t=e.subscription;if(has("esri-2d-update-debug")){const s=t.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${e.end}] Processor._process`)}await this._fetchResources(e),r(t.signal);const s=await this._write(e,t.tile.createArcadeEvaluationOptions(w(this._schema))),i=t.tile.tileInfoView.getLODInfoAt(t.tile.key),{message:a,transferList:o}=s.serialize(i),n={objectIdMap:null,inner:e.createMessage(a,this._version,this._attributeStore.epoch)};if(this._schema?.mesh.properties.returnMeshObjectId){n.objectIdMap={};const t=e.reader?.getCursor();if(t)for(;t.next();)n.objectIdMap[t.getDisplayId()]=t.getObjectId()}if(r(t.signal),await this._connection.container.onMessage(n,{signal:t.signal,transferList:o}),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")){const s=t.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${e.end}] Processor._process.await`)}}async _fetchResources(e){await this._fetchMatcherResources(e),await this._fetchWriterResources(e)}async _fetchMatcherResources(e){if(e.reader)return this._factory.enqueueMatcherRequests(this._proxy,e.reader)}async _fetchWriterResources(e){if(!e.reader)return;const t=e.reader.getCursor(),s=e.subscription.tile.createArcadeEvaluationOptions(w(this._schema));for(;t.next();)this._factory.enqueueWriterRequests(this._proxy,t,s);await this._proxy.fetchEnqueuedResources()}async _write(e,t){const s=e.subscription.tile,r=e.reader?.getCursor(),i=r?.getSize()??0,a=s.tileInfoView.tileInfo.isWrappable,o=s.tileInfoView.tileInfo.spatialReference.isWGS84,c=new n(s.key,this._strategy.enablePixelBuffering,a,o,i);if(!r)return c;const h=s.createArcadeEvaluationOptions(w(this._schema));for(;r.next();){const e=this._getSortKeyValue(r,t);c.entityStart(r.getDisplayId(),e),this._factory.write(c,this._proxy,r,h,s.level),c.entityEnd()}return c}_getSortKeyValue(e,t){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,a=i?this._factory.getSortKey(e,t):s?.read(e,t);return null==a||isNaN(a)?0:a*("asc"===r?-1:1)}}function b(e,t){const s=[];return e?.timeExtent?.start===t.timeExtent?.start&&e?.timeExtent?.end===t.timeExtent?.end||s.push("timeProperties"),s}function w(e){const{timeZone:t}=e?.mesh.properties??{},{timeExtent:s}=e?.expressionProperties??{};return{timeZone:t,timeExtent:s}}export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class e{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}get isAggregate(){return!1}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(t){}hasArcadeDependency(t){return!1}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}beforeUpdateChunks(){}afterUpdateChunks(){}}export{e as AProcessorStrategy,t as ASendState};
5
+ class t{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class e{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}get isAggregate(){return!1}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(t){}hasArcadeDependency(t){return!1}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}afterUpdateChunks(){}}export{e as AProcessorStrategy,t as ASendState};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../geometry.js";import{unquantizeOptimizedGeometry as e,convertToFeature as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as s}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as a}from"../../../../../layers/graphics/data/projectionSupport.js";import r from"../../../../../layers/support/FieldsIndex.js";import{ComputedAggregateField as i}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as n}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as l,FeatureTileUpdateMessage as d}from"../sources/FeatureSourceMessage.js";import{isLocalEditChunk as c}from"../sources/strategies/chunks/OverrideChunk.js";import{ComputedAttributeStorage as u}from"../support/ComputedAttributeStorage.js";import f from"../support/FeatureFilter.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as h}from"../support/FeatureSetReaderJSON.js";import g from"../../../tiling/TileKey.js";import m from"../../../../../geometry/SpatialReference.js";class y extends n{constructor(e,t){super(e),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.done=!1}invaldateForLocalEditDropped(){this.handledChunks.clear(),this.bins.clear()}destroy(){const e=this.subscription.tile.key.level;for(const t of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${t}.${e}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const s=t.clone();s.geometry&&e(s.geometry,s.geometry,!1,!1,this.subscription.tile.transform),yield s}}}class I extends o{static async create(e,t,s,r,o){const n=new u({spatialReference:t}),l=await Promise.all(e.fields.map((async e=>i.create(n,e)))),d=e.featureFilter?await f.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return"geohash"===e.index.type&&await a(t,m.WGS84),new I(e,d,o,l,t,s,r)}constructor(e,t,s,a,i,o,n){super(o,n,i,a),this._schema=e,this._featureFilter=t,this._arcadeContextInfo=s,this._metadata=p.createFeature({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fieldsIndex:new r(e.fields).toJSON(),globalIdField:null,spatialReference:o.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new y(e,this._attributeStore)}async*applyLocalEdit(e){for(const t of this._sendStates.values()){t.reset();const e=new l(t.subscription,h.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const a=new Map(e.map((e=>[t(e),e]))),r=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace()){const{objectId:t,displayId:i}=e,o=a.get(t);if(null!=o){const e=s(i,o,t);r.push(e),a.delete(t)}}return r}getDisplayFeatures(e){const s=new Set(e),a=new Set,r=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace())s.has(e.displayId)&&!a.has(e.objectId)&&(e.geometry&&r.push({...t(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),a.add(e.objectId));return{features:[],aggregates:r}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.containedObjectIds);return[]}beforeUpdateChunks(){const e=this._source.chunks();if(!e.length)return;let t=!1;for(const s of e)c(s)&&s.lastLocalEditDropped!==this._lastHandledLocalEdit&&(this._lastHandledLocalEdit=s.lastLocalEditDropped,t=!0);if(t)for(const s of this._sendStates.values())s.invaldateForLocalEditDropped()}async*updateChunks(){for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){const t=new Set;for(const s of this._sendStates.values())for(const a of s.featuresWorldSpace())t.has(a.objectId)||(e(a),t.add(a.objectId))}_createIndexOptions(e){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:e.scale};case"grid":{const t=this._schema.index.fixedBinLevel,s=null!=t?e.tileInfoView.getLODInfoAt(t).scale:e.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:s}}}}async*_update(e,t){const{handledChunks:a,subscription:r,bins:i,featureCache:o}=e,n=r.tile;if(e.done)return;for(const s of t.chunks()){if(a.has(s.chunkId))continue;a.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new g(t.tileId);if(e.level!==n.level||e.world!==n.key.world)continue}s.getAggregateIndex(this._createIndexOptions(e.tile)).putBounded(i,e.tile.extent,e.tile.resolution)}const l=[],c=r.tile.transform,u=r.tile.key.level;for(const d of i.values()){let e=o.get(d.id);if(e)e.attributes=d.getAttributes();else{const t=d.getGeometry(this.spatialReference,c);e=new s(t,d.getAttributes(),null),t||(e.centroid=d.getGeometricCentroid(this.spatialReference,c)),e.objectId=d.id,e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${u}`),o.set(d.id,e)}l.push(e)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const f=h.fromOptimizedFeatures(l,this._metadata,c),p=f.getCursor(),m=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo);for(;p.next();)this._attributeStore.setAttributeData(p.getDisplayId(),p,m);const y=new d(e.subscription,f,[],e.done,{});yield y}}export{y as BinningState,I as BinningStrategy};
5
+ import"../../../../../geometry.js";import{unquantizeOptimizedGeometry as e,convertToFeature as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as s}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as r}from"../../../../../layers/graphics/data/projectionSupport.js";import a from"../../../../../layers/support/FieldsIndex.js";import{ComputedAggregateField as i}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as n}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as l,FeatureTileUpdateMessage as d}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as c}from"../support/ComputedAttributeStorage.js";import u from"../support/FeatureFilter.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as p}from"../support/FeatureSetReaderJSON.js";import h from"../../../tiling/TileKey.js";import g from"../../../../../geometry/SpatialReference.js";class m extends n{constructor(e,t){super(e),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.done=!1}destroy(){const e=this.subscription.tile.key.level;for(const t of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${t}.${e}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const s=t.clone();s.geometry&&e(s.geometry,s.geometry,!1,!1,this.subscription.tile.transform),yield s}}}class y extends o{static async create(e,t,s,a,o){const n=new c({spatialReference:t}),l=await Promise.all(e.fields.map((async e=>i.create(n,e)))),d=e.featureFilter?await u.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return"geohash"===e.index.type&&await r(t,g.WGS84),new y(e,d,o,l,t,s,a)}constructor(e,t,s,r,i,o,n){super(o,n,i,r),this._schema=e,this._featureFilter=t,this._arcadeContextInfo=s,this._metadata=f.createFeature({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fieldsIndex:new a(e.fields).toJSON(),globalIdField:null,spatialReference:o.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new m(e,this._attributeStore)}async*applyOverrideUpdate(e){for(const t of this._sendStates.values()){t.reset();const e=new l(t.subscription,p.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),a=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace()){const{objectId:t,displayId:i}=e,o=r.get(t);if(null!=o){const e=s(i,o,t);a.push(e),r.delete(t)}}return a}getDisplayFeatures(e){const s=new Set(e),r=new Set,a=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace())s.has(e.displayId)&&!r.has(e.objectId)&&(e.geometry&&a.push({...t(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),r.add(e.objectId));return{features:[],aggregates:a}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.containedObjectIds);return[]}async*updateChunks(){for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){const t=new Set;for(const s of this._sendStates.values())for(const r of s.featuresWorldSpace())t.has(r.objectId)||(e(r),t.add(r.objectId))}_createIndexOptions(e){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:e.scale};case"grid":{const t=this._schema.index.fixedBinLevel,s=null!=t?e.tileInfoView.getLODInfoAt(t).scale:e.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:s}}}}async*_update(e,t){const{handledChunks:r,subscription:a,bins:i,featureCache:o}=e,n=a.tile;if(e.done)return;for(const s of t.chunks()){if(r.has(s.chunkId))continue;r.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new h(t.tileId);if(e.level!==n.level||e.world!==n.key.world)continue}s.getAggregateIndex(this._createIndexOptions(e.tile)).putBounded(i,e.tile.extent,e.tile.resolution)}const l=[],c=a.tile.transform,u=a.tile.key.level;for(const d of i.values()){let e=o.get(d.id);if(e)e.attributes=d.getAttributes();else{const t=d.getGeometry(this.spatialReference,c);e=new s(t,d.getAttributes(),null,d.id),t||(e.centroid=d.getGeometricCentroid(this.spatialReference,c)),e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${u}`),o.set(d.id,e)}l.push(e)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const f=p.fromOptimizedFeatures(l,this._metadata,c),g=f.getCursor(),m=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo);for(;g.next();)this._attributeStore.setAttributeData(g.getDisplayId(),g,m);const y=new d(e.subscription,f,[],e.done,{});yield y}}export{m as BinningState,y as BinningStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{convertToFeature as e}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as t}from"../../../../../layers/graphics/OptimizedFeature.js";import s from"../../../../../layers/graphics/OptimizedGeometry.js";import i from"../../../../../layers/support/FieldsIndex.js";import{tileSize as r}from"../../../engine/webgl/definitions.js";import{ComputedAggregateField as n}from"../aggregation/ComputedAggregateField.js";import{GridCell as a}from"../aggregation/GridCell.js";import{pixelsPerMapUnit as l}from"../aggregation/GridSpatialIndex.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as d}from"./AProcessorStrategy.js";import{WithDisplayId as c}from"./support/WithDisplayId.js";import{FeatureTileAppendMessage as u}from"../sources/FeatureSourceMessage.js";import{isLocalEditChunk as h}from"../sources/strategies/chunks/OverrideChunk.js";import{ComputedAttributeStorage as p}from"../support/ComputedAttributeStorage.js";import f from"../support/FeatureFilter.js";import{FeatureMetadata as g}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as _}from"../support/FeatureSetReaderJSON.js";import m from"../../../tiling/TileKey.js";const y=128;class S extends d{constructor(e){super(e),this.didSend=!1,this.done=!1}}class I{constructor(e,t,s,i,r){this._level=e,this._scale=t,this._indexOptions=s,this._clusterRadius=i,this._store=r,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const e of this._clusters.values())this._store.releaseDisplayIdForObjectId(e.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const e of this._clusters.values()){const s=e.inner.getCentroid(null),i=new t(s,e.inner.getAttributes(),null);i.objectId=e.inner.id,i.displayId=e.displayId,yield i}}clusters(){return this._clusters.values()}updateChunks(e,t){let s=!1;for(const a of e){const e=a.queryInfo;if("tileId"in e){if(new m(e.tileId).level!==this._level)continue}if(!this._handledChunks.has(a.normalizedChunkId)){this._handledChunks.add(a.normalizedChunkId),s=!0;a.getAggregateIndex({...this._indexOptions,scale:this._scale}).put(this._cells)}}const i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=l(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:a}of t){const e=a.tile.bounds,t=Math.floor(e[0]*r/n),s=Math.floor(e[1]*r/n),l=Math.ceil(e[2]*r/n),o=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,t),i.yMin=Math.min(i.yMin,s),i.xMax=Math.max(i.xMax,l),i.yMax=Math.max(i.yMax,o)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),s}async updateStatistics(e){let t=!1;for(const s of this._clusters.values())s.inner.count>1&&(t=this._updateAggregateStatistics(this._statistics,s.inner)||t);if(t){const t=Array.from(this._statistics.entries()).map((([e,t])=>({fieldName:e,minValue:t.minValue,maxValue:t.maxValue})));await e.container.updateStatistics(this._level,t)}}createAggregateFeatures(e,i){const n=e.subscription,a=[],l=n.tile.transform;for(const o of this._clusters.values()){let e=o.inner.getCentroidX(l);const i=o.inner.getCentroidY(l),d=n.tile.lod,c=d.wrap?d.worldSize[0]:null,u=1===o.inner.count?o.inner.firstObjectId:o.inner.id,h=o.displayId;if(null!=c)if(1===c){const n=new s([],[e,i]),l=new t(n,o.inner.getAttributes(),null);l.geometry.coords[0]-=r,l.objectId=u,l.displayId=h,a.push(l);const d=new s([],[e,i]),c=new t(d,o.inner.getAttributes(),null);c.geometry.coords[0]+=r,c.objectId=u,c.displayId=h,a.push(c)}else e>r+r/2?e-=c*r:e<-r/2&&(e+=c*r);if(e<r+y&&e>=-y&&i<r+y&&i>=-y){const r=new s([],[e,i]),n=new t(r,o.inner.getAttributes(),null);n.objectId=u,n.displayId=h,a.push(n)}}return _.fromOptimizedFeatures(a,i,n.tile.transform)}_clusterCells(e){let t=Array.from(this._cells.values());t=t.sort(((e,t)=>t.count-e.count));const s=[];for(const a of this._clusters.values())s.push(a.inner.id);this._clusters.clear();const i=this._clusterRadius*(1/l(this._indexOptions.spatialReference,this._scale)),r=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const l of t){if(n.has(l.id))continue;if(l.gridX<e.xMin||l.gridX>e.xMax||l.gridY<e.yMin||l.gridY>e.yMax)continue;const t=this._store.createDisplayIdForObjectId(l.id),s=new c(l.clone(),t);n.add(l.id),this._clusters.set(l.id,s);const o=l.centroidXWorld,d=l.centroidYWorld;for(let e=l.gridY-r;e<=l.gridY+r;e++)for(let t=l.gridX-r;t<=l.gridX+r;t++){if(e===l.gridY&&t===l.gridX)continue;const r=this._cells.get(a.createId(t,e));if(!r||n.has(r.id))continue;const c=Math.abs(r.centroidXWorld-o),u=Math.abs(r.centroidYWorld-d);c<i&&u<i&&(s.inner.merge(r),n.add(r.id))}}for(const a of s)this._store.releaseDisplayIdForObjectId(a)}_updateAggregateStatistics(e,t){let s=!1;for(const i of t.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const t=i.value,r=i.field,n=e.get(r.name);if(n){const{minValue:e,maxValue:i}=n,r=Math.min(n.minValue,t),a=Math.max(n.maxValue,t);e===r&&i===a||(n.minValue=r,n.maxValue=a,s=!0)}else e.set(r.name,{minValue:t,maxValue:t}),s=!0}return s}}class x extends o{static async create(e,t,s,i,r,a){const l=new p({spatialReference:s}),o={type:"grid",fields:await Promise.all(t.fields.map((async e=>n.create(l,e)))),spatialReference:s,featureFilter:t.featureFilter?await f.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:t.featureFilter}):null,cellSize:t.clusterRadius/4,arcadeContextInfo:a};return new x(e,t.clusterRadius,o,t.fields,i,r)}constructor(e,t,s,r,n,a){super(n,a,s.spatialReference,s.fields),this._connection=e,this._clusterRadius=t,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=g.createFeature({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fieldsIndex:new i([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const e of this._cellsPerScale.values())e.destroy();this._cellsPerScale.clear()}onSubscribe(e){super.onSubscribe(e),this._requiredLevel=e.tile.level,this._requiredScale=e.tile.scale}createState(e){return new S(e)}async*applyLocalEdit(e){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(e,t,s){const i=new Map(e.map((e=>[t(e),e]))),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const a of n.clusters()){const e=i.get(a.inner.id);if(null==e){if(1===a.inner.count){const{firstObjectId:e}=a.inner,t=e?i.get(e):null;if(null!=t){const n=s(a.displayId,t,e);r.push(n),i.delete(e)}}}else{const t=s(a.displayId,e,a.inner.id);r.push(t),i.delete(a.inner.id)}}return r}getDisplayFeatures(t){const s=new Set(t),i=new Set,r=[],n=[],a=this._getClusterState(this._requiredLevel,this._requiredScale);for(const l of a.aggregatesWorldSpace())if(s.has(l.displayId)&&!i.has(l.displayId)){const t=e(l,this._metadata.geometryType,!1,!1);if(i.add(l.displayId),1===t.attributes.cluster_count){r.push({...t,displayId:l.displayId});continue}n.push({...t,displayId:l.displayId})}return{features:r,aggregates:n}}getFeatureObjectIdsForAggregate(e){const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.clusters())if(s.inner.id===e)return Array.from(s.inner.containedObjectIds);return[]}async*updateChunks(){const e=this._source.chunks();if(!e.length)return;for(const n of e)h(n)&&n.lastLocalEditDropped!==this._lastHandledLocalEdit&&(this.invalidate(),this._lastHandledLocalEdit=n.lastLocalEditDropped);const t=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter((e=>e.subscription.tile.level===this._requiredLevel));if(t.updateChunks(e,s)||!this._source.updateTracking.updating)for(const n of s)n.subscription.tile.level===this._requiredLevel&&(n.didSend=!1,n.done=!1);const i=Array.from(this._sendStates.values()).filter((e=>e.done)).map((e=>e.subscription.tile.key)),r=new Set(i);for(const n of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some((e=>e.containsChild(n.subscription.tile.key))))continue;if(n.subscription.tile.key.getChildKeys().every((e=>r.has(e))))continue}n.didSend||n.subscription.tile.level!==this._requiredLevel||(n.didSend=!0,yield*this._update(n,t,this._source))}await t.updateStatistics(this._connection)}forEachAggregateWorldSpace(e){if(null==this._requiredLevel||null==this._requiredScale)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.aggregatesWorldSpace())e(s)}_getClusterState(e,t){if(null==e||null==t)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(t);return s||(s=new I(e,t,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(t,s)),s}async*_update(e,t,s){if(e.done)return;const i=t.createAggregateFeatures(e,this._metadata);this.events.emit("changed"),e.done=!s.updateTracking.updating;const r=i.getCursor(),n=e.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.arcadeContextInfo);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n);const a=new u(e.subscription,i,!0,e.done,{});yield a}}export{S as ClusterState,x as ClusterStrategy};
5
+ import{convertToFeature as e}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as t}from"../../../../../layers/graphics/OptimizedFeature.js";import s from"../../../../../layers/graphics/OptimizedGeometry.js";import i from"../../../../../layers/support/FieldsIndex.js";import{tileSize as r}from"../../../engine/webgl/definitions.js";import{ComputedAggregateField as n}from"../aggregation/ComputedAggregateField.js";import{GridCell as a}from"../aggregation/GridCell.js";import{pixelsPerMapUnit as l}from"../aggregation/GridSpatialIndex.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as d}from"./AProcessorStrategy.js";import{WithDisplayId as u}from"./support/WithDisplayId.js";import{FeatureTileAppendMessage as c}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as h}from"../support/ComputedAttributeStorage.js";import p from"../support/FeatureFilter.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as g}from"../support/FeatureSetReaderJSON.js";import _ from"../../../tiling/TileKey.js";const m=128;class y extends d{constructor(e){super(e),this.didSend=!1,this.done=!1}}class S{constructor(e,t,s,i,r){this._level=e,this._scale=t,this._indexOptions=s,this._clusterRadius=i,this._store=r,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const e of this._clusters.values())this._store.releaseDisplayIdForObjectId(e.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const e of this._clusters.values()){const s=e.inner.getCentroid(null),i=new t(s,e.inner.getAttributes(),null,e.inner.id,e.displayId);yield i}}clusters(){return this._clusters.values()}updateChunks(e,t){let s=!1;for(const a of e){const e=a.queryInfo;if("tileId"in e){if(new _(e.tileId).level!==this._level)continue}if(!this._handledChunks.has(a.normalizedChunkId)){this._handledChunks.add(a.normalizedChunkId),s=!0;a.getAggregateIndex({...this._indexOptions,scale:this._scale}).put(this._cells)}}const i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=l(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:a}of t){const e=a.tile.bounds,t=Math.floor(e[0]*r/n),s=Math.floor(e[1]*r/n),l=Math.ceil(e[2]*r/n),o=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,t),i.yMin=Math.min(i.yMin,s),i.xMax=Math.max(i.xMax,l),i.yMax=Math.max(i.yMax,o)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),s}async updateStatistics(e){let t=!1;for(const s of this._clusters.values())s.inner.count>1&&(t=this._updateAggregateStatistics(this._statistics,s.inner)||t);if(t){const t=Array.from(this._statistics.entries()).map((([e,t])=>({fieldName:e,minValue:t.minValue,maxValue:t.maxValue})));await e.container.updateStatistics(this._level,t)}}createAggregateFeatures(e,i){const n=e.subscription,a=[],l=n.tile.transform;for(const o of this._clusters.values()){let e=o.inner.getCentroidX(l);const i=o.inner.getCentroidY(l),d=n.tile.lod,u=d.wrap?d.worldSize[0]:null,c=1===o.inner.count?o.inner.firstObjectId:o.inner.id,h=o.displayId;if(null!=u)if(1===u){const n=new s([],[e,i]),l=new t(n,o.inner.getAttributes(),null,c,h);l.geometry.coords[0]-=r,a.push(l);const d=new s([],[e,i]),u=new t(d,o.inner.getAttributes(),null,c,h);u.geometry.coords[0]+=r,a.push(u)}else e>r+r/2?e-=u*r:e<-r/2&&(e+=u*r);if(e<r+m&&e>=-m&&i<r+m&&i>=-m){const r=new s([],[e,i]),n=new t(r,o.inner.getAttributes(),null,c,h);a.push(n)}}return g.fromOptimizedFeatures(a,i,n.tile.transform)}_clusterCells(e){let t=Array.from(this._cells.values());t=t.sort(((e,t)=>t.count-e.count));const s=[];for(const a of this._clusters.values())s.push(a.inner.id);this._clusters.clear();const i=this._clusterRadius*(1/l(this._indexOptions.spatialReference,this._scale)),r=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const l of t){if(n.has(l.id))continue;if(l.gridX<e.xMin||l.gridX>e.xMax||l.gridY<e.yMin||l.gridY>e.yMax)continue;const t=this._store.createDisplayIdForObjectId(l.id),s=new u(l.clone(),t);n.add(l.id),this._clusters.set(l.id,s);const o=l.centroidXWorld,d=l.centroidYWorld;for(let e=l.gridY-r;e<=l.gridY+r;e++)for(let t=l.gridX-r;t<=l.gridX+r;t++){if(e===l.gridY&&t===l.gridX)continue;const r=this._cells.get(a.createId(t,e));if(!r||n.has(r.id))continue;const u=Math.abs(r.centroidXWorld-o),c=Math.abs(r.centroidYWorld-d);u<i&&c<i&&(s.inner.merge(r),n.add(r.id))}}for(const a of s)this._store.releaseDisplayIdForObjectId(a)}_updateAggregateStatistics(e,t){let s=!1;for(const i of t.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const t=i.value,r=i.field,n=e.get(r.name);if(n){const{minValue:e,maxValue:i}=n,r=Math.min(n.minValue,t),a=Math.max(n.maxValue,t);e===r&&i===a||(n.minValue=r,n.maxValue=a,s=!0)}else e.set(r.name,{minValue:t,maxValue:t}),s=!0}return s}}class x extends o{static async create(e,t,s,i,r,a){const l=new h({spatialReference:s}),o={type:"grid",fields:await Promise.all(t.fields.map((async e=>n.create(l,e)))),spatialReference:s,featureFilter:t.featureFilter?await p.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:t.featureFilter}):null,cellSize:t.clusterRadius/4,arcadeContextInfo:a};return new x(e,t.clusterRadius,o,t.fields,i,r)}constructor(e,t,s,r,n,a){super(n,a,s.spatialReference,s.fields),this._connection=e,this._clusterRadius=t,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=f.createFeature({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fieldsIndex:new i([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const e of this._cellsPerScale.values())e.destroy();this._cellsPerScale.clear()}onSubscribe(e){super.onSubscribe(e),this._requiredLevel=e.tile.level,this._requiredScale=e.tile.scale}createState(e){return new y(e)}async*applyOverrideUpdate(e){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(e,t,s){const i=new Map(e.map((e=>[t(e),e]))),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const a of n.clusters()){const e=i.get(a.inner.id);if(null==e){if(1===a.inner.count){const{firstObjectId:e}=a.inner,t=e?i.get(e):null;if(null!=t){const n=s(a.displayId,t,e);r.push(n),i.delete(e)}}}else{const t=s(a.displayId,e,a.inner.id);r.push(t),i.delete(a.inner.id)}}return r}getDisplayFeatures(t){const s=new Set(t),i=new Set,r=[],n=[],a=this._getClusterState(this._requiredLevel,this._requiredScale);for(const l of a.aggregatesWorldSpace())if(s.has(l.displayId)&&!i.has(l.displayId)){const t=e(l,this._metadata.geometryType,!1,!1);if(i.add(l.displayId),1===t.attributes.cluster_count){r.push({...t,displayId:l.displayId});continue}n.push({...t,displayId:l.displayId})}return{features:r,aggregates:n}}getFeatureObjectIdsForAggregate(e){const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.clusters())if(s.inner.id===e)return Array.from(s.inner.containedObjectIds);return[]}async*updateChunks(){const e=this._source.chunks();if(!e.length)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter((e=>e.subscription.tile.level===this._requiredLevel));if(t.updateChunks(e,s)||!this._source.updateTracking.updating)for(const n of s)n.subscription.tile.level===this._requiredLevel&&(n.didSend=!1,n.done=!1);const i=Array.from(this._sendStates.values()).filter((e=>e.done)).map((e=>e.subscription.tile.key)),r=new Set(i);for(const n of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some((e=>e.containsChild(n.subscription.tile.key))))continue;if(n.subscription.tile.key.getChildKeys().every((e=>r.has(e))))continue}n.didSend||n.subscription.tile.level!==this._requiredLevel||(n.didSend=!0,yield*this._update(n,t,this._source))}await t.updateStatistics(this._connection)}forEachAggregateWorldSpace(e){if(null==this._requiredLevel||null==this._requiredScale)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.aggregatesWorldSpace())e(s)}_getClusterState(e,t){if(null==e||null==t)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(t);return s||(s=new S(e,t,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(t,s)),s}async*_update(e,t,s){if(e.done)return;const i=t.createAggregateFeatures(e,this._metadata);this.events.emit("changed"),e.done=!s.updateTracking.updating;const r=i.getCursor(),n=e.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.arcadeContextInfo);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n);const a=new c(e.subscription,i,!0,e.done,{});yield a}}export{y as ClusterState,x as ClusterStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import{ASendState as e,AProcessorStrategy as t}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as s,FeatureTileAppendMessage as r}from"../sources/FeatureSourceMessage.js";import{OverrideChunk as a}from"../sources/strategies/chunks/OverrideChunk.js";import{createArcadeEvaluationOptions as o}from"../support/arcadeUtils.js";class n extends e{}class d extends t{constructor(e,t,s){super(e,t),this._arcadeContextInfo=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(e){this.handledChunksForAttributeData.clear(),this._arcadeContextInfo=e,this._evalOptions=o(this._evalOptions.$view.scale,e)}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.createArcadeEvaluationOptions(this._arcadeContextInfo)}createState(e){return new n(e)}get aggregateQueryEngine(){return null}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),a=[];for(const o of this._source.chunks()){const e=o.reader.getCursor();for(;e.next();){const t=e.getObjectId(),o=e.getDisplayId(),n=r.get(t);if(null!=n){const e=s(o,n,t);a.push(e),r.delete(t)}}}return a}getDisplayFeatures(e){const t=new Set(e),s=new Set,r=[];for(const a of this._source.chunks()){const e=a.reader.getCursor();for(;e.next();){const a=e.getObjectId(),o=e.getDisplayId();t.has(o)&&!s.has(a)&&(r.push({...e.readLegacyFeatureWorldSpace(),displayId:o}),s.add(a))}}return{features:r,aggregates:[]}}async*applyLocalEdit(e){const t=[],r=e.reader.getCursor();for(;r.next();){const e=r.getObjectId(),s=this._attributeStore.createDisplayIdForObjectId(e);r.setDisplayId(s),this._attributeStore.setAttributeData(s,r,this._evalOptions),t.push(s)}const o=[];for(const s of e.removed){const e=this._attributeStore.getDisplayIdForObjectId(s);null!=e&&o.push(e)}has("esri-2d-update-debug")&&console.debug("FeatureUpdateStrategy.applyLocalEdit",{message:e,modifiedDisplayIds:t,removedDisplayIds:o});const n=new a(this._source.metadata,"localEdit");n.applyOverrides(e),this.handledChunks.add(n.chunkId),this.handledChunksForAttributeData.add(n.chunkId),this.handledChunksForIdCreation.add(n.chunkId);for(const a of this._sendStates.values())a.handledChunks.add(n.chunkId),yield new s(a.subscription,null,t,!1,n.queryInfo);for(const a of this._sendStates.values()){const e=n.getTileReader(a.subscription.tile);yield new s(a.subscription,e,o,!1,n.queryInfo)}for(const s of e.removed)this._attributeStore.releaseDisplayIdForObjectId(s)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}afterUpdateChunks(){for(const e of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(e);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(e):this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}async _updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:s}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=s.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions)}}}*_update(e){const{subscription:t,handledChunks:s}=e;for(const a of this._source.chunks()){const{chunkId:o}=a;if(s.has(o))continue;s.add(o);const n=a.getTileReader(t.tile);n&&(yield new r(e.subscription,n,!1,a.end,a.queryInfo))}}}export{n as DefaultSendState,d as FeatureUpdateStrategy};
5
+ import has from"../../../../../core/has.js";import{ASendState as e,AProcessorStrategy as t}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as s,FeatureTileAppendMessage as r}from"../sources/FeatureSourceMessage.js";import{OverrideChunk as o}from"../sources/strategies/chunks/Overrides.js";import{createArcadeEvaluationOptions as a}from"../support/arcadeUtils.js";import{FeatureSetReaderJSON as n}from"../support/FeatureSetReaderJSON.js";class d extends e{}class i extends t{constructor(e,t,s){super(e,t),this._arcadeContextInfo=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(e){this.handledChunksForAttributeData.clear(),this._arcadeContextInfo=e,this._evalOptions=a(this._evalOptions.$view.scale,e)}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.createArcadeEvaluationOptions(this._arcadeContextInfo)}createState(e){return new d(e)}get aggregateQueryEngine(){return null}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),o=[];for(const a of this._source.chunks()){const e=a.reader.getCursor();for(;e.next();){const t=e.getObjectId(),a=e.getDisplayId(),n=r.get(t);if(null!=n){const e=s(a,n,t);o.push(e),r.delete(t)}}}return o}getDisplayFeatures(e){const t=new Set(e),s=new Set,r=[];for(const o of this._source.chunks()){const e=o.reader.getCursor();for(;e.next();){const o=e.getObjectId(),a=e.getDisplayId();t.has(a)&&!s.has(o)&&(r.push({...e.readLegacyFeatureWorldSpace(),displayId:a}),s.add(o))}}return{features:r,aggregates:[]}}async*applyOverrideUpdate(e){const t=[];for(const s of e.modified){const e=this._attributeStore.createDisplayIdForObjectId(s.objectId);s.displayId=e,t.push(e)}const r=n.fromOptimizedFeatures(e.modified,this._source.metadata).getCursor();for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,this._evalOptions);const a=[];for(const s of e.removed){const e=this._attributeStore.getDisplayIdForObjectId(s);null!=e&&a.push(e)}has("esri-2d-update-debug")&&console.debug("FeatureUpdateStrategy.applyLocalEdit",{message:e,modifiedDisplayIds:t,removedDisplayIds:a});const d=o.fromFeatures(e.modified,this._source.metadata);this.handledChunks.add(d.chunkId),this.handledChunksForAttributeData.add(d.chunkId),this.handledChunksForIdCreation.add(d.chunkId);for(const o of this._sendStates.values())o.handledChunks.add(d.chunkId),yield new s(o.subscription,null,t,!1,d.queryInfo);for(const o of this._sendStates.values()){const e=d.getTileReader(o.subscription.tile);yield new s(o.subscription,e,a,!1,d.queryInfo)}for(const s of e.removed)this._attributeStore.releaseDisplayIdForObjectId(s)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}afterUpdateChunks(){for(const e of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(e);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(e):this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}async _updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:s}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=s.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions)}}}*_update(e){const{subscription:t,handledChunks:s}=e;for(const o of this._source.chunks()){const{chunkId:a}=o;if(s.has(a))continue;s.add(a);const n=o.getTileReader(t.tile);n&&(yield new r(e.subscription,n,!1,o.end,o.queryInfo))}}}export{d as DefaultSendState,i as FeatureUpdateStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as e,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{OptimizedFeature as o}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as n}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as d}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as c}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as u}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as l}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as m}from"./strategies/PagedTileLoadStrategy.js";import{ParquetLoadStrategy as p}from"./strategies/ParquetLoadStrategy.js";import{SnapshotLoadStrategy as _}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as g}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as y}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as v}from"../support/FeatureSetReaderJSON.js";import{UpdateTracking2D as S}from"../../support/UpdateTracking2D.js";class b{constructor(t,e,s,r,a){this.service=t,this._aggregateAdapter=e,this._subscriptions=s,this._onChange=r,this._connection=a,this._updateTracking=new S({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._store=new y(this._onChange),this._metadata=f.createFeature(t.metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((t=>t.close()))}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:t}=this._schema.mutable,e=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new n({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:t.definitionExpression,availableFields:e})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(t){this._connection.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._connection.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._connection.onEvent({type:"error",tile:t.tile.id,error:e}))),this._updateTracking.addPromise(e))}onResume(t){this._updateTracking.addPromise(e(this._strategy?.load(t)))}onUnsubscribe(t){this._connection.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}getLocalEdit(t){return this._updateTracking.addPromise(this._getGetLocalEdit(t))}applyLocalEdit(t){this._didInvalidateData=!0,this._store.applyLocalEdit(t,this.metadata)}async update(t,e){const s=t.source,o=r(this._schema?.mutable,s.mutable);if(!o)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:o}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(o,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if(("feature"===s.type||"parquet"===s.type)&&a(o,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(e);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(n){this._connection.onEvent({type:"updateFieldsError",error:n})}}return!1}return!(!i(o,"dataFilter")&&!i(o,"sourceRefreshVersion"))&&(await this._updateStrategy(e),!0)}async addParquetFile(t){this._strategy.addParquetFile(t)}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new u(this._connection))}async _getGetLocalEdit(t){if(t.historicMoment&&"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=t.historicMoment,this._strategy.unsafeSetQueryHistoricMoment(new Date(t.historicMoment))),"edit-by-feature"===t.type){const e=[...t.added,...t.updated].map((t=>o.fromJSON(t,this.metadata.objectIdField)));return{reader:v.fromOptimizedFeatures(e,this.metadata),removed:this._resolveIdentifiers(t.removed)}}const e=this._resolveIdentifiers(t.removed);if(!t.updated.length&&!t.added.length)return{reader:v.empty(this.metadata),removed:e};const s=this._resolveIdentifiers([...t.added,...t.updated]);return{reader:await this._strategy.queryByObjectId(s),removed:e}}_resolveIdentifiers(t){const e=[],s=[];for(const r of t)null!=r.objectId&&-1!==r.objectId?s.push(r.objectId):e.push(r.globalId);if(e.length){const t=new Set(e),r=this.metadata.globalIdField;if(null==r)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");this._store.forEachUnsafe((e=>{const a=e.readAttribute(r);t.has(a)&&s.push(e.getObjectId())}))}return s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const e=this.service.source,s={...e.query,f:"json"},r=(await t(e.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const t="isSourceHosted"in this.service&&this.service.isSourceHosted,e=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=t||e||s;if("stream"===this._schema.type){const t=new g(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}if("parquet"===this._schema.type){const t=this.service;return new p(t,this._metadata,this._schema,this._store)}const a=this.service,i=c.fromSchema(a,this._schema,this._metadata),o=await this._supportSnapshotMode(a,i);return o?new _(a,i,this._store,o.featureCount,this.metadata,this._connection):r?new m(a,i,this._store,this.metadata,this._connection):new l(a,i,this._store,this.metadata,this._connection)}async _updateStrategy(t){const e=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:e.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=e,has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategy`,{strategy:e});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((t=>this._strategy.load(t).then((()=>this._connection.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._connection.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(o){s(o)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategyEnd`,{strategy:e})}async _supportSnapshotMode(t,e){const{queryMetadata:s}=t,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=t.source,i=e.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const o=(await d(a,i.inner,{query:i.customParameters})).data.count,{min:n,max:h}=r.snapshotCountThresholds;return o<=n||r.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}export{b as FeatureSource};
5
+ import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{OptimizedFeature as n}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as o}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as d}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as u}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as c}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as m}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as p}from"./strategies/PagedTileLoadStrategy.js";import{ParquetLoadStrategy as l}from"./strategies/ParquetLoadStrategy.js";import{SnapshotLoadStrategy as _}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as y}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{UpdateTracking2D as v}from"../../support/UpdateTracking2D.js";class S{constructor(e,t,s,r,a){this.service=e,this._aggregateAdapter=t,this._subscriptions=s,this._onChange=r,this._connection=a,this._updateTracking=new v({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._metadata=f.createFeature(e.metadata),this._store=new g(this._onChange,this._metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((e=>e.close()))}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new o({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._connection.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._connection.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}applyOverride(e){this._didInvalidateData=!0,this._store.applyOverride(e)}takeOverrideUpdate(){return this._store.takeOverrideUpdate()}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if(("feature"===s.type||"parquet"===s.type)&&a(n,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(t);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(o){this._connection.onEvent({type:"updateFieldsError",error:o})}}return!1}return!(!i(n,"dataFilter")&&!i(n,"sourceRefreshVersion"))&&(await this._updateStrategy(t),!0)}async addParquetFile(e){this._strategy.addParquetFile(e)}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new c(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(n.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(n.fromJSON),remove:e.commands.remove,release:e.commands.release}},s=e.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(s);return t.commands.updateWeak.push(...r),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],s=(await this._strategy.queryByObjectId(e)).getCursor();for(;s.next();)t.push(s.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=new Set(e),s=this.metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=[];return this._store.forEachUnsafe((e=>{const a=e.readAttribute(s);if(t.has(a)){const t=e.getObjectId();null!=t&&r.push(t)}})),r}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e="isSourceHosted"in this.service&&this.service.isSourceHosted,t=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=e||t||s;if("stream"===this._schema.type){const e=new y(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}if("parquet"===this._schema.type){const e=this.service;return new l(e,this._metadata,this._schema,this._store)}const a=this.service,i=u.fromSchema(a,this._schema,this._metadata),n=await this._supportSnapshotMode(a,i);return n?new _(a,i,this._store,n.featureCount,this.metadata,this._connection):r?new p(a,i,this._store,this.metadata,this._connection):new m(a,i,this._store,this.metadata,this._connection)}async _updateStrategy(e){const t=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._connection.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await d(a,i.inner,{query:i.customParameters})).data.count,{min:o,max:h}=r.snapshotCountThresholds;return n<=o||r.supportsSnapshotMaxThreshold&&n<h?{featureCount:n}:null}}export{S as FeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- class r{constructor(r){this._store=r,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}unsafeSetQueryHistoricMoment(r){throw new Error("InternalError: LoadStrategy does not support query info")}async queryOverride(r){throw new Error("InternalError: LoadStrategy does not support fetching")}async queryByObjectId(r){throw new Error("InternalError: LoadStrategy does not support fetching")}async addParquetFile(r){throw new Error("InternalError: LoadStrategy does not support loading blobs")}}export{r as ALoadStrategy};
5
+ class r{constructor(r){this._store=r,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}unsafeSetQueryHistoricMoment(r){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(r){throw new Error("InternalError: LoadStrategy does not support fetching")}async addParquetFile(r){throw new Error("InternalError: LoadStrategy does not support loading blobs")}}export{r as ALoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{FeatureSpatialIndex as e}from"../../../FeatureSpatialIndex.js";import{GeohashSpatialIndex as t}from"../../../aggregation/GeohashSpatialIndex.js";import{GridSpatialIndex as a}from"../../../aggregation/GridSpatialIndex.js";import{FeatureSetReaderIndirect as r}from"../../../support/FeatureSetReaderIndirect.js";class i{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._aggregateIndex=null,this._aggregateIndexHash=null,this._spatialIndex=null}queryFeaturesInBounds(e){const t=this._getSpatialIndex().search(e);return r.from(this.reader,t)}getAggregateIndex(e){const r=JSON.stringify(e);if(r!==this._aggregateIndexHash){switch(this._aggregateIndexHash=r,e.type){case"grid":this._aggregateIndex=new a(e);break;case"geohash":this._aggregateIndex=new t(e)}this._aggregateIndex.insert(this.reader,this.isTiled)}return this._aggregateIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=e.fromReader(this.reader)),this._spatialIndex}}export{i as ASourceChunk};
5
+ import{FeatureSpatialIndex as e}from"../../../FeatureSpatialIndex.js";import{GeohashSpatialIndex as t}from"../../../aggregation/GeohashSpatialIndex.js";import{GridSpatialIndex as r}from"../../../aggregation/GridSpatialIndex.js";import{FeatureSetReaderIndirect as a}from"../../../support/FeatureSetReaderIndirect.js";class i{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._aggregateIndex=null,this._aggregateIndexHash=null,this._spatialIndex=null}registerOverrides(e){this.reader.registerOverrides(e),this.invalidate()}queryFeaturesInBounds(e){const t=this._getSpatialIndex().search(e);return a.from(this.reader,t)}getAggregateIndex(e){const a=JSON.stringify(e);if(a!==this._aggregateIndexHash){switch(this._aggregateIndexHash=a,e.type){case"grid":this._aggregateIndex=new r(e);break;case"geohash":this._aggregateIndex=new t(e)}this._aggregateIndex.insert(this.reader,this.isTiled)}return this._aggregateIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=e.fromReader(this.reader)),this._spatialIndex}}export{i as ASourceChunk};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as t}from"../../../support/FeatureSetReaderJSON.js";class s{constructor(){this.modified=[],this.removed=[]}modify(e){this.modified.push(e)}remove(e){this.removed.push(e)}get isEmpty(){return 0===this.modified.length&&0===this.removed.length}}class r extends e{constructor(e){super(),this._reader=e,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(e,s){const i=t.fromOptimizedFeatures(e,s);return new r(i)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(e){if(!this._reader.getSize())return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class i{constructor(e,t){this.inner=e,this.isWeak=t,this.lastWeak=null}}class o{constructor(){this._overrides=new Map,this._update=new s}hasOverride(e){return this._overrides.has(e)}onChunkInsert(e){if(this._overrides.size){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),s=this._overrides.get(e);s?.lastWeak&&(s.lastWeak=null),s?.isWeak&&(this._overrides.delete(e),this._update.remove(e),this.invalidate())}}e.registerOverrides(this)}apply(e,t){const{updateWeak:s,removeWeak:r,update:o,remove:n,release:d}=e.commands;this.invalidate();for(const a of s)this._overrides.set(a.objectId,new i(a,!0)),this._update.modify(a);for(const a of o){const e=new i(a,!1),t=this._overrides.get(a.objectId);t?.isWeak&&(e.lastWeak=t),this._overrides.set(a.objectId,e),this._update.modify(a)}for(const a of r)this._overrides.set(a,new i(null,!0)),this._update.remove(a);for(const a of n){const e=new i(null,!1),t=this._overrides.get(a);t?.isWeak&&(e.lastWeak=t),this._overrides.set(a,e),this._update.remove(a)}if(d.length){const e=new Set;for(const t of d){const s=this._overrides.get(t);s?.lastWeak?this._overrides.set(t,s.lastWeak):s&&!s.isWeak&&(this._overrides.delete(t),e.add(t))}t.forEachUnsafe((t=>{const s=t.getObjectId();e.has(s)&&(this._update.modify(t.readOptimizedFeatureWorldSpace()),e.delete(s))}));for(const t of e.values())this._update.remove(t)}}takeOverrideUpdate(){const e=this._update;return e.isEmpty?null:(this._update=new s,e)}asChunk(e){if(!this._chunk){const t=[];for(const e of this._overrides.values())null!=e.inner&&t.push(e.inner);this._chunk=r.fromFeatures(t,e)}return this._chunk}invalidate(){this._chunk=null}}export{r as OverrideChunk,o as OverrideState,s as OverrideUpdate};