@arcgis/core 4.32.0-next.20241010 → 4.32.0-next.20241012
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/WebDocument2D.js +1 -1
- package/WebScene.js +1 -1
- package/arcade/arcade.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeEnvironment.js +1 -1
- package/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{fe3af59e9eeb7005af9b.js → 103524334199f47ebb62.js} +10 -10
- package/assets/esri/core/workers/chunks/38216a3288fa3af5fa32.js +1 -0
- package/assets/esri/core/workers/chunks/{5a421cb8a3d886527c02.js → 3d411e74ce7bc1ce2497.js} +1 -1
- package/assets/esri/core/workers/chunks/{e2f3021123ff133cd552.js → 63670af7bc12a6f243d0.js} +1 -1
- package/assets/esri/core/workers/chunks/740a5c1633bbfdbee8bd.js +1 -0
- package/assets/esri/core/workers/chunks/{c55e9d8a8f04d314ac11.js → 7c08a7c6ec663a11ce0d.js} +1 -1
- package/assets/esri/core/workers/chunks/90e758afa0bc8f5a5001.js +1 -0
- package/assets/esri/core/workers/chunks/92ce57cb12d9a7a3699e.js +1 -0
- package/assets/esri/core/workers/chunks/97e2da750105431b8e94.js +1 -0
- package/assets/esri/core/workers/chunks/{6b3044e47d695db21722.js → 99f28667eacd170fe43c.js} +1 -1
- package/assets/esri/core/workers/chunks/9cf974c9c014bac2cd1e.js +1 -0
- package/assets/esri/core/workers/chunks/9cfaf1cbbb1d6453e939.js +1 -0
- package/assets/esri/core/workers/chunks/{ca3fb8d334091e4d249a.js → a1752adee1f58ee21581.js} +1 -1
- package/assets/esri/core/workers/chunks/a9084c92aad84e35385d.js +1 -0
- package/assets/esri/core/workers/chunks/ae9820b24859aa497286.js +1 -0
- package/assets/esri/core/workers/chunks/{02aec39572c6928e4d95.js → b04a0a0641d9b907a853.js} +2 -2
- package/assets/esri/core/workers/chunks/{353e7e5510d9b8bb4a6c.js → b8c49178cd0f7465380c.js} +1 -1
- package/assets/esri/core/workers/chunks/{d5043df03c565e7cd197.js → c06c5c815b5e37717fa1.js} +1 -1
- package/assets/esri/core/workers/chunks/c63500a279bc877049fe.js +1 -0
- package/assets/esri/core/workers/chunks/d497b6443353efc80417.js +1 -0
- package/assets/esri/core/workers/chunks/e6a83b36048f5ed89724.js +1 -0
- package/assets/esri/core/workers/chunks/eb84d8e4cf82402bca17.js +1 -0
- package/assets/esri/core/workers/chunks/ee200440485d4f0981ed.js +1 -0
- package/assets/esri/core/workers/chunks/{22d8b88411813953584f.js → f60024154f8402e189c6.js} +1 -1
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_ar.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_bg.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_bs.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_ca.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_cs.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_da.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_de.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_el.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_en.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_es.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_et.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_fi.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_fr.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_he.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_hr.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_hu.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_id.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_it.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_ja.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_ko.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_lt.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_lv.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_nb.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_nl.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_pl.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_pt-BR.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_pt-PT.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_ro.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_ru.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_sk.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_sl.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_sr.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_sv.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_th.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_tr.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_uk.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_vi.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_zh-CN.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_zh-HK.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_zh-TW.json +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/Tooltip.js +1 -1
- package/chunks/arcade.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/core/unitUtils.js +1 -1
- package/geometry/operators/bufferOperator.js +1 -1
- package/geometry/operators/distanceOperator.js +1 -1
- package/interfaces.d.ts +480 -21
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/supportUtils.js +1 -1
- package/layers/mixins/FeatureReductionLayer.js +1 -1
- package/layers/orientedImagery/core/utils.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/support/TelemetryDisplay.js +1 -1
- package/layers/support/TilemapCache.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/rasterFunctions/ColormapToRGBFunction.js +1 -1
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/layers/video/videoUtils.js +1 -1
- package/libs/maquette-advanced-projector/projector.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItemResource.js +1 -1
- package/portal/support/portalItemUtils.js +1 -1
- package/renderers/support/DictionaryLoader.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/FeatureTile.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VideoLayerView2D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedConfiguration.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/environment/CloudsRenderer.js +1 -1
- package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils3D.js +1 -1
- package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +5 -0
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandEncoder.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js +2 -2
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTransformPoint.js +1 -1
- package/views/interactive/tooltip/content/tooltipContentFactory.js +1 -1
- package/views/interactive/tooltip/fields/TooltipFieldSize.js +5 -0
- package/views/interactive/tooltip/fields/fields.js +1 -1
- package/views/interactive/tooltip/infos/TransformMeshTooltipInfo.js +1 -1
- package/views/interactive/tooltip/infos/TransformPointTooltipInfo.js +1 -1
- package/views/layers/VectorTileLayerView.d.ts +4 -0
- package/widgets/Feature/FeatureMedia/pieChart.js +1 -1
- package/widgets/Feature/FeatureMedia/xyChart.js +1 -1
- package/widgets/FeatureTable/AttachmentsColumn.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
- package/widgets/FeatureTable/support/AttachmentsViewOptions.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable/support/exportUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/assets/esri/core/workers/chunks/0281c669d63ff132337f.js +0 -1
- package/assets/esri/core/workers/chunks/125b014b9e6106696e0f.js +0 -1
- package/assets/esri/core/workers/chunks/479b24afd320fdab8be9.js +0 -1
- package/assets/esri/core/workers/chunks/78c7d2bba8b687ed30c8.js +0 -1
- package/assets/esri/core/workers/chunks/88409aee2fd55496b00e.js +0 -1
- package/assets/esri/core/workers/chunks/8b969fd9d4495307c8c4.js +0 -1
- package/assets/esri/core/workers/chunks/916bb9d2ea06c4c1668a.js +0 -1
- package/assets/esri/core/workers/chunks/a2d7ae6fc7477b632a30.js +0 -1
- package/assets/esri/core/workers/chunks/bc249a183a915f5e595f.js +0 -1
- package/assets/esri/core/workers/chunks/c041a959c2bebee4b364.js +0 -1
- package/assets/esri/core/workers/chunks/c1276e3e8374baad68e4.js +0 -1
- package/assets/esri/core/workers/chunks/dddb068f0e319a7da0fd.js +0 -1
- package/assets/esri/core/workers/chunks/e7a0c4b0dde9ad13fa1c.js +0 -1
- package/assets/esri/core/workers/chunks/f8cf1a1e59fbafabd0a6.js +0 -1
- package/views/interactive/tooltip/content/TooltipContentTransformAbsolute.js +0 -5
- package/views/interactive/tooltip/content/TooltipContentTransformRotate.js +0 -5
- package/views/interactive/tooltip/content/TooltipContentTransformScale.js +0 -5
- package/views/interactive/tooltip/infos/TransformAbsoluteTooltipInfo.js +0 -5
- package/views/interactive/tooltip/infos/TransformRotateTooltipInfo.js +0 -5
- package/views/interactive/tooltip/infos/TransformScaleTooltipInfo.js +0 -5
package/WebDocument2D.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import i from"./Map.js";import r from"./Viewpoint.js";import{isSome as o}from"./core/arrayUtils.js";import s from"./core/Collection.js";import n from"./core/Error.js";import a from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as u}from"./core/maybe.js";import{MultiOriginJSONMixin as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as c}from"./core/promiseUtils.js";import{whenOnce as d}from"./core/reactiveUtils.js";import{addQueryParameter as g,isDataProtocol as f,dataComponents as b}from"./core/urlUtils.js";import{property as y}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as w}from"./core/accessorSupport/decorators/reader.js";import{subclass as A}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{readLoadable as _}from"./core/accessorSupport/read.js";import v from"./geometry/SpatialReference.js";import V from"./portal/PortalItem.js";import{typeKeyword as j}from"./portal/support/portalItemUtils.js";import I from"./support/MapFloorInfo.js";import U from"./time/TimeExtent.js";import{SaveOperationType as P}from"./webdoc/interfaces.js";import O from"./webdoc/RangeInfo.js";import x from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as L}from"./webdoc/support/thumbnailUtils.js";import{loadFromSource as F}from"./webdoc/support/webdocLoadUtils.js";import{getLayerJSON as E}from"./webdoc/support/writeUtils.js";import R from"./webmap/ApplicationProperties.js";import k from"./webmap/Bookmark.js";import T from"./webmap/InitialViewProperties.js";import{Version as B}from"./webmap/Version.js";import N from"./webmap/background/ColorBackground.js";const J=s.ofType(k),M=new Map([["image/jpeg","jpeg"],["image/jpg","jpg"],["image/png","png"],["image/gif","gif"]]),Z="ArcGIS Pro",W=j.JSAPI;let $=class extends(m(a.LoadableMixin(h(i)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this.resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new J,this.floorInfo=null,this.initialViewProperties=new T,this.portalItem=null,this.sourceVersion=null,this.widgets=null,this._debouncedSaveOperations=c((async(e,t,i)=>{const{save:r,saveAs:o}=await import("./webdoc/support/webdocSaveUtils.js");switch(e){case P.SAVE:return r(this.context,this,t);case P.SAVE_AS:return o(this.context,this,i,t)}})),this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){this.portalItem=u(this.portalItem)}initialize(){if(this.when().catch((e=>{l.getLogger(this).error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=W}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,i){e&&this._isAuthoringAppVersionSetByUser?i.authoringAppVersion=e:i.authoringAppVersion=t}readInitialViewProperties(e,t){const i=new T;t.background&&(i.background=N.fromJSON(t.background));const o=t.initialState?.timeExtent;o&&(i.timeExtent=U.fromArray(o));const s=t.initialState?.viewpoint;if(s){if(s.rotation){B.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===Z&&(s.rotation*=-1)}i.viewpoint=r.fromJSON(s)}return t.mapRangeInfo&&(i.rangeInfo=O.fromJSON(t.mapRangeInfo)),t.spatialReference&&(i.spatialReference=v.fromJSON(t.spatialReference)),t.timeZone&&(i.timeZone=t.timeZone),i}writeInitialViewProperties(e,t,i,r){if(!e)return;e.background?.color&&(t.background=e.background.write({},r));const{timeExtent:o,viewpoint:s}=e;if(s||o){const e={};s&&(e.viewpoint=s.write({},r)),o&&(e.timeExtent=o.toArray()),t.initialState=e}e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(r)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},r)),t.timeZone=e.timeZone}writeLayers(e,t,i,r){t[i]=this._writeLayers(e,r,"operational-layers")}readSourceVersion(e,t){const[i,r]=t.version.split(".");return new B(parseInt(i,10),parseInt(r,10))}writeSourceVersion(e,t,i){t[i]=`${this.context.currentVersion.major}.${this.context.currentVersion.minor}`}writeTables(e,t,i,r){const o=this._writeLayers(e,r,"tables");o.length&&(t[i]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}get updatingFromView(){return!!this._updateFromPromise}load(e){return this.addResolvingPromise(F(this.context,this)),Promise.resolve(this)}loadAll(){return p(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:this.context.origin};const i=this._getAuthoringPropsState();_(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(i)}write(e,t){if("loaded"!==this.loadStatus){const e=new n("webmap:not-loaded","Web map must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:this.context.origin,restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){return this._debouncedSaveOperations(P.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(P.SAVE_AS,t,e)}async updateFrom(e,t){const i=this._updateFromInternal(e,t);this._updateFromPromise=i,await i;i===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.baseMapLayers||[]]).find((t=>t.id===e.id))}async updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename})),this._clearThumbnailOverride())}getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:g(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,i){t={...t,layerContainerType:i};return e.map((e=>E(e,"tables"===i?null:this.getLayerJSONFromResourceInfo(e),t))).filter(o).toArray()}_validateJSON(e){const t=B.parse(e.version||"","webmap");return this.context.currentVersion.validate(t),e.version=`${t.major}.${t.minor}`,e}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e?.viewing?.search,i=e=>this.allLayers.some((t=>t.id===e));if(t?.layers&&(t.layers=t.layers.filter((e=>i(e.id)))),t?.tables&&(t.tables=t.tables.filter((e=>this.tables.some((t=>t.id===e.id))))),e){const t=e.editing?.locationTracking;t?.info&&!i(t.info.layerId)&&(e.editing=null)}const r="presentation"in this?this.presentation:null,o=r?.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>i(e.id))))}))}async _updateFromInternal(e,t){if(t??={},await d((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const i of e.allLayerViews)"visible"in i&&"visible"in i.layer&&i._isOverridden("visible")&&(i.layer.visible=i.visible),"featureEffect"in i&&"featureEffect"in i.layer&&i._isOverridden("featureEffect")&&(i.layer.featureEffect=i.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),this.initialViewProperties.spatialReference=e.spatialReference?.clone(),this.initialViewProperties.timeExtent=e.timeExtent?.clone(),this.initialViewProperties.timeZone=e.timeZone,t.viewpointExcluded||(this.initialViewProperties.viewpoint=new r({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),i=e.extent.clone(),r=i.width/2;return i.xmin=t.x-r,i.xmax=t.x+r,i}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const i=L(e,t.thumbnailSize),r=await e.takeScreenshot({format:"png",width:i.width,height:i.height});this._setAutoGeneratedThumbnail(r.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(f(e)){const t=b(e),i=t?.mediaType,r=i&&M.get(i.toLowerCase())||null,o=`thumbnail${Date.now()}`;return r?`${o}.${r}`:o}return null}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}};e([y()],$.prototype,"_updateFromPromise",void 0),e([y({type:R,json:{write:!0}})],$.prototype,"applicationProperties",void 0),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],$.prototype,"authoringApp",null),e([S("authoringApp")],$.prototype,"writeAuthoringApp",null),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],$.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],$.prototype,"writeAuthoringAppVersion",null),e([y({type:J,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],$.prototype,"bookmarks",void 0),e([y({type:I,json:{name:"mapFloorInfo",write:!0}})],$.prototype,"floorInfo",void 0),e([y({type:T,nonNullable:!0,json:{read:{source:["background","initialState.timeExtent","initialState.viewpoint","mapRangeInfo","spatialReference","timeZone"]},write:{ignoreOrigin:!0,target:{background:{type:N},"initialState.timeExtent":{type:U},"initialState.viewpoint":{type:r},mapRangeInfo:{type:O},spatialReference:{type:v},"timeZone:":{type:String}}}}})],$.prototype,"initialViewProperties",void 0),e([w("initialViewProperties")],$.prototype,"readInitialViewProperties",null),e([S("initialViewProperties")],$.prototype,"writeInitialViewProperties",null),e([y({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],$.prototype,"layers",void 0),e([S("layers")],$.prototype,"writeLayers",null),e([y({type:V})],$.prototype,"portalItem",void 0),e([y()],$.prototype,"resourceInfo",void 0),e([y({readOnly:!0,type:B,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],$.prototype,"sourceVersion",void 0),e([w("sourceVersion")],$.prototype,"readSourceVersion",null),e([S("sourceVersion")],$.prototype,"writeSourceVersion",null),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],$.prototype,"tables",void 0),e([S("tables")],$.prototype,"writeTables",null),e([y()],$.prototype,"thumbnailUrl",null),e([y()],$.prototype,"updatingFromView",null),e([y({type:x,json:{write:!0}})],$.prototype,"widgets",void 0),$=e([A("esri.WebDocument2D")],$);const C=$;export{C as default};
|
|
5
|
+
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{isSome as o}from"./core/arrayUtils.js";import s from"./core/Collection.js";import n from"./core/Error.js";import a from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as u}from"./core/maybe.js";import{MultiOriginJSONMixin as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as c}from"./core/promiseUtils.js";import{whenOnce as d}from"./core/reactiveUtils.js";import{addQueryParameter as g,isDataProtocol as f,dataComponents as b}from"./core/urlUtils.js";import{property as y}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as w}from"./core/accessorSupport/decorators/reader.js";import{subclass as A}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{readLoadable as _}from"./core/accessorSupport/read.js";import v from"./geometry/SpatialReference.js";import V from"./portal/PortalItem.js";import{typeKeyword as j}from"./portal/support/portalItemUtils.js";import I from"./support/MapFloorInfo.js";import U from"./time/TimeExtent.js";import{SaveOperationType as P}from"./webdoc/interfaces.js";import O from"./webdoc/RangeInfo.js";import x from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as L}from"./webdoc/support/thumbnailUtils.js";import{loadFromSource as F}from"./webdoc/support/webdocLoadUtils.js";import{getLayerJSON as E}from"./webdoc/support/writeUtils.js";import R from"./webmap/ApplicationProperties.js";import k from"./webmap/Bookmark.js";import T from"./webmap/InitialViewProperties.js";import{Version as B}from"./webmap/Version.js";import N from"./webmap/background/ColorBackground.js";const J=s.ofType(k),M=new Map([["image/jpeg","jpeg"],["image/jpg","jpg"],["image/png","png"],["image/gif","gif"]]),Z="ArcGIS Pro",W=j.JSAPI;let $=class extends(m(a.LoadableMixin(h(r)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this.resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new J,this.floorInfo=null,this.initialViewProperties=new T,this.portalItem=null,this.sourceVersion=null,this.widgets=null,this._debouncedSaveOperations=c((async(e,t,r)=>{const{save:i,saveAs:o}=await import("./webdoc/support/webdocSaveUtils.js");switch(e){case P.SAVE:return i(this.context,this,t);case P.SAVE_AS:return o(this.context,this,r,t)}})),this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){this.portalItem=u(this.portalItem)}initialize(){if(this.when().catch((e=>{l.getLogger(this).error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=W}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){const r=new T;t.background&&(r.background=N.fromJSON(t.background));const o=t.initialState?.timeExtent;o&&(r.timeExtent=U.fromArray(o));const s=t.initialState?.viewpoint;if(s){if(s.rotation){B.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===Z&&(s.rotation*=-1)}r.viewpoint=i.fromJSON(s)}return t.mapRangeInfo&&(r.rangeInfo=O.fromJSON(t.mapRangeInfo)),t.spatialReference&&(r.spatialReference=v.fromJSON(t.spatialReference)),t.timeZone&&(r.timeZone=t.timeZone),r}writeInitialViewProperties(e,t,r,i){if(!e)return;e.background?.color&&(t.background=e.background.write({},i));const{timeExtent:o,viewpoint:s}=e;if(s||o){const e={};s&&(e.viewpoint=s.write({},i)),o&&(e.timeExtent=o.toArray()),t.initialState=e}e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i)),t.timeZone=e.timeZone}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new B(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${this.context.currentVersion.major}.${this.context.currentVersion.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}get updatingFromView(){return!!this._updateFromPromise}load(e){return this.addResolvingPromise(F(this.context,this)),Promise.resolve(this)}loadAll(){return p(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:this.context.origin};const r=this._getAuthoringPropsState();_(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new n("webmap:not-loaded","Web map must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:this.context.origin,restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){return this._debouncedSaveOperations(P.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(P.SAVE_AS,t,e)}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.baseMapLayers||[]]).find((t=>t.id===e.id))}async updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename})),this._clearThumbnailOverride())}getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:g(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>E(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t))).filter(o).toArray()}_validateJSON(e){const t=B.parse(e.version||"","webmap");return this.context.currentVersion.validate(t),e.version=`${t.major}.${t.minor}`,e}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e?.viewing?.search,r=e=>this.allLayers.some((t=>t.id===e));if(t?.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t?.tables&&(t.tables=t.tables.filter((e=>this.tables.some((t=>t.id===e.id))))),e){const t=e.editing?.locationTracking;t?.info&&!r(t.info.layerId)&&(e.editing=null)}const i="presentation"in this?this.presentation:null,o=i?.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _updateFromInternal(e,t){if(t??={},await d((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)"visible"in r&&"visible"in r.layer&&r._isOverridden("visible")&&(r.layer.visible=r.visible),"featureEffect"in r&&"featureEffect"in r.layer&&r._isOverridden("featureEffect")&&(r.layer.featureEffect=r.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),this.initialViewProperties.spatialReference=e.spatialReference?.clone(),this.initialViewProperties.timeZone=e.timeZone,t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=L(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(f(e)){const t=b(e),r=t?.mediaType,i=r&&M.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}};e([y()],$.prototype,"_updateFromPromise",void 0),e([y({type:R,json:{write:!0}})],$.prototype,"applicationProperties",void 0),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],$.prototype,"authoringApp",null),e([S("authoringApp")],$.prototype,"writeAuthoringApp",null),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],$.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],$.prototype,"writeAuthoringAppVersion",null),e([y({type:J,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],$.prototype,"bookmarks",void 0),e([y({type:I,json:{name:"mapFloorInfo",write:!0}})],$.prototype,"floorInfo",void 0),e([y({type:T,nonNullable:!0,json:{read:{source:["background","initialState.timeExtent","initialState.viewpoint","mapRangeInfo","spatialReference","timeZone"]},write:{ignoreOrigin:!0,target:{background:{type:N},"initialState.timeExtent":{type:U},"initialState.viewpoint":{type:i},mapRangeInfo:{type:O},spatialReference:{type:v},"timeZone:":{type:String}}}}})],$.prototype,"initialViewProperties",void 0),e([w("initialViewProperties")],$.prototype,"readInitialViewProperties",null),e([S("initialViewProperties")],$.prototype,"writeInitialViewProperties",null),e([y({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],$.prototype,"layers",void 0),e([S("layers")],$.prototype,"writeLayers",null),e([y({type:V})],$.prototype,"portalItem",void 0),e([y()],$.prototype,"resourceInfo",void 0),e([y({readOnly:!0,type:B,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],$.prototype,"sourceVersion",void 0),e([w("sourceVersion")],$.prototype,"readSourceVersion",null),e([S("sourceVersion")],$.prototype,"writeSourceVersion",null),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],$.prototype,"tables",void 0),e([S("tables")],$.prototype,"writeTables",null),e([y()],$.prototype,"thumbnailUrl",null),e([y()],$.prototype,"updatingFromView",null),e([y({type:x,json:{write:!0}})],$.prototype,"widgets",void 0),$=e([A("esri.WebDocument2D")],$);const C=$;export{C as default};
|
package/WebScene.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as y,watch as w}from"./core/reactiveUtils.js";import{urlToObject as f,addQueryParameter as g}from"./core/urlUtils.js";import{property as b}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as v}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as _}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as A}from"./core/accessorSupport/originUtils.js";import{readLoadable as I}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import L from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as R}from"./geometry/projection.js";import V from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as O}from"./geometry/support/spatialReferenceUtils.js";import E from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{createForItemWrite as C}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as N,typeKeyword as T}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as x}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import{WebSceneTag as F}from"./support/tagSymbols.js";import{createSchemaValidationError as J,createCopyError as W}from"./support/webSceneUtils.js";import $ from"./time/TimeExtent.js";import{ViewingMode as B}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as q}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as k}from"./webdoc/interfaces.js";import D from"./webdoc/Widgets.js";import{updateItemWithResources as K,saveResources as H}from"./webdoc/support/resourceUtils.js";import{validateSaveAPIKey as z}from"./webdoc/support/saveAPIKeyUtils.js";import{evaluateWriteErrors as Q}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as X}from"./webdoc/support/thumbnailUtils.js";import{isCopyAllowed as Y,initializeNewItem as Z}from"./webdoc/support/webdocSaveUtils.js";import ee from"./webscene/ApplicationProperties.js";import te from"./webscene/Environment.js";import re from"./webscene/InitialViewProperties.js";import ie from"./webscene/Presentation.js";import oe from"./webscene/TransportationNetwork.js";import{Version as se}from"./webscene/Version.js";import{getLoader as ae}from"./webscene/support/schemaValidatorLoader.js";var ne;const le=new se(1,35),pe=()=>{const e=8,t=[],r=le.major;for(let i=e;i<=le.minor;i++)t.push(`${r}.${i}`);return t},ce="Web Scene";let de=class extends(n.LoadableMixin(m(d(r)))){constructor(e){super(e),this[ne]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new ie,this.initialViewProperties=new re,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u((async(e,t,r)=>{switch(e){case k.SAVE:return this._saveImpl(t);case k.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new se(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${le.major}.${le.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};t.initialState?.environment&&(r.environment=te.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?V.fromJSON(t.spatialReference):V.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint));const o=t.initialState?.timeExtent;return null!=o&&(r.timeExtent=$.fromArray(o)),new re(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??V.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy(),this._validateFeatureLayerSymbolVisibility()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(I(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t?.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(k.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(z(this.portalItem),this.portalItem?.type!==ce)throw new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${ce}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(C(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await K(this.portalItem,i,this._resourceReferences,r),A(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(k.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new s("webscene:portal-item-required","saveAs requires a portal item to save to");z(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||E.getDefault();await this._ensureLoadBeforeSave(),r.type=ce,r.portal=i;const o=this._enableVerifyItemRelativeUrls(C(r,"web-scene",!0)),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");const p=this.portalItem,c={item:p,authenticated:!(!p?.id||!p.portal.user)},{copyAllowed:d,itemReloaded:m}=await Y(c,i);if(c.authenticated||=m,!d)throw new s(`${o.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u={...t,copyAllResources:!0};return await Z(r,c,a,u)&&(this._resourceReferences.portalItem=r),await H(this._resourceReferences,o),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?f(r.itemUrl):void 0}),A(o),n&&(this.thumbnailUrl=l?g(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i=!1){if(!O(this.spatialReference))throw new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:o,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=r||{};Q(t,{errorName:"webscene:save"},{ignoreUnsupported:o,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const l=ae();if(n&&l){const t=(await l()).validate(e);if(!t.length)return;const r=`webscene did not validate:\n${t.join("\n")}`;p.getLogger(this).error(`${i?"saveAs":"save"}(): ${r}`);const o=t.map((e=>new s("webscene:schema-validation",e)));throw J(o)}}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(W()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=te.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=X(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem?.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||E.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r.filter((e=>"base-elevation"===e.type||"elevation"===e.type)))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:f(e.itemUrl),portal:e.portal||E.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!q(t,B.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||R(e,t)}else{if(!q(t,B.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateFeatureLayerSymbolVisibility(){this.sourceVersion?.greaterEqual(1,35)||this.layers.forEach((e=>{"feature"===e.type&&w((()=>e.loaded),(()=>e.warnInvisibleDrapedSymbols()),{once:!0,sync:!0})}))}_validateJSON(e){const t=se.parse(e.version||"","webscene");return le.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=V.WebMercator.toJSON()),e}_updateTypeKeywords(e){N(e,T.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),N(e,T.DEVELOPER_BASEMAP,x(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&x(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||V.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?f(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e?.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};ne=F,de.version=`${le.major}.${le.minor}`,e([b({type:ee,json:{write:!0}})],de.prototype,"applicationProperties",void 0),e([b({type:j,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],de.prototype,"clippingArea",void 0),e([_("clippingArea")],de.prototype,"writeClippingArea",null),e([b({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],de.prototype,"clippingEnabled",void 0),e([v("clippingEnabled",["clippingArea"])],de.prototype,"readClippingEnabled",null),e([_("clippingEnabled")],de.prototype,"writeClippingEnabled",null),e([b({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],de.prototype,"floorInfo",void 0),e([b({type:L,json:{write:!0}})],de.prototype,"heightModelInfo",void 0),e([b({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],de.prototype,"layers",void 0),e([_("layers")],de.prototype,"writeLayers",null),e([b({readOnly:!0,type:se,json:{type:pe(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],de.prototype,"sourceVersion",void 0),e([v("sourceVersion",["version"])],de.prototype,"readSourceVersion",null),e([_("sourceVersion")],de.prototype,"writeSourceVersion",null),e([b({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],de.prototype,"tables",void 0),e([_("tables")],de.prototype,"writeTables",null),e([b()],de.prototype,"thumbnailUrl",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],de.prototype,"authoringApp",null),e([_("authoringApp")],de.prototype,"writeAuthoringApp",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],de.prototype,"authoringAppVersion",null),e([_("authoringAppVersion")],de.prototype,"writeAuthoringAppVersion",null),e([b({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],de.prototype,"ground",void 0),e([_("ground")],de.prototype,"writeGround",null),e([b({type:o.ofType(oe),json:{write:!0}})],de.prototype,"transportationNetworks",void 0),e([b({type:ie,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],de.prototype,"presentation",void 0),e([b({type:re,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new re({viewingMode:"global",spatialReference:V.WebMercator})}})],de.prototype,"initialViewProperties",void 0),e([v("initialViewProperties",["initialState.timeExtent","initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],de.prototype,"readInitialViewProperties",null),e([b({type:V,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],de.prototype,"spatialReference",null),e([b({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],de.prototype,"viewingMode",null),e([b({type:M})],de.prototype,"portalItem",void 0),e([b()],de.prototype,"resourceInfo",void 0),e([b({type:D,json:{write:!0}})],de.prototype,"widgets",void 0),de=e([S("esri.WebScene")],de);const he=de;export{he as default};
|
|
5
|
+
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as y,watch as w}from"./core/reactiveUtils.js";import{urlToObject as f,addQueryParameter as g}from"./core/urlUtils.js";import{property as b}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as v}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as _}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as A}from"./core/accessorSupport/originUtils.js";import{readLoadable as I}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import L from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as V}from"./geometry/projection.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as E}from"./geometry/support/jsonUtils.js";import{isEarth as O}from"./geometry/support/spatialReferenceUtils.js";import M from"./portal/Portal.js";import U from"./portal/PortalItem.js";import{createForItemWrite as C}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as N,typeKeyword as T}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as x}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import{WebSceneTag as F}from"./support/tagSymbols.js";import{createSchemaValidationError as J}from"./support/webSceneUtils.js";import W from"./time/TimeExtent.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as B}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as q}from"./webdoc/interfaces.js";import k from"./webdoc/Widgets.js";import{updateItemWithResources as D,saveResources as K}from"./webdoc/support/resourceUtils.js";import{validateSaveAPIKey as H}from"./webdoc/support/saveAPIKeyUtils.js";import{evaluateWriteErrors as z}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as Q}from"./webdoc/support/thumbnailUtils.js";import{isCopyAllowed as X,initializeNewItem as Y}from"./webdoc/support/webdocSaveUtils.js";import Z from"./webscene/ApplicationProperties.js";import ee from"./webscene/Environment.js";import te from"./webscene/InitialViewProperties.js";import re from"./webscene/Presentation.js";import ie from"./webscene/TransportationNetwork.js";import{Version as oe}from"./webscene/Version.js";import{getLoader as se}from"./webscene/support/schemaValidatorLoader.js";var ae;const ne=new oe(1,35),le=()=>{const e=8,t=[],r=ne.major;for(let i=e;i<=ne.minor;i++)t.push(`${r}.${i}`);return t},pe="Web Scene";let ce=class extends(n.LoadableMixin(m(d(r)))){constructor(e){super(e),this[ae]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new re,this.initialViewProperties=new te,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u((async(e,t,r)=>{switch(e){case q.SAVE:return this._saveImpl(t);case q.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new oe(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${ne.major}.${ne.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};t.initialState?.environment&&(r.environment=ee.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?R.fromJSON(t.spatialReference):R.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint));const o=t.initialState?.timeExtent;return null!=o&&(r.timeExtent=W.fromArray(o)),new te(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy(),this._validateFeatureLayerSymbolVisibility()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(I(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t?.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(q.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(H(this.portalItem),this.portalItem?.type!==pe)throw new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${pe}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(C(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,q.SAVE,e),this._updateTypeKeywords(this.portalItem),await D(this.portalItem,i,this._resourceReferences,r),A(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(q.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=U.from(e);if(!r)throw new s("webscene:portal-item-required","saveAs requires a portal item to save to");H(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||M.getDefault();await this._ensureLoadBeforeSave(),r.type=pe,r.portal=i;const o=this._enableVerifyItemRelativeUrls(C(r,"web-scene",!0)),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");const p=this.portalItem,c={item:p,authenticated:!(!p?.id||!p.portal.user)},{copyAllowed:d,itemReloaded:m}=await X(c,i);if(c.authenticated||=m,!d)throw new s(`${o.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u={...t,copyAllResources:!0};return await Y(r,c,a,u)&&(this._resourceReferences.portalItem=r),await K(this._resourceReferences,o),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?f(r.itemUrl):void 0}),A(o),n&&(this.thumbnailUrl=l?g(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i){if(!O(this.spatialReference))throw new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:o,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=i||{};z(t,{errorName:"webscene:save"},{ignoreUnsupported:o,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const l=se();if(n&&l){const t=(await l()).validate(e);if(!t.length)return;const i=`webscene did not validate:\n${t.join("\n")}`;p.getLogger(this).error(`${r===q.SAVE_AS?"saveAs":"save"}(): ${i}`);const o=t.map((e=>new s("webscene:schema-validation",e)));throw J(o)}}_verifySaveAs(e,t,r){return this._verifySave(e,t,q.SAVE_AS,r)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(){return!1}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=ee.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=Q(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem?.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||M.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r.filter((e=>"base-elevation"===e.type||"elevation"===e.type)))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:f(e.itemUrl),portal:e.portal||M.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!B(t,$.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||V(e,t)}else{if(!B(t,$.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateFeatureLayerSymbolVisibility(){this.sourceVersion?.greaterEqual(1,35)||this.layers.forEach((e=>{"feature"===e.type&&w((()=>e.loaded),(()=>e.warnInvisibleDrapedSymbols()),{once:!0,sync:!0})}))}_validateJSON(e){const t=oe.parse(e.version||"","webscene");return ne.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){N(e,T.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),N(e,T.DEVELOPER_BASEMAP,x(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&x(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?f(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e?.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};ae=F,ce.version=`${ne.major}.${ne.minor}`,e([b({type:Z,json:{write:!0}})],ce.prototype,"applicationProperties",void 0),e([b({type:j,json:{read:{source:"clippingArea.geometry",reader:E},write:{target:"clippingArea.geometry"}}})],ce.prototype,"clippingArea",void 0),e([_("clippingArea")],ce.prototype,"writeClippingArea",null),e([b({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],ce.prototype,"clippingEnabled",void 0),e([v("clippingEnabled",["clippingArea"])],ce.prototype,"readClippingEnabled",null),e([_("clippingEnabled")],ce.prototype,"writeClippingEnabled",null),e([b({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],ce.prototype,"floorInfo",void 0),e([b({type:L,json:{write:!0}})],ce.prototype,"heightModelInfo",void 0),e([b({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],ce.prototype,"layers",void 0),e([_("layers")],ce.prototype,"writeLayers",null),e([b({readOnly:!0,type:oe,json:{type:le(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],ce.prototype,"sourceVersion",void 0),e([v("sourceVersion",["version"])],ce.prototype,"readSourceVersion",null),e([_("sourceVersion")],ce.prototype,"writeSourceVersion",null),e([b({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],ce.prototype,"tables",void 0),e([_("tables")],ce.prototype,"writeTables",null),e([b()],ce.prototype,"thumbnailUrl",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ce.prototype,"authoringApp",null),e([_("authoringApp")],ce.prototype,"writeAuthoringApp",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ce.prototype,"authoringAppVersion",null),e([_("authoringAppVersion")],ce.prototype,"writeAuthoringAppVersion",null),e([b({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],ce.prototype,"ground",void 0),e([_("ground")],ce.prototype,"writeGround",null),e([b({type:o.ofType(ie),json:{write:!0}})],ce.prototype,"transportationNetworks",void 0),e([b({type:re,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],ce.prototype,"presentation",void 0),e([b({type:te,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new te({viewingMode:"global",spatialReference:R.WebMercator})}})],ce.prototype,"initialViewProperties",void 0),e([v("initialViewProperties",["initialState.timeExtent","initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],ce.prototype,"readInitialViewProperties",null),e([b({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ce.prototype,"spatialReference",null),e([b({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ce.prototype,"viewingMode",null),e([b({type:U})],ce.prototype,"portalItem",void 0),e([b()],ce.prototype,"resourceInfo",void 0),e([b({type:k,json:{write:!0}})],ce.prototype,"widgets",void 0),ce=e([S("esri.WebScene")],ce);const de=ce;export{de as default};
|
package/arcade/arcade.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./arcadeCompiler.js";import"./ArcadeModuleResolver.js";import"./arcadeRuntime.js";import"./executionError.js";import"./parser.js";import"./treeAnalysis.js";import"./functions/geomsync.js";import"../core/has.js";import"../core/maybe.js";export{_ as _loadScriptDependenciesImpl,c as compileScript,o as enableAsyncSupport,q as enableAsyncSupportImpl,d as enableFeatureSetSupport,w as enableFeatureSetSupportImpl,b as enableGeometrySupport,n as enableGeometrySupportImpl,e as executeScript,i as extend,a as extractExpectedFieldLiterals,m as extractFieldLiterals,f as featureSetUtils,u as isAsyncEnabled,t as isFeatureSetSupportEnabled,v as isGeometryEnabled,A as loadDependentModules,l as loadScriptDependencies,j as parseAndExecuteScript,p as parseScript,k as referencesFunction,r as referencesMember,y as scriptIsAsync,s as scriptTouchesGeometry,x as scriptUsesFeatureSet,g as scriptUsesGeometryEngine,z as scriptUsesModules}from"../chunks/arcade.js";
|
|
5
|
+
import"./arcadeCompiler.js";import"./ArcadeModuleResolver.js";import"./arcadeRuntime.js";import"./executionError.js";import"./parser.js";import"./treeAnalysis.js";import"./functions/geomsync.js";import"../core/has.js";import"../core/maybe.js";export{_ as _loadScriptDependenciesImpl,c as compileScript,o as enableAsyncSupport,q as enableAsyncSupportImpl,d as enableFeatureSetSupport,w as enableFeatureSetSupportImpl,b as enableGeometrySupport,n as enableGeometrySupportImpl,e as executeScript,i as extend,a as extractExpectedFieldLiterals,m as extractFieldLiterals,f as featureSetUtils,u as isAsyncEnabled,t as isFeatureSetSupportEnabled,v as isGeometryEnabled,A as loadDependentModules,l as loadScriptDependencies,j as parseAndExecuteScript,p as parseScript,k as referencesFunction,r as referencesMember,y as scriptIsAsync,s as scriptTouchesGeometry,x as scriptUsesFeatureSet,g as scriptUsesGeometryEngine,z as scriptUsesModules,B as scriptUsesViewProperties}from"../chunks/arcade.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o}from"./containerUtils.js";import a from"./Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as l,ensureArcadeExecutionError as s}from"./executionError.js";import c from"./Feature.js";import{NativeFunction as u,ScopeMarshalledFunction as f,ArcadeFunction as p,wrapModuleScopedResponse as w}from"./FunctionWrapper.js";import{G as d,a as h,E as m,i as g,c as y,z as v,o as b,b as S,g as x,r as F,q as I,j as R,D as A,F as M,R as C,I as j,A as N,B as k,x as O,C as E,u as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as K}from"./treeAnalysis.js";import{A as L}from"../chunks/array.js";import{registerFunctions as U}from"./functions/date.js";import{registerFunctions as D}from"./functions/geomasync.js";import{registerFunctions as G}from"./functions/geometry.js";import{registerFunctions as Z}from"./functions/maths.js";import{registerFunctions as P}from"./functions/stats.js";import{registerFunctions as q}from"./functions/string.js";import T from"../geometry/Geometry.js";import W from"../geometry/SpatialReference.js";const V=100;async function _(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await Q(e,t.arguments[r]));return n}async function z(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await _(e,t))}class Y extends p{constructor(e,t){super(),this.definition=null,this.context=null,this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new i(e,l.MaximumCallDepth,null);return Le(this.definition,n,t,null)}}call(e,t){return J(e,t,((n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{},abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1}};if(a.depthCounter.depth>64)throw new i(e,l.MaximumCallDepth,t);return Le(this.definition,a,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,(async(o,a,i)=>{const l={spatialReference:e.spatialReference,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!g(t)||t instanceof f?t:w(t,e,r))),w(await Le(this.definition,l,i,t),n,r)}))}}class H extends t{constructor(e){super(),this.source=e}async global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=await Q(this.executingContext,t.node),t.valueset=!0),g(t.value)&&!(t.value instanceof f)){const e=new f;e.fn=t.value,e.parameterEvaluator=J,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(g(t))throw new i(null,l.AssignModuleFunction,null);this.executingContext.globalScope[e.toLowerCase()]={value:t,valueset:!0,node:null}}hasGlobal(e){return void 0===this.executingContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.executingContext.exports[e]}async loadModule(e){let t=e.spatialReference;null==t&&(t=new W({wkid:102100})),this.moduleScope=Ge({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,services:e.services,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,globalScope:this.moduleScope,console:e.console??Ze,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:null,depthCounter:{depth:1}},await ge(this.executingContext,this.source.syntax)}}async function J(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await _(e,t))}async function Q(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await pe(e,t);case"AssignmentExpression":return await de(e,t);case"TemplateLiteral":return await Oe(e,t);case"Identifier":return await Ne(e,t);case"MemberExpression":return await Re(e,t);case"Literal":return t.value;case"CallExpression":return await ke(e,t);case"UnaryExpression":return await Ae(e,t);case"BinaryExpression":return await Ce(e,t);case"LogicalExpression":return await je(e,t);case"ArrayExpression":return await Me(e,t);case"ObjectExpression":return await $(e,t);default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function X(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await Se(e,t);case"ExportNamedDeclaration":return await xe(e,t);case"VariableDeclaration":return await Fe(e,t,0);case"BlockStatement":return await ge(e,t);case"FunctionDeclaration":return await be(e,t);case"ReturnStatement":return await ve(e,t);case"IfStatement":return await me(e,t);case"ExpressionStatement":return await he(e,t);case"ForStatement":return await oe(e,t);case"WhileStatement":return await ee(e,t);case"ForInStatement":return await fe(e,t);case"BreakStatement":return N;case"EmptyStatement":return v;case"ContinueStatement":return k;default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function $(e,t){const n=[];for(let a=0;a<t.properties.length;a++){const r=t.properties[a],o=await Q(e,r.value),i="Identifier"===r.key.type?r.key.name:await Q(e,r.key);n[a]={key:i,value:o}}const r={},o=new Map;for(let a=0;a<n.length;a++){const s=n[a];if(g(s.value))throw new i(e,l.NoFunctionInDictionary,t);if(!1===y(s.key))throw new i(e,l.KeyMustBeString,t);let c=s.key.toString();const u=c.toLowerCase();o.has(u)?c=o.get(u):o.set(u,c),s.value===v?r[c]=null:r[c]=s.value}const s=new a(r);return s.immutable=!1,s}async function ee(e,t){const n={testResult:!0,lastAction:v};if(n.testResult=await Q(e,t.test),!1===n.testResult)return v;if(!0!==n.testResult)throw new i(e,l.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=await X(e,t.body),n.lastAction!==N)&&!(n.lastAction instanceof C);)if(n.testResult=await Q(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new i(e,l.BooleanConditionRequired,t);return n.lastAction instanceof C?n.lastAction:v}async function te(e,t,n){const r=await X(e,t.body);return n.lastAction=r,n.lastAction===N||n.lastAction instanceof C?(n.testResult=!1,n):null!==t.update?(await Q(e,t.update),n):n}async function ne(e,t,n){if(null!==t.test){const r=await Q(e,t.test);if(!0===e.abortSignal?.aborted)throw new i(e,l.Cancelled,t);if(n.testResult=r,!1===n.testResult)return n;if(!0!==n.testResult)throw new i(e,l.BooleanConditionRequired,t);return te(e,t,n)}return te(e,t,n)}function re(e,t,n,r,o,a){try{ne(e,t,n).then((()=>{try{!0===n.testResult?++a>V?(a=0,setTimeout((()=>{re(e,t,n,r,o,a)}),0)):re(e,t,n,r,o,a):n.lastAction instanceof C?r(n.lastAction):r(v)}catch(i){o(i)}}),(e=>{o(e)}))}catch(i){o(i)}}async function oe(e,t){try{return null!==t.init&&("VariableDeclaration"===t.init.type?await X(e,t.init):await Q(e,t.init)),await new Promise(((n,r)=>{re(e,t,{testResult:!0,lastAction:v},(e=>{n(e)}),(e=>{r(e)}),0)}))}catch(n){throw n}}function ae(e,t,n,r,o,a,i,l,s,c){try{if(r<=a)return void l(v);o.value="k"===i?n[a]:a,X(e,t.body).then((u=>{try{u instanceof C?l(u):u===N?l(v):++c>V?(c=0,setTimeout((()=>{ae(e,t,n,r,o,a+1,i,l,s,c)}),0)):ae(e,t,n,r,o,a+1,i,l,s,c)}catch(f){s(f)}}),(e=>{s(e)}))}catch(u){s(u)}}function ie(e,t,n,r,o,a,i,l,s){try{if(n.length()<=o)return void i(v);r.value="k"===a?n.get(o):o,X(e,t.body).then((c=>{c instanceof C?i(c):c===N?i(v):++s>V?(s=0,setTimeout((()=>{ie(e,t,n,r,o+1,a,i,l,s)}),0)):ie(e,t,n,r,o+1,a,i,l,s)}),(e=>{l(e)}))}catch(c){l(c)}}function le(e,t,n,r,o,a){try{if(void 0===a&&(a="i"),0===n.length)return void r.resolve(v);ae(e,t,n,n.length,o,0,a,(e=>{r.resolve(e)}),(e=>{r.reject(e)}),0)}catch(i){r.reject(i)}}function se(e,t,n,r,o,a){try{if(void 0===a&&(a="i"),0===n.length())return void r.resolve(v);ie(e,t,n,o,0,a,(e=>{r.resolve(e)}),(e=>{r.reject(e)}),0)}catch(i){r.reject(i)}}function ce(e,t,n,r,o){try{le(e,t,n.keys(),r,o,"k")}catch(a){r.reject(a)}}function ue(e,t,n,r,o,a,i,l){try{e.next().then((s=>{try{if(null===s)a(v);else{const u=c.createFromGraphicLikeObject(s.geometry,s.attributes,r,t.timeZone);u._underlyingGraphic=s,o.value=u;X(t,n.body).then((s=>{try{s===N?a(v):s instanceof C?a(s):++l>V?(l=0,setTimeout((()=>{ue(e,t,n,r,o,a,i,l)}),0)):ue(e,t,n,r,o,a,i,l)}catch(c){i(c)}}),(e=>{i(e)}))}}catch(u){i(u)}}),(e=>{i(e)}))}catch(s){i(s)}}async function fe(t,n){return new Promise(((r,o)=>{Q(t,n.right).then((s=>{try{let c;c="VariableDeclaration"===n.left.type?X(t,n.left):Promise.resolve(),c.then((()=>{try{const c=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let u=null;if(null!=t.localScope&&void 0!==t.localScope[c]&&(u=t.localScope[c]),null===u&&void 0!==t.globalScope[c]&&(u=t.globalScope[c]),null===u)return void o(new i(t,l.InvalidIdentifier,n));b(s)||y(s)?le(t,n,s,{reject:o,resolve:r},u):I(s)?se(t,n,s,{reject:o,resolve:r},u):s instanceof a||F(s)?ce(t,n,s,{reject:o,resolve:r},u):B(s)?ue(s.iterator(t.abortSignal),t,n,s,u,(e=>{r(e)}),(e=>{o(e)}),0):le(t,n,[],{reject:o,resolve:r},u)}catch(c){o(c)}}),o)}catch(c){o(c)}}),o)}))}async function pe(t,n){const r=n.argument;if("CallExpression"===r.type)throw new i(t,l.NeverReach,n);if("MemberExpression"===r.type){const e=await Q(t,r.object);let o,s;if(!0===r.computed)o=await Q(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.Unrecognized,n);o=r.property.name}if(b(e)){if(!S(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new i(t,l.OutOfBounds,n);s=x(e[o]),e[o]="++"===n.operator?s+1:s-1}else if(e instanceof a){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=x(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}else if(e instanceof H){if(!1===y(o))throw new i(t,l.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);s=x(await e.global(o)),e.setGlobal(o,"++"===n.operator?s+1:s-1)}else{if(!F(e))throw I(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=x(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}return!1===n.prefix?s:"++"===n.operator?s+1:s-1}const o=e(r);let s;if(null!=t.localScope&&void 0!==t.localScope[o])return s=x(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;if(void 0!==t.globalScope[o])return s=x(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;throw new i(t,l.InvalidIdentifier,n)}function we(e,t,n,r,o){switch(t){case"=":return e===v?null:e;case"/=":return x(n)/x(e);case"*=":return x(n)*x(e);case"-=":return x(n)-x(e);case"+=":return y(n)||y(e)?R(n)+R(e):x(n)+x(e);case"%=":return x(n)%x(e);default:throw new i(o,l.UnsupportedOperator,r)}}async function de(t,n){const r=n.left;if("MemberExpression"===r.type){const e=await Q(t,r.object);let o;if(!0===r.computed)o=await Q(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.InvalidIdentifier,n);o=r.property.name}const s=await Q(t,n.right);if(b(e)){if(!S(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>e.length)throw new i(t,l.OutOfBounds,n);if(o===e.length){if("="!==n.operator)throw new i(t,l.OutOfBounds,n);e[o]=we(s,n.operator,e[o],n,t)}else e[o]=we(s,n.operator,e[o],n,t)}else if(e instanceof a){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,we(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,we(s,n.operator,null,n,t))}}else if(e instanceof H){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);e.setGlobal(o,we(s,n.operator,await e.global(o),n,t))}else{if(!F(e))throw I(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,we(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,we(s,n.operator,null,n,t))}}return v}const o=e(r);if(null!=t.localScope&&void 0!==t.localScope[o]){const e=await Q(t,n.right);return t.localScope[o]={value:we(e,n.operator,t.localScope[o].value,n,t),valueset:!0,node:n.right},v}if(void 0!==t.globalScope[o]){const e=await Q(t,n.right);return t.globalScope[o]={value:we(e,n.operator,t.globalScope[o].value,n,t),valueset:!0,node:n.right},v}throw new i(t,l.InvalidIdentifier,n)}async function he(e,t){const n=await Q(e,t.expression);return n===v?v:new j(n)}async function me(e,t){const n=await Q(e,t.test);if(!0===n)return X(e,t.consequent);if(!1===n)return null!==t.alternate?X(e,t.alternate):v;throw new i(e,l.BooleanConditionRequired,t)}async function ge(e,t){return ye(e,t,0)}async function ye(e,t,n){if(n>=t.body.length)return v;const r=await X(e,t.body[n]);return r instanceof C||r===N||r===k||n===t.body.length-1?r:ye(e,t,n+1)}async function ve(e,t){if(null===t.argument)return new C(v);const n=await Q(e,t.argument);return new C(n)}async function be(t,n){const r=e(n.id);return t.globalScope[r]={valueset:!0,node:null,value:new Y(n,t)},v}async function Se(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let a;return t.libraryResolver._moduleSingletons?.has(o.uri)?a=t.libraryResolver._moduleSingletons.get(o.uri):(a=new H(o),await a.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,a)),t.globalScope[r]={value:a,valueset:!0,node:n},v}async function xe(t,n){if(await X(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return v}async function Fe(e,t,n){return n>=t.declarations.length?v:(await Ie(e,t.declarations[n]),n===t.declarations.length-1||await Fe(e,t,n+1),v)}async function Ie(t,n){let r=null;if(r=null===n.init?null:await Q(t,n.init),null!==t.localScope){if(r===v&&(r=null),"Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);return void(null!=t.localScope&&(t.localScope[o]={value:r,valueset:!0,node:n.init}))}if("Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);r===v&&(r=null),t.globalScope[o]={value:r,valueset:!0,node:n.init}}async function Re(e,t){const n=await Q(e,t.object);if(null===n)throw new i(e,l.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof a||F(n))return n.field(t.property.name);if(n instanceof T)return o(n,t.property.name,e,t);if(n instanceof H){if(!n.hasGlobal(t.property.name))throw new i(e,l.InvalidIdentifier,t);return n.global(t.property.name)}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}let r=await Q(e,t.property);if(n instanceof a||F(n)){if(y(r))return n.field(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof H){if(y(r))return n.global(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof T){if(y(r))return o(n,r,e,t);throw new i(e,l.InvalidMemberAccessKey,t)}if(b(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}if(I(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new i(e,l.OutOfBounds,t);return n.get(r)}throw new i(e,l.InvalidMemberAccessKey,t)}if(y(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}async function Ae(e,t){const n=await Q(e,t.argument);if(h(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,l.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,l.UnsupportedUnaryOperator,t)}async function Me(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await Q(e,t.elements[r]));for(let r=0;r<n.length;r++){if(g(n[r]))throw new i(e,l.NoFunctionInArray,t);n[r]===v&&(n[r]=null)}return n}async function Ce(e,t){const n=await Q(e,t.left),r=await Q(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(x(n),x(r),t.operator);case"==":return m(n,r);case"!=":return!m(n,r);case"<":case">":case"<=":case">=":return A(n,r,t.operator);case"+":return y(n)||y(r)?R(n)+R(r):x(n)+x(r);case"-":return x(n)-x(r);case"*":return x(n)*x(r);case"/":return x(n)/x(r);case"%":return x(n)%x(r);default:throw new i(e,l.UnsupportedOperator,t)}}async function je(e,t){const n=await Q(e,t.left);if(!h(n))throw new i(e,l.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":{if(!0===n)return n;const r=await Q(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=await Q(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}default:throw new i(e,l.LogicExpressionOrAnd,t)}}async function Ne(t,n){const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=Q(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=Q(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}throw new i(t,l.InvalidIdentifier,n)}async function ke(t,n){if("MemberExpression"===n.callee.type){const e=await Q(t,n.callee.object);if(!(e instanceof H))throw new i(t,l.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:await Q(t,n.callee.property);if(!e.hasGlobal(r))throw new i(t,l.FunctionNotFound,n);const o=await e.global(r);if(!g(o))throw new i(t,l.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new i(t,l.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(g(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(g(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}throw new i(t,l.FunctionNotFound,n)}async function Oe(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await Q(e,t.expressions[r]);if(g(o))throw new i(e,l.NoFunctionInTemplateLiteral,t);n+=R(o)}r++}return n}const Ee={};async function Be(e,t,n,r){const o=await Q(e,t.arguments[n]);if(m(o,r))return Q(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?Q(e,t.arguments[n]):2===a?null:3===a?Q(e,t.arguments[n+2]):Be(e,t,n+2,r)}async function Ke(e,t,n,r){if(!0===r)return Q(e,t.arguments[n+1]);if(3===t.arguments.length-n)return Q(e,t.arguments[n+2]);const o=await Q(e,t.arguments[n+2]);if(!1===h(o))throw new i(e,l.ModuleExportNotFound,t.arguments[n+2]);return Ke(e,t,n+2,o)}async function Le(t,n,r,o){const a=t.body;if(r.length!==t.params.length)throw new i(n,l.WrongNumberOfParameters,null);for(let i=0;i<r.length;i++){const o=t.params[i];"Identifier"===o.type&&null!=n.localScope&&(n.localScope[e(o)]={d:null,value:r[i],valueset:!0,node:null})}const s=await X(n,a);if(s instanceof C)return s.value;if(s===N)throw new i(n,l.UnexpectedToken,o);if(s===k)throw new i(n,l.UnexpectedToken,o);return s instanceof j?s.value:s}U(Ee,z),q(Ee,z),Z(Ee,z),G(Ee,z),P(Ee,z),D({functions:Ee,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:z,standardFunctionAsync:J}),Ee.iif=async function(e,t){d(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await Q(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t);return Q(e,n?t.arguments[1]:t.arguments[2])},Ee.defaultvalue=async function(e,t){d(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await Q(e,t.arguments[0]);if(3===t.arguments.length){const o=await Q(e,t.arguments[1]),a=r(n,o);return null!=a&&""!==a?a:Q(e,t.arguments[2])}return null==n||""===n?Q(e,t.arguments[1]):n},Ee.decode=async function(e,t){if(t.arguments.length<2)throw new i(e,l.WrongNumberOfParameters,t);if(2===t.arguments.length)return Q(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new i(e,l.WrongNumberOfParameters,t);return Be(e,t,1,await Q(e,t.arguments[0]))},Ee.when=async function(e,t){if(t.arguments.length<3)throw new i(e,l.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new i(e,l.WrongNumberOfParameters,t);const n=await Q(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t.arguments[0]);return Ke(e,t,0,n)};const Ue={fixSpatialReference:O,parseArguments:_,standardFunction:z,standardFunctionAsync:J,evaluateIdentifier:Ne};for(const We in Ee)Ee[We]={value:new u(Ee[We]),valueset:!0,node:null};const De=function(){};function Ge(e,t,n){const r=new De;null==e&&(e={}),null==t&&(t={});const o=new a({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o,valueset:!0,node:null};for(const a in t)r[a]={value:new u(t[a]),native:!0,valueset:!0,node:null};for(const a in e)r[a]={value:E(e[a])?c.createFromGraphic(e[a],n):e[a],valueset:!0,node:null};return r}function Ze(e){console.log(e)}De.prototype=Ee,De.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},De.prototype.pi={value:Math.PI,valueset:!0,node:null};const Pe=Ue;function qe(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:z,standardFunctionAsync:J,evaluateIdentifier:Ne};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ee[n]={value:new u(t.functions[n]),valueset:!0,node:null},De.prototype[n]=Ee[n];for(let n=0;n<t.signatures.length;n++)K(t.signatures[n],"async")}async function Te(e,t){let r=t.spatialReference;null==r&&(r=new W({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const a=Ge(t.vars,t.customfunctions,t.timeZone),s={spatialReference:r,services:t.services,exports:{},libraryResolver:o,abortSignal:void 0===t.abortSignal||null===t.abortSignal?{aborted:!1}:t.abortSignal,globalScope:a,console:t.console??Ze,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,localScope:null,depthCounter:{depth:1}},c=await ge(s,e);if(c instanceof C||c instanceof j){const e=c.value;if(e===v)return null;if(g(e))throw new i(s,l.IllegalResult,null);return e}if(c===v)return null;if(c===N)throw new i(s,l.IllegalResult,null);if(c===k)throw new i(s,l.IllegalResult,null);throw new i(s,l.NeverReach,null)}qe([L]);export{Te as executeScript,qe as extend,Pe as functionHelper};
|
|
5
|
+
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o}from"./containerUtils.js";import a from"./Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as l,ensureArcadeExecutionError as s}from"./executionError.js";import c from"./Feature.js";import{NativeFunction as u,ScopeMarshalledFunction as f,ArcadeFunction as p,wrapModuleScopedResponse as w}from"./FunctionWrapper.js";import{G as d,a as h,E as g,i as m,c as y,z as v,o as b,b as S,g as x,r as F,q as I,j as M,D as C,F as R,R as k,I as A,A as N,B as O,x as E,C as j,u as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as K}from"./treeAnalysis.js";import{A as L}from"../chunks/array.js";import{registerFunctions as U}from"./functions/date.js";import{registerFunctions as D}from"./functions/geomasync.js";import{registerFunctions as G}from"./functions/geometry.js";import{registerFunctions as Z}from"./functions/maths.js";import{registerFunctions as q}from"./functions/stats.js";import{registerFunctions as P}from"./functions/string.js";import W from"../geometry/Geometry.js";import T from"../geometry/SpatialReference.js";async function V(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await J(e,t.arguments[r]));return n}async function _(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await V(e,t))}class z extends p{constructor(e,t){super(),this.definition=null,this.context=null,this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new i(e,l.MaximumCallDepth,null);return Ae(this.definition,n,t,null)}}call(e,t){return H(e,t,((n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{},abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1}};if(a.depthCounter.depth>64)throw new i(e,l.MaximumCallDepth,t);return Ae(this.definition,a,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,(async(o,a,i)=>{const l={spatialReference:e.spatialReference,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!m(t)||t instanceof f?t:w(t,e,r))),w(await Ae(this.definition,l,i,t),n,r)}))}}class Y extends t{constructor(e){super(),this.source=e}async global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=await J(this.executingContext,t.node),t.valueset=!0),m(t.value)&&!(t.value instanceof f)){const e=new f;e.fn=t.value,e.parameterEvaluator=H,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(m(t))throw new i(null,l.AssignModuleFunction,null);this.executingContext.globalScope[e.toLowerCase()]={value:t,valueset:!0,node:null}}hasGlobal(e){return void 0===this.executingContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.executingContext.exports[e]}async loadModule(e){let t=e.spatialReference;null==t&&(t=new T({wkid:102100})),this.moduleScope=Ee({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,services:e.services,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,globalScope:this.moduleScope,console:e.console??je,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:null,depthCounter:{depth:1}},await ue(this.executingContext,this.source.syntax)}}async function H(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await V(e,t))}async function J(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await ae(e,t);case"AssignmentExpression":return await le(e,t);case"TemplateLiteral":return await Me(e,t);case"Identifier":return await Fe(e,t);case"MemberExpression":return await ye(e,t);case"Literal":return t.value;case"CallExpression":return await Ie(e,t);case"UnaryExpression":return await ve(e,t);case"BinaryExpression":return await Se(e,t);case"LogicalExpression":return await xe(e,t);case"ArrayExpression":return await be(e,t);case"ObjectExpression":return await X(e,t);default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function Q(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await de(e,t);case"ExportNamedDeclaration":return await he(e,t);case"VariableDeclaration":return await ge(e,t,0);case"BlockStatement":return await ue(e,t);case"FunctionDeclaration":return await we(e,t);case"ReturnStatement":return await pe(e,t);case"IfStatement":return await ce(e,t);case"ExpressionStatement":return await se(e,t);case"ForStatement":return await ee(e,t);case"WhileStatement":return await $(e,t);case"ForInStatement":return await oe(e,t);case"BreakStatement":return N;case"EmptyStatement":return v;case"ContinueStatement":return O;default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function X(e,t){const n=[];for(let a=0;a<t.properties.length;a++){const r=t.properties[a],o=await J(e,r.value),i="Identifier"===r.key.type?r.key.name:await J(e,r.key);n[a]={key:i,value:o}}const r={},o=new Map;for(let a=0;a<n.length;a++){const s=n[a];if(m(s.value))throw new i(e,l.NoFunctionInDictionary,t);if(!1===y(s.key))throw new i(e,l.KeyMustBeString,t);let c=s.key.toString();const u=c.toLowerCase();o.has(u)?c=o.get(u):o.set(u,c),s.value===v?r[c]=null:r[c]=s.value}const s=new a(r);return s.immutable=!1,s}async function $(e,t){let n=await J(e,t.test);if(!1===n)return v;if(!0!==n)throw new i(e,l.BooleanConditionRequired,t);for(;!0===n;){const r=await Q(e,t.body);if(r===N)break;if(r instanceof k)return r;if(n=await J(e,t.test),!0!==n&&!1!==n)throw new i(e,l.BooleanConditionRequired,t)}return v}async function ee(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await Q(e,t.init):await J(e,t.init));;){if(null!==t.test){const n=await J(e,t.test);if(!0===e.abortSignal?.aborted)throw new i(e,l.Cancelled,t);if(!1===n)break;if(!0!==n)throw new i(e,l.BooleanConditionRequired,t)}const n=await Q(e,t.body);if(n===N)break;if(n instanceof k)return n;null!==t.update&&await J(e,t.update)}return v}catch(n){throw n}}async function te(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){r.value="k"===o?n[i]:i;const a=await Q(e,t.body);if(a===N)break;if(a instanceof k)return a}return v}async function ne(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.value="k"===o?n.get(i):i;const a=await Q(e,t.body);if(a===N)break;if(a instanceof k)return a}return v}async function re(e,t,n,r){const o=n.iterator(e.abortSignal);let a;for(;null!=(a=await o.next());){const o=c.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone);o._underlyingGraphic=a,r.value=o;const i=await Q(e,t.body);if(i===N)break;if(i instanceof k)return i}return v}async function oe(t,n){const r=await J(t,n.right);"VariableDeclaration"===n.left.type&&await Q(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let s=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(s=t.localScope[o]),null===s&&void 0!==t.globalScope[o]&&(s=t.globalScope[o]),null===s)throw new i(t,l.InvalidIdentifier,n);return b(r)||y(r)?await te(t,n,r,s):I(r)?await ne(t,n,r,s):r instanceof a||F(r)?await te(t,n,r.keys(),s,"k"):B(r)?await re(t,n,r,s):v}async function ae(t,n){const r=n.argument;if("CallExpression"===r.type)throw new i(t,l.NeverReach,n);if("MemberExpression"===r.type){const e=await J(t,r.object);let o,s;if(!0===r.computed)o=await J(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.Unrecognized,n);o=r.property.name}if(b(e)){if(!S(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new i(t,l.OutOfBounds,n);s=x(e[o]),e[o]="++"===n.operator?s+1:s-1}else if(e instanceof a){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=x(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}else if(e instanceof Y){if(!1===y(o))throw new i(t,l.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);s=x(await e.global(o)),e.setGlobal(o,"++"===n.operator?s+1:s-1)}else{if(!F(e))throw I(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=x(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}return!1===n.prefix?s:"++"===n.operator?s+1:s-1}const o=e(r);let s;if(null!=t.localScope&&void 0!==t.localScope[o])return s=x(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;if(void 0!==t.globalScope[o])return s=x(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;throw new i(t,l.InvalidIdentifier,n)}function ie(e,t,n,r,o){switch(t){case"=":return e===v?null:e;case"/=":return x(n)/x(e);case"*=":return x(n)*x(e);case"-=":return x(n)-x(e);case"+=":return y(n)||y(e)?M(n)+M(e):x(n)+x(e);case"%=":return x(n)%x(e);default:throw new i(o,l.UnsupportedOperator,r)}}async function le(t,n){const r=n.left;if("MemberExpression"===r.type){const e=await J(t,r.object);let o;if(!0===r.computed)o=await J(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.InvalidIdentifier,n);o=r.property.name}const s=await J(t,n.right);if(b(e)){if(!S(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>e.length)throw new i(t,l.OutOfBounds,n);if(o===e.length){if("="!==n.operator)throw new i(t,l.OutOfBounds,n);e[o]=ie(s,n.operator,e[o],n,t)}else e[o]=ie(s,n.operator,e[o],n,t)}else if(e instanceof a){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,ie(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,ie(s,n.operator,null,n,t))}}else if(e instanceof Y){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);e.setGlobal(o,ie(s,n.operator,await e.global(o),n,t))}else{if(!F(e))throw I(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,ie(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,ie(s,n.operator,null,n,t))}}return v}const o=e(r);if(null!=t.localScope&&void 0!==t.localScope[o]){const e=await J(t,n.right);return t.localScope[o]={value:ie(e,n.operator,t.localScope[o].value,n,t),valueset:!0,node:n.right},v}if(void 0!==t.globalScope[o]){const e=await J(t,n.right);return t.globalScope[o]={value:ie(e,n.operator,t.globalScope[o].value,n,t),valueset:!0,node:n.right},v}throw new i(t,l.InvalidIdentifier,n)}async function se(e,t){const n=await J(e,t.expression);return n===v?v:new A(n)}async function ce(e,t){const n=await J(e,t.test);if(!0===n)return Q(e,t.consequent);if(!1===n)return null!==t.alternate?Q(e,t.alternate):v;throw new i(e,l.BooleanConditionRequired,t)}async function ue(e,t){return fe(e,t,0)}async function fe(e,t,n){if(n>=t.body.length)return v;const r=await Q(e,t.body[n]);return r instanceof k||r===N||r===O||n===t.body.length-1?r:fe(e,t,n+1)}async function pe(e,t){if(null===t.argument)return new k(v);const n=await J(e,t.argument);return new k(n)}async function we(t,n){const r=e(n.id);return t.globalScope[r]={valueset:!0,node:null,value:new z(n,t)},v}async function de(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let a;return t.libraryResolver._moduleSingletons?.has(o.uri)?a=t.libraryResolver._moduleSingletons.get(o.uri):(a=new Y(o),await a.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,a)),t.globalScope[r]={value:a,valueset:!0,node:n},v}async function he(t,n){if(await Q(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return v}async function ge(e,t,n){return n>=t.declarations.length?v:(await me(e,t.declarations[n]),n===t.declarations.length-1||await ge(e,t,n+1),v)}async function me(t,n){let r=null;if(r=null===n.init?null:await J(t,n.init),null!==t.localScope){if(r===v&&(r=null),"Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);return void(null!=t.localScope&&(t.localScope[o]={value:r,valueset:!0,node:n.init}))}if("Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);r===v&&(r=null),t.globalScope[o]={value:r,valueset:!0,node:n.init}}async function ye(e,t){const n=await J(e,t.object);if(null===n)throw new i(e,l.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof a||F(n))return n.field(t.property.name);if(n instanceof W)return o(n,t.property.name,e,t);if(n instanceof Y){if(!n.hasGlobal(t.property.name))throw new i(e,l.InvalidIdentifier,t);return n.global(t.property.name)}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}let r=await J(e,t.property);if(n instanceof a||F(n)){if(y(r))return n.field(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof Y){if(y(r))return n.global(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof W){if(y(r))return o(n,r,e,t);throw new i(e,l.InvalidMemberAccessKey,t)}if(b(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}if(I(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new i(e,l.OutOfBounds,t);return n.get(r)}throw new i(e,l.InvalidMemberAccessKey,t)}if(y(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}async function ve(e,t){const n=await J(e,t.argument);if(h(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,l.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,l.UnsupportedUnaryOperator,t)}async function be(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await J(e,t.elements[r]));for(let r=0;r<n.length;r++){if(m(n[r]))throw new i(e,l.NoFunctionInArray,t);n[r]===v&&(n[r]=null)}return n}async function Se(e,t){const n=await J(e,t.left),r=await J(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return R(x(n),x(r),t.operator);case"==":return g(n,r);case"!=":return!g(n,r);case"<":case">":case"<=":case">=":return C(n,r,t.operator);case"+":return y(n)||y(r)?M(n)+M(r):x(n)+x(r);case"-":return x(n)-x(r);case"*":return x(n)*x(r);case"/":return x(n)/x(r);case"%":return x(n)%x(r);default:throw new i(e,l.UnsupportedOperator,t)}}async function xe(e,t){const n=await J(e,t.left);if(!h(n))throw new i(e,l.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":{if(!0===n)return n;const r=await J(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=await J(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}default:throw new i(e,l.LogicExpressionOrAnd,t)}}async function Fe(t,n){const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=J(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=J(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}throw new i(t,l.InvalidIdentifier,n)}async function Ie(t,n){if("MemberExpression"===n.callee.type){const e=await J(t,n.callee.object);if(!(e instanceof Y))throw new i(t,l.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:await J(t,n.callee.property);if(!e.hasGlobal(r))throw new i(t,l.FunctionNotFound,n);const o=await e.global(r);if(!m(o))throw new i(t,l.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new i(t,l.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(m(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(m(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}throw new i(t,l.FunctionNotFound,n)}async function Me(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await J(e,t.expressions[r]);if(m(o))throw new i(e,l.NoFunctionInTemplateLiteral,t);n+=M(o)}r++}return n}const Ce={};async function Re(e,t,n,r){const o=await J(e,t.arguments[n]);if(g(o,r))return J(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?J(e,t.arguments[n]):2===a?null:3===a?J(e,t.arguments[n+2]):Re(e,t,n+2,r)}async function ke(e,t,n,r){if(!0===r)return J(e,t.arguments[n+1]);if(3===t.arguments.length-n)return J(e,t.arguments[n+2]);const o=await J(e,t.arguments[n+2]);if(!1===h(o))throw new i(e,l.ModuleExportNotFound,t.arguments[n+2]);return ke(e,t,n+2,o)}async function Ae(t,n,r,o){const a=t.body;if(r.length!==t.params.length)throw new i(n,l.WrongNumberOfParameters,null);for(let i=0;i<r.length;i++){const o=t.params[i];"Identifier"===o.type&&null!=n.localScope&&(n.localScope[e(o)]={d:null,value:r[i],valueset:!0,node:null})}const s=await Q(n,a);if(s instanceof k)return s.value;if(s===N)throw new i(n,l.UnexpectedToken,o);if(s===O)throw new i(n,l.UnexpectedToken,o);return s instanceof A?s.value:s}U(Ce,_),P(Ce,_),Z(Ce,_),G(Ce,_),q(Ce,_),D({functions:Ce,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:_,standardFunctionAsync:H}),Ce.iif=async function(e,t){d(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await J(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t);return J(e,n?t.arguments[1]:t.arguments[2])},Ce.defaultvalue=async function(e,t){d(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await J(e,t.arguments[0]);if(3===t.arguments.length){const o=await J(e,t.arguments[1]),a=r(n,o);return null!=a&&""!==a?a:J(e,t.arguments[2])}return null==n||""===n?J(e,t.arguments[1]):n},Ce.decode=async function(e,t){if(t.arguments.length<2)throw new i(e,l.WrongNumberOfParameters,t);if(2===t.arguments.length)return J(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new i(e,l.WrongNumberOfParameters,t);return Re(e,t,1,await J(e,t.arguments[0]))},Ce.when=async function(e,t){if(t.arguments.length<3)throw new i(e,l.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new i(e,l.WrongNumberOfParameters,t);const n=await J(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t.arguments[0]);return ke(e,t,0,n)};const Ne={fixSpatialReference:E,parseArguments:V,standardFunction:_,standardFunctionAsync:H,evaluateIdentifier:Fe};for(const Ue in Ce)Ce[Ue]={value:new u(Ce[Ue]),valueset:!0,node:null};const Oe=function(){};function Ee(e,t,n){const r=new Oe;null==e&&(e={}),null==t&&(t={});const o=new a({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o,valueset:!0,node:null};for(const a in t)r[a]={value:new u(t[a]),native:!0,valueset:!0,node:null};for(const a in e)r[a]={value:j(e[a])?c.createFromGraphic(e[a],n):e[a],valueset:!0,node:null};return r}function je(e){console.log(e)}Oe.prototype=Ce,Oe.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Oe.prototype.pi={value:Math.PI,valueset:!0,node:null};const Be=Ne;function Ke(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:_,standardFunctionAsync:H,evaluateIdentifier:Fe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ce[n]={value:new u(t.functions[n]),valueset:!0,node:null},Oe.prototype[n]=Ce[n];for(let n=0;n<t.signatures.length;n++)K(t.signatures[n],"async")}async function Le(e,t){let r=t.spatialReference;null==r&&(r=new T({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const a=Ee(t.vars,t.customfunctions,t.timeZone),s={spatialReference:r,services:t.services,exports:{},libraryResolver:o,abortSignal:void 0===t.abortSignal||null===t.abortSignal?{aborted:!1}:t.abortSignal,globalScope:a,console:t.console??je,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,localScope:null,depthCounter:{depth:1}},c=await ue(s,e);if(c instanceof k||c instanceof A){const e=c.value;if(e===v)return null;if(m(e))throw new i(s,l.IllegalResult,null);return e}if(c===v)return null;if(c===N)throw new i(s,l.IllegalResult,null);if(c===O)throw new i(s,l.IllegalResult,null);throw new i(s,l.NeverReach,null)}Ke([L]);export{Le as executeScript,Ke as extend,Be as functionHelper};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function
|
|
5
|
+
import{ArcadeExecutionError as e,ExecutionErrorCodes as r}from"./executionError.js";function t(t){if("Literal"===t.type){if("string"!=typeof t.value)throw new e(null,r.InvalidIdentifier,null);return t.value.toLowerCase()}return t.name.toLowerCase()}export{t as toSymbolId};
|
package/arcade/treeAnalysis.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e}from"./arcadeEnvironment.js";const n={all:{min:2,max:2},time:{min:0,max:4},dateonly:{min:0,max:3},getenvironment:{min:0,max:0},none:{min:2,max:2},any:{min:2,max:2},reduce:{min:2,max:3},map:{min:2,max:2},filter:{min:2,max:2},fromcodepoint:{min:1,max:-1},fromcharcode:{min:1,max:-1},tocodepoint:{min:1,max:2},tocharcode:{min:1,max:2},concatenate:{min:0,max:-1},expects:{min:1,max:-1},getfeatureset:{min:1,max:2},week:{min:1,max:2},fromjson:{min:1,max:1},length3d:{min:1,max:2},tohex:{min:1,max:1},hash:{min:1,max:1},timezone:{min:1,max:1},timezoneoffset:{min:1,max:1},changetimezone:{min:2,max:2},isoweek:{min:1,max:1},isoweekday:{min:1,max:1},hasvalue:{min:2,max:2},isomonth:{min:1,max:1},isoyear:{min:1,max:1},resize:{min:2,max:3},slice:{min:0,max:-1},splice:{min:0,max:-1},push:{min:2,max:2},pop:{min:1,max:1},includes:{min:2,max:2},array:{min:0,max:2},front:{min:1,max:1},back:{min:1,max:1},insert:{min:3,max:3},erase:{min:2,max:2},split:{min:2,max:4},guid:{min:0,max:1},standardizeguid:{min:2,max:2},today:{min:0,max:0},angle:{min:2,max:3},bearing:{min:2,max:3},urlencode:{min:1,max:1},now:{min:0,max:0},timestamp:{min:0,max:0},day:{min:1,max:1},month:{min:1,max:1},year:{min:1,max:1},hour:{min:1,max:1},second:{min:1,max:1},millisecond:{min:1,max:1},minute:{min:1,max:1},weekday:{min:1,max:1},toutc:{min:1,max:1},tolocal:{min:1,max:1},date:{min:0,max:8},datediff:{min:2,max:4},dateadd:{min:2,max:3},trim:{min:1,max:1},text:{min:1,max:2},left:{min:2,max:2},right:{min:2,max:2},mid:{min:2,max:3},upper:{min:1,max:1},proper:{min:1,max:2},lower:{min:1,max:1},find:{min:2,max:3},iif:{min:3,max:3},decode:{min:2,max:-1},when:{min:2,max:-1},defaultvalue:{min:2,max:3},isempty:{min:1,max:1},domaincode:{min:2,max:4},domainname:{min:2,max:4},polygon:{min:1,max:1},point:{min:1,max:1},polyline:{min:1,max:1},extent:{min:1,max:1},multipoint:{min:1,max:1},ringisclockwise:{min:1,max:1},geometry:{min:1,max:1},count:{min:0,max:-1},number:{min:1,max:2},acos:{min:1,max:1},asin:{min:1,max:1},atan:{min:1,max:1},atan2:{min:2,max:2},ceil:{min:1,max:2},floor:{min:1,max:2},round:{min:1,max:2},cos:{min:1,max:1},exp:{min:1,max:1},log:{min:1,max:1},min:{min:0,max:-1},constrain:{min:3,max:3},console:{min:0,max:-1},max:{min:0,max:-1},pow:{min:2,max:2},random:{min:0,max:0},sqrt:{min:1,max:1},sin:{min:1,max:1},tan:{min:1,max:1},abs:{min:1,max:1},isnan:{min:1,max:1},stdev:{min:0,max:-1},average:{min:0,max:-1},mean:{min:0,max:-1},sum:{min:0,max:-1},variance:{min:0,max:-1},distinct:{min:0,max:-1},first:{min:1,max:1},top:{min:2,max:2},boolean:{min:1,max:1},dictionary:{min:0,max:-1},typeof:{min:1,max:1},reverse:{min:1,max:1},replace:{min:3,max:4},sort:{min:1,max:2},feature:{min:1,max:-1},haskey:{min:2,max:2},indexof:{min:2,max:2},disjoint:{min:2,max:2},intersects:{min:2,max:2},touches:{min:2,max:2},crosses:{min:2,max:2},within:{min:2,max:2},contains:{min:2,max:2},overlaps:{min:2,max:2},equals:{min:2,max:2},relate:{min:3,max:3},intersection:{min:2,max:2},union:{min:1,max:2},difference:{min:2,max:2},symmetricdifference:{min:2,max:2},clip:{min:2,max:2},cut:{min:2,max:2},area:{min:1,max:2},areageodetic:{min:1,max:2},length:{min:1,max:2},lengthgeodetic:{min:1,max:2},distancegeodetic:{min:2,max:3},distance:{min:2,max:3},densify:{min:2,max:3},densifygeodetic:{min:2,max:3},generalize:{min:2,max:4},buffer:{min:2,max:3},buffergeodetic:{min:2,max:3},offset:{min:2,max:6},rotate:{min:2,max:3},issimple:{min:1,max:1},simplify:{min:1,max:1},convexhull:{min:1,max:1},centroid:{min:1,max:1},nearestcoordinate:{min:2,max:2},nearestvertex:{min:2,max:2},isselfintersecting:{min:1,max:1},multiparttosinglepart:{min:1,max:1},setgeometry:{min:2,max:2},portal:{min:1,max:1},getuser:{min:0,max:2},subtypes:{min:1,max:1},subtypecode:{min:1,max:1},subtypename:{min:1,max:1},domain:{min:2,max:3},convertdirection:{min:3,max:3},sqltimestamp:{min:1,max:3},schema:{min:1,max:1},measuretocoordinate:{min:2,max:2},distancetocoordinate:{min:2,max:2},pointtocoordinate:{min:2,max:2}},a={functionDefinitions:new Map,constantDefinitions:new Map},t={functionDefinitions:new Map,constantDefinitions:new Map};for(const h of["pi","infinity"])t.constantDefinitions.set(h,{type:"constant"}),a.constantDefinitions.set(h,{type:"constant"});t.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"newline",type:"constant"}]}),a.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"newline",type:"constant"}]});for(const h in n){const e=n[h];t.functionDefinitions.set(h,{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]}),a.functionDefinitions.set(h,{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]})}const i=new Set(["featureset","featuresetbyid","featuresetbyname","featuresetbyassociation","featuresetbyrelationshipname","featuresetbyurl","getfeatureset","getuser","attachments","featuresetbyportalitem","getfeaturesetinfo","filterbysubtypecode","knowledgegraphbyportalitem","querygraph"]),m=new Set(["disjoint","intersects","touches","crosses","within","contains","overlaps","equals","relate","intersection","nearestvertex","nearestcoordinate","union","difference","symmetricdifference","clip","cut","area","areageodetic","length","length3d","lengthgeodetic","distance","distancegeodetic","densify","densifygeodetic","generalize","buffer","buffergeodetic","offset","rotate","issimple","convexhull","simplify","multiparttosinglepart","pointtocoordinate","distancetocoordinate","measuretocoordinate"]);function o(e){return"string"==typeof e||e instanceof String}function s(e,n){const i="sync"===n?a:t;i.functionDefinitions.has(e.name.toLowerCase())?i.functionDefinitions.get(e.name.toLowerCase())?.overloads.push({type:"function",parametersInfo:{min:e.min,max:e.max}}):i.functionDefinitions.set(e.name.toLowerCase(),{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]})}function r(e,n){if(e)for(const a of e)c(a,n)}function c(e,n){if(e&&!1!==n(e))switch(e.type){case"ImportDeclaration":r(e.specifiers,n),c(e.source,n);break;case"ExportNamedDeclaration":c(e.declaration,n);break;case"ArrayExpression":r(e.elements,n);break;case"AssignmentExpression":case"BinaryExpression":case"LogicalExpression":c(e.left,n),c(e.right,n);break;case"BlockStatement":case"Program":r(e.body,n);break;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":case"Identifier":case"Literal":break;case"CallExpression":c(e.callee,n),r(e.arguments,n);break;case"ExpressionStatement":c(e.expression,n);break;case"ForInStatement":c(e.left,n),c(e.right,n),c(e.body,n);break;case"ForStatement":c(e.init,n),c(e.test,n),c(e.update,n),c(e.body,n);break;case"WhileStatement":c(e.test,n),c(e.body,n);break;case"FunctionDeclaration":c(e.id,n),r(e.params,n),c(e.body,n);break;case"IfStatement":c(e.test,n),c(e.consequent,n),c(e.alternate,n);break;case"MemberExpression":c(e.object,n),c(e.property,n);break;case"ObjectExpression":r(e.properties,n);break;case"Property":c(e.key,n),c(e.value,n);break;case"ReturnStatement":case"UnaryExpression":case"UpdateExpression":c(e.argument,n);break;case"VariableDeclaration":r(e.declarations,n);break;case"VariableDeclarator":c(e.id,n),c(e.init,n);break;case"TemplateLiteral":r(e.expressions,n),r(e.quasis,n)}}function x(e,n){let a=!1;const t=n.toLowerCase();return c(e,(e=>!a&&("Identifier"===e.type&&e.name&&e.name.toLowerCase()===t&&(a=!0),!0))),a}function p(n){const a=[];return c(n,(n=>("ImportDeclaration"===n.type&&n.source&&n.source.value&&a.push({libname:e(n.specifiers[0].local),source:n.source.value}),!0))),a}function l(e,n){let a=!1;const t=n.toLowerCase();return c(e,(e=>!a&&("CallExpression"!==e.type||"Identifier"!==e.callee.type||!e.callee.name||e.callee.name.toLowerCase()!==t||(a=!0,!1)))),a}function u(e){const n=[];return c(e,(e=>"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1))),n}function f(e){const n=[];return c(e,(e=>{if("CallExpression"===e.type){if("Identifier"===e.callee.type&&"expects"===e.callee.name.toLowerCase()){let a="";for(let t=0;t<(e.arguments||[]).length;t++)0===t?"Identifier"===e.arguments[t].type&&(a=e.arguments[t].name.toLowerCase()):a&&"Literal"===e.arguments[t].type&&o(e.arguments[t].value)&&n.push(a+"."+e.arguments[t].value.toLowerCase());return!1}if("Identifier"===e.callee.type&&["domainname","domaincode","domain","haskey"].includes(e.callee.name.toLowerCase())&&e.arguments.length>=2){let a="";return"Identifier"===e.arguments[0].type&&(a=e.arguments[0].name.toLowerCase()),a&&"Literal"===e.arguments[1].type&&o(e.arguments[1].value)&&n.push(a+"."+e.arguments[1].value.toLowerCase()),!1}}return"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1)})),n}function y(e,n){const a=[];if(void 0!==n.params&&null!==n.params)for(let t=0;t<n.params.length;t++)a.push("any");return{name:e,return:"any",params:a}}function d(e){const n=[];return c(e,(e=>("CallExpression"===e.type&&"Identifier"===e.callee.type&&n.push(e.callee.name.toLowerCase()),!0))),n}function g(e,n=[]){let a=null;if(void 0===e.usesFeatureSet){null===a&&(a=d(e)),e.usesFeatureSet=!1;for(let n=0;n<a.length;n++)i.has(a[n])&&(e.usesFeatureSet=!0,e.isAsync=!0);if(!1===e.usesFeatureSet&&n&&n.length>0)for(const a of n)if(x(e,a)){e.usesFeatureSet=!0,e.isAsync=!0;break}}if(void 0===e.usesModules){e.usesModules=!1;p(e).length>0&&(e.usesModules=!0)}if(void 0===e.usesGeometry){e.usesGeometry=!1,null===a&&(a=d(e));for(let n=0;n<a.length;n++)m.has(a[n])&&(e.usesGeometry=!0)}}function b(e){const n=d(e);for(let a=0;a<n.length;a++)if(i.has(n[a]))return!0;return!1}export{s as addFunctionDeclaration,y as extractFunctionDeclaration,f as findExpectedFieldLiterals,u as findFieldLiterals,d as findFunctionCalls,p as findModuleImports,g as findScriptDependencies,t as fullArcadeApiAsync,a as fullArcadeApiSync,l as referencesFunction,x as referencesMember,b as scriptUsesFeatureSet,c as walk};
|
|
5
|
+
import{toSymbolId as e}from"./arcadeEnvironment.js";const n={all:{min:2,max:2},time:{min:0,max:4},dateonly:{min:0,max:3},getenvironment:{min:0,max:0},none:{min:2,max:2},any:{min:2,max:2},reduce:{min:2,max:3},map:{min:2,max:2},filter:{min:2,max:2},fromcodepoint:{min:1,max:-1},fromcharcode:{min:1,max:-1},tocodepoint:{min:1,max:2},tocharcode:{min:1,max:2},concatenate:{min:0,max:-1},expects:{min:1,max:-1},getfeatureset:{min:1,max:2},week:{min:1,max:2},fromjson:{min:1,max:1},length3d:{min:1,max:2},tohex:{min:1,max:1},hash:{min:1,max:1},timezone:{min:1,max:1},timezoneoffset:{min:1,max:1},changetimezone:{min:2,max:2},isoweek:{min:1,max:1},isoweekday:{min:1,max:1},hasvalue:{min:2,max:2},isomonth:{min:1,max:1},isoyear:{min:1,max:1},resize:{min:2,max:3},slice:{min:0,max:-1},splice:{min:0,max:-1},push:{min:2,max:2},pop:{min:1,max:1},includes:{min:2,max:2},array:{min:0,max:2},front:{min:1,max:1},back:{min:1,max:1},insert:{min:3,max:3},erase:{min:2,max:2},split:{min:2,max:4},guid:{min:0,max:1},standardizeguid:{min:2,max:2},today:{min:0,max:0},angle:{min:2,max:3},bearing:{min:2,max:3},urlencode:{min:1,max:1},now:{min:0,max:0},timestamp:{min:0,max:0},day:{min:1,max:1},month:{min:1,max:1},year:{min:1,max:1},hour:{min:1,max:1},second:{min:1,max:1},millisecond:{min:1,max:1},minute:{min:1,max:1},weekday:{min:1,max:1},toutc:{min:1,max:1},tolocal:{min:1,max:1},date:{min:0,max:8},datediff:{min:2,max:4},dateadd:{min:2,max:3},trim:{min:1,max:1},text:{min:1,max:2},left:{min:2,max:2},right:{min:2,max:2},mid:{min:2,max:3},upper:{min:1,max:1},proper:{min:1,max:2},lower:{min:1,max:1},find:{min:2,max:3},iif:{min:3,max:3},decode:{min:2,max:-1},when:{min:2,max:-1},defaultvalue:{min:2,max:3},isempty:{min:1,max:1},domaincode:{min:2,max:4},domainname:{min:2,max:4},polygon:{min:1,max:1},point:{min:1,max:1},polyline:{min:1,max:1},extent:{min:1,max:1},multipoint:{min:1,max:1},ringisclockwise:{min:1,max:1},geometry:{min:1,max:1},count:{min:0,max:-1},number:{min:1,max:2},acos:{min:1,max:1},asin:{min:1,max:1},atan:{min:1,max:1},atan2:{min:2,max:2},ceil:{min:1,max:2},floor:{min:1,max:2},round:{min:1,max:2},cos:{min:1,max:1},exp:{min:1,max:1},log:{min:1,max:1},min:{min:0,max:-1},constrain:{min:3,max:3},console:{min:0,max:-1},max:{min:0,max:-1},pow:{min:2,max:2},random:{min:0,max:0},sqrt:{min:1,max:1},sin:{min:1,max:1},tan:{min:1,max:1},abs:{min:1,max:1},isnan:{min:1,max:1},stdev:{min:0,max:-1},average:{min:0,max:-1},mean:{min:0,max:-1},sum:{min:0,max:-1},variance:{min:0,max:-1},distinct:{min:0,max:-1},first:{min:1,max:1},top:{min:2,max:2},boolean:{min:1,max:1},dictionary:{min:0,max:-1},typeof:{min:1,max:1},reverse:{min:1,max:1},replace:{min:3,max:4},sort:{min:1,max:2},feature:{min:1,max:-1},haskey:{min:2,max:2},indexof:{min:2,max:2},disjoint:{min:2,max:2},intersects:{min:2,max:2},touches:{min:2,max:2},crosses:{min:2,max:2},within:{min:2,max:2},contains:{min:2,max:2},overlaps:{min:2,max:2},equals:{min:2,max:2},relate:{min:3,max:3},intersection:{min:2,max:2},union:{min:1,max:2},difference:{min:2,max:2},symmetricdifference:{min:2,max:2},clip:{min:2,max:2},cut:{min:2,max:2},area:{min:1,max:2},areageodetic:{min:1,max:2},length:{min:1,max:2},lengthgeodetic:{min:1,max:2},distancegeodetic:{min:2,max:3},distance:{min:2,max:3},densify:{min:2,max:3},densifygeodetic:{min:2,max:3},generalize:{min:2,max:4},buffer:{min:2,max:3},buffergeodetic:{min:2,max:3},offset:{min:2,max:6},rotate:{min:2,max:3},issimple:{min:1,max:1},simplify:{min:1,max:1},convexhull:{min:1,max:1},centroid:{min:1,max:1},nearestcoordinate:{min:2,max:2},nearestvertex:{min:2,max:2},isselfintersecting:{min:1,max:1},multiparttosinglepart:{min:1,max:1},setgeometry:{min:2,max:2},portal:{min:1,max:1},getuser:{min:0,max:2},subtypes:{min:1,max:1},subtypecode:{min:1,max:1},subtypename:{min:1,max:1},domain:{min:2,max:3},convertdirection:{min:3,max:3},sqltimestamp:{min:1,max:3},schema:{min:1,max:1},measuretocoordinate:{min:2,max:2},distancetocoordinate:{min:2,max:2},pointtocoordinate:{min:2,max:2}},a={functionDefinitions:new Map,constantDefinitions:new Map},t={functionDefinitions:new Map,constantDefinitions:new Map};for(const h of["pi","infinity"])t.constantDefinitions.set(h,{type:"constant"}),a.constantDefinitions.set(h,{type:"constant"});t.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"newline",type:"constant"}]}),a.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"newline",type:"constant"}]});for(const h in n){const e=n[h];t.functionDefinitions.set(h,{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]}),a.functionDefinitions.set(h,{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]})}const i=new Set(["featureset","featuresetbyid","featuresetbyname","featuresetbyassociation","featuresetbyrelationshipname","featuresetbyurl","getfeatureset","getuser","attachments","featuresetbyportalitem","getfeaturesetinfo","filterbysubtypecode","knowledgegraphbyportalitem","querygraph"]),m=new Set(["disjoint","intersects","touches","crosses","within","contains","overlaps","equals","relate","intersection","nearestvertex","nearestcoordinate","union","difference","symmetricdifference","clip","cut","area","areageodetic","length","length3d","lengthgeodetic","distance","distancegeodetic","densify","densifygeodetic","generalize","buffer","buffergeodetic","offset","rotate","issimple","convexhull","simplify","multiparttosinglepart","pointtocoordinate","distancetocoordinate","measuretocoordinate"]);function o(e){return"string"==typeof e||e instanceof String}function s(e,n){const i="sync"===n?a:t;i.functionDefinitions.has(e.name.toLowerCase())?i.functionDefinitions.get(e.name.toLowerCase())?.overloads.push({type:"function",parametersInfo:{min:e.min,max:e.max}}):i.functionDefinitions.set(e.name.toLowerCase(),{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]})}function r(e,n){if(e)for(const a of e)c(a,n)}function c(e,n){if(e&&!1!==n(e))switch(e.type){case"ImportDeclaration":r(e.specifiers,n),c(e.source,n);break;case"ExportNamedDeclaration":c(e.declaration,n);break;case"ArrayExpression":r(e.elements,n);break;case"AssignmentExpression":case"BinaryExpression":case"LogicalExpression":c(e.left,n),c(e.right,n);break;case"BlockStatement":case"Program":r(e.body,n);break;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":case"Identifier":case"Literal":break;case"CallExpression":c(e.callee,n),r(e.arguments,n);break;case"ExpressionStatement":c(e.expression,n);break;case"ForInStatement":c(e.left,n),c(e.right,n),c(e.body,n);break;case"ForStatement":c(e.init,n),c(e.test,n),c(e.update,n),c(e.body,n);break;case"WhileStatement":c(e.test,n),c(e.body,n);break;case"FunctionDeclaration":c(e.id,n),r(e.params,n),c(e.body,n);break;case"IfStatement":c(e.test,n),c(e.consequent,n),c(e.alternate,n);break;case"MemberExpression":c(e.object,n),c(e.property,n);break;case"ObjectExpression":r(e.properties,n);break;case"Property":c(e.key,n),c(e.value,n);break;case"ReturnStatement":case"UnaryExpression":case"UpdateExpression":c(e.argument,n);break;case"VariableDeclaration":r(e.declarations,n);break;case"VariableDeclarator":c(e.id,n),c(e.init,n);break;case"TemplateLiteral":r(e.expressions,n),r(e.quasis,n)}}function x(e,n){let a=!1;const t=n.toLowerCase();return c(e,(e=>!a&&("Identifier"===e.type&&e.name&&e.name.toLowerCase()===t&&(a=!0),!0))),a}function p(n){const a=[];return c(n,(n=>("ImportDeclaration"===n.type&&n.source&&n.source.value&&a.push({libname:e(n.specifiers[0].local),source:n.source.value}),!0))),a}function l(e,n){let a=!1;const t=n.toLowerCase();return c(e,(e=>!a&&("CallExpression"!==e.type||"Identifier"!==e.callee.type||!e.callee.name||e.callee.name.toLowerCase()!==t||(a=!0,!1)))),a}function u(n){const a=[];return c(n,(n=>"MemberExpression"!==n.type||"Identifier"!==n.object.type||(("Identifier"===n.property.type||"Literal"===n.property.type&&"string"==typeof n.property.value)&&a.push({varId:e(n.object),memberId:e(n.property)}),!1))),a}function f(e){const n=[];return c(e,(e=>{if("CallExpression"===e.type){if("Identifier"===e.callee.type&&"expects"===e.callee.name.toLowerCase()){let a="";for(let t=0;t<(e.arguments||[]).length;t++)0===t?"Identifier"===e.arguments[t].type&&(a=e.arguments[t].name.toLowerCase()):a&&"Literal"===e.arguments[t].type&&o(e.arguments[t].value)&&n.push(a+"."+e.arguments[t].value.toLowerCase());return!1}if("Identifier"===e.callee.type&&["domainname","domaincode","domain","haskey"].includes(e.callee.name.toLowerCase())&&e.arguments.length>=2){let a="";return"Identifier"===e.arguments[0].type&&(a=e.arguments[0].name.toLowerCase()),a&&"Literal"===e.arguments[1].type&&o(e.arguments[1].value)&&n.push(a+"."+e.arguments[1].value.toLowerCase()),!1}}return"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1)})),n}function d(e,n){const a=[];if(void 0!==n.params&&null!==n.params)for(let t=0;t<n.params.length;t++)a.push("any");return{name:e,return:"any",params:a}}function y(e){const n=[];return c(e,(e=>("CallExpression"===e.type&&"Identifier"===e.callee.type&&n.push(e.callee.name.toLowerCase()),!0))),n}function g(e,n=[]){let a=null;if(void 0===e.usesFeatureSet){null===a&&(a=y(e)),e.usesFeatureSet=!1;for(let n=0;n<a.length;n++)i.has(a[n])&&(e.usesFeatureSet=!0,e.isAsync=!0);if(!1===e.usesFeatureSet&&n&&n.length>0)for(const a of n)if(x(e,a)){e.usesFeatureSet=!0,e.isAsync=!0;break}}if(void 0===e.usesModules){e.usesModules=!1;p(e).length>0&&(e.usesModules=!0)}if(void 0===e.usesGeometry){e.usesGeometry=!1,null===a&&(a=y(e));for(let n=0;n<a.length;n++)m.has(a[n])&&(e.usesGeometry=!0)}}function b(e){const n=y(e);for(let a=0;a<n.length;a++)if(i.has(n[a]))return!0;return!1}export{s as addFunctionDeclaration,d as extractFunctionDeclaration,f as findExpectedFieldLiterals,y as findFunctionCalls,u as findLiteralMemberAccesses,p as findModuleImports,g as findScriptDependencies,t as fullArcadeApiAsync,a as fullArcadeApiSync,l as referencesFunction,x as referencesMember,b as scriptUsesFeatureSet,c as walk};
|