@arcgis/core 4.30.0-next.20240518 → 4.30.0-next.20240521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/drawUtils.d.ts +4 -0
- package/applications/Components/getContrastingBackgroundTheme.d.ts +4 -0
- package/applications/Components/gfxUtils.d.ts +4 -0
- package/applications/Components/gfxUtils.js +1 -1
- package/applications/Components/layerOriginUtils.d.ts +4 -0
- package/applications/Components/styleUtils.d.ts +4 -0
- package/applications/Components/svgUtils.d.ts +4 -0
- package/applications/Components/webStyleSymbolUtils.d.ts +4 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{9bf758be13aaa5ebba64.js → 1b4c91833fb7b99c6cfe.js} +1 -1
- package/assets/esri/core/workers/chunks/{1476f4b9ed8a7d3330ce.js → 2f8a51d6b8229a90c240.js} +1 -1
- package/assets/esri/core/workers/chunks/3ad5de35a52b16be8dd5.js +1 -0
- package/assets/esri/core/workers/chunks/{c8628b5e9472e72a9cb3.js → 6d409cb694daa5002747.js} +1 -1
- package/assets/esri/core/workers/chunks/ba988cd3a49987a0fb83.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -0
- package/assets/esri/themes/base/widgets/_Grid.scss +4 -0
- package/assets/esri/themes/base/widgets/_Widget.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ar.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bg.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bs.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ca.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_cs.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_da.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_de.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_el.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_es.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_et.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fi.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_he.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hu.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_id.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_it.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ja.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ko.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lt.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lv.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nb.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-BR.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-PT.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ro.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ru.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sk.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sv.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_th.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_tr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_uk.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_vi.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-CN.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-HK.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-TW.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ar.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_bg.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_bs.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ca.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_cs.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_da.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_de.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_el.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_es.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_et.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_fi.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_fr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_he.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_hr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_hu.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_id.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_it.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ja.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ko.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_lt.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_lv.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_nb.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_nl.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_pl.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_pt-BR.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_pt-PT.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ro.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ru.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sk.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sl.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sv.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_th.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_tr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_uk.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_vi.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_zh-CN.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_zh-HK.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_zh-TW.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nb.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_ar.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_bg.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_bs.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_ca.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_cs.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_da.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_de.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_el.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_es.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_et.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_fi.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_fr.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_he.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_hr.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_hu.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_id.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_it.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_ja.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_ko.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_lt.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_lv.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_nb.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_nl.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_pl.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_pt-BR.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_pt-PT.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_ro.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_ru.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_sk.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_sl.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_sr.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_sv.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_th.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_tr.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_uk.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_vi.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_zh-CN.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_zh-HK.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_zh-TW.json +1 -1
- package/core/Accessor.js +1 -1
- package/core/Collection.js +1 -1
- package/core/Handles.js +1 -1
- package/interfaces.d.ts +203 -29
- package/layers/CatalogLayer.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/catalog/CatalogDynamicGroupLayer.js +1 -1
- package/package.json +1 -1
- package/rest/support/RelationshipQuery.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/AnimationManager.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolRepository.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/RenderState.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/ui/UI.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/assets/esri/core/workers/chunks/92979bf325405d87c090.js +0 -1
- package/assets/esri/core/workers/chunks/ed24ad7c7fbb02c307aa.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{GridIndex as e,isSearchCircleOverlapingSymbol as s,tileCoordChange as l}from"./util.js";const o=32,t=8,i=64;class
|
|
5
|
+
import{GridIndex as e,isSearchCircleOverlapingSymbol as s,tileCoordChange as l}from"./util.js";const o=32,t=8,i=64,n=20;class r{constructor(e,s,l){this.tileCoordRange=e,this._visibleTiles=s,this._createUnique=l,this._tiles=new Map,this._uniqueSymbolsReferences=new Map}get uniqueSymbols(){return null==this._uniqueSymbolLayerArray&&(this._uniqueSymbolLayerArray=this._createUniqueSymbolLayerArray()),this._uniqueSymbolLayerArray}get uniqueSymbolsReferences(){return this._uniqueSymbolsReferences}add(s,l){this._uniqueSymbolLayerArray=null;let n=this._tiles.get(s.id);n||(n={symbols:new Map},this._tiles.set(s.id,n));const r=new Map;if(l)for(const e of l)n.symbols.has(e)&&(r.set(e,n.symbols.get(e)),n.symbols.delete(e));else for(const[e,o]of s.layerData)n.symbols.has(e)&&(r.set(e,n.symbols.get(e)),n.symbols.delete(e));this._removeSymbols(r);const y=s.symbols,a=new Map;for(const[f,u]of y){let s=u.length;if(s>=o){let l=this.tileCoordRange;do{l/=2,s/=4}while(s>t&&l>i);const o=new e(this.tileCoordRange,this.tileCoordRange,l);a.set(f,{flat:u,index:o}),n.symbols.set(f,{flat:u,index:o});for(const e of u)o.getCell(e.xTile,e.yTile).push(e)}else a.set(f,{flat:u}),n.symbols.set(f,{flat:u})}this._addSymbols(s.key,y)}deleteStyleLayers(e){this._uniqueSymbolLayerArray=null;for(const[s,l]of this._tiles){const o=new Map;for(const s of e)l.symbols.has(s)&&(o.set(s,l.symbols.get(s)),l.symbols.delete(s));this._removeSymbols(o),0===l.symbols.size&&this._tiles.delete(s)}}removeTile(e){this._uniqueSymbolLayerArray=null;const s=this._tiles.get(e.id);if(!s)return;const l=new Map;for(const[o,t]of e.symbols)s.symbols.has(o)&&(l.set(o,s.symbols.get(o)),s.symbols.delete(o));this._removeSymbols(l),0===s.symbols.size&&this._tiles.delete(e.id)}querySymbols(e,l,o,t){const i=[],n=this.uniqueSymbols;for(const r of n){const t=r.styleLayerUID,n=r.uniqueSymbols;for(const r of n){const n=r.tileSymbols.find((e=>e.selectedForRendering));n&&s(n,e,l*(window.devicePixelRatio||1),o)&&i.push({vtlSymbol:n,styleLayerUID:t,tileKey:n.tile.key})}}return i}_removeSymbols(e){for(const[s,{flat:l}]of e)for(const e of l){const l=e.unique,o=l.tileSymbols,t=o.length-1;for(let s=0;s<t;s++)if(o[s]===e){o[s]=o[t];break}if(o.length=t,0===t){const e=this._uniqueSymbolsReferences.get(s);e.delete(l),0===e.size&&this._uniqueSymbolsReferences.delete(s)}e.unique=null}}_addSymbols(e,s){if(0===s.size)return;const l=this._visibleTiles;for(const o of l)o.parentTile||o.key.world!==e.world||o.key.level===e.level&&!o.key.equals(e)||this._matchSymbols(o,e,s);for(const[o,t]of s)for(const e of t)if(null==e.unique){const s=this._createUnique();e.unique=s,s.tileSymbols.push(e);let l=this._uniqueSymbolsReferences.get(o);l||(l=new Set,this._uniqueSymbolsReferences.set(o,l)),l.add(s)}}_matchSymbols(e,s,o){if(e.key.level>s.level){const l=e.key.level-s.level;if(e.key.row>>l!==s.row||e.key.col>>l!==s.col)return}if(s.level>e.key.level){const l=s.level-e.key.level;if(s.row>>l!==e.key.row||s.col>>l!==e.key.col)return}if(s.equals(e.key)){for(const l of e.childrenTiles)this._matchSymbols(l,s,o);return}const t=new Map;for(const[i,r]of o){const o=[];for(const t of r){const i=l(this.tileCoordRange,t.xTile,s.level,s.col,e.key.level,e.key.col),n=l(this.tileCoordRange,t.yTile,s.level,s.row,e.key.level,e.key.row);i>=0&&i<this.tileCoordRange&&n>=0&&n<this.tileCoordRange&&o.push({symbol:t,xTransformed:i,yTransformed:n})}const y=[],a=(e.key.level<s.level?1:1<<e.key.level-s.level)+n,f=this._tiles.get(e.id).symbols.get(i);if(f){const e=f.flat;for(const s of o){let l,o=!1;const t=s.xTransformed,i=s.yTransformed;l=null!=f.index?f.index.getCell(t,i):e;const n=s.symbol,r=n.hash;for(const e of l)if(r===e.hash&&Math.abs(t-e.xTile)<=a&&Math.abs(i-e.yTile)<=a){const s=e.unique;n.unique=s,s.tileSymbols.push(n),o=!0;break}o||y.push(n)}}y.length>0&&t.set(i,y)}for(const l of e.childrenTiles)this._matchSymbols(l,s,t)}_createUniqueSymbolLayerArray(){const e=this._uniqueSymbolsReferences,s=new Array(e.size);let l,o=0;for(const[t,i]of e){const e=new Array(i.size);l=0;for(const s of i)e[l++]=s;s[o]={styleLayerUID:t,uniqueSymbols:e},o++}return s}}export{r as SymbolRepository};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/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{deepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,throwIfNotAbortError as d,isAbortError as y}from"../../../core/promiseUtils.js";import{watch as g,initial as f}from"../../../core/reactiveUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import _ from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as v}from"../../../layers/graphics/featureConversionUtils.js";import b from"../../../layers/support/FeatureFilter.js";import{packFields as F}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as A}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as S}from"../../../layers/support/timeSupport.js";import E from"../../../rest/support/AggregateFeatureSet.js";import x from"../../../rest/support/FeatureSet.js";import j from"../../../rest/support/Query.js";import{getHighlightBits as V}from"../engine/highlightReasons.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import{FeatureContainer as R}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as U}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as k}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 Q}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as O}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as L}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as H}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{StreamLayerAdapter as P}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as W}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as T}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import D from"./support/FeatureCommandQueue.js";import{handleNoEngineError as M}from"./support/handleNoEngineError.js";import{HighlightCounter as N}from"./support/HighlightCounter.js";import{toJSONGeometryType as J}from"./support/util.js";import{FeatureTileSubscriptionManager as $}from"../tiling/FeatureTileSubscriptionManager.js";import G from"../../layers/FeatureLayerView.js";import z from"../../layers/LayerView.js";import B from"../../layers/RefreshableLayerView.js";import Z from"../../../geometry/Extent.js";function K(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 X=4294967294;let Y=class extends(G(B(C(z)))){constructor(){super(...arguments),this._commandsQueue=new D({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new N,this._lastAvailableFields=[],this.eventLog=new k,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new _}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransitions()}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===A(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 U(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){d(r)}this._workerAttached.reject()}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&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 Q(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new Q(this.layer);case"subtype-group":return new W(this.layer);case"ogc-feature":return new L(this.layer);case"stream":return new P(this.layer);case"oriented-imagery":return new H(this.layer);case"knowledge-graph-sublayer":return new O(this.layer);case"catalog-footprint":return new q(this.layer);default:a(this.layer)}return null}get timeExtent(){return S(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="highlight"){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 M(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 M(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 M(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 M(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 M(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 M(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 M(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 M(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 M(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=x.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 M(r,{features:[]}),s=x.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 M(r,{features:[]}),s=E.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 M(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return M(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return M(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return M(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return M(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return M(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await M(r,{count:0,extent:null});return{count:i.count,extent:Z.fromJSON(i.extent)}}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;const t=this._subscriptionManager.update(e);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),this._updatingHandles.addPromise(this._workerAttached.promise),this._attachProxy(),this.featureContainer=new R(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new $({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([g((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),f),g((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())}))]),"stream"!==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._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),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:t=>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 T(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=j.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=j.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(d):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%X+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%X+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){const e=!1,r=!1,i=J(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>v(t,i,e,r))),c=u.map((t=>v(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,objectIdField: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}}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 this._updateRequiredFields(),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.endTransitions(),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){y(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=K(this._lastAvailableFields,e);return this._lastAvailableFields=t,F(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[ee(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}}_addHighlights(e,t){this._highlightCounter.addReason(e,t),this._updateHighlights()}_removeHighlights(e,t){this._highlightCounter.deleteReason(e,t),this._updateHighlights()}async _updateHighlights(){const e=[];for(const r of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightReason(r),i=V(t);e.push({objectId:r,highlightFlags:i})}const t=(await this.getWorker()).pipeline.updateHighlight({highlights:e}).catch((e=>{y(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(t)}_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 ee(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 b,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new b).toJSON(),n.hiddenIds=Array.from(i)),n}e([m()],Y.prototype,"_commandsQueue",void 0),e([m()],Y.prototype,"_sourceRefreshVersion",void 0),e([m()],Y.prototype,"_displayRefreshVersion",void 0),e([m({readOnly:!0})],Y.prototype,"_pipelineUpdating",void 0),e([m({readOnly:!0})],Y.prototype,"hasAllFeatures",null),e([m({readOnly:!0})],Y.prototype,"hasAllFeaturesInView",null),e([m({readOnly:!0})],Y.prototype,"hasFullGeometries",null),e([m()],Y.prototype,"featureEffectView",void 0),e([m()],Y.prototype,"labelingCollisionInfos",null),e([m()],Y.prototype,"layerAdapter",null),e([m({readOnly:!0})],Y.prototype,"timeExtent",null),e([m()],Y.prototype,"updating",void 0),Y=e([w("esri.views.2d.layers.FeatureLayerView2D")],Y);const te=Y;export{te 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{deepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,throwIfNotAbortError as d,isAbortError as y}from"../../../core/promiseUtils.js";import{watch as g,initial as f}from"../../../core/reactiveUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import _ from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as v}from"../../../layers/graphics/featureConversionUtils.js";import b from"../../../layers/support/FeatureFilter.js";import{packFields as F}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as A}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as S}from"../../../layers/support/timeSupport.js";import E from"../../../rest/support/AggregateFeatureSet.js";import x from"../../../rest/support/FeatureSet.js";import j from"../../../rest/support/Query.js";import{getHighlightBits as V}from"../engine/highlightReasons.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import{FeatureContainer as R}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as U}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as k}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 Q}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as O}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as L}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as H}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{StreamLayerAdapter as P}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as W}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as T}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import D from"./support/FeatureCommandQueue.js";import{handleNoEngineError as M}from"./support/handleNoEngineError.js";import{HighlightCounter as N}from"./support/HighlightCounter.js";import{toJSONGeometryType as J}from"./support/util.js";import{FeatureTileSubscriptionManager as $}from"../tiling/FeatureTileSubscriptionManager.js";import G from"../../layers/FeatureLayerView.js";import z from"../../layers/LayerView.js";import B from"../../layers/RefreshableLayerView.js";import Z from"../../../geometry/Extent.js";function K(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 X=4294967294;let Y=class extends(G(B(C(z)))){constructor(){super(...arguments),this._commandsQueue=new D({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new N,this._lastAvailableFields=[],this.eventLog=new k,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new _}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransitions()}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===A(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 U(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){d(r)}this._workerAttached.reject()}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&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 Q(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new Q(this.layer);case"subtype-group":return new W(this.layer);case"ogc-feature":return new L(this.layer);case"stream":return new P(this.layer);case"oriented-imagery":return new H(this.layer);case"knowledge-graph-sublayer":return new O(this.layer);case"catalog-footprint":return new q(this.layer);default:a(this.layer)}return null}get timeExtent(){return S(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="highlight"){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 M(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 M(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 M(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 M(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 M(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 M(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 M(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 M(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 M(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=x.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 M(r,{features:[]}),s=x.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 M(r,{features:[]}),s=E.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 M(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return M(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return M(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return M(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return M(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return M(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await M(r,{count:0,extent:null});return{count:i.count,extent:Z.fromJSON(i.extent)}}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;const t=this._subscriptionManager.update(e);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),this._updatingHandles.addPromise(this._workerAttached.promise),this._attachProxy(),this.featureContainer=new R(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new $({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([g((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),f),g((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())}))]),"stream"!==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._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),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:t=>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 T(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=j.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=j.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(d):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%X+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%X+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){const e=!1,r=!1,i=J(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>v(t,i,e,r))),c=u.map((t=>v(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,objectIdField: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}}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 this._updateRequiredFields(),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.endTransitions(),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){y(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=K(this._lastAvailableFields,e);return this._lastAvailableFields=t,F(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[ee(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}}_addHighlights(e,t){this._highlightCounter.addReason(e,t),this._updateHighlights()}_removeHighlights(e,t){this._highlightCounter.deleteReason(e,t),this._updateHighlights()}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightReason(i),r=V(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=>{y(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 ee(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 b,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new b).toJSON(),n.hiddenIds=Array.from(i)),n}e([m()],Y.prototype,"_commandsQueue",void 0),e([m()],Y.prototype,"_sourceRefreshVersion",void 0),e([m()],Y.prototype,"_displayRefreshVersion",void 0),e([m({readOnly:!0})],Y.prototype,"_pipelineUpdating",void 0),e([m({readOnly:!0})],Y.prototype,"hasAllFeatures",null),e([m({readOnly:!0})],Y.prototype,"hasAllFeaturesInView",null),e([m({readOnly:!0})],Y.prototype,"hasFullGeometries",null),e([m()],Y.prototype,"featureEffectView",void 0),e([m()],Y.prototype,"labelingCollisionInfos",null),e([m()],Y.prototype,"layerAdapter",null),e([m({readOnly:!0})],Y.prototype,"timeExtent",null),e([m()],Y.prototype,"updating",void 0),Y=e([w("esri.views.2d.layers.FeatureLayerView2D")],Y);const te=Y;export{te 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{create as i}from"../../../../geometry/support/aaBoundingRect.js";import"../../tiling/TileInfoView.js";import s from"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{FeatureTile as o}from"../../engine/webgl/FeatureTile.js";import{getPow2NeighborKey as r}from"./support/tileUtils.js";class n{constructor(e,t,i){this.getStage=e,this.version=t,this._tileInfoView=i,this._tiles=new Map,this._pendingUpdates=[],this._locked=!1}destroy(){}tiles(){return this._tiles.values()}size(){return this._tiles.size}setTiles(e){this._tiles.clear();for(const t of e)this._tiles.set(t.key.id,t)}lockUploads(){this._locked=!0}unlockUploads(){this._locked=!1;for(const e of this._pendingUpdates)this.updateTile(e);this._pendingUpdates=[]}updateTile(e){if(this._locked)return void this._pendingUpdates.push(e);if(has("esri-2d-update-debug")){const t=e.debugInfo?.chunkId??"<EnsureEnd>";console.debug(`Version[${e.version}] Tile[${e.id}] Chunk[${t}] RenderState.updateTile [${e.type}]`,e)}const t=this._ensureTile(e.id);if("update"===e.type){const[i,...s]=e.modify;t.onMessage({type:"update",modify:i,remove:e.remove,end:e.end,attributeEpoch:e.attributeEpoch});for(const t of s){const i=this._tiles.get(t.tileId);i&&i.onMessage({type:"update",modify:t,remove:e.remove,end:!1,isPixelBuffer:!0,attributeEpoch:null})}return}if(null==e.append)return void t.onMessage({type:"append",clear:e.clear,debugInfo:e.debugInfo,end:e.end,attributeEpoch:e.attributeEpoch});const[i,...s]=e.append;t.onMessage({type:"append",clear:e.clear,append:i,debugInfo:e.debugInfo,end:e.end,attributeEpoch:e.attributeEpoch});for(const o of s){const e=this._tiles.get(o.tileId);e&&e.onMessage({type:"update",modify:o,remove:[],sort:!1,end:!1,isPixelBuffer:!0,attributeEpoch:null})}}removeTile(e){const t=this._tiles.get(e);has("esri-2d-update-debug")&&console.debug(`Tile[${e}] RenderState.removeTile`),t?.destroy(),this._tiles.delete(e)}isTileDone(e){const t=this._tiles.get(e.id);return!!t&&t.isReady}_ensureTile(e){if(!this._tiles.has(e)){const t=this._createTile(e);this._copyPixelBufferedEntitiesInto(t),this._tiles.set(e,t)}return this._tiles.get(e)}_createTile(r){has("esri-2d-update-debug")&&console.debug(`Version[${this.version}] Tile[${r}] RenderState.createTile`);const n=new s(r),l=this._tileInfoView.getTileBounds(i(),n),d=this._tileInfoView.getTileResolution(n.level),a=new o(n,d,l[0],l[3],!0);if(a.stage=this.getStage(),!a.stage){const i=new e("featurelayerview:webgl","Cannot create tile with empty stage");t.getLogger("esri.views.2d.layers.features.RenderState").error(i)}return a}_copyPixelBufferedEntitiesInto(e){let t=7;for(let i=-1;i<=1;i++)for(let s=-1;s<=1;s++){if(0===i&&0===s)continue;const o=this._tileInfoView.tileInfo.isWrappable,n=r(e.key,s,i,o).id,l=this._tiles.get(n);if(null!=l){const o=1<<t;e.copyPixelBufferedEntitesFrom(l,o,s,i)}t--}}}export{n as RenderState};
|
|
5
|
+
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{create as i}from"../../../../geometry/support/aaBoundingRect.js";import"../../tiling/TileInfoView.js";import s from"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{FeatureTile as o}from"../../engine/webgl/FeatureTile.js";import{getPow2NeighborKey as r}from"./support/tileUtils.js";class n{constructor(e,t,i){this.getStage=e,this.version=t,this._tileInfoView=i,this._tiles=new Map,this._pendingUpdates=[],this._locked=!1}destroy(){for(const e of this.tiles())e.destroy()}tiles(){return this._tiles.values()}size(){return this._tiles.size}setTiles(e){this._tiles.clear();for(const t of e)this._tiles.set(t.key.id,t)}lockUploads(){this._locked=!0}unlockUploads(){this._locked=!1;for(const e of this._pendingUpdates)this.updateTile(e);this._pendingUpdates=[]}updateTile(e){if(this._locked)return void this._pendingUpdates.push(e);if(has("esri-2d-update-debug")){const t=e.debugInfo?.chunkId??"<EnsureEnd>";console.debug(`Version[${e.version}] Tile[${e.id}] Chunk[${t}] RenderState.updateTile [${e.type}]`,e)}const t=this._ensureTile(e.id);if("update"===e.type){const[i,...s]=e.modify;t.onMessage({type:"update",modify:i,remove:e.remove,end:e.end,attributeEpoch:e.attributeEpoch});for(const t of s){const i=this._tiles.get(t.tileId);i&&i.onMessage({type:"update",modify:t,remove:e.remove,end:!1,isPixelBuffer:!0,attributeEpoch:null})}return}if(null==e.append)return void t.onMessage({type:"append",clear:e.clear,debugInfo:e.debugInfo,end:e.end,attributeEpoch:e.attributeEpoch});const[i,...s]=e.append;t.onMessage({type:"append",clear:e.clear,append:i,debugInfo:e.debugInfo,end:e.end,attributeEpoch:e.attributeEpoch});for(const o of s){const e=this._tiles.get(o.tileId);e&&e.onMessage({type:"update",modify:o,remove:[],sort:!1,end:!1,isPixelBuffer:!0,attributeEpoch:null})}}removeTile(e){const t=this._tiles.get(e);has("esri-2d-update-debug")&&console.debug(`Tile[${e}] RenderState.removeTile`),t?.destroy(),this._tiles.delete(e)}isTileDone(e){const t=this._tiles.get(e.id);return!!t&&t.isReady}_ensureTile(e){if(!this._tiles.has(e)){const t=this._createTile(e);this._copyPixelBufferedEntitiesInto(t),this._tiles.set(e,t)}return this._tiles.get(e)}_createTile(r){has("esri-2d-update-debug")&&console.debug(`Version[${this.version}] Tile[${r}] RenderState.createTile`);const n=new s(r),l=this._tileInfoView.getTileBounds(i(),n),d=this._tileInfoView.getTileResolution(n.level),a=new o(n,d,l[0],l[3],!0);if(a.stage=this.getStage(),!a.stage){const i=new e("featurelayerview:webgl","Cannot create tile with empty stage");t.getLogger("esri.views.2d.layers.features.RenderState").error(i)}return a}_copyPixelBufferedEntitiesInto(e){let t=7;for(let i=-1;i<=1;i++)for(let s=-1;s<=1;s++){if(0===i&&0===s)continue;const o=this._tileInfoView.tileInfo.isWrappable,n=r(e.key,s,i,o).id,l=this._tiles.get(n);if(null!=l){const o=1<<t;e.copyPixelBufferedEntitesFrom(l,o,s,i)}t--}}}export{n as RenderState};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{difference as t,isSome as s}from"../core/arrayUtils.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{difference as t,isSome as s}from"../core/arrayUtils.js";import o from"../core/Collection.js";import{referenceSetter as i}from"../core/collectionUtils.js";import n from"../core/Evented.js";import{getOrCreateMapValue as r}from"../core/MapUtils.js";import{removeMaybe as l}from"../core/maybe.js";import c from"../core/ReactiveMap.js";import{watch as a,on as h}from"../core/reactiveUtils.js";import{symmetricDifference as u}from"../core/SetUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{isSubtypeGroupLayer as f,isSubtypeSublayer as g}from"../layers/support/layerUtils.js";import _ from"../rest/support/Query.js";let y=class extends n.EventedAccessor{constructor(e){super(e),this._selectionMap=new c,this._sources=new o,this._trashCan=[],this._layerEditHandles=new o,this._vizTaskId=0,this.showHighlight=!0}initialize(){this.addHandles([a((()=>[this.view,this.showHighlight]),(()=>this._refreshVisualization())),h((()=>this.sources),"change",(e=>{const t=this._selectionMap;for(const s of e.removed)t.delete(s);this._refreshListeners(),this._refreshVisualization()}),{onListenerAdd:()=>this._refreshListeners()})]);const e=new o;this.view.when().then((()=>{this.view.map&&(this.view.map.allLayers.flatten((e=>"sublayers"in e&&e.sublayers?e.sublayers:null)).forEach((t=>{(v(t)&&!f(t)||g(t))&&e.add(t)})),this.sources=e)}))}destroy(){this._layerEditHandles.drain(l)}get selections(){return Array.from(this._selectionMap.entries()).map((e=>{const[t,s]=e;return{layer:t,selection:[...s.selection]}}))}get count(){let e=0;for(const t of this._selectionMap.values())e+=t.selection.length;return e}get hasSelection(){return this.count>0}get sources(){return this._sources}set sources(e){i(e,this._sources)}async getSelectedFeatures(e,t={},s="layerView"){const{view:o,selections:i}=this,n=(void 0!==e?i.filter((t=>e.includes(t.layer))):i).filter((e=>e.selection.length>0)).map((async e=>{const{layer:i,selection:n}=e,r=g(i)?i.parent:i;if(null==r||!S(r))return null;if("layer"===s)return M(r,n,t);if(m(r))return null;const l=await o.whenLayerView(r);return M(l,n,t)}));return(await Promise.all(n)).filter((e=>null!==e))}updateSelection(e){const s=new Map;for(const[t,n]of this._selectionMap)s.set(t,[...n.selection]);let o=!1;const i=e.current.concat(e.added);for(const t of i){const e=t.sourceLayer,i=t.getObjectId();if(this.sources.includes(e)&&(v(e)||g(e))&&null!==i){const t=r(s,e,(()=>[]));t.includes(i)||(t.push(i),o=!0)}}for(const t of e.removed){const e=t.sourceLayer,i=t.getObjectId();if(this.sources.includes(e)&&(v(e)||g(e))&&null!==i){const t=s.get(e),n=t?.indexOf(i);void 0!==n&&n>=0&&(t?.splice(n,1),o=!0)}}if(o){const{_selectionMap:e,_trashCan:o}=this,i=[];for(const[n,r]of s){const s=e.get(n);void 0!==s&&o.push(s),e.set(n,{selection:r}),i.push({layer:n,selection:r,...t(void 0!==s?s.selection:[],r)})}this._onSelectionChange(i)}}setSelection(e,t){this._setSelection(e,t)}getSelection(e){const t=this._selectionMap.get(e);return t?.selection}appendToSelection(e,t){const s=this._selectionMap.get(e),o=void 0!==s?[...s.selection]:[];for(const i of t)o.includes(i)||o.push(i);this._setSelection(e,o)}removeFromSelection(e,t){const s=this._selectionMap.get(e);if(!s)return;const o=[];for(const i of s.selection)t.includes(i)||o.push(i);this._setSelection(e,o)}toggleInSelection(e,t){const s=this._selectionMap.get(e);if(!s||0===s.selection.length)return void this._setSelection(e,t);const o=new Set(s.selection),i=new Set(t),n=u(o,i);this._setSelection(e,Array.from(n))}clear(){const e=this._selectionMap.values();this._trashCan.push(...e);const t=[];for(const[s,o]of this._selectionMap.entries())t.push({layer:s,added:[],removed:[...o.selection],selection:[]});this._selectionMap.clear(),this._onSelectionChange(t)}_onSelectionChange(e){this._refreshVisualization(),this.emit("selection-change",{view:this.view,changes:e})}_refreshVisualization(){if(null==this.view||null==this.sources)return;for(this._vizTaskId++;this._trashCan.length>0;){const e=this._trashCan.pop();e?.highlightHandle?.remove()}const{sources:e,view:t,_selectionMap:s,showHighlight:o}=this,i=this._vizTaskId;for(const n of e){const e=s.get(n),r=g(n)?n.parent:n;if(null!=r&&S(r)){if(m(r))continue;t.whenLayerView(r).then((t=>{e?.highlightHandle?.remove(),void 0!==e&&o&&i===this._vizTaskId&&"highlight"in t&&"function"==typeof t.highlight&&e.selection.length>0&&(e.highlightHandle=t.highlight(e.selection,"selection"))}))}}}_refreshListeners(){this._layerEditHandles.drain(l);for(const e of this.sources){const t=g(e)?e.parent:e;if(null!=t&&v(t)){const s=t.on("edits",(t=>{this._handleEditChanges(t,e)}));this._layerEditHandles.push(s)}}}_handleEditChanges(e,t){if(void 0!==e.deletedFeatures&&e.deletedFeatures.length>0&&this._selectionMap.has(t)){const o=e.deletedFeatures.filter((e=>null==e.error)).map((e=>e.objectId)).filter(s);this.removeFromSelection(t,o)}}_setSelection(e,s){if(!this.sources.includes(e))throw new Error(`Cannot set selection on layer ${e.title} because it is not in 'sources'`);const o=this._selectionMap.get(e);if(void 0===o||!j(o,{selection:s})){void 0!==o&&this._trashCan.push(o),this._selectionMap.set(e,{selection:[...s]});const i={layer:e,selection:[...s],...t(void 0!==o?o.selection:[],s)};this._onSelectionChange([i])}}};e([d({readOnly:!0,nonNullable:!0})],y.prototype,"selections",null),e([d({readOnly:!0,nonNullable:!0})],y.prototype,"count",null),e([d({constructOnly:!0,nonNullable:!0})],y.prototype,"view",void 0),e([d({readOnly:!0,nonNullable:!0})],y.prototype,"hasSelection",null),e([d()],y.prototype,"showHighlight",void 0),e([d()],y.prototype,"sources",null),y=e([p("esri.views.SelectionManager")],y);const m=e=>g(e)?!0===e.parent?.isTable:e.isTable,v=e=>void 0!==e.createQuery&&void 0!==e.on,w=e=>void 0!==e.layer,S=e=>void 0!==e?.when,j=(e,t)=>{if(null==e&&null==t)return!0;if(null!=e&&null==t||null==e&&null!=t)return!1;if(null!=e&&null!=t&&null!=e.selection&&null!=t.selection){const s=[...e.selection],o=[...t.selection];if(s.length!==o.length)return!1;s.sort(),o.sort();for(let e=0;e<s.length;e++)if(s[e]!==o[e])return!1}return!0},M=async(e,t,s={})=>{let o;if(w(e)){const i=e;o=void 0===i?null:await i.queryFeatures(new _({...s,objectIds:t})).then((t=>({data:t,layer:e.layer})))}else{const i=e;o=void 0===i?null:await i.queryFeatures(new _({...s,objectIds:t})).then((e=>({data:e,layer:i})))}return o},b=y;export{b as default};
|
package/views/ui/UI.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import"../../intl.js";import{isSome as
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import"../../intl.js";import o from"../../core/Accessor.js";import{isSome as e}from"../../core/arrayUtils.js";import{empty as n,insertBefore as i}from"../../core/domUtils.js";import r from"../../core/Evented.js";import{makeHandle as s}from"../../core/handleUtils.js";import{watch as a,initial as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{setCalciteThemeClass as m}from"../../support/themeUtils.js";import h from"./Component.js";import{isRTL as u}from"../../widgets/support/widgetUtils.js";import{getLocale as f,onLocaleChange as _}from"../../intl/locale.js";const g={left:0,top:0,bottom:0,right:0},y={bottom:30,top:15,right:15,left:15},C="esri-ui",v={ui:C,corner:`${C}-corner`,innerContainer:`${C}-inner-container`,manualContainer:`${C}-manual-container`,cornerContainer:`${C}-corner-container`,topLeft:`${C}-top-left`,topRight:`${C}-top-right`,bottomLeft:`${C}-bottom-left`,bottomRight:`${C}-bottom-right`};function b(t){return t&&!t._started&&"function"==typeof t.postMixInProperties&&"function"==typeof t.buildRendering&&"function"==typeof t.postCreate&&"function"==typeof t.startup}function w(t){return 0===t?"0":`${t}px`}function P(t){const o="object"==typeof t&&null!==t&&Object.getPrototypeOf(t);return(null===o||o===Object.prototype)&&("component"in t||"index"in t||"position"in t)?t:null}function L(t,{top:o,bottom:e,left:n,right:i}){t.style.top=o,t.style.bottom=e,t.style.left=n,t.style.right=i}let j=class extends r.EventedAccessor{constructor(t){super(t),this._cornerNameToContainerLookup={},this._positionNameToContainerLookup={},this._components=new Array,this._componentMap=new Map,this._removeWidgetHandleKey=Symbol("componentOnRemoveSymbol"),this._locale=f(),this.view=null,this._applyViewPadding=()=>{const t=this.container;t&&L(t,this._toPixelPosition(this._getViewPadding()))},this._applyUIPadding=()=>{const t=this._innerContainer;t&&L(t,this._toPixelPosition(this.padding))},this._initContainers()}initialize(){this.addHandles([a((()=>[this.view?.padding,this.container]),this._applyViewPadding,p),a((()=>this.padding),this._applyUIPadding,p),a((()=>[this.container,this._locale]),(([t,o])=>{t&&t.setAttribute("lang",o)}),p),_((t=>{this._locale=t}))])}destroy(){this.container=null;for(const t of this._components)t.destroy();this._components.length=0,this._componentMap.clear()}set container(t){const o=this._get("container");t!==o&&(t&&(t.classList.add(v.ui),m(t),this._attachContainers(t)),o&&(o.classList.remove(v.ui),L(o,{top:"",bottom:"",left:"",right:""}),n(o)),this._set("container",t))}get height(){const t=this.view?.height??0;if(0===t)return t;const o=this._getViewPadding(),{top:e,bottom:n}=o;return Math.max(t-e-n,0)}get padding(){return this._get("padding")}set padding(t){this._overrideIfSome("padding",t)}castPadding(t){return"number"==typeof t?{bottom:t,top:t,right:t,left:t}:{...y,...t}}get width(){const t=this.view?.width??0;if(0===t)return t;const o=this._getViewPadding(),{left:e,right:n}=o;return Math.max(t-e-n,0)}add(t,o){let e,n,i;if(Array.isArray(t))return void t.forEach((t=>this.add(t,o)));const r=P(t);r&&({index:e,position:o,component:t,key:n}=r),o&&"object"==typeof o&&({index:e,key:n,position:o,internal:i}=o),!t||o&&!this._isValidPosition(o)||this._add(t,o,e,n,i)}remove(t,o){if(!t)return;if(Array.isArray(t))return t.map((t=>this.remove(t,o)));const e=this._find(t);if(e){if(this._componentMap.has(e)&&this._componentMap.get(e)?.key!==o)return;const t=this._components.indexOf(e),n=e.node.parentNode;return n?.removeChild(e.node),this._componentMap.delete(e),e.widget?.removeHandlesReference(this._removeWidgetHandleKey),this._components.splice(t,1)[0]}}empty(t,o={removeInternal:!1}){if(Array.isArray(t)){for(const e of t)this.empty(e,o);return}const e=this._positionNameToContainerLookup[t??"manual"],n=Array.prototype.slice.call(e.children).map((t=>this._findByNode(t))).filter((t=>{if(null==t)return!1;return!(this._componentMap.get(t)?.internal??!1)||o.removeInternal}));for(const i of n)this.remove(i)}move(t,o){if(Array.isArray(t)&&t.forEach((t=>this.move(t,o))),!t)return;let e;const n=P(t)||P(o);if(n&&(e=n.index,o=n.position,t=n.component||t),o&&!this._isValidPosition(o))return;const i=this.remove(t);i&&this.add(i,{position:o,index:e})}find(t){if(!t)return null;const o=this._findById(t);return o&&(o.widget||o.node)}getComponents(t,o={includeInternal:!1}){return t?Array.isArray(t)?t.flatMap((t=>this._getComponentsAtPosition(t,o))):this._getComponentsAtPosition(t,o):this._components.filter((t=>o.includeInternal||!this._componentMap.get(t)?.internal)).map((({widget:t,node:o})=>t??o))}getPosition(t){for(const o in this._positionNameToContainerLookup){if(this._positionNameToContainerLookup[o].contains(t))return o}return null}_add(t,e,n,i,r){t instanceof h||(t=new h({node:t}));const{widget:a}=t;null!=a&&a instanceof o&&a.addHandles(s((()=>{queueMicrotask((()=>this.remove(t)))})),this._removeWidgetHandleKey),this._place({component:t,position:e,index:n}),this._components.push(t),this._componentMap.set(t,{key:i,internal:r})}_find(t){return t?t instanceof h?this._findByComponent(t):"string"==typeof t?this._findById(t):this._findByNode(t.domNode||t):null}_getViewPadding(){return this.view?.padding??g}_attachContainers(t){t.appendChild(this._innerContainer),t.appendChild(this._manualContainer)}_initContainers(){const t=document.createElement("div");t.classList.add(v.innerContainer,v.cornerContainer);const o=document.createElement("div");o.classList.add(v.innerContainer,v.manualContainer);const e=document.createElement("div");e.classList.add(v.topLeft,v.corner),t.appendChild(e);const n=document.createElement("div");n.classList.add(v.topRight,v.corner),t.appendChild(n);const i=document.createElement("div");i.classList.add(v.bottomLeft,v.corner),t.appendChild(i);const r=document.createElement("div");r.classList.add(v.bottomRight,v.corner),t.appendChild(r),this._innerContainer=t,this._manualContainer=o;const s=u();this._cornerNameToContainerLookup={"top-left":e,"top-right":n,"bottom-left":i,"bottom-right":r,"top-leading":s?n:e,"top-trailing":s?e:n,"bottom-leading":s?r:i,"bottom-trailing":s?i:r},this._positionNameToContainerLookup={manual:o,...this._cornerNameToContainerLookup}}_isValidPosition(t){return!!this._positionNameToContainerLookup[t]}_place(t){const o=t.position??"manual",{component:e,index:n}=t,r=this._positionNameToContainerLookup[o],s=null!=n&&n>-1;if(b(e.widget)&&e.widget.startup(),!s)return void r.appendChild(e.node);const a=Array.from(r.children);if(0===n)return void(r.firstChild?i(e.node,r.firstChild):r.appendChild(e.node));n>=a.length?r.appendChild(e.node):i(e.node,a[n])}_toPixelPosition(t){return{top:w(t.top),left:w(t.left),right:w(t.right),bottom:w(t.bottom)}}_findByComponent(t){return this._components.find((o=>o===t))??null}_findById(t){return this._components.find((({id:o})=>o===t))??null}_findByNode(t){return this._components.find((({node:o})=>o===t))??null}_getComponentsAtPosition(t,o){const n=this._positionNameToContainerLookup[t];return Array.prototype.slice.call(n.children).map((t=>this._findByNode(t))).filter(e).filter((t=>o.includeInternal||!this._componentMap.get(t)?.internal)).map((({widget:t,node:o})=>t??o))}};t([d()],j.prototype,"_locale",void 0),t([d()],j.prototype,"container",null),t([d()],j.prototype,"height",null),t([d({value:y})],j.prototype,"padding",null),t([l("padding")],j.prototype,"castPadding",null),t([d()],j.prototype,"view",void 0),t([d()],j.prototype,"width",null),j=t([c("esri.views.ui.UI")],j);const A=j;export{A 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{IdentifiableMixin as s}from"../../../core/Identifiable.js";import{ignoreAbortErrors as i,debounce as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as c,findRelatedLayer as C}from"../support/featureUtils.js";import{getFieldsInTitleAndDesc as _}from"../../FeatureForm/featureFormUtils.js";const b=100;let g=class extends(l(s(r))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await i(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await i(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,b),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,b),this._queryPageDebounced=n(this._queryPageController,b),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.drain((e=>e.destroy())),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.addHandles([u((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.drain((e=>e.destroy())),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=c(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&null!=this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&null!=this.relationshipId&&
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{IdentifiableMixin as s}from"../../../core/Identifiable.js";import{ignoreAbortErrors as i,debounce as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as c,findRelatedLayer as C}from"../support/featureUtils.js";import{getFieldsInTitleAndDesc as _}from"../../FeatureForm/featureFormUtils.js";const b=100;let g=class extends(l(s(r))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await i(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await i(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,b),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,b),this._queryPageDebounced=n(this._queryPageController,b),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.drain((e=>e.destroy())),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.addHandles([u((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.drain((e=>e.destroy())),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=c(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&null!=this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&null!=this.relationshipId&&null!=this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?C(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return null!=e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}refresh(){this._queryFeatureCountDebounced()}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t||null==o)return void this._set("featureCount",0);const i=t.createQuery(),n=new p({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:c}=this;if(!h||!s||!d||null==c)return[];const C=r?((n-1)*l+u)%u:0,b=r?l:a,g=d.objectIdField,F=[...t.map((e=>e.field)),..._(d),g].filter(o),f=t.map((e=>`${e.field} ${e.order}`)),m=d.createQuery(),q=new p({orderByFields:f,start:C,num:b,outFields:F,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[c],where:m.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[c]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([y()],g.prototype,"_loaded",void 0),e([y()],g.prototype,"_queryAbortController",void 0),e([y()],g.prototype,"_queryPageAbortController",void 0),e([y()],g.prototype,"_queryFeatureCountAbortController",void 0),e([y({value:1})],g.prototype,"featurePage",null),e([y()],g.prototype,"featuresPerPage",void 0),e([y({readOnly:!0})],g.prototype,"orderByFieldsFixedCasing",null),e([y({readOnly:!0})],g.prototype,"supportsCacheHint",null),e([y({readOnly:!0})],g.prototype,"canLoad",null),e([y({readOnly:!0})],g.prototype,"canQuery",null),e([y()],g.prototype,"description",void 0),e([y({readOnly:!0})],g.prototype,"itemDescriptionFieldName",null),e([y({value:3})],g.prototype,"displayCount",null),e([y({type:t})],g.prototype,"graphic",void 0),e([y()],g.prototype,"layer",void 0),e([y()],g.prototype,"map",void 0),e([y({readOnly:!0})],g.prototype,"objectId",null),e([y({readOnly:!0})],g.prototype,"objectIdField",null),e([y()],g.prototype,"orderByFields",void 0),e([y({readOnly:!0})],g.prototype,"relatedFeatures",null),e([y({readOnly:!0})],g.prototype,"relatedLayer",null),e([y({readOnly:!0})],g.prototype,"relationship",null),e([y()],g.prototype,"featureCount",void 0),e([y({readOnly:!0})],g.prototype,"relatedFeatureViewModels",null),e([y()],g.prototype,"relationshipId",void 0),e([y()],g.prototype,"showAllEnabled",void 0),e([y()],g.prototype,"state",null),e([y()],g.prototype,"title",void 0),g=e([h("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],g);const F=g;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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",c={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let a=class extends t.EventedAccessor{constructor(e){super(e),this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:o}=e,{formatFunction:i}=this,n=r.sanitize(o);if(i&&t){const{index:e,item:{feature:o}}=t;return i({column:this,feature:o,index:e,value:n})}return n},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,o=this.createHeaderContent();this.removeCellContent(t),t.appendChild(o)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:o})=>{const i=this.getCellValue(t,o),n=this.cellValueFormatFunction({column:t,rowData:o,value:i});let r=null;r=n instanceof HTMLElement?n:s(this.messagesURIUtils,n),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([o((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),o((()=>this.hidden),(()=>this.closeMenu())),o((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:o,iconClass:i,label:n,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:i,iconStart:o,selected:s,textContent:n,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],o=this.visibleElements?.columnMenuItems;if(!1!==o?.sortAscending){const o=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e.sortAsc,onclick:()=>this.direction="asc"});t.push(o)}if(!1!==o?.sortDescending){const o=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e.sortDesc,onclick:()=>this.direction="desc"});t.push(o)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:o}=this,i=this.createCalciteAction({icon:o?.icon??"ellipsis",text:this.messages?.menu,slot:"trigger"}),n=document.createElement("calcite-dropdown");if(n.maxItems=5,n.placement="top-end",n.appendChild(i),n.overlayPositioning="fixed",t.length){const e=n.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=n.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=o?.selectionMode??"none",t.append(...e)}return n}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e,t){return e.path&&t?.item?t.item[e.path]:""}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:o,initialSortPriority:i}=this,n=document.createElement("vaadin-grid-sorter");return n.classList.add(c.sorter),n.setAttribute("path",o),n.setAttribute("title",e),n.textContent=e,t&&n.setAttribute("direction",t),null!=i&&(n._initialOrder=i),n.addEventListener("direction-changed",(()=>{this.direction!==n.direction&&this._set("direction",n.direction)})),n}createCalciteAction(e){const t=document.createElement("calcite-action"),{className:o,disabled:i,icon:n,label:s,scale:r,slot:l,text:c,textEnabled:a,onclick:d}=e;return t.className=o??"",t.disabled=!!i,t.icon=n??"",t.label=s??"",t.scale=r??"s",t.slot=l??"",t.text=t.title=c??"",t.textEnabled=!!a,t.onclick=d??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:o,className:i,disabled:n,iconEnd:s,loading:r,onclick:l,scale:c,textContent:a}=e;return t.className=i??"",t.scale=c??"s",t.appearance=o??"transparent",t.disabled=!!n,t.iconEnd=s??"",t.loading=!!r,t.textContent=t.title=a??"",t.onclick=l??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:o,hidden:i,iconClass:n,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(n&&!s){const e=document.createElement("span"),o=document.createElement("span");o.classList.add(c.headerMenuIcon,n),e.textContent=e.title=d,e.insertBefore(o,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!o,t.hidden="function"==typeof i?i():!!i,t.selected=!!a,t.onclick=l??null,t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:o,scale:i,textLabel:n}=e,s=document.createElement("calcite-icon"),r=n??t;return s.icon=o,s.scale=i??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,o=document.createElement("div");if(o.classList.add(c.headerContent),t&&o.appendChild(t),this.sortable)o.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(c.headerLabel);const i=t.appendChild(document.createElement("span"));i.textContent=e,i.setAttribute("title",e),o.appendChild(t)}return this.menuVisible&&o.appendChild(this.menu),o}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}};e([i()],a.prototype,"autoWidth",void 0),e([i()],a.prototype,"cellValueFormatFunction",void 0),e([i()],a.prototype,"customMenuItems",null),e([i()],a.prototype,"defaultMenuItems",null),e([i()],a.prototype,"direction",void 0),e([i()],a.prototype,"effectiveLabel",null),e([i({constructOnly:!0})],a.prototype,"fieldName",void 0),e([i()],a.prototype,"flexGrow",void 0),e([i()],a.prototype,"footerRenderFunction",void 0),e([i()],a.prototype,"formatFunction",void 0),e([i()],a.prototype,"frozen",void 0),e([i()],a.prototype,"frozenToEnd",void 0),e([i()],a.prototype,"grid",void 0),e([i()],a.prototype,"iconNode",null),e([i()],a.prototype,"invalid",null),e([i()],a.prototype,"headerRenderFunction",void 0),e([i()],a.prototype,"hidden",void 0),e([i()],a.prototype,"icon",void 0),e([i({constructOnly:!0})],a.prototype,"initialSortPriority",void 0),e([i()],a.prototype,"label",void 0),e([i()],a.prototype,"menu",null),e([i()],a.prototype,"menuItems",null),e([i()],a.prototype,"menuConfig",void 0),e([i()],a.prototype,"menuVisible",null),e([i()],a.prototype,"messages",void 0),e([i()],a.prototype,"messagesCommon",void 0),e([i()],a.prototype,"messagesURIUtils",void 0),e([i()],a.prototype,"renderFunction",void 0),e([i()],a.prototype,"resizable",void 0),e([i()],a.prototype,"sortable",void 0),e([i({readOnly:!0})],a.prototype,"sortElement",void 0),e([i()],a.prototype,"store",void 0),e([i()],a.prototype,"textAlign",void 0),e([i()],a.prototype,"textWrap",void 0),e([i()],a.prototype,"timeZone",void 0),e([i()],a.prototype,"timeZoneName",void 0),e([i()],a.prototype,"visibleElements",void 0),e([i()],a.prototype,"width",void 0),a=e([n("esri.widgets.FeatureTable.Grid.Column")],a);const d=a;export{d as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",c={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let a=class extends t.EventedAccessor{constructor(e){super(e),this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:o}=e,{formatFunction:i}=this,n=r.sanitize(o);if(i&&t){const{index:e,item:{feature:o}}=t;return i({column:this,feature:o,index:e,value:n})}return n},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,o=this.createHeaderContent();this.removeCellContent(t),t.appendChild(o)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:o})=>{const i=this.getCellValue(t,o),n=this.cellValueFormatFunction({column:t,rowData:o,value:i});let r=null;r=n instanceof HTMLElement?n:s(this.messagesURIUtils,n),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([o((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),o((()=>this.hidden),(()=>this.closeMenu())),o((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:o,iconClass:i,label:n,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:i,iconStart:o,selected:s,textContent:n,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],o=this.visibleElements?.columnMenuItems;if(!1!==o?.sortAscending){const o=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e.sortAsc,onclick:()=>this.direction="asc"});t.push(o)}if(!1!==o?.sortDescending){const o=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e.sortDesc,onclick:()=>this.direction="desc"});t.push(o)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:o}=this,i=this.createCalciteAction({icon:o?.icon??"ellipsis",text:this.messages?.menu,slot:"trigger"}),n=document.createElement("calcite-dropdown");if(n.maxItems=5,n.placement="top-end",n.appendChild(i),n.overlayPositioning="fixed",n.addEventListener("mousewheel",(e=>{e.stopPropagation()})),t.length){const e=n.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=n.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=o?.selectionMode??"none",t.append(...e)}return n}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e,t){return e.path&&t?.item?t.item[e.path]:""}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:o,initialSortPriority:i}=this,n=document.createElement("vaadin-grid-sorter");return n.classList.add(c.sorter),n.setAttribute("path",o),n.setAttribute("title",e),n.textContent=e,t&&n.setAttribute("direction",t),null!=i&&(n._initialOrder=i),n.addEventListener("direction-changed",(()=>{this.direction!==n.direction&&this._set("direction",n.direction)})),n}createCalciteAction(e){const t=document.createElement("calcite-action"),{className:o,disabled:i,icon:n,label:s,scale:r,slot:l,text:c,textEnabled:a,onclick:d}=e;return t.className=o??"",t.disabled=!!i,t.icon=n??"",t.label=s??"",t.scale=r??"s",t.slot=l??"",t.text=t.title=c??"",t.textEnabled=!!a,t.onclick=d??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:o,className:i,disabled:n,iconEnd:s,loading:r,onclick:l,scale:c,textContent:a}=e;return t.className=i??"",t.scale=c??"s",t.appearance=o??"transparent",t.disabled=!!n,t.iconEnd=s??"",t.loading=!!r,t.textContent=t.title=a??"",t.onclick=l??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:o,hidden:i,iconClass:n,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(n&&!s){const e=document.createElement("span"),o=document.createElement("span");o.classList.add(c.headerMenuIcon,n),e.textContent=e.title=d,e.insertBefore(o,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!o,t.hidden="function"==typeof i?i():!!i,t.selected=!!a,t.onclick=l??null,t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:o,scale:i,textLabel:n}=e,s=document.createElement("calcite-icon"),r=n??t;return s.icon=o,s.scale=i??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,o=document.createElement("div");if(o.classList.add(c.headerContent),t&&o.appendChild(t),this.sortable)o.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(c.headerLabel);const i=t.appendChild(document.createElement("span"));i.textContent=e,i.setAttribute("title",e),o.appendChild(t)}return this.menuVisible&&o.appendChild(this.menu),o}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}};e([i()],a.prototype,"autoWidth",void 0),e([i()],a.prototype,"cellValueFormatFunction",void 0),e([i()],a.prototype,"customMenuItems",null),e([i()],a.prototype,"defaultMenuItems",null),e([i()],a.prototype,"direction",void 0),e([i()],a.prototype,"effectiveLabel",null),e([i({constructOnly:!0})],a.prototype,"fieldName",void 0),e([i()],a.prototype,"flexGrow",void 0),e([i()],a.prototype,"footerRenderFunction",void 0),e([i()],a.prototype,"formatFunction",void 0),e([i()],a.prototype,"frozen",void 0),e([i()],a.prototype,"frozenToEnd",void 0),e([i()],a.prototype,"grid",void 0),e([i()],a.prototype,"iconNode",null),e([i()],a.prototype,"invalid",null),e([i()],a.prototype,"headerRenderFunction",void 0),e([i()],a.prototype,"hidden",void 0),e([i()],a.prototype,"icon",void 0),e([i({constructOnly:!0})],a.prototype,"initialSortPriority",void 0),e([i()],a.prototype,"label",void 0),e([i()],a.prototype,"menu",null),e([i()],a.prototype,"menuItems",null),e([i()],a.prototype,"menuConfig",void 0),e([i()],a.prototype,"menuVisible",null),e([i()],a.prototype,"messages",void 0),e([i()],a.prototype,"messagesCommon",void 0),e([i()],a.prototype,"messagesURIUtils",void 0),e([i()],a.prototype,"renderFunction",void 0),e([i()],a.prototype,"resizable",void 0),e([i()],a.prototype,"sortable",void 0),e([i({readOnly:!0})],a.prototype,"sortElement",void 0),e([i()],a.prototype,"store",void 0),e([i()],a.prototype,"textAlign",void 0),e([i()],a.prototype,"textWrap",void 0),e([i()],a.prototype,"timeZone",void 0),e([i()],a.prototype,"timeZoneName",void 0),e([i()],a.prototype,"visibleElements",void 0),e([i()],a.prototype,"width",void 0),a=e([n("esri.widgets.FeatureTable.Grid.Column")],a);const d=a;export{d 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import a from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import{watch as l,when as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/AttachmentQuery.js";import y from"../../../rest/support/RelationshipQuery.js";import{isIFeatureTableSupportedLayerWithAttachments as _,isIFeatureTableSupportedLayerWithEditing as m,isIFeatureTableSupportedLayerWithRelationships as f}from"./tableUtils.js";let g=class extends r{constructor(e){super(e),this._editOperationQueue=new o,this._hasStaleCache=!1,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new o,this._queryOperationQueue=new o,this.attachmentsEnabled=!1,this.count=0,this.failures=new o,this.filterGeometry=null,this.itemCache=new o,this.layer=null,this.objectIds=null,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.timeExtent=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.relationshipConfig,this.returnGeometry,this.timeExtent,this.where]),(()=>this._reset())),p((()=>this.attachmentsEnabled),(()=>this._reset())),p((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _layerWithAttachments(){const{_capabilities:e,attachmentsEnabled:t,layer:r,supportsAttachments:s}=this;if(e&&r&&t&&s)return _(r)?r:null}get _layerWithEditing(){const e=this.layer;return m(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return f(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:o,role:a}=t,n=i>0;return("one-to-one"!==o||!n)&&("one-to-many"!==o||"origin"!==a||!n)}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get syncing(){return this._editOperationQueue.length>0}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.when(),await this._syncLayerInfo(),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async refreshLayerInfo(){return this._syncLayerInfo()}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:o,state:a}=this;return o&&"loaded"===a?this._query({layer:o,start:s,num:i,page:t,pageSize:r}):[]}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,{features:i}=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){await this._update(e)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new a("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}getItemByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return;const s=r.objectIdField;return t.find((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getItemIndexByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return-1;const s=r.objectIdField;return t.findIndex((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getLocalItemAt(e){return this.itemCache.at(e)}at(e){return Promise.resolve(this.itemCache.at(e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll()}_getIdsFromFeatures(e,t){return e.map((e=>e.getObjectId()??e.attributes[t]))}_resultsToFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,o=s.objectIdField;return r.map((e=>{const{attributes:r}=e,a=e.getObjectId()??r[o],n=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{n.push({relationshipId:t,count:e[a]??0})})),{objectId:a,feature:e,attachments:t[a]??null,relatedRecords:n}}))}async _update(e){const{_layerWithEditing:r}=this;if(!this.supportsUpdate||!r)throw new a("store:update-error","Update is not supported.");const{index:s,name:i,value:o}=e,u=await this.at(s);if(!u?.feature)throw new a("store:update-error","Feature with provided 'objectId' not found.");const{feature:l}=u,p=n(l.attributes);p[i]=o;const d=new t({attributes:p}),h=r.applyEdits({updateFeatures:[d]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(l.attributes=p),e}));return this._queueEditOperation((()=>h))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._syncObjectIdCache(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=this._getIdsFromFeatures(r,t.objectIdField),i=await this._queryAttachments(s),o=await this._queryRelatedCounts(s);return this._resultsToFeatureData({layer:t,features:r,attachments:i,relatedRecords:o})||[]}))}async _syncLayerInfo(){await this._syncCount(),await this._syncObjectIdCache()}async _syncCount(){await this._queryCount().then((e=>this._set("count",e)))}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryForObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new y({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:o,filterGeometry:a,objectIds:n}=this,u=t.createQuery();return u.geometry=a,u.returnGeometry=!1,u.where=o,u.timeExtent=i,u.objectIds=n,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const o=await t.queryRelatedFeaturesCount(new y({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,o)}))),i):i}_queryForObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:o,supportsCacheHint:a,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i,n&&(u.orderByFields=o),a&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{effectiveTimeExtent:r,effectiveWhere:s,filterGeometry:i,objectIds:o,orderByFields:a,returnGeometry:n,supportsCacheHint:u,supportsOrderBy:l,supportsPagination:p}=this,{layer:d,start:h,pageSize:c}=e,y=d.createQuery();y.returnGeometry=n,p?(y.start=h,y.num=c,y.where=s,y.timeExtent=r,y.objectIds=o):y.objectIds=o||this._getObjectIdsForPage(h,c??0),l&&(y.orderByFields=a),i&&(y.geometry=i),u&&(y.cacheHint=!0);return(await d.queryFeatures(y)).features}async _queryRelatedFeatures(e,t){const{orderByFields:r,returnGeometry:s,supportsCacheHint:i}=this,{layer:o,start:a,pageSize:n}=e,{relatedLayer:u,relationshipId:l}=t,p=t.objectId,d=o.createQuery(),h=new y({cacheHint:i,num:n??0,objectIds:[p],orderByFields:r,outFields:["*"],relationshipId:l,returnGeometry:s,start:a,where:d.where??void 0}),c=await u.queryRelatedFeatures(h);return c[p]?.features||[]}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new a("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:o,supportsOrderBy:n}=this,u=t.createQuery();return u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),o&&(u.cacheHint=!0),t.queryFeatures(u)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?t.queryAttachments(new c({objectIds:e,where:r})):Promise.resolve({})}_syncLocalCache(e){const{layer:t}=this;if(!t)return;const{objectIdField:r}=t,{itemCache:s}=this;e.forEach((e=>{if(e?.feature){const{feature:t}=e,i=t.getObjectId()??t.attributes[r];if(null!=i){const t=this.getItemIndexByObjectId(i);-1===t?s.add(e):s.splice(t,1,e)}}}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?(this._syncLocalCache(t),t):[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_logError(e,t){u.getLogger(this).error(e,t)}};e([d({readOnly:!0})],g.prototype,"_capabilities",null),e([d()],g.prototype,"_editOperationQueue",void 0),e([d()],g.prototype,"_hasStaleCache",void 0),e([d({readOnly:!0})],g.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],g.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],g.prototype,"_layerWithRelationships",null),e([d()],g.prototype,"_loaded",void 0),e([d()],g.prototype,"_loadError",void 0),e([d()],g.prototype,"_loading",void 0),e([d()],g.prototype,"_objectIdCache",void 0),e([d()],g.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],g.prototype,"_relatedLayer",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],g.prototype,"_relatedLayerSupportsQuery",null),e([d()],g.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],g.prototype,"_canUseRelatedLayer",null),e([d()],g.prototype,"attachmentsEnabled",void 0),e([d()],g.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],g.prototype,"count",void 0),e([d()],g.prototype,"effectiveTimeExtent",null),e([d()],g.prototype,"effectiveWhere",null),e([d({readOnly:!0})],g.prototype,"failures",void 0),e([d()],g.prototype,"filterGeometry",void 0),e([d({readOnly:!0})],g.prototype,"itemCache",void 0),e([d()],g.prototype,"layer",void 0),e([d()],g.prototype,"objectIds",void 0),e([d()],g.prototype,"orderByFields",null),e([d({readOnly:!0})],g.prototype,"querying",null),e([d()],g.prototype,"relationship",null),e([d()],g.prototype,"relationshipConfig",void 0),e([d()],g.prototype,"relationshipIds",null),e([d()],g.prototype,"relationships",null),e([d()],g.prototype,"relatedRecordsEnabled",void 0),e([d()],g.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],g.prototype,"state",null),e([d()],g.prototype,"supportsAdd",null),e([d()],g.prototype,"supportsAttachments",null),e([d()],g.prototype,"supportsCacheHint",null),e([d()],g.prototype,"supportsCacheHintQueryRelated",null),e([d()],g.prototype,"supportsDelete",null),e([d()],g.prototype,"supportsEditing",null),e([d()],g.prototype,"supportsOrderBy",null),e([d()],g.prototype,"supportsPagination",null),e([d()],g.prototype,"supportsQuery",null),e([d()],g.prototype,"supportsQueryRelated",null),e([d()],g.prototype,"supportsUpdate",null),e([d({readOnly:!0})],g.prototype,"syncing",null),e([d()],g.prototype,"timeExtent",void 0),e([d()],g.prototype,"where",void 0),g=e([h("esri.widgets.FeatureTable.support.FeatureStore")],g);const b=g;export{b as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import a from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import{watch as l,when as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/AttachmentQuery.js";import y from"../../../rest/support/RelationshipQuery.js";import{isIFeatureTableSupportedLayerWithAttachments as _,isIFeatureTableSupportedLayerWithEditing as m,isIFeatureTableSupportedLayerWithRelationships as f}from"./tableUtils.js";let g=class extends r{constructor(e){super(e),this._editOperationQueue=new o,this._hasStaleCache=!1,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new o,this._queryOperationQueue=new o,this.attachmentsEnabled=!1,this.count=0,this.failures=new o,this.filterGeometry=null,this.itemCache=new o,this.layer=null,this.objectIds=null,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.timeExtent=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.relationshipConfig,this.returnGeometry,this.timeExtent,this.where]),(()=>this._reset())),p((()=>this.attachmentsEnabled),(()=>this._reset())),p((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _layerWithAttachments(){const{_capabilities:e,attachmentsEnabled:t,layer:r,supportsAttachments:s}=this;if(e&&r&&t&&s)return _(r)?r:null}get _layerWithEditing(){const e=this.layer;return m(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return f(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:o,role:a}=t,n=i>0;return("one-to-one"!==o||!n)&&("one-to-many"!==o||"origin"!==a||!n)}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get syncing(){return this._editOperationQueue.length>0}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.when(),await this._syncLayerInfo(),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async refreshLayerInfo(){return this._syncLayerInfo()}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:o,state:a}=this;return o&&"loaded"===a?this._query({layer:o,start:s,num:i,page:t,pageSize:r}):[]}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,{features:i}=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){await this._update(e)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new a("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}getItemByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return;const s=r.objectIdField;return t.find((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getItemIndexByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return-1;const s=r.objectIdField;return t.findIndex((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getLocalItemAt(e){return this.itemCache.at(e)}at(e){return Promise.resolve(this.itemCache.at(e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll()}_getIdsFromFeatures(e,t){return e.map((e=>e.getObjectId()??e.attributes[t]))}_resultsToFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,o=s.objectIdField;return r.map((e=>{const{attributes:r}=e,a=e.getObjectId()??r[o],n=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{n.push({relationshipId:t,count:e[a]??0})})),{objectId:a,feature:e,attachments:t[a]??null,relatedRecords:n}}))}async _update(e){const{_layerWithEditing:r}=this;if(!this.supportsUpdate||!r)throw new a("store:update-error","Update is not supported.");const{index:s,name:i,value:o}=e,u=await this.at(s);if(!u?.feature)throw new a("store:update-error","Feature with provided 'objectId' not found.");const{feature:l}=u,p=n(l.attributes);p[i]=o;const d=new t({attributes:p}),h=r.applyEdits({updateFeatures:[d]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(l.attributes=p),e}));return this._queueEditOperation((()=>h))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._syncObjectIdCache(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=this._getIdsFromFeatures(r,t.objectIdField),i=await this._queryAttachments(s),o=await this._queryRelatedCounts(s);return this._resultsToFeatureData({layer:t,features:r,attachments:i,relatedRecords:o})||[]}))}async _syncLayerInfo(){await this._syncCount(),await this._syncObjectIdCache()}async _syncCount(){await this._queryCount().then((e=>this._set("count",e)))}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryForObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new y({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:o,filterGeometry:a,objectIds:n}=this,u=t.createQuery();return u.geometry=a,u.returnGeometry=!1,u.where=o,u.timeExtent=i,u.objectIds=n,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const o=await t.queryRelatedFeaturesCount(new y({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,o)}))),i):i}_queryForObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:o,supportsCacheHint:a,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i,n&&(u.orderByFields=o),a&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{effectiveTimeExtent:r,effectiveWhere:s,filterGeometry:i,objectIds:o,orderByFields:a,returnGeometry:n,supportsCacheHint:u,supportsOrderBy:l,supportsPagination:p}=this,{layer:d,start:h,pageSize:c}=e,y=d.createQuery();y.returnGeometry=n,p?(y.start=h,y.num=c,y.where=s,y.timeExtent=r,y.objectIds=o):y.objectIds=o||this._getObjectIdsForPage(h,c??0),l&&(y.orderByFields=a),i&&(y.geometry=i),u&&(y.cacheHint=!0);return(await d.queryFeatures(y)).features}async _queryRelatedFeatures(e,t){const{orderByFields:r,returnGeometry:s,supportsCacheHint:i}=this,{layer:o,start:a,pageSize:n}=e,{objectId:u,relatedLayer:l,relationshipId:p}=t,d=o.createQuery(),h=new y({cacheHint:i,num:n??0,objectIds:[u],orderByFields:r,outFields:["*"],relationshipId:p,returnGeometry:s,start:a,where:d.where??void 0}),c=await l.queryRelatedFeatures(h);return c[u]?.features||[]}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new a("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:o,supportsOrderBy:n}=this,u=t.createQuery();return u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),o&&(u.cacheHint=!0),t.queryFeatures(u)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?t.queryAttachments(new c({objectIds:e,where:r})):Promise.resolve({})}_syncLocalCache(e){const{layer:t}=this;if(!t)return;const{objectIdField:r}=t,{itemCache:s}=this;e.forEach((e=>{if(e?.feature){const{feature:t}=e,i=t.getObjectId()??t.attributes[r];if(null!=i){const t=this.getItemIndexByObjectId(i);-1===t?s.add(e):s.splice(t,1,e)}}}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?(this._syncLocalCache(t),t):[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_logError(e,t){u.getLogger(this).error(e,t)}};e([d({readOnly:!0})],g.prototype,"_capabilities",null),e([d()],g.prototype,"_editOperationQueue",void 0),e([d()],g.prototype,"_hasStaleCache",void 0),e([d({readOnly:!0})],g.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],g.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],g.prototype,"_layerWithRelationships",null),e([d()],g.prototype,"_loaded",void 0),e([d()],g.prototype,"_loadError",void 0),e([d()],g.prototype,"_loading",void 0),e([d()],g.prototype,"_objectIdCache",void 0),e([d()],g.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],g.prototype,"_relatedLayer",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],g.prototype,"_relatedLayerSupportsQuery",null),e([d()],g.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],g.prototype,"_canUseRelatedLayer",null),e([d()],g.prototype,"attachmentsEnabled",void 0),e([d()],g.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],g.prototype,"count",void 0),e([d()],g.prototype,"effectiveTimeExtent",null),e([d()],g.prototype,"effectiveWhere",null),e([d({readOnly:!0})],g.prototype,"failures",void 0),e([d()],g.prototype,"filterGeometry",void 0),e([d({readOnly:!0})],g.prototype,"itemCache",void 0),e([d()],g.prototype,"layer",void 0),e([d()],g.prototype,"objectIds",void 0),e([d()],g.prototype,"orderByFields",null),e([d({readOnly:!0})],g.prototype,"querying",null),e([d()],g.prototype,"relationship",null),e([d()],g.prototype,"relationshipConfig",void 0),e([d()],g.prototype,"relationshipIds",null),e([d()],g.prototype,"relationships",null),e([d()],g.prototype,"relatedRecordsEnabled",void 0),e([d()],g.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],g.prototype,"state",null),e([d()],g.prototype,"supportsAdd",null),e([d()],g.prototype,"supportsAttachments",null),e([d()],g.prototype,"supportsCacheHint",null),e([d()],g.prototype,"supportsCacheHintQueryRelated",null),e([d()],g.prototype,"supportsDelete",null),e([d()],g.prototype,"supportsEditing",null),e([d()],g.prototype,"supportsOrderBy",null),e([d()],g.prototype,"supportsPagination",null),e([d()],g.prototype,"supportsQuery",null),e([d()],g.prototype,"supportsQueryRelated",null),e([d()],g.prototype,"supportsUpdate",null),e([d({readOnly:!0})],g.prototype,"syncing",null),e([d()],g.prototype,"timeExtent",void 0),e([d()],g.prototype,"where",void 0),g=e([h("esri.widgets.FeatureTable.support.FeatureStore")],g);const b=g;export{b as default};
|