@arcgis/core 4.29.0-next.20231206 → 4.29.0-next.20231207
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/arcade/arcadeRuntime.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{9c1f2a14e610b5ccae80.js → 2f72d3675f3144a44228.js} +1 -1
- package/assets/esri/core/workers/chunks/419f4aaecc4231fdd171.js +1 -0
- package/assets/esri/core/workers/chunks/{65d32058db5969e58290.js → 92e8ca2f5b7676f57cf4.js} +1 -1
- package/assets/esri/core/workers/chunks/{bdbfc256d349281cc510.js → 9e27cff2c1cd9ce6bfc2.js} +28 -28
- package/assets/esri/core/workers/chunks/fca6199a87817ace8032.js +1 -0
- package/assets/esri/images/portal/3dobjecttileslayer16.png +0 -0
- package/assets/esri/images/portal/integratedmeshtileslayer16.png +0 -0
- package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +6 -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/views/interactive/tooltip/t9n/Tooltip.json +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip_en.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_ar.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_bg.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_bs.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_ca.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_cs.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_da.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_de.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_el.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_es.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_et.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_fi.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_fr.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_he.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_hr.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_hu.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_id.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_it.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_ja.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_ko.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_lt.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_lv.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_nb.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_nl.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_pl.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_pt-BR.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_pt-PT.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_ro.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_ru.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_sk.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_sl.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_sr.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_sv.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_th.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_tr.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_uk.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_vi.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_zh-CN.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_zh-HK.json +1 -1
- package/assets/esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls_zh-TW.json +1 -1
- package/geometry/support/spatialReferenceUtils.js +1 -1
- package/interfaces.d.ts +17 -1
- package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
- package/layers/support/ClientSideConnection.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/style/StyleProperty.js +1 -1
- package/views/3d/effects/RenderNode.js +5 -0
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/symbolMemory.js +5 -0
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNode.d.ts +4 -0
- package/views/3d/webgl-engine/effects/RenderNodeCollection.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/draw/DrawScreenTool.js +1 -1
- package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
- package/views/interactive/tooltip/components/directionModeIcons.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/widgets/support/SketchTooltipControls.js +1 -1
- package/assets/esri/core/workers/chunks/6739113d882b9ad80a57.js +0 -1
- package/assets/esri/core/workers/chunks/fd49374dfb72d309c034.js +0 -1
- package/views/3d/webgl-engine/effects/RenderNode.js +0 -5
package/arcade/arcadeRuntime.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import n from"./Dictionary.js";import{ArcadeExecutionError as o,ExecutionErrorCodes as r,ensureArcadeExecutionError as l}from"./executionError.js";import i from"./Feature.js";import{NativeFunction as a,ArcadeFunction as s,ScopeMarshalledFunction as c,wrapModuleScopedResponse as u}from"./FunctionWrapper.js";import{E as f,a as p,C as d,A as h,z as w,y as m,i as g,c as v,o as y,R as b,q as x,r as S,b as I,g as F,I as C,j as R,B as A,D as M,w as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as L}from"./treeAnalysis.js";import{A as N}from"../chunks/array.js";import{registerFunctions as O}from"./functions/date.js";import{registerFunctions as B,geometryMember as j}from"./functions/geometry.js";import{registerFunctions as k}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as K}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import q from"../geometry/Geometry.js";import Z from"../geometry/SpatialReference.js";class G extends s{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,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new o(e,r.MaximumCallDepth,null);return Ie(this.definition,n,t,null)}}call(e,t){return W(e,t,((n,l,i)=>{const a={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(a.depthCounter.depth>64)throw new o(e,r.MaximumCallDepth,t);return Ie(this.definition,a,i,t)}))}marshalledCall(e,t,n,o){return o(e,t,((r,l,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!g(t)||t instanceof c?t:u(t,e,o))),u(Ie(this.definition,a,i,t),n,o)}))}}class P extends e{constructor(e){super(e)}global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=V(this.executingContext,t.node),t.valueset=!0),g(t.value)&&!(t.value instanceof c)){const e=new c;e.fn=t.value,e.parameterEvaluator=W,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(g(t))throw new o(null,r.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]}loadModule(e){let n=e.spatialReference;null==n&&(n=new Z({wkid:102100})),this.moduleScope=Ce({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:n,globalScope:this.moduleScope,localScope:null,libraryResolver:new t(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ae,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},V(this.executingContext,this.source.syntax)}}function T(e,t){const n=[];for(let o=0;o<t.arguments.length;o++)n.push(V(e,t.arguments[o]));return n}function W(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,T(e,t))}catch(o){throw o}}function V(e,t){try{switch(t?.type){case"EmptyStatement":return m;case"VariableDeclarator":return ce(e,t);case"VariableDeclaration":return se(e,t);case"ImportDeclaration":return ie(e,t);case"ExportNamedDeclaration":return ae(e,t);case"BlockStatement":case"Program":return oe(e,t);case"FunctionDeclaration":return le(e,t);case"ReturnStatement":return re(e,t);case"IfStatement":return ne(e,t);case"ExpressionStatement":return te(e,t);case"AssignmentExpression":return ee(e,t);case"UpdateExpression":return X(e,t);case"BreakStatement":return w;case"ContinueStatement":return h;case"TemplateElement":return we(e,t);case"TemplateLiteral":return ge(e,t);case"ForStatement":return H(e,t);case"ForInStatement":return Y(e,t);case"WhileStatement":return J(e,t);case"Identifier":return ve(e,t);case"MemberExpression":return ue(e,t);case"Literal":return t.value;case"CallExpression":return ye(e,t);case"UnaryExpression":return fe(e,t);case"BinaryExpression":return de(e,t);case"LogicalExpression":return he(e,t);case"ArrayExpression":return pe(e,t);case"ObjectExpression":return _(e,t);case"Property":return z(e,t);default:throw new o(e,r.Unrecognized,t)}}catch(n){throw l(e,t,n)}}function _(e,t){const l={},i=new Map;for(let n=0;n<t.properties.length;n++){const a=V(e,t.properties[n]);if(g(a.value))throw new o(e,r.NoFunctionInDictionary,t);if(!1===v(a.key))throw new o(e,r.KeyMustBeString,t);let s=a.key.toString();const c=s.toLowerCase();i.has(c)?s=i.get(c):i.set(c,s),a.value===m?l[s]=null:l[s]=a.value}const a=new n(l);return a.immutable=!1,a}function z(e,t){return{key:"Identifier"===t.key.type?t.key.name:V(e,t.key),value:V(e,t.value)}}function Y(e,t){const l=V(e,t.right);"VariableDeclaration"===t.left.type&&V(e,t.left);let i=null,a="";if("VariableDeclaration"===t.left.type){const e=t.left.declarations[0].id;"Identifier"===e.type&&(a=e.name)}else"Identifier"===t.left.type&&(a=t.left.name);if(!a)throw new o(e,r.InvalidIdentifier,t);if(a=a.toLowerCase(),null!=e.localScope&&void 0!==e.localScope[a]&&(i=e.localScope[a]),null===i&&void 0!==e.globalScope[a]&&(i=e.globalScope[a]),null===i)throw new o(e,r.InvalidIdentifier,t);if(y(l)||v(l)){const n=l.length;for(let o=0;o<n;o++){i.value=o;const n=V(e,t.body);if(n===w)break;if(n instanceof b)return n}return m}if(x(l)){for(let n=0;n<l.length();n++){i.value=n;const o=V(e,t.body);if(o===w)break;if(o instanceof b)return o}return m}if(!(l instanceof n||S(l)))return m;{const n=l.keys();for(let o=0;o<n.length;o++){i.value=n[o];const r=V(e,t.body);if(r===w)break;if(r instanceof b)return r}}}function H(e,t){null!==t.init&&V(e,t.init);const n={testResult:!0,lastAction:m};do{Q(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof b?n.lastAction:m}function J(e,t){const n={testResult:!0,lastAction:m};if(n.testResult=V(e,t.test),!1===n.testResult)return m;if(!0!==n.testResult)throw new o(e,r.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=V(e,t.body),n.lastAction!==w)&&!(n.lastAction instanceof b);)if(n.testResult=V(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new o(e,r.BooleanConditionRequired,t);return n.lastAction instanceof b?n.lastAction:m}function Q(e,t,n){if(null!==t.test){if(n.testResult=V(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new o(e,r.BooleanConditionRequired,t)}n.lastAction=V(e,t.body),n.lastAction!==w?n.lastAction instanceof b?n.testResult=!1:null!==t.update&&V(e,t.update):n.testResult=!1}function X(e,t){let l,i=null,a="";if("MemberExpression"===t.argument.type){if(i=V(e,t.argument.object),!0===t.argument.computed?a=V(e,t.argument.property):"Identifier"===t.argument.property.type&&(a=t.argument.property.name),y(i)){if(!I(a))throw new o(e,r.ArrayAccessorMustBeNumber,t);if(a<0&&(a=i.length+a),a<0||a>=i.length)throw new o(e,r.OutOfBounds,t);l=F(i[a]),i[a]="++"===t.operator?l+1:l-1}else if(i instanceof n){if(!1===v(a))throw new o(e,r.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new o(e,r.FieldNotFound,t);l=F(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else if(S(i)){if(!1===v(a))throw new o(e,r.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new o(e,r.FieldNotFound,t);l=F(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else{if(x(i))throw new o(e,r.Immutable,t);if(!(i instanceof P))throw new o(e,r.InvalidParameter,t);if(!1===v(a))throw new o(e,r.ModuleAccessorMustBeString,t);if(!0!==i.hasGlobal(a))throw new o(e,r.ModuleExportNotFound,t);l=F(i.global(a)),i.setGlobal(a,"++"===t.operator?l+1:l-1)}return!1===t.prefix?l:"++"===t.operator?l+1:l-1}if(i="Identifier"===t.argument.type?t.argument.name.toLowerCase():"",!i)throw new o(e,r.InvalidIdentifier,t);if(null!=e.localScope&&void 0!==e.localScope[i])return l=F(e.localScope[i].value),e.localScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;if(void 0!==e.globalScope[i])return l=F(e.globalScope[i].value),e.globalScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;throw new o(e,r.InvalidIdentifier,t)}function $(e,t,n,l,i){switch(t){case"=":return e===m?null:e;case"/=":return F(n)/F(e);case"*=":return F(n)*F(e);case"-=":return F(n)-F(e);case"+=":return v(n)||v(e)?R(n)+R(e):F(n)+F(e);case"%=":return F(n)%F(e);default:throw new o(i,r.UnsupportedOperator,l)}}function ee(e,t){let l=null,i="";if("MemberExpression"===t.left.type){if(l=V(e,t.left.object),!0===t.left.computed)i=V(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new o(e,r.InvalidIdentifier,t);i=t.left.property.name}const a=V(e,t.right);if(y(l)){if(!I(i))throw new o(e,r.ArrayAccessorMustBeNumber,t);if(i<0&&(i=l.length+i),i<0||i>l.length)throw new o(e,r.OutOfBounds,t);if(i===l.length){if("="!==t.operator)throw new o(e,r.OutOfBounds,t);l[i]=$(a,t.operator,l[i],t,e)}else l[i]=$(a,t.operator,l[i],t,e)}else if(l instanceof n){if(!1===v(i))throw new o(e,r.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new o(e,r.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else if(S(l)){if(!1===v(i))throw new o(e,r.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new o(e,r.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else{if(x(l))throw new o(e,r.Immutable,t);if(!(l instanceof P))throw new o(e,r.InvalidIdentifier,t);if(!1===v(i))throw new o(e,r.ModuleAccessorMustBeString,t);if(!0!==l.hasGlobal(i))throw new o(e,r.ModuleExportNotFound,t);l.setGlobal(i,$(a,t.operator,l.global(i),t,e))}return m}l=t.left.name.toLowerCase();const a=V(e,t.right);if(null!=e.localScope&&void 0!==e.localScope[l])return e.localScope[l]={value:$(a,t.operator,e.localScope[l].value,t,e),valueset:!0,node:t.right},m;if(void 0!==e.globalScope[l])return e.globalScope[l]={value:$(a,t.operator,e.globalScope[l].value,t,e),valueset:!0,node:t.right},m;throw new o(e,r.InvalidIdentifier,t)}function te(e,t){if("AssignmentExpression"===t.expression.type||"UpdateExpression"===t.expression.type)return V(e,t.expression);if("CallExpression"===t.expression.type){const n=V(e,t.expression);return n===m?m:new C(n)}{const n=V(e,t.expression);return n===m?m:new C(n)}}function ne(e,t){const n=V(e,t.test);if(!0===n)return V(e,t.consequent);if(!1===n)return null!==t.alternate?V(e,t.alternate):m;throw new o(e,r.BooleanConditionRequired,t)}function oe(e,t){let n=m;for(let o=0;o<t.body.length;o++)if(n=V(e,t.body[o]),n instanceof b||n===w||n===h)return n;return n}function re(e,t){if(null===t.argument)return new b(m);const n=V(e,t.argument);return new b(n)}function le(e,t){const n=t.id.name.toLowerCase();return e.globalScope[n]={valueset:!0,node:null,value:new G(t,e)},m}function ie(e,t){const n=t.specifiers[0].local.name.toLowerCase(),o=e.libraryResolver.loadLibrary(n);let r=null;return e.libraryResolver._moduleSingletons?.has(o.uri)?r=e.libraryResolver._moduleSingletons.get(o.uri):(r=new P(o),r.loadModule(e),e.libraryResolver._moduleSingletons?.set(o.uri,r)),e.globalScope[n]={value:r,valueset:!0,node:t},m}function ae(e,t){if(V(e,t.declaration),"FunctionDeclaration"===t.declaration.type)e.exports[t.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===t.declaration.type)for(const n of t.declaration.declarations)e.exports[n.id.name.toLowerCase()]="variable";return m}function se(e,t){for(let n=0;n<t.declarations.length;n++)V(e,t.declarations[n]);return m}function ce(e,t){let n=null===t.init?null:V(e,t.init);if(n===m&&(n=null),"Identifier"!==t.id.type)throw new o(e,r.InvalidIdentifier,t);const l=t.id.name.toLowerCase();return null!=e.localScope?e.localScope[l]={value:n,valueset:!0,node:t.init}:e.globalScope[l]={value:n,valueset:!0,node:t.init},m}function ue(e,t){try{const l=V(e,t.object);if(null===l)throw new o(e,r.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(l instanceof n||S(l))return l.field(t.property.name);if(l instanceof q)return j(l,t.property.name,t,e);if(l instanceof P){if(!l.hasGlobal(t.property.name))throw new o(e,r.InvalidIdentifier,t);return l.global(t.property.name)}}throw new o(e,r.InvalidMemberAccessKey,t)}{let i=V(e,t.property);if(l instanceof n||S(l)){if(v(i))return l.field(i);throw new o(e,r.InvalidMemberAccessKey,t)}if(l instanceof P){if(v(i))return l.global(i);throw new o(e,r.InvalidMemberAccessKey,t)}if(l instanceof q){if(v(i))return j(l,i,t,e);throw new o(e,r.InvalidMemberAccessKey,t)}if(y(l)){if(I(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new o(e,r.OutOfBounds,t);return l[i]}throw new o(e,r.InvalidMemberAccessKey,t)}if(v(l)){if(I(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new o(e,r.OutOfBounds,t);return l[i]}throw new o(e,r.InvalidMemberAccessKey,t)}if(x(l)){if(I(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length()+i),i>=l.length()||i<0)throw new o(e,r.OutOfBounds,t);return l.get(i)}throw new o(e,r.InvalidMemberAccessKey,t)}throw new o(e,r.InvalidMemberAccessKey,t)}}catch(l){throw l}}function fe(e,t){try{const n=V(e,t.argument);if(p(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*F(n);if("+"===t.operator)return 1*F(n);if("~"===t.operator)return~F(n);throw new o(e,r.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~F(n);if("-"===t.operator)return-1*F(n);if("+"===t.operator)return 1*F(n);throw new o(e,r.UnsupportedUnaryOperator,t)}catch(n){throw n}}function pe(e,t){try{const n=[];for(let l=0;l<t.elements.length;l++){const i=V(e,t.elements[l]);if(g(i))throw new o(e,r.NoFunctionInArray,t);i===m?n.push(null):n.push(i)}return n}catch(n){throw n}}function de(e,t){try{const n=[V(e,t.left),V(e,t.right)],l=n[0],i=n[1];switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(F(l),F(i),t.operator);case"==":return d(l,i);case"!=":return!d(l,i);case"<":case">":case"<=":case">=":return A(l,i,t.operator);case"+":return v(l)||v(i)?R(l)+R(i):F(l)+F(i);case"-":return F(l)-F(i);case"*":return F(l)*F(i);case"/":return F(l)/F(i);case"%":return F(l)%F(i);default:throw new o(e,r.UnsupportedOperator,t)}}catch(n){throw n}}function he(e,t){try{const n=V(e,t.left);if(p(n))switch(t.operator){case"||":if(!0===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new o(e,r.LogicExpressionOrAnd,t)}case"&&":if(!1===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new o(e,r.LogicExpressionOrAnd,t)}default:throw new o(e,r.LogicExpressionOrAnd,t)}throw new o(e,r.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function we(e,t){return t.value?t.value.cooked:""}function me(e,t,n){if(g(e))throw new o(t,r.NoFunctionInTemplateLiteral,n);return e}function ge(e,t){let n="",o=0;for(const r of t.quasis)if(n+=r.value?r.value.cooked:"",!1===r.tail){n+=t.expressions[o]?R(me(V(e,t.expressions[o]),e,t)):"",o++}return n}function ve(e,t){let n;try{const l=t.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[l])return n=e.localScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;if(void 0!==e.globalScope[l])return n=e.globalScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;throw new o(e,r.InvalidIdentifier,t)}catch(l){throw l}}function ye(e,t){try{if("MemberExpression"===t.callee.type){const n=V(e,t.callee.object);if(!(n instanceof P))throw new o(e,r.FunctionNotFound,t);const l=!1===t.callee.computed?t.callee.property.name:V(e,t.callee.property);if(!n.hasGlobal(l))throw new o(e,r.FunctionNotFound,t);const i=n.global(l);if(!g(i))throw new o(e,r.CallNonFunction,t);return i.call(e,t)}if("Identifier"!==t.callee.type)throw new o(e,r.FunctionNotFound,t);if(null!=e.localScope&&void 0!==e.localScope[t.callee.name.toLowerCase()]){const n=e.localScope[t.callee.name.toLowerCase()];if(g(n.value))return n.value.call(e,t);throw new o(e,r.CallNonFunction,t)}if(void 0!==e.globalScope[t.callee.name.toLowerCase()]){const n=e.globalScope[t.callee.name.toLowerCase()];if(g(n.value))return n.value.call(e,t);throw new o(e,r.CallNonFunction,t)}throw new o(e,r.FunctionNotFound,t)}catch(n){throw n}}const be={};function xe(e,t,n,o){try{const r=t.arguments,l=V(e,r[n]);if(d(l,o))return V(e,r[n+1]);{const l=r.length-n;return 1===l?V(e,r[n]):2===l?null:3===l?V(e,r[n+2]):xe(e,t,n+2,o)}}catch(r){throw r}}function Se(e,t,n,l){try{const i=t.arguments;if(!0===l)return V(e,i[n+1]);if(3===i.length-n)return V(e,i[n+2]);{const l=V(e,i[n+2]);if(!1===p(l))throw new o(e,r.BooleanConditionRequired,i[n+2]);return Se(e,t,n+2,l)}}catch(i){throw i}}function Ie(e,t,n,l){try{const i=e.body;if(n.length!==e.params.length)throw new o(t,r.WrongNumberOfParameters,l);if(null!=t.localScope)for(let o=0;o<n.length;o++)t.localScope[e.params[o].name.toLowerCase()]={value:n[o],valueset:!0,node:null};const a=V(t,i);if(a instanceof b)return a.value;if(a===w)throw new o(t,r.UnexpectedToken,l);if(a===h)throw new o(t,r.UnexpectedToken,l);return a instanceof C?a.value:a}catch(i){throw i}}O(be,W),U(be,W),D(be,W),B(be,W),K(be,W),k(be,W),be.iif=function(e,t){try{const n=t.arguments;f(null===n?[]:n,3,3,e,t);const l=V(e,n[0]);if(!1===p(l))throw new o(e,r.BooleanConditionRequired,t);return V(e,!0===l?n[1]:n[2])}catch(n){throw n}},be.decode=function(e,t){try{const n=t.arguments;if(n.length<2)throw new o(e,r.WrongNumberOfParameters,t);if(2===n.length)return V(e,n[1]);{if((n.length-1)%2==0)throw new o(e,r.WrongNumberOfParameters,t);const l=V(e,n[0]);return xe(e,t,1,l)}}catch(n){throw n}},be.when=function(e,t){try{const n=t.arguments;if(n.length<3)throw new o(e,r.WrongNumberOfParameters,t);if(n.length%2==0)throw new o(e,r.WrongNumberOfParameters,t);const l=V(e,n[0]);if(!1===p(l))throw new o(e,r.BooleanConditionRequired,n[0]);return Se(e,t,0,l)}catch(n){throw n}};for(const Le in be)be[Le]={value:new a(be[Le]),valueset:!0,node:null};const Fe=function(){};function Ce(e,t,o){const r=new Fe;e||(e={}),t||(t={});const l=new n({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});l.immutable=!1,r.textformatting={value:l,valueset:!0,node:null};for(const n in t)r[n]={value:new a(t[n]),native:!0,valueset:!0,node:null};for(const n in e)e[n]&&"esri.Graphic"===e[n].declaredClass?r[n]={value:i.createFromGraphic(e[n],o),valueset:!0,node:null}:r[n]={value:e[n],valueset:!0,node:null};return r}Fe.prototype=be,Fe.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Fe.prototype.pi={value:Math.PI,valueset:!0,node:null};const Re={fixSpatialReference:E,parseArguments:T,standardFunction:W};function Ae(e){console.log(e)}function Me(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:W,evaluateIdentifier:ve};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)be[n]={value:new a(t.functions[n]),valueset:!0,node:null},Fe.prototype[n]=be[n];for(let n=0;n<t.signatures.length;n++)L(t.signatures[n],"sync")}function Ee(e,n){let l=n.spatialReference;null==l&&(l=new Z({wkid:102100}));let i=null;e.usesModules&&(i=new t(new Map,e.loadedModules));const a={spatialReference:l,globalScope:Ce(n.vars,n.customfunctions,n.timeZone),localScope:null,services:n.services??null,exports:{},libraryResolver:i,console:n.console??Ae,timeZone:n.timeZone??null,lrucache:n.lrucache,interceptor:n.interceptor,depthCounter:{depth:1}};let s=V(a,e);if(s instanceof b&&(s=s.value),s instanceof C&&(s=s.value),s===m&&(s=null),s===w)throw new o(a,r.IllegalResult,null);if(s===h)throw new o(a,r.IllegalResult,null);if(g(s))throw new o(a,r.IllegalResult,null);return s}Me([N]);export{Ee as executeScript,Me as extend,Re as functionHelper};
|
|
5
|
+
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import n from"./Dictionary.js";import{ExecutionErrorCodes as o,ArcadeExecutionError as r,ensureArcadeExecutionError as l}from"./executionError.js";import i from"./Feature.js";import{NativeFunction as a,ArcadeFunction as s,ScopeMarshalledFunction as c,wrapModuleScopedResponse as u}from"./FunctionWrapper.js";import{E as f,a as p,C as d,A as h,z as w,y as m,i as g,c as v,o as y,R as b,q as x,r as S,b as I,g as F,I as C,j as R,B as A,D as M,w as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as L}from"./treeAnalysis.js";import{A as N}from"../chunks/array.js";import{registerFunctions as O}from"./functions/date.js";import{registerFunctions as B,geometryMember as j}from"./functions/geometry.js";import{registerFunctions as k}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as K}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import q from"../geometry/Geometry.js";import Z from"../geometry/SpatialReference.js";class G extends s{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,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,null);return Ie(this.definition,n,t,null)}}call(e,t){return W(e,t,((n,l,i)=>{const a={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(a.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,t);return Ie(this.definition,a,i,t)}))}marshalledCall(e,t,n,o){return o(e,t,((r,l,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!g(t)||t instanceof c?t:u(t,e,o))),u(Ie(this.definition,a,i,t),n,o)}))}}class P extends e{constructor(e){super(e)}global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=V(this.executingContext,t.node),t.valueset=!0),g(t.value)&&!(t.value instanceof c)){const e=new c;e.fn=t.value,e.parameterEvaluator=W,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(g(t))throw new r(null,o.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]}loadModule(e){let n=e.spatialReference;null==n&&(n=new Z({wkid:102100})),this.moduleScope=Ce({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:n,globalScope:this.moduleScope,localScope:null,libraryResolver:new t(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ae,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},V(this.executingContext,this.source.syntax)}}function T(e,t){const n=[];for(let o=0;o<t.arguments.length;o++)n.push(V(e,t.arguments[o]));return n}function W(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,T(e,t))}catch(o){throw o}}function V(e,t){try{switch(t?.type){case"EmptyStatement":return m;case"VariableDeclarator":return ce(e,t);case"VariableDeclaration":return se(e,t);case"ImportDeclaration":return ie(e,t);case"ExportNamedDeclaration":return ae(e,t);case"BlockStatement":case"Program":return oe(e,t);case"FunctionDeclaration":return le(e,t);case"ReturnStatement":return re(e,t);case"IfStatement":return ne(e,t);case"ExpressionStatement":return te(e,t);case"AssignmentExpression":return ee(e,t);case"UpdateExpression":return X(e,t);case"BreakStatement":return w;case"ContinueStatement":return h;case"TemplateElement":return we(e,t);case"TemplateLiteral":return ge(e,t);case"ForStatement":return H(e,t);case"ForInStatement":return Y(e,t);case"WhileStatement":return J(e,t);case"Identifier":return ve(e,t);case"MemberExpression":return ue(e,t);case"Literal":return t.value;case"CallExpression":return ye(e,t);case"UnaryExpression":return fe(e,t);case"BinaryExpression":return de(e,t);case"LogicalExpression":return he(e,t);case"ArrayExpression":return pe(e,t);case"ObjectExpression":return _(e,t);case"Property":return z(e,t);default:throw new r(e,o.Unrecognized,t)}}catch(n){throw l(e,t,n)}}function _(e,t){const l={},i=new Map;for(let n=0;n<t.properties.length;n++){const a=V(e,t.properties[n]);if(g(a.value))throw new r(e,o.NoFunctionInDictionary,t);if(!1===v(a.key))throw new r(e,o.KeyMustBeString,t);let s=a.key.toString();const c=s.toLowerCase();i.has(c)?s=i.get(c):i.set(c,s),a.value===m?l[s]=null:l[s]=a.value}const a=new n(l);return a.immutable=!1,a}function z(e,t){return{key:"Identifier"===t.key.type?t.key.name:V(e,t.key),value:V(e,t.value)}}function Y(e,t){const l=V(e,t.right);"VariableDeclaration"===t.left.type&&V(e,t.left);let i=null,a="";if("VariableDeclaration"===t.left.type){const e=t.left.declarations[0].id;"Identifier"===e.type&&(a=e.name)}else"Identifier"===t.left.type&&(a=t.left.name);if(!a)throw new r(e,o.InvalidIdentifier,t);if(a=a.toLowerCase(),null!=e.localScope&&void 0!==e.localScope[a]&&(i=e.localScope[a]),null===i&&void 0!==e.globalScope[a]&&(i=e.globalScope[a]),null===i)throw new r(e,o.InvalidIdentifier,t);if(y(l)||v(l)){const n=l.length;for(let o=0;o<n;o++){i.value=o;const n=V(e,t.body);if(n===w)break;if(n instanceof b)return n}return m}if(x(l)){for(let n=0;n<l.length();n++){i.value=n;const o=V(e,t.body);if(o===w)break;if(o instanceof b)return o}return m}if(!(l instanceof n||S(l)))return m;{const n=l.keys();for(let o=0;o<n.length;o++){i.value=n[o];const r=V(e,t.body);if(r===w)break;if(r instanceof b)return r}}}function H(e,t){null!==t.init&&V(e,t.init);const n={testResult:!0,lastAction:m};do{Q(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof b?n.lastAction:m}function J(e,t){const n={testResult:!0,lastAction:m};if(n.testResult=V(e,t.test),!1===n.testResult)return m;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=V(e,t.body),n.lastAction!==w)&&!(n.lastAction instanceof b);)if(n.testResult=V(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return n.lastAction instanceof b?n.lastAction:m}function Q(e,t,n){if(null!==t.test){if(n.testResult=V(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t)}n.lastAction=V(e,t.body),n.lastAction!==w?n.lastAction instanceof b?n.testResult=!1:null!==t.update&&V(e,t.update):n.testResult=!1}function X(e,t){let l,i=null,a="";if("MemberExpression"===t.argument.type){if(i=V(e,t.argument.object),!0===t.argument.computed?a=V(e,t.argument.property):"Identifier"===t.argument.property.type&&(a=t.argument.property.name),y(i)){if(!I(a))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(a<0&&(a=i.length+a),a<0||a>=i.length)throw new r(e,o.OutOfBounds,t);l=F(i[a]),i[a]="++"===t.operator?l+1:l-1}else if(i instanceof n){if(!1===v(a))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new r(e,o.FieldNotFound,t);l=F(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else if(S(i)){if(!1===v(a))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new r(e,o.FieldNotFound,t);l=F(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else{if(x(i))throw new r(e,o.Immutable,t);if(!(i instanceof P))throw new r(e,o.InvalidParameter,t);if(!1===v(a))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==i.hasGlobal(a))throw new r(e,o.ModuleExportNotFound,t);l=F(i.global(a)),i.setGlobal(a,"++"===t.operator?l+1:l-1)}return!1===t.prefix?l:"++"===t.operator?l+1:l-1}if(i="Identifier"===t.argument.type?t.argument.name.toLowerCase():"",!i)throw new r(e,o.InvalidIdentifier,t);if(null!=e.localScope&&void 0!==e.localScope[i])return l=F(e.localScope[i].value),e.localScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;if(void 0!==e.globalScope[i])return l=F(e.globalScope[i].value),e.globalScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;throw new r(e,o.InvalidIdentifier,t)}function $(e,t,n,l,i){switch(t){case"=":return e===m?null:e;case"/=":return F(n)/F(e);case"*=":return F(n)*F(e);case"-=":return F(n)-F(e);case"+=":return v(n)||v(e)?R(n)+R(e):F(n)+F(e);case"%=":return F(n)%F(e);default:throw new r(i,o.UnsupportedOperator,l)}}function ee(e,t){let l=null,i="";if("MemberExpression"===t.left.type){if(l=V(e,t.left.object),!0===t.left.computed)i=V(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new r(e,o.InvalidIdentifier,t);i=t.left.property.name}const a=V(e,t.right);if(y(l)){if(!I(i))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(i<0&&(i=l.length+i),i<0||i>l.length)throw new r(e,o.OutOfBounds,t);if(i===l.length){if("="!==t.operator)throw new r(e,o.OutOfBounds,t);l[i]=$(a,t.operator,l[i],t,e)}else l[i]=$(a,t.operator,l[i],t,e)}else if(l instanceof n){if(!1===v(i))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else if(S(l)){if(!1===v(i))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else{if(x(l))throw new r(e,o.Immutable,t);if(!(l instanceof P))throw new r(e,o.InvalidIdentifier,t);if(!1===v(i))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==l.hasGlobal(i))throw new r(e,o.ModuleExportNotFound,t);l.setGlobal(i,$(a,t.operator,l.global(i),t,e))}return m}l=t.left.name.toLowerCase();const a=V(e,t.right);if(null!=e.localScope&&void 0!==e.localScope[l])return e.localScope[l]={value:$(a,t.operator,e.localScope[l].value,t,e),valueset:!0,node:t.right},m;if(void 0!==e.globalScope[l])return e.globalScope[l]={value:$(a,t.operator,e.globalScope[l].value,t,e),valueset:!0,node:t.right},m;throw new r(e,o.InvalidIdentifier,t)}function te(e,t){if("AssignmentExpression"===t.expression.type||"UpdateExpression"===t.expression.type)return V(e,t.expression);if("CallExpression"===t.expression.type){const n=V(e,t.expression);return n===m?m:new C(n)}{const n=V(e,t.expression);return n===m?m:new C(n)}}function ne(e,t){const n=V(e,t.test);if(!0===n)return V(e,t.consequent);if(!1===n)return null!==t.alternate?V(e,t.alternate):m;throw new r(e,o.BooleanConditionRequired,t)}function oe(e,t){let n=m;for(let o=0;o<t.body.length;o++)if(n=V(e,t.body[o]),n instanceof b||n===w||n===h)return n;return n}function re(e,t){if(null===t.argument)return new b(m);const n=V(e,t.argument);return new b(n)}function le(e,t){const n=t.id.name.toLowerCase();return e.globalScope[n]={valueset:!0,node:null,value:new G(t,e)},m}function ie(e,t){const n=t.specifiers[0].local.name.toLowerCase(),o=e.libraryResolver.loadLibrary(n);let r=null;return e.libraryResolver._moduleSingletons?.has(o.uri)?r=e.libraryResolver._moduleSingletons.get(o.uri):(r=new P(o),r.loadModule(e),e.libraryResolver._moduleSingletons?.set(o.uri,r)),e.globalScope[n]={value:r,valueset:!0,node:t},m}function ae(e,t){if(V(e,t.declaration),"FunctionDeclaration"===t.declaration.type)e.exports[t.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===t.declaration.type)for(const n of t.declaration.declarations)e.exports[n.id.name.toLowerCase()]="variable";return m}function se(e,t){for(let n=0;n<t.declarations.length;n++)V(e,t.declarations[n]);return m}function ce(e,t){let n=null===t.init?null:V(e,t.init);if(n===m&&(n=null),"Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const l=t.id.name.toLowerCase();return null!=e.localScope?e.localScope[l]={value:n,valueset:!0,node:t.init}:e.globalScope[l]={value:n,valueset:!0,node:t.init},m}function ue(e,t){try{const l=V(e,t.object);if(null===l)throw new r(e,o.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(l instanceof n||S(l))return l.field(t.property.name);if(l instanceof q)return j(l,t.property.name,t,e);if(l instanceof P){if(!l.hasGlobal(t.property.name))throw new r(e,o.InvalidIdentifier,t);return l.global(t.property.name)}}throw new r(e,o.InvalidMemberAccessKey,t)}{let i=V(e,t.property);if(l instanceof n||S(l)){if(v(i))return l.field(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(l instanceof P){if(v(i))return l.global(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(l instanceof q){if(v(i))return j(l,i,t,e);throw new r(e,o.InvalidMemberAccessKey,t)}if(y(l)){if(I(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new r(e,o.OutOfBounds,t);return l[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(v(l)){if(I(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new r(e,o.OutOfBounds,t);return l[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(x(l)){if(I(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length()+i),i>=l.length()||i<0)throw new r(e,o.OutOfBounds,t);return l.get(i)}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}}catch(l){throw l}}function fe(e,t){try{const n=V(e,t.argument);if(p(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*F(n);if("+"===t.operator)return 1*F(n);if("~"===t.operator)return~F(n);throw new r(e,o.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~F(n);if("-"===t.operator)return-1*F(n);if("+"===t.operator)return 1*F(n);throw new r(e,o.UnsupportedUnaryOperator,t)}catch(n){throw n}}function pe(e,t){try{const n=[];for(let l=0;l<t.elements.length;l++){const i=V(e,t.elements[l]);if(g(i))throw new r(e,o.NoFunctionInArray,t);i===m?n.push(null):n.push(i)}return n}catch(n){throw n}}function de(e,t){try{const n=[V(e,t.left),V(e,t.right)],l=n[0],i=n[1];switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(F(l),F(i),t.operator);case"==":return d(l,i);case"!=":return!d(l,i);case"<":case">":case"<=":case">=":return A(l,i,t.operator);case"+":return v(l)||v(i)?R(l)+R(i):F(l)+F(i);case"-":return F(l)-F(i);case"*":return F(l)*F(i);case"/":return F(l)/F(i);case"%":return F(l)%F(i);default:throw new r(e,o.UnsupportedOperator,t)}}catch(n){throw n}}function he(e,t){try{const n=V(e,t.left);if(p(n))switch(t.operator){case"||":if(!0===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new r(e,o.LogicExpressionOrAnd,t)}case"&&":if(!1===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new r(e,o.LogicExpressionOrAnd,t)}default:throw new r(e,o.LogicExpressionOrAnd,t)}throw new r(e,o.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function we(e,t){return t.value?t.value.cooked:""}function me(e,t,n){if(g(e))throw new r(t,o.NoFunctionInTemplateLiteral,n);return e}function ge(e,t){let n="",o=0;for(const r of t.quasis)if(n+=r.value?r.value.cooked:"",!1===r.tail){n+=t.expressions[o]?R(me(V(e,t.expressions[o]),e,t)):"",o++}return n}function ve(e,t){let n;try{const l=t.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[l])return n=e.localScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;if(void 0!==e.globalScope[l])return n=e.globalScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;throw new r(e,o.InvalidIdentifier,t)}catch(l){throw l}}function ye(e,t){try{if("MemberExpression"===t.callee.type){const n=V(e,t.callee.object);if(!(n instanceof P))throw new r(e,o.FunctionNotFound,t);const l=!1===t.callee.computed?t.callee.property.name:V(e,t.callee.property);if(!n.hasGlobal(l))throw new r(e,o.FunctionNotFound,t);const i=n.global(l);if(!g(i))throw new r(e,o.CallNonFunction,t);return i.call(e,t)}if("Identifier"!==t.callee.type)throw new r(e,o.FunctionNotFound,t);if(null!=e.localScope&&void 0!==e.localScope[t.callee.name.toLowerCase()]){const n=e.localScope[t.callee.name.toLowerCase()];if(g(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}if(void 0!==e.globalScope[t.callee.name.toLowerCase()]){const n=e.globalScope[t.callee.name.toLowerCase()];if(g(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}throw new r(e,o.FunctionNotFound,t)}catch(n){throw n}}const be={};function xe(e,t,n,o){try{const r=t.arguments,l=V(e,r[n]);if(d(l,o))return V(e,r[n+1]);{const l=r.length-n;return 1===l?V(e,r[n]):2===l?null:3===l?V(e,r[n+2]):xe(e,t,n+2,o)}}catch(r){throw r}}function Se(e,t,n,l){try{const i=t.arguments;if(!0===l)return V(e,i[n+1]);if(3===i.length-n)return V(e,i[n+2]);{const l=V(e,i[n+2]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,i[n+2]);return Se(e,t,n+2,l)}}catch(i){throw i}}function Ie(e,t,n,l){try{const i=e.body;if(n.length!==e.params.length)throw new r(t,o.WrongNumberOfParameters,l);if(null!=t.localScope)for(let o=0;o<n.length;o++)t.localScope[e.params[o].name.toLowerCase()]={value:n[o],valueset:!0,node:null};const a=V(t,i);if(a instanceof b)return a.value;if(a===w)throw new r(t,o.UnexpectedToken,l);if(a===h)throw new r(t,o.UnexpectedToken,l);return a instanceof C?a.value:a}catch(i){throw i}}O(be,W),U(be,W),D(be,W),B(be,W),K(be,W),k(be,W),be.iif=function(e,t){try{const n=t.arguments;f(null===n?[]:n,3,3,e,t);const l=V(e,n[0]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,t);return V(e,!0===l?n[1]:n[2])}catch(n){throw n}},be.decode=function(e,t){try{const n=t.arguments;if(n.length<2)throw new r(e,o.WrongNumberOfParameters,t);if(2===n.length)return V(e,n[1]);{if((n.length-1)%2==0)throw new r(e,o.WrongNumberOfParameters,t);const l=V(e,n[0]);return xe(e,t,1,l)}}catch(n){throw n}},be.when=function(e,t){try{const n=t.arguments;if(n.length<3)throw new r(e,o.WrongNumberOfParameters,t);if(n.length%2==0)throw new r(e,o.WrongNumberOfParameters,t);const l=V(e,n[0]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,n[0]);return Se(e,t,0,l)}catch(n){throw n}};for(const Le in be)be[Le]={value:new a(be[Le]),valueset:!0,node:null};const Fe=function(){};function Ce(e,t,o){const r=new Fe;e||(e={}),t||(t={});const l=new n({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});l.immutable=!1,r.textformatting={value:l,valueset:!0,node:null};for(const n in t)r[n]={value:new a(t[n]),native:!0,valueset:!0,node:null};for(const n in e)e[n]&&"esri.Graphic"===e[n].declaredClass?r[n]={value:i.createFromGraphic(e[n],o),valueset:!0,node:null}:r[n]={value:e[n],valueset:!0,node:null};return r}Fe.prototype=be,Fe.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Fe.prototype.pi={value:Math.PI,valueset:!0,node:null};const Re={fixSpatialReference:E,parseArguments:T,standardFunction:W};function Ae(e){console.log(e)}function Me(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:W,evaluateIdentifier:ve};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)be[n]={value:new a(t.functions[n]),valueset:!0,node:null},Fe.prototype[n]=be[n];for(let n=0;n<t.signatures.length;n++)L(t.signatures[n],"sync")}function Ee(e,n){let l=n.spatialReference;null==l&&(l=new Z({wkid:102100}));let i=null;e.usesModules&&(i=new t(new Map,e.loadedModules));const a={spatialReference:l,globalScope:Ce(n.vars,n.customfunctions,n.timeZone),localScope:null,services:n.services??null,exports:{},libraryResolver:i,console:n.console??Ae,timeZone:n.timeZone??null,lrucache:n.lrucache,interceptor:n.interceptor,depthCounter:{depth:1}};let s=V(a,e);if(s instanceof b&&(s=s.value),s instanceof C&&(s=s.value),s===m&&(s=null),s===w)throw new r(a,o.IllegalResult,null);if(s===h)throw new r(a,o.IllegalResult,null);if(g(s))throw new r(a,o.IllegalResult,null);return s}Me([N]);export{Ee as executeScript,Me as extend,Re as functionHelper};
|