@arcgis/coding-components
Version:
Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.
95 lines (94 loc) • 4.66 kB
JavaScript
import { createArcadeExecutor as C } from "@arcgis/core/arcade.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
v4.33.14 */
const G = "https://developers.arcgis.com/arcade/", O = 100, A = 100;
function u(t) {
return !!t && typeof t == "object" && "declaredRootClass" in t && typeof t.declaredRootClass == "string" && t.declaredRootClass === "esri.arcade.featureset.support.FeatureSet";
}
function g(t) {
return !!t && typeof t == "object" && "arcadeDeclaredClass" in t && typeof t.arcadeDeclaredClass == "string" && t.arcadeDeclaredClass === "esri.arcade.Feature";
}
function b(t) {
return !!t && typeof t == "object" && "declaredClass" in t && typeof t.declaredClass == "string" && t.declaredClass === "esri.arcade.Dictionary";
}
function R(t) {
return !!t && typeof t == "object" && "declaredClass" in t && typeof t.declaredClass == "string" && t.declaredClass.startsWith("esri.geometry.");
}
function w(t) {
return !!t && typeof t == "object" && "declaredClass" in t && typeof t.declaredClass == "string" && t.declaredClass.startsWith("esri.rest.knowledgeGraph.KnowledgeGraph");
}
function h(t) {
return !!t && typeof t == "object" && "declaredClass" in t && typeof t.declaredClass == "string" && t.declaredClass === "esri.arcade.Portal";
}
function D(t) {
return !!t && typeof t == "object" && "declaredClass" in t && typeof t.declaredClass == "string" && t.declaredClass === "esri.arcade.Attachment";
}
function S(t) {
return !!t && typeof t == "object" && "declaredRootClass" in t && typeof t.declaredRootClass == "string" && t.declaredRootClass === "esri.arcade.arcadedate";
}
function x(t) {
return !!t && typeof t == "object" && "declaredRootClass" in t && typeof t.declaredRootClass == "string" && t.declaredRootClass === "esri.core.sql.dateonly";
}
function F(t) {
return !!t && typeof t == "object" && "declaredRootClass" in t && typeof t.declaredRootClass == "string" && t.declaredRootClass === "esri.core.sql.timeonly";
}
function T(t) {
return !!t && typeof t == "object" && "length" in t && typeof t.length == "function" && "get" in t && typeof t.get == "function" && "toArray" in t && typeof t.toArray == "function" && "_elements" in t && Array.isArray(t._elements);
}
function j(t) {
return t == null ? { type: "null" } : Array.isArray(t) ? { type: "array", value: t } : T(t) ? { type: "array", value: t.toArray() } : t instanceof Date ? { type: "date", value: t } : typeof t == "string" ? { type: "text", value: t } : typeof t == "number" ? { type: "number", value: t } : typeof t == "boolean" ? { type: "boolean", value: t } : typeof t != "object" ? { type: "unknown" } : S(t) ? { type: "date", value: t } : x(t) ? { type: "dateOnly", value: t } : F(t) ? { type: "time", value: t } : D(t) ? { type: "attachment", value: t } : h(t) ? { type: "portal", value: t } : u(t) ? { type: "featureSet", value: t, features: [], iterator: null } : g(t) ? { type: "feature", value: t } : b(t) ? { type: "dictionary", value: t } : R(t) ? { type: "geometry", value: t } : w(t) ? { type: "knowledgeGraph", value: t } : { type: "unknown" };
}
function I(t, r = "en") {
return t.value instanceof Date ? new Intl.DateTimeFormat(r, { dateStyle: "medium", timeStyle: "long" }).format(t.value) : t.value.toDateTime().setLocale(r).toFormat(t.value.isUnknownTimeZone ? "FF" : "FF ZZZZZ");
}
function B(t) {
return t.value.toString();
}
function E(t) {
return t.value.toString();
}
async function Z(t, r = "system") {
const e = j(t);
return e.type !== "featureSet" || (await e.value.load(), e.iterator = e.value.iterator({ aborted: !1 }), e.features = await e.iterator.nextBatchAsArcadeFeatures(A, r) ?? []), e;
}
async function P(t, r, e, i) {
const a = /* @__PURE__ */ new Date();
i ??= () => {
};
try {
const n = performance.now(), o = await C(r ?? "", {
variables: t?.variables ?? []
}), c = performance.now(), { profileVariableInstances: f, spatialReference: y, timeZone: d, services: p } = e, m = {
spatialReference: y,
timeZone: d,
rawOutput: !0,
console: i,
services: p
}, l = await o.executeAsync(
f,
m
), s = await Z(l, d);
return s.timeStamp = a, s.compilationTime = c - n, s.executionTime = performance.now() - c, s;
} catch (n) {
let o = "Unknown Error";
return n instanceof Error && (o = n.message), {
type: "error",
value: o,
error: n,
timeStamp: a,
compilationTime: 0,
executionTime: 0
};
}
}
export {
A as B,
G as D,
O as M,
B as a,
I as b,
P as e,
E as f,
j as v
};