@arcgis/core 4.32.0-next.20241010 → 4.32.0-next.20241011
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/arcade/arcadeAsyncRuntime.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/90e758afa0bc8f5a5001.js +1 -0
- package/assets/esri/core/workers/chunks/92ce57cb12d9a7a3699e.js +1 -0
- package/assets/esri/core/workers/chunks/ae9820b24859aa497286.js +1 -0
- package/assets/esri/core/workers/chunks/{d5043df03c565e7cd197.js → c06c5c815b5e37717fa1.js} +1 -1
- package/assets/esri/core/workers/chunks/cbdc05e11bb52bd3a0c3.js +1 -0
- package/assets/esri/widgets/support/GridControls/t9n/GridControls.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/GridControls_en.json +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 +450 -4
- package/layers/LinkChartLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/supportUtils.js +1 -1
- package/libs/maquette-advanced-projector/projector.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItemResource.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/layers/MediaLayerView2D.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/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/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/assets/esri/core/workers/chunks/88409aee2fd55496b00e.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/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};
|
|
@@ -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};
|