@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.32 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{compileScript as e,extend as r,enableAsyncSupport as t}from"../arcade/arcadeCompiler.js";import{ArcadeModuleResolver as n}from"../arcade/ArcadeModuleResolver.js";import{executeScript as s,extend as a}from"../arcade/arcadeRuntime.js";import{ArcadeExecutionError as u,ExecutionErrorCodes as o}from"../arcade/executionError.js";import{parseScript as i}from"../arcade/parser.js";import{referencesMember as c,referencesFunction as l,findLiteralMemberAccesses as f,findExpectedFieldLiterals as p,findScriptDependencies as d,findModuleImports as m,findFunctionCalls as y}from"../arcade/treeAnalysis.js";import{loadOperators as S}from"../arcade/functions/geomsync.js";import has from"../core/has.js";import{assertIsSome as b}from"../core/maybe.js";const w=new Set(["feature","angle","bearing","centroid","envelopeintersects","extent","geometry","isselfintersecting","ringisclockwise"]);let h=!1,A=!1,g=null,j=[];function x(r,t){if(!0===t.useAsync||!0===r.isAsync)return M(r,t);if(has("esri-csp-restrictions")){return function(e){return s(r,e)}}try{return e(r,t)}catch(n){if("esri.arcade.arcadeuncompilableerror"===n.declaredRootClass)return function(e){return s(r,e)};throw n}}function M(r,t){if(null===g)throw new u(null,o.AsyncNotEnabled,null);if(has("esri-csp-restrictions")){return function(e){return g.executeScript(r,e)}}try{return e(r,t,!0)}catch(n){if("esri.arcade.arcadeuncompilableerror"===n.declaredRootClass)return function(e){return g.executeScript(r,e)};throw n}}function v(e){a(e),r(e,"sync"),null===g?j.push(e):(r(e,"async"),g.extend(e))}function F(e,r=[]){return i(e,r)}function E(e,r,t=[]){return G(i(e,t),r)}function G(e,r){if(!0===r.useAsync||!0===e.isAsync){if(null===g)throw new u(null,o.AsyncNotEnabled,null);return g.executeScript(e,r)}return s(e,r)}function I(e,r){return c(e,r)}function U(e,r){return l(e,r)}function _(e,r=!1){return void 0===r&&(r=!1),f(e).map((({varId:e,memberId:r})=>`${e}.${r}`))}function C(e){return p(e)}function R(e,r=[]){return void 0===e.usesGeometry&&d(e,r),!0===e.usesGeometry}let k=null;function D(){return k||(k=P(),k)}async function P(){return await S(),A=!0,!0}let z=null;function L(){return null!==z||(z=$()),z}async function $(){await t(),g=await import("../arcade/arcadeAsyncRuntime.js");for(const e of j)g.extend(e),r(e,"async");return j=null,!0}function N(){return h}function O(){return!!g}function T(){return A}let q=null;function B(){return q||(q=V(),q)}async function V(){await L();const[e,t,n,s,a,u]=await Promise.all([import("../arcade/featureSetUtils.js"),import("../arcade/functions/featuresetbase.js"),import("../arcade/functions/featuresetgeom.js"),import("../arcade/functions/featuresetstats.js"),import("../arcade/functions/featuresetstring.js"),import("../arcade/functions/knowledgegraph.js")]);return re=e,g.extend([t,n,s,a,u]),r([t,n,s,a,u],"async"),h=!0,!0}function H(e,r=[]){return void 0===e.usesFeatureSet&&d(e,r),!0===e.usesFeatureSet}function J(e,r=[]){return void 0===e.isAsync&&d(e,r),!0===e.isAsync}function K(e,r){if(r){for(const t of r)if(I(e,t))return!0;return!1}return!1}async function Q(e,r,t=[],n=!1,s=null){return W(new Set,e,r,t,n,s)}async function W(e,r,t,n=[],s=!1,a=null){const u="string"==typeof r?F(r):r,o=[];return u&&(!1===T()&&(R(u)||s)&&o.push(D()),!1===O()&&(!0===u.isAsync||t)&&o.push(L()),!1===N()&&(H(u)||K(u,n))&&o.push(B())),o.length&&await Promise.all(o),await Y(e,u,a,t,s),!0}function X(e,r=[]){return void 0===e.usesModules&&d(e,r),!0===e.usesModules}async function Y(e,r,t=null,s=!1,a=!1){const i=m(r);null===t&&i.length>0&&(t=n.getDefault()),r.loadedModules={};for(const n of i){b(t);const i=t.normalizeModuleUri(n.source);if(e.has(i.uri))throw new u(null,o.CircularModules,null);e.add(i.uri);const c=await t.fetchModule(i);await W(e,c,s,[],a,t),e.delete(i.uri),c.isAsync&&(r.isAsync=!0),c.usesFeatureSet&&(r.usesFeatureSet=!0),c.usesGeometry&&(r.usesGeometry=!0),r.loadedModules[n.libname]={uri:i.uri,script:c}}}function Z(e){if(R(e))return!0;const r=y(e);let t=!1;for(let n=0;n<r.length;n++)if(w.has(r[n])){t=!0;break}return t}function ee(e,r){const t=null==r?null:new Set(r.map((e=>e.toLowerCase())));return f(e).some((({varId:e,memberId:r})=>"$view"===e&&(null==t||t.has(r))))}let re=null;function te(){return re}const ne=Object.freeze(Object.defineProperty({__proto__:null,_loadScriptDependenciesImpl:W,compileScript:x,enableAsyncSupport:L,enableAsyncSupportImpl:$,enableFeatureSetSupport:B,enableFeatureSetSupportImpl:V,enableGeometrySupport:D,enableGeometrySupportImpl:P,executeScript:G,extend:v,extractExpectedFieldLiterals:C,extractFieldLiterals:_,featureSetUtils:te,isAsyncEnabled:O,isFeatureSetSupportEnabled:N,isGeometryEnabled:T,loadDependentModules:Y,loadScriptDependencies:Q,parseAndExecuteScript:E,parseScript:F,referencesFunction:U,referencesMember:I,scriptIsAsync:J,scriptTouchesGeometry:Z,scriptUsesFeatureSet:H,scriptUsesGeometryEngine:R,scriptUsesModules:X,scriptUsesViewProperties:ee},Symbol.toStringTag,{value:"Module"}));export{Y as A,ee as B,W as _,C as a,D as b,x as c,B as d,G as e,te as f,R as g,ne as h,v as i,E as j,U as k,Q as l,_ as m,P as n,L as o,F as p,$ as q,I as r,Z as s,N as t,O as u,T as v,V as w,H as x,J as y,X as z};