@arcgis/coding-components 4.30.0-next.21 → 4.30.0-next.22
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/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ar.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bg.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bs.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ca.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.cs.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.da.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.de.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.el.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.en.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.es.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.et.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fi.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fr.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.he.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hr.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hu.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.id.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.it.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ja.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ko.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lt.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lv.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nb.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nl.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pl.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-BR.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-PT.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ro.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ru.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sk.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sl.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sr.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sv.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.th.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.tr.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.uk.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.vi.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-CN.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-HK.json +25 -0
- package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-TW.json +25 -0
- package/dist/arcgis-coding-components/index.esm.js +2 -2
- package/dist/arcgis-coding-components/p-0596e58a.js +68 -0
- package/dist/arcgis-coding-components/p-09b3d456.js +6 -0
- package/dist/arcgis-coding-components/{p-5583b25d.js → p-237cd069.js} +2 -2
- package/dist/arcgis-coding-components/{p-a63eeed9.js → p-3c4c9bb1.js} +1 -1
- package/dist/arcgis-coding-components/{p-253f92ea.js → p-52af3d36.js} +2 -2
- package/dist/arcgis-coding-components/{p-cb5166f2.js → p-54a3c846.js} +2 -2
- package/dist/arcgis-coding-components/{p-192601ca.js → p-68c09f28.js} +2 -2
- package/dist/arcgis-coding-components/p-704509f4.entry.js +6 -0
- package/dist/arcgis-coding-components/{p-b177db92.js → p-89a837be.js} +2 -2
- package/dist/arcgis-coding-components/p-8be62afd.js +7 -0
- package/dist/arcgis-coding-components/{p-eb16cce2.js → p-a8a82d95.js} +2 -2
- package/dist/arcgis-coding-components/{p-1451e0cc.js → p-bf1aaa39.js} +2 -2
- package/dist/arcgis-coding-components/{p-0e7b5896.js → p-bf789380.js} +2 -2
- package/dist/arcgis-coding-components/p-f31fa95c.js +6 -0
- package/dist/arcgis-coding-components/p-f9bdf871.js +6 -0
- package/dist/cjs/Accessor-YDTURKZ7-064d4ec3.js +1249 -0
- package/dist/cjs/{arcade-defaults-9d57f506.js → arcade-defaults-75be7a9b.js} +294 -295
- package/dist/cjs/{arcade-mode-9079b8e0.js → arcade-mode-bf406304.js} +4 -4
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1347 -89
- package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
- package/dist/cjs/chunk-OMA4PI5N-c7c531ca.js +1286 -0
- package/dist/cjs/{css-9aa4569b.js → css-a1b28a9f.js} +1 -1
- package/dist/cjs/{cssMode-6f57c416.js → cssMode-5b3b9c9b.js} +3 -3
- package/dist/cjs/decorators-443AWDOE-ab85b9eb.js +120 -0
- package/dist/cjs/{html-95d3a234.js → html-51efc5f2.js} +3 -3
- package/dist/cjs/{htmlMode-ebd8894d.js → htmlMode-a3589bc9.js} +3 -3
- package/dist/cjs/{index-a3f52cf5.js → index-6a3d1ddd.js} +42 -4
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/{javascript-1a01235b.js → javascript-f387480b.js} +4 -4
- package/dist/cjs/{jsonMode-26ed7799.js → jsonMode-f9b19644.js} +3 -3
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{tsMode-9cfeb9a5.js → tsMode-b1e0bb57.js} +3 -3
- package/dist/cjs/{typescript-f9907455.js → typescript-64e66362.js} +3 -3
- package/dist/components/Accessor-YDTURKZ7.js +1247 -0
- package/dist/components/arcade-api.js +9 -15
- package/dist/components/arcade-contribution.js +3 -3
- package/dist/components/arcade-defaults.js +10 -10
- package/dist/components/arcade-mode.js +3 -3
- package/dist/components/arcade-results.js +24 -35
- package/dist/components/arcade-suggestions.js +10 -16
- package/dist/components/arcade-variables.js +11 -20
- package/dist/components/arcgis-arcade-api.js +1 -1
- package/dist/components/arcgis-arcade-editor.js +20 -24
- package/dist/components/arcgis-arcade-results.js +1 -1
- package/dist/components/arcgis-arcade-suggestions.js +1 -1
- package/dist/components/arcgis-arcade-variables.js +1 -1
- package/dist/components/arcgis-assets.d.ts +1 -1
- package/dist/components/arcgis-assets.js +1 -1
- package/dist/components/arcgis-code-editor.js +1 -1
- package/dist/components/chunk-3I7AEPTU.js +1290 -0
- package/dist/components/chunk-OMA4PI5N.js +1257 -0
- package/dist/components/code-editor.js +6 -6
- package/dist/components/decorators-443AWDOE.js +109 -0
- package/dist/components/fields.js +40 -39
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +3 -3
- package/dist/components/markdown.js +1 -1
- package/dist/components/utilities.js +3 -3
- package/dist/esm/Accessor-YDTURKZ7-4eefd1d8.js +1247 -0
- package/dist/esm/{arcade-defaults-1577045c.js → arcade-defaults-fcc709e4.js} +286 -285
- package/dist/esm/{arcade-mode-ec8b7890.js → arcade-mode-dbf28353.js} +4 -4
- package/dist/esm/arcgis-arcade-api_6.entry.js +1389 -131
- package/dist/esm/arcgis-coding-components.js +4 -4
- package/dist/esm/chunk-OMA4PI5N-0c09fa7b.js +1257 -0
- package/dist/esm/{css-6350c0f7.js → css-6122a30a.js} +1 -1
- package/dist/esm/{cssMode-629b1349.js → cssMode-b890adfc.js} +3 -3
- package/dist/esm/decorators-443AWDOE-77ed5d5a.js +109 -0
- package/dist/esm/{html-979016b0.js → html-2f56c6c3.js} +3 -3
- package/dist/esm/{htmlMode-dd504dae.js → htmlMode-84b5c7ea.js} +3 -3
- package/dist/esm/{index-093931a1.js → index-e75c4ffc.js} +42 -5
- package/dist/esm/index.js +3 -3
- package/dist/esm/{javascript-7af48cb1.js → javascript-8456a624.js} +4 -4
- package/dist/esm/{jsonMode-eb6b41d1.js → jsonMode-29439efe.js} +3 -3
- package/dist/esm/loader.js +4 -4
- package/dist/esm/{tsMode-64deb000.js → tsMode-ec7fe1bf.js} +3 -3
- package/dist/esm/{typescript-c9b14542.js → typescript-d9362143.js} +3 -3
- package/dist/loader/cdn.js +1 -1
- package/dist/loader/index.cjs.js +1 -1
- package/dist/loader/index.es2017.js +1 -1
- package/dist/loader/index.js +1 -1
- package/dist/types/components/arcade-api/arcade-api.d.ts +4 -5
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +7 -4
- package/dist/types/components/arcade-results/arcade-results.d.ts +4 -7
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +4 -5
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +4 -6
- package/package.json +12 -12
- package/dist/arcgis-coding-components/p-81935687.js +0 -68
- package/dist/arcgis-coding-components/p-a2190df0.js +0 -7
- package/dist/arcgis-coding-components/p-e8c2933f.entry.js +0 -6
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stencil.config.d.ts +0 -3
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-inline-url-importer.d.ts +0 -9
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-json-importer.d.ts +0 -19
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/stencil-monaco-plugins.d.ts +0 -6
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
* See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
|
-
* v4.30.0-next.
|
|
4
|
+
* v4.30.0-next.22
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
const index = require('./index-
|
|
11
|
-
const arcadeDefaults = require('./arcade-defaults-
|
|
10
|
+
const index = require('./index-6a3d1ddd.js');
|
|
11
|
+
const arcadeDefaults = require('./arcade-defaults-75be7a9b.js');
|
|
12
12
|
|
|
13
13
|
async function colorizeCode(code) {
|
|
14
14
|
return await arcadeDefaults.editor.colorize(code, "arcade", { tabSize: 2 });
|
|
@@ -2941,6 +2941,1287 @@ function convertMarkdownString(value) {
|
|
|
2941
2941
|
return result;
|
|
2942
2942
|
}
|
|
2943
2943
|
|
|
2944
|
+
// ../components-utils/dist/index.js
|
|
2945
|
+
var h = class {
|
|
2946
|
+
constructor() {
|
|
2947
|
+
this.resolve = () => {
|
|
2948
|
+
}, this.reject = () => {
|
|
2949
|
+
}, this.promise = new Promise((t, n) => {
|
|
2950
|
+
this.resolve = t, this.reject = n;
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
function w(e, t) {
|
|
2955
|
+
let n = e;
|
|
2956
|
+
for (; n; ) {
|
|
2957
|
+
if (n === t)
|
|
2958
|
+
return true;
|
|
2959
|
+
if (!n.parentNode)
|
|
2960
|
+
return false;
|
|
2961
|
+
n.parentNode instanceof ShadowRoot ? n = n.parentNode.host : n = n.parentNode;
|
|
2962
|
+
}
|
|
2963
|
+
return false;
|
|
2964
|
+
}
|
|
2965
|
+
function b(e, t, n) {
|
|
2966
|
+
let { subscribe: r } = $(t);
|
|
2967
|
+
return r((o) => {
|
|
2968
|
+
o.some((s) => w(e, s.target)) && n();
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
var f = {};
|
|
2972
|
+
function $(e) {
|
|
2973
|
+
let t = e.join(","), n = f[t];
|
|
2974
|
+
if (n !== void 0)
|
|
2975
|
+
return n;
|
|
2976
|
+
let r = /* @__PURE__ */ new Set(), o = new MutationObserver((s) => r.forEach((a) => a(s)));
|
|
2977
|
+
o.observe(document.documentElement, { attributes: true, attributeFilter: e, subtree: true });
|
|
2978
|
+
let i = { subscribe(s) {
|
|
2979
|
+
return r.add(s), { remove: () => {
|
|
2980
|
+
r.delete(s), r.size === 0 && (o.disconnect(), f[t] = void 0);
|
|
2981
|
+
} };
|
|
2982
|
+
} };
|
|
2983
|
+
return f[t] = i, i;
|
|
2984
|
+
}
|
|
2985
|
+
function x(e, t) {
|
|
2986
|
+
let n = e;
|
|
2987
|
+
for (; n; ) {
|
|
2988
|
+
let r = n.closest(t);
|
|
2989
|
+
if (r)
|
|
2990
|
+
return r;
|
|
2991
|
+
let o = n.getRootNode();
|
|
2992
|
+
if (o === document)
|
|
2993
|
+
return null;
|
|
2994
|
+
n = o.host;
|
|
2995
|
+
}
|
|
2996
|
+
return null;
|
|
2997
|
+
}
|
|
2998
|
+
function m(e, t, n) {
|
|
2999
|
+
return x(e, `[${t}]`)?.getAttribute(t) ?? n;
|
|
3000
|
+
}
|
|
3001
|
+
var A = (e) => e.charAt(0).toUpperCase() + e.slice(1);
|
|
3002
|
+
var T = (e) => A(e.replaceAll(/([a-z])([A-Z])/gu, "$1 $2"));
|
|
3003
|
+
var v = /* @__PURE__ */ new Set(["ar", "bg", "bs", "ca", "cs", "da", "de", "el", "en", "es", "et", "fi", "fr", "he", "hr", "hu", "id", "it", "ja", "ko", "lt", "lv", "nl", "nb", "pl", "pt-BR", "pt-PT", "ro", "ru", "sk", "sl", "sr", "sv", "th", "tr", "uk", "vi", "zh-CN", "zh-HK", "zh-TW"]);
|
|
3004
|
+
var g = "en";
|
|
3005
|
+
async function j(e, t, n = "") {
|
|
3006
|
+
let r = `${t}/${n}`, o = `${r}${e}.json`;
|
|
3007
|
+
return u[o] ?? (u[o] = S(e, r)), await u[o];
|
|
3008
|
+
}
|
|
3009
|
+
var u = {};
|
|
3010
|
+
async function S(e, t) {
|
|
3011
|
+
let n = `${t}${e}.json`;
|
|
3012
|
+
try {
|
|
3013
|
+
let r = await fetch(n);
|
|
3014
|
+
if (r.ok)
|
|
3015
|
+
return await r.json();
|
|
3016
|
+
} catch (r) {
|
|
3017
|
+
return console.error(r), E;
|
|
3018
|
+
}
|
|
3019
|
+
return e === g ? E : await S(g, t);
|
|
3020
|
+
}
|
|
3021
|
+
var E = new Proxy({}, { get: (e, t) => T(t.toString()) });
|
|
3022
|
+
function M(e) {
|
|
3023
|
+
let t = m(e, "lang", navigator.language || g);
|
|
3024
|
+
if (v.has(t))
|
|
3025
|
+
return { lang: t, t9nLocale: t };
|
|
3026
|
+
let n = t.slice(0, 2);
|
|
3027
|
+
return { lang: t, t9nLocale: v.has(n) ? n : g };
|
|
3028
|
+
}
|
|
3029
|
+
function Y(e, t, n, r) {
|
|
3030
|
+
let o, i = () => void P(e, t, r).then((s) => {
|
|
3031
|
+
(o?.lang !== s.lang || o.t9nLocale !== s.t9nLocale || o.t9nStrings !== s.t9nStrings) && n(s), o = s;
|
|
3032
|
+
}).catch(console.error);
|
|
3033
|
+
return i(), b(e, ["lang"], i);
|
|
3034
|
+
}
|
|
3035
|
+
async function P(e, t, n = e.tagName.toLowerCase().replace("arcgis-", "")) {
|
|
3036
|
+
let { lang: r, t9nLocale: o } = M(e), i = `${t}/${n}/t9n`, s = `${n}.t9n.`, a = await j(o, i, s);
|
|
3037
|
+
return { lang: r, t9nLocale: o, t9nStrings: a };
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
// src/types.ts
|
|
3041
|
+
var controllerSymbol = Symbol("controller");
|
|
3042
|
+
|
|
3043
|
+
// src/utils.ts
|
|
3044
|
+
function safeCall(callback) {
|
|
3045
|
+
try {
|
|
3046
|
+
return callback?.();
|
|
3047
|
+
} catch (error) {
|
|
3048
|
+
console.error(error, callback);
|
|
3049
|
+
}
|
|
3050
|
+
return void 0;
|
|
3051
|
+
}
|
|
3052
|
+
async function safeAsyncCall(callback) {
|
|
3053
|
+
try {
|
|
3054
|
+
return await callback();
|
|
3055
|
+
} catch (error) {
|
|
3056
|
+
console.error(error, callback);
|
|
3057
|
+
}
|
|
3058
|
+
return void 0;
|
|
3059
|
+
}
|
|
3060
|
+
function extendObject(base, extend) {
|
|
3061
|
+
Object.entries(extend).forEach(([key, value]) => {
|
|
3062
|
+
if (key in base)
|
|
3063
|
+
throw new Error(`Unable to extend object because property "${key}" is already defined`);
|
|
3064
|
+
const thisBase = base;
|
|
3065
|
+
thisBase[key] = value;
|
|
3066
|
+
});
|
|
3067
|
+
return base;
|
|
3068
|
+
}
|
|
3069
|
+
var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
3070
|
+
|
|
3071
|
+
// src/ControllerInternals.ts
|
|
3072
|
+
var ControllerInternals = class {
|
|
3073
|
+
constructor() {
|
|
3074
|
+
this._ambientControllers = [];
|
|
3075
|
+
/**
|
|
3076
|
+
* The type definition has to be duplicated due to the
|
|
3077
|
+
* "'use' is referenced directly or indirectly in its own type annotation."
|
|
3078
|
+
* error
|
|
3079
|
+
*/
|
|
3080
|
+
this.use = async (value, watchExports) => {
|
|
3081
|
+
const controller = this._useRefSync(value);
|
|
3082
|
+
if (controller === void 0) {
|
|
3083
|
+
if (typeof watchExports === "function") {
|
|
3084
|
+
const error = new Error(
|
|
3085
|
+
`Unable to resolve a controller from the provided value, so can't watch it's exports. ${unresolvableExports}`
|
|
3086
|
+
);
|
|
3087
|
+
console.error(error);
|
|
3088
|
+
}
|
|
3089
|
+
return value;
|
|
3090
|
+
}
|
|
3091
|
+
await controller.ready;
|
|
3092
|
+
if (typeof watchExports === "function") {
|
|
3093
|
+
if (controller.watchExports === void 0)
|
|
3094
|
+
throw new Error(`The controller must implement watchExports method to support watching exports`);
|
|
3095
|
+
const unsubscribe = controller.watchExports(
|
|
3096
|
+
(exports) => watchExports(exports, unsubscribe)
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
return controller.exports;
|
|
3100
|
+
};
|
|
3101
|
+
this.useRef = async (value) => {
|
|
3102
|
+
const controller = this._useRefSync(value);
|
|
3103
|
+
if (controller === void 0)
|
|
3104
|
+
throw new Error(`Unable to resolve a controller from the provided value. ${unresolvableExports}`);
|
|
3105
|
+
await controller.ready;
|
|
3106
|
+
return controller;
|
|
3107
|
+
};
|
|
3108
|
+
this.shouldBypassSetter = false;
|
|
3109
|
+
/**
|
|
3110
|
+
* A map from component instance or component element to component instance.
|
|
3111
|
+
* To get from component instance or component element to component element,
|
|
3112
|
+
* you can just use the .el property
|
|
3113
|
+
*/
|
|
3114
|
+
this.elementToInstance = /* @__PURE__ */ new WeakMap();
|
|
3115
|
+
}
|
|
3116
|
+
/*
|
|
3117
|
+
* Allow controllers to implicitly retrive which component they are in, to
|
|
3118
|
+
* improve DX (avoids the need to pass "this" explicitly for each controller)
|
|
3119
|
+
*/
|
|
3120
|
+
setAmbientComponent(component) {
|
|
3121
|
+
if (this._ambientComponent === component)
|
|
3122
|
+
return;
|
|
3123
|
+
this._ambientComponent = component;
|
|
3124
|
+
queueMicrotask(() => {
|
|
3125
|
+
if (this._ambientComponent === component)
|
|
3126
|
+
this._ambientComponent = void 0;
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
retriveComponent(name) {
|
|
3130
|
+
if (this._ambientComponent === void 0)
|
|
3131
|
+
throw new Error(
|
|
3132
|
+
[
|
|
3133
|
+
`Unable to find out which component ${name || "this"} controller `,
|
|
3134
|
+
"belongs to. This might happen if you tried to create a controller ",
|
|
3135
|
+
"outside the component. If so, please wrap your controller ",
|
|
3136
|
+
"definition in an arrow function, ",
|
|
3137
|
+
"`const myController = ()=>makeController(...);` and call that",
|
|
3138
|
+
"function inside the component `my = myController();`, or ",
|
|
3139
|
+
"define your controller using makeGenericController/GenericController ",
|
|
3140
|
+
"instead.\n",
|
|
3141
|
+
"If you wish to use a controller inside an async controller, ",
|
|
3142
|
+
"make sure you are using controller.use.\n",
|
|
3143
|
+
"You might also have multiple instances of Controllers loaded"
|
|
3144
|
+
].join("\n")
|
|
3145
|
+
);
|
|
3146
|
+
return this._ambientComponent;
|
|
3147
|
+
}
|
|
3148
|
+
/*
|
|
3149
|
+
* Aids proxyExports() in knowing who is it's host
|
|
3150
|
+
*/
|
|
3151
|
+
setParentController(controller) {
|
|
3152
|
+
if (controller === void 0) {
|
|
3153
|
+
this._ambientControllers = [];
|
|
3154
|
+
return;
|
|
3155
|
+
}
|
|
3156
|
+
const index = this._ambientControllers.indexOf(controller);
|
|
3157
|
+
this._ambientControllers = index === -1 ? [...this._ambientControllers, controller] : this._ambientControllers.slice(0, index + 1);
|
|
3158
|
+
queueMicrotask(() => {
|
|
3159
|
+
this._ambientControllers = [];
|
|
3160
|
+
});
|
|
3161
|
+
}
|
|
3162
|
+
retriveParentControllers() {
|
|
3163
|
+
return this._ambientControllers;
|
|
3164
|
+
}
|
|
3165
|
+
/*
|
|
3166
|
+
* Aids controller.use in retrieving controller value when it receives
|
|
3167
|
+
* controller exports, rather than the controller itself
|
|
3168
|
+
*/
|
|
3169
|
+
setAmbientChildController(controller) {
|
|
3170
|
+
if (this._ambientChildController === controller)
|
|
3171
|
+
return;
|
|
3172
|
+
this._ambientChildController = controller;
|
|
3173
|
+
queueMicrotask(() => {
|
|
3174
|
+
if (this._ambientChildController === controller)
|
|
3175
|
+
this._ambientChildController = void 0;
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
3178
|
+
retriveAmbientChildController() {
|
|
3179
|
+
const controller = this._ambientChildController;
|
|
3180
|
+
this._ambientChildController = void 0;
|
|
3181
|
+
return controller;
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Try to resolve a controller, without awaiting it's load
|
|
3185
|
+
*/
|
|
3186
|
+
_useRefSync(value) {
|
|
3187
|
+
const ambientChildController = this.retriveAmbientChildController();
|
|
3188
|
+
if (ambientChildController !== void 0)
|
|
3189
|
+
return ambientChildController;
|
|
3190
|
+
const component = Controller.internals.retriveComponent();
|
|
3191
|
+
const controller = component.manager.internals.resolveExports(value);
|
|
3192
|
+
if (controller !== void 0)
|
|
3193
|
+
return controller;
|
|
3194
|
+
if (isController(value))
|
|
3195
|
+
return value;
|
|
3196
|
+
return void 0;
|
|
3197
|
+
}
|
|
3198
|
+
};
|
|
3199
|
+
var unresolvableExports = [
|
|
3200
|
+
"The value you passed is not a controller and not a controller exports. If ",
|
|
3201
|
+
"your controller exports a literal value, try making your controller export ",
|
|
3202
|
+
"an object instead"
|
|
3203
|
+
].join("");
|
|
3204
|
+
|
|
3205
|
+
// src/stencil.ts
|
|
3206
|
+
function retrieveComponentMeta(component) {
|
|
3207
|
+
const constructor = component.constructor;
|
|
3208
|
+
const meta = constructor.__registerControllers?.(component)?.$cmpMeta$ ?? void 0;
|
|
3209
|
+
constructor.__registerControllers = void 0;
|
|
3210
|
+
if (typeof meta !== "object")
|
|
3211
|
+
throw new Error(
|
|
3212
|
+
"Failed to retrive internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
|
|
3213
|
+
);
|
|
3214
|
+
component.manager.internals.meta = meta;
|
|
3215
|
+
}
|
|
3216
|
+
function parsePropertyValue(value, type = 0) {
|
|
3217
|
+
if (value == null || typeof type !== "number")
|
|
3218
|
+
return value;
|
|
3219
|
+
if ((type & 4 /* Boolean */) !== 0)
|
|
3220
|
+
return value === "false" ? false : value === "" || !!value;
|
|
3221
|
+
else if ((type & 2 /* Number */) !== 0)
|
|
3222
|
+
return Number.parseFloat(value.toString());
|
|
3223
|
+
else if ((type & 1 /* String */) !== 0)
|
|
3224
|
+
return String(value);
|
|
3225
|
+
else
|
|
3226
|
+
return value;
|
|
3227
|
+
}
|
|
3228
|
+
var makeMemberFilter = (filter) => (component) => {
|
|
3229
|
+
const meta = component.manager.internals.meta;
|
|
3230
|
+
return Object.entries(meta.$members$ ?? {}).filter(([_name, [propType]]) => (propType & filter) !== 0).map(([name]) => name);
|
|
3231
|
+
};
|
|
3232
|
+
var getPropLikeMembers = makeMemberFilter(63 /* PropLike */);
|
|
3233
|
+
var getMemberType = (component, name) => component.manager.internals.meta.$members$?.[name]?.[0];
|
|
3234
|
+
function getPropType(component, name) {
|
|
3235
|
+
const type = getMemberType(component, name);
|
|
3236
|
+
if (type === void 0)
|
|
3237
|
+
return void 0;
|
|
3238
|
+
else if (type & 32 /* State */)
|
|
3239
|
+
return "state";
|
|
3240
|
+
else
|
|
3241
|
+
return "prop";
|
|
3242
|
+
}
|
|
3243
|
+
function addPropertyWatcher(component, property) {
|
|
3244
|
+
const meta = component.manager.internals.meta;
|
|
3245
|
+
meta.$watchers$ ?? (meta.$watchers$ = {});
|
|
3246
|
+
const watchers = meta.$watchers$;
|
|
3247
|
+
if (!(property in watchers))
|
|
3248
|
+
watchers[property] = [];
|
|
3249
|
+
if (!watchers[property].includes(watcherCallbackName))
|
|
3250
|
+
watchers[property].push(watcherCallbackName);
|
|
3251
|
+
}
|
|
3252
|
+
var watcherCallbackName = "dynamicWatcherCallback";
|
|
3253
|
+
|
|
3254
|
+
// src/Controller.ts
|
|
3255
|
+
var _a;
|
|
3256
|
+
var _Controller = class _Controller {
|
|
3257
|
+
constructor(component) {
|
|
3258
|
+
this._ready = new h();
|
|
3259
|
+
this._lifecycleDisconnected = [];
|
|
3260
|
+
this.connectedCalled = false;
|
|
3261
|
+
this.willLoadCalled = false;
|
|
3262
|
+
this.didLoadCalled = false;
|
|
3263
|
+
this[_a] = true;
|
|
3264
|
+
this.ready = this._ready.promise;
|
|
3265
|
+
/*
|
|
3266
|
+
* Setting default exports to "this" so that controllers that don't use
|
|
3267
|
+
* exports/proxyExports(), could still be used as if they did
|
|
3268
|
+
* (i.e with controller.use)
|
|
3269
|
+
*/
|
|
3270
|
+
this._exports = makeProvisionalValue(this);
|
|
3271
|
+
this._exportWatchers = /* @__PURE__ */ new Set();
|
|
3272
|
+
const resolvedComponent = toControllerHost(
|
|
3273
|
+
component ?? _Controller.internals.retriveComponent(new.target.name)
|
|
3274
|
+
);
|
|
3275
|
+
Object.defineProperty(this, "component", {
|
|
3276
|
+
writable: false,
|
|
3277
|
+
enumerable: false,
|
|
3278
|
+
configurable: true,
|
|
3279
|
+
value: resolvedComponent
|
|
3280
|
+
});
|
|
3281
|
+
this.component.addController(this);
|
|
3282
|
+
const manager = this.component.manager;
|
|
3283
|
+
this.connected = manager?.connected;
|
|
3284
|
+
this.internals = manager?.internals;
|
|
3285
|
+
_Controller.internals.setParentController(this);
|
|
3286
|
+
if ("hostDestroy" in this)
|
|
3287
|
+
this.component.manager.ensureHasDestroy();
|
|
3288
|
+
if (manager !== void 0)
|
|
3289
|
+
queueMicrotask(() => this.catchUpLifecycle());
|
|
3290
|
+
const controller = this;
|
|
3291
|
+
this._callbacks = {
|
|
3292
|
+
hostConnected: "hostConnected" in this ? [() => controller.hostConnected?.()] : [],
|
|
3293
|
+
hostDisconnected: "hostDisconnected" in this ? [() => controller.hostDisconnected?.()] : [],
|
|
3294
|
+
hostLoad: "hostLoad" in this ? [() => controller.hostLoad?.()] : [],
|
|
3295
|
+
hostLoaded: "hostLoaded" in this ? [() => controller.hostLoaded?.()] : [],
|
|
3296
|
+
hostRender: "hostRender" in this ? [() => controller.hostRender?.()] : [],
|
|
3297
|
+
hostRendered: "hostRendered" in this ? [() => controller.hostRendered?.()] : [],
|
|
3298
|
+
hostUpdate: "hostUpdate" in this ? [() => controller.hostUpdate?.()] : [],
|
|
3299
|
+
hostUpdated: "hostUpdated" in this ? [() => controller.hostUpdated?.()] : [],
|
|
3300
|
+
hostDestroy: "hostDestroy" in this ? [() => controller.hostDestroy?.()] : [],
|
|
3301
|
+
hostLifecycle: "hostLifecycle" in this ? [() => controller.hostLifecycle?.()] : []
|
|
3302
|
+
};
|
|
3303
|
+
}
|
|
3304
|
+
/**
|
|
3305
|
+
* If controller is being added dynamically, after the component
|
|
3306
|
+
* construction, then trigger connected and load right away
|
|
3307
|
+
*/
|
|
3308
|
+
catchUpLifecycle() {
|
|
3309
|
+
if (this.connectedCalled)
|
|
3310
|
+
return;
|
|
3311
|
+
this.triggerConnected();
|
|
3312
|
+
this.triggerLoad().then(() => this.triggerLoaded()).catch(console.error);
|
|
3313
|
+
}
|
|
3314
|
+
get exports() {
|
|
3315
|
+
return this._exports;
|
|
3316
|
+
}
|
|
3317
|
+
/**
|
|
3318
|
+
* Set controller's exports property (for usage with proxyExports()) and mark
|
|
3319
|
+
* controller as ready (for usage in other controllers). Also, triggers
|
|
3320
|
+
* re-render of the component
|
|
3321
|
+
*/
|
|
3322
|
+
set exports(exports) {
|
|
3323
|
+
if (this._exports !== exports) {
|
|
3324
|
+
this._exports = exports;
|
|
3325
|
+
if (this.connectedCalled)
|
|
3326
|
+
this.component.requestUpdate();
|
|
3327
|
+
this._exportWatchers.forEach((callback) => callback(exports));
|
|
3328
|
+
}
|
|
3329
|
+
this._ready.resolve(exports);
|
|
3330
|
+
}
|
|
3331
|
+
setProvisionalExports(exports) {
|
|
3332
|
+
this._exports = makeProvisionalValue(exports);
|
|
3333
|
+
this._exportWatchers.forEach((callback) => callback(this._exports));
|
|
3334
|
+
}
|
|
3335
|
+
watchExports(callback) {
|
|
3336
|
+
const safeCallback = (exports) => safeCall(() => callback(exports));
|
|
3337
|
+
this._exportWatchers.add(safeCallback);
|
|
3338
|
+
return () => void this._exportWatchers.delete(safeCallback);
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* A flexible utility for making sure a controller is loaded before it's used,
|
|
3342
|
+
* regardless of how or where a controller was defined:
|
|
3343
|
+
*
|
|
3344
|
+
* @example
|
|
3345
|
+
* makeGenericController(async (component, controller) => {
|
|
3346
|
+
* // Await some controller from the component:
|
|
3347
|
+
* await controller.use(component.someController);
|
|
3348
|
+
* // Initialize new controllers
|
|
3349
|
+
* await controller.use(load(importCoreReactiveUtils));
|
|
3350
|
+
* await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
|
|
3351
|
+
* await controller.use(someController(component));
|
|
3352
|
+
* });
|
|
3353
|
+
*
|
|
3354
|
+
* @remarks
|
|
3355
|
+
* If your controller is not async, and you are not creating it async, then
|
|
3356
|
+
* you are not required to use controller.use - you can use it directly.
|
|
3357
|
+
* Similarly, accessing controllers after componentWillLoad callback does not
|
|
3358
|
+
* require awaiting them as they are guaranteed to be loaded by then.
|
|
3359
|
+
*/
|
|
3360
|
+
get use() {
|
|
3361
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3362
|
+
return _Controller.internals.use;
|
|
3363
|
+
}
|
|
3364
|
+
/**
|
|
3365
|
+
* Just like controller.use, but returns the controller itself, rather than it's
|
|
3366
|
+
* exports
|
|
3367
|
+
*
|
|
3368
|
+
* Use cases:
|
|
3369
|
+
* - You have a controller and you want to make sure it's loaded before you
|
|
3370
|
+
* try to use it
|
|
3371
|
+
* - Your contoller is not using exports, so you wish to access some props on
|
|
3372
|
+
* it directly
|
|
3373
|
+
* - You have a controller exports only, and you want to retrieve the
|
|
3374
|
+
* controller itself. This is useful if you wish to call .watchExports() or
|
|
3375
|
+
* some other method on the controller
|
|
3376
|
+
*/
|
|
3377
|
+
get useRef() {
|
|
3378
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3379
|
+
return _Controller.internals.useRef;
|
|
3380
|
+
}
|
|
3381
|
+
/**
|
|
3382
|
+
* If you need to set a prop/state without triggering the custom setter you
|
|
3383
|
+
* defined with getSet()/dynamicGetSet()/readonly(), set the value inside
|
|
3384
|
+
* of this function
|
|
3385
|
+
*
|
|
3386
|
+
* @example
|
|
3387
|
+
* @Prop({mutable:true}) readOnly = this.manager.readOnly(true);
|
|
3388
|
+
*
|
|
3389
|
+
* someAction(): void {
|
|
3390
|
+
* this.manager.bypassSetter(()=>{
|
|
3391
|
+
* this.readOnly = false;
|
|
3392
|
+
* });
|
|
3393
|
+
* }
|
|
3394
|
+
*
|
|
3395
|
+
*/
|
|
3396
|
+
bypassSetter(callback) {
|
|
3397
|
+
_Controller.internals.shouldBypassSetter = true;
|
|
3398
|
+
const result = safeCall(callback);
|
|
3399
|
+
_Controller.internals.shouldBypassSetter = false;
|
|
3400
|
+
return result;
|
|
3401
|
+
}
|
|
3402
|
+
/**
|
|
3403
|
+
* Like this.manager.getSet(), but can be called on any component's
|
|
3404
|
+
* state/prop from anywhere, rather than just from the default value
|
|
3405
|
+
*/
|
|
3406
|
+
dynamicGetSet(name, getSet) {
|
|
3407
|
+
this.genericGetSet(name, getSet);
|
|
3408
|
+
}
|
|
3409
|
+
/**
|
|
3410
|
+
* Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
|
|
3411
|
+
* getters/setters in place where property names & types are not known
|
|
3412
|
+
* statically
|
|
3413
|
+
*/
|
|
3414
|
+
genericGetSet(property, getSet) {
|
|
3415
|
+
var _a2, _b;
|
|
3416
|
+
const classPrototype = Object.getPrototypeOf(this.component);
|
|
3417
|
+
this.internals.getSetProxy(classPrototype, property, getSet, "class");
|
|
3418
|
+
const htmlPrototype = Object.getPrototypeOf(this.component.el);
|
|
3419
|
+
if (classPrototype !== htmlPrototype)
|
|
3420
|
+
this.internals.getSetProxy(htmlPrototype, property, getSet, "html");
|
|
3421
|
+
const genericGetSet = getSet;
|
|
3422
|
+
if (genericGetSet.get !== void 0) {
|
|
3423
|
+
(_a2 = this.internals.getters)[property] ?? (_a2[property] = []);
|
|
3424
|
+
if (getSet.order === "last")
|
|
3425
|
+
this.internals.getters[property].splice(-1, 0, genericGetSet.get);
|
|
3426
|
+
else
|
|
3427
|
+
this.internals.getters[property].unshift(genericGetSet.get);
|
|
3428
|
+
}
|
|
3429
|
+
if (genericGetSet.set !== void 0) {
|
|
3430
|
+
(_b = this.internals.setters)[property] ?? (_b[property] = []);
|
|
3431
|
+
if (getSet.order === "last")
|
|
3432
|
+
this.internals.setters[property].splice(-1, 0, genericGetSet.set);
|
|
3433
|
+
else
|
|
3434
|
+
this.internals.setters[property].unshift(genericGetSet.set);
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3437
|
+
// FEATURE: improve typings
|
|
3438
|
+
/**
|
|
3439
|
+
* Dynamically set a watcher for any @Prop()/@State() property
|
|
3440
|
+
*/
|
|
3441
|
+
watch(property, callback) {
|
|
3442
|
+
var _a2;
|
|
3443
|
+
const type = getMemberType(this.component, property);
|
|
3444
|
+
if (type === void 0)
|
|
3445
|
+
throw new Error(
|
|
3446
|
+
`Trying to watch a non-@Prop, non-@State property "${property}". Either convert it into a @State() or use manager.getSet/dynamicGetSet`
|
|
3447
|
+
);
|
|
3448
|
+
addPropertyWatcher(this.component, property);
|
|
3449
|
+
(_a2 = this.internals.watchers)[property] ?? (_a2[property] = []);
|
|
3450
|
+
const watchers = this.internals.watchers[property];
|
|
3451
|
+
const genericCallback = callback;
|
|
3452
|
+
const safeCallback = (newValue, oldValue, propertyName) => safeCall(() => genericCallback(newValue, oldValue, propertyName));
|
|
3453
|
+
watchers.push(safeCallback);
|
|
3454
|
+
return () => {
|
|
3455
|
+
const index = watchers.indexOf(safeCallback);
|
|
3456
|
+
if (index !== -1)
|
|
3457
|
+
watchers.splice(index, 1);
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
// Register a lifecycle callback
|
|
3461
|
+
onConnected(callback) {
|
|
3462
|
+
this._callbacks.hostConnected.push(callback);
|
|
3463
|
+
}
|
|
3464
|
+
onDisconnected(callback) {
|
|
3465
|
+
this._callbacks.hostDisconnected.push(callback);
|
|
3466
|
+
}
|
|
3467
|
+
onLoad(callback) {
|
|
3468
|
+
this._callbacks.hostLoad.push(callback);
|
|
3469
|
+
}
|
|
3470
|
+
onLoaded(callback) {
|
|
3471
|
+
this._callbacks.hostLoaded.push(callback);
|
|
3472
|
+
}
|
|
3473
|
+
onRender(callback) {
|
|
3474
|
+
this._callbacks.hostRender.push(callback);
|
|
3475
|
+
}
|
|
3476
|
+
onRendered(callback) {
|
|
3477
|
+
this._callbacks.hostRendered.push(callback);
|
|
3478
|
+
}
|
|
3479
|
+
onUpdate(callback) {
|
|
3480
|
+
this._callbacks.hostUpdate.push(callback);
|
|
3481
|
+
}
|
|
3482
|
+
onUpdated(callback) {
|
|
3483
|
+
this._callbacks.hostUpdated.push(callback);
|
|
3484
|
+
}
|
|
3485
|
+
onDestroy(callback) {
|
|
3486
|
+
this.component.manager.ensureHasDestroy();
|
|
3487
|
+
this._callbacks.hostDestroy.push(callback);
|
|
3488
|
+
}
|
|
3489
|
+
onLifecycle(callback) {
|
|
3490
|
+
this._callbacks.hostLifecycle.push(callback);
|
|
3491
|
+
if (this.connectedCalled && this.component.el.isConnected)
|
|
3492
|
+
this._callLifecycle(callback);
|
|
3493
|
+
}
|
|
3494
|
+
// Call each lifecycle hook
|
|
3495
|
+
triggerConnected() {
|
|
3496
|
+
this._callbacks.hostConnected.forEach(safeCall);
|
|
3497
|
+
this.triggerLifecycle();
|
|
3498
|
+
this.connectedCalled = true;
|
|
3499
|
+
}
|
|
3500
|
+
triggerDisconnected() {
|
|
3501
|
+
this._callbacks.hostDisconnected.forEach(safeCall);
|
|
3502
|
+
this._lifecycleDisconnected.forEach(safeCall);
|
|
3503
|
+
this._lifecycleDisconnected = [];
|
|
3504
|
+
}
|
|
3505
|
+
async triggerLoad() {
|
|
3506
|
+
if (this.willLoadCalled)
|
|
3507
|
+
return;
|
|
3508
|
+
this.willLoadCalled = true;
|
|
3509
|
+
if (this._callbacks.hostLoad.length > 0)
|
|
3510
|
+
await Promise.allSettled(this._callbacks.hostLoad.map(safeAsyncCall));
|
|
3511
|
+
this._ready.resolve(this._exports);
|
|
3512
|
+
}
|
|
3513
|
+
triggerLoaded() {
|
|
3514
|
+
if (this.didLoadCalled)
|
|
3515
|
+
return;
|
|
3516
|
+
this._callbacks.hostLoaded.forEach(safeCall);
|
|
3517
|
+
this.didLoadCalled = true;
|
|
3518
|
+
}
|
|
3519
|
+
async triggerRender() {
|
|
3520
|
+
if (this._callbacks.hostRender.length > 0)
|
|
3521
|
+
await Promise.allSettled(this._callbacks.hostRender.map(safeAsyncCall));
|
|
3522
|
+
}
|
|
3523
|
+
triggerRendered() {
|
|
3524
|
+
this._callbacks.hostRendered.forEach(safeCall);
|
|
3525
|
+
}
|
|
3526
|
+
async triggerUpdate() {
|
|
3527
|
+
if (this._callbacks.hostUpdate.length > 0)
|
|
3528
|
+
await Promise.allSettled(this._callbacks.hostUpdate.map(safeAsyncCall));
|
|
3529
|
+
}
|
|
3530
|
+
triggerUpdated() {
|
|
3531
|
+
this._callbacks.hostUpdated.forEach(safeCall);
|
|
3532
|
+
}
|
|
3533
|
+
triggerDestroy() {
|
|
3534
|
+
this._callbacks.hostDestroy.forEach(safeCall);
|
|
3535
|
+
}
|
|
3536
|
+
triggerLifecycle() {
|
|
3537
|
+
this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
|
|
3538
|
+
}
|
|
3539
|
+
_callLifecycle(callback) {
|
|
3540
|
+
const cleanupRaw = safeCall(callback);
|
|
3541
|
+
const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
|
|
3542
|
+
cleanup.forEach((cleanup2) => {
|
|
3543
|
+
if (typeof cleanup2 === "function")
|
|
3544
|
+
this._lifecycleDisconnected.push(cleanup2);
|
|
3545
|
+
else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function")
|
|
3546
|
+
this._lifecycleDisconnected.push(cleanup2.remove);
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
_a = controllerSymbol;
|
|
3551
|
+
_Controller.internals = new ControllerInternals();
|
|
3552
|
+
var Controller = _Controller;
|
|
3553
|
+
var GenericController = class extends Controller {
|
|
3554
|
+
// Redundant constructor needed to improve typing
|
|
3555
|
+
constructor(component) {
|
|
3556
|
+
super(component);
|
|
3557
|
+
}
|
|
3558
|
+
// Overriding super's watch only to improve typing
|
|
3559
|
+
watch(property, callback) {
|
|
3560
|
+
return super.watch(
|
|
3561
|
+
property,
|
|
3562
|
+
callback
|
|
3563
|
+
);
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
* Silence "Property 'dynamicGetSet' in type
|
|
3567
|
+
* 'GenericController<Exports, Requires>' is not assignable to the same
|
|
3568
|
+
* property in base type 'Controller<Exports>'", as TypeScript is being overly
|
|
3569
|
+
* conservative here with what it allows
|
|
3570
|
+
*/
|
|
3571
|
+
dynamicGetSet(property, getSet) {
|
|
3572
|
+
super.genericGetSet(property, getSet);
|
|
3573
|
+
}
|
|
3574
|
+
};
|
|
3575
|
+
function makeProvisionalValue(base) {
|
|
3576
|
+
if (typeof base !== "object" && typeof base !== "function" || base === null)
|
|
3577
|
+
return base;
|
|
3578
|
+
const proxy3 = new Proxy(base, {
|
|
3579
|
+
get(target, prop, receiver) {
|
|
3580
|
+
if (cyclical.has(prop) && prop in target && target[prop] === proxy3)
|
|
3581
|
+
return void 0;
|
|
3582
|
+
if (prop in target || promiseMethods.has(prop) || typeof prop === "symbol")
|
|
3583
|
+
return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
|
|
3584
|
+
console.error(`Trying to access "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
3585
|
+
return void 0;
|
|
3586
|
+
},
|
|
3587
|
+
set(target, prop, newValue, reciever) {
|
|
3588
|
+
console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
3589
|
+
return Reflect.set(target, prop, newValue, reciever);
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
return proxy3;
|
|
3593
|
+
}
|
|
3594
|
+
var promiseMethods = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
|
|
3595
|
+
var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
|
|
3596
|
+
var accessBeforeLoad = [
|
|
3597
|
+
"This might be the case if you are trying to access an async controller in ",
|
|
3598
|
+
"connectedCallback(). Or, if you are using it inside of ",
|
|
3599
|
+
"componentWillLoad()/another controller without controller.use. Example correct ",
|
|
3600
|
+
"usage:\n",
|
|
3601
|
+
"makeController(async (component, controller)=>{ await controller.use(someOtherController); });"
|
|
3602
|
+
].join("");
|
|
3603
|
+
function toControllerHost(component) {
|
|
3604
|
+
if ("addController" in component)
|
|
3605
|
+
return component;
|
|
3606
|
+
else
|
|
3607
|
+
throw new Error(
|
|
3608
|
+
"Component does not implement ControllerHost. This might be because you forgot to add 'manager: Controller<this> = useControllerManager(this);' in your component, or you tried to use some controller before that line"
|
|
3609
|
+
);
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3612
|
+
// src/trackPropertyKey.ts
|
|
3613
|
+
function trackPropertyKey(object, onResolved, defaultValue) {
|
|
3614
|
+
const keys = Object.keys(object);
|
|
3615
|
+
const keyCount = keys.length;
|
|
3616
|
+
if (keyTrackMap === void 0)
|
|
3617
|
+
queueMicrotask(keyTrackResolve);
|
|
3618
|
+
keyTrackMap ?? (keyTrackMap = /* @__PURE__ */ new Map());
|
|
3619
|
+
let pendingTrackers = keyTrackMap.get(object);
|
|
3620
|
+
if (pendingTrackers === void 0) {
|
|
3621
|
+
pendingTrackers = { callbacks: [], keyCount };
|
|
3622
|
+
keyTrackMap.set(object, pendingTrackers);
|
|
3623
|
+
}
|
|
3624
|
+
if (pendingTrackers.keyCount !== keyCount) {
|
|
3625
|
+
pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
|
|
3626
|
+
pendingTrackers.callbacks = [];
|
|
3627
|
+
pendingTrackers.keyCount = keyCount;
|
|
3628
|
+
}
|
|
3629
|
+
pendingTrackers.callbacks.push((keys2) => {
|
|
3630
|
+
const key = keys2[keyCount];
|
|
3631
|
+
if (key === void 0)
|
|
3632
|
+
onResolved(void 0);
|
|
3633
|
+
else if (object[key] === defaultValue)
|
|
3634
|
+
onResolved(key);
|
|
3635
|
+
else
|
|
3636
|
+
onResolved(void 0);
|
|
3637
|
+
});
|
|
3638
|
+
return defaultValue;
|
|
3639
|
+
}
|
|
3640
|
+
var keyTrackMap = void 0;
|
|
3641
|
+
function keyTrackResolve() {
|
|
3642
|
+
Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
|
|
3643
|
+
const keys = Object.keys(object);
|
|
3644
|
+
callbacks.forEach((commit) => commit(keys));
|
|
3645
|
+
});
|
|
3646
|
+
keyTrackMap = void 0;
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3649
|
+
// src/ComponentInternals.ts
|
|
3650
|
+
var ComponentInternals = class {
|
|
3651
|
+
constructor(component) {
|
|
3652
|
+
this.trackKey = (hostsCandidates, onResolved, defaultValue) => {
|
|
3653
|
+
const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
|
|
3654
|
+
let leftToResolve = candidateHosts.length + 1;
|
|
3655
|
+
const resolved = (resolution) => {
|
|
3656
|
+
leftToResolve -= 1;
|
|
3657
|
+
if (resolution !== void 0)
|
|
3658
|
+
leftToResolve = 0;
|
|
3659
|
+
if (leftToResolve === 0)
|
|
3660
|
+
onResolved(resolution);
|
|
3661
|
+
};
|
|
3662
|
+
candidateHosts.forEach(
|
|
3663
|
+
(host) => this.component.manager.trackPropertyKey(
|
|
3664
|
+
host,
|
|
3665
|
+
(key) => resolved(
|
|
3666
|
+
key === void 0 ? void 0 : {
|
|
3667
|
+
key,
|
|
3668
|
+
host,
|
|
3669
|
+
type: "property",
|
|
3670
|
+
domValue: void 0
|
|
3671
|
+
}
|
|
3672
|
+
),
|
|
3673
|
+
defaultValue
|
|
3674
|
+
)
|
|
3675
|
+
);
|
|
3676
|
+
this.component.manager.trackPropKey((key, domValue) => {
|
|
3677
|
+
const propType = key === void 0 ? void 0 : getPropType(this.component, key);
|
|
3678
|
+
resolved(
|
|
3679
|
+
key === void 0 ? void 0 : {
|
|
3680
|
+
key,
|
|
3681
|
+
host: this.component,
|
|
3682
|
+
type: propType ?? "prop",
|
|
3683
|
+
domValue: propType === "prop" ? domValue : void 0
|
|
3684
|
+
}
|
|
3685
|
+
);
|
|
3686
|
+
}, defaultValue);
|
|
3687
|
+
return defaultValue;
|
|
3688
|
+
};
|
|
3689
|
+
this.trackPropKey = (onResolved, defaultValue) => {
|
|
3690
|
+
if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
|
|
3691
|
+
this._firePropertyTrackers(void 0, void 0, void 0);
|
|
3692
|
+
if (this._keyTrackers.length === 0)
|
|
3693
|
+
queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
|
|
3694
|
+
this._trackedValue = defaultValue;
|
|
3695
|
+
this._keyTrackers.push(
|
|
3696
|
+
(key, value, previousValue) => onResolved(defaultValue === value ? key : void 0, previousValue)
|
|
3697
|
+
);
|
|
3698
|
+
return defaultValue;
|
|
3699
|
+
};
|
|
3700
|
+
this._trackedValue = nothing;
|
|
3701
|
+
this._keyTrackers = [];
|
|
3702
|
+
this.getters = {};
|
|
3703
|
+
this.setters = {};
|
|
3704
|
+
this._exports = /* @__PURE__ */ new WeakMap();
|
|
3705
|
+
Object.defineProperty(this, "component", {
|
|
3706
|
+
writable: false,
|
|
3707
|
+
enumerable: false,
|
|
3708
|
+
configurable: true,
|
|
3709
|
+
value: component
|
|
3710
|
+
});
|
|
3711
|
+
}
|
|
3712
|
+
_firePropertyTrackers(key, value, oldValue) {
|
|
3713
|
+
const trackers = this._keyTrackers;
|
|
3714
|
+
this._trackedValue = nothing;
|
|
3715
|
+
this._keyTrackers = [];
|
|
3716
|
+
trackers.forEach((tracker) => tracker(key, value, oldValue));
|
|
3717
|
+
}
|
|
3718
|
+
/**
|
|
3719
|
+
* Configure a getter or setter for a given @Prop/@State. Note, since props
|
|
3720
|
+
* are defined on the prototype, they are shared between all instances of a
|
|
3721
|
+
* component. Thus instead of passing function reference to
|
|
3722
|
+
* Object.defineProperty, we use instance-owned getters and setters array.
|
|
3723
|
+
*/
|
|
3724
|
+
getSetProxy(prototype, name, {
|
|
3725
|
+
get,
|
|
3726
|
+
set
|
|
3727
|
+
}, type) {
|
|
3728
|
+
const component = this.component;
|
|
3729
|
+
const propType = getMemberType(component, name);
|
|
3730
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
3731
|
+
const tolerateNotFound = type === "html";
|
|
3732
|
+
if (descriptor?.set === void 0 || descriptor.get === void 0)
|
|
3733
|
+
if (descriptor !== void 0 && "value" in descriptor)
|
|
3734
|
+
throw new Error(
|
|
3735
|
+
`getSet() should only be used on Stencil's @Prop and @State properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name}" in ${component.el.tagName}`
|
|
3736
|
+
);
|
|
3737
|
+
else if (tolerateNotFound)
|
|
3738
|
+
return;
|
|
3739
|
+
else
|
|
3740
|
+
throw new Error(`Unable to find "${name}" property on the ${component.el.tagName} component`);
|
|
3741
|
+
const { get: originalGet, set: originalSet } = descriptor;
|
|
3742
|
+
const isGetterAlreadyOverwritten = customAccessor in originalGet;
|
|
3743
|
+
const isSetterAlreadyOverwritten = customAccessor in originalSet;
|
|
3744
|
+
const shouldOverwriteGet = !isGetterAlreadyOverwritten && typeof get === "function";
|
|
3745
|
+
const shouldOverwriteSet = !isSetterAlreadyOverwritten && typeof set === "function";
|
|
3746
|
+
if (!shouldOverwriteGet && !shouldOverwriteSet)
|
|
3747
|
+
return;
|
|
3748
|
+
const finalGetter = shouldOverwriteGet ? function getter() {
|
|
3749
|
+
let value = originalGet.call(this);
|
|
3750
|
+
const component2 = Controller.internals.elementToInstance.get(this);
|
|
3751
|
+
const getters = component2?.manager.internals.getters[name] ?? [];
|
|
3752
|
+
for (let i = 0; i < getters.length; i++)
|
|
3753
|
+
value = getters[i](value, name);
|
|
3754
|
+
return value;
|
|
3755
|
+
} : originalGet;
|
|
3756
|
+
const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
|
|
3757
|
+
if (Controller.internals.shouldBypassSetter) {
|
|
3758
|
+
originalSet.call(this, rawNewValue);
|
|
3759
|
+
return;
|
|
3760
|
+
}
|
|
3761
|
+
const oldValue = originalGet.call(this);
|
|
3762
|
+
let newValue = parsePropertyValue(rawNewValue, propType);
|
|
3763
|
+
const component2 = Controller.internals.elementToInstance.get(this);
|
|
3764
|
+
const internals = component2?.manager.internals;
|
|
3765
|
+
if (newValue === oldValue)
|
|
3766
|
+
originalSet.call(this, rawNewValue);
|
|
3767
|
+
else {
|
|
3768
|
+
const setters = internals?.setters[name] ?? [];
|
|
3769
|
+
for (let i = 0; i < setters.length; i++)
|
|
3770
|
+
newValue = setters[i](newValue, oldValue, name);
|
|
3771
|
+
originalSet.call(this, newValue);
|
|
3772
|
+
}
|
|
3773
|
+
if ((internals?._keyTrackers.length ?? 0) > 0)
|
|
3774
|
+
internals?._firePropertyTrackers(name, rawNewValue, oldValue);
|
|
3775
|
+
} : originalSet;
|
|
3776
|
+
if (shouldOverwriteGet)
|
|
3777
|
+
Object.defineProperty(finalGetter, customAccessor, { value: true });
|
|
3778
|
+
if (shouldOverwriteSet)
|
|
3779
|
+
Object.defineProperty(finalSetter, customAccessor, { value: true });
|
|
3780
|
+
Object.defineProperty(prototype, name, {
|
|
3781
|
+
...descriptor,
|
|
3782
|
+
get: finalGetter,
|
|
3783
|
+
set: finalSetter
|
|
3784
|
+
});
|
|
3785
|
+
}
|
|
3786
|
+
/**
|
|
3787
|
+
* Associate an exports object with a controller for reverse lookup in
|
|
3788
|
+
* controller.use
|
|
3789
|
+
*/
|
|
3790
|
+
markExports(controller, exports) {
|
|
3791
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function")
|
|
3792
|
+
this._exports.set(exports, controller);
|
|
3793
|
+
}
|
|
3794
|
+
resolveExports(exports) {
|
|
3795
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function")
|
|
3796
|
+
return this._exports.get(exports);
|
|
3797
|
+
else
|
|
3798
|
+
return void 0;
|
|
3799
|
+
}
|
|
3800
|
+
};
|
|
3801
|
+
var customAccessor = Symbol("controllersCustomAccessor");
|
|
3802
|
+
var nothing = Symbol("nothing");
|
|
3803
|
+
|
|
3804
|
+
// ../core-adapter/dist/index.js
|
|
3805
|
+
var isAMD = typeof window !== "undefined" && "$arcgis" in window && typeof window.$arcgis === "object" && "import" in window.$arcgis;
|
|
3806
|
+
function isDefaultModule(module) {
|
|
3807
|
+
return module.default !== void 0;
|
|
3808
|
+
}
|
|
3809
|
+
async function importCoreAccessor() {
|
|
3810
|
+
if (isAMD) {
|
|
3811
|
+
return await window.$arcgis.import("esri/core/Accessor");
|
|
3812
|
+
}
|
|
3813
|
+
const module = await Promise.resolve().then(function () { return require('./Accessor-YDTURKZ7-064d4ec3.js'); });
|
|
3814
|
+
return isDefaultModule(module) ? module.default : module;
|
|
3815
|
+
}
|
|
3816
|
+
async function importCoreAccessorSupportDecorators() {
|
|
3817
|
+
if (isAMD) {
|
|
3818
|
+
return await window.$arcgis.import("esri/core/accessorSupport/decorators");
|
|
3819
|
+
}
|
|
3820
|
+
const module = await Promise.resolve().then(function () { return require('./decorators-443AWDOE-ab85b9eb.js'); });
|
|
3821
|
+
return isDefaultModule(module) ? module.default : module;
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
// src/accessorIntegration.ts
|
|
3825
|
+
var accessorPromise = Promise.all([importCoreAccessor(), importCoreAccessorSupportDecorators()]);
|
|
3826
|
+
async function accessorIntegration(component) {
|
|
3827
|
+
let accessor = void 0;
|
|
3828
|
+
const getSet = {
|
|
3829
|
+
get: (value, propertyName) => {
|
|
3830
|
+
const accessorValue = accessor?.[propertyName];
|
|
3831
|
+
return value ?? accessorValue;
|
|
3832
|
+
},
|
|
3833
|
+
set: (newValue, oldValue, propertyName) => {
|
|
3834
|
+
if (accessor !== void 0)
|
|
3835
|
+
accessor[propertyName] = newValue;
|
|
3836
|
+
return newValue;
|
|
3837
|
+
}
|
|
3838
|
+
};
|
|
3839
|
+
const members = getPropLikeMembers(component);
|
|
3840
|
+
members.forEach((member) => component.manager.genericGetSet(member, getSet));
|
|
3841
|
+
const [Accessor, { subclass, property }] = await accessorPromise;
|
|
3842
|
+
return () => {
|
|
3843
|
+
class AccessorSubclass extends Accessor {
|
|
3844
|
+
}
|
|
3845
|
+
members.forEach(
|
|
3846
|
+
(name) => property({
|
|
3847
|
+
value: component[name]
|
|
3848
|
+
})(AccessorSubclass.prototype, name)
|
|
3849
|
+
);
|
|
3850
|
+
const Subclass = subclass(component.el.tagName)(AccessorSubclass);
|
|
3851
|
+
accessor = new Subclass();
|
|
3852
|
+
};
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
// src/ControllerManager.ts
|
|
3856
|
+
var useControllerManager = (component) => new ControllerManager(component);
|
|
3857
|
+
var ControllerManager = class extends GenericController {
|
|
3858
|
+
constructor(component) {
|
|
3859
|
+
const controllers = /* @__PURE__ */ new Set();
|
|
3860
|
+
const watchers = {};
|
|
3861
|
+
const controllerHost = {
|
|
3862
|
+
addController: (controller) => {
|
|
3863
|
+
controllers.add(controller);
|
|
3864
|
+
},
|
|
3865
|
+
[watcherCallbackName]: (newValue, oldValue, propertyName) => {
|
|
3866
|
+
watchers[propertyName]?.forEach((callback) => callback(newValue, oldValue, propertyName));
|
|
3867
|
+
},
|
|
3868
|
+
removeController: (controller) => {
|
|
3869
|
+
controllers.delete(controller);
|
|
3870
|
+
},
|
|
3871
|
+
requestUpdate: () => index.forceUpdate(component)
|
|
3872
|
+
};
|
|
3873
|
+
extendObject(component, controllerHost);
|
|
3874
|
+
super(component);
|
|
3875
|
+
this._connected = new h();
|
|
3876
|
+
this.internals = new ComponentInternals(this.component);
|
|
3877
|
+
this.connected = this._connected.promise;
|
|
3878
|
+
this.hasDestroy = false;
|
|
3879
|
+
this.destroyed = false;
|
|
3880
|
+
this._updatePromise = new h();
|
|
3881
|
+
this._originalLifecycles = {};
|
|
3882
|
+
/**
|
|
3883
|
+
* A magical solution to finding out what property name a given controller
|
|
3884
|
+
* on a given object was assigned to. Note, this does not work for properties
|
|
3885
|
+
* that have \@Prop() or \@State() decorator - for those, use
|
|
3886
|
+
* manager.trackPropKey() instead.
|
|
3887
|
+
*
|
|
3888
|
+
* @example
|
|
3889
|
+
* function trackMe<T>(defaultValue:T, component:BaseComponent):T {
|
|
3890
|
+
* component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
|
|
3891
|
+
* return defaultValue;
|
|
3892
|
+
* }
|
|
3893
|
+
*
|
|
3894
|
+
* class MyComponent extends BaseComponent {
|
|
3895
|
+
* // Will console log "myProp"
|
|
3896
|
+
* myProp = trackMe('a', this);
|
|
3897
|
+
* }
|
|
3898
|
+
*
|
|
3899
|
+
*/
|
|
3900
|
+
this.trackPropertyKey = trackPropertyKey;
|
|
3901
|
+
/**
|
|
3902
|
+
* Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
|
|
3903
|
+
* decorator
|
|
3904
|
+
*
|
|
3905
|
+
* @example
|
|
3906
|
+
* function trackMe(component:BaseComponent) {
|
|
3907
|
+
* component.manager.trackPropKey((key)=>console.log(key));
|
|
3908
|
+
* }
|
|
3909
|
+
*
|
|
3910
|
+
* class MyComponent extends BaseComponent {
|
|
3911
|
+
* // Will console log "myProp"
|
|
3912
|
+
* @Prop() myProp = trackMe(this);
|
|
3913
|
+
*
|
|
3914
|
+
* // Will console log "myState"
|
|
3915
|
+
* @State() myState = trackMe(this);
|
|
3916
|
+
* }
|
|
3917
|
+
*/
|
|
3918
|
+
this.trackPropKey = this.internals.trackPropKey;
|
|
3919
|
+
/**
|
|
3920
|
+
* A combination of trackPropertyKey() and trackPropKey(). For usage when
|
|
3921
|
+
* you want to track a property, but don't know if it will be defined with the
|
|
3922
|
+
* \@Prop() decorator or not
|
|
3923
|
+
*/
|
|
3924
|
+
this.trackKey = this.internals.trackKey;
|
|
3925
|
+
this.component.manager = this;
|
|
3926
|
+
retrieveComponentMeta(component);
|
|
3927
|
+
this._controllers = controllers;
|
|
3928
|
+
this.internals.watchers = watchers;
|
|
3929
|
+
this.exports = void 0;
|
|
3930
|
+
this.hasDestroy = "preserveOnDisconnect" in this.component && typeof this.component.destroy === "function";
|
|
3931
|
+
if (this.hasDestroy)
|
|
3932
|
+
this.watch("preserveOnDisconnect", () => this._preserveOnDisconnectWatcher());
|
|
3933
|
+
this._bindLifecycleMethods();
|
|
3934
|
+
Object.defineProperty(component, "updateComplete", {
|
|
3935
|
+
get: async () => await this._updatePromise.promise
|
|
3936
|
+
});
|
|
3937
|
+
this.component.addController(this);
|
|
3938
|
+
this._accessorIntegrationReady = accessorIntegration(this.component);
|
|
3939
|
+
Controller.internals.setParentController(void 0);
|
|
3940
|
+
Controller.internals.setAmbientComponent(component);
|
|
3941
|
+
Controller.internals.elementToInstance.set(component.el, component);
|
|
3942
|
+
Controller.internals.elementToInstance.set(component, component);
|
|
3943
|
+
}
|
|
3944
|
+
_bindLifecycleMethods() {
|
|
3945
|
+
const component = this.component;
|
|
3946
|
+
this._originalLifecycles = {
|
|
3947
|
+
connectedCallback: component.connectedCallback,
|
|
3948
|
+
disconnectedCallback: component.disconnectedCallback,
|
|
3949
|
+
componentWillLoad: component.componentWillLoad,
|
|
3950
|
+
componentDidLoad: component.componentDidLoad,
|
|
3951
|
+
componentWillRender: component.componentWillRender,
|
|
3952
|
+
componentDidRender: component.componentDidRender,
|
|
3953
|
+
componentWillUpdate: component.componentWillUpdate,
|
|
3954
|
+
componentDidUpdate: component.componentDidUpdate,
|
|
3955
|
+
destroy: component.destroy
|
|
3956
|
+
};
|
|
3957
|
+
component.connectedCallback = this._connectedCallback.bind(this);
|
|
3958
|
+
component.disconnectedCallback = this._disconnectedCallback.bind(this);
|
|
3959
|
+
component.componentWillLoad = this._componentWillLoad.bind(this);
|
|
3960
|
+
component.componentDidLoad = this._componentDidLoad.bind(this);
|
|
3961
|
+
component.componentWillRender = this._componentWillRender.bind(this);
|
|
3962
|
+
component.componentDidRender = this._componentDidRender.bind(this);
|
|
3963
|
+
component.componentWillUpdate = this._componentWillUpdate.bind(this);
|
|
3964
|
+
component.componentDidUpdate = this._componentDidUpdate.bind(this);
|
|
3965
|
+
if (this.hasDestroy)
|
|
3966
|
+
component.destroy = this.destroy.bind(this);
|
|
3967
|
+
}
|
|
3968
|
+
/**
|
|
3969
|
+
* Throws an error if component does not implement destroy() lifecycle, but
|
|
3970
|
+
* tries to use it.
|
|
3971
|
+
*/
|
|
3972
|
+
ensureHasDestroy() {
|
|
3973
|
+
if (!this.hasDestroy)
|
|
3974
|
+
throw new Error(destroyErrorMessage);
|
|
3975
|
+
}
|
|
3976
|
+
/**
|
|
3977
|
+
* Private because this is not supposed to be called by Component directly.
|
|
3978
|
+
* Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
|
|
3979
|
+
* calling lifecycle methods twice.
|
|
3980
|
+
*/
|
|
3981
|
+
_connectedCallback() {
|
|
3982
|
+
if (this.destroyed) {
|
|
3983
|
+
const tagName = this.component.el.tagName.toLowerCase();
|
|
3984
|
+
this.component.el.remove();
|
|
3985
|
+
throw new Error(
|
|
3986
|
+
`The ${tagName} component has already been destroyed. It can not be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the preserveOnDisconnect prop.`
|
|
3987
|
+
);
|
|
3988
|
+
}
|
|
3989
|
+
keyTrackResolve();
|
|
3990
|
+
this._connected.resolve();
|
|
3991
|
+
this._controllers.forEach(
|
|
3992
|
+
(controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(() => controller.hostConnected?.())
|
|
3993
|
+
);
|
|
3994
|
+
this._originalLifecycles.connectedCallback?.call(this.component);
|
|
3995
|
+
}
|
|
3996
|
+
_disconnectedCallback() {
|
|
3997
|
+
if (this.destroyed)
|
|
3998
|
+
return;
|
|
3999
|
+
this._controllers.forEach(
|
|
4000
|
+
(controller) => "triggerDisconnected" in controller ? controller.triggerDisconnected() : safeCall(() => controller.hostDisconnected?.())
|
|
4001
|
+
);
|
|
4002
|
+
this._originalLifecycles.disconnectedCallback?.call(this.component);
|
|
4003
|
+
if (this.hasDestroy)
|
|
4004
|
+
this._preserveOnDisconnectWatcher();
|
|
4005
|
+
}
|
|
4006
|
+
async _componentWillLoad() {
|
|
4007
|
+
const enableIntegration = await this._accessorIntegrationReady;
|
|
4008
|
+
enableIntegration();
|
|
4009
|
+
await Promise.allSettled(
|
|
4010
|
+
Array.from(
|
|
4011
|
+
this._controllers,
|
|
4012
|
+
async (controller) => "triggerLoad" in controller ? await controller.triggerLoad() : await safeAsyncCall(async () => await controller.hostLoad?.())
|
|
4013
|
+
)
|
|
4014
|
+
);
|
|
4015
|
+
await this._originalLifecycles.componentWillLoad?.call(this.component);
|
|
4016
|
+
}
|
|
4017
|
+
_componentDidLoad() {
|
|
4018
|
+
this._controllers.forEach(
|
|
4019
|
+
(controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(() => controller.hostLoaded?.())
|
|
4020
|
+
);
|
|
4021
|
+
this._originalLifecycles.componentDidLoad?.call(this.component);
|
|
4022
|
+
}
|
|
4023
|
+
async _componentWillRender() {
|
|
4024
|
+
await Promise.allSettled(
|
|
4025
|
+
Array.from(
|
|
4026
|
+
this._controllers,
|
|
4027
|
+
async (controller) => "triggerRender" in controller ? await controller.triggerRender() : await safeAsyncCall(async () => await controller.hostRender?.())
|
|
4028
|
+
)
|
|
4029
|
+
);
|
|
4030
|
+
await this._originalLifecycles.componentWillRender?.call(this.component);
|
|
4031
|
+
}
|
|
4032
|
+
_componentDidRender() {
|
|
4033
|
+
this._controllers.forEach(
|
|
4034
|
+
(controller) => "triggerRendered" in controller ? controller.triggerRendered() : safeCall(() => controller.hostRendered?.())
|
|
4035
|
+
);
|
|
4036
|
+
this._originalLifecycles.componentDidRender?.call(this.component);
|
|
4037
|
+
}
|
|
4038
|
+
async _componentWillUpdate() {
|
|
4039
|
+
await Promise.allSettled(
|
|
4040
|
+
Array.from(
|
|
4041
|
+
this._controllers,
|
|
4042
|
+
async (controller) => "triggerUpdate" in controller ? await controller.triggerUpdate() : await safeAsyncCall(async () => await controller.hostUpdate?.())
|
|
4043
|
+
)
|
|
4044
|
+
);
|
|
4045
|
+
await this._originalLifecycles.componentWillUpdate?.call(this.component);
|
|
4046
|
+
}
|
|
4047
|
+
_componentDidUpdate() {
|
|
4048
|
+
this._controllers.forEach(
|
|
4049
|
+
(controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(() => controller.hostUpdated?.())
|
|
4050
|
+
);
|
|
4051
|
+
this._originalLifecycles.componentDidUpdate?.call(this.component);
|
|
4052
|
+
const updatePromise = this._updatePromise;
|
|
4053
|
+
this._updatePromise = new h();
|
|
4054
|
+
updatePromise.resolve(true);
|
|
4055
|
+
}
|
|
4056
|
+
async destroy() {
|
|
4057
|
+
this.ensureHasDestroy();
|
|
4058
|
+
if (this.destroyed)
|
|
4059
|
+
return;
|
|
4060
|
+
if (this.component.el.isConnected) {
|
|
4061
|
+
this.hasDestroy = false;
|
|
4062
|
+
this.component.el.remove();
|
|
4063
|
+
this.hasDestroy = true;
|
|
4064
|
+
}
|
|
4065
|
+
this.destroyed = true;
|
|
4066
|
+
this._controllers.forEach(
|
|
4067
|
+
(controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(() => controller.hostDestroy?.())
|
|
4068
|
+
);
|
|
4069
|
+
await this._originalLifecycles.destroy?.call(this.component);
|
|
4070
|
+
}
|
|
4071
|
+
_preserveOnDisconnectWatcher() {
|
|
4072
|
+
if (!this.component.el.isConnected && !this.component.preserveOnDisconnect)
|
|
4073
|
+
void this.destroy().catch(console.error);
|
|
4074
|
+
}
|
|
4075
|
+
readonly(value) {
|
|
4076
|
+
return this.getSet(value, {
|
|
4077
|
+
set: (newValue, _oldValue, property) => {
|
|
4078
|
+
throw new Error(
|
|
4079
|
+
`Cannot assign to read-only property "${property}" of ${this.component.el.tagName.toLowerCase()}. Trying to assign "${String(
|
|
4080
|
+
newValue
|
|
4081
|
+
)}"`
|
|
4082
|
+
);
|
|
4083
|
+
}
|
|
4084
|
+
});
|
|
4085
|
+
}
|
|
4086
|
+
/**
|
|
4087
|
+
* Listen for any component's @State()/@Prop() change, and mutate it's
|
|
4088
|
+
* value before it is set.
|
|
4089
|
+
* This is necessary because Stencil's Compiler does not support get/set for
|
|
4090
|
+
* @State()/@Prop().
|
|
4091
|
+
* For private component properties, you should use regular get/set syntax.
|
|
4092
|
+
*
|
|
4093
|
+
* @example
|
|
4094
|
+
* @Prop() exampleProp = this.manager.getSet(defaultValue,{get,set})
|
|
4095
|
+
* @Prop() someProp = this.manager.getSet(
|
|
4096
|
+
* undefined as string | undefined,
|
|
4097
|
+
* {
|
|
4098
|
+
* get: (value)=>value.trim(),
|
|
4099
|
+
* set: (newValue,oldValue) => newValue.trim() ?? oldValue
|
|
4100
|
+
* }
|
|
4101
|
+
* )
|
|
4102
|
+
*
|
|
4103
|
+
* @remarks
|
|
4104
|
+
* Unlike a native get/set, the get function receives the current attribute
|
|
4105
|
+
* value, and can modify it before returning it (or can disregard the current
|
|
4106
|
+
* value and get it from elsewhere instead).
|
|
4107
|
+
* Similarly, setter is called with the new and old value, and is expected to
|
|
4108
|
+
* return the final new value (or return the old value to undo the change)
|
|
4109
|
+
*/
|
|
4110
|
+
getSet(defaultValue, getSet) {
|
|
4111
|
+
return this.component.manager.trackPropKey((name) => {
|
|
4112
|
+
if (name === void 0)
|
|
4113
|
+
throw new Error(
|
|
4114
|
+
"Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
|
|
4115
|
+
);
|
|
4116
|
+
const genericComponent = this.component;
|
|
4117
|
+
const value = genericComponent[name];
|
|
4118
|
+
if (value != null && value !== defaultValue && typeof getSet.set === "function" && getSet.initialSet !== false) {
|
|
4119
|
+
const newValue = getSet.set(value, defaultValue, name);
|
|
4120
|
+
if (newValue !== value)
|
|
4121
|
+
genericComponent[name] = newValue;
|
|
4122
|
+
}
|
|
4123
|
+
this.genericGetSet(name, getSet);
|
|
4124
|
+
}, defaultValue);
|
|
4125
|
+
}
|
|
4126
|
+
};
|
|
4127
|
+
var destroyErrorMessage = `
|
|
4128
|
+
If the component uses a controller that uses destroy() method, then the
|
|
4129
|
+
component must have the following properties:
|
|
4130
|
+
${// Don't expose internal code in production, and keep bundle smaller:
|
|
4131
|
+
`preserveOnDisconnect and destroy` }
|
|
4132
|
+
`.trim();
|
|
4133
|
+
|
|
4134
|
+
// src/proxyExports.ts
|
|
4135
|
+
var proxyExports = (Class) => (...args) => {
|
|
4136
|
+
const ambientControllers = Controller.internals.retriveParentControllers();
|
|
4137
|
+
const instance = new Class(...args);
|
|
4138
|
+
const initialExports = instance.exports;
|
|
4139
|
+
Controller.internals.setParentController(ambientControllers.at(-1));
|
|
4140
|
+
const internals = instance.component.manager.internals;
|
|
4141
|
+
internals.markExports(instance, initialExports);
|
|
4142
|
+
instance.watchExports((exports) => internals.markExports(instance, exports));
|
|
4143
|
+
Controller.internals.setAmbientChildController(instance);
|
|
4144
|
+
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
4145
|
+
return internals.trackKey(
|
|
4146
|
+
hostCandidates,
|
|
4147
|
+
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
|
|
4148
|
+
initialExports
|
|
4149
|
+
);
|
|
4150
|
+
};
|
|
4151
|
+
function setProxy(controller, host, key, initialExports) {
|
|
4152
|
+
const genericHost = host;
|
|
4153
|
+
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
4154
|
+
const hostValueChanged = genericHost[key] !== initialExports;
|
|
4155
|
+
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
4156
|
+
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
|
|
4157
|
+
genericHost[key] = controller.exports;
|
|
4158
|
+
controller.watchExports(() => {
|
|
4159
|
+
if (genericHost[key] !== controller.exports)
|
|
4160
|
+
genericHost[key] = controller.exports;
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
// src/functional.ts
|
|
4165
|
+
var makeController = (constructor) => proxy(void 0, constructor);
|
|
4166
|
+
var FunctionalController = class extends Controller {
|
|
4167
|
+
constructor(component, constructor) {
|
|
4168
|
+
super(component);
|
|
4169
|
+
const originalExports = this.exports;
|
|
4170
|
+
try {
|
|
4171
|
+
Controller.internals.setAmbientComponent(this.component);
|
|
4172
|
+
const value = constructor(this.component, this);
|
|
4173
|
+
const constructorChangedExports = this.exports !== originalExports;
|
|
4174
|
+
if (value instanceof Promise) {
|
|
4175
|
+
if (!constructorChangedExports)
|
|
4176
|
+
this.setProvisionalExports(value);
|
|
4177
|
+
const resolved = value.then((result) => {
|
|
4178
|
+
this.exports = result;
|
|
4179
|
+
super.catchUpLifecycle();
|
|
4180
|
+
}).catch((error) => {
|
|
4181
|
+
this._ready.reject(error);
|
|
4182
|
+
console.error(error);
|
|
4183
|
+
});
|
|
4184
|
+
this.onLoad(async () => await resolved);
|
|
4185
|
+
} else {
|
|
4186
|
+
if (!constructorChangedExports || value !== void 0)
|
|
4187
|
+
this.exports = value;
|
|
4188
|
+
super.catchUpLifecycle();
|
|
4189
|
+
}
|
|
4190
|
+
} catch (error) {
|
|
4191
|
+
this._ready.reject(error);
|
|
4192
|
+
console.error(error);
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
/** Noop - will be called in the constructor instead */
|
|
4196
|
+
catchUpLifecycle() {
|
|
4197
|
+
return;
|
|
4198
|
+
}
|
|
4199
|
+
};
|
|
4200
|
+
var proxy = proxyExports(FunctionalController);
|
|
4201
|
+
function useT9n({
|
|
4202
|
+
blocking = false,
|
|
4203
|
+
name
|
|
4204
|
+
} = {}) {
|
|
4205
|
+
return makeController((component, controller) => {
|
|
4206
|
+
controller.onLifecycle(
|
|
4207
|
+
() => Y(
|
|
4208
|
+
component.el,
|
|
4209
|
+
index.getAssetPath("./assets"),
|
|
4210
|
+
({ t9nLocale, t9nStrings, lang }) => {
|
|
4211
|
+
controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
|
|
4212
|
+
if (typeof t9nStrings.widgetLabel === "string" && "label" in component)
|
|
4213
|
+
component.label ?? (component.label = t9nStrings.widgetLabel);
|
|
4214
|
+
},
|
|
4215
|
+
name
|
|
4216
|
+
)
|
|
4217
|
+
);
|
|
4218
|
+
if (blocking)
|
|
4219
|
+
return controller.ready;
|
|
4220
|
+
const locale = M(component.el);
|
|
4221
|
+
return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
|
|
4222
|
+
});
|
|
4223
|
+
}
|
|
4224
|
+
|
|
2944
4225
|
function isMonacoEnvironmentSetup() {
|
|
2945
4226
|
return !!window.MonacoEnvironment?.getWorkerUrl;
|
|
2946
4227
|
}
|
|
@@ -2981,7 +4262,7 @@ function setupMonacoEnvironment(assetsPath) {
|
|
|
2981
4262
|
break;
|
|
2982
4263
|
}
|
|
2983
4264
|
// If we have a relative path or we are on same orgin, we can use the default js implementation
|
|
2984
|
-
if (!arcadeDefaults.
|
|
4265
|
+
if (!arcadeDefaults.de(url) || arcadeDefaults.ge(url, globalThis.location.href, true)) {
|
|
2985
4266
|
return new Worker(url, { name: languageId });
|
|
2986
4267
|
}
|
|
2987
4268
|
// For cross orgin, we will load the worker code as a string and manufacture a blob
|
|
@@ -3088,7 +4369,7 @@ async function getArcadeWorker(uri) {
|
|
|
3088
4369
|
* @returns arcade mode module
|
|
3089
4370
|
*/
|
|
3090
4371
|
async function getMode() {
|
|
3091
|
-
return await Promise.resolve().then(function () { return require('./arcade-mode-
|
|
4372
|
+
return await Promise.resolve().then(function () { return require('./arcade-mode-bf406304.js'); });
|
|
3092
4373
|
}
|
|
3093
4374
|
// Register the language in Monaco
|
|
3094
4375
|
arcadeDefaults.languages.register({
|
|
@@ -3118,6 +4399,8 @@ const ArcgisArcadeApi = class {
|
|
|
3118
4399
|
index.registerInstance(this, hostRef);
|
|
3119
4400
|
this.close = index.createEvent(this, "close", 3);
|
|
3120
4401
|
this.itemSelected = index.createEvent(this, "itemSelected", 3);
|
|
4402
|
+
this.manager = useControllerManager(this);
|
|
4403
|
+
this.messages = useT9n();
|
|
3121
4404
|
this._emitItemSelected = (e) => {
|
|
3122
4405
|
const item = e.target?.["data-item"];
|
|
3123
4406
|
if (!item) {
|
|
@@ -3157,9 +4440,6 @@ const ArcgisArcadeApi = class {
|
|
|
3157
4440
|
this._updateFilterValue = (e) => {
|
|
3158
4441
|
this._filterValue = e.target?.value ?? "";
|
|
3159
4442
|
};
|
|
3160
|
-
this._lang = "";
|
|
3161
|
-
this._t9nLocale = "";
|
|
3162
|
-
this._t9nStrings = undefined;
|
|
3163
4443
|
this._selectedApiItem = undefined;
|
|
3164
4444
|
this._filterValue = "";
|
|
3165
4445
|
this._colorizeStyle = "";
|
|
@@ -3173,7 +4453,6 @@ const ArcgisArcadeApi = class {
|
|
|
3173
4453
|
async componentWillLoad() {
|
|
3174
4454
|
this._colorizeStyle = generateColorizeStyles();
|
|
3175
4455
|
this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
|
|
3176
|
-
await arcadeDefaults.B(this, index.getAssetPath("./assets"));
|
|
3177
4456
|
arcadeDefaults.arcadeDefaults.onModelContextDidChange((key) => {
|
|
3178
4457
|
if (!this.modelId || key !== arcadeDefaults.Uri.parse(this.modelId).toString()) {
|
|
3179
4458
|
return;
|
|
@@ -3183,7 +4462,6 @@ const ArcgisArcadeApi = class {
|
|
|
3183
4462
|
await this._updateApiLibrary();
|
|
3184
4463
|
}
|
|
3185
4464
|
disconnectedCallback() {
|
|
3186
|
-
arcadeDefaults.q(this);
|
|
3187
4465
|
this._flowObserver?.disconnect();
|
|
3188
4466
|
this._themeChangedListner?.dispose();
|
|
3189
4467
|
}
|
|
@@ -3239,14 +4517,14 @@ const ArcgisArcadeApi = class {
|
|
|
3239
4517
|
if (!filteredApiItems.length) {
|
|
3240
4518
|
return null;
|
|
3241
4519
|
}
|
|
3242
|
-
return (index.h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (index.h("calcite-list-item", { label: arcadeDefaults.
|
|
4520
|
+
return (index.h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (index.h("calcite-list-item", { label: arcadeDefaults.oe(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, index.h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
|
|
3243
4521
|
}
|
|
3244
4522
|
renderApiItemFlowItem() {
|
|
3245
4523
|
const apiItem = this._selectedApiItem;
|
|
3246
4524
|
if (!apiItem) {
|
|
3247
4525
|
return null;
|
|
3248
4526
|
}
|
|
3249
|
-
return (index.h("calcite-flow-item", { heading: this.
|
|
4527
|
+
return (index.h("calcite-flow-item", { heading: this.messages.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (index.h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", scale: "s", href: apiItem.link, target: "Arcade Help", "icon-start": "information" }, this.messages.moreinformation)), index.h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelectedAndClose, "data-item": apiItem, ref: (e) => void e?.setFocus() }, this.messages.insert ?? "Insert"), index.h("calcite-block", { open: true, heading: arcadeDefaults.oe(apiItem.completion.detail) }, index.h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (index.h("div", { ref: (e) => {
|
|
3250
4528
|
if (!e) {
|
|
3251
4529
|
return;
|
|
3252
4530
|
}
|
|
@@ -3257,10 +4535,10 @@ const ArcgisArcadeApi = class {
|
|
|
3257
4535
|
render() {
|
|
3258
4536
|
const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
|
|
3259
4537
|
const empty = categories.every((g) => !g);
|
|
3260
|
-
return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this.
|
|
4538
|
+
return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this.messages.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), this._preparingApi ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (index.h("calcite-list", null, empty ? index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
|
|
3261
4539
|
}
|
|
3262
4540
|
static get assetsDirs() { return ["assets"]; }
|
|
3263
|
-
get
|
|
4541
|
+
get el() { return index.getElement(this); }
|
|
3264
4542
|
};
|
|
3265
4543
|
ArcgisArcadeApi.style = arcadeApiCss;
|
|
3266
4544
|
|
|
@@ -3493,8 +4771,9 @@ const ArcgisArcadeEditor = class {
|
|
|
3493
4771
|
index.registerInstance(this, hostRef);
|
|
3494
4772
|
this.scriptChange = index.createEvent(this, "scriptChange", 3);
|
|
3495
4773
|
this.diagnosticsChange = index.createEvent(this, "diagnosticsChange", 3);
|
|
4774
|
+
this.manager = useControllerManager(this);
|
|
3496
4775
|
this._componentReadyDefer = new arcadeDefaults.h();
|
|
3497
|
-
this._modelId = arcadeDefaults.
|
|
4776
|
+
this._modelId = arcadeDefaults.Q();
|
|
3498
4777
|
this._editorProfilePromise = Promise.resolve(undefined);
|
|
3499
4778
|
this._disposables = [];
|
|
3500
4779
|
this._executeScript = async () => {
|
|
@@ -3543,9 +4822,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3543
4822
|
this._insertAsText = (e) => void this._codeEditorElt?.insertText(e.detail).catch(console.error);
|
|
3544
4823
|
this._onResultPanelChange = (e) => void (this._resultPanel = e.detail);
|
|
3545
4824
|
this._onExecutionPanelClose = () => void (this._showExecutionPanel = false);
|
|
3546
|
-
this.
|
|
3547
|
-
this._t9nLocale = "";
|
|
3548
|
-
this._t9nStrings = undefined;
|
|
4825
|
+
this.messages = useT9n();
|
|
3549
4826
|
this._standaloneCodeEditor = undefined;
|
|
3550
4827
|
this._preparingProfile = false;
|
|
3551
4828
|
this._editorProfile = undefined;
|
|
@@ -3625,11 +4902,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3625
4902
|
* @internal
|
|
3626
4903
|
*/
|
|
3627
4904
|
async updateThemeColors(colorRules) {
|
|
3628
|
-
const theme = arcadeDefaults.
|
|
4905
|
+
const theme = arcadeDefaults._(this.el);
|
|
3629
4906
|
updateThemeColors(theme, colorRules);
|
|
3630
4907
|
if (colorRules === undefined) {
|
|
3631
4908
|
colorRulesKeys.forEach((key) => {
|
|
3632
|
-
this.
|
|
4909
|
+
this.el.style.removeProperty(`--arcgis-arcade-editor-${key}`);
|
|
3633
4910
|
});
|
|
3634
4911
|
return;
|
|
3635
4912
|
}
|
|
@@ -3638,7 +4915,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3638
4915
|
if (!foreground) {
|
|
3639
4916
|
return;
|
|
3640
4917
|
}
|
|
3641
|
-
this.
|
|
4918
|
+
this.el.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
|
|
3642
4919
|
});
|
|
3643
4920
|
}
|
|
3644
4921
|
// #endregion
|
|
@@ -3650,10 +4927,9 @@ const ArcgisArcadeEditor = class {
|
|
|
3650
4927
|
// However, we need to setup the environment before the code editor is instantiated because
|
|
3651
4928
|
// we need to access the arcade language service to get the api library.
|
|
3652
4929
|
setupMonacoEnvironment(assetsPath);
|
|
3653
|
-
|
|
3654
|
-
//
|
|
3655
|
-
|
|
3656
|
-
await arcadeDefaults.B(this, assetsPath, async () => await this._updateEditorProfile());
|
|
4930
|
+
await this._updateEditorProfile();
|
|
4931
|
+
// The profile has to be refreshed on locale change
|
|
4932
|
+
this.manager.watch("messages", () => void this._updateEditorProfile().catch(console.error));
|
|
3657
4933
|
}
|
|
3658
4934
|
async componentDidLoad() {
|
|
3659
4935
|
// Mark on component as ready.
|
|
@@ -3681,7 +4957,6 @@ const ArcgisArcadeEditor = class {
|
|
|
3681
4957
|
await this._codeEditorElt?.setFocus();
|
|
3682
4958
|
}
|
|
3683
4959
|
disconnectedCallback() {
|
|
3684
|
-
arcadeDefaults.q(this);
|
|
3685
4960
|
arcadeDefaults.arcadeDefaults.disposeApiContextForModel(this._modelId);
|
|
3686
4961
|
arcadeDefaults.arcadeDefaults.disposeEditorProfileForModel(this._modelId);
|
|
3687
4962
|
while (this._disposables.length) {
|
|
@@ -3698,7 +4973,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3698
4973
|
try {
|
|
3699
4974
|
// Set a new profile for the model using the profile definition and the locale.
|
|
3700
4975
|
await arcadeDefaults.arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
|
|
3701
|
-
locale: this._t9nLocale,
|
|
4976
|
+
locale: this.messages._t9nLocale,
|
|
3702
4977
|
snippets: this.snippets
|
|
3703
4978
|
});
|
|
3704
4979
|
// Get the corresponding editor profile for the model.
|
|
@@ -3719,7 +4994,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3719
4994
|
if (!this.testData) {
|
|
3720
4995
|
return null;
|
|
3721
4996
|
}
|
|
3722
|
-
return (index.h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.h("calcite-action", { text: this.
|
|
4997
|
+
return (index.h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.h("calcite-action", { text: this.messages.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (index.h("calcite-action", { text: this.messages.lastresults ?? "Last results", active: this._showExecutionPanel, "text-enabled": true, icon: "access-string-results", iconFlipRtl: true, scale: "s", onClick: this._toggleShowExecutionPanel })) : null)));
|
|
3723
4998
|
}
|
|
3724
4999
|
//#endregion
|
|
3725
5000
|
//#region Render Main Panel
|
|
@@ -3737,20 +5012,20 @@ const ArcgisArcadeEditor = class {
|
|
|
3737
5012
|
}
|
|
3738
5013
|
return (index.h("calcite-action-bar", { class: "side-action-bar border-inline-start", expanded: !!this.sideActionBarExpanded, position: "end", onCalciteActionBarToggle: this._toggleSideActionBarExpanded }, index.h("calcite-action-group", null, this.renderAction({
|
|
3739
5014
|
id: "profile-variables-action",
|
|
3740
|
-
label: this.
|
|
5015
|
+
label: this.messages.profilevariables ?? "Profile variables",
|
|
3741
5016
|
icon: "profile-variables",
|
|
3742
5017
|
active: this.openedSidePanel === "variables",
|
|
3743
5018
|
panelName: "variables"
|
|
3744
5019
|
}), this.renderAction({
|
|
3745
5020
|
id: "function-action",
|
|
3746
|
-
label: this.
|
|
5021
|
+
label: this.messages.constantsandfunctions ?? "Constants and functions",
|
|
3747
5022
|
icon: "function",
|
|
3748
5023
|
active: this.openedSidePanel === "api",
|
|
3749
5024
|
panelName: "api"
|
|
3750
5025
|
}), this.suggestions?.length
|
|
3751
5026
|
? this.renderAction({
|
|
3752
5027
|
id: "suggestions-action",
|
|
3753
|
-
label: this.
|
|
5028
|
+
label: this.messages.suggestions ?? "Suggestions",
|
|
3754
5029
|
icon: "lightbulb",
|
|
3755
5030
|
active: this.openedSidePanel === "suggestions",
|
|
3756
5031
|
panelName: "suggestions"
|
|
@@ -3759,7 +5034,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3759
5034
|
? null
|
|
3760
5035
|
: this.renderAction({
|
|
3761
5036
|
id: "developer-website-action",
|
|
3762
|
-
label: this.
|
|
5037
|
+
label: this.messages.help ?? "Help",
|
|
3763
5038
|
icon: "question",
|
|
3764
5039
|
active: false,
|
|
3765
5040
|
panelName: "none",
|
|
@@ -3797,7 +5072,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3797
5072
|
return (index.h(index.Host, null, this.renderMainActionBar(), index.h("div", { class: "flex-row flex-adjustable" }, index.h("div", { class: "flex-column flex-adjustable" }, this.renderMainPanel(), this.renderResultsPanel()), this.renderSidePanel(), this.renderSideActionBar())));
|
|
3798
5073
|
}
|
|
3799
5074
|
static get assetsDirs() { return ["assets"]; }
|
|
3800
|
-
get
|
|
5075
|
+
get el() { return index.getElement(this); }
|
|
3801
5076
|
static get watchers() { return {
|
|
3802
5077
|
"profile": ["_profileChanged"],
|
|
3803
5078
|
"testData": ["_testDataChanged"],
|
|
@@ -3838,7 +5113,7 @@ function renderSimpleValue(arcadeResult) {
|
|
|
3838
5113
|
case "null":
|
|
3839
5114
|
return index.h("span", { class: "constant-value" }, arcadeResult.type);
|
|
3840
5115
|
case "text":
|
|
3841
|
-
return index.h("span", { class: "string-value" }, arcadeDefaults.
|
|
5116
|
+
return index.h("span", { class: "string-value" }, arcadeDefaults.te(arcadeResult.value));
|
|
3842
5117
|
case "number":
|
|
3843
5118
|
return index.h("span", { class: "number-value" }, arcadeResult.value.toString());
|
|
3844
5119
|
case "boolean":
|
|
@@ -3846,9 +5121,9 @@ function renderSimpleValue(arcadeResult) {
|
|
|
3846
5121
|
case "date":
|
|
3847
5122
|
return index.h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
|
|
3848
5123
|
case "dateOnly":
|
|
3849
|
-
return index.h("span", { class: "string-value" }, arcadeDefaults.
|
|
5124
|
+
return index.h("span", { class: "string-value" }, arcadeDefaults.te(formatArcadeResultDateOnly(arcadeResult)));
|
|
3850
5125
|
case "time":
|
|
3851
|
-
return index.h("span", { class: "string-value" }, arcadeDefaults.
|
|
5126
|
+
return index.h("span", { class: "string-value" }, arcadeDefaults.te(formatArcadeResultTimeOnly(arcadeResult)));
|
|
3852
5127
|
default:
|
|
3853
5128
|
return null;
|
|
3854
5129
|
}
|
|
@@ -3870,6 +5145,9 @@ const ArcgisArcadeResults = class {
|
|
|
3870
5145
|
index.registerInstance(this, hostRef);
|
|
3871
5146
|
this.openedResultPanelChange = index.createEvent(this, "openedResultPanelChange", 3);
|
|
3872
5147
|
this.close = index.createEvent(this, "close", 3);
|
|
5148
|
+
this.manager = useControllerManager(this);
|
|
5149
|
+
//#region Private Properties
|
|
5150
|
+
this.messages = useT9n();
|
|
3873
5151
|
this._switchResultPanel = (e) => {
|
|
3874
5152
|
if (!e.target) {
|
|
3875
5153
|
return;
|
|
@@ -3881,23 +5159,12 @@ const ArcgisArcadeResults = class {
|
|
|
3881
5159
|
this.updateResultPanel(panelName);
|
|
3882
5160
|
};
|
|
3883
5161
|
this._emitClose = () => this.close.emit();
|
|
3884
|
-
this._lang = "";
|
|
3885
|
-
this._t9nLocale = "";
|
|
3886
|
-
this._t9nStrings = undefined;
|
|
3887
5162
|
this.loading = true;
|
|
3888
5163
|
this.openedResultPanel = "output";
|
|
3889
5164
|
this.result = undefined;
|
|
3890
5165
|
this.consoleLogs = undefined;
|
|
3891
5166
|
}
|
|
3892
5167
|
//#endregion
|
|
3893
|
-
// #region Component lifecycle events
|
|
3894
|
-
async componentWillLoad() {
|
|
3895
|
-
await arcadeDefaults.B(this, index.getAssetPath("./assets"));
|
|
3896
|
-
}
|
|
3897
|
-
disconnectedCallback() {
|
|
3898
|
-
arcadeDefaults.q(this);
|
|
3899
|
-
}
|
|
3900
|
-
// #endregion
|
|
3901
5168
|
//#region Private Methods
|
|
3902
5169
|
updateResultPanel(resultPanelType) {
|
|
3903
5170
|
this.openedResultPanel = resultPanelType;
|
|
@@ -3912,7 +5179,7 @@ const ArcgisArcadeResults = class {
|
|
|
3912
5179
|
if (this.loading && !this.consoleLogs?.length) {
|
|
3913
5180
|
return index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
|
|
3914
5181
|
}
|
|
3915
|
-
return (index.h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ?
|
|
5182
|
+
return (index.h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? this.consoleLogs.map((log) => index.h("p", null, log)) : index.h("p", null, this.messages.consolemessage)));
|
|
3916
5183
|
}
|
|
3917
5184
|
renderLogPanel() {
|
|
3918
5185
|
if (this.openedResultPanel !== "log") {
|
|
@@ -3922,24 +5189,24 @@ const ArcgisArcadeResults = class {
|
|
|
3922
5189
|
return index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
|
|
3923
5190
|
}
|
|
3924
5191
|
const iconClass = this.result?.type === "error" ? "color-error" : "color-success";
|
|
3925
|
-
return (index.h("calcite-list", null, this.result ? (index.h(index.Fragment, null, index.h("calcite-list-item", { label: arcadeDefaults.
|
|
3926
|
-
timeStamp: new Intl.DateTimeFormat(this._t9nLocale, {
|
|
5192
|
+
return (index.h("calcite-list", null, this.result ? (index.h(index.Fragment, null, index.h("calcite-list-item", { label: arcadeDefaults.re(this.messages.lastexecutionformat, {
|
|
5193
|
+
timeStamp: new Intl.DateTimeFormat(this.messages._t9nLocale, {
|
|
3927
5194
|
dateStyle: "medium",
|
|
3928
5195
|
timeStyle: "medium"
|
|
3929
5196
|
}).format(this.result.timeStamp)
|
|
3930
|
-
}) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.
|
|
3931
|
-
time: new Intl.NumberFormat(this._t9nLocale, {
|
|
5197
|
+
}) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.re(this.messages.compilationtimeformat, {
|
|
5198
|
+
time: new Intl.NumberFormat(this.messages._t9nLocale, {
|
|
3932
5199
|
style: "unit",
|
|
3933
5200
|
unit: "millisecond",
|
|
3934
5201
|
maximumFractionDigits: 2
|
|
3935
5202
|
}).format(this.result.compilationTime ?? 0)
|
|
3936
|
-
}) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.
|
|
3937
|
-
time: new Intl.NumberFormat(this._t9nLocale, {
|
|
5203
|
+
}) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.re(this.messages.executiontimeformat, {
|
|
5204
|
+
time: new Intl.NumberFormat(this.messages._t9nLocale, {
|
|
3938
5205
|
style: "unit",
|
|
3939
5206
|
unit: "millisecond",
|
|
3940
5207
|
maximumFractionDigits: 2
|
|
3941
5208
|
}).format(this.result.executionTime ?? 0)
|
|
3942
|
-
}) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (index.h("calcite-list-item", { label: this.
|
|
5209
|
+
}) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (index.h("calcite-list-item", { label: this.messages.runscriptmessage ?? "No output, run the script once." }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
|
|
3943
5210
|
}
|
|
3944
5211
|
renderOutputPanel() {
|
|
3945
5212
|
if (this.openedResultPanel !== "output") {
|
|
@@ -3950,7 +5217,7 @@ const ArcgisArcadeResults = class {
|
|
|
3950
5217
|
}
|
|
3951
5218
|
switch (this.result?.type) {
|
|
3952
5219
|
case "error":
|
|
3953
|
-
return (index.h("div", { class: "result-value-simple flex-adjustable" }, arcadeDefaults.
|
|
5220
|
+
return (index.h("div", { class: "result-value-simple flex-adjustable" }, arcadeDefaults.re(this.messages.executionerrorformat, {
|
|
3954
5221
|
message: this.result.value
|
|
3955
5222
|
})));
|
|
3956
5223
|
case "null":
|
|
@@ -3981,13 +5248,13 @@ const ArcgisArcadeResults = class {
|
|
|
3981
5248
|
case "knowledgeGraph":
|
|
3982
5249
|
return (index.h("div", { class: "result-value-simple ltr-container" }, index.h("span", { class: "value-type" }, this.result.type, ":\u00A0"), index.h("span", { class: "string-value" }, this.result.value.url)));
|
|
3983
5250
|
default:
|
|
3984
|
-
return
|
|
5251
|
+
return index.h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this.messages.runscriptmessage);
|
|
3985
5252
|
}
|
|
3986
5253
|
}
|
|
3987
5254
|
renderArrayHeader(arcadeResult) {
|
|
3988
5255
|
const items = arcadeResult.value ?? [];
|
|
3989
5256
|
const leftoverCount = Math.max(items.length - MaxArrayItems, 0);
|
|
3990
|
-
return (index.h(index.Fragment, null, index.h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (index.h("span", null, "\u00A0", arcadeDefaults.
|
|
5257
|
+
return (index.h(index.Fragment, null, index.h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (index.h("span", null, "\u00A0", arcadeDefaults.re(this.messages.showingfirstitemsformat, {
|
|
3991
5258
|
count: MaxArrayItems.toString()
|
|
3992
5259
|
}))) : null));
|
|
3993
5260
|
}
|
|
@@ -4033,15 +5300,15 @@ const ArcgisArcadeResults = class {
|
|
|
4033
5300
|
}
|
|
4034
5301
|
}
|
|
4035
5302
|
renderFeatureSetLabel(arcadeResult) {
|
|
4036
|
-
return (index.h("div", { class: "value-type" }, index.h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (index.h("span", null, "\u00A0", arcadeDefaults.
|
|
5303
|
+
return (index.h("div", { class: "value-type" }, index.h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (index.h("span", null, "\u00A0", arcadeDefaults.re(this.messages.showingfirstitemsformat, {
|
|
4037
5304
|
count: BatchSize.toString()
|
|
4038
5305
|
}))) : null));
|
|
4039
5306
|
}
|
|
4040
5307
|
render() {
|
|
4041
|
-
return (index.h(index.Host, null, index.h("header", { class: "flex-row" }, index.h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.h("calcite-action", { active: this.openedResultPanel === "output", text: this.
|
|
5308
|
+
return (index.h(index.Host, null, index.h("header", { class: "flex-row" }, index.h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.h("calcite-action", { active: this.openedResultPanel === "output", text: this.messages.output ?? "Output", "text-enabled": true, scale: "s", icon: "list-show-all", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "output" }), index.h("calcite-action", { active: this.openedResultPanel === "console", text: this.messages.console ?? "Console", "text-enabled": true, scale: "s", icon: "console", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "console" }), index.h("calcite-action", { active: this.openedResultPanel === "log", text: this.messages.log ?? "Log", "text-enabled": true, scale: "s", icon: "list", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "log" }))), index.h("calcite-action", { scale: "s", icon: "x", text: this.messages.close ?? "", onClick: this._emitClose })), index.h("article", { class: "flex-adjustable" }, this.loading ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (index.h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
|
|
4042
5309
|
}
|
|
4043
5310
|
static get assetsDirs() { return ["assets"]; }
|
|
4044
|
-
get
|
|
5311
|
+
get el() { return index.getElement(this); }
|
|
4045
5312
|
};
|
|
4046
5313
|
ArcgisArcadeResults.style = arcadeResultsCss;
|
|
4047
5314
|
|
|
@@ -4062,6 +5329,8 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4062
5329
|
index.registerInstance(this, hostRef);
|
|
4063
5330
|
this.close = index.createEvent(this, "close", 3);
|
|
4064
5331
|
this.itemSelected = index.createEvent(this, "itemSelected", 3);
|
|
5332
|
+
this.manager = useControllerManager(this);
|
|
5333
|
+
this.messages = useT9n();
|
|
4065
5334
|
this._updateFilterValue = (e) => {
|
|
4066
5335
|
this._filterValue = e.target?.value ?? "";
|
|
4067
5336
|
};
|
|
@@ -4090,9 +5359,6 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4090
5359
|
this._beforeBack = async () => {
|
|
4091
5360
|
this._selectedSuggestion = undefined;
|
|
4092
5361
|
};
|
|
4093
|
-
this._lang = "";
|
|
4094
|
-
this._t9nLocale = "";
|
|
4095
|
-
this._t9nStrings = undefined;
|
|
4096
5362
|
this._selectedSuggestion = undefined;
|
|
4097
5363
|
this._filterValue = "";
|
|
4098
5364
|
this._colorizeStyle = "";
|
|
@@ -4106,12 +5372,10 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4106
5372
|
async componentWillLoad() {
|
|
4107
5373
|
this._colorizeStyle = generateColorizeStyles();
|
|
4108
5374
|
this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
|
|
4109
|
-
await arcadeDefaults.B(this, index.getAssetPath("./assets"));
|
|
4110
5375
|
}
|
|
4111
5376
|
disconnectedCallback() {
|
|
4112
5377
|
this._flowObserver?.disconnect();
|
|
4113
5378
|
this._themeChangedListner?.dispose();
|
|
4114
|
-
arcadeDefaults.q(this);
|
|
4115
5379
|
}
|
|
4116
5380
|
// #endregion
|
|
4117
5381
|
//#region Private Methods
|
|
@@ -4147,22 +5411,22 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4147
5411
|
renderSuggestionListItems(suggestions) {
|
|
4148
5412
|
suggestions = arcadeDefaults.filterCollection(suggestions, "label", this._filterValue);
|
|
4149
5413
|
if (!suggestions.length) {
|
|
4150
|
-
return index.h("div", { class: "notice-container" }, this.
|
|
5414
|
+
return index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
|
|
4151
5415
|
}
|
|
4152
|
-
return suggestions.map((suggestion) => (index.h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, index.h("calcite-action", { slot: "actions-end", text: this.
|
|
5416
|
+
return suggestions.map((suggestion) => (index.h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, index.h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
|
|
4153
5417
|
}
|
|
4154
5418
|
renderSuggestionFlowItem() {
|
|
4155
5419
|
const suggestion = this._selectedSuggestion;
|
|
4156
5420
|
if (!suggestion) {
|
|
4157
5421
|
return null;
|
|
4158
5422
|
}
|
|
4159
|
-
return (index.h("calcite-flow-item", { heading: this.
|
|
5423
|
+
return (index.h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, index.h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => void e?.setFocus(), "data-item": suggestion }, this.messages.insert), index.h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, index.h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), index.h("pre", null, index.h("code", { ref: (e) => e === undefined ? undefined : void colorizeCodeElement(e, suggestion.code).catch(console.error) })))));
|
|
4160
5424
|
}
|
|
4161
5425
|
render() {
|
|
4162
|
-
return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this.
|
|
5426
|
+
return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), index.h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
|
|
4163
5427
|
}
|
|
4164
5428
|
static get assetsDirs() { return ["assets"]; }
|
|
4165
|
-
get
|
|
5429
|
+
get el() { return index.getElement(this); }
|
|
4166
5430
|
static get watchers() { return {
|
|
4167
5431
|
"suggestions": ["suggestionsPropChanged"]
|
|
4168
5432
|
}; }
|
|
@@ -4181,6 +5445,8 @@ const ArcgisArcadeVariables = class {
|
|
|
4181
5445
|
index.registerInstance(this, hostRef);
|
|
4182
5446
|
this.close = index.createEvent(this, "close", 3);
|
|
4183
5447
|
this.itemSelected = index.createEvent(this, "itemSelected", 3);
|
|
5448
|
+
this.manager = useControllerManager(this);
|
|
5449
|
+
this.messages = useT9n();
|
|
4184
5450
|
this._updateFilterValue = (e) => {
|
|
4185
5451
|
this._filterValue = e.target.value;
|
|
4186
5452
|
};
|
|
@@ -4213,9 +5479,6 @@ const ArcgisArcadeVariables = class {
|
|
|
4213
5479
|
e.stopPropagation();
|
|
4214
5480
|
this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
|
|
4215
5481
|
};
|
|
4216
|
-
this._lang = "";
|
|
4217
|
-
this._t9nLocale = "";
|
|
4218
|
-
this._t9nStrings = undefined;
|
|
4219
5482
|
this._mutationCounter = 1;
|
|
4220
5483
|
this._flowItemRenderers = [];
|
|
4221
5484
|
this._filterValue = "";
|
|
@@ -4226,12 +5489,7 @@ const ArcgisArcadeVariables = class {
|
|
|
4226
5489
|
this._flowItemRenderers = [];
|
|
4227
5490
|
}
|
|
4228
5491
|
//#endregion
|
|
4229
|
-
// #region Component lifecycle events
|
|
4230
|
-
async componentWillLoad() {
|
|
4231
|
-
await arcadeDefaults.B(this, index.getAssetPath("./assets"));
|
|
4232
|
-
}
|
|
4233
5492
|
disconnectedCallback() {
|
|
4234
|
-
arcadeDefaults.q(this);
|
|
4235
5493
|
this._flowObserver?.disconnect();
|
|
4236
5494
|
}
|
|
4237
5495
|
// #endregion
|
|
@@ -4285,15 +5543,15 @@ const ArcgisArcadeVariables = class {
|
|
|
4285
5543
|
});
|
|
4286
5544
|
loading = true;
|
|
4287
5545
|
}
|
|
4288
|
-
return (index.h("calcite-flow-item", { heading: this.
|
|
5546
|
+
return (index.h("calcite-flow-item", { heading: this.messages.profilevariables, description: collection.breadcrumb, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-action", { slot: "header-actions-end", text: this.messages.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), loading ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (index.h("calcite-list", null, this.renderEditorVariables(collection)))));
|
|
4289
5547
|
};
|
|
4290
5548
|
}
|
|
4291
5549
|
renderEditorVariables(collection) {
|
|
4292
5550
|
// Filter the variables. Skip group, we will filter the children later on.
|
|
4293
|
-
const filterExpression = arcadeDefaults.
|
|
5551
|
+
const filterExpression = arcadeDefaults.ne(this._filterValue);
|
|
4294
5552
|
const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
|
|
4295
5553
|
if (!filteredVariables.length) {
|
|
4296
|
-
return index.h("div", { class: "notice-container" }, this.
|
|
5554
|
+
return index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
|
|
4297
5555
|
}
|
|
4298
5556
|
return filteredVariables.map((variable) => this.renderEditorVariable(variable));
|
|
4299
5557
|
}
|
|
@@ -4303,18 +5561,18 @@ const ArcgisArcadeVariables = class {
|
|
|
4303
5561
|
// Group is a collection but we represent it differently
|
|
4304
5562
|
return (index.h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
|
|
4305
5563
|
default:
|
|
4306
|
-
return (index.h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (index.h("calcite-action", { slot: "actions-end", text: this.
|
|
5564
|
+
return (index.h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (index.h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: stopEnterPropagation, "data-item": variable })) : null, variable.icon ? index.h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
|
|
4307
5565
|
}
|
|
4308
5566
|
}
|
|
4309
5567
|
render() {
|
|
4310
5568
|
const profile = arcadeDefaults.arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
|
|
4311
5569
|
if (!this.loading && !profile?.variables.length) {
|
|
4312
|
-
return (index.h("calcite-flow", null, index.h("calcite-flow-item", { heading: this.
|
|
5570
|
+
return (index.h("calcite-flow", null, index.h("calcite-flow-item", { heading: this.messages.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("div", { class: "notice-container" }, this.messages.noprofilevariablesmessage ?? ""))));
|
|
4313
5571
|
}
|
|
4314
5572
|
return (index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
|
|
4315
5573
|
}
|
|
4316
5574
|
static get assetsDirs() { return ["assets"]; }
|
|
4317
|
-
get
|
|
5575
|
+
get el() { return index.getElement(this); }
|
|
4318
5576
|
static get watchers() { return {
|
|
4319
5577
|
"modelId": ["modelIdPropChanged"]
|
|
4320
5578
|
}; }
|
|
@@ -4345,7 +5603,7 @@ const ArcgisCodeEditor = class {
|
|
|
4345
5603
|
this._disposables = [];
|
|
4346
5604
|
this.value = undefined;
|
|
4347
5605
|
this.language = undefined;
|
|
4348
|
-
this.modelId = arcadeDefaults.
|
|
5606
|
+
this.modelId = arcadeDefaults.Q();
|
|
4349
5607
|
this.options = undefined;
|
|
4350
5608
|
}
|
|
4351
5609
|
valuePropChange(newValue) {
|
|
@@ -4487,7 +5745,7 @@ const ArcgisCodeEditor = class {
|
|
|
4487
5745
|
this.valueChange.emit(script);
|
|
4488
5746
|
});
|
|
4489
5747
|
// Detect if the host element or its ancestors got a theme attribute mutation
|
|
4490
|
-
this._themeObserver = arcadeDefaults.
|
|
5748
|
+
this._themeObserver = arcadeDefaults.b(this._hostElt, ["class"], () => this.updateTheme());
|
|
4491
5749
|
// Update the theme of the Monaco Editor
|
|
4492
5750
|
this.updateTheme();
|
|
4493
5751
|
// Creates a resize observer to re-layout the editor on size changing
|
|
@@ -4500,7 +5758,7 @@ const ArcgisCodeEditor = class {
|
|
|
4500
5758
|
while (this._disposables.length) {
|
|
4501
5759
|
this._disposables.pop()?.dispose();
|
|
4502
5760
|
}
|
|
4503
|
-
this._themeObserver?.
|
|
5761
|
+
this._themeObserver?.remove();
|
|
4504
5762
|
}
|
|
4505
5763
|
//#endregion
|
|
4506
5764
|
// #region Private methods API
|
|
@@ -4518,7 +5776,7 @@ const ArcgisCodeEditor = class {
|
|
|
4518
5776
|
// This is called the first time and subsequently by the Mutation Observer
|
|
4519
5777
|
// Figure out the theme by walking the ancestor path.
|
|
4520
5778
|
// If no theme is found then default to light.
|
|
4521
|
-
const theme = arcadeDefaults.
|
|
5779
|
+
const theme = arcadeDefaults._(this._hostElt) === "light" ? "vs" : "vs-dark";
|
|
4522
5780
|
if (theme === this._currentTheme) {
|
|
4523
5781
|
return;
|
|
4524
5782
|
}
|