@arcgis/core 5.0.0-next.31 → 5.0.0-next.32
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/SceneViewer/sceneViewerUtils.d.ts +3 -0
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/1dd867fa7c58c06b79ea.js +1 -0
- package/assets/esri/core/workers/chunks/22d66d1c8dfccdbbcf30.js +1 -0
- package/assets/esri/core/workers/chunks/27bd88e1101873d4ce12.js +1 -0
- package/assets/esri/core/workers/chunks/{5f2cf73fb2944f82661d.js → 433d249c35c56bf15806.js} +34 -34
- package/assets/esri/core/workers/chunks/{b2fbb44e219232e61cbd.js → 794960ec36e11f4416c2.js} +1 -1
- package/assets/esri/core/workers/chunks/{0bfb7db0a151a5e85dd1.js → 8ad6595ad44c2d60c1ce.js} +1 -1
- package/assets/esri/core/workers/chunks/{11bb437437272d8f3e2c.js → 9252854b512237b6a0ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{e615983fab688d515205.js → 944dfa9309da8f49a616.js} +1 -1
- package/assets/esri/core/workers/chunks/{f2f4e34247882eceb50d.js → a2cee5ac0d4df0108425.js} +3 -3
- package/assets/esri/core/workers/chunks/a4b7ba8aec109beb5b4d.js +1 -0
- package/assets/esri/core/workers/chunks/da517b4b07d4d27ce94c.js +1 -0
- package/assets/esri/core/workers/chunks/defc6b50df5018bd9e86.js +1 -0
- package/assets/esri/core/workers/chunks/ed1dabed10ff9f4e0369.js +1 -0
- package/assets/esri/core/workers/chunks/{14dc21fe66c7b98fb456.js → f3127bdf28a1d9b8db27.js} +1 -1
- package/assets/esri/core/workers/chunks/fee942ef802a162e0248.js +1 -0
- package/assets/esri/themes/base/widgets/_Attribution.scss +8 -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/chunks/BlendLayers.glsl.js +1 -1
- package/config.js +1 -1
- package/core/deprecate.js +1 -1
- package/core/keyboard.js +5 -0
- package/interfaces.d.ts +55 -3
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolRepository.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/layers/graphics/LabelDeconflictor.js +1 -1
- package/views/3d/support/Attribution3D.js +5 -0
- package/views/3d/terrain/TileBlendTechniqueConfiguration.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js +4 -4
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/AdjustProjectedPosition.glsl.js +4 -4
- package/views/Attribution.js +5 -0
- package/views/DOMContainer.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/draw/support/managers/DrawTooltipManager.js +5 -0
- package/views/interactive/tooltip/content/TooltipContentDynamic.js +5 -0
- package/views/interactive/tooltip/content/tooltipContentFactory.js +1 -1
- package/views/interactive/tooltip/fields/TooltipField.js +1 -1
- package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +5 -0
- package/views/layers/LayerView.js +1 -1
- package/views/support/AttributionItem.d.ts +4 -0
- package/views/support/AttributionItem.js +5 -0
- package/views/support/LayerViewManager.js +1 -1
- package/views/support/attributionUtils.js +5 -0
- package/views/support/geodesicAreaMeasurementUtils.js +1 -1
- package/views/support/geodesicLengthMeasurementUtils.js +1 -1
- package/views/ui/2d/DefaultUI2D.js +1 -1
- package/views/ui/3d/DefaultUI3D.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/Attribution.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLine.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/decorators/accessibleHandler.js +1 -1
- package/widgets/support/jsxWidgetSupport.js +1 -1
- package/widgets/support/widget.js +1 -1
- package/widgets/support/widgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/25143b919e75d5d2da05.js +0 -1
- package/assets/esri/core/workers/chunks/2d17ed5321ca05acb8e3.js +0 -1
- package/assets/esri/core/workers/chunks/447b53a9280b2b19b7a6.js +0 -1
- package/assets/esri/core/workers/chunks/6ce7ca6bebdc61d8eada.js +0 -1
- package/assets/esri/core/workers/chunks/8fbda0b85731ac77e1d8.js +0 -1
- package/assets/esri/core/workers/chunks/98c32d10a2344cd7a50b.js +0 -1
- package/assets/esri/core/workers/chunks/d5b464ff83ce29b51968.js +0 -1
- package/assets/esri/core/workers/chunks/d777d7cb8df3f21ac97e.js +0 -1
- package/layers/support/attributionUtils.js +0 -5
package/widgets/Attribution.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import{deprecated as t}from"../core/deprecate.js";import has from"../core/has.js";import i from"../core/Logger.js";import{on as r}from"../core/reactiveUtils.js";import{property as s,subclass as o}from"../core/accessorSupport/decorators.js";import n from"./Widget.js";import l from"./Attribution/AttributionViewModel.js";import{globalCss as a}from"./support/globalCss.js";import{messageBundle as c,accessibleHandler as d,tsx as h}from"./support/widget.js";const u="esri-attribution",p={base:u,poweredBy:`${u}__powered-by`,sources:`${u}__sources`,open:`${u}--open`,sourcesOpen:`${u}__sources--open`,link:`${u}__link`};let _=class extends n{constructor(e,r){super(e,r),this._isOpen=!1,this._attributionTextOverflowed=!1,this._prevSourceNodeHeight=0,this._sourcesNode=null,this._overflowRequestAnimationFrame=null,this._resizeObserver=new ResizeObserver(e=>{e.forEach(({target:e})=>{this._scheduleOverflowCheck(e)})}),this._mutationObserver=new MutationObserver(e=>{let t=!1;for(const i of e)if("childList"===i.type||"characterData"===i.type||"attributes"===i.type){t=!0;break}t&&this._sourcesNode&&this._scheduleOverflowCheck(this._sourcesNode)}),this.itemDelimiter=" | ",this.messages=null,this.viewModel=new l,has("esri-deprecation-warnings")&&t(i.getLogger("esri.widgets.Attribution"),"This widget is deprecated. Use View.attributionVisible and View.attributionItems instead.",{replacement:"view.attributionVisible and view.attributionItems",warnOnce:!0})}initialize(){this.addHandles(r(()=>this.viewModel?.items,"change",()=>this.scheduleRender()))}destroy(){this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),null!=this._overflowRequestAnimationFrame&&(cancelAnimationFrame(this._overflowRequestAnimationFrame),this._overflowRequestAnimationFrame=null)}get _isInteractive(){return this._isOpen||this._attributionTextOverflowed}_scheduleOverflowCheck(e){null==this._overflowRequestAnimationFrame&&(this._overflowRequestAnimationFrame=requestAnimationFrame(()=>{this._overflowRequestAnimationFrame=null,this._checkSourceTextOverflow(e)}))}get attributionText(){return this.viewModel.items.reduce((e,t)=>(e.includes(t.text)||e.push(t.text),e),[]).join(this.itemDelimiter)}get icon(){return"description"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const e={[p.open]:this._isOpen};return h("div",{bind:this,class:this.classes(p.base,a.widget,e),dir:"ltr",onclick:this._toggleState,onkeydown:this._toggleState},this._renderSourcesNode(),this._renderPoweredBy())}_renderPoweredBy(){return h("div",{class:p.poweredBy},"Powered by"," ",h("a",{class:p.link,href:"https://www.esri.com/",rel:"noreferrer",target:"_blank"},"Esri"))}_renderSourcesNode(){const e=this._isOpen,t=this._isInteractive,i=t?0:void 0,{attributionText:r}=this,s={[p.sourcesOpen]:e,[a.interactive]:t};return h("div",{afterCreate:this._afterSourcesNodeCreate,bind:this,class:this.classes(p.sources,s),innerHTML:r,tabIndex:i})}_afterSourcesNodeCreate(e){this._prevSourceNodeHeight=e.clientWidth,this._sourcesNode=e,this._resizeObserver.observe(e),this._mutationObserver.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),this._scheduleOverflowCheck(e)}_checkSourceTextOverflow(e){let t=!1;const{clientHeight:i,clientWidth:r,scrollWidth:s}=e,o=s>r,n=this._attributionTextOverflowed!==o;if(this._attributionTextOverflowed=o,n&&(t=!0),this._isOpen){const e=i<this._prevSourceNodeHeight;this._prevSourceNodeHeight=i,e&&(this._isOpen=!1,t=!0)}t&&this.scheduleRender()}_toggleState(){this._isInteractive&&(this._isOpen=!this._isOpen)}};e([s()],_.prototype,"_isOpen",void 0),e([s()],_.prototype,"_isInteractive",null),e([s()],_.prototype,"_attributionTextOverflowed",void 0),e([s()],_.prototype,"_prevSourceNodeHeight",void 0),e([s({readOnly:!0,dependsOn:["viewModel.items.length","itemDelimiter"]})],_.prototype,"attributionText",null),e([s()],_.prototype,"icon",null),e([s()],_.prototype,"itemDelimiter",void 0),e([s()],_.prototype,"label",null),e([s(),c("esri/widgets/Attribution/t9n/Attribution")],_.prototype,"messages",void 0),e([s()],_.prototype,"view",null),e([s({type:l})],_.prototype,"viewModel",void 0),e([d()],_.prototype,"_toggleState",null),_=e([o("esri.widgets.Attribution")],_);const v=_;export{v 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Color.js";import{deprecated as o,esriurl as i}from"../../core/deprecate.js";import{EventedAccessor as r}from"../../core/Evented.js";import{handlesGroup as s}from"../../core/handleUtils.js";import has from"../../core/has.js";import l from"../../core/Logger.js";import{memoize as n}from"../../core/memoize.js";import{watch as p,syncAndInitial as a,sync as u}from"../../core/reactiveUtils.js";import{generateUUID as m}from"../../core/uuid.js";import{property as c,subclass as h}from"../../core/accessorSupport/decorators.js";import d from"../../geometry/Point.js";import{getConfig as f}from"./support/constants.js";import{binaryFindClosest as v}from"./support/profileUtils.js";import{convertSamples as y,convertStatistics as g}from"./support/unitUtils.js";let b=class extends r{constructor(e){super(e),this.type=null,this.id=m(),this.title=null,this.color=new t("#000000"),this.visible=!0,this._getSamplesMemoized=n((e,t)=>y(e,t)),this._getStatisticsMemoized=n((e,t)=>g(e,t)),this.viewVisualizationEnabled=!0,this.result=null,this.effectiveUnits=null,this.numSamplesForPreview=30,this.numSamplesPerChunk=200,this.chartFillEnabled=!0,this.chartStrokeWidth=1.5,this.chartStrokeOffsetY=0,this._viewModel=null,has("esri-deprecation-warnings")&&!e?.isDefaultLine&&o(l.getLogger(this),"This class is deprecated. Use the Elevation Profile component or the elevation profile analysis directly instead.",{see:[`Elevation Profile component reference: ${i}arcgis-elevation-profile/`,`Esri's move to web components: ${i}components-transition-plan/`],replacement:"ElevationProfileAnalysis or <arcgis-elevation-profile></arcgis-elevation-profile>",warnOnce:!0})}normalizeCtorArgs(e){const{isDefaultLine:t,...o}=e??{};return o}get progress(){return null!=this.result&&this.visible?this.result.progress:0}get samples(){return this._getSamplesMemoized(this.result,this.effectiveUnits)}get statistics(){return this._getStatisticsMemoized(this.result,this.effectiveUnits)}get hoveredPoint(){const e=this._viewModel?.hoveredChartPosition;return null!=e?this._getPoint(e):null}get available(){return!0}get hasZ(){const e=this.result;return null!=e&&e.hasZ}get minDemResolution(){return f().defaultDemResolution}queryElevation(){throw new Error("not implemented")}attach(e){return this._viewModel=e,s([p(()=>e.effectiveUnits,e=>{this.effectiveUnits=e},a),p(()=>[e.input],()=>this._onChange(),u)])}toggleVisibility(e){this.visible=void 0===e?!this.visible:e}_onChange(){this.emit("change")}_getPoint(e){const{samples:t,result:o}=this;if(null==t||null==o)return null;const i=t.length;if(0===i)return null;const r=t[i-1].distance,s=v(t,e*r,e=>e.distance);if(null==s)return null;const{x:l,y:n,z:p}=s;return null==p?null:new d({x:l,y:n,z:p,spatialReference:o.spatialReference})}};e([c({nonNullable:!0})],b.prototype,"id",void 0),e([c()],b.prototype,"title",void 0),e([c({type:t,nonNullable:!0})],b.prototype,"color",void 0),e([c({nonNullable:!0})],b.prototype,"visible",void 0),e([c({readOnly:!0})],b.prototype,"progress",null),e([c({readOnly:!0})],b.prototype,"samples",null),e([c({readOnly:!0})],b.prototype,"statistics",null),e([c()],b.prototype,"hoveredPoint",null),e([c()],b.prototype,"viewVisualizationEnabled",void 0),e([c()],b.prototype,"available",null),e([c()],b.prototype,"result",void 0),e([c()],b.prototype,"effectiveUnits",void 0),e([c()],b.prototype,"numSamplesForPreview",void 0),e([c()],b.prototype,"numSamplesPerChunk",void 0),e([c()],b.prototype,"chartFillEnabled",void 0),e([c()],b.prototype,"chartStrokeWidth",void 0),e([c()],b.prototype,"chartStrokeOffsetY",void 0),e([c({readOnly:!0})],b.prototype,"hasZ",null),e([c({readOnly:!0})],b.prototype,"minDemResolution",null),e([c()],b.prototype,"_viewModel",void 0),b=e([h("esri.widgets.ElevationProfile.ElevationProfileLine")],b);const w=b;export{w 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{isSome as r,min as o}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import n from"../../core/Logger.js";import{LRUCache as
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{isSome as r,min as o}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as n}from"../../core/deprecate.js";import u from"../../core/Logger.js";import{LRUCache as a}from"../../core/LRUCache.js";import{destroyMaybe as p}from"../../core/maybe.js";import{memoize as h}from"../../core/memoize.js";import{watch as c,syncAndInitial as d}from"../../core/reactiveUtils.js";import{adaptiveLengthUnit as f,adaptiveVerticalLengthUnit as m,measurementLengthUnits as v}from"../../core/units.js";import{property as g,subclass as y}from"../../core/accessorSupport/decorators.js";import{ElevationQueryTileCache as b}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as _}from"../../properties/defaultUnit.js";import{ElevationProfileController as U}from"./ElevationProfileController.js";import P from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as w}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as j}from"./ElevationProfileTool.js";import{isPolyline as O,isValidInputPath as C}from"./support/geometryUtils.js";import{isProfileGenerationError as E}from"./support/ProfileGenerationError.js";import{createProfileQueue as S}from"./support/profileUtils.js";import{getBoundsInMeters as T,mergeStatistics as D}from"./support/statisticsUtils.js";let L=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=h((t,e)=>({distance:t,elevation:e})),this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._defaultProfileLineGround=new P({isDefaultLine:!0}),this._userUnitOptions=null,this._userUnit=null,t?.isDefaultViewModel||n(u.getLogger(this),"Elevation Profile","arcgis-elevation-profile",{version:"5.0"}),t?.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}normalizeCtorArgs(t){const{isDefaultViewModel:e,...i}=t??{};return i}initialize(){this.addHandles(c(()=>this.view,t=>{if(null==t)return void u.getLogger(this).warnOnce("no view. Widget will be disabled until a view is provided.");this.removeHandles(G);const e="3d"===t.type?t.resourceController:void 0;this.queue?.destroy(),this.queue=S(e?.scheduler);const i=e?.addUpdatingObject(this);i&&this.addHandles(i,G)},d)),this.tool=new j({viewModel:this}),this._controller=new U({viewModel:this})}destroy(){this._defaultProfileLineGround=p(this._defaultProfileLineGround),this._controller=p(this._controller),this._currentTileCache=p(this._currentTileCache),this.tool=p(this.tool),this.queue=p(this.queue)}get profiles(){return this._get("profiles")}set profiles(t){const e=this._get("profiles"),i=t??new s;this._set("profiles",l(i,e))}get state(){const t=this.view;return null!=t&&t.ready?this.tool.state:"disabled"}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=T(this.visibleProfiles.map(t=>t.result)),e=f(t.maxDistance,"meters",this.unit),i=m(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get highlightEnabled(){return this.tool.highlightEnabled}set highlightEnabled(t){this.tool.highlightEnabled=t}get hasVertices(){const t=this.input?.geometry;return O(t)&&t.paths.reduce((t,e)=>t+e.length,0)>0}get hoveredPoints(){return null!=this.input&&this.visible&&this.tool.editable?this.visibleProfiles.map(t=>{const e=t.hoveredPoint;return null!=e?{hoveredPoint:e,color:t.color}:null}).filter(r):[]}get statistics(){return D(this.visibleProfiles.map(t=>t.statistics))}get chartData(){if(null==this.input)return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:r,uniformChartScaling:o}=this,s=r.filter(t=>t.hasZ).map(t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled}));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:r.some(t=>"view"===t.type),uniformScaling:o}}get visibleProfiles(){return this.profiles.toArray().filter(t=>t.available&&t.visible)}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)null!=e&&t.push(e);return t}get minDemResolution(){return o(this.minDemResolutions)}get errorState(){const t=this.input?.geometry;if(!C(t))return"no-valid-input";if(null!=this.error){if(E(this.error))switch(this.error.cause){case"too-complex":return"too-complex";case"invalid-geometry":return"invalid-geometry";case"invalid-elevation-info":return"invalid-elevation-info";case"elevation-query-error":return"no-valid-input"}return"unknown-error"}return 0===this.visibleProfiles.length?"no-visible-profiles":null==this.chartData&&1===this.progress?"refined-but-no-chart-data":"none"}get tileCache(){this._currentTileCache=p(this._currentTileCache);const t=this.view;if(null!=t&&"3d"===t?.type){const e=t.basemapTerrain?.elevationQueryCache;if(null!=e)return e}return null==this._currentTileCache&&(this._currentTileCache=new b(new a(20971520))),this._currentTileCache}get visible(){return this.tool.visible}set visible(t){this.tool.visible=t}get selectAvailable(){for(const t of this.view?.map?.allLayers??[]){if("graphics"===t.type&&!t.internal&&t.graphics.some(t=>"polyline"===t.geometry?.type))return!0;if("geometryType"in t&&"polyline"===t.geometryType)return!0}return!!this.view?.graphics?.some(t=>"polyline"===t.geometry?.type)}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return null!=t&&"3d"===t.type?t.elevationProvider:null}get updating(){const{progress:t}=this,e=!!this.queue?.updating;return t>0&&t<1||e}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return null!=t&&i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(null!=t?t:[]).filter(t=>v.includes(t));return 0===e.length?v.slice():e}};t([g()],L.prototype,"view",void 0),t([g({type:e})],L.prototype,"input",void 0),t([g({type:w,nonNullable:!0})],L.prototype,"profiles",null),t([g({readOnly:!0})],L.prototype,"state",null),t([g({readOnly:!0})],L.prototype,"progress",null),t([g()],L.prototype,"unitOptions",null),t([g()],L.prototype,"unit",null),t([g({readOnly:!0})],L.prototype,"effectiveUnits",null),t([g()],L.prototype,"hoveredChartPosition",void 0),t([g()],L.prototype,"uniformChartScaling",void 0),t([g()],L.prototype,"highlightEnabled",null),t([g({readOnly:!0})],L.prototype,"hoveredPoints",null),t([g({readOnly:!0})],L.prototype,"statistics",null),t([g()],L.prototype,"chartData",null),t([g()],L.prototype,"visibleProfiles",null),t([g()],L.prototype,"minDemResolutions",null),t([g({readOnly:!0})],L.prototype,"minDemResolution",null),t([g({readOnly:!0})],L.prototype,"errorState",null),t([g(_)],L.prototype,"defaultUnit",void 0),t([g()],L.prototype,"queue",void 0),t([g()],L.prototype,"tileCache",null),t([g()],L.prototype,"tool",void 0),t([g()],L.prototype,"visible",null),t([g()],L.prototype,"error",void 0),t([g()],L.prototype,"selectAvailable",null),t([g()],L.prototype,"inputIsSketched",null),t([g()],L.prototype,"elevationProvider",null),t([g()],L.prototype,"updating",null),t([g()],L.prototype,"_defaultProfileLineGround",void 0),t([g()],L.prototype,"_userUnitOptions",void 0),t([g()],L.prototype,"_controller",void 0),t([g()],L.prototype,"_userUnit",void 0),L=t([y("esri.widgets.ElevationProfile.ElevationProfileViewModel")],L);const G=Symbol("updating-object"),k=L;export{k 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{createTask as e}from"../core/asyncUtils.js";import{abortMaybe as i,destroyMaybe as s}from"../core/maybe.js";import{memoize as n}from"../core/memoize.js";import{throwIfAborted as r,createAbortError as o}from"../core/promiseUtils.js";import{watch as a,initial as l}from"../core/reactiveUtils.js";import{property as c,subclass as h}from"../core/accessorSupport/decorators.js";import d from"./Widget.js";import{css as p}from"./ElevationProfile/css.js";import u from"./ElevationProfile/ElevationProfileViewModel.js";import m from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as _}from"./ElevationProfile/components/Legend.js";import{SettingsButton as v}from"./ElevationProfile/components/SettingsButton.js";import{getConfig as C}from"./ElevationProfile/support/constants.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{messageBundle as y,tsx as b,tsxFragment as w}from"./support/widget.js";const k=[{type:"select"},{type:"sketch"}],M={none:null,"no-valid-input":"noProfile","no-visible-profiles":"noProfile","refined-but-no-chart-data":"noProfile","too-complex":"tooComplex","unknown-error":"unknown","invalid-geometry":"invalidGeometry","invalid-elevation-info":"invalidElevationInfo"};let B=class extends d{constructor(t,e){super(t,e),this.viewModel=null,this.visibleElements=new m,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=n((t,e,i,s)=>({chart:t,data:e,stationary:i,messages:s})),this._onZoomOutButtonClick=()=>{this._chart?.zoomOut()},this._onClearButtonClick=()=>{this.viewModel.clear()},t?.viewModel||(this._defaultViewModel=new u({view:t?.view}),this.viewModel=this._defaultViewModel)}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}postInitialize(){this.addHandles([a(()=>({container:this._chartContainer}),({container:t})=>{this._destroyChart(),null!=t&&this._initializeChart(t)},l),a(()=>this._chartUpdateParams,()=>this._updateChart(this._chartUpdateParams),l)])}destroy(){this._destroyChart(),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get input(){return this.viewModel.input}set input(t){this.viewModel.input=t}get profiles(){return this.viewModel.profiles}set profiles(t){this.viewModel.profiles=t}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(t){this.viewModel.unitOptions=t}get unit(){return this.viewModel.unit}set unit(t){this.viewModel.unit=t}get icon(){return"altitude"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}get test(){return{chart:this._chart}}get _selectButtonVisible(){return!0===this.visibleElements.selectButton&&this.viewModel.selectAvailable}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,null==t||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _profilesArray(){return this.profiles.toArray()}render(){const{viewModel:t,visible:e}=this;return b("div",{"aria-label":this.messages.widgetLabel,class:this.classes({[p.base]:e,[f.widget]:e,[f.panel]:e,[f.widgetDisabled]:e&&"disabled"===t.state,[p.refined]:1===t.progress}),key:this},b("div",{bind:this,key:"content-wrapper"},e?this._renderContentForState():null))}_renderContentForState(){switch(this.viewModel.state){case"ready":case"disabled":return this._renderContentForReadyState();case"selecting":return this._renderContentForSelectingState();case"creating":return this._renderContentForCreatingState();case"selected":return this._renderContentForSelectedState();case"created":return this._renderContentForCreatedState()}}_renderContentForReadyState(){const{messages:t,visibleElements:e,_selectButtonVisible:i}=this,{sketchButton:s}=e;let n;return n=s&&i?t.readyPrompt:s?t.readyPromptCreateOnly:i?t.readyPromptSelectOnly:t.errors?.noProfile,this._renderContent({prompt:n,chart:!1,actions:k})}_renderContentForSelectingState(){const{view:t}=this;if(null==t)return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:"select-cancel"}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(null==t)return null;const i=e.hasVertices?[{type:"sketch-cancel"},{type:"sketch-done",disabled:!e.tool.interaction.canStopCreating}]:[{type:"select"},{type:"sketch",disabled:!0}];if("no-valid-input"===e.errorState){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const s=this._getErrorMessage();return s?this._renderContent({chart:!1,actions:i,prompt:s}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:k,prompt:t}):this._renderContent({chart:!0,actions:k})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:k,prompt:t}):this._renderContent({chart:!0,actions:k})}_getErrorMessage(){const t=M[this.viewModel.errorState];return t?this.messages?.errors?.[t]:null}_renderContent(t){const e=null!=t.prompt?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),{viewModel:i}=this,s=null!=i.input;return b(w,null,b("header",{class:p.header,key:"header"},this._zoomOutButtonVisible?this._renderZoomOutButton():null,this.visibleElements.clearButton&&s?this._renderClearButton():null,this.visibleElements.settingsButton?b(v,{messages:this.messages,uniformChartScaling:i.uniformChartScaling,unit:i.unit,unitOptions:i.unitOptions,visibleElements:this.visibleElements,onUniformChartScalingChange:t=>i.uniformChartScaling=t,onUnitChange:t=>i.unit=t}):null),b("div",{class:p.mainContainer,key:"main-container"},e),this.visibleElements.legend?b(_,{effectiveUnits:i.effectiveUnits,messages:this.messages,profiles:this._profilesArray}):null,this._renderActions(t))}_renderZoomOutButton(){const t=this.messages.zoomOut;return b("calcite-action",{appearance:"transparent",class:p.zoomOutButton,"data-testid":"zoom-out-button",icon:"magnifying-glass-minus",key:"zoom-out",onclick:this._onZoomOutButtonClick,scale:"s",text:t,title:t})}_renderClearButton(){const t=this.messages.clearProfile;return b("calcite-action",{appearance:"transparent",class:p.clearButton,"data-testid":"clear-button",icon:"trash",key:"clear-profile",onclick:this._onClearButtonClick,scale:"s",text:t,title:t})}_renderPrompt(t){return[b("div",{bind:this,class:p.promptContainer,key:"prompt-container"},b("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return b("div",{class:p.chartContainer,key:"empty-chart-container"});const{chartData:t,progress:e}=this.viewModel,i=this._chartIsRefined||this._canRenderChart(),s=null!=t&&e<1;return i?b(w,null,this._renderSpinner({size:i?"small":"large",visible:s}),b("div",{afterCreate:this._onChartContainerUpdate,afterRemoved:this._onChartContainerRemoved,afterUpdate:this._onChartContainerUpdate,bind:this,class:p.chartContainer,key:"chart-container"})):b(w,null,this._renderSpinner({size:"large",visible:s}),b("div",{class:p.chartContainer,key:"chart-container-empty"}))}_renderSpinner(t){const e="small"===t.size,i=t.visible??!0;return b("calcite-loader",{class:this.classes(p.chartSpinner,e&&p.chartSpinnerSmall,i&&p.chartSpinnerVisible),"data-testid":"chart-spinner",inline:e,key:"spinner",label:"",scale:"s"})}_canRenderChart(){const t=this.viewModel.chartData;if(null==t)return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:i}of t.lines)e+=null!=i?i.length:0;return t.refined||e<=C().largeChartSamples}_renderActions({actions:t}){const e=t.map(t=>{switch(t.type){case"sketch":return this.visibleElements.sketchButton&&this._renderAction({action:t,className:p.sketchButton,label:this.messages.sketchButtonLabel,onClick:this._onSketchButtonClick,primary:!0});case"sketch-cancel":return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.sketchCancelButton,label:this.messagesCommon.cancel,primary:!1});case"sketch-done":return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:p.sketchDoneButton,label:this.messagesCommon.done,primary:!0});case"select":return this._selectButtonVisible&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:p.selectButton,label:this.messages.selectButtonLabel,primary:!1});case"select-cancel":return this._selectButtonVisible&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.selectCancelButton,label:this.messagesCommon.cancel,primary:!1})}}).filter(Boolean);return e.length?b("footer",{class:p.footer,key:"footer"},e):null}_renderAction({action:t,className:e,label:i,onClick:s,primary:n}){return b("calcite-button",{appearance:n?"solid":"outline-fill",bind:this,class:this.classes(p.actionButton,e),disabled:t.disabled,key:`action-${t.type}`,onclick:s},i)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_updateChart(t){const{data:e,chart:i,messages:s,stationary:n}=t;null!=i&&null!=s&&n&&this._canRenderChart()&&(i.update(t),this._chartIsRefined=null!=e&&e.refined)}_onChartContainerUpdate(t){this._chartContainer=t}_onChartContainerRemoved(t){this._chartContainer===t&&(this._chartContainer=null)}_initializeChart(t){i(this._chartInitTask),this._chartInitTask=e(async e=>{const{createChart:i}=await import("./ElevationProfile/support/chartUtils.js");r(e);const n=await i({container:t,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw s(n),o();this._chart=n,this._updateChart(this._chartUpdateParams)})}_destroyChart(){this._chartInitTask=i(this._chartInitTask),this._chart=s(this._chart),this._chartIsRefined=!1}};t([c({type:u})],B.prototype,"viewModel",void 0),t([c()],B.prototype,"view",null),t([c()],B.prototype,"input",null),t([c()],B.prototype,"profiles",null),t([c()],B.prototype,"unitOptions",null),t([c()],B.prototype,"unit",null),t([c({type:m,nonNullable:!0})],B.prototype,"visibleElements",void 0),t([c()],B.prototype,"icon",null),t([c()],B.prototype,"label",null),t([c()],B.prototype,"visible",null),t([c(),y("esri/widgets/ElevationProfile/t9n/ElevationProfile")],B.prototype,"messages",void 0),t([c(),y("esri/t9n/common")],B.prototype,"messagesCommon",void 0),t([c(),y("esri/core/t9n/Units")],B.prototype,"messagesUnits",void 0),t([c()],B.prototype,"_chartContainer",void 0),t([c()],B.prototype,"_chart",void 0),t([c()],B.prototype,"_chartInitTask",void 0),t([c()],B.prototype,"_chartIsRefined",void 0),t([c()],B.prototype,"_zoomOutButtonVisible",void 0),t([c()],B.prototype,"_selectButtonVisible",null),t([c()],B.prototype,"_chartUpdateParams",null),t([c()],B.prototype,"_chartMessages",null),t([c()],B.prototype,"_profilesArray",null),B=t([h("esri.widgets.ElevationProfile")],B);const S=B;export{S as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import{createTask as e}from"../core/asyncUtils.js";import{deprecateWidget as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{abortMaybe as n,destroyMaybe as r}from"../core/maybe.js";import{memoize as o}from"../core/memoize.js";import{throwIfAborted as a,createAbortError as l}from"../core/promiseUtils.js";import{watch as c,initial as h}from"../core/reactiveUtils.js";import{property as d,subclass as p}from"../core/accessorSupport/decorators.js";import u from"./Widget.js";import{css as m}from"./ElevationProfile/css.js";import _ from"./ElevationProfile/ElevationProfileViewModel.js";import v from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as C}from"./ElevationProfile/components/Legend.js";import{SettingsButton as g}from"./ElevationProfile/components/SettingsButton.js";import{getConfig as f}from"./ElevationProfile/support/constants.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{messageBundle as w,tsx as k,tsxFragment as M}from"./support/widget.js";const B=[{type:"select"},{type:"sketch"}],S={none:null,"no-valid-input":"noProfile","no-visible-profiles":"noProfile","refined-but-no-chart-data":"noProfile","too-complex":"tooComplex","unknown-error":"unknown","invalid-geometry":"invalidGeometry","invalid-elevation-info":"invalidElevationInfo"};let P=class extends u{constructor(t,e){super(t,e),this.viewModel=null,this.visibleElements=new v,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=o((t,e,i,s)=>({chart:t,data:e,stationary:i,messages:s})),this._onZoomOutButtonClick=()=>{this._chart?.zoomOut()},this._onClearButtonClick=()=>{this.viewModel.clear()},i(s.getLogger(this),"Elevation Profile","arcgis-elevation-profile",{version:"5.0"}),t?.viewModel||(this._defaultViewModel=new _({view:t?.view,isDefaultViewModel:!0}),this.viewModel=this._defaultViewModel)}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}postInitialize(){this.addHandles([c(()=>({container:this._chartContainer}),({container:t})=>{this._destroyChart(),null!=t&&this._initializeChart(t)},h),c(()=>this._chartUpdateParams,()=>this._updateChart(this._chartUpdateParams),h)])}destroy(){this._destroyChart(),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get input(){return this.viewModel.input}set input(t){this.viewModel.input=t}get profiles(){return this.viewModel.profiles}set profiles(t){this.viewModel.profiles=t}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(t){this.viewModel.unitOptions=t}get unit(){return this.viewModel.unit}set unit(t){this.viewModel.unit=t}get icon(){return"altitude"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}get test(){return{chart:this._chart}}get _selectButtonVisible(){return!0===this.visibleElements.selectButton&&this.viewModel.selectAvailable}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,null==t||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _profilesArray(){return this.profiles.toArray()}render(){const{viewModel:t,visible:e}=this;return k("div",{"aria-label":this.messages.widgetLabel,class:this.classes({[m.base]:e,[b.widget]:e,[b.panel]:e,[b.widgetDisabled]:e&&"disabled"===t.state,[m.refined]:1===t.progress}),key:this},k("div",{bind:this,key:"content-wrapper"},e?this._renderContentForState():null))}_renderContentForState(){switch(this.viewModel.state){case"ready":case"disabled":return this._renderContentForReadyState();case"selecting":return this._renderContentForSelectingState();case"creating":return this._renderContentForCreatingState();case"selected":return this._renderContentForSelectedState();case"created":return this._renderContentForCreatedState()}}_renderContentForReadyState(){const{messages:t,visibleElements:e,_selectButtonVisible:i}=this,{sketchButton:s}=e;let n;return n=s&&i?t.readyPrompt:s?t.readyPromptCreateOnly:i?t.readyPromptSelectOnly:t.errors?.noProfile,this._renderContent({prompt:n,chart:!1,actions:B})}_renderContentForSelectingState(){const{view:t}=this;if(null==t)return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:"select-cancel"}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(null==t)return null;const i=e.hasVertices?[{type:"sketch-cancel"},{type:"sketch-done",disabled:!e.tool.interaction.canStopCreating}]:[{type:"select"},{type:"sketch",disabled:!0}];if("no-valid-input"===e.errorState){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const s=this._getErrorMessage();return s?this._renderContent({chart:!1,actions:i,prompt:s}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:B,prompt:t}):this._renderContent({chart:!0,actions:B})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:B,prompt:t}):this._renderContent({chart:!0,actions:B})}_getErrorMessage(){const t=S[this.viewModel.errorState];return t?this.messages?.errors?.[t]:null}_renderContent(t){const e=null!=t.prompt?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),{viewModel:i}=this,s=null!=i.input;return k(M,null,k("header",{class:m.header,key:"header"},this._zoomOutButtonVisible?this._renderZoomOutButton():null,this.visibleElements.clearButton&&s?this._renderClearButton():null,this.visibleElements.settingsButton?k(g,{messages:this.messages,uniformChartScaling:i.uniformChartScaling,unit:i.unit,unitOptions:i.unitOptions,visibleElements:this.visibleElements,onUniformChartScalingChange:t=>i.uniformChartScaling=t,onUnitChange:t=>i.unit=t}):null),k("div",{class:m.mainContainer,key:"main-container"},e),this.visibleElements.legend?k(C,{effectiveUnits:i.effectiveUnits,messages:this.messages,profiles:this._profilesArray}):null,this._renderActions(t))}_renderZoomOutButton(){const t=this.messages.zoomOut;return k("calcite-action",{appearance:"transparent",class:m.zoomOutButton,"data-testid":"zoom-out-button",icon:"magnifying-glass-minus",key:"zoom-out",onclick:this._onZoomOutButtonClick,scale:"s",text:t,title:t})}_renderClearButton(){const t=this.messages.clearProfile;return k("calcite-action",{appearance:"transparent",class:m.clearButton,"data-testid":"clear-button",icon:"trash",key:"clear-profile",onclick:this._onClearButtonClick,scale:"s",text:t,title:t})}_renderPrompt(t){return[k("div",{bind:this,class:m.promptContainer,key:"prompt-container"},k("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return k("div",{class:m.chartContainer,key:"empty-chart-container"});const{chartData:t,progress:e}=this.viewModel,i=this._chartIsRefined||this._canRenderChart(),s=null!=t&&e<1;return i?k(M,null,this._renderSpinner({size:i?"small":"large",visible:s}),k("div",{afterCreate:this._onChartContainerUpdate,afterRemoved:this._onChartContainerRemoved,afterUpdate:this._onChartContainerUpdate,bind:this,class:m.chartContainer,key:"chart-container"})):k(M,null,this._renderSpinner({size:"large",visible:s}),k("div",{class:m.chartContainer,key:"chart-container-empty"}))}_renderSpinner(t){const e="small"===t.size,i=t.visible??!0;return k("calcite-loader",{class:this.classes(m.chartSpinner,e&&m.chartSpinnerSmall,i&&m.chartSpinnerVisible),"data-testid":"chart-spinner",inline:e,key:"spinner",label:"",scale:"s"})}_canRenderChart(){const t=this.viewModel.chartData;if(null==t)return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:i}of t.lines)e+=null!=i?i.length:0;return t.refined||e<=f().largeChartSamples}_renderActions({actions:t}){const e=t.map(t=>{switch(t.type){case"sketch":return this.visibleElements.sketchButton&&this._renderAction({action:t,className:m.sketchButton,label:this.messages.sketchButtonLabel,onClick:this._onSketchButtonClick,primary:!0});case"sketch-cancel":return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:m.sketchCancelButton,label:this.messagesCommon.cancel,primary:!1});case"sketch-done":return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:m.sketchDoneButton,label:this.messagesCommon.done,primary:!0});case"select":return this._selectButtonVisible&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:m.selectButton,label:this.messages.selectButtonLabel,primary:!1});case"select-cancel":return this._selectButtonVisible&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:m.selectCancelButton,label:this.messagesCommon.cancel,primary:!1})}}).filter(Boolean);return e.length?k("footer",{class:m.footer,key:"footer"},e):null}_renderAction({action:t,className:e,label:i,onClick:s,primary:n}){return k("calcite-button",{appearance:n?"solid":"outline-fill",bind:this,class:this.classes(m.actionButton,e),disabled:t.disabled,key:`action-${t.type}`,onclick:s},i)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_updateChart(t){const{data:e,chart:i,messages:s,stationary:n}=t;null!=i&&null!=s&&n&&this._canRenderChart()&&(i.update(t),this._chartIsRefined=null!=e&&e.refined)}_onChartContainerUpdate(t){this._chartContainer=t}_onChartContainerRemoved(t){this._chartContainer===t&&(this._chartContainer=null)}_initializeChart(t){n(this._chartInitTask),this._chartInitTask=e(async e=>{const{createChart:i}=await import("./ElevationProfile/support/chartUtils.js");a(e);const s=await i({container:t,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw r(s),l();this._chart=s,this._updateChart(this._chartUpdateParams)})}_destroyChart(){this._chartInitTask=n(this._chartInitTask),this._chart=r(this._chart),this._chartIsRefined=!1}};t([d({type:_})],P.prototype,"viewModel",void 0),t([d()],P.prototype,"view",null),t([d()],P.prototype,"input",null),t([d()],P.prototype,"profiles",null),t([d()],P.prototype,"unitOptions",null),t([d()],P.prototype,"unit",null),t([d({type:v,nonNullable:!0})],P.prototype,"visibleElements",void 0),t([d()],P.prototype,"icon",null),t([d()],P.prototype,"label",null),t([d()],P.prototype,"visible",null),t([d(),w("esri/widgets/ElevationProfile/t9n/ElevationProfile")],P.prototype,"messages",void 0),t([d(),w("esri/t9n/common")],P.prototype,"messagesCommon",void 0),t([d(),w("esri/core/t9n/Units")],P.prototype,"messagesUnits",void 0),t([d()],P.prototype,"_chartContainer",void 0),t([d()],P.prototype,"_chart",void 0),t([d()],P.prototype,"_chartInitTask",void 0),t([d()],P.prototype,"_chartIsRefined",void 0),t([d()],P.prototype,"_zoomOutButtonVisible",void 0),t([d()],P.prototype,"_selectButtonVisible",null),t([d()],P.prototype,"_chartUpdateParams",null),t([d()],P.prototype,"_chartMessages",null),t([d()],P.prototype,"_profilesArray",null),P=t([p("esri.widgets.ElevationProfile")],P);const E=P;export{E as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Map.js";import{rotate as i}from"../../../arcade/geometry/operators.js";import r from"../../../core/Error.js";import{EventedAccessor as a}from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{isAbortError as l}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as h,initial as d}from"../../../core/reactiveUtils.js";import{property as g,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import u from"../../../geometry/Point.js";import y from"../../../geometry/Polygon.js";import v from"../../../geometry/SpatialReference.js";import{e as f}from"../../../chunks/intersectionOperator.js";import{g as _}from"../../../chunks/proximityOperator.js";import w from"../../../layers/GraphicsLayer.js";import R from"../../../layers/ImageryTileLayer.js";import x from"../../../layers/support/RasterFunction.js";import{convolutionKernel as C}from"../../../layers/support/rasterFunctionConstants.js";import I from"../../../layers/support/TileInfo.js";import b from"../../../views/MapView.js";import{getResolutionToScaleFactor as j}from"../../../views/2d/viewpointUtils.js";import{castImageSource as M,logAndThrow as P,getMissingPropertyErrorName as k,getMissingPropertyErrorMessage as H}from"../utils.js";const S={click:"click-handle",enhancements:"enhancements-handle"};let V=class extends a{constructor(e){super(e),this._imageChanged=!1,this._panConstraint=null,this._image=null,this._loadController=null,this._overlays=new w({blendMode:"source-atop"}),this._map=new t,this.autoLoad=!1,this.clickAction="none",this.error=null,this.imageSource=null,this.imageRotation=0,this.navigationManager=null,this.navigationViewModel=null,this.state="ready",this.updatingHandles=new c,this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createImageHandles=()=>{this.removeHandles(S.enhancements),this.addHandles(m(()=>[this.brightness,this.contrast,this.sharpness],([e,t,i])=>{this.image?.loaded&&(this.image.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(this.image,i))},h))},this._createPanConstraint=()=>{const{image:e,imageRenderer:t}=this,r=r=>{if(!(e&&t&&r.targetGeometry&&e.serviceRasterInfo))return r;const{extent:a}=e.serviceRasterInfo,{constraints:s,rotation:o,width:n,height:l}=t,{extent:m}=i(y.fromExtent(a),o,a.center.x,a.center.y),{width:h,height:d}=m,g=r.targetGeometry.clone(),p=s.scaleToZoom(r.scale),c=1/2**p,u=n/l;let v=c*h,f=c*d;p&&(h/n>d/l?f=v/u:v=f*u);const w=m.clone();return w.xmin+=v/2,w.xmax-=v/2,w.ymin+=f/2,w.ymax-=f/2,r.targetGeometry=_(y.fromExtent(w),g).coordinate,this.state="image-loaded",r};return{constrain:r,applyPanConstraint:r}},this._createResizeHandles=e=>{e.removeHandles("resize"),e.addHandles(m(()=>{if(!this.imageRenderer.ready)return;const{extent:t}=e.serviceRasterInfo,{width:r,height:a,rotation:s}=this.imageRenderer,{extent:o}=i(y.fromExtent(t),s,t.center.x,t.center.y),{width:n,height:l}=o;return Math.max(n/r,l/a)},e=>{if(!this.imageRenderer||null==e)return;const{constraints:t,scale:i,spatialReference:r}=this.imageRenderer,a=t.minScale,s=j(r),o=.25*s,n=s*e;let l=n;const m=[];for(;l>o;)m.push(l),l/=2;m.push(l);const{lods:h}=I.create({scales:m});if(t.set({minScale:n,lods:h}),this._imageChanged)return this.imageRenderer.scale=n,void(this._imageChanged=!1);this.imageRenderer.scale=Math.abs(i-a)<=1e-6?n:i},h),"resize")},this._loadImageInternal=(e,t={})=>{this.state="image-loading",this.clearImage(),this.error=null,this._imageChanged=!0;const i="string"==typeof e,r=i?void 0:e.datasetFormat,a=i?e:e.url,{customParameters:o,options:n}=t;return this._image=new R({ioConfig:{skipExtensions:["aux.xml","jgw"],skipMapInfo:!0,datasetFormat:r},url:a,customParameters:o}),this._image.when(e=>{this._updatePanConstraint(),this._createResizeHandles(e),this._map.add(e),this.state="image-loaded"},t=>{l(t)?this.state="image-load-aborted":(this.state="image-load-error",this.error=t,s.getLogger(this).error(`error occurred while loading image ${i?e:JSON.stringify(e)}`,t),this.imageSource=null)}),this._image.load(n)},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._loadNavigationManager=async()=>{if(!this.navigationManager||this.navigationManager?.destroyed){const e=await import("../navigation/NavigationManager.js").then(e=>e.default);this.navigationManager=new e({viewModel:this.navigationViewModel})}return this.navigationManager},this._updatePanConstraint=()=>{this._panConstraint&&this.imageRenderer.constraints.customConstraints.remove(this._panConstraint),this._panConstraint=this._createPanConstraint(),this.imageRenderer.constraints.customConstraints.add(this._panConstraint)},this.addGraphic=(e,t)=>{this._overlays.graphics.add(e,t)},this.addManyGraphics=e=>{this._overlays.addMany(e)},this.clearGraphics=()=>{this._overlays.graphics.removeAll()},this.clearImage=()=>{this.image&&(this._map.layers.remove(this.image),this._image=n(this._image))},this.loadImage=e=>{const{customParameters:t,imageSource:i}=this;return i?this._loadImageInternal(i,{customParameters:t,options:e}):P(this.declaredClass,new r(k("image-viewer"),H("ImageViewerViewModel","imageSource")))},this.navigate=async(e,t)=>this.updatingHandles.addPromise(this.navigateInternal(e,t)),this.navigateInternal=async(e,t)=>{const i=await this._loadNavigationManager();return await i.navigate(e,t)},this.removeGraphic=e=>{this._overlays.remove(e)},this.removeManyGraphics=e=>{this._overlays.removeMany(e)},this._imageRenderer=new b({constraints:{snapToZoom:!0,rotationEnabled:!1},map:this._map,popupEnabled:!1,spatialReference:v.WebMercator,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([m(()=>this.imageSource,e=>{e&&this.autoLoad&&this._loadWithController()},h),m(()=>this.image?.loaded,()=>{this._createImageHandles()}),m(()=>this.imageRotation,()=>{this._rotateImage()}),m(()=>this.imageRenderer.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},d),m(()=>this.imageRenderer.map.allLayers.length,e=>{e&&this.imageRenderer.map.layers.reorder(this._overlays,e-1)},h),m(()=>this.clickAction,e=>{this.removeHandles(S.click),"none"!==e&&this.addHandles(this.imageRenderer.on("click",t=>{if(this.image?.loaded&&this.imageRenderer.ready)switch(e){case"emit":t.stopPropagation(),this.emit("click",t);break;case"hittest":t.stopPropagation(),t.defer(async()=>{const e=await this.imageRenderer.hitTest(t.screenPoint,{include:this._overlays});e.results=e.results.filter(e=>"graphic"===e.type),this.emit("hittest-response",e)});break;case"pixel-location":{if(t.stopPropagation(),!this.image?.serviceRasterInfo||!t.mapPoint)return void this.emit("pixel-location",null);const{extent:e,pixelSize:i}=this.image.serviceRasterInfo,r=(t.mapPoint.x-e.xmin)*i.x,a=(e.ymax-t.mapPoint.y)*i.y,s=new u({x:r,y:a,spatialReference:e.spatialReference});this.emit("pixel-location",s);break}}}))},h)])}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",o(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",o(e,-10,10))}get currentNode(){return this.navigationViewModel?.currentNode}get image(){return this._image}get imagePointsInView(){const{extent:e,ready:t}=this.imageRenderer,r=this.imageRotation,a=this.image?.fullExtent,s=this.image?.serviceRasterInfo,o=!0===this._imageRenderer.allLayerViews.find(({layer:e})=>e===this.image)?.attached;if(!(t&&e&&a&&s&&o))return null;const n=i(y.fromExtent(e),r,e.center.x,e.center.y),l=y.fromExtent(a),m=f(n,l),{rings:h}=m;return h.flat().map(([e,t])=>({x:(e-s.extent.xmin)*s.pixelSize.x,y:(s.extent.ymax-t)*s.pixelSize.y}))}get imageSize(){const{image:e}=this;if(!e?.raster)return null;const{width:t,height:i}=e.raster.rasterInfo;return[t,i]}get imageRenderer(){return this._imageRenderer}get imageView(){return this.imageRenderer.allLayerViews.find(e=>e.layer===this.image)}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",o(e,0,1))}get updating(){return this.updatingHandles.updating}_rotateImage(){this.imageRenderer.constraints.rotationEnabled=!0,this.imageRenderer.rotation=this.imageRotation,this.imageRenderer.constraints.rotationEnabled=!1}sharpenImage(e,t){if(!t)return void(e.rasterFunction=null);const i=[0,-1*t,0,-1*t,4*t+1,-1*t,0,-1*t,0],r=new x({functionName:"Convolution",functionArguments:{type:C.userDefined,cols:3,rows:3,kernel:i,convolutionType:C.userDefined}});e.rasterFunction=r}};e([g()],V.prototype,"_image",void 0),e([g()],V.prototype,"_imageRenderer",void 0),e([g()],V.prototype,"_loadController",void 0),e([g()],V.prototype,"_overlays",void 0),e([g()],V.prototype,"_map",void 0),e([g({type:Boolean})],V.prototype,"autoLoad",void 0),e([g({type:Number})],V.prototype,"brightness",null),e([g()],V.prototype,"clickAction",void 0),e([g({type:Number})],V.prototype,"contrast",null),e([g()],V.prototype,"currentNode",null),e([g({type:Object})],V.prototype,"customParameters",void 0),e([g({type:r})],V.prototype,"error",void 0),e([g({readOnly:!0})],V.prototype,"image",null),e([g({readOnly:!0})],V.prototype,"imagePointsInView",null),e([g({readOnly:!0})],V.prototype,"imageSize",null),e([g({cast:M})],V.prototype,"imageSource",void 0),e([g({readOnly:!0})],V.prototype,"imageRenderer",null),e([g({type:Number})],V.prototype,"imageRotation",void 0),e([g()],V.prototype,"imageView",null),e([g()],V.prototype,"navigationManager",void 0),e([g()],V.prototype,"navigationViewModel",void 0),e([g({type:Number})],V.prototype,"sharpness",null),e([g()],V.prototype,"state",void 0),e([g()],V.prototype,"updatingHandles",void 0),e([g()],V.prototype,"updating",null),V=e([p("esri.widgets.OrientedImageryViewer.components.ImageViewerViewModel")],V);const E=V;export{E as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Map.js";import{rotate as i}from"../../../arcade/geometry/operators.js";import r from"../../../core/Error.js";import{EventedAccessor as a}from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{isAbortError as l}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as h,initial as d}from"../../../core/reactiveUtils.js";import{property as g,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import u from"../../../geometry/Point.js";import y from"../../../geometry/Polygon.js";import v from"../../../geometry/SpatialReference.js";import{e as f}from"../../../chunks/intersectionOperator.js";import{g as _}from"../../../chunks/proximityOperator.js";import w from"../../../layers/GraphicsLayer.js";import R from"../../../layers/ImageryTileLayer.js";import x from"../../../layers/support/RasterFunction.js";import{convolutionKernel as C}from"../../../layers/support/rasterFunctionConstants.js";import I from"../../../layers/support/TileInfo.js";import b from"../../../views/MapView.js";import{getResolutionToScaleFactor as j}from"../../../views/2d/viewpointUtils.js";import{castImageSource as M,logAndThrow as P,getMissingPropertyErrorName as V,getMissingPropertyErrorMessage as k}from"../utils.js";const H={click:"click-handle",enhancements:"enhancements-handle"};let S=class extends a{constructor(e){super(e),this._imageChanged=!1,this._panConstraint=null,this._image=null,this._loadController=null,this._overlays=new w({blendMode:"source-atop"}),this._map=new t,this.autoLoad=!1,this.clickAction="none",this.error=null,this.imageSource=null,this.imageRotation=0,this.navigationManager=null,this.navigationViewModel=null,this.state="ready",this.updatingHandles=new c,this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createImageHandles=()=>{this.removeHandles(H.enhancements),this.addHandles(m(()=>[this.brightness,this.contrast,this.sharpness],([e,t,i])=>{this.image?.loaded&&(this.image.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(this.image,i))},h))},this._createPanConstraint=()=>{const{image:e,imageRenderer:t}=this,r=r=>{if(!(e&&t&&r.targetGeometry&&e.serviceRasterInfo))return r;const{extent:a}=e.serviceRasterInfo,{constraints:s,rotation:o,width:n,height:l}=t,{extent:m}=i(y.fromExtent(a),o,a.center.x,a.center.y),{width:h,height:d}=m,g=r.targetGeometry.clone(),p=s.scaleToZoom(r.scale),c=1/2**p,u=n/l;let v=c*h,f=c*d;p&&(h/n>d/l?f=v/u:v=f*u);const w=m.clone();return w.xmin+=v/2,w.xmax-=v/2,w.ymin+=f/2,w.ymax-=f/2,r.targetGeometry=_(y.fromExtent(w),g).coordinate,this.state="image-loaded",r};return{constrain:r,applyPanConstraint:r}},this._createResizeHandles=e=>{e.removeHandles("resize"),e.addHandles(m(()=>{if(!this.imageRenderer.ready)return;const{extent:t}=e.serviceRasterInfo,{width:r,height:a,rotation:s}=this.imageRenderer,{extent:o}=i(y.fromExtent(t),s,t.center.x,t.center.y),{width:n,height:l}=o;return Math.max(n/r,l/a)},e=>{if(!this.imageRenderer||null==e)return;const{constraints:t,scale:i,spatialReference:r}=this.imageRenderer,a=t.minScale,s=j(r),o=.25*s,n=s*e;let l=n;const m=[];for(;l>o;)m.push(l),l/=2;m.push(l);const{lods:h}=I.create({scales:m});if(t.set({minScale:n,lods:h}),this._imageChanged)return this.imageRenderer.scale=n,void(this._imageChanged=!1);this.imageRenderer.scale=Math.abs(i-a)<=1e-6?n:i},h),"resize")},this._loadImageInternal=(e,t={})=>{this.state="image-loading",this.clearImage(),this.error=null,this._imageChanged=!0;const i="string"==typeof e,r=i?void 0:e.datasetFormat,a=i?e:e.url,{customParameters:o,options:n}=t;return this._image=new R({ioConfig:{skipExtensions:["aux.xml","jgw"],skipMapInfo:!0,datasetFormat:r},url:a,customParameters:o}),this._image.when(e=>{this._updatePanConstraint(),this._createResizeHandles(e),this._map.add(e),this.state="image-loaded"},t=>{l(t)?this.state="image-load-aborted":(this.state="image-load-error",this.error=t,s.getLogger(this).error(`error occurred while loading image ${i?e:JSON.stringify(e)}`,t),this.imageSource=null)}),this._image.load(n)},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._loadNavigationManager=async()=>{if(!this.navigationManager||this.navigationManager?.destroyed){const e=await import("../navigation/NavigationManager.js").then(e=>e.default);this.navigationManager=new e({viewModel:this.navigationViewModel})}return this.navigationManager},this._updatePanConstraint=()=>{this._panConstraint&&this.imageRenderer.constraints.customConstraints.remove(this._panConstraint),this._panConstraint=this._createPanConstraint(),this.imageRenderer.constraints.customConstraints.add(this._panConstraint)},this.addGraphic=(e,t)=>{this._overlays.graphics.add(e,t)},this.addManyGraphics=e=>{this._overlays.addMany(e)},this.clearGraphics=()=>{this._overlays.graphics.removeAll()},this.clearImage=()=>{this.image&&(this._map.layers.remove(this.image),this._image=n(this._image))},this.loadImage=e=>{const{customParameters:t,imageSource:i}=this;return i?this._loadImageInternal(i,{customParameters:t,options:e}):P(this.declaredClass,new r(V("image-viewer"),k("ImageViewerViewModel","imageSource")))},this.navigate=async(e,t)=>this.updatingHandles.addPromise(this.navigateInternal(e,t)),this.navigateInternal=async(e,t)=>{const i=await this._loadNavigationManager();return await i.navigate(e,t)},this.removeGraphic=e=>{this._overlays.remove(e)},this.removeManyGraphics=e=>{this._overlays.removeMany(e)},this._imageRenderer=new b({constraints:{snapToZoom:!0,rotationEnabled:!1},map:this._map,popupEnabled:!1,spatialReference:v.WebMercator,attributionVisible:!1})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([m(()=>this.imageSource,e=>{e&&this.autoLoad&&this._loadWithController()},h),m(()=>this.image?.loaded,()=>{this._createImageHandles()}),m(()=>this.imageRotation,()=>{this._rotateImage()}),m(()=>this.imageRenderer.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},d),m(()=>this.imageRenderer.map.allLayers.length,e=>{e&&this.imageRenderer.map.layers.reorder(this._overlays,e-1)},h),m(()=>this.clickAction,e=>{this.removeHandles(H.click),"none"!==e&&this.addHandles(this.imageRenderer.on("click",t=>{if(this.image?.loaded&&this.imageRenderer.ready)switch(e){case"emit":t.stopPropagation(),this.emit("click",t);break;case"hittest":t.stopPropagation(),t.defer(async()=>{const e=await this.imageRenderer.hitTest(t.screenPoint,{include:this._overlays});e.results=e.results.filter(e=>"graphic"===e.type),this.emit("hittest-response",e)});break;case"pixel-location":{if(t.stopPropagation(),!this.image?.serviceRasterInfo||!t.mapPoint)return void this.emit("pixel-location",null);const{extent:e,pixelSize:i}=this.image.serviceRasterInfo,r=(t.mapPoint.x-e.xmin)*i.x,a=(e.ymax-t.mapPoint.y)*i.y,s=new u({x:r,y:a,spatialReference:e.spatialReference});this.emit("pixel-location",s);break}}}))},h)])}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",o(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",o(e,-10,10))}get currentNode(){return this.navigationViewModel?.currentNode}get image(){return this._image}get imagePointsInView(){const{extent:e,ready:t}=this.imageRenderer,r=this.imageRotation,a=this.image?.fullExtent,s=this.image?.serviceRasterInfo,o=!0===this._imageRenderer.allLayerViews.find(({layer:e})=>e===this.image)?.attached;if(!(t&&e&&a&&s&&o))return null;const n=i(y.fromExtent(e),r,e.center.x,e.center.y),l=y.fromExtent(a),m=f(n,l),{rings:h}=m;return h.flat().map(([e,t])=>({x:(e-s.extent.xmin)*s.pixelSize.x,y:(s.extent.ymax-t)*s.pixelSize.y}))}get imageSize(){const{image:e}=this;if(!e?.raster)return null;const{width:t,height:i}=e.raster.rasterInfo;return[t,i]}get imageRenderer(){return this._imageRenderer}get imageView(){return this.imageRenderer.allLayerViews.find(e=>e.layer===this.image)}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",o(e,0,1))}get updating(){return this.updatingHandles.updating}_rotateImage(){this.imageRenderer.constraints.rotationEnabled=!0,this.imageRenderer.rotation=this.imageRotation,this.imageRenderer.constraints.rotationEnabled=!1}sharpenImage(e,t){if(!t)return void(e.rasterFunction=null);const i=[0,-1*t,0,-1*t,4*t+1,-1*t,0,-1*t,0],r=new x({functionName:"Convolution",functionArguments:{type:C.userDefined,cols:3,rows:3,kernel:i,convolutionType:C.userDefined}});e.rasterFunction=r}};e([g()],S.prototype,"_image",void 0),e([g()],S.prototype,"_imageRenderer",void 0),e([g()],S.prototype,"_loadController",void 0),e([g()],S.prototype,"_overlays",void 0),e([g()],S.prototype,"_map",void 0),e([g({type:Boolean})],S.prototype,"autoLoad",void 0),e([g({type:Number})],S.prototype,"brightness",null),e([g()],S.prototype,"clickAction",void 0),e([g({type:Number})],S.prototype,"contrast",null),e([g()],S.prototype,"currentNode",null),e([g({type:Object})],S.prototype,"customParameters",void 0),e([g({type:r})],S.prototype,"error",void 0),e([g({readOnly:!0})],S.prototype,"image",null),e([g({readOnly:!0})],S.prototype,"imagePointsInView",null),e([g({readOnly:!0})],S.prototype,"imageSize",null),e([g({cast:M})],S.prototype,"imageSource",void 0),e([g({readOnly:!0})],S.prototype,"imageRenderer",null),e([g({type:Number})],S.prototype,"imageRotation",void 0),e([g()],S.prototype,"imageView",null),e([g()],S.prototype,"navigationManager",void 0),e([g()],S.prototype,"navigationViewModel",void 0),e([g({type:Number})],S.prototype,"sharpness",null),e([g()],S.prototype,"state",void 0),e([g()],S.prototype,"updatingHandles",void 0),e([g()],S.prototype,"updating",null),S=e([p("esri.widgets.OrientedImageryViewer.components.ImageViewerViewModel")],S);const E=S;export{E as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{JSONMap as n}from"../../core/jsonMap.js";import d from"../../core/Logger.js";import{rad2deg as h,deg2rad as m}from"../../core/mathUtils.js";import{destroyMaybe as l}from"../../core/maybe.js";import{waitTick as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as v}from"../../core/reactiveUtils.js";import{property as _,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import V from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as M}from"../../layers/orientedImagery/transformations/utils.js";import R from"../../views/SceneView.js";import{fixedImageSize as P}from"../OrientedImageryViewer/constants.js";import{logAndThrow as z,getMissingPropertyErrorName as H,getMissingPropertyErrorMessage as F}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as C,maxPanoramicViewerHFOV as b,minPanoramicViewerHFOV as S,humanBinocularHFOV as O}from"./constants.js";import j from"./PanoramicZoomConditions.js";import I from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as L,createImageSphere as k}from"./utils.js";import{enumeration as A}from"../../core/accessorSupport/decorators/enumeration.js";const G={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let T=class extends s{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new V({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new a([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.closestFeature=null,this.currentTime=0,this.imageSize=null,this.oiViewModel=null,this.videoSource=null,this.videoDuration=void 0,this.videoLoaded=!1,this.videoPaused=null,this.videoMuted=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.video=null,this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(G.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()})],G.navigation)},this._addHFOVHandles=()=>{this.removeHandles(G.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new j({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),G.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new I({view:this.imageRenderer,panoramicZoomConditions:new j({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});t.results=t.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",t)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=M(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadVideo(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.enableAudio=()=>{const{video:e}=this;e&&(e.muted=!1,this.videoMuted=!1)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(t),!0},this.togglePanoramicAudio=()=>{if(this.video){const e=this.video.muted;this.video.muted=!e,this.videoMuted=!e}},this._imageRenderer=new R({map:this._map,viewingMode:"local",camera:{position:C},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([p(()=>this.videoSource,()=>{this.videoSource&&this.autoLoad&&this._loadWithController()},g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(G.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>this.video,e=>{if(e instanceof HTMLVideoElement){this._startVideo();const t=async()=>{this.currentTime=Number(e.currentTime.toFixed(2)),e.currentTime&&await this._updateVidFootprint(e.currentTime)};e.addEventListener("timeupdate",t),e.addEventListener("play",()=>this._updateVideoIcon(e.paused)),e.addEventListener("pause",()=>this._pauseVideoHandler(e))}},g)],G.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*h(Math.atan(Math.tan(m(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?x(b,e/t):b}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?x(S,e/t):S}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*h(Math.atan(Math.tan(m(e/2))*Math.cos(a)))}async _loadVideoInternal(e,t){return this.state="image-loading",this.video=document.createElement("video"),this.video.src=e,this.video.addEventListener("loadedmetadata",()=>{this._setVideoDuration(),this.videoLoaded=!0}),this._updateImageSphere(this.video,t)}_pauseVideoHandler(e){this._updateVideoIcon(e.paused)}_setVideoDuration(){const{video:e}=this;e?.duration&&(this.videoDuration=e.duration)}_startVideo(){try{this.enableAudio();const e=this.oiViewModel.currentBestFeature;e&&this.playPanoramicVideoFromSelectedLocation(e)}catch(e){d.getLogger(this).error("oriented-imagery-viewer:video-load",e)}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=l(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){return await c(t),this._imageGraphic=L(k(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,t).then(()=>{const{size:[e,t]}=this.imageRenderer;this.fov=x(O,e/t)}),this.imageSize=P,this._imageGraphic.geometry}async _updateVidFootprint(e){const t=this.oiViewModel?.featureCache.find(t=>t.attributes.offsetFromStart===Math.floor(e)),{yaw:i,pitch:o,vfov:a,hfov:r}=this,s=!(t?.attributes.offsetFromStart&&a&&r&&i&&o),n=t?.attributes.objectId===this.closestFeature?.attributes.objectId;s||n||(this.closestFeature=t,await this.oiViewModel.updateFootprintPanorama({yaw:i,pitch:o,verticalFieldOfView:a,horizontalFieldOfView:r,feature:t}))}_updateVideoIcon(e){this.videoPaused=!!e}async loadVideo(e){return this._removeImageSphere(),this.videoSource?this._loadVideoInternal(this.videoSource,e):z(this.declaredClass,new r(H("panoramic-viewer"),F("PanoramicViewerViewModel","videoSource")))}playPanoramicVideoHandler(){const{video:e}=this;e&&(e.paused?e.play().catch(e=>{d.getLogger(this).error("error playing video",e)}):e.pause())}playPanoramicVideoFromSelectedLocation(e){const t=e.attributes.offsetFromStart;if(t){const e=this.video;e&&(e.currentTime=t,e.play().catch(e=>{d.getLogger(this).error("error playing video",e)}))}}rewindPanoramicVideoHandler(){const{video:e}=this;e&&(e.currentTime=0,e.play().catch(e=>{d.getLogger(this).error("error playing video",e)}))}};e([_()],T.prototype,"_graphics",void 0),e([_()],T.prototype,"_imageGraphic",void 0),e([_()],T.prototype,"_imageRenderer",void 0),e([_()],T.prototype,"_loadController",void 0),e([_()],T.prototype,"_map",void 0),e([_()],T.prototype,"_zoomViewModel",void 0),e([_({type:Boolean})],T.prototype,"autoLoad",void 0),e([_({type:t})],T.prototype,"camera",null),e([A(new n({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],T.prototype,"clickAction",void 0),e([_()],T.prototype,"closestFeature",void 0),e([_()],T.prototype,"currentTime",void 0),e([_({type:Number})],T.prototype,"fov",null),e([_({readOnly:!0})],T.prototype,"hfov",null),e([_({readOnly:!0})],T.prototype,"imageRenderer",null),e([_()],T.prototype,"imageSize",void 0),e([_()],T.prototype,"oiViewModel",void 0),e([_()],T.prototype,"videoSource",void 0),e([_()],T.prototype,"videoDuration",void 0),e([_()],T.prototype,"videoLoaded",void 0),e([_()],T.prototype,"videoPaused",void 0),e([_()],T.prototype,"videoMuted",void 0),e([_({readOnly:!0})],T.prototype,"maxHFOV",null),e([_({readOnly:!0})],T.prototype,"minHFOV",null),e([_({type:Number})],T.prototype,"pitch",void 0),e([_()],T.prototype,"state",void 0),e([_()],T.prototype,"updatingHandles",void 0),e([_()],T.prototype,"updating",null),e([_({readOnly:!0})],T.prototype,"vfov",null),e([_()],T.prototype,"video",void 0),e([_({type:Number})],T.prototype,"yaw",void 0),T=e([y("esri.widgets.PanoramicViewer.PanoramicVideoViewerViewModel")],T);const E=T;export{E as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{JSONMap as n}from"../../core/jsonMap.js";import d from"../../core/Logger.js";import{rad2deg as h,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as m}from"../../core/maybe.js";import{waitTick as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as v}from"../../core/reactiveUtils.js";import{property as _,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import V from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as M}from"../../layers/orientedImagery/transformations/utils.js";import R from"../../views/SceneView.js";import{fixedImageSize as P}from"../OrientedImageryViewer/constants.js";import{logAndThrow as z,getMissingPropertyErrorName as H,getMissingPropertyErrorMessage as b}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as F,maxPanoramicViewerHFOV as C,minPanoramicViewerHFOV as S,humanBinocularHFOV as O}from"./constants.js";import j from"./PanoramicZoomConditions.js";import I from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as L,createImageSphere as k}from"./utils.js";import{enumeration as A}from"../../core/accessorSupport/decorators/enumeration.js";const G={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let T=class extends s{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new V({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new a([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.closestFeature=null,this.currentTime=0,this.imageSize=null,this.oiViewModel=null,this.videoSource=null,this.videoDuration=void 0,this.videoLoaded=!1,this.videoPaused=null,this.videoMuted=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.video=null,this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(G.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()})],G.navigation)},this._addHFOVHandles=()=>{this.removeHandles(G.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new j({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),G.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new I({view:this.imageRenderer,panoramicZoomConditions:new j({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});t.results=t.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",t)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=M(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadVideo(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.enableAudio=()=>{const{video:e}=this;e&&(e.muted=!1,this.videoMuted=!1)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(t),!0},this.togglePanoramicAudio=()=>{if(this.video){const e=this.video.muted;this.video.muted=!e,this.videoMuted=!e}},this._imageRenderer=new R({map:this._map,viewingMode:"local",camera:{position:F},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([p(()=>this.videoSource,()=>{this.videoSource&&this.autoLoad&&this._loadWithController()},g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(G.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>this.video,e=>{if(e instanceof HTMLVideoElement){this._startVideo();const t=async()=>{this.currentTime=Number(e.currentTime.toFixed(2)),e.currentTime&&await this._updateVidFootprint(e.currentTime)};e.addEventListener("timeupdate",t),e.addEventListener("play",()=>this._updateVideoIcon(e.paused)),e.addEventListener("pause",()=>this._pauseVideoHandler(e))}},g)],G.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*h(Math.atan(Math.tan(l(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?x(C,e/t):C}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?x(S,e/t):S}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*h(Math.atan(Math.tan(l(e/2))*Math.cos(a)))}async _loadVideoInternal(e,t){return this.state="image-loading",this.video=document.createElement("video"),this.video.src=e,this.video.addEventListener("loadedmetadata",()=>{this._setVideoDuration(),this.videoLoaded=!0}),this._updateImageSphere(this.video,t)}_pauseVideoHandler(e){this._updateVideoIcon(e.paused)}_setVideoDuration(){const{video:e}=this;e?.duration&&(this.videoDuration=e.duration)}_startVideo(){try{this.enableAudio();const e=this.oiViewModel.currentBestFeature;e&&this.playPanoramicVideoFromSelectedLocation(e)}catch(e){d.getLogger(this).error("oriented-imagery-viewer:video-load",e)}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=m(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){return await c(t),this._imageGraphic=L(k(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,t).then(()=>{const{size:[e,t]}=this.imageRenderer;this.fov=x(O,e/t)}),this.imageSize=P,this._imageGraphic.geometry}async _updateVidFootprint(e){const t=this.oiViewModel?.featureCache.find(t=>t.attributes.offsetFromStart===Math.floor(e)),{yaw:i,pitch:o,vfov:a,hfov:r}=this,s=!(t?.attributes.offsetFromStart&&a&&r&&i&&o),n=t?.attributes.objectId===this.closestFeature?.attributes.objectId;s||n||(this.closestFeature=t,await this.oiViewModel.updateFootprintPanorama({yaw:i,pitch:o,verticalFieldOfView:a,horizontalFieldOfView:r,feature:t}))}_updateVideoIcon(e){this.videoPaused=!!e}async loadVideo(e){return this._removeImageSphere(),this.videoSource?this._loadVideoInternal(this.videoSource,e):z(this.declaredClass,new r(H("panoramic-viewer"),b("PanoramicViewerViewModel","videoSource")))}playPanoramicVideoHandler(){const{video:e}=this;e&&(e.paused?e.play().catch(e=>{d.getLogger(this).error("error playing video",e)}):e.pause())}playPanoramicVideoFromSelectedLocation(e){const t=e.attributes.offsetFromStart;if(t){const e=this.video;e&&(e.currentTime=t,e.play().catch(e=>{d.getLogger(this).error("error playing video",e)}))}}rewindPanoramicVideoHandler(){const{video:e}=this;e&&(e.currentTime=0,e.play().catch(e=>{d.getLogger(this).error("error playing video",e)}))}};e([_()],T.prototype,"_graphics",void 0),e([_()],T.prototype,"_imageGraphic",void 0),e([_()],T.prototype,"_imageRenderer",void 0),e([_()],T.prototype,"_loadController",void 0),e([_()],T.prototype,"_map",void 0),e([_()],T.prototype,"_zoomViewModel",void 0),e([_({type:Boolean})],T.prototype,"autoLoad",void 0),e([_({type:t})],T.prototype,"camera",null),e([A(new n({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],T.prototype,"clickAction",void 0),e([_()],T.prototype,"closestFeature",void 0),e([_()],T.prototype,"currentTime",void 0),e([_({type:Number})],T.prototype,"fov",null),e([_({readOnly:!0})],T.prototype,"hfov",null),e([_({readOnly:!0})],T.prototype,"imageRenderer",null),e([_()],T.prototype,"imageSize",void 0),e([_()],T.prototype,"oiViewModel",void 0),e([_()],T.prototype,"videoSource",void 0),e([_()],T.prototype,"videoDuration",void 0),e([_()],T.prototype,"videoLoaded",void 0),e([_()],T.prototype,"videoPaused",void 0),e([_()],T.prototype,"videoMuted",void 0),e([_({readOnly:!0})],T.prototype,"maxHFOV",null),e([_({readOnly:!0})],T.prototype,"minHFOV",null),e([_({type:Number})],T.prototype,"pitch",void 0),e([_()],T.prototype,"state",void 0),e([_()],T.prototype,"updatingHandles",void 0),e([_()],T.prototype,"updating",null),e([_({readOnly:!0})],T.prototype,"vfov",null),e([_()],T.prototype,"video",void 0),e([_({type:Number})],T.prototype,"yaw",void 0),T=e([y("esri.widgets.PanoramicViewer.PanoramicVideoViewerViewModel")],T);const E=T;export{E as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import r from"../../request.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as h}from"../../core/Evented.js";import{JSONMap as m}from"../../core/jsonMap.js";import{rad2deg as d,deg2rad as l}from"../../core/mathUtils.js";import{throwIfAborted as c,isAbortError as p,waitTick as g}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as y,when as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as f,subclass as w}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as M}from"../../core/support/UpdatingHandles.js";import P from"../../geometry/SpatialReference.js";import R from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as V}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as z}from"../../support/guards.js";import C from"../../views/SceneView.js";import{logAndThrow as H,getMissingPropertyErrorName as k,getMissingPropertyErrorMessage as G}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as S,defaultImageSphereSize as I,maxPanoramicViewerHFOV as O,minPanoramicViewerHFOV as b,humanBinocularHFOV as j}from"./constants.js";import x from"./PanoramicZoomConditions.js";import A from"./PanoramicZoomViewModel.js";import{meshToGraphic as F,findDiagonalFOV as T,loadRaster as L,loadPyramid as N,loadMeshes as E,createImageSphere as W}from"./utils.js";import{enumeration as D}from"../../core/accessorSupport/decorators/enumeration.js";const Z={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let U=class extends h{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=[],this._graphics=new R({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new C({map:this._map,viewingMode:"local",camera:{position:S},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:P.WebMercator,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new A({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new x({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=I/2,this.imageSize=null,this.imageSource=null,this.navigationManager=null,this.navigationViewModel=null,this.pitch=90,this.state="ready",this.updatingHandles=new M,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(Z.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,Z.navigation)},this._addHFOVHandles=()=>{this.removeHandles(Z.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new x({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},y),Z.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new A({view:this.imageRenderer,panoramicZoomConditions:new x({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=o(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,o=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.includes(`${e.level}/${e.row}/${e.column}`));if(!o?.length)return;const s=await Promise.all(o.map(async i=>await i.loadMesh({signal:e})));c(e);const n=s.map(F);n.forEach((e,i)=>{const t=o[i].key;e.attributes={key:t},this.tileCache.push(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(z);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const i=V(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:P.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadNavigationManager=async()=>{if(!this.navigationManager||this.navigationManager?.destroyed){const e=await import("../OrientedImageryViewer/navigation/NavigationManagerPanoramic.js").then(e=>e.default);this.navigationManager=new e({viewModel:this.navigationViewModel})}return this.navigationManager},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.navigate=async(e,i)=>this.updatingHandles.addPromise(this.navigateInternal(e,i)),this.navigateInternal=async(e,i)=>{const t=await this._loadNavigationManager();return await t.navigate(e,i)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.imageSource,()=>{this.imageSource&&this.autoLoad&&this._loadWithController()},y),u(()=>this.fov,()=>{this._reloadCamera()},y),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},y),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},y),_(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},y),u(()=>this.clickAction,e=>{this.removeHandles(Z.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},y),u(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(z),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],Z.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?T(O,e/i):O}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?T(b,e/i):b}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray()),this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache=[]}async _loadImageInternal(e,i){let t;this.state="image-loading";try{t=(await r(e,{responseType:"image",...i})).data}catch(a){throw p(a)?this.state="image-load-aborted":this.state="image-load-error",a}return this._updateImageSphere(t,i)}async loadImageTiled(e,i){this._removeImageSphere(),this.state="image-loading";try{const t=await L(e,i),a=await N(t,i),r=a.getLowResolutionTiles(),o=await E(r,i),{imageSize:s}=a;if(c(i),!r?.length)throw new n("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",{imageSource:e});this.imagePyramid=a,this.imagePyramidLevel=a.maximumPyramidLevel;const h=o.map(F);h.forEach((e,i)=>{const t=r[i].key;e.attributes={key:t},this.tileCache.push(t)}),this._imageGraphic=h,this._graphics.addMany(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=T(j,e/i)}),this.imageSize=s}catch(t){throw this.state=p(t)?"image-load-aborted":"image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async _updateImageSphere(e,i){return await g(i),this._imageGraphic=F(W(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=T(j,e/i)}),this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):H(this.declaredClass,new n(k("panoramic-viewer"),G("PanoramicViewerViewModel","imageSource")))}};e([f()],U.prototype,"_graphics",void 0),e([f()],U.prototype,"_imageGraphic",void 0),e([f({constructOnly:!0})],U.prototype,"currentGraphics",void 0),e([f()],U.prototype,"imagePyramid",void 0),e([f()],U.prototype,"imagePyramidLevel",void 0),e([f()],U.prototype,"_map",void 0),e([f()],U.prototype,"_imageRenderer",void 0),e([f()],U.prototype,"_loadController",void 0),e([f()],U.prototype,"zoomViewModel",void 0),e([f({type:Boolean})],U.prototype,"autoLoad",void 0),e([f({type:i})],U.prototype,"camera",null),e([D(new m({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],U.prototype,"clickAction",void 0),e([f()],U.prototype,"distanceFactor",null),e([f({type:Number})],U.prototype,"fov",null),e([f({readOnly:!0})],U.prototype,"hfov",null),e([f()],U.prototype,"imageMeshDistance",void 0),e([f({readOnly:!0})],U.prototype,"imageRenderer",null),e([f()],U.prototype,"imageSize",void 0),e([f()],U.prototype,"imageSource",void 0),e([f({readOnly:!0})],U.prototype,"maxHFOV",null),e([f({readOnly:!0})],U.prototype,"minHFOV",null),e([f()],U.prototype,"navigationViewModel",void 0),e([f({type:Number})],U.prototype,"pitch",void 0),e([f()],U.prototype,"state",void 0),e([f()],U.prototype,"updatingHandles",void 0),e([f()],U.prototype,"updating",null),e([f({readOnly:!0})],U.prototype,"vfov",null),e([f({type:Number})],U.prototype,"yaw",void 0),U=e([w("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],U);const q=U;export{q as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import r from"../../request.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as h}from"../../core/Evented.js";import{JSONMap as m}from"../../core/jsonMap.js";import{rad2deg as d,deg2rad as l}from"../../core/mathUtils.js";import{throwIfAborted as c,isAbortError as p,waitTick as g}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as y,when as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as f,subclass as w}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as M}from"../../core/support/UpdatingHandles.js";import P from"../../geometry/SpatialReference.js";import R from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as V}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as z}from"../../support/guards.js";import C from"../../views/SceneView.js";import{logAndThrow as H,getMissingPropertyErrorName as k,getMissingPropertyErrorMessage as G}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as S,defaultImageSphereSize as b,maxPanoramicViewerHFOV as I,minPanoramicViewerHFOV as O,humanBinocularHFOV as j}from"./constants.js";import x from"./PanoramicZoomConditions.js";import A from"./PanoramicZoomViewModel.js";import{meshToGraphic as F,findDiagonalFOV as T,loadRaster as L,loadPyramid as N,loadMeshes as E,createImageSphere as W}from"./utils.js";import{enumeration as D}from"../../core/accessorSupport/decorators/enumeration.js";const Z={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let U=class extends h{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=[],this._graphics=new R({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new C({map:this._map,viewingMode:"local",camera:{position:S},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:P.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new A({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new x({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=b/2,this.imageSize=null,this.imageSource=null,this.navigationManager=null,this.navigationViewModel=null,this.pitch=90,this.state="ready",this.updatingHandles=new M,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(Z.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,Z.navigation)},this._addHFOVHandles=()=>{this.removeHandles(Z.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new x({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},y),Z.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new A({view:this.imageRenderer,panoramicZoomConditions:new x({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=o(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,o=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.includes(`${e.level}/${e.row}/${e.column}`));if(!o?.length)return;const s=await Promise.all(o.map(async i=>await i.loadMesh({signal:e})));c(e);const n=s.map(F);n.forEach((e,i)=>{const t=o[i].key;e.attributes={key:t},this.tileCache.push(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(z);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const i=V(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:P.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadNavigationManager=async()=>{if(!this.navigationManager||this.navigationManager?.destroyed){const e=await import("../OrientedImageryViewer/navigation/NavigationManagerPanoramic.js").then(e=>e.default);this.navigationManager=new e({viewModel:this.navigationViewModel})}return this.navigationManager},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.navigate=async(e,i)=>this.updatingHandles.addPromise(this.navigateInternal(e,i)),this.navigateInternal=async(e,i)=>{const t=await this._loadNavigationManager();return await t.navigate(e,i)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.imageSource,()=>{this.imageSource&&this.autoLoad&&this._loadWithController()},y),u(()=>this.fov,()=>{this._reloadCamera()},y),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},y),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},y),_(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},y),u(()=>this.clickAction,e=>{this.removeHandles(Z.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},y),u(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(z),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],Z.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?T(I,e/i):I}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?T(O,e/i):O}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray()),this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache=[]}async _loadImageInternal(e,i){let t;this.state="image-loading";try{t=(await r(e,{responseType:"image",...i})).data}catch(a){throw p(a)?this.state="image-load-aborted":this.state="image-load-error",a}return this._updateImageSphere(t,i)}async loadImageTiled(e,i){this._removeImageSphere(),this.state="image-loading";try{const t=await L(e,i),a=await N(t,i),r=a.getLowResolutionTiles(),o=await E(r,i),{imageSize:s}=a;if(c(i),!r?.length)throw new n("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",{imageSource:e});this.imagePyramid=a,this.imagePyramidLevel=a.maximumPyramidLevel;const h=o.map(F);h.forEach((e,i)=>{const t=r[i].key;e.attributes={key:t},this.tileCache.push(t)}),this._imageGraphic=h,this._graphics.addMany(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=T(j,e/i)}),this.imageSize=s}catch(t){throw this.state=p(t)?"image-load-aborted":"image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async _updateImageSphere(e,i){return await g(i),this._imageGraphic=F(W(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=T(j,e/i)}),this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):H(this.declaredClass,new n(k("panoramic-viewer"),G("PanoramicViewerViewModel","imageSource")))}};e([f()],U.prototype,"_graphics",void 0),e([f()],U.prototype,"_imageGraphic",void 0),e([f({constructOnly:!0})],U.prototype,"currentGraphics",void 0),e([f()],U.prototype,"imagePyramid",void 0),e([f()],U.prototype,"imagePyramidLevel",void 0),e([f()],U.prototype,"_map",void 0),e([f()],U.prototype,"_imageRenderer",void 0),e([f()],U.prototype,"_loadController",void 0),e([f()],U.prototype,"zoomViewModel",void 0),e([f({type:Boolean})],U.prototype,"autoLoad",void 0),e([f({type:i})],U.prototype,"camera",null),e([D(new m({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],U.prototype,"clickAction",void 0),e([f()],U.prototype,"distanceFactor",null),e([f({type:Number})],U.prototype,"fov",null),e([f({readOnly:!0})],U.prototype,"hfov",null),e([f()],U.prototype,"imageMeshDistance",void 0),e([f({readOnly:!0})],U.prototype,"imageRenderer",null),e([f()],U.prototype,"imageSize",void 0),e([f()],U.prototype,"imageSource",void 0),e([f({readOnly:!0})],U.prototype,"maxHFOV",null),e([f({readOnly:!0})],U.prototype,"minHFOV",null),e([f()],U.prototype,"navigationViewModel",void 0),e([f({type:Number})],U.prototype,"pitch",void 0),e([f()],U.prototype,"state",void 0),e([f()],U.prototype,"updatingHandles",void 0),e([f()],U.prototype,"updating",null),e([f({readOnly:!0})],U.prototype,"vfov",null),e([f({type:Number})],U.prototype,"yaw",void 0),U=e([w("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],U);const q=U;export{q as default};
|
package/widgets/Widget.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{fetchMessageBundle as t,onLocaleChange as r}from"../intl.js";import{byId as s}from"../core/domUtils.js";import{EventedAccessor as o}from"../core/Evented.js";import{isEventedOrEventTarget as i,on as n}from"../core/events.js";import"../core/has.js";import{clone as d}from"../core/lang.js";import a from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{EsriPromiseMixin as c}from"../core/Promise.js";import{debounce as h,throwIfNotAbortError as p}from"../core/promiseUtils.js";import{watch as u,syncAndInitial as m,when as g}from"../core/reactiveUtils.js";import{generateUUID as y}from"../core/uuid.js";import{property as v,subclass as _}from"../core/accessorSupport/decorators.js";import{runTracked as f}from"../core/accessorSupport/tracking.js";import{SimpleTrackingTarget as j}from"../core/accessorSupport/tracking/SimpleTrackingTarget.js";import{createAdvancedProjector as b}from"../libs/maquette-advanced-projector/projector.js";import{commitAssetPath as w}from"./support/componentsUtils.js";import{isWidgetConstructor as R,processWidgets as S}from"./support/jsxWidgetSupport.js";import{widgetSymbol as P,widgetTestDataSymbol as k}from"./support/symbols.js";import{registerAlive as
|
|
5
|
+
import{__decorate as e}from"tslib";import{fetchMessageBundle as t,onLocaleChange as r}from"../intl.js";import{byId as s}from"../core/domUtils.js";import{EventedAccessor as o}from"../core/Evented.js";import{isEventedOrEventTarget as i,on as n}from"../core/events.js";import"../core/has.js";import{clone as d}from"../core/lang.js";import a from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{EsriPromiseMixin as c}from"../core/Promise.js";import{debounce as h,throwIfNotAbortError as p}from"../core/promiseUtils.js";import{watch as u,syncAndInitial as m,when as g}from"../core/reactiveUtils.js";import{generateUUID as y}from"../core/uuid.js";import{property as v,subclass as _}from"../core/accessorSupport/decorators.js";import{runTracked as f}from"../core/accessorSupport/tracking.js";import{SimpleTrackingTarget as j}from"../core/accessorSupport/tracking/SimpleTrackingTarget.js";import{createAdvancedProjector as b}from"../libs/maquette-advanced-projector/projector.js";import{commitAssetPath as w}from"./support/componentsUtils.js";import{isWidgetConstructor as R,processWidgets as S}from"./support/jsxWidgetSupport.js";import{widgetSymbol as P,widgetTestDataSymbol as k}from"./support/symbols.js";import{registerAlive as C,registerLoading as E}from"./support/tests.js";import{getVNodeCache as F,setVNodeCache as L,deleteVNodeCache as T,clearVNodeCache as I}from"./support/vnodeCache.js";import{classes as N}from"./support/widget.js";var H;let $=0;function U(e,t){const r=Object.prototype.hasOwnProperty;for(const s in t)r.call(t,s)&&r.call(e,s)&&(null!=e[s]&&null!=t[s]&&"object"==typeof e[s]&&"object"==typeof t[s]?U(e[s],t[s]):e[s]=t[s]);return e}const z=b({postProcessProjectionOptions(e){const t=e.eventHandlerInterceptor,r=/capture$/i;e.eventHandlerInterceptor=(e,s,o,i)=>{const n=t?.(e,s,o,i),d=r.test(e);if(!((e=e.replace(r,"")).toLowerCase()in o)||d){const t=e[2].toLowerCase()+e.slice(3),r=e=>n?.call(o,e);o.addEventListener(t,r,d);const s=()=>o.removeEventListener(t,r,d),a=i.afterRemoved;i.afterRemoved=e=>{a?.(e),s()}}return n}},handleInterceptedEvent(e,t,r,s){const{eventPhase:o,type:i}=s,n=o===Event.CAPTURING_PHASE;let d=`on${i}${n?"capture":""}`;const a=t.properties;(a&&d in a||(d=`on${i[0].toUpperCase()}${i.slice(1)}${n?"Capture":""}`,a&&d in a))&&(I(),e.scheduleRender(),a[d].call(a.bind||r,s))}});let x=!1,O=class extends(c(o)){static{this[H]=!0}constructor(e,r){super(e,r),this._attached=!1,this._projector=z,this._readyForTrueRender=!1,this.key=this,this.autoRenderingEnabled=!0,this._loadLocale=h(async()=>{if(this._messageBundleProps?.length){const e=await Promise.allSettled(this._messageBundleProps.map(async({bundlePath:e,propertyName:r})=>{if(this.destroyed)return;let s=await t(e);this.destroyed||(this.uiStrings&&Object.keys(this.uiStrings)&&(s=U(d(s),this.uiStrings)),this[r]=s)}));if(this.destroyed)return;for(const t of e)"rejected"===t.status&&a.getLogger(this).error("widget-intl:locale-error",this.declaredClass,t.reason)}await this.loadLocale()}),this.addHandles(C()),w();const s="esri-widget-uid-"+y(),o=this.render.bind(this);this._trackingTarget=new j(()=>{this.autoRenderingEnabled&&this.scheduleRender()});const i=()=>({vnodeSelector:"div",properties:{key:`${s}-hidden`,class:"",styles:{display:"none"}},domNode:null,children:void 0,text:void 0}),n=()=>{if(!this._readyForTrueRender||this.destroyed)return null;const e=o()??i(),t=e.properties??={};if(t.key??=s,R(e.vnodeSelector)){if(!this.visible)return i()}else this.visible?t.styles||(t.styles={}):(t.class="",t.styles={display:"none"}),t.styles.display??="";let r=0;return e.children?.forEach(e=>{R(e.vnodeSelector)||(e.properties??={},e.properties.key??=`${this.id}--${r++}`)}),S(this,e)};this.render=()=>{if(x)return n();let e=F(this)??null;if(e)return e;this._trackingTarget.clear(),x=!0;try{e=f(this._trackingTarget,n)}catch(t){throw a.getLogger(this).error(t),t}finally{x=!1}return e&&L(this,e),e};const l=this.beforeFirstRender();l?this._resourcesFetch=l.then(()=>{this.destroyed||(this._readyForTrueRender=!0,this._postInitialize())}):(this._resourcesFetch=Promise.resolve().then(()=>{this.destroyed||this._postInitialize()}),this._readyForTrueRender=!0),this.addResolvingPromise(this._resourcesFetch),E(this._resourcesFetch)}normalizeCtorArgs(e,t){const r={...e};return t&&(r.container=t),r}postInitialize(){}beforeFirstRender(){const e=this.loadDependencies();return this._messageBundleProps?.length||e?Promise.all([e,this._loadLocale()]).then(()=>{}).catch(p):null}loadDependencies(){return null}loadLocale(){return null}destroy(){this.destroyed||(l(this._trackingTarget),l(this.viewModel),this._detach(this.container),this._set("container",null),this.render=()=>null,this._projector=null,T(this))}get container(){return this._get("container")}set container(e){this._get("container")||this._set("container",s(e))}get destroyed(){return super.destroyed}get domNode(){return this.container}set domNode(e){this.container=e}get icon(){return null}set icon(e){this._overrideIfSome("icon",e)}get id(){return this._get("id")||this.container?.id||Date.now().toString(16)+"-widget-"+$++}set id(e){e&&this._set("id",e)}get label(){return this.declaredClass.split(".").pop()}set label(e){this._overrideIfSome("label",e)}get renderable(){return this._resourcesFetch}get visible(){return this._get("visible")}set visible(e){this._set("visible",e)}get[(H=P,k)](){return{projector:this._projector}}static{this.vnodeSelector="div"}render(){throw new Error("not implemented")}removeContainer(){this._set("container",null)}scheduleRender(){this.destroyed||(T(this),this._projector.scheduleRender())}classes(...e){return N.apply(this,e)}renderNow(){T(this),this._projector.renderNow()}_postInitialize(){if(this.destroyed)return;this.scheduleRender(),this._delegatedEventNames?.length&&this.addHandles(u(()=>this.viewModel,(e,t)=>{t&&this.removeHandles("delegated-events"),e&&i(e)&&this.addHandles(this._delegatedEventNames.map(t=>n(e,t,e=>{this.emit(t,e)})),"delegated-events")},m)),this.postInitialize();const e=async()=>{await this._loadLocale().catch(p),this.scheduleRender()};this.addHandles([r(e),u(()=>this.uiStrings,e)]),this.addHandles(g(()=>this.container,e=>{this.destroyed||this._attach(e)},{initial:!0,once:!0}))}_attach(e){e&&(this._projector.merge(e,this.render),this._attached=!0)}_detach(e){this._attached&&(this._projector.detach(this.render),this._attached=!1),e?.parentNode?.removeChild(e)}};e([v()],O.prototype,"_readyForTrueRender",void 0),e([v({value:null})],O.prototype,"container",null),e([v()],O.prototype,"icon",null),e([v()],O.prototype,"id",null),e([v()],O.prototype,"label",null),e([v()],O.prototype,"renderable",null),e([v()],O.prototype,"uiStrings",void 0),e([v()],O.prototype,"viewModel",void 0),e([v({value:!0})],O.prototype,"visible",null),e([v()],O.prototype,"key",void 0),e([v()],O.prototype,"children",void 0),e([v()],O.prototype,"afterCreate",void 0),e([v()],O.prototype,"afterUpdate",void 0),e([v()],O.prototype,"afterRemoved",void 0),O=e([_("esri.widgets.Widget")],O);const A=O;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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isActivationKey as n}from"
|
|
5
|
+
import{isActivationKey as n}from"../../../core/keyboard.js";function t(){return function(n,t){if(!n[t])throw new TypeError(`Cannot auto bind undefined function '${String(t)}'`);return{value:r(n[t])}}}function e(n){const t=n?.type;return n instanceof KeyboardEvent||"keyup"===t||"keydown"===t||"keypress"===t}function r(t){return function(r,...o){e(r)?n(r.key)&&(r.preventDefault(),r.stopPropagation(),r.target.click()):t.call(this,r,...o)}}export{t as accessibleHandler};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{makeHandle as e}from"../../core/handleUtils.js";import{widgetSymbol as t,widgetTestDataSymbol as r}from"./symbols.js";const o=[],n={},i=new
|
|
5
|
+
import{makeHandle as e}from"../../core/handleUtils.js";import{widgetSymbol as t,widgetTestDataSymbol as r}from"./symbols.js";const o=[],n={},i=new Map;function d(e,t){let r=t.children;if(r?.length)for(let o=0;o<r.length;++o)r[o]=d(e,r[o]);else r=o;const i=t.vnodeSelector;if(f(i)){const o=t.properties||n,d=o.key||i,f={key:d,afterCreate:c,afterUpdate:s,afterRemoved:a,parentWidget:e,widgetConstructor:i,widgetProperties:{...o,key:d,children:r}};return{vnodeSelector:i.vnodeSelector,properties:f,children:void 0,text:void 0,domNode:null}}return t}function c(t,o,n,{parentWidget:d,widgetConstructor:c,widgetProperties:s}){const f=new c(s);f.container=t,i.set(t,f),f.afterCreate?.(f,t),d.addHandles(e(()=>a(t))),queueMicrotask(()=>{f[r].projector?.renderNow()})}function s(e,t,r,{widgetProperties:o}){const n=i.get(e);n&&(n.set(o),n.afterUpdate?.(n,e))}function a(e){const t=i.get(e);t&&(t.afterRemoved?.(t,e),t.destroy(),i.delete(e))}function f(e){return"function"==typeof e&&e[t]}export{f as isWidgetConstructor,d as processWidgets,i as widgetMap};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{isActivationKey as e}from"../../core/keyboard.js";import{isWidgetConstructor as o}from"./jsxWidgetSupport.js";import{classes as r,isRTL as t,cssTransition as n,storeNode as i}from"./widgetUtils.js";import{accessibleHandler as s}from"./decorators/accessibleHandler.js";import{messageBundle as d}from"./decorators/messageBundle.js";import{vmEvent as c}from"./decorators/vmEvent.js";var a=function(e){return{vnodeSelector:"",properties:void 0,children:void 0,text:e.toString(),domNode:null}},u=function(e,o){for(var r=0,t=e.length;r<t;r++){var n=e[r];Array.isArray(n)?u(n,o):null!=n&&!1!==n&&(n.hasOwnProperty("vnodeSelector")||(n=a(n)),o.push(n))}},f=function(e,o){for(var r=[],t=2;t<arguments.length;t++)r[t-2]=arguments[t];if(1===r.length&&"string"==typeof r[0])return{vnodeSelector:e,properties:o||void 0,children:void 0,text:r[0],domNode:null};var n=[];return u(r,n),{vnodeSelector:e,properties:o||void 0,children:n,text:void 0,domNode:null}};const l=s,p=r,v=d,m=c,y=t,g=n,h=e,j=i;function x(e,r,...t){return"function"!=typeof e||o(e)?f(e,r??null,...t):e(r,...t)}function S(...e){return e}function b(e){return e&&"function"==typeof e.render}function N(e){return e&&"function"==typeof e.postMixInProperties&&"function"==typeof e.buildRendering&&"function"==typeof e.postCreate&&"function"==typeof e.startup}export{l as accessibleHandler,p as classes,g as cssTransition,N as hasDomNode,h as isActivationKey,y as isRTL,b as isWidget,v as messageBundle,j as storeNode,x as tsx,S as tsxFragment,m as vmEvent};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/ArrayPool.js";import{handlesGroup as t,makeHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import"../../core/Logger.js";import{signalFromSignalOrOptions as o}from"../../core/promiseUtils.js";import{watch as r,syncAndInitial as i}from"../../core/reactiveUtils.js";import{waitAnimationFrame as s}from"../../core/scheduling.js";import{clearVNodeCache as c}from"./vnodeCache.js";var a,u,f=function(e){if("WebkitTransition"in e.style)a="webkitTransitionEnd",u="webkitAnimationEnd";else{if(!("transition"in e.style))throw new Error("Your browser is not supported!");a="transitionend",u="animationend"}},d=function(e){a||f(e)},l=function(e,t){return void 0===t&&(t=e+"-active"),function(n){d(n);var o=!1,r=function(i){o||(o=!0,n.removeEventListener(a,r),n.removeEventListener(u,r),n.classList.remove(e),n.classList.remove(t))};n.classList.add(e),n.addEventListener(a,r),n.addEventListener(u,r),requestAnimationFrame(function(){n.classList.add(t)})}},m=function(e,t){return void 0===t&&(t=e+"-active"),function(n,o){d(n);var r=!1,i=function(e){r||(r=!0,n.removeEventListener(a,i),n.removeEventListener(u,i),o())};n.classList.add(e),n.addEventListener(a,i),n.addEventListener(u,i),requestAnimationFrame(function(){n.classList.add(t)})}};function v(...t){const n=e.acquire();for(let e=0;e<t.length;e++){const o=t[e],r=typeof o;if("string"===r)n.push(o);else if(Array.isArray(o))n.push.apply(n,o);else if("object"===r)for(const e in o)o[e]&&n.push(e)}const o=n.join(" ");return e.release(n),o}const p=(()=>{const e=new Map,o=new ResizeObserver(t=>{c();for(const n of t)e.get(n.target)?.(n)}),s=(t,r,i)=>(e.set(t,r),o.observe(t,i),n(()=>{o.unobserve(t),e.delete(t)}));return(e,o,c)=>{let a=null;return t([r(()=>"function"==typeof e?e():e,e=>{a?.remove(),e&&(a=s(e,o,c))},i),n(()=>a?.remove())])}})();function L(e){const t=e?.closest("[dir]");return null!==t&&t instanceof HTMLElement&&"rtl"===t.dir||"rtl"===document.dir}function E(e,t){return("enter"===e?l:m)(t)}function h(e){const t="data-node-ref";this[e.getAttribute(t)]=null}function y(e){const t="data-node-ref";this[e.getAttribute(t)]=e}
|
|
5
|
+
import e from"../../core/ArrayPool.js";import{handlesGroup as t,makeHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import"../../core/Logger.js";import{signalFromSignalOrOptions as o}from"../../core/promiseUtils.js";import{watch as r,syncAndInitial as i}from"../../core/reactiveUtils.js";import{waitAnimationFrame as s}from"../../core/scheduling.js";import{clearVNodeCache as c}from"./vnodeCache.js";var a,u,f=function(e){if("WebkitTransition"in e.style)a="webkitTransitionEnd",u="webkitAnimationEnd";else{if(!("transition"in e.style))throw new Error("Your browser is not supported!");a="transitionend",u="animationend"}},d=function(e){a||f(e)},l=function(e,t){return void 0===t&&(t=e+"-active"),function(n){d(n);var o=!1,r=function(i){o||(o=!0,n.removeEventListener(a,r),n.removeEventListener(u,r),n.classList.remove(e),n.classList.remove(t))};n.classList.add(e),n.addEventListener(a,r),n.addEventListener(u,r),requestAnimationFrame(function(){n.classList.add(t)})}},m=function(e,t){return void 0===t&&(t=e+"-active"),function(n,o){d(n);var r=!1,i=function(e){r||(r=!0,n.removeEventListener(a,i),n.removeEventListener(u,i),o())};n.classList.add(e),n.addEventListener(a,i),n.addEventListener(u,i),requestAnimationFrame(function(){n.classList.add(t)})}};function v(...t){const n=e.acquire();for(let e=0;e<t.length;e++){const o=t[e],r=typeof o;if("string"===r)n.push(o);else if(Array.isArray(o))n.push.apply(n,o);else if("object"===r)for(const e in o)o[e]&&n.push(e)}const o=n.join(" ");return e.release(n),o}const p=(()=>{const e=new Map,o=new ResizeObserver(t=>{c();for(const n of t)e.get(n.target)?.(n)}),s=(t,r,i)=>(e.set(t,r),o.observe(t,i),n(()=>{o.unobserve(t),e.delete(t)}));return(e,o,c)=>{let a=null;return t([r(()=>"function"==typeof e?e():e,e=>{a?.remove(),e&&(a=s(e,o,c))},i),n(()=>a?.remove())])}})();function L(e){const t=e?.closest("[dir]");return null!==t&&t instanceof HTMLElement&&"rtl"===t.dir||"rtl"===document.dir}function E(e,t){return("enter"===e?l:m)(t)}function h(e){const t="data-node-ref";this[e.getAttribute(t)]=null}function y(e){const t="data-node-ref";this[e.getAttribute(t)]=e}async function b(e,t){await s(o(t));const n="function"==typeof e?e():e;n&&("setFocus"in n&&"function"==typeof n.setFocus?await n.setFocus():n instanceof HTMLElement&&n.focus())}export{v as classes,E as cssTransition,h as discardNode,L as isRTL,p as onResize,b as setFocus,y as storeNode};
|