@arcgis/coding-components
Version:
Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.
65 lines (64 loc) • 1.48 kB
JavaScript
import i from "@arcgis/core/request.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 */
function p() {
return !!window.MonacoEnvironment?.getWorkerUrl;
}
let n = "";
const u = /* @__PURE__ */ new Map();
async function l(s, e) {
const r = await i(s, { responseType: "text" });
return new Worker(URL.createObjectURL(new Blob([r.data], { type: "text/javascript" })), { type: "module" });
}
function k(s) {
if (p())
return;
n = s;
const e = `${n}/code-editor`, r = {
arcade: `${e}/arcade.worker.js`,
"arcgis-sql-expression": `${e}/sql-expr.worker.js`,
html: `${e}/html.worker.js`,
css: `${e}/css.worker.js`,
typescript: `${e}/ts.worker.js`,
json: `${e}/json.worker.js`,
default: `${e}/editor.worker.js`
}, t = {
arcade: {
url: r.arcade
},
"arcgis-sql-expression": {
url: r["arcgis-sql-expression"]
},
html: {
url: r.html
},
css: {
url: r.css
},
typescript: {
url: r.typescript
},
javascript: {
url: r.typescript
},
json: {
url: r.json
},
default: {
url: r.default
}
};
window.MonacoEnvironment = {
getWorker: async (w, o) => {
const a = u.get(o);
if (a)
return await l(a);
const { url: c, localWorker: d } = t[o] || t.default;
return await l(c);
}
};
}
export {
k as s
};