@arcgis/coding-components 4.30.0-next.8 → 4.31.0-next.0
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/LICENSE.md +1 -1
- package/README.md +2 -4
- package/dist/arcgis-coding-components/arcgis-coding-components.css +1 -1
- package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +3 -3
- 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/assets/arcade-language/t9n/profile.t9n.ar.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bg.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bs.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ca.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.cs.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.da.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.de.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.el.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.es.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.et.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fi.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fr.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.he.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hr.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hu.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.id.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.it.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ja.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ko.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.lt.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.lv.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nb.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nl.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pl.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-BR.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-PT.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ro.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ru.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sk.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sl.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sr.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sv.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.th.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.tr.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.uk.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.vi.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-CN.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-HK.json +2 -0
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-TW.json +2 -0
- package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +2 -2
- package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/editor.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +1 -1
- package/dist/arcgis-coding-components/index.esm.js +3 -3
- package/dist/arcgis-coding-components/{p-2db3fc64.js → p-25960980.js} +3 -3
- package/dist/arcgis-coding-components/{p-eba1532d.js → p-3fb3347e.js} +3 -3
- package/dist/arcgis-coding-components/{p-1be5d1e3.js → p-4b079737.js} +3 -3
- package/dist/arcgis-coding-components/p-52fc1b44.js +7 -0
- package/dist/arcgis-coding-components/{p-c07e13b5.js → p-73af647c.js} +4 -4
- package/dist/arcgis-coding-components/p-75571c31.entry.js +6 -0
- package/dist/arcgis-coding-components/{p-c56ad593.js → p-a333eca1.js} +4 -4
- package/dist/arcgis-coding-components/{p-a1824310.js → p-b0f66fd8.js} +3 -3
- package/dist/arcgis-coding-components/{p-387fc534.js → p-bd97ed67.js} +4 -4
- package/dist/arcgis-coding-components/p-c07f51a4.js +68 -0
- package/dist/arcgis-coding-components/{p-c671d2bf.js → p-d34c7a85.js} +3 -3
- package/dist/arcgis-coding-components/{p-5748bf4f.js → p-f32a81b3.js} +2 -2
- package/dist/cjs/{arcade-defaults-965e518f.js → arcade-defaults-fa428ea6.js} +621 -249
- package/dist/cjs/{arcade-mode-d5e8a53f.js → arcade-mode-75d2c139.js} +46 -52
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1561 -290
- package/dist/cjs/arcgis-coding-components.cjs.js +4 -4
- package/dist/cjs/{css-c160c8ba.js → css-c5819912.js} +2 -2
- package/dist/cjs/{cssMode-aeef664b.js → cssMode-555a44d1.js} +4 -4
- package/dist/cjs/{html-5af7df92.js → html-2bff0c65.js} +4 -4
- package/dist/cjs/{htmlMode-cab67fdd.js → htmlMode-77c4a499.js} +4 -4
- package/dist/cjs/{index-f65c651a.js → index-f61a8dce.js} +41 -5
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/{javascript-e19bbbf3.js → javascript-70a512ed.js} +5 -5
- package/dist/cjs/{jsonMode-d7bc09c2.js → jsonMode-0a74131c.js} +4 -4
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/{tsMode-f1863db3.js → tsMode-8cb776f7.js} +4 -4
- package/dist/cjs/{typescript-bc515b09.js → typescript-2695cf9d.js} +4 -4
- package/dist/components/arcade-api.js +22 -33
- package/dist/components/arcade-contribution.js +73 -14
- package/dist/components/arcade-defaults.js +132 -150
- package/dist/components/arcade-mode.js +45 -51
- package/dist/components/arcade-results.js +48 -61
- package/dist/components/arcade-suggestions.js +24 -34
- package/dist/components/arcade-variables.js +23 -37
- package/dist/components/arcgis-arcade-api.js +2 -2
- package/dist/components/arcgis-arcade-editor.js +61 -151
- package/dist/components/arcgis-arcade-results.js +2 -2
- package/dist/components/arcgis-arcade-suggestions.js +2 -2
- package/dist/components/arcgis-arcade-variables.js +2 -2
- package/dist/components/arcgis-assets.d.ts +2 -2
- package/dist/components/arcgis-assets.js +2 -2
- package/dist/components/arcgis-code-editor.js +2 -2
- package/dist/components/chunk-63RMNUHL.js +1275 -0
- package/dist/components/code-editor.js +71 -79
- package/dist/components/fields.js +46 -46
- package/dist/components/index.js +2 -2
- package/dist/components/index2.js +390 -4
- package/dist/components/markdown.js +10 -12
- package/dist/components/useT9n.js +35 -0
- package/dist/components/utilities.js +4 -4
- package/dist/esm/{arcade-defaults-916efe71.js → arcade-defaults-ef553659.js} +604 -236
- package/dist/esm/{arcade-mode-ae564848.js → arcade-mode-f534f6f8.js} +46 -52
- package/dist/esm/arcgis-arcade-api_6.entry.js +1561 -290
- package/dist/esm/arcgis-coding-components.js +5 -5
- package/dist/esm/{css-16e746d3.js → css-34fa13c1.js} +2 -2
- package/dist/esm/{cssMode-92ac5593.js → cssMode-8758c994.js} +4 -4
- package/dist/esm/{html-44d7e611.js → html-c2757f30.js} +4 -4
- package/dist/esm/{htmlMode-d42d5f00.js → htmlMode-64bfdd08.js} +4 -4
- package/dist/esm/{index-faa20c76.js → index-7be467d0.js} +41 -5
- package/dist/esm/index.js +4 -4
- package/dist/esm/{javascript-7e015ca6.js → javascript-7cb6a2cd.js} +5 -5
- package/dist/esm/{jsonMode-0e712976.js → jsonMode-728cfcab.js} +4 -4
- package/dist/esm/loader.js +5 -5
- package/dist/esm/{tsMode-9fe641b9.js → tsMode-f3c09a15.js} +4 -4
- package/dist/esm/{typescript-ccf21d8e.js → typescript-a359e263.js} +4 -4
- package/dist/loader/cdn.js +2 -2
- package/dist/loader/index.cjs.js +2 -2
- package/dist/loader/index.es2017.js +2 -2
- package/dist/loader/index.js +2 -2
- package/dist/types/components/arcade-api/arcade-api.d.ts +6 -7
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +18 -12
- package/dist/types/components/arcade-results/arcade-results.d.ts +6 -9
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +7 -8
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +6 -8
- package/dist/types/components/code-editor/code-editor.d.ts +23 -13
- package/dist/types/components.d.ts +57 -35
- package/dist/types/controllers/useT9n.d.ts +1 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stencil.config.d.ts +3 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/arcade-editor.stories.d.ts +27 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/editorContext.d.ts +11 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/code-editor/code-editor.stories.d.ts +6 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/reference/stories/arcade-editor.stories.d.ts +9 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-inline-url-importer.d.ts +9 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-json-importer.d.ts +19 -0
- package/dist/types/data/actions-runner-2/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/stencil-monaco-plugins.d.ts +6 -0
- package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -1
- package/dist/types/utils/profile/types.d.ts +15 -13
- package/dist/types/utils/profile/utils.d.ts +1 -3
- package/package.json +21 -21
- package/dist/arcgis-coding-components/p-85bf5222.entry.js +0 -6
- package/dist/arcgis-coding-components/p-a5a18422.js +0 -68
- package/dist/arcgis-coding-components/p-b3439e53.js +0 -7
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
-
* See https://js.arcgis.com/4.
|
|
4
|
-
* v4.
|
|
3
|
+
* See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
+
* v4.31.0-next.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { g as generateTokensCSSForColorMap, e as editor, S as StandaloneServices, I as IStandaloneThemeService, c as createCommonjsModule, b as commonjsGlobal,
|
|
6
|
+
import { g as getAssetPath, r as registerInstance, c as createEvent, h, H as Host, a as getElement, F as Fragment } from './index-7be467d0.js';
|
|
7
|
+
import { g as generateTokensCSSForColorMap, e as editor, S as StandaloneServices, I as IStandaloneThemeService, c as createCommonjsModule, b as commonjsGlobal, D as Deferred, d as camelToKebab, s as safeCall, f as safeAsyncCall, h as devToolsAwareTimeout, i as startLocaleObserver, j as getElementLocales, k as isURL, l as hasSameOrigin, m as importRequest, n as languages, o as arcadeDefaults, U as Uri, p as setFocusOnElement, q as filterCollection, r as addLTRMark, t as importArcade, u as generateGuid, v as getElementTheme, K as KeyCode, w as setValuesInString, x as quoteString, y as supportedFields, z as createFilterExpression, R as Range, A as observeAncestorsMutation, B as KeyMod } from './arcade-defaults-ef553659.js';
|
|
8
8
|
|
|
9
9
|
async function colorizeCode(code) {
|
|
10
10
|
return await editor.colorize(code, "arcade", { tabSize: 2 });
|
|
@@ -2917,25 +2917,1313 @@ var marked_umd = createCommonjsModule(function (module, exports) {
|
|
|
2917
2917
|
// Set up the marked library to use GitHub Flavored Markdown and to use the custom renderer for links.
|
|
2918
2918
|
marked_umd.marked.use({
|
|
2919
2919
|
gfm: true,
|
|
2920
|
+
breaks: true,
|
|
2921
|
+
async: false,
|
|
2920
2922
|
renderer: {
|
|
2921
2923
|
link(href, title, text) {
|
|
2922
2924
|
return `<calcite-link href="${href}" title="${title ?? text}" target="Arcade Help">${text}</calcite-link>`;
|
|
2923
|
-
}
|
|
2924
|
-
}
|
|
2925
|
+
},
|
|
2926
|
+
},
|
|
2925
2927
|
});
|
|
2926
2928
|
/**
|
|
2927
2929
|
* Converts a markdown string to HTML using the marked library.
|
|
2928
2930
|
*/
|
|
2929
2931
|
function convertMarkdownString(value) {
|
|
2930
|
-
value
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2932
|
+
if (value === null || value === undefined) {
|
|
2933
|
+
return "";
|
|
2934
|
+
}
|
|
2935
|
+
return marked_umd.marked.parse(typeof value === "string" ? value : value.value);
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
// src/framework.ts
|
|
2939
|
+
function retrieveComponentMembers(component, isLit) {
|
|
2940
|
+
if (isLit) {
|
|
2941
|
+
const elementProperties = getLitProperties(component);
|
|
2942
|
+
component.manager.internals.members = Object.fromEntries(
|
|
2943
|
+
Array.from(elementProperties, ([name, { state, type }]) => [
|
|
2944
|
+
name,
|
|
2945
|
+
[
|
|
2946
|
+
state ? 32 /* State */ : type === Number ? 2 /* Number */ : type === Boolean ? 4 /* Boolean */ : 1 /* String */
|
|
2947
|
+
]
|
|
2948
|
+
])
|
|
2949
|
+
);
|
|
2950
|
+
} else {
|
|
2951
|
+
const constructor = component.constructor;
|
|
2952
|
+
const members = constructor.__registerControllers?.(component) ?? void 0;
|
|
2953
|
+
constructor.__registerControllers = void 0;
|
|
2954
|
+
if (typeof members !== "object")
|
|
2955
|
+
throw new Error(
|
|
2956
|
+
"Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
|
|
2957
|
+
);
|
|
2958
|
+
component.manager.internals.members = members;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
var getLitProperties = (component) => component.constructor.elementProperties;
|
|
2962
|
+
function parsePropertyValue(value, type = 8 /* Any */) {
|
|
2963
|
+
const isComplex = value == null || typeof value === "object" || typeof value === "function";
|
|
2964
|
+
if (isComplex)
|
|
2965
|
+
return value;
|
|
2966
|
+
if ((type & 4 /* Boolean */) !== 0)
|
|
2967
|
+
return value === "false" ? false : value === "" || !!value;
|
|
2968
|
+
else if ((type & 2 /* Number */) !== 0)
|
|
2969
|
+
return Number.parseFloat(value);
|
|
2970
|
+
else if ((type & 1 /* String */) !== 0)
|
|
2971
|
+
return String(value);
|
|
2972
|
+
else
|
|
2973
|
+
return value;
|
|
2974
|
+
}
|
|
2975
|
+
var makeMemberFilter = (filter) => (component) => {
|
|
2976
|
+
const members = component.manager.internals.members;
|
|
2977
|
+
return Object.entries(members ?? {}).filter(([_name, [propType]]) => (propType & filter) !== 0).map(([name]) => name);
|
|
2978
|
+
};
|
|
2979
|
+
var getPropLikeMembers = makeMemberFilter(63 /* PropLike */);
|
|
2980
|
+
var getMemberType = (component, name) => component.manager.internals.members?.[name]?.[0];
|
|
2981
|
+
function getPropType(component, name) {
|
|
2982
|
+
const type = getMemberType(component, name);
|
|
2983
|
+
if (type === void 0)
|
|
2984
|
+
return void 0;
|
|
2985
|
+
else if (type & 32 /* State */)
|
|
2986
|
+
return "state";
|
|
2987
|
+
else
|
|
2988
|
+
return "prop";
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
// src/types.ts
|
|
2992
|
+
var controllerSymbol = Symbol("controller");
|
|
2993
|
+
|
|
2994
|
+
// src/utils.ts
|
|
2995
|
+
var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
2996
|
+
|
|
2997
|
+
// src/ControllerInternals.ts
|
|
2998
|
+
var ControllerInternals = class {
|
|
2999
|
+
constructor() {
|
|
3000
|
+
this._ambientControllers = [];
|
|
3001
|
+
/**
|
|
3002
|
+
* The type definition has to be duplicated due to the
|
|
3003
|
+
* "'use' is referenced directly or indirectly in its own type annotation."
|
|
3004
|
+
* error
|
|
3005
|
+
*/
|
|
3006
|
+
this.use = async (value, watchExports) => {
|
|
3007
|
+
const controller = this.useRefSync(value);
|
|
3008
|
+
if (controller === void 0) {
|
|
3009
|
+
if (typeof watchExports === "function") {
|
|
3010
|
+
const error = new Error(
|
|
3011
|
+
`Unable to resolve a controller from the provided value, so can't watch it's exports. ${unresolvableExports}`
|
|
3012
|
+
);
|
|
3013
|
+
console.error(error);
|
|
3014
|
+
}
|
|
3015
|
+
return value;
|
|
3016
|
+
}
|
|
3017
|
+
await controller.ready;
|
|
3018
|
+
if (typeof watchExports === "function") {
|
|
3019
|
+
if (controller.watchExports === void 0)
|
|
3020
|
+
throw new Error(`The controller must implement watchExports method to support watching exports`);
|
|
3021
|
+
const unsubscribe = controller.watchExports(
|
|
3022
|
+
(exports) => watchExports(exports, unsubscribe)
|
|
3023
|
+
);
|
|
3024
|
+
}
|
|
3025
|
+
return controller.exports;
|
|
3026
|
+
};
|
|
3027
|
+
this.useRef = async (value) => {
|
|
3028
|
+
const controller = this.useRefSync(value);
|
|
3029
|
+
if (controller === void 0)
|
|
3030
|
+
throw new Error(`Unable to resolve a controller from the provided value. ${unresolvableExports}`);
|
|
3031
|
+
await controller.ready;
|
|
3032
|
+
return controller;
|
|
3033
|
+
};
|
|
3034
|
+
this.useRefSync = (value) => {
|
|
3035
|
+
const ambientChildController = this.retrieveAmbientChildController();
|
|
3036
|
+
if (ambientChildController !== void 0)
|
|
3037
|
+
return ambientChildController;
|
|
3038
|
+
const component = Controller.internals.retrieveComponent();
|
|
3039
|
+
const controller = component.manager.internals.resolveExports(value);
|
|
3040
|
+
if (controller !== void 0)
|
|
3041
|
+
return controller;
|
|
3042
|
+
if (isController(value))
|
|
3043
|
+
return value;
|
|
3044
|
+
return void 0;
|
|
3045
|
+
};
|
|
3046
|
+
this.shouldBypassSetter = false;
|
|
3047
|
+
this.shouldBypassGetter = false;
|
|
3048
|
+
this.shouldBypassReadonly = false;
|
|
3049
|
+
/**
|
|
3050
|
+
* A map from component instance or component element to component instance.
|
|
3051
|
+
* To get from component instance or component element to component element,
|
|
3052
|
+
* you can just use the .el property
|
|
3053
|
+
*/
|
|
3054
|
+
this.elementToInstance = /* @__PURE__ */ new WeakMap();
|
|
3055
|
+
}
|
|
3056
|
+
/*
|
|
3057
|
+
* Allow controllers to implicitly retrieve which component they are in, to
|
|
3058
|
+
* improve DX (avoids the need to pass "this" explicitly for each controller)
|
|
3059
|
+
*/
|
|
3060
|
+
setAmbientComponent(component) {
|
|
3061
|
+
if (this._ambientComponent === component)
|
|
3062
|
+
return;
|
|
3063
|
+
this._ambientComponent = component;
|
|
3064
|
+
queueMicrotask(() => {
|
|
3065
|
+
if (this._ambientComponent === component)
|
|
3066
|
+
this._ambientComponent = void 0;
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
retrieveComponent(name) {
|
|
3070
|
+
if (this._ambientComponent === void 0)
|
|
3071
|
+
throw new Error(
|
|
3072
|
+
[
|
|
3073
|
+
`Unable to find out which component ${name || "this"} controller `,
|
|
3074
|
+
"belongs to. This might happen if you tried to create a controller ",
|
|
3075
|
+
"outside the component. If so, please wrap your controller ",
|
|
3076
|
+
"definition in an arrow function, ",
|
|
3077
|
+
"`const myController = ()=>makeController(...);` and call that",
|
|
3078
|
+
"function inside the component `my = myController();`, or ",
|
|
3079
|
+
"define your controller using makeGenericController/GenericController ",
|
|
3080
|
+
"instead.\n",
|
|
3081
|
+
"If you wish to use a controller inside an async controller, ",
|
|
3082
|
+
"make sure you are using controller.use.\n",
|
|
3083
|
+
"You might also have multiple instances of Controllers loaded"
|
|
3084
|
+
].join("\n")
|
|
3085
|
+
);
|
|
3086
|
+
return this._ambientComponent;
|
|
3087
|
+
}
|
|
3088
|
+
/*
|
|
3089
|
+
* Aids proxyExports() in knowing who is it's host
|
|
3090
|
+
*/
|
|
3091
|
+
setParentController(controller) {
|
|
3092
|
+
if (controller === void 0) {
|
|
3093
|
+
this._ambientControllers = [];
|
|
3094
|
+
return;
|
|
3095
|
+
}
|
|
3096
|
+
const index = this._ambientControllers.indexOf(controller);
|
|
3097
|
+
this._ambientControllers = index === -1 ? [...this._ambientControllers, controller] : this._ambientControllers.slice(0, index + 1);
|
|
3098
|
+
queueMicrotask(() => {
|
|
3099
|
+
this._ambientControllers = [];
|
|
3100
|
+
});
|
|
3101
|
+
}
|
|
3102
|
+
retrieveParentControllers() {
|
|
3103
|
+
return this._ambientControllers;
|
|
3104
|
+
}
|
|
3105
|
+
/*
|
|
3106
|
+
* Aids controller.use in retrieving controller value when it receives
|
|
3107
|
+
* controller exports, rather than the controller itself
|
|
3108
|
+
*/
|
|
3109
|
+
setAmbientChildController(controller) {
|
|
3110
|
+
if (this._ambientChildController === controller)
|
|
3111
|
+
return;
|
|
3112
|
+
this._ambientChildController = controller;
|
|
3113
|
+
queueMicrotask(() => {
|
|
3114
|
+
if (this._ambientChildController === controller)
|
|
3115
|
+
this._ambientChildController = void 0;
|
|
2936
3116
|
});
|
|
2937
|
-
|
|
3117
|
+
}
|
|
3118
|
+
retrieveAmbientChildController() {
|
|
3119
|
+
const controller = this._ambientChildController;
|
|
3120
|
+
this._ambientChildController = void 0;
|
|
3121
|
+
return controller;
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
var unresolvableExports = [
|
|
3125
|
+
"The value you passed is not a controller and not a controller exports. If ",
|
|
3126
|
+
"your controller exports a literal value, try making your controller export ",
|
|
3127
|
+
"an object instead"
|
|
3128
|
+
].join("");
|
|
3129
|
+
|
|
3130
|
+
// src/Controller.ts
|
|
3131
|
+
var _a;
|
|
3132
|
+
var _Controller = class _Controller {
|
|
3133
|
+
constructor(component) {
|
|
3134
|
+
this._callbacks = {
|
|
3135
|
+
hostConnected: [],
|
|
3136
|
+
hostDisconnected: [],
|
|
3137
|
+
hostLoad: [],
|
|
3138
|
+
hostLoaded: [],
|
|
3139
|
+
hostUpdate: [],
|
|
3140
|
+
hostUpdated: [],
|
|
3141
|
+
hostDestroy: [],
|
|
3142
|
+
hostLifecycle: []
|
|
3143
|
+
};
|
|
3144
|
+
this._ready = new Deferred();
|
|
3145
|
+
this._lifecycleDisconnected = [];
|
|
3146
|
+
this.connectedCalled = false;
|
|
3147
|
+
this.willLoadCalled = false;
|
|
3148
|
+
this.didLoadCalled = false;
|
|
3149
|
+
this[_a] = true;
|
|
3150
|
+
this.ready = this._ready.promise;
|
|
3151
|
+
/*
|
|
3152
|
+
* Setting default exports to "this" so that controllers that don't use
|
|
3153
|
+
* exports/proxyExports(), could still be used as if they did
|
|
3154
|
+
* (i.e with controller.use)
|
|
3155
|
+
*/
|
|
3156
|
+
this._exports = makeProvisionalValue(this);
|
|
3157
|
+
this._exportWatchers = /* @__PURE__ */ new Set();
|
|
3158
|
+
const resolvedComponent = toControllerHost(
|
|
3159
|
+
component ?? _Controller.internals.retrieveComponent(new.target.name)
|
|
3160
|
+
);
|
|
3161
|
+
Object.defineProperty(this, "component", {
|
|
3162
|
+
writable: false,
|
|
3163
|
+
enumerable: false,
|
|
3164
|
+
configurable: true,
|
|
3165
|
+
value: resolvedComponent
|
|
3166
|
+
});
|
|
3167
|
+
this.component.addController(this);
|
|
3168
|
+
_Controller.internals.setParentController(this);
|
|
3169
|
+
if ("hostDestroy" in this)
|
|
3170
|
+
this.component.manager.ensureHasDestroy();
|
|
3171
|
+
const manager = this.component.manager;
|
|
3172
|
+
const isInControllerManager = manager === void 0;
|
|
3173
|
+
if (!isInControllerManager)
|
|
3174
|
+
queueMicrotask(() => this.catchUpLifecycle());
|
|
3175
|
+
}
|
|
3176
|
+
/**
|
|
3177
|
+
* If controller is being added dynamically, after the component
|
|
3178
|
+
* construction, then trigger connected and load right away
|
|
3179
|
+
*/
|
|
3180
|
+
catchUpLifecycle() {
|
|
3181
|
+
const { manager } = this.component;
|
|
3182
|
+
const connectedWillStillHappen = !manager.connectedCalled;
|
|
3183
|
+
if (!connectedWillStillHappen && !this.connectedCalled)
|
|
3184
|
+
this.triggerConnected();
|
|
3185
|
+
const loadWillStillHappen = !manager.willLoadCalled;
|
|
3186
|
+
if (loadWillStillHappen)
|
|
3187
|
+
return;
|
|
3188
|
+
this.triggerLoad().then(() => {
|
|
3189
|
+
const loadedWillStillHappen = !manager.didLoadCalled;
|
|
3190
|
+
if (loadedWillStillHappen)
|
|
3191
|
+
return;
|
|
3192
|
+
this.triggerLoaded();
|
|
3193
|
+
}).catch(console.error);
|
|
3194
|
+
}
|
|
3195
|
+
get exports() {
|
|
3196
|
+
return this._exports;
|
|
3197
|
+
}
|
|
3198
|
+
/**
|
|
3199
|
+
* Set controller's exports property (for usage with proxyExports()) and mark
|
|
3200
|
+
* controller as ready (for usage in other controllers). Also, triggers
|
|
3201
|
+
* re-render of the component
|
|
3202
|
+
*/
|
|
3203
|
+
set exports(exports) {
|
|
3204
|
+
if (this._exports !== exports) {
|
|
3205
|
+
this._exports = exports;
|
|
3206
|
+
if (this.connectedCalled)
|
|
3207
|
+
this.component.requestUpdate();
|
|
3208
|
+
this._exportWatchers.forEach(safeCall);
|
|
3209
|
+
}
|
|
3210
|
+
this._ready.resolve(exports);
|
|
3211
|
+
}
|
|
3212
|
+
setProvisionalExports(exports) {
|
|
3213
|
+
this._exports = makeProvisionalValue(exports);
|
|
3214
|
+
this._exportWatchers.forEach(safeCall);
|
|
3215
|
+
}
|
|
3216
|
+
watchExports(callback) {
|
|
3217
|
+
const safeCallback = () => callback(this._exports);
|
|
3218
|
+
this._exportWatchers.add(safeCallback);
|
|
3219
|
+
return () => void this._exportWatchers.delete(safeCallback);
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* A flexible utility for making sure a controller is loaded before it's used,
|
|
3223
|
+
* regardless of how or where a controller was defined:
|
|
3224
|
+
*
|
|
3225
|
+
* @example
|
|
3226
|
+
* makeGenericController(async (component, controller) => {
|
|
3227
|
+
* // Await some controller from the component:
|
|
3228
|
+
* await controller.use(component.someController);
|
|
3229
|
+
* // Initialize new controllers
|
|
3230
|
+
* await controller.use(load(importCoreReactiveUtils));
|
|
3231
|
+
* await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
|
|
3232
|
+
* await controller.use(someController(component));
|
|
3233
|
+
* });
|
|
3234
|
+
*
|
|
3235
|
+
* @remarks
|
|
3236
|
+
* If your controller is not async, and you are not creating it async, then
|
|
3237
|
+
* you are not required to use controller.use - you can use it directly.
|
|
3238
|
+
* Similarly, accessing controllers after componentWillLoad callback does not
|
|
3239
|
+
* require awaiting them as they are guaranteed to be loaded by then.
|
|
3240
|
+
*/
|
|
3241
|
+
get use() {
|
|
3242
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3243
|
+
return _Controller.internals.use;
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Just like controller.use, but returns the controller itself, rather than it's
|
|
3247
|
+
* exports
|
|
3248
|
+
*
|
|
3249
|
+
* Use cases:
|
|
3250
|
+
* - You have a controller and you want to make sure it's loaded before you
|
|
3251
|
+
* try to use it
|
|
3252
|
+
* - Your controller is not using exports, so you wish to access some props on
|
|
3253
|
+
* it directly
|
|
3254
|
+
* - You have a controller exports only, and you want to retrieve the
|
|
3255
|
+
* controller itself. This is useful if you wish to call .watchExports() or
|
|
3256
|
+
* some other method on the controller
|
|
3257
|
+
*/
|
|
3258
|
+
get useRef() {
|
|
3259
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3260
|
+
return _Controller.internals.useRef;
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* Like useRef, but doesn't wait for the controller to get ready
|
|
3264
|
+
*/
|
|
3265
|
+
get useRefSync() {
|
|
3266
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3267
|
+
return _Controller.internals.useRefSync;
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* If you need to set a prop/state without triggering the custom setter you
|
|
3271
|
+
* defined with getSet()/dynamicGetSet()/readonly(), set the value inside
|
|
3272
|
+
* of this function
|
|
3273
|
+
*
|
|
3274
|
+
* @example
|
|
3275
|
+
* @Prop() readOnly = this.manager.readOnly(true);
|
|
3276
|
+
*
|
|
3277
|
+
* someAction(): void {
|
|
3278
|
+
* this.manager.bypassSetter(()=>{
|
|
3279
|
+
* this.readOnly = false;
|
|
3280
|
+
* });
|
|
3281
|
+
* }
|
|
3282
|
+
*
|
|
3283
|
+
*/
|
|
3284
|
+
bypassSetter(callback) {
|
|
3285
|
+
_Controller.internals.shouldBypassSetter = true;
|
|
3286
|
+
try {
|
|
3287
|
+
return callback();
|
|
3288
|
+
} finally {
|
|
3289
|
+
_Controller.internals.shouldBypassSetter = false;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Like bypassSetter, but only bypasses this.manager.readonly(), rather that
|
|
3294
|
+
* all setters set using this.manager.getSet()
|
|
3295
|
+
*/
|
|
3296
|
+
bypassReadonly(callback) {
|
|
3297
|
+
_Controller.internals.shouldBypassReadonly = true;
|
|
3298
|
+
try {
|
|
3299
|
+
return callback();
|
|
3300
|
+
} finally {
|
|
3301
|
+
_Controller.internals.shouldBypassReadonly = false;
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Property reads inside of this function will bypass any custom getter you
|
|
3306
|
+
* may have, and read the value directly from what's stored in Stencil/Lit.
|
|
3307
|
+
*
|
|
3308
|
+
* This also bypasses reactiveUtils integration - reading a property inside of
|
|
3309
|
+
* bypassGetter won't make that property tracked.
|
|
3310
|
+
*
|
|
3311
|
+
* @example
|
|
3312
|
+
* reactiveUtils.watch(
|
|
3313
|
+
* ()=>{
|
|
3314
|
+
* this.manager.bypassGetter(()=>{
|
|
3315
|
+
* console.log(this.someProp);
|
|
3316
|
+
* });
|
|
3317
|
+
* return this.prop;
|
|
3318
|
+
* },
|
|
3319
|
+
* console.log
|
|
3320
|
+
* )
|
|
3321
|
+
*/
|
|
3322
|
+
bypassGetter(callback) {
|
|
3323
|
+
_Controller.internals.shouldBypassGetter = true;
|
|
3324
|
+
try {
|
|
3325
|
+
return callback();
|
|
3326
|
+
} finally {
|
|
3327
|
+
_Controller.internals.shouldBypassGetter = false;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
/**
|
|
3331
|
+
* Like this.manager.getSet(), but can be called on any component's
|
|
3332
|
+
* state/prop from anywhere, rather than just from the default value
|
|
3333
|
+
*/
|
|
3334
|
+
dynamicGetSet(name, getSet) {
|
|
3335
|
+
this.genericGetSet(name, getSet);
|
|
3336
|
+
}
|
|
3337
|
+
/**
|
|
3338
|
+
* Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
|
|
3339
|
+
* getters/setters in place where property names & types are not known
|
|
3340
|
+
* statically
|
|
3341
|
+
*/
|
|
3342
|
+
genericGetSet(property, getSet) {
|
|
3343
|
+
var _a2, _b;
|
|
3344
|
+
const genericGetSet = getSet;
|
|
3345
|
+
const internals = this.component.manager.internals;
|
|
3346
|
+
if (typeof genericGetSet.get === "function") {
|
|
3347
|
+
(_a2 = internals.getters)[property] ?? (_a2[property] = []);
|
|
3348
|
+
internals.getters[property].unshift(genericGetSet.get);
|
|
3349
|
+
}
|
|
3350
|
+
const set = genericGetSet.set === "ignore" ? ignoreSet : genericGetSet.set;
|
|
3351
|
+
if (set) {
|
|
3352
|
+
(_b = internals.setters)[property] ?? (_b[property] = []);
|
|
3353
|
+
internals.setters[property].unshift(set);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
// FEATURE: improve typings
|
|
3357
|
+
/**
|
|
3358
|
+
* Dynamically set a watcher for any reactive property
|
|
3359
|
+
*/
|
|
3360
|
+
watch(property, callback) {
|
|
3361
|
+
var _a2;
|
|
3362
|
+
const type = getMemberType(this.component, property);
|
|
3363
|
+
if (type === void 0)
|
|
3364
|
+
throw new Error(
|
|
3365
|
+
`Trying to watch a non-@property, non-@state property "${property}". Either convert it into a @state() or use get/set syntax`
|
|
3366
|
+
);
|
|
3367
|
+
const internals = this.component.manager.internals;
|
|
3368
|
+
(_a2 = internals.allWatchers)[property] ?? (_a2[property] = []);
|
|
3369
|
+
const watchers = internals.allWatchers[property];
|
|
3370
|
+
const genericCallback = callback;
|
|
3371
|
+
const safeCallback = (newValue, oldValue, propertyName) => safeCall(genericCallback, null, newValue, oldValue, propertyName);
|
|
3372
|
+
watchers.push(safeCallback);
|
|
3373
|
+
return () => {
|
|
3374
|
+
const index = watchers.indexOf(safeCallback);
|
|
3375
|
+
if (index !== -1)
|
|
3376
|
+
watchers.splice(index, 1);
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
controllerRemoved() {
|
|
3380
|
+
if (this.component.el.isConnected)
|
|
3381
|
+
this.triggerDisconnected();
|
|
3382
|
+
this.triggerDestroy();
|
|
3383
|
+
}
|
|
3384
|
+
// Register a lifecycle callback
|
|
3385
|
+
onConnected(callback) {
|
|
3386
|
+
this._callbacks.hostConnected.push(callback);
|
|
3387
|
+
}
|
|
3388
|
+
onDisconnected(callback) {
|
|
3389
|
+
this._callbacks.hostDisconnected.push(callback);
|
|
3390
|
+
}
|
|
3391
|
+
onLoad(callback) {
|
|
3392
|
+
this._callbacks.hostLoad.push(callback);
|
|
3393
|
+
}
|
|
3394
|
+
onLoaded(callback) {
|
|
3395
|
+
this._callbacks.hostLoaded.push(callback);
|
|
3396
|
+
}
|
|
3397
|
+
onUpdate(callback) {
|
|
3398
|
+
this._callbacks.hostUpdate.push(callback);
|
|
3399
|
+
}
|
|
3400
|
+
onUpdated(callback) {
|
|
3401
|
+
this._callbacks.hostUpdated.push(callback);
|
|
3402
|
+
}
|
|
3403
|
+
onDestroy(callback) {
|
|
3404
|
+
this.component.manager.ensureHasDestroy();
|
|
3405
|
+
this._callbacks.hostDestroy.push(callback);
|
|
3406
|
+
}
|
|
3407
|
+
onLifecycle(callback) {
|
|
3408
|
+
this._callbacks.hostLifecycle.push(callback);
|
|
3409
|
+
if (this.connectedCalled && this.component.el.isConnected)
|
|
3410
|
+
this._callLifecycle(callback);
|
|
3411
|
+
}
|
|
3412
|
+
// Call each lifecycle hook
|
|
3413
|
+
triggerConnected() {
|
|
3414
|
+
const genericController = this;
|
|
3415
|
+
if (genericController.hostConnected)
|
|
3416
|
+
safeCall(genericController.hostConnected, genericController);
|
|
3417
|
+
this._callbacks.hostConnected.forEach(safeCall);
|
|
3418
|
+
this.triggerLifecycle();
|
|
3419
|
+
this.connectedCalled = true;
|
|
3420
|
+
}
|
|
3421
|
+
triggerDisconnected() {
|
|
3422
|
+
const genericController = this;
|
|
3423
|
+
if (genericController.hostDisconnected)
|
|
3424
|
+
safeCall(genericController.hostDisconnected, genericController);
|
|
3425
|
+
this._callbacks.hostDisconnected.forEach(safeCall);
|
|
3426
|
+
this._lifecycleDisconnected.forEach(safeCall);
|
|
3427
|
+
this._lifecycleDisconnected = [];
|
|
3428
|
+
}
|
|
3429
|
+
async triggerLoad() {
|
|
3430
|
+
if (this.willLoadCalled)
|
|
3431
|
+
return;
|
|
3432
|
+
this.willLoadCalled = true;
|
|
3433
|
+
const genericController = this;
|
|
3434
|
+
if (genericController.hostLoad)
|
|
3435
|
+
await safeAsyncCall(genericController.hostLoad, genericController);
|
|
3436
|
+
if (this._callbacks.hostLoad.length > 0)
|
|
3437
|
+
await Promise.allSettled(this._callbacks.hostLoad.map(safeAsyncCall));
|
|
3438
|
+
this._ready.resolve(this._exports);
|
|
3439
|
+
}
|
|
3440
|
+
triggerLoaded() {
|
|
3441
|
+
if (this.didLoadCalled)
|
|
3442
|
+
return;
|
|
3443
|
+
const genericController = this;
|
|
3444
|
+
if (genericController.hostLoaded)
|
|
3445
|
+
safeCall(genericController.hostLoaded, genericController);
|
|
3446
|
+
this._callbacks.hostLoaded.forEach(safeCall);
|
|
3447
|
+
this.didLoadCalled = true;
|
|
3448
|
+
}
|
|
3449
|
+
triggerUpdate() {
|
|
3450
|
+
const genericController = this;
|
|
3451
|
+
if (genericController.hostUpdate)
|
|
3452
|
+
safeCall(genericController.hostUpdate, genericController);
|
|
3453
|
+
this._callbacks.hostUpdate.forEach(safeCall);
|
|
3454
|
+
}
|
|
3455
|
+
triggerUpdated() {
|
|
3456
|
+
const genericController = this;
|
|
3457
|
+
if (genericController.hostUpdated)
|
|
3458
|
+
safeCall(genericController.hostUpdated, genericController);
|
|
3459
|
+
this._callbacks.hostUpdated.forEach(safeCall);
|
|
3460
|
+
}
|
|
3461
|
+
triggerDestroy() {
|
|
3462
|
+
const genericController = this;
|
|
3463
|
+
if (genericController.hostDestroy)
|
|
3464
|
+
safeCall(genericController.hostDestroy, genericController);
|
|
3465
|
+
this._callbacks.hostDestroy.forEach(safeCall);
|
|
3466
|
+
}
|
|
3467
|
+
triggerLifecycle() {
|
|
3468
|
+
const genericController = this;
|
|
3469
|
+
if (genericController.hostLifecycle)
|
|
3470
|
+
this._callLifecycle(() => genericController.hostLifecycle());
|
|
3471
|
+
this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
|
|
3472
|
+
}
|
|
3473
|
+
_callLifecycle(callback) {
|
|
3474
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3475
|
+
const cleanupRaw = safeCall(callback);
|
|
3476
|
+
const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
|
|
3477
|
+
cleanup.forEach((cleanup2) => {
|
|
3478
|
+
if (typeof cleanup2 === "function")
|
|
3479
|
+
this._lifecycleDisconnected.push(cleanup2);
|
|
3480
|
+
else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function")
|
|
3481
|
+
this._lifecycleDisconnected.push(cleanup2.remove);
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
_a = controllerSymbol;
|
|
3486
|
+
_Controller.internals = new ControllerInternals();
|
|
3487
|
+
var Controller = _Controller;
|
|
3488
|
+
var GenericController = class extends Controller {
|
|
3489
|
+
// Redundant constructor needed to improve typing
|
|
3490
|
+
constructor(component) {
|
|
3491
|
+
super(component);
|
|
3492
|
+
}
|
|
3493
|
+
// Overriding super's watch only to improve typing
|
|
3494
|
+
watch(property, callback) {
|
|
3495
|
+
return super.watch(
|
|
3496
|
+
property,
|
|
3497
|
+
callback
|
|
3498
|
+
);
|
|
3499
|
+
}
|
|
3500
|
+
dynamicGetSet(property, getSet) {
|
|
3501
|
+
super.genericGetSet(property, getSet);
|
|
3502
|
+
}
|
|
3503
|
+
};
|
|
3504
|
+
function makeProvisionalValue(base) {
|
|
3505
|
+
if (typeof base !== "object" && typeof base !== "function" || base === null)
|
|
3506
|
+
return base;
|
|
3507
|
+
const proxy2 = new Proxy(base, {
|
|
3508
|
+
get(target, prop, receiver) {
|
|
3509
|
+
if (cyclical.has(prop) && prop in target && target[prop] === proxy2)
|
|
3510
|
+
return void 0;
|
|
3511
|
+
if (prop in target || prop in Promise.prototype || typeof prop === "symbol")
|
|
3512
|
+
return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
|
|
3513
|
+
console.error(`Trying to access "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
3514
|
+
return void 0;
|
|
3515
|
+
},
|
|
3516
|
+
set(target, prop, newValue, receiver) {
|
|
3517
|
+
console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
3518
|
+
return Reflect.set(target, prop, newValue, receiver);
|
|
3519
|
+
}
|
|
3520
|
+
});
|
|
3521
|
+
return proxy2;
|
|
3522
|
+
}
|
|
3523
|
+
var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
|
|
3524
|
+
var accessBeforeLoad = "" ;
|
|
3525
|
+
function toControllerHost(component) {
|
|
3526
|
+
if ("addController" in component)
|
|
3527
|
+
return component;
|
|
3528
|
+
else
|
|
3529
|
+
throw new Error(
|
|
3530
|
+
"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"
|
|
3531
|
+
);
|
|
2938
3532
|
}
|
|
3533
|
+
var ignoreSet = (_, value) => value;
|
|
3534
|
+
function trackPropertyKey(object, onResolved, defaultValue) {
|
|
3535
|
+
const keys = Object.keys(object);
|
|
3536
|
+
const keyCount = keys.length;
|
|
3537
|
+
if (keyTrackMap === void 0)
|
|
3538
|
+
queueMicrotask(keyTrackResolve);
|
|
3539
|
+
keyTrackMap ?? (keyTrackMap = /* @__PURE__ */ new Map());
|
|
3540
|
+
let pendingTrackers = keyTrackMap.get(object);
|
|
3541
|
+
if (pendingTrackers === void 0) {
|
|
3542
|
+
pendingTrackers = { callbacks: [], keyCount };
|
|
3543
|
+
keyTrackMap.set(object, pendingTrackers);
|
|
3544
|
+
}
|
|
3545
|
+
if (pendingTrackers.keyCount !== keyCount) {
|
|
3546
|
+
pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
|
|
3547
|
+
pendingTrackers.callbacks = [];
|
|
3548
|
+
pendingTrackers.keyCount = keyCount;
|
|
3549
|
+
}
|
|
3550
|
+
pendingTrackers.callbacks.push((keys2) => {
|
|
3551
|
+
const callback = (key2) => safeCall(onResolved, null, key2);
|
|
3552
|
+
const key = keys2[keyCount];
|
|
3553
|
+
if (key === void 0)
|
|
3554
|
+
callback(void 0);
|
|
3555
|
+
else if (object[key] === defaultValue)
|
|
3556
|
+
callback(key);
|
|
3557
|
+
else
|
|
3558
|
+
callback(void 0);
|
|
3559
|
+
});
|
|
3560
|
+
return defaultValue;
|
|
3561
|
+
}
|
|
3562
|
+
var keyTrackMap = void 0;
|
|
3563
|
+
function keyTrackResolve() {
|
|
3564
|
+
Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
|
|
3565
|
+
const keys = Object.keys(object);
|
|
3566
|
+
callbacks.forEach((commit) => commit(keys));
|
|
3567
|
+
});
|
|
3568
|
+
keyTrackMap = void 0;
|
|
3569
|
+
}
|
|
3570
|
+
var ComponentInternals = class {
|
|
3571
|
+
constructor(component) {
|
|
3572
|
+
/**
|
|
3573
|
+
* When watchers are set, set then into `allWatchers`. When watchers are read
|
|
3574
|
+
* in the setter, read from `enabledWatchers`.
|
|
3575
|
+
* On connectedCallback(), controller manager does `enabledWatchers=allWatchers`.
|
|
3576
|
+
* Reasoning:
|
|
3577
|
+
* - This disables watchers until connected callback (matches behavior of
|
|
3578
|
+
* Stencil's watchers)
|
|
3579
|
+
* - This removes in the setter to check if watchers were enabled already or
|
|
3580
|
+
* not (as getters/setters are hot path, and should be streamlined)
|
|
3581
|
+
*/
|
|
3582
|
+
this.enabledWatchers = {};
|
|
3583
|
+
this.allWatchers = {};
|
|
3584
|
+
this.trackKey = (hostsCandidates, onResolved, defaultValue) => {
|
|
3585
|
+
const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
|
|
3586
|
+
let leftToResolve = candidateHosts.length + 1;
|
|
3587
|
+
const resolved = (resolution) => {
|
|
3588
|
+
leftToResolve -= 1;
|
|
3589
|
+
if (resolution !== void 0)
|
|
3590
|
+
leftToResolve = 0;
|
|
3591
|
+
if (leftToResolve === 0)
|
|
3592
|
+
onResolved(resolution);
|
|
3593
|
+
};
|
|
3594
|
+
candidateHosts.forEach(
|
|
3595
|
+
(host) => this.component.manager.trackPropertyKey(
|
|
3596
|
+
host,
|
|
3597
|
+
(key) => resolved(
|
|
3598
|
+
key === void 0 ? void 0 : {
|
|
3599
|
+
key,
|
|
3600
|
+
host,
|
|
3601
|
+
type: "property",
|
|
3602
|
+
domValue: void 0
|
|
3603
|
+
}
|
|
3604
|
+
),
|
|
3605
|
+
defaultValue
|
|
3606
|
+
)
|
|
3607
|
+
);
|
|
3608
|
+
this.component.manager.trackPropKey((key, domValue) => {
|
|
3609
|
+
const propType = key === void 0 ? void 0 : getPropType(this.component, key);
|
|
3610
|
+
resolved(
|
|
3611
|
+
key === void 0 ? void 0 : {
|
|
3612
|
+
key,
|
|
3613
|
+
host: this.component,
|
|
3614
|
+
type: propType ?? "prop",
|
|
3615
|
+
domValue: propType === "prop" ? domValue : void 0
|
|
3616
|
+
}
|
|
3617
|
+
);
|
|
3618
|
+
}, defaultValue);
|
|
3619
|
+
return defaultValue;
|
|
3620
|
+
};
|
|
3621
|
+
this.trackPropKey = (onResolved, defaultValue) => {
|
|
3622
|
+
if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
|
|
3623
|
+
this._firePropertyTrackers(void 0, void 0, void 0);
|
|
3624
|
+
if (this._keyTrackers.length === 0)
|
|
3625
|
+
queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
|
|
3626
|
+
this._trackedValue = defaultValue;
|
|
3627
|
+
this._keyTrackers.push(
|
|
3628
|
+
(key, value, previousValue) => safeCall(onResolved, void 0, defaultValue === value ? key : void 0, previousValue)
|
|
3629
|
+
);
|
|
3630
|
+
return defaultValue;
|
|
3631
|
+
};
|
|
3632
|
+
this._trackedValue = nothing;
|
|
3633
|
+
this._keyTrackers = [];
|
|
3634
|
+
this.getters = {};
|
|
3635
|
+
this.setters = {};
|
|
3636
|
+
this.accessorGetter = {};
|
|
3637
|
+
this.accessorSetter = {};
|
|
3638
|
+
this.reactiveUtilsIntegrations = /* @__PURE__ */ new Set();
|
|
3639
|
+
this._exports = /* @__PURE__ */ new WeakMap();
|
|
3640
|
+
Object.defineProperty(this, "component", {
|
|
3641
|
+
writable: false,
|
|
3642
|
+
enumerable: false,
|
|
3643
|
+
configurable: true,
|
|
3644
|
+
value: component
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
3647
|
+
_firePropertyTrackers(key, value, oldValue) {
|
|
3648
|
+
const trackers = this._keyTrackers;
|
|
3649
|
+
this._trackedValue = nothing;
|
|
3650
|
+
this._keyTrackers = [];
|
|
3651
|
+
trackers.forEach((tracker) => tracker(key, value, oldValue));
|
|
3652
|
+
}
|
|
3653
|
+
/**
|
|
3654
|
+
* Configure a getter or setter for a given \@Prop/\@State
|
|
3655
|
+
*
|
|
3656
|
+
* Note, since props are defined on the prototype, they are shared between all
|
|
3657
|
+
* instances of a component. Thus, instead of passing a reference to the
|
|
3658
|
+
* getter/setter function, you should update the
|
|
3659
|
+
* ComponentInternals.getters/setters properties, and then call getSetProxy
|
|
3660
|
+
* to apply the changes to the prototype
|
|
3661
|
+
*/
|
|
3662
|
+
getSetProxy(property, hasGetter, hasSetter) {
|
|
3663
|
+
const component = this.component;
|
|
3664
|
+
const classPrototype = component.constructor.prototype;
|
|
3665
|
+
this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
|
|
3666
|
+
if (component.manager.isLit)
|
|
3667
|
+
return;
|
|
3668
|
+
const htmlPrototype = component.el.constructor.prototype;
|
|
3669
|
+
if (classPrototype !== htmlPrototype)
|
|
3670
|
+
this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
|
|
3671
|
+
}
|
|
3672
|
+
_getSetProxy(prototype, name, hasGetter, hasSetter, type) {
|
|
3673
|
+
const component = this.component;
|
|
3674
|
+
const propType = getMemberType(component, name);
|
|
3675
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
3676
|
+
const tolerateNotFound = type === "html";
|
|
3677
|
+
if (descriptor?.set === void 0 || descriptor.get === void 0)
|
|
3678
|
+
if (descriptor !== void 0 && "value" in descriptor)
|
|
3679
|
+
throw new Error(
|
|
3680
|
+
`getSet() should only be used on @Prop/@property/@State/@state properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name}" in ${component.el.tagName}`
|
|
3681
|
+
);
|
|
3682
|
+
else if (tolerateNotFound)
|
|
3683
|
+
return;
|
|
3684
|
+
else
|
|
3685
|
+
throw new Error(`Unable to find "${name}" property on the ${component.el.tagName} component`);
|
|
3686
|
+
const { get: originalGet, set: originalSet } = descriptor;
|
|
3687
|
+
const isGetterAlreadyOverwritten = customAccessor in originalGet;
|
|
3688
|
+
const isSetterAlreadyOverwritten = customAccessor in originalSet;
|
|
3689
|
+
const shouldOverwriteGet = !isGetterAlreadyOverwritten && hasGetter;
|
|
3690
|
+
const shouldOverwriteSet = !isSetterAlreadyOverwritten && hasSetter;
|
|
3691
|
+
if (!shouldOverwriteGet && !shouldOverwriteSet)
|
|
3692
|
+
return;
|
|
3693
|
+
const finalGetter = shouldOverwriteGet ? function getter() {
|
|
3694
|
+
let value = originalGet.call(this);
|
|
3695
|
+
const component2 = Controller.internals.elementToInstance.get(this);
|
|
3696
|
+
if (Controller.internals.shouldBypassGetter || component2 === void 0)
|
|
3697
|
+
return value;
|
|
3698
|
+
const internals = component2.manager.internals;
|
|
3699
|
+
value = internals.accessorGetter[name](value, name);
|
|
3700
|
+
const getters = internals.getters[name] ?? emptyArray;
|
|
3701
|
+
for (let i = 0; i < getters.length; i++)
|
|
3702
|
+
value = getters[i](value, name);
|
|
3703
|
+
return value;
|
|
3704
|
+
} : originalGet;
|
|
3705
|
+
const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
|
|
3706
|
+
const oldValue = originalGet.call(this);
|
|
3707
|
+
const component2 = Controller.internals.elementToInstance.get(this);
|
|
3708
|
+
if (component2 === void 0) {
|
|
3709
|
+
originalSet.call(this, rawNewValue);
|
|
3710
|
+
return;
|
|
3711
|
+
}
|
|
3712
|
+
let newValue = component2.manager.isLit ? rawNewValue : parsePropertyValue(rawNewValue, propType);
|
|
3713
|
+
const internals = component2.manager.internals;
|
|
3714
|
+
if (newValue === oldValue)
|
|
3715
|
+
originalSet.call(this, rawNewValue);
|
|
3716
|
+
else {
|
|
3717
|
+
const setters = Controller.internals.shouldBypassSetter ? emptyArray : internals.setters[name] ?? emptyArray;
|
|
3718
|
+
for (let i = 0; i < setters.length; i++) {
|
|
3719
|
+
newValue = setters[i](newValue, oldValue, name);
|
|
3720
|
+
if (newValue === oldValue)
|
|
3721
|
+
break;
|
|
3722
|
+
}
|
|
3723
|
+
newValue = internals.accessorSetter[name](newValue, oldValue, name);
|
|
3724
|
+
originalSet.call(this, newValue);
|
|
3725
|
+
if (newValue !== oldValue)
|
|
3726
|
+
internals.enabledWatchers[name]?.forEach((watcher) => watcher(newValue, oldValue, name));
|
|
3727
|
+
}
|
|
3728
|
+
if (internals._keyTrackers.length > 0)
|
|
3729
|
+
internals?._firePropertyTrackers(name, rawNewValue, oldValue);
|
|
3730
|
+
} : originalSet;
|
|
3731
|
+
if (shouldOverwriteGet)
|
|
3732
|
+
Object.defineProperty(finalGetter, customAccessor, { value: true });
|
|
3733
|
+
if (shouldOverwriteSet)
|
|
3734
|
+
Object.defineProperty(finalSetter, customAccessor, { value: true });
|
|
3735
|
+
Object.defineProperty(prototype, name, {
|
|
3736
|
+
...descriptor,
|
|
3737
|
+
get: finalGetter,
|
|
3738
|
+
set: finalSetter
|
|
3739
|
+
});
|
|
3740
|
+
}
|
|
3741
|
+
/**
|
|
3742
|
+
* Associate an exports object with a controller for reverse lookup in
|
|
3743
|
+
* controller.use
|
|
3744
|
+
*/
|
|
3745
|
+
markExports(controller, exports) {
|
|
3746
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function")
|
|
3747
|
+
this._exports.set(exports, controller);
|
|
3748
|
+
}
|
|
3749
|
+
resolveExports(exports) {
|
|
3750
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function")
|
|
3751
|
+
return this._exports.get(exports);
|
|
3752
|
+
else
|
|
3753
|
+
return void 0;
|
|
3754
|
+
}
|
|
3755
|
+
};
|
|
3756
|
+
var emptyArray = [];
|
|
3757
|
+
var customAccessor = Symbol("controllersCustomAccessor");
|
|
3758
|
+
var nothing = Symbol("nothing");
|
|
3759
|
+
var useControllerManager = (component, forceUpdate) => new ControllerManager(component, forceUpdate);
|
|
3760
|
+
var ControllerManager = class extends GenericController {
|
|
3761
|
+
constructor(component, forceUpdate) {
|
|
3762
|
+
const isLit = "addController" in component;
|
|
3763
|
+
const controllers = /* @__PURE__ */ new Set();
|
|
3764
|
+
function addController(controller) {
|
|
3765
|
+
controllers.add(controller);
|
|
3766
|
+
if (isLit && !(controllerSymbol in controller) && component.el.isConnected)
|
|
3767
|
+
controller.hostConnected?.();
|
|
3768
|
+
}
|
|
3769
|
+
function removeController(controller) {
|
|
3770
|
+
void controllers.delete(controller);
|
|
3771
|
+
controller.controllerRemoved?.();
|
|
3772
|
+
}
|
|
3773
|
+
const controllerHost = component;
|
|
3774
|
+
controllerHost.addController = addController;
|
|
3775
|
+
controllerHost.removeController = removeController;
|
|
3776
|
+
if (!isLit) {
|
|
3777
|
+
const update = forceUpdate ?? component.constructor.__forceUpdate;
|
|
3778
|
+
controllerHost.requestUpdate = () => update(component);
|
|
3779
|
+
}
|
|
3780
|
+
super(component);
|
|
3781
|
+
this.internals = new ComponentInternals(this.component);
|
|
3782
|
+
this.destroyed = false;
|
|
3783
|
+
this._updatePromise = new Deferred();
|
|
3784
|
+
this._originalLifecycles = {};
|
|
3785
|
+
/**
|
|
3786
|
+
* A magical solution to finding out what property name a given controller
|
|
3787
|
+
* on a given object was assigned to. Note, this does not work for properties
|
|
3788
|
+
* that have \@Prop() or \@State() decorator - for those, use
|
|
3789
|
+
* manager.trackPropKey() instead.
|
|
3790
|
+
*
|
|
3791
|
+
* @example
|
|
3792
|
+
* function trackMe<T>(defaultValue:T, component:BaseComponent):T {
|
|
3793
|
+
* component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
|
|
3794
|
+
* return defaultValue;
|
|
3795
|
+
* }
|
|
3796
|
+
*
|
|
3797
|
+
* class MyComponent extends BaseComponent {
|
|
3798
|
+
* // Will console log "myProp"
|
|
3799
|
+
* myProp = trackMe('a', this);
|
|
3800
|
+
* }
|
|
3801
|
+
*
|
|
3802
|
+
*/
|
|
3803
|
+
this.trackPropertyKey = trackPropertyKey;
|
|
3804
|
+
/**
|
|
3805
|
+
* Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
|
|
3806
|
+
* decorator
|
|
3807
|
+
*
|
|
3808
|
+
* @example
|
|
3809
|
+
* function trackMe(component:BaseComponent) {
|
|
3810
|
+
* component.manager.trackPropKey((key)=>console.log(key));
|
|
3811
|
+
* }
|
|
3812
|
+
*
|
|
3813
|
+
* class MyComponent extends BaseComponent {
|
|
3814
|
+
* // Will console log "myProp"
|
|
3815
|
+
* @Prop() myProp = trackMe(this);
|
|
3816
|
+
*
|
|
3817
|
+
* // Will console log "myState"
|
|
3818
|
+
* @State() myState = trackMe(this);
|
|
3819
|
+
* }
|
|
3820
|
+
*/
|
|
3821
|
+
this.trackPropKey = this.internals.trackPropKey;
|
|
3822
|
+
/**
|
|
3823
|
+
* A combination of trackPropertyKey() and trackPropKey(). For usage when
|
|
3824
|
+
* you want to track a property, but don't know if it will be defined with the
|
|
3825
|
+
* \@Prop() decorator or not
|
|
3826
|
+
*/
|
|
3827
|
+
this.trackKey = this.internals.trackKey;
|
|
3828
|
+
this._readonlySetter = (newValue, oldValue, property) => {
|
|
3829
|
+
if (Controller.internals.shouldBypassReadonly)
|
|
3830
|
+
return newValue;
|
|
3831
|
+
const component = this.component;
|
|
3832
|
+
const isProp = getPropType(component, property) === "prop";
|
|
3833
|
+
if (isProp) {
|
|
3834
|
+
if (this.isLit) {
|
|
3835
|
+
const details = getLitProperties(component).get(property);
|
|
3836
|
+
if (details && details?.attribute !== false)
|
|
3837
|
+
component.el.setAttribute(
|
|
3838
|
+
typeof details.attribute === "string" ? details.attribute : camelToKebab(property),
|
|
3839
|
+
// Not using converter.toAttribute to keep this unlikely case simpler
|
|
3840
|
+
String(oldValue)
|
|
3841
|
+
);
|
|
3842
|
+
} else
|
|
3843
|
+
component.requestUpdate();
|
|
3844
|
+
}
|
|
3845
|
+
throw new Error(
|
|
3846
|
+
`Cannot assign to read-only property "${property}" of ${component.el.tagName.toLowerCase()}. Trying to assign "${String(
|
|
3847
|
+
newValue
|
|
3848
|
+
)}"`
|
|
3849
|
+
);
|
|
3850
|
+
};
|
|
3851
|
+
/**
|
|
3852
|
+
* In development, on hot module reload, controller would be re-initialized
|
|
3853
|
+
* with all Props and State values persistent, but properties lost. This unsafe
|
|
3854
|
+
* development-only API lets you set or get data for a controller that would
|
|
3855
|
+
* persist across hot reloads.
|
|
3856
|
+
*/
|
|
3857
|
+
this.devOnlySetPersistentControllerData = void 0 ;
|
|
3858
|
+
this.devOnlyGetPersistentControllerData = void 0 ;
|
|
3859
|
+
this.isLit = isLit;
|
|
3860
|
+
this.component.manager = this;
|
|
3861
|
+
retrieveComponentMembers(component, isLit);
|
|
3862
|
+
this._controllers = controllers;
|
|
3863
|
+
this.exports = void 0;
|
|
3864
|
+
this.hasDestroy = "autoDestroyDisabled" in this.component && typeof this.component.destroy === "function";
|
|
3865
|
+
if (this.hasDestroy)
|
|
3866
|
+
this.watch("autoDestroyDisabled", () => this._autoDestroyDisabledWatcher());
|
|
3867
|
+
this._bindLifecycleMethods();
|
|
3868
|
+
if (!isLit)
|
|
3869
|
+
Object.defineProperty(component, "updateComplete", {
|
|
3870
|
+
get: async () => await this._updatePromise.promise
|
|
3871
|
+
});
|
|
3872
|
+
const members = getPropLikeMembers(component);
|
|
3873
|
+
const internals = component.manager.internals;
|
|
3874
|
+
members.forEach((name) => {
|
|
3875
|
+
internals.accessorGetter[name] = defaultGetterSetter;
|
|
3876
|
+
internals.accessorSetter[name] = defaultGetterSetter;
|
|
3877
|
+
internals.getSetProxy(name, true, true);
|
|
3878
|
+
});
|
|
3879
|
+
Controller.internals.setParentController(void 0);
|
|
3880
|
+
Controller.internals.setAmbientComponent(component);
|
|
3881
|
+
Controller.internals.elementToInstance.set(component.el, component);
|
|
3882
|
+
Controller.internals.elementToInstance.set(component, component);
|
|
3883
|
+
}
|
|
3884
|
+
_bindLifecycleMethods() {
|
|
3885
|
+
const component = this.component;
|
|
3886
|
+
const isLit = this.isLit;
|
|
3887
|
+
this._originalLifecycles = {
|
|
3888
|
+
// These component's callbacks will be called by Lit, so we don't have to
|
|
3889
|
+
connectedCallback: isLit ? void 0 : component.connectedCallback,
|
|
3890
|
+
disconnectedCallback: isLit ? void 0 : component.disconnectedCallback,
|
|
3891
|
+
componentWillLoad: isLit ? void 0 : component.componentWillLoad,
|
|
3892
|
+
componentDidLoad: isLit ? void 0 : component.componentDidLoad,
|
|
3893
|
+
componentWillUpdate: isLit ? void 0 : component.componentWillUpdate,
|
|
3894
|
+
componentDidUpdate: isLit ? void 0 : component.componentDidUpdate,
|
|
3895
|
+
destroy: component.destroy
|
|
3896
|
+
};
|
|
3897
|
+
const hostConnected = this._connectedCallback.bind(this);
|
|
3898
|
+
const hostDisconnected = this._disconnectedCallback.bind(this);
|
|
3899
|
+
const hostUpdate = this._update.bind(this);
|
|
3900
|
+
const hostUpdated = this._updated.bind(this);
|
|
3901
|
+
if (isLit)
|
|
3902
|
+
component.constructor.prototype.addController.call(component, {
|
|
3903
|
+
// Lit will call these callbacks
|
|
3904
|
+
hostConnected,
|
|
3905
|
+
hostDisconnected,
|
|
3906
|
+
hostUpdate,
|
|
3907
|
+
hostUpdated
|
|
3908
|
+
});
|
|
3909
|
+
else {
|
|
3910
|
+
component.connectedCallback = hostConnected;
|
|
3911
|
+
component.disconnectedCallback = hostDisconnected;
|
|
3912
|
+
component.componentWillLoad = this._load.bind(this);
|
|
3913
|
+
component.componentDidLoad = this._loaded.bind(this);
|
|
3914
|
+
component.componentWillUpdate = hostUpdate;
|
|
3915
|
+
component.componentDidUpdate = hostUpdated;
|
|
3916
|
+
}
|
|
3917
|
+
if (this.hasDestroy)
|
|
3918
|
+
component.destroy = this.destroy.bind(this);
|
|
3919
|
+
}
|
|
3920
|
+
/**
|
|
3921
|
+
* Throws an error if component does not implement destroy() lifecycle, but
|
|
3922
|
+
* tries to use it.
|
|
3923
|
+
*/
|
|
3924
|
+
ensureHasDestroy() {
|
|
3925
|
+
if (!this.hasDestroy)
|
|
3926
|
+
throw new Error(destroyErrorMessage);
|
|
3927
|
+
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Private because this is not supposed to be called by Component directly.
|
|
3930
|
+
* Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
|
|
3931
|
+
* calling lifecycle methods twice.
|
|
3932
|
+
*/
|
|
3933
|
+
_connectedCallback() {
|
|
3934
|
+
if (this.destroyed) {
|
|
3935
|
+
const tagName = this.component.el.tagName.toLowerCase();
|
|
3936
|
+
this.component.el.remove();
|
|
3937
|
+
throw new Error(
|
|
3938
|
+
`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 autoDestroyDisabled prop.`
|
|
3939
|
+
);
|
|
3940
|
+
}
|
|
3941
|
+
if (this._autoDestroyTimeout !== void 0)
|
|
3942
|
+
clearTimeout(this._autoDestroyTimeout);
|
|
3943
|
+
this.internals.enabledWatchers = this.internals.allWatchers;
|
|
3944
|
+
keyTrackResolve();
|
|
3945
|
+
this._controllers.forEach(
|
|
3946
|
+
(controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(controller.hostConnected, controller)
|
|
3947
|
+
);
|
|
3948
|
+
this._originalLifecycles.connectedCallback?.call(this.component);
|
|
3949
|
+
}
|
|
3950
|
+
_disconnectedCallback() {
|
|
3951
|
+
if (this.destroyed)
|
|
3952
|
+
return;
|
|
3953
|
+
this._controllers.forEach(
|
|
3954
|
+
(controller) => "triggerDisconnected" in controller ? controller.triggerDisconnected() : safeCall(controller.hostDisconnected, controller)
|
|
3955
|
+
);
|
|
3956
|
+
this._originalLifecycles.disconnectedCallback?.call(this.component);
|
|
3957
|
+
if (this.hasDestroy)
|
|
3958
|
+
this._autoDestroyDisabledWatcher();
|
|
3959
|
+
}
|
|
3960
|
+
async _load() {
|
|
3961
|
+
const integrations = this.internals.reactiveUtilsIntegrations;
|
|
3962
|
+
if (integrations.size > 0) {
|
|
3963
|
+
for (const controller of integrations) {
|
|
3964
|
+
if ("triggerLoad" in controller)
|
|
3965
|
+
await controller.triggerLoad();
|
|
3966
|
+
else
|
|
3967
|
+
await safeAsyncCall(controller.hostLoad, controller);
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
await Promise.allSettled(
|
|
3971
|
+
Array.from(
|
|
3972
|
+
this._controllers,
|
|
3973
|
+
async (controller) => integrations.has(controller) ? void 0 : "triggerLoad" in controller ? await controller.triggerLoad() : await safeAsyncCall(controller.hostLoad, controller)
|
|
3974
|
+
)
|
|
3975
|
+
);
|
|
3976
|
+
await this._originalLifecycles.componentWillLoad?.call(this.component);
|
|
3977
|
+
}
|
|
3978
|
+
_loaded() {
|
|
3979
|
+
this._controllers.forEach(
|
|
3980
|
+
(controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(controller.hostLoaded, controller)
|
|
3981
|
+
);
|
|
3982
|
+
this._originalLifecycles.componentDidLoad?.call(this.component);
|
|
3983
|
+
}
|
|
3984
|
+
_update() {
|
|
3985
|
+
this._controllers.forEach(
|
|
3986
|
+
(controller) => "triggerUpdate" in controller ? controller.triggerUpdate() : safeCall(controller.hostUpdate, controller)
|
|
3987
|
+
);
|
|
3988
|
+
void this._originalLifecycles.componentWillUpdate?.call(this.component);
|
|
3989
|
+
}
|
|
3990
|
+
_updated() {
|
|
3991
|
+
this._controllers.forEach(
|
|
3992
|
+
(controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(controller.hostUpdated, controller)
|
|
3993
|
+
);
|
|
3994
|
+
this._originalLifecycles.componentDidUpdate?.call(this.component);
|
|
3995
|
+
if (!this.isLit) {
|
|
3996
|
+
const updatePromise = this._updatePromise;
|
|
3997
|
+
this._updatePromise = new Deferred();
|
|
3998
|
+
updatePromise.resolve(true);
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
async destroy() {
|
|
4002
|
+
this.ensureHasDestroy();
|
|
4003
|
+
if (this.destroyed)
|
|
4004
|
+
return;
|
|
4005
|
+
if (this.component.el.isConnected) {
|
|
4006
|
+
this.hasDestroy = false;
|
|
4007
|
+
try {
|
|
4008
|
+
this.component.el.remove();
|
|
4009
|
+
} finally {
|
|
4010
|
+
this.hasDestroy = true;
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
this._autoDestroyTimeout = void 0;
|
|
4014
|
+
this.destroyed = true;
|
|
4015
|
+
this._controllers.forEach(
|
|
4016
|
+
(controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(controller.hostDestroy, controller)
|
|
4017
|
+
);
|
|
4018
|
+
this._controllers.clear();
|
|
4019
|
+
await this._originalLifecycles.destroy?.call(this.component);
|
|
4020
|
+
}
|
|
4021
|
+
_autoDestroyDisabledWatcher() {
|
|
4022
|
+
if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
|
|
4023
|
+
if (this._autoDestroyTimeout !== void 0)
|
|
4024
|
+
clearTimeout(this._autoDestroyTimeout);
|
|
4025
|
+
const destroy = () => void this.destroy().catch(console.error);
|
|
4026
|
+
this._autoDestroyTimeout = devToolsAwareTimeout(destroy, autoDestroyOnDisconnectTimeout);
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
// REFACTOR: replace this with a readonly:true option in @property()
|
|
4030
|
+
/**
|
|
4031
|
+
* Make a @Prop() or @State() readonly (prevent overwriting default value).
|
|
4032
|
+
*
|
|
4033
|
+
* For internal properties, prefer TypeScript's "readonly" modifier instead.
|
|
4034
|
+
*
|
|
4035
|
+
* @example
|
|
4036
|
+
* // Defining readonly prop
|
|
4037
|
+
* @Prop({ reflect: true }) prop = this.manager.readonly('a');
|
|
4038
|
+
*
|
|
4039
|
+
* @example
|
|
4040
|
+
* // Overwriting readonly prop internally
|
|
4041
|
+
* this.manager.bypassReadonly(()=>{
|
|
4042
|
+
* this.prop = 'b';
|
|
4043
|
+
* });
|
|
4044
|
+
*
|
|
4045
|
+
*/
|
|
4046
|
+
readonly(value) {
|
|
4047
|
+
return this.getSet(value, { set: this._readonlySetter });
|
|
4048
|
+
}
|
|
4049
|
+
// REFACTOR: remove this in Lit in favor of native get/set
|
|
4050
|
+
/**
|
|
4051
|
+
* Listen for any component's @State()/@Prop() change, and mutate it's
|
|
4052
|
+
* value before it is set.
|
|
4053
|
+
* This is necessary because Stencil's Compiler does not support get/set for
|
|
4054
|
+
* @State()/@Prop().
|
|
4055
|
+
* For private component properties, you should use regular get/set syntax.
|
|
4056
|
+
*
|
|
4057
|
+
* @example
|
|
4058
|
+
* @Prop() exampleProp = this.manager.getSet(defaultValue,{get,set})
|
|
4059
|
+
* @Prop() someProp = this.manager.getSet(
|
|
4060
|
+
* undefined as string | undefined,
|
|
4061
|
+
* {
|
|
4062
|
+
* get: (value)=>value.trim(),
|
|
4063
|
+
* set: (newValue,oldValue) => newValue.trim() ?? oldValue
|
|
4064
|
+
* }
|
|
4065
|
+
* )
|
|
4066
|
+
*
|
|
4067
|
+
* @remarks
|
|
4068
|
+
* Unlike a native get/set, the get function receives the current attribute
|
|
4069
|
+
* value, and can modify it before returning it (or can disregard the current
|
|
4070
|
+
* value and get it from elsewhere instead).
|
|
4071
|
+
* Similarly, setter is called with the new and old value, and is expected to
|
|
4072
|
+
* return the final new value (or return the old value to undo the change)
|
|
4073
|
+
*/
|
|
4074
|
+
getSet(defaultValue, getSet) {
|
|
4075
|
+
return this.component.manager.trackPropKey((name) => {
|
|
4076
|
+
var _a2;
|
|
4077
|
+
if (name === void 0)
|
|
4078
|
+
throw new Error(
|
|
4079
|
+
"Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
|
|
4080
|
+
);
|
|
4081
|
+
if (getSet.set === this._readonlySetter) {
|
|
4082
|
+
(_a2 = this.internals).readonlyProps ?? (_a2.readonlyProps = /* @__PURE__ */ new Set());
|
|
4083
|
+
this.internals.readonlyProps.add(name);
|
|
4084
|
+
}
|
|
4085
|
+
const genericComponent = this.component;
|
|
4086
|
+
const value = genericComponent[name];
|
|
4087
|
+
const isStencilHotReload = "production" !== "production" ;
|
|
4088
|
+
const initialSet = getSet.initialSet ?? true;
|
|
4089
|
+
if (value != null && value !== defaultValue && typeof getSet.set === "function" && initialSet && !isStencilHotReload) {
|
|
4090
|
+
const newValue = getSet.set(value, defaultValue, name);
|
|
4091
|
+
if (newValue !== value)
|
|
4092
|
+
if (this.isLit)
|
|
4093
|
+
genericComponent[name] = newValue;
|
|
4094
|
+
else {
|
|
4095
|
+
let firstConnected = true;
|
|
4096
|
+
this.onConnected(() => {
|
|
4097
|
+
if (!firstConnected)
|
|
4098
|
+
return;
|
|
4099
|
+
firstConnected = true;
|
|
4100
|
+
this.bypassSetter(() => {
|
|
4101
|
+
genericComponent[name] = newValue;
|
|
4102
|
+
});
|
|
4103
|
+
});
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
this.genericGetSet(name, getSet);
|
|
4107
|
+
}, defaultValue);
|
|
4108
|
+
}
|
|
4109
|
+
};
|
|
4110
|
+
var destroyErrorMessage = `
|
|
4111
|
+
If the component uses a controller that uses destroy() method, then the
|
|
4112
|
+
component must have the following properties:
|
|
4113
|
+
${// Don't expose internal code in production, and keep bundle smaller:
|
|
4114
|
+
`autoDestroyDisabled and destroy` }
|
|
4115
|
+
`.trim();
|
|
4116
|
+
var autoDestroyOnDisconnectTimeout = 1e3;
|
|
4117
|
+
var defaultGetterSetter = (value) => value;
|
|
4118
|
+
|
|
4119
|
+
// src/proxyExports.ts
|
|
4120
|
+
var proxyExports = (Class) => (...args) => {
|
|
4121
|
+
const ambientControllers = Controller.internals.retrieveParentControllers();
|
|
4122
|
+
const instance = new Class(...args);
|
|
4123
|
+
const initialExports = instance.exports;
|
|
4124
|
+
Controller.internals.setParentController(ambientControllers.at(-1));
|
|
4125
|
+
const internals = instance.component.manager.internals;
|
|
4126
|
+
internals.markExports(instance, initialExports);
|
|
4127
|
+
instance.watchExports((exports) => internals.markExports(instance, exports));
|
|
4128
|
+
Controller.internals.setAmbientChildController(instance);
|
|
4129
|
+
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
4130
|
+
return internals.trackKey(
|
|
4131
|
+
hostCandidates,
|
|
4132
|
+
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution, initialExports),
|
|
4133
|
+
initialExports
|
|
4134
|
+
);
|
|
4135
|
+
};
|
|
4136
|
+
function setProxy(controller, { host, key, type }, initialExports) {
|
|
4137
|
+
const genericHost = host;
|
|
4138
|
+
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
4139
|
+
const hostValueChanged = genericHost[key] !== initialExports;
|
|
4140
|
+
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
4141
|
+
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
|
|
4142
|
+
genericHost[key] = controller.exports;
|
|
4143
|
+
const isProxyExportsOnComponent = host === controller.component;
|
|
4144
|
+
if (isProxyExportsOnComponent && type === "prop") {
|
|
4145
|
+
const internals = controller.component.manager.internals;
|
|
4146
|
+
if (hostValueChanged)
|
|
4147
|
+
internals.markExports(controller, genericHost[key]);
|
|
4148
|
+
controller.component.manager.watch(key, (value) => {
|
|
4149
|
+
if (value !== controller.exports)
|
|
4150
|
+
internals.markExports(controller, value);
|
|
4151
|
+
});
|
|
4152
|
+
}
|
|
4153
|
+
controller.watchExports(() => {
|
|
4154
|
+
if (genericHost[key] === controller.exports)
|
|
4155
|
+
return;
|
|
4156
|
+
const manager = controller.component.manager;
|
|
4157
|
+
const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
|
|
4158
|
+
if (isReadOnly)
|
|
4159
|
+
manager.bypassReadonly(() => {
|
|
4160
|
+
genericHost[key] = controller.exports;
|
|
4161
|
+
});
|
|
4162
|
+
else
|
|
4163
|
+
genericHost[key] = controller.exports;
|
|
4164
|
+
});
|
|
4165
|
+
}
|
|
4166
|
+
|
|
4167
|
+
// src/functional.ts
|
|
4168
|
+
var makeController = (constructor) => proxy(void 0, constructor);
|
|
4169
|
+
var FunctionalController = class extends Controller {
|
|
4170
|
+
constructor(component, constructor) {
|
|
4171
|
+
super(component);
|
|
4172
|
+
const originalExports = this.exports;
|
|
4173
|
+
try {
|
|
4174
|
+
Controller.internals.setAmbientComponent(this.component);
|
|
4175
|
+
const value = constructor(this.component, this);
|
|
4176
|
+
const constructorChangedExports = this.exports !== originalExports;
|
|
4177
|
+
if (value instanceof Promise) {
|
|
4178
|
+
if (!constructorChangedExports)
|
|
4179
|
+
this.setProvisionalExports(value);
|
|
4180
|
+
const resolved = value.then((result) => {
|
|
4181
|
+
this.exports = result;
|
|
4182
|
+
super.catchUpLifecycle();
|
|
4183
|
+
}).catch((error) => {
|
|
4184
|
+
this._ready.reject(error);
|
|
4185
|
+
console.error(error);
|
|
4186
|
+
});
|
|
4187
|
+
this.onLoad(async () => await resolved);
|
|
4188
|
+
} else {
|
|
4189
|
+
if (!constructorChangedExports || value !== void 0)
|
|
4190
|
+
this.exports = value;
|
|
4191
|
+
queueMicrotask(() => super.catchUpLifecycle());
|
|
4192
|
+
}
|
|
4193
|
+
} catch (error) {
|
|
4194
|
+
this._ready.reject(error);
|
|
4195
|
+
console.error(error);
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
/** Noop - will be called in the constructor instead */
|
|
4199
|
+
catchUpLifecycle() {
|
|
4200
|
+
return;
|
|
4201
|
+
}
|
|
4202
|
+
};
|
|
4203
|
+
var proxy = proxyExports(FunctionalController);
|
|
4204
|
+
|
|
4205
|
+
var makeT9nController = (getAssetPath) => ({ blocking = false, name } = {}) => (
|
|
4206
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4207
|
+
makeController((component, controller) => {
|
|
4208
|
+
controller.onLifecycle(
|
|
4209
|
+
() => startLocaleObserver(
|
|
4210
|
+
component.el,
|
|
4211
|
+
getAssetPath("./assets"),
|
|
4212
|
+
({ t9nLocale, t9nStrings, lang }) => {
|
|
4213
|
+
controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
|
|
4214
|
+
const label = t9nStrings.componentLabel ?? t9nStrings.widgetLabel;
|
|
4215
|
+
if (typeof label === "string" && "label" in component && component.label == null)
|
|
4216
|
+
component.label ?? (component.label = label);
|
|
4217
|
+
},
|
|
4218
|
+
name
|
|
4219
|
+
)
|
|
4220
|
+
);
|
|
4221
|
+
if (blocking)
|
|
4222
|
+
return controller.ready;
|
|
4223
|
+
const locale = getElementLocales(component.el);
|
|
4224
|
+
return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
|
|
4225
|
+
})
|
|
4226
|
+
);
|
|
2939
4227
|
|
|
2940
4228
|
function isMonacoEnvironmentSetup() {
|
|
2941
4229
|
return !!window.MonacoEnvironment?.getWorkerUrl;
|
|
@@ -2977,21 +4265,81 @@ function setupMonacoEnvironment(assetsPath) {
|
|
|
2977
4265
|
break;
|
|
2978
4266
|
}
|
|
2979
4267
|
// If we have a relative path or we are on same orgin, we can use the default js implementation
|
|
2980
|
-
if (!
|
|
4268
|
+
if (!isURL(url) || hasSameOrigin(url, globalThis.location.href, true)) {
|
|
2981
4269
|
return new Worker(url, { name: languageId });
|
|
2982
4270
|
}
|
|
2983
4271
|
// For cross orgin, we will load the worker code as a string and manufacture a blob
|
|
2984
4272
|
const esriRequest = await importRequest();
|
|
2985
4273
|
const response = await esriRequest(url, {
|
|
2986
|
-
responseType: "text"
|
|
4274
|
+
responseType: "text",
|
|
2987
4275
|
});
|
|
2988
4276
|
return new Worker(URL.createObjectURL(new Blob([response.data], {
|
|
2989
|
-
type: "text/javascript"
|
|
4277
|
+
type: "text/javascript",
|
|
2990
4278
|
})));
|
|
2991
|
-
}
|
|
4279
|
+
},
|
|
2992
4280
|
};
|
|
2993
4281
|
}
|
|
2994
4282
|
|
|
4283
|
+
const themeConfig = {
|
|
4284
|
+
"arcade-light-theme": {
|
|
4285
|
+
comment: "#606060",
|
|
4286
|
+
constant: "#9809C8",
|
|
4287
|
+
date: "#296389",
|
|
4288
|
+
identifier: "#0000B3",
|
|
4289
|
+
keyword: "#BF4900",
|
|
4290
|
+
number: "#136D3D",
|
|
4291
|
+
string: "#A31515"
|
|
4292
|
+
},
|
|
4293
|
+
"arcade-dark-theme": {
|
|
4294
|
+
comment: "#BFBFBF",
|
|
4295
|
+
constant: "#CDBAEA",
|
|
4296
|
+
date: "#97A6CE",
|
|
4297
|
+
identifier: "#9FD4F3",
|
|
4298
|
+
keyword: "#EEAA5A",
|
|
4299
|
+
number: "#AAD04B",
|
|
4300
|
+
string: "#F2877B"
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4303
|
+
|
|
4304
|
+
function setupArcadeTheme() {
|
|
4305
|
+
["light", "dark"].forEach((theme) => {
|
|
4306
|
+
const base = theme === "light" ? "vs" : "vs-dark";
|
|
4307
|
+
const colors = themeConfig[`arcade-${theme}-theme`];
|
|
4308
|
+
// Defines the light and dark theme based on the calcite theme name
|
|
4309
|
+
editor.defineTheme(base, {
|
|
4310
|
+
base,
|
|
4311
|
+
inherit: true,
|
|
4312
|
+
rules: [
|
|
4313
|
+
{ token: "comment.arc", foreground: colors.comment },
|
|
4314
|
+
{ token: "constant.arc", foreground: colors.constant },
|
|
4315
|
+
{ token: "keyword.arc", foreground: colors.keyword },
|
|
4316
|
+
{ token: "identifier.arc", foreground: colors.identifier },
|
|
4317
|
+
{ token: "number.arc", foreground: colors.number },
|
|
4318
|
+
{ token: "string.arc", foreground: colors.string },
|
|
4319
|
+
],
|
|
4320
|
+
colors: {},
|
|
4321
|
+
});
|
|
4322
|
+
});
|
|
4323
|
+
}
|
|
4324
|
+
const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
|
|
4325
|
+
const colorRulesKeys = [...monacoThemeKeys, "date"];
|
|
4326
|
+
function updateThemeColors(theme, colorRules) {
|
|
4327
|
+
if (colorRules === undefined) {
|
|
4328
|
+
setupArcadeTheme();
|
|
4329
|
+
return;
|
|
4330
|
+
}
|
|
4331
|
+
const base = theme === "light" ? "vs" : "vs-dark";
|
|
4332
|
+
const rules = [];
|
|
4333
|
+
monacoThemeKeys.forEach((key) => {
|
|
4334
|
+
const foreground = colorRules[key];
|
|
4335
|
+
if (!foreground) {
|
|
4336
|
+
return;
|
|
4337
|
+
}
|
|
4338
|
+
rules.push({ token: `${key}.arc`, foreground });
|
|
4339
|
+
});
|
|
4340
|
+
editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
|
|
4341
|
+
}
|
|
4342
|
+
|
|
2995
4343
|
/**
|
|
2996
4344
|
* Returns the arcade diagnostic service.
|
|
2997
4345
|
* Example:
|
|
@@ -3021,23 +4369,22 @@ async function getArcadeWorker(uri) {
|
|
|
3021
4369
|
}
|
|
3022
4370
|
/**
|
|
3023
4371
|
* Request the arcade mode
|
|
3024
|
-
* @returns mode
|
|
4372
|
+
* @returns arcade mode module
|
|
3025
4373
|
*/
|
|
3026
4374
|
async function getMode() {
|
|
3027
|
-
return await import('./arcade-mode-
|
|
4375
|
+
return await import('./arcade-mode-f534f6f8.js');
|
|
3028
4376
|
}
|
|
3029
4377
|
// Register the language in Monaco
|
|
3030
4378
|
languages.register({
|
|
3031
4379
|
id: arcadeDefaults.languageId,
|
|
3032
4380
|
aliases: ["Arcade", "arcade"],
|
|
3033
4381
|
extensions: [".arc"],
|
|
3034
|
-
mimetypes: ["application/arcade"]
|
|
4382
|
+
mimetypes: ["application/arcade"],
|
|
3035
4383
|
});
|
|
3036
4384
|
// An event emitted when a language is first time needed
|
|
3037
4385
|
languages.onLanguage(arcadeDefaults.languageId, () => {
|
|
3038
|
-
|
|
4386
|
+
setupArcadeTheme();
|
|
3039
4387
|
arcadeDefaults.setLanguageOptions({ assetsPath: `${getAssetsPath() ?? "."}/arcade-language` });
|
|
3040
|
-
// Async import the language mode
|
|
3041
4388
|
getMode()
|
|
3042
4389
|
.then((mode) => {
|
|
3043
4390
|
// Setup the language mode
|
|
@@ -3048,13 +4395,17 @@ languages.onLanguage(arcadeDefaults.languageId, () => {
|
|
|
3048
4395
|
});
|
|
3049
4396
|
});
|
|
3050
4397
|
|
|
3051
|
-
const
|
|
4398
|
+
const useT9n = makeT9nController(getAssetPath);
|
|
4399
|
+
|
|
4400
|
+
const arcadeApiCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}:host calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}";
|
|
3052
4401
|
|
|
3053
4402
|
const ArcgisArcadeApi = class {
|
|
3054
4403
|
constructor(hostRef) {
|
|
3055
4404
|
registerInstance(this, hostRef);
|
|
3056
|
-
this.
|
|
3057
|
-
this.
|
|
4405
|
+
this.arcgisClose = createEvent(this, "arcgisClose", 3);
|
|
4406
|
+
this.arcgisItemSelected = createEvent(this, "arcgisItemSelected", 3);
|
|
4407
|
+
this.manager = useControllerManager(this);
|
|
4408
|
+
this.messages = useT9n();
|
|
3058
4409
|
this._emitItemSelected = (e) => {
|
|
3059
4410
|
const item = e.target?.["data-item"];
|
|
3060
4411
|
if (!item) {
|
|
@@ -3063,10 +4414,10 @@ const ArcgisArcadeApi = class {
|
|
|
3063
4414
|
const keyEvent = e;
|
|
3064
4415
|
if (!keyEvent.key || keyEvent.key === "Enter") {
|
|
3065
4416
|
e.preventDefault();
|
|
3066
|
-
this.
|
|
4417
|
+
this.arcgisItemSelected.emit(item.completion.insertText);
|
|
3067
4418
|
}
|
|
3068
4419
|
};
|
|
3069
|
-
this._emitClose = () => this.
|
|
4420
|
+
this._emitClose = () => this.arcgisClose.emit();
|
|
3070
4421
|
this._emitItemSelectedAndClose = (e) => {
|
|
3071
4422
|
if (!e.target) {
|
|
3072
4423
|
return;
|
|
@@ -3078,7 +4429,7 @@ const ArcgisArcadeApi = class {
|
|
|
3078
4429
|
if (!item) {
|
|
3079
4430
|
return;
|
|
3080
4431
|
}
|
|
3081
|
-
this.
|
|
4432
|
+
this.arcgisItemSelected.emit(item.completion.insertText);
|
|
3082
4433
|
}
|
|
3083
4434
|
};
|
|
3084
4435
|
this._selectItem = (e) => {
|
|
@@ -3094,9 +4445,6 @@ const ArcgisArcadeApi = class {
|
|
|
3094
4445
|
this._updateFilterValue = (e) => {
|
|
3095
4446
|
this._filterValue = e.target?.value ?? "";
|
|
3096
4447
|
};
|
|
3097
|
-
this._lang = "";
|
|
3098
|
-
this._t9nLocale = "";
|
|
3099
|
-
this._t9nStrings = undefined;
|
|
3100
4448
|
this._selectedApiItem = undefined;
|
|
3101
4449
|
this._filterValue = "";
|
|
3102
4450
|
this._colorizeStyle = "";
|
|
@@ -3110,7 +4458,6 @@ const ArcgisArcadeApi = class {
|
|
|
3110
4458
|
async componentWillLoad() {
|
|
3111
4459
|
this._colorizeStyle = generateColorizeStyles();
|
|
3112
4460
|
this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
|
|
3113
|
-
await B(this, getAssetPath("./assets"));
|
|
3114
4461
|
arcadeDefaults.onModelContextDidChange((key) => {
|
|
3115
4462
|
if (!this.modelId || key !== Uri.parse(this.modelId).toString()) {
|
|
3116
4463
|
return;
|
|
@@ -3120,7 +4467,6 @@ const ArcgisArcadeApi = class {
|
|
|
3120
4467
|
await this._updateApiLibrary();
|
|
3121
4468
|
}
|
|
3122
4469
|
disconnectedCallback() {
|
|
3123
|
-
q(this);
|
|
3124
4470
|
this._flowObserver?.disconnect();
|
|
3125
4471
|
this._themeChangedListner?.dispose();
|
|
3126
4472
|
}
|
|
@@ -3165,7 +4511,7 @@ const ArcgisArcadeApi = class {
|
|
|
3165
4511
|
// When switching between flow the same reference is reused
|
|
3166
4512
|
this._flowObserver = new MutationObserver(() => {
|
|
3167
4513
|
// Get the last panel and try to set focus on the input element
|
|
3168
|
-
|
|
4514
|
+
setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
|
|
3169
4515
|
});
|
|
3170
4516
|
this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
|
|
3171
4517
|
}
|
|
@@ -3176,14 +4522,14 @@ const ArcgisArcadeApi = class {
|
|
|
3176
4522
|
if (!filteredApiItems.length) {
|
|
3177
4523
|
return null;
|
|
3178
4524
|
}
|
|
3179
|
-
return (h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (h("calcite-list-item", { label:
|
|
4525
|
+
return (h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (h("calcite-list-item", { label: addLTRMark(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
|
|
3180
4526
|
}
|
|
3181
4527
|
renderApiItemFlowItem() {
|
|
3182
4528
|
const apiItem = this._selectedApiItem;
|
|
3183
4529
|
if (!apiItem) {
|
|
3184
4530
|
return null;
|
|
3185
4531
|
}
|
|
3186
|
-
return (h("calcite-flow-item", { heading: this.
|
|
4532
|
+
return (h("calcite-flow-item", { heading: this.messages.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (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)), 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"), h("calcite-block", { open: true, heading: addLTRMark(apiItem.completion.detail) }, h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (h("div", { ref: (e) => {
|
|
3187
4533
|
if (!e) {
|
|
3188
4534
|
return;
|
|
3189
4535
|
}
|
|
@@ -3194,10 +4540,10 @@ const ArcgisArcadeApi = class {
|
|
|
3194
4540
|
render() {
|
|
3195
4541
|
const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
|
|
3196
4542
|
const empty = categories.every((g) => !g);
|
|
3197
|
-
return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this.
|
|
4543
|
+
return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this.messages.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), this._preparingApi ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (h("calcite-list", null, empty ? h("div", { class: "notice-container" }, this.messages.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
|
|
3198
4544
|
}
|
|
3199
4545
|
static get assetsDirs() { return ["assets"]; }
|
|
3200
|
-
get
|
|
4546
|
+
get el() { return getElement(this); }
|
|
3201
4547
|
};
|
|
3202
4548
|
ArcgisArcadeApi.style = arcadeApiCss;
|
|
3203
4549
|
|
|
@@ -3384,7 +4730,7 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3384
4730
|
// Setup an executor with the script
|
|
3385
4731
|
const arcade = await importArcade();
|
|
3386
4732
|
const executor = await arcade.createArcadeExecutor(script ?? "", {
|
|
3387
|
-
variables: editorProfile?.variables ?? []
|
|
4733
|
+
variables: editorProfile?.variables ?? [],
|
|
3388
4734
|
});
|
|
3389
4735
|
// We want to measure the execution time
|
|
3390
4736
|
const t1 = performance.now();
|
|
@@ -3394,7 +4740,7 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3394
4740
|
spatialReference,
|
|
3395
4741
|
timeZone,
|
|
3396
4742
|
rawOutput: true,
|
|
3397
|
-
console
|
|
4743
|
+
console,
|
|
3398
4744
|
};
|
|
3399
4745
|
// Execute the script
|
|
3400
4746
|
const scriptOutput = await executor.executeAsync(profileVariableInstances, executeContext);
|
|
@@ -3418,81 +4764,21 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3418
4764
|
error,
|
|
3419
4765
|
timeStamp,
|
|
3420
4766
|
compilationTime: 0,
|
|
3421
|
-
executionTime: 0
|
|
4767
|
+
executionTime: 0,
|
|
3422
4768
|
};
|
|
3423
4769
|
}
|
|
3424
4770
|
}
|
|
3425
4771
|
|
|
3426
|
-
const
|
|
3427
|
-
"arcade-light-theme": {
|
|
3428
|
-
comment: "#606060",
|
|
3429
|
-
constant: "#9809C8",
|
|
3430
|
-
date: "#296389",
|
|
3431
|
-
identifier: "#0000B3",
|
|
3432
|
-
keyword: "#BF4900",
|
|
3433
|
-
number: "#136D3D",
|
|
3434
|
-
string: "#A31515"
|
|
3435
|
-
},
|
|
3436
|
-
"arcade-dark-theme": {
|
|
3437
|
-
comment: "#BFBFBF",
|
|
3438
|
-
constant: "#CDBAEA",
|
|
3439
|
-
date: "#97A6CE",
|
|
3440
|
-
identifier: "#9FD4F3",
|
|
3441
|
-
keyword: "#EEAA5A",
|
|
3442
|
-
number: "#AAD04B",
|
|
3443
|
-
string: "#F2877B"
|
|
3444
|
-
}
|
|
3445
|
-
};
|
|
3446
|
-
|
|
3447
|
-
function setupArcadeTheme() {
|
|
3448
|
-
["light", "dark"].forEach((theme) => {
|
|
3449
|
-
const base = theme === "light" ? "vs" : "vs-dark";
|
|
3450
|
-
const colors = themeConfig[`arcade-${theme}-theme`];
|
|
3451
|
-
// Defines the light and dark theme based on the calcite theme name
|
|
3452
|
-
editor.defineTheme(base, {
|
|
3453
|
-
base,
|
|
3454
|
-
inherit: true,
|
|
3455
|
-
rules: [
|
|
3456
|
-
{ token: "comment.arc", foreground: colors.comment },
|
|
3457
|
-
{ token: "constant.arc", foreground: colors.constant },
|
|
3458
|
-
{ token: "keyword.arc", foreground: colors.keyword },
|
|
3459
|
-
{ token: "identifier.arc", foreground: colors.identifier },
|
|
3460
|
-
{ token: "number.arc", foreground: colors.number },
|
|
3461
|
-
{ token: "string.arc", foreground: colors.string }
|
|
3462
|
-
],
|
|
3463
|
-
colors: {}
|
|
3464
|
-
});
|
|
3465
|
-
});
|
|
3466
|
-
}
|
|
3467
|
-
const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
|
|
3468
|
-
const colorRulesKeys = [...monacoThemeKeys, "date"];
|
|
3469
|
-
function updateThemeColors(theme, colorRules) {
|
|
3470
|
-
if (colorRules === undefined) {
|
|
3471
|
-
setupArcadeTheme();
|
|
3472
|
-
return;
|
|
3473
|
-
}
|
|
3474
|
-
const base = theme === "light" ? "vs" : "vs-dark";
|
|
3475
|
-
const rules = [];
|
|
3476
|
-
monacoThemeKeys.forEach((key) => {
|
|
3477
|
-
const foreground = colorRules[key];
|
|
3478
|
-
if (!foreground) {
|
|
3479
|
-
return;
|
|
3480
|
-
}
|
|
3481
|
-
rules.push({ token: `${key}.arc`, foreground });
|
|
3482
|
-
});
|
|
3483
|
-
editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
|
|
3484
|
-
}
|
|
3485
|
-
|
|
3486
|
-
const arcadeEditorCss = "arcgis-arcade-editor{display:flex;flex-direction:column;height:100%;width:100%;position:relative;overflow:hidden;border:1px solid var(--calcite-color-border-3);box-sizing:border-box;background-color:var(--calcite-color-foreground-1)}arcgis-arcade-editor .flex-adjustable{flex:1 1 auto;overflow:hidden}arcgis-arcade-editor .flex-panel{flex:1 0 auto}arcgis-arcade-editor .position-relative{position:relative}arcgis-arcade-editor .flex-row{display:flex;flex-direction:row;overflow:hidden}arcgis-arcade-editor .flex-column{display:flex;flex-direction:column;overflow:hidden}arcgis-arcade-editor .border-inline-start{border-inline-start:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .border-inline-end{border-inline-end:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .sticky{position:sticky;top:0px;z-index:10}arcgis-arcade-editor .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-color-foreground-1);text-align:center}arcgis-arcade-editor .side-action-bar{max-width:25%}arcgis-arcade-editor .side-panel{max-width:45%;width:600px}arcgis-arcade-editor .side-panel calcite-flow{height:100%}arcgis-arcade-editor .main-action-bar{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}arcgis-arcade-editor .main-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group:last-child{border-inline-end-width:0px}arcgis-arcade-editor .main-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}arcgis-arcade-editor arcgis-arcade-results{border-top:1px solid var(--calcite-color-border-3);box-sizing:border-box;max-height:50%;min-height:50%;margin-bottom:-1px}arcgis-arcade-editor calcite-flow [slot=footer]{word-break:break-word}arcgis-arcade-editor calcite-list-item-group calcite-list-item{margin-bottom:1px;box-shadow:0 1px 0 var(--calcite-color-border-3)}arcgis-arcade-editor calcite-list-item-group calcite-list-item:last-child{box-shadow:none}arcgis-arcade-editor calcite-list-item-group:last-child{margin-bottom:var(--calcite-spacing-1)}";
|
|
4772
|
+
const arcadeEditorCss = "arcgis-arcade-editor{display:flex;flex-direction:column;position:relative;overflow:hidden;border:1px solid var(--calcite-color-border-3);box-sizing:border-box;background-color:var(--calcite-color-foreground-1);height:100%}arcgis-arcade-editor .flex-adjustable{flex:1 1 auto;overflow:hidden}arcgis-arcade-editor .flex-panel{flex:1 0 auto}arcgis-arcade-editor .position-relative{position:relative}arcgis-arcade-editor .flex-row{display:flex;flex-direction:row;overflow:hidden}arcgis-arcade-editor .flex-column{display:flex;flex-direction:column;overflow:hidden}arcgis-arcade-editor .border-inline-start{border-inline-start:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .border-inline-end{border-inline-end:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .sticky{position:sticky;top:0px;z-index:10}arcgis-arcade-editor .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1);text-align:center}arcgis-arcade-editor .side-action-bar{max-width:25%}arcgis-arcade-editor .side-panel{max-width:45%;width:600px}arcgis-arcade-editor .side-panel calcite-flow{height:100%}arcgis-arcade-editor .main-action-bar{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}arcgis-arcade-editor .main-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}arcgis-arcade-editor .main-action-bar calcite-action-group:last-child{border-inline-end-width:0px}arcgis-arcade-editor .main-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}arcgis-arcade-editor arcgis-arcade-results{border-top:1px solid var(--calcite-color-border-3);box-sizing:border-box;max-height:50%;min-height:50%;margin-bottom:-1px}arcgis-arcade-editor calcite-flow [slot=footer]{word-break:break-word}";
|
|
3487
4773
|
|
|
3488
|
-
setupArcadeTheme();
|
|
3489
4774
|
const ArcgisArcadeEditor = class {
|
|
3490
4775
|
constructor(hostRef) {
|
|
3491
4776
|
registerInstance(this, hostRef);
|
|
3492
|
-
this.
|
|
3493
|
-
this.
|
|
3494
|
-
this.
|
|
3495
|
-
this.
|
|
4777
|
+
this.arcgisScriptChange = createEvent(this, "arcgisScriptChange", 3);
|
|
4778
|
+
this.arcgisDiagnosticsChange = createEvent(this, "arcgisDiagnosticsChange", 3);
|
|
4779
|
+
this.manager = useControllerManager(this);
|
|
4780
|
+
this._componentReadyDefer = new Deferred();
|
|
4781
|
+
this._modelId = generateGuid();
|
|
3496
4782
|
this._editorProfilePromise = Promise.resolve(undefined);
|
|
3497
4783
|
this._disposables = [];
|
|
3498
4784
|
this._executeScript = async () => {
|
|
@@ -3533,18 +4819,16 @@ const ArcgisArcadeEditor = class {
|
|
|
3533
4819
|
}
|
|
3534
4820
|
};
|
|
3535
4821
|
this._openArcadeHelp = () => void window.open(DevelopersWebSitePath, "Arcade Help");
|
|
3536
|
-
this.
|
|
4822
|
+
this._onCodeEditorValueChange = (e) => {
|
|
3537
4823
|
e.stopPropagation();
|
|
3538
|
-
this.
|
|
4824
|
+
this.script = e.detail;
|
|
4825
|
+
this.arcgisScriptChange.emit(e.detail);
|
|
3539
4826
|
};
|
|
3540
4827
|
this._insertAsSnippet = (e) => void this._codeEditorElt?.insertSnippet(e.detail).catch(console.error);
|
|
3541
4828
|
this._insertAsText = (e) => void this._codeEditorElt?.insertText(e.detail).catch(console.error);
|
|
3542
4829
|
this._onResultPanelChange = (e) => void (this._resultPanel = e.detail);
|
|
3543
4830
|
this._onExecutionPanelClose = () => void (this._showExecutionPanel = false);
|
|
3544
|
-
this.
|
|
3545
|
-
this._t9nLocale = "";
|
|
3546
|
-
this._t9nStrings = undefined;
|
|
3547
|
-
this._standaloneCodeEditor = undefined;
|
|
4831
|
+
this.messages = useT9n();
|
|
3548
4832
|
this._preparingProfile = false;
|
|
3549
4833
|
this._editorProfile = undefined;
|
|
3550
4834
|
this._showExecutionPanel = false;
|
|
@@ -3562,6 +4846,10 @@ const ArcgisArcadeEditor = class {
|
|
|
3562
4846
|
this.sideActionBarExpanded = false;
|
|
3563
4847
|
this.openedSidePanel = "none";
|
|
3564
4848
|
this.editorOptions = undefined;
|
|
4849
|
+
this.editorInstance = this.manager.getSet(undefined, {
|
|
4850
|
+
get: () => this._codeEditorElt?.editorInstance,
|
|
4851
|
+
set: "ignore",
|
|
4852
|
+
});
|
|
3565
4853
|
}
|
|
3566
4854
|
_profileChanged() {
|
|
3567
4855
|
this._updateEditorProfile().catch(console.error);
|
|
@@ -3574,18 +4862,17 @@ const ArcgisArcadeEditor = class {
|
|
|
3574
4862
|
}
|
|
3575
4863
|
_snippetChanged() {
|
|
3576
4864
|
arcadeDefaults.updateApiContextForModel(this._modelId, {
|
|
3577
|
-
snippets: this.snippets
|
|
4865
|
+
snippets: this.snippets,
|
|
3578
4866
|
});
|
|
3579
4867
|
}
|
|
3580
4868
|
// #endregion
|
|
3581
4869
|
// #region Public methods API
|
|
3582
4870
|
/**
|
|
3583
|
-
*
|
|
3584
|
-
* @returns {Promise<string>}
|
|
4871
|
+
* @deprecated Use `script` property instead.
|
|
3585
4872
|
*/
|
|
3586
4873
|
async getScript() {
|
|
3587
4874
|
await this._componentReadyDefer.promise;
|
|
3588
|
-
return
|
|
4875
|
+
return this._codeEditorElt?.value;
|
|
3589
4876
|
}
|
|
3590
4877
|
/**
|
|
3591
4878
|
* Set the focus on the element.
|
|
@@ -3596,12 +4883,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3596
4883
|
}
|
|
3597
4884
|
/**
|
|
3598
4885
|
* @internal
|
|
3599
|
-
*
|
|
3600
|
-
* @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
|
|
4886
|
+
* @deprecated Use `editorInstance` property instead.
|
|
3601
4887
|
*/
|
|
3602
4888
|
async getEditorInstance() {
|
|
3603
4889
|
await this._componentReadyDefer.promise;
|
|
3604
|
-
return
|
|
4890
|
+
return this._codeEditorElt?.editorInstance;
|
|
3605
4891
|
}
|
|
3606
4892
|
/**
|
|
3607
4893
|
* Returns the Arcade result for the script for the provided test data.
|
|
@@ -3623,11 +4909,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3623
4909
|
* @internal
|
|
3624
4910
|
*/
|
|
3625
4911
|
async updateThemeColors(colorRules) {
|
|
3626
|
-
const theme =
|
|
4912
|
+
const theme = getElementTheme(this.el);
|
|
3627
4913
|
updateThemeColors(theme, colorRules);
|
|
3628
4914
|
if (colorRules === undefined) {
|
|
3629
4915
|
colorRulesKeys.forEach((key) => {
|
|
3630
|
-
this.
|
|
4916
|
+
this.el.style.removeProperty(`--arcgis-arcade-editor-${key}`);
|
|
3631
4917
|
});
|
|
3632
4918
|
return;
|
|
3633
4919
|
}
|
|
@@ -3636,7 +4922,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3636
4922
|
if (!foreground) {
|
|
3637
4923
|
return;
|
|
3638
4924
|
}
|
|
3639
|
-
this.
|
|
4925
|
+
this.el.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
|
|
3640
4926
|
});
|
|
3641
4927
|
}
|
|
3642
4928
|
// #endregion
|
|
@@ -3644,14 +4930,13 @@ const ArcgisArcadeEditor = class {
|
|
|
3644
4930
|
async componentWillLoad() {
|
|
3645
4931
|
const assetsPath = getAssetPath("./assets");
|
|
3646
4932
|
// We are a bit in a chicken and egg situation here.
|
|
3647
|
-
// Normally, it is the code editor that is responsible for setting up the Monaco
|
|
4933
|
+
// Normally, it is the code editor that is responsible for setting up the Monaco environment.
|
|
3648
4934
|
// However, we need to setup the environment before the code editor is instantiated because
|
|
3649
4935
|
// we need to access the arcade language service to get the api library.
|
|
3650
4936
|
setupMonacoEnvironment(assetsPath);
|
|
3651
|
-
|
|
3652
|
-
//
|
|
3653
|
-
|
|
3654
|
-
await B(this, assetsPath, async () => await this._updateEditorProfile());
|
|
4937
|
+
await this._updateEditorProfile();
|
|
4938
|
+
// The profile has to be refreshed on locale change
|
|
4939
|
+
this.manager.watch("messages", () => void this._updateEditorProfile().catch(console.error));
|
|
3655
4940
|
}
|
|
3656
4941
|
async componentDidLoad() {
|
|
3657
4942
|
// Mark on component as ready.
|
|
@@ -3660,10 +4945,9 @@ const ArcgisArcadeEditor = class {
|
|
|
3660
4945
|
// Start listening to the validation diagnostics.
|
|
3661
4946
|
// We are doing this as late as possible
|
|
3662
4947
|
const diagnosticsService = await getArcadeDiagnosticService();
|
|
3663
|
-
this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.
|
|
4948
|
+
this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.arcgisDiagnosticsChange.emit(event.diagnostics)));
|
|
3664
4949
|
// Get editor instance and add action
|
|
3665
|
-
this.
|
|
3666
|
-
this._standaloneCodeEditor?.addAction({
|
|
4950
|
+
this.editorInstance?.addAction({
|
|
3667
4951
|
// An unique identifier for the action.
|
|
3668
4952
|
id: "run-script",
|
|
3669
4953
|
label: "Run Arcade Expression",
|
|
@@ -3674,12 +4958,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3674
4958
|
if (this.testData) {
|
|
3675
4959
|
this._executeScript().catch(console.error);
|
|
3676
4960
|
}
|
|
3677
|
-
}
|
|
4961
|
+
},
|
|
3678
4962
|
});
|
|
3679
4963
|
await this._codeEditorElt?.setFocus();
|
|
3680
4964
|
}
|
|
3681
4965
|
disconnectedCallback() {
|
|
3682
|
-
q(this);
|
|
3683
4966
|
arcadeDefaults.disposeApiContextForModel(this._modelId);
|
|
3684
4967
|
arcadeDefaults.disposeEditorProfileForModel(this._modelId);
|
|
3685
4968
|
while (this._disposables.length) {
|
|
@@ -3696,8 +4979,8 @@ const ArcgisArcadeEditor = class {
|
|
|
3696
4979
|
try {
|
|
3697
4980
|
// Set a new profile for the model using the profile definition and the locale.
|
|
3698
4981
|
await arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
|
|
3699
|
-
locale: this._t9nLocale,
|
|
3700
|
-
snippets: this.snippets
|
|
4982
|
+
locale: this.messages._t9nLocale,
|
|
4983
|
+
snippets: this.snippets,
|
|
3701
4984
|
});
|
|
3702
4985
|
// Get the corresponding editor profile for the model.
|
|
3703
4986
|
// The editor profile contains the specialized profile for the UI.
|
|
@@ -3717,16 +5000,16 @@ const ArcgisArcadeEditor = class {
|
|
|
3717
5000
|
if (!this.testData) {
|
|
3718
5001
|
return null;
|
|
3719
5002
|
}
|
|
3720
|
-
return (h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { text: this.
|
|
5003
|
+
return (h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { text: this.messages.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (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)));
|
|
3721
5004
|
}
|
|
3722
5005
|
//#endregion
|
|
3723
5006
|
//#region Render Main Panel
|
|
3724
5007
|
renderMainPanel() {
|
|
3725
|
-
return (h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions,
|
|
5008
|
+
return (h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions, onArcgisValueChange: this._onCodeEditorValueChange, ref: (e) => (this._codeEditorElt = e) }));
|
|
3726
5009
|
}
|
|
3727
5010
|
//#endregion
|
|
3728
5011
|
//#region Rendering the Action Bar
|
|
3729
|
-
renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel }) {
|
|
5012
|
+
renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel, }) {
|
|
3730
5013
|
return (h(Fragment, null, h("calcite-action", { id: id, text: label, icon: icon, active: active, onClick: onClick, "data-panel-name": panelName }), !this.sideActionBarExpanded && (h("calcite-tooltip", { label: label, "reference-element": id }, h("span", null, label)))));
|
|
3731
5014
|
}
|
|
3732
5015
|
renderSideActionBar() {
|
|
@@ -3735,33 +5018,33 @@ const ArcgisArcadeEditor = class {
|
|
|
3735
5018
|
}
|
|
3736
5019
|
return (h("calcite-action-bar", { class: "side-action-bar border-inline-start", expanded: !!this.sideActionBarExpanded, position: "end", onCalciteActionBarToggle: this._toggleSideActionBarExpanded }, h("calcite-action-group", null, this.renderAction({
|
|
3737
5020
|
id: "profile-variables-action",
|
|
3738
|
-
label: this.
|
|
5021
|
+
label: this.messages.profilevariables ?? "Profile variables",
|
|
3739
5022
|
icon: "profile-variables",
|
|
3740
5023
|
active: this.openedSidePanel === "variables",
|
|
3741
|
-
panelName: "variables"
|
|
5024
|
+
panelName: "variables",
|
|
3742
5025
|
}), this.renderAction({
|
|
3743
5026
|
id: "function-action",
|
|
3744
|
-
label: this.
|
|
5027
|
+
label: this.messages.constantsandfunctions ?? "Constants and functions",
|
|
3745
5028
|
icon: "function",
|
|
3746
5029
|
active: this.openedSidePanel === "api",
|
|
3747
|
-
panelName: "api"
|
|
5030
|
+
panelName: "api",
|
|
3748
5031
|
}), this.suggestions?.length
|
|
3749
5032
|
? this.renderAction({
|
|
3750
5033
|
id: "suggestions-action",
|
|
3751
|
-
label: this.
|
|
5034
|
+
label: this.messages.suggestions ?? "Suggestions",
|
|
3752
5035
|
icon: "lightbulb",
|
|
3753
5036
|
active: this.openedSidePanel === "suggestions",
|
|
3754
|
-
panelName: "suggestions"
|
|
5037
|
+
panelName: "suggestions",
|
|
3755
5038
|
})
|
|
3756
5039
|
: null, this.hideDocumentationActions
|
|
3757
5040
|
? null
|
|
3758
5041
|
: this.renderAction({
|
|
3759
5042
|
id: "developer-website-action",
|
|
3760
|
-
label: this.
|
|
5043
|
+
label: this.messages.help ?? "Help",
|
|
3761
5044
|
icon: "question",
|
|
3762
5045
|
active: false,
|
|
3763
5046
|
panelName: "none",
|
|
3764
|
-
onClick: this._openArcadeHelp
|
|
5047
|
+
onClick: this._openArcadeHelp,
|
|
3765
5048
|
}))));
|
|
3766
5049
|
}
|
|
3767
5050
|
//#endregion
|
|
@@ -3772,11 +5055,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3772
5055
|
}
|
|
3773
5056
|
switch (this.openedSidePanel) {
|
|
3774
5057
|
case "api":
|
|
3775
|
-
return (h("arcgis-arcade-api", { class: "side-panel flex-panel border-inline-start", modelId: this._modelId, hideDocumentationActions: this.hideDocumentationActions,
|
|
5058
|
+
return (h("arcgis-arcade-api", { class: "side-panel flex-panel border-inline-start", modelId: this._modelId, hideDocumentationActions: this.hideDocumentationActions, onArcgisItemSelected: this._insertAsSnippet, onArcgisClose: this._toggleSidePanel, "data-panel-name": "none" }));
|
|
3776
5059
|
case "variables":
|
|
3777
|
-
return (h("arcgis-arcade-variables", { class: "side-panel flex-panel border-inline-start", loading: this._preparingProfile, modelId: this._modelId,
|
|
5060
|
+
return (h("arcgis-arcade-variables", { class: "side-panel flex-panel border-inline-start", loading: this._preparingProfile, modelId: this._modelId, onArcgisItemSelected: this._insertAsText, onArcgisClose: this._toggleSidePanel, "data-panel-name": "none" }));
|
|
3778
5061
|
case "suggestions":
|
|
3779
|
-
return (h("arcgis-arcade-suggestions", { class: "side-panel flex-panel border-inline-start", suggestions: this.suggestions,
|
|
5062
|
+
return (h("arcgis-arcade-suggestions", { class: "side-panel flex-panel border-inline-start", suggestions: this.suggestions, onArcgisItemSelected: this._insertAsText, onArcgisClose: this._toggleSidePanel, "data-panel-name": "none" }));
|
|
3780
5063
|
default:
|
|
3781
5064
|
return null;
|
|
3782
5065
|
}
|
|
@@ -3787,7 +5070,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3787
5070
|
if (!this._showExecutionPanel) {
|
|
3788
5071
|
return null;
|
|
3789
5072
|
}
|
|
3790
|
-
return (h("arcgis-arcade-results", { class: "flex-adjustable", openedResultPanel: this._resultPanel, loading: this._executingScript, result: this._executionResult, consoleLogs: this._consoleLogs,
|
|
5073
|
+
return (h("arcgis-arcade-results", { class: "flex-adjustable", openedResultPanel: this._resultPanel, loading: this._executingScript, result: this._executionResult, consoleLogs: this._consoleLogs, onArcgisOpenedResultPanelChange: this._onResultPanelChange, onArcgisClose: this._onExecutionPanelClose }));
|
|
3791
5074
|
}
|
|
3792
5075
|
//#endregion
|
|
3793
5076
|
//#region Render
|
|
@@ -3795,7 +5078,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3795
5078
|
return (h(Host, null, this.renderMainActionBar(), h("div", { class: "flex-row flex-adjustable" }, h("div", { class: "flex-column flex-adjustable" }, this.renderMainPanel(), this.renderResultsPanel()), this.renderSidePanel(), this.renderSideActionBar())));
|
|
3796
5079
|
}
|
|
3797
5080
|
static get assetsDirs() { return ["assets"]; }
|
|
3798
|
-
get
|
|
5081
|
+
get el() { return getElement(this); }
|
|
3799
5082
|
static get watchers() { return {
|
|
3800
5083
|
"profile": ["_profileChanged"],
|
|
3801
5084
|
"testData": ["_testDataChanged"],
|
|
@@ -3804,20 +5087,20 @@ const ArcgisArcadeEditor = class {
|
|
|
3804
5087
|
};
|
|
3805
5088
|
ArcgisArcadeEditor.style = arcadeEditorCss;
|
|
3806
5089
|
|
|
3807
|
-
const arcadeResultsCss = ":host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2)}:host .flex-adjustable{flex:1 1 auto;overflow:hidden}:host .flex-row{display:flex;flex-direction:row;overflow:hidden}:host .flex-column{display:flex;flex-direction:column;overflow:hidden}:host .y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-color-foreground-1)}:host header{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}:host .ltr-container{direction:ltr}:host calcite-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-
|
|
5090
|
+
const arcadeResultsCss = ":host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2)}:host .flex-adjustable{flex:1 1 auto;overflow:hidden}:host .flex-row{display:flex;flex-direction:row;overflow:hidden}:host .flex-column{display:flex;flex-direction:column;overflow:hidden}:host .y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-color-foreground-1)}:host header{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}:host .ltr-container{direction:ltr}:host calcite-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}:host calcite-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}:host calcite-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}:host calcite-action-bar calcite-action-group:last-child{border-inline-end-width:0px}:host calcite-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .color-info{color:var(--calcite-color-status-info)}:host .color-error{color:var(--calcite-color-status-danger)}:host .color-success{color:var(--calcite-color-status-success)}:host [class*=result-value-]{font-size:var(--calcite-font-size--2);line-height:1.25rem;background-color:var(--calcite-color-foreground-1);margin:var(--calcite-spacing-md)}:host .console-logs-container{background-color:var(--calcite-color-foreground-1);padding:0 var(--calcite-spacing-md);font-family:var(--calcite-code-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal)}:host .result-value-table table{display:block;max-width:fit-content;overflow-x:auto;border-spacing:0;border-collapse:collapse;text-align:start;white-space:nowrap}:host .result-value-table table thead{background-color:var(--calcite-color-foreground-2)}:host .result-value-table table tr{border-top:1px solid var(--calcite-color-border-3);border-bottom:1px solid var(--calcite-color-border-3)}:host .result-value-table table th,:host .result-value-table table td{border-inline-start:1px solid var(--calcite-color-border-3);border-inline-end:1px solid var(--calcite-color-border-3);text-align:start;padding:var(--calcite-spacing-xxs)}:host .result-value-table table th .string-value,:host .result-value-table table td .string-value{white-space:pre}:host .result-value-table table th{font-weight:var(--calcite-font-weight-medium)}:host .tree-item-label,:host .number-value,:host .string-value,:host .boolean-value{font-family:var(--calcite-code-family)}:host .tree-item-label,:host .value-type{color:var(--calcite-color-text-2);font-weight:var(--calcite-font-weight-normal)}:host .dictionary-property{color:var(--arcgis-arcade-editor-identifier)}:host .number-value{color:var(--arcgis-arcade-editor-number)}:host .string-value{color:var(--arcgis-arcade-editor-string);white-space:pre-wrap}:host .constant-value{color:var(--arcgis-arcade-editor-constant)}:host .date-value{color:var(--arcgis-arcade-editor-date)}";
|
|
3808
5091
|
|
|
3809
5092
|
//#region Specialized Constants
|
|
3810
5093
|
const treeProps = {
|
|
3811
5094
|
lines: true,
|
|
3812
5095
|
selectionMode: "none",
|
|
3813
5096
|
scale: "s",
|
|
3814
|
-
onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false))
|
|
5097
|
+
onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false)),
|
|
3815
5098
|
};
|
|
3816
5099
|
const expandableTreeItemProps = {
|
|
3817
5100
|
onClick: (e) => {
|
|
3818
5101
|
const item = e.currentTarget;
|
|
3819
5102
|
item.expanded = !item.expanded;
|
|
3820
|
-
}
|
|
5103
|
+
},
|
|
3821
5104
|
};
|
|
3822
5105
|
//#endregion
|
|
3823
5106
|
//#region Helper Functions
|
|
@@ -3836,7 +5119,7 @@ function renderSimpleValue(arcadeResult) {
|
|
|
3836
5119
|
case "null":
|
|
3837
5120
|
return h("span", { class: "constant-value" }, arcadeResult.type);
|
|
3838
5121
|
case "text":
|
|
3839
|
-
return h("span", { class: "string-value" },
|
|
5122
|
+
return h("span", { class: "string-value" }, quoteString(arcadeResult.value));
|
|
3840
5123
|
case "number":
|
|
3841
5124
|
return h("span", { class: "number-value" }, arcadeResult.value.toString());
|
|
3842
5125
|
case "boolean":
|
|
@@ -3844,9 +5127,9 @@ function renderSimpleValue(arcadeResult) {
|
|
|
3844
5127
|
case "date":
|
|
3845
5128
|
return h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
|
|
3846
5129
|
case "dateOnly":
|
|
3847
|
-
return h("span", { class: "string-value" },
|
|
5130
|
+
return h("span", { class: "string-value" }, quoteString(formatArcadeResultDateOnly(arcadeResult)));
|
|
3848
5131
|
case "time":
|
|
3849
|
-
return h("span", { class: "string-value" },
|
|
5132
|
+
return h("span", { class: "string-value" }, quoteString(formatArcadeResultTimeOnly(arcadeResult)));
|
|
3850
5133
|
default:
|
|
3851
5134
|
return null;
|
|
3852
5135
|
}
|
|
@@ -3866,8 +5149,11 @@ function renderFeatureSetTable(arcadeResult) {
|
|
|
3866
5149
|
const ArcgisArcadeResults = class {
|
|
3867
5150
|
constructor(hostRef) {
|
|
3868
5151
|
registerInstance(this, hostRef);
|
|
3869
|
-
this.
|
|
3870
|
-
this.
|
|
5152
|
+
this.arcgisOpenedResultPanelChange = createEvent(this, "arcgisOpenedResultPanelChange", 3);
|
|
5153
|
+
this.arcgisClose = createEvent(this, "arcgisClose", 3);
|
|
5154
|
+
this.manager = useControllerManager(this);
|
|
5155
|
+
//#region Private Properties
|
|
5156
|
+
this.messages = useT9n();
|
|
3871
5157
|
this._switchResultPanel = (e) => {
|
|
3872
5158
|
if (!e.target) {
|
|
3873
5159
|
return;
|
|
@@ -3878,28 +5164,17 @@ const ArcgisArcadeResults = class {
|
|
|
3878
5164
|
}
|
|
3879
5165
|
this.updateResultPanel(panelName);
|
|
3880
5166
|
};
|
|
3881
|
-
this._emitClose = () => this.
|
|
3882
|
-
this._lang = "";
|
|
3883
|
-
this._t9nLocale = "";
|
|
3884
|
-
this._t9nStrings = undefined;
|
|
5167
|
+
this._emitClose = () => this.arcgisClose.emit();
|
|
3885
5168
|
this.loading = true;
|
|
3886
5169
|
this.openedResultPanel = "output";
|
|
3887
5170
|
this.result = undefined;
|
|
3888
5171
|
this.consoleLogs = undefined;
|
|
3889
5172
|
}
|
|
3890
5173
|
//#endregion
|
|
3891
|
-
// #region Component lifecycle events
|
|
3892
|
-
async componentWillLoad() {
|
|
3893
|
-
await B(this, getAssetPath("./assets"));
|
|
3894
|
-
}
|
|
3895
|
-
disconnectedCallback() {
|
|
3896
|
-
q(this);
|
|
3897
|
-
}
|
|
3898
|
-
// #endregion
|
|
3899
5174
|
//#region Private Methods
|
|
3900
5175
|
updateResultPanel(resultPanelType) {
|
|
3901
5176
|
this.openedResultPanel = resultPanelType;
|
|
3902
|
-
this.
|
|
5177
|
+
this.arcgisOpenedResultPanelChange.emit(resultPanelType);
|
|
3903
5178
|
}
|
|
3904
5179
|
//#endregion
|
|
3905
5180
|
//#region Rendering
|
|
@@ -3910,7 +5185,7 @@ const ArcgisArcadeResults = class {
|
|
|
3910
5185
|
if (this.loading && !this.consoleLogs?.length) {
|
|
3911
5186
|
return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
|
|
3912
5187
|
}
|
|
3913
|
-
return (h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ?
|
|
5188
|
+
return (h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? this.consoleLogs.map((log) => h("p", null, log)) : h("p", null, this.messages.consolemessage)));
|
|
3914
5189
|
}
|
|
3915
5190
|
renderLogPanel() {
|
|
3916
5191
|
if (this.openedResultPanel !== "log") {
|
|
@@ -3920,24 +5195,24 @@ const ArcgisArcadeResults = class {
|
|
|
3920
5195
|
return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
|
|
3921
5196
|
}
|
|
3922
5197
|
const iconClass = this.result?.type === "error" ? "color-error" : "color-success";
|
|
3923
|
-
return (h("calcite-list", null, this.result ? (h(Fragment, null, h("calcite-list-item", { label:
|
|
3924
|
-
timeStamp: new Intl.DateTimeFormat(this._t9nLocale, {
|
|
5198
|
+
return (h("calcite-list", null, this.result ? (h(Fragment, null, h("calcite-list-item", { label: setValuesInString(this.messages.lastexecutionformat, {
|
|
5199
|
+
timeStamp: new Intl.DateTimeFormat(this.messages._t9nLocale, {
|
|
3925
5200
|
dateStyle: "medium",
|
|
3926
|
-
timeStyle: "medium"
|
|
3927
|
-
}).format(this.result.timeStamp)
|
|
3928
|
-
}) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label:
|
|
3929
|
-
time: new Intl.NumberFormat(this._t9nLocale, {
|
|
5201
|
+
timeStyle: "medium",
|
|
5202
|
+
}).format(this.result.timeStamp),
|
|
5203
|
+
}) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: setValuesInString(this.messages.compilationtimeformat, {
|
|
5204
|
+
time: new Intl.NumberFormat(this.messages._t9nLocale, {
|
|
3930
5205
|
style: "unit",
|
|
3931
5206
|
unit: "millisecond",
|
|
3932
|
-
maximumFractionDigits: 2
|
|
3933
|
-
}).format(this.result.compilationTime ?? 0)
|
|
3934
|
-
}) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label:
|
|
3935
|
-
time: new Intl.NumberFormat(this._t9nLocale, {
|
|
5207
|
+
maximumFractionDigits: 2,
|
|
5208
|
+
}).format(this.result.compilationTime ?? 0),
|
|
5209
|
+
}) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: setValuesInString(this.messages.executiontimeformat, {
|
|
5210
|
+
time: new Intl.NumberFormat(this.messages._t9nLocale, {
|
|
3936
5211
|
style: "unit",
|
|
3937
5212
|
unit: "millisecond",
|
|
3938
|
-
maximumFractionDigits: 2
|
|
3939
|
-
}).format(this.result.executionTime ?? 0)
|
|
3940
|
-
}) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (h("calcite-list-item", { label: this.
|
|
5213
|
+
maximumFractionDigits: 2,
|
|
5214
|
+
}).format(this.result.executionTime ?? 0),
|
|
5215
|
+
}) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (h("calcite-list-item", { label: this.messages.runscriptmessage ?? "No output, run the script once." }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
|
|
3941
5216
|
}
|
|
3942
5217
|
renderOutputPanel() {
|
|
3943
5218
|
if (this.openedResultPanel !== "output") {
|
|
@@ -3948,8 +5223,8 @@ const ArcgisArcadeResults = class {
|
|
|
3948
5223
|
}
|
|
3949
5224
|
switch (this.result?.type) {
|
|
3950
5225
|
case "error":
|
|
3951
|
-
return (h("div", { class: "result-value-simple flex-adjustable" },
|
|
3952
|
-
message: this.result.value
|
|
5226
|
+
return (h("div", { class: "result-value-simple flex-adjustable" }, setValuesInString(this.messages.executionerrorformat, {
|
|
5227
|
+
message: this.result.value,
|
|
3953
5228
|
})));
|
|
3954
5229
|
case "null":
|
|
3955
5230
|
case "unknown":
|
|
@@ -3979,14 +5254,14 @@ const ArcgisArcadeResults = class {
|
|
|
3979
5254
|
case "knowledgeGraph":
|
|
3980
5255
|
return (h("div", { class: "result-value-simple ltr-container" }, h("span", { class: "value-type" }, this.result.type, ":\u00A0"), h("span", { class: "string-value" }, this.result.value.url)));
|
|
3981
5256
|
default:
|
|
3982
|
-
return
|
|
5257
|
+
return h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this.messages.runscriptmessage);
|
|
3983
5258
|
}
|
|
3984
5259
|
}
|
|
3985
5260
|
renderArrayHeader(arcadeResult) {
|
|
3986
5261
|
const items = arcadeResult.value ?? [];
|
|
3987
5262
|
const leftoverCount = Math.max(items.length - MaxArrayItems, 0);
|
|
3988
|
-
return (h(Fragment, null, h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (h("span", null, "\u00A0",
|
|
3989
|
-
count: MaxArrayItems.toString()
|
|
5263
|
+
return (h(Fragment, null, h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (h("span", null, "\u00A0", setValuesInString(this.messages.showingfirstitemsformat, {
|
|
5264
|
+
count: MaxArrayItems.toString(),
|
|
3990
5265
|
}))) : null));
|
|
3991
5266
|
}
|
|
3992
5267
|
renderArrayTree(items, subtree = false) {
|
|
@@ -4031,15 +5306,15 @@ const ArcgisArcadeResults = class {
|
|
|
4031
5306
|
}
|
|
4032
5307
|
}
|
|
4033
5308
|
renderFeatureSetLabel(arcadeResult) {
|
|
4034
|
-
return (h("div", { class: "value-type" }, h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (h("span", null, "\u00A0",
|
|
4035
|
-
count: BatchSize.toString()
|
|
5309
|
+
return (h("div", { class: "value-type" }, h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (h("span", null, "\u00A0", setValuesInString(this.messages.showingfirstitemsformat, {
|
|
5310
|
+
count: BatchSize.toString(),
|
|
4036
5311
|
}))) : null));
|
|
4037
5312
|
}
|
|
4038
5313
|
render() {
|
|
4039
|
-
return (h(Host, null, h("header", { class: "flex-row" }, h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { active: this.openedResultPanel === "output", text: this.
|
|
5314
|
+
return (h(Host, null, h("header", { class: "flex-row" }, h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, 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" }), 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" }), 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" }))), h("calcite-action", { scale: "s", icon: "x", text: this.messages.close ?? "", onClick: this._emitClose })), h("article", { class: "flex-adjustable" }, this.loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
|
|
4040
5315
|
}
|
|
4041
5316
|
static get assetsDirs() { return ["assets"]; }
|
|
4042
|
-
get
|
|
5317
|
+
get el() { return getElement(this); }
|
|
4043
5318
|
};
|
|
4044
5319
|
ArcgisArcadeResults.style = arcadeResultsCss;
|
|
4045
5320
|
|
|
@@ -4053,13 +5328,15 @@ function isSuggestionGroups(item) {
|
|
|
4053
5328
|
return Array.isArray(item[0].suggestions);
|
|
4054
5329
|
}
|
|
4055
5330
|
|
|
4056
|
-
const arcadeSuggestionsCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-
|
|
5331
|
+
const arcadeSuggestionsCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}:host calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}";
|
|
4057
5332
|
|
|
4058
5333
|
const ArcgisArcadeSuggestions = class {
|
|
4059
5334
|
constructor(hostRef) {
|
|
4060
5335
|
registerInstance(this, hostRef);
|
|
4061
|
-
this.
|
|
4062
|
-
this.
|
|
5336
|
+
this.arcgisClose = createEvent(this, "arcgisClose", 3);
|
|
5337
|
+
this.arcgisItemSelected = createEvent(this, "arcgisItemSelected", 3);
|
|
5338
|
+
this.manager = useControllerManager(this);
|
|
5339
|
+
this.messages = useT9n();
|
|
4063
5340
|
this._updateFilterValue = (e) => {
|
|
4064
5341
|
this._filterValue = e.target?.value ?? "";
|
|
4065
5342
|
};
|
|
@@ -4071,7 +5348,7 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4071
5348
|
const keyEvent = e;
|
|
4072
5349
|
if (!keyEvent.key || keyEvent.key === "Enter") {
|
|
4073
5350
|
e.preventDefault();
|
|
4074
|
-
this.
|
|
5351
|
+
this.arcgisItemSelected.emit(item.code);
|
|
4075
5352
|
}
|
|
4076
5353
|
};
|
|
4077
5354
|
this._showSuggestionDetail = (e) => {
|
|
@@ -4083,14 +5360,11 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4083
5360
|
this._selectedSuggestion = item;
|
|
4084
5361
|
};
|
|
4085
5362
|
this._emitClose = () => {
|
|
4086
|
-
this.
|
|
5363
|
+
this.arcgisClose.emit();
|
|
4087
5364
|
};
|
|
4088
5365
|
this._beforeBack = async () => {
|
|
4089
5366
|
this._selectedSuggestion = undefined;
|
|
4090
5367
|
};
|
|
4091
|
-
this._lang = "";
|
|
4092
|
-
this._t9nLocale = "";
|
|
4093
|
-
this._t9nStrings = undefined;
|
|
4094
5368
|
this._selectedSuggestion = undefined;
|
|
4095
5369
|
this._filterValue = "";
|
|
4096
5370
|
this._colorizeStyle = "";
|
|
@@ -4103,13 +5377,11 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4103
5377
|
// #region Component lifecycle events
|
|
4104
5378
|
async componentWillLoad() {
|
|
4105
5379
|
this._colorizeStyle = generateColorizeStyles();
|
|
4106
|
-
this.
|
|
4107
|
-
await B(this, getAssetPath("./assets"));
|
|
5380
|
+
this._themeChangedListener = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
|
|
4108
5381
|
}
|
|
4109
5382
|
disconnectedCallback() {
|
|
4110
5383
|
this._flowObserver?.disconnect();
|
|
4111
|
-
this.
|
|
4112
|
-
q(this);
|
|
5384
|
+
this._themeChangedListener?.dispose();
|
|
4113
5385
|
}
|
|
4114
5386
|
// #endregion
|
|
4115
5387
|
//#region Private Methods
|
|
@@ -4127,7 +5399,7 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4127
5399
|
// When switching between flow the same reference is reused
|
|
4128
5400
|
this._flowObserver = new MutationObserver(() => {
|
|
4129
5401
|
// Get the last panel and try to set focus on the input element
|
|
4130
|
-
|
|
5402
|
+
setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
|
|
4131
5403
|
});
|
|
4132
5404
|
this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
|
|
4133
5405
|
}
|
|
@@ -4145,29 +5417,29 @@ const ArcgisArcadeSuggestions = class {
|
|
|
4145
5417
|
renderSuggestionListItems(suggestions) {
|
|
4146
5418
|
suggestions = filterCollection(suggestions, "label", this._filterValue);
|
|
4147
5419
|
if (!suggestions.length) {
|
|
4148
|
-
return h("div", { class: "notice-container" }, this.
|
|
5420
|
+
return h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
|
|
4149
5421
|
}
|
|
4150
|
-
return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this.
|
|
5422
|
+
return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
|
|
4151
5423
|
}
|
|
4152
5424
|
renderSuggestionFlowItem() {
|
|
4153
5425
|
const suggestion = this._selectedSuggestion;
|
|
4154
5426
|
if (!suggestion) {
|
|
4155
5427
|
return null;
|
|
4156
5428
|
}
|
|
4157
|
-
return (h("calcite-flow-item", { heading: this.
|
|
5429
|
+
return (h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, 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), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: (e) => e === undefined ? undefined : void colorizeCodeElement(e, suggestion.code).catch(console.error) })))));
|
|
4158
5430
|
}
|
|
4159
5431
|
render() {
|
|
4160
|
-
return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this.
|
|
5432
|
+
return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
|
|
4161
5433
|
}
|
|
4162
5434
|
static get assetsDirs() { return ["assets"]; }
|
|
4163
|
-
get
|
|
5435
|
+
get el() { return getElement(this); }
|
|
4164
5436
|
static get watchers() { return {
|
|
4165
5437
|
"suggestions": ["suggestionsPropChanged"]
|
|
4166
5438
|
}; }
|
|
4167
5439
|
};
|
|
4168
5440
|
ArcgisArcadeSuggestions.style = arcadeSuggestionsCss;
|
|
4169
5441
|
|
|
4170
|
-
const arcadeVariablesCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-
|
|
5442
|
+
const arcadeVariablesCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}";
|
|
4171
5443
|
|
|
4172
5444
|
function stopEnterPropagation(e) {
|
|
4173
5445
|
if (e.key === "Enter") {
|
|
@@ -4177,8 +5449,10 @@ function stopEnterPropagation(e) {
|
|
|
4177
5449
|
const ArcgisArcadeVariables = class {
|
|
4178
5450
|
constructor(hostRef) {
|
|
4179
5451
|
registerInstance(this, hostRef);
|
|
4180
|
-
this.
|
|
4181
|
-
this.
|
|
5452
|
+
this.arcgisClose = createEvent(this, "arcgisClose", 3);
|
|
5453
|
+
this.arcgisItemSelected = createEvent(this, "arcgisItemSelected", 3);
|
|
5454
|
+
this.manager = useControllerManager(this);
|
|
5455
|
+
this.messages = useT9n();
|
|
4182
5456
|
this._updateFilterValue = (e) => {
|
|
4183
5457
|
this._filterValue = e.target.value;
|
|
4184
5458
|
};
|
|
@@ -4187,7 +5461,7 @@ const ArcgisArcadeVariables = class {
|
|
|
4187
5461
|
this._filterValue = "";
|
|
4188
5462
|
};
|
|
4189
5463
|
this._emitClose = () => {
|
|
4190
|
-
this.
|
|
5464
|
+
this.arcgisClose.emit();
|
|
4191
5465
|
};
|
|
4192
5466
|
this._backToTop = () => {
|
|
4193
5467
|
this._flowItemRenderers = [];
|
|
@@ -4200,7 +5474,7 @@ const ArcgisArcadeVariables = class {
|
|
|
4200
5474
|
const keyEvent = e;
|
|
4201
5475
|
if (!keyEvent.key || keyEvent.key === "Enter") {
|
|
4202
5476
|
e.preventDefault();
|
|
4203
|
-
this.
|
|
5477
|
+
this.arcgisItemSelected.emit(variable.snippet);
|
|
4204
5478
|
}
|
|
4205
5479
|
};
|
|
4206
5480
|
this._showCollectionPanel = (e) => {
|
|
@@ -4211,9 +5485,6 @@ const ArcgisArcadeVariables = class {
|
|
|
4211
5485
|
e.stopPropagation();
|
|
4212
5486
|
this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
|
|
4213
5487
|
};
|
|
4214
|
-
this._lang = "";
|
|
4215
|
-
this._t9nLocale = "";
|
|
4216
|
-
this._t9nStrings = undefined;
|
|
4217
5488
|
this._mutationCounter = 1;
|
|
4218
5489
|
this._flowItemRenderers = [];
|
|
4219
5490
|
this._filterValue = "";
|
|
@@ -4224,12 +5495,7 @@ const ArcgisArcadeVariables = class {
|
|
|
4224
5495
|
this._flowItemRenderers = [];
|
|
4225
5496
|
}
|
|
4226
5497
|
//#endregion
|
|
4227
|
-
// #region Component lifecycle events
|
|
4228
|
-
async componentWillLoad() {
|
|
4229
|
-
await B(this, getAssetPath("./assets"));
|
|
4230
|
-
}
|
|
4231
5498
|
disconnectedCallback() {
|
|
4232
|
-
q(this);
|
|
4233
5499
|
this._flowObserver?.disconnect();
|
|
4234
5500
|
}
|
|
4235
5501
|
// #endregion
|
|
@@ -4254,7 +5520,7 @@ const ArcgisArcadeVariables = class {
|
|
|
4254
5520
|
// When switching between flow the same reference is reused
|
|
4255
5521
|
this._flowObserver = new MutationObserver(() => {
|
|
4256
5522
|
// Get the last panel and try to set focus on the input element
|
|
4257
|
-
|
|
5523
|
+
setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
|
|
4258
5524
|
});
|
|
4259
5525
|
this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
|
|
4260
5526
|
}
|
|
@@ -4283,15 +5549,15 @@ const ArcgisArcadeVariables = class {
|
|
|
4283
5549
|
});
|
|
4284
5550
|
loading = true;
|
|
4285
5551
|
}
|
|
4286
|
-
return (h("calcite-flow-item", { heading: this.
|
|
5552
|
+
return (h("calcite-flow-item", { heading: this.messages.profilevariables, description: collection.breadcrumb, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, 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 }), h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
|
|
4287
5553
|
};
|
|
4288
5554
|
}
|
|
4289
5555
|
renderEditorVariables(collection) {
|
|
4290
5556
|
// Filter the variables. Skip group, we will filter the children later on.
|
|
4291
|
-
const filterExpression =
|
|
5557
|
+
const filterExpression = createFilterExpression(this._filterValue);
|
|
4292
5558
|
const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
|
|
4293
5559
|
if (!filteredVariables.length) {
|
|
4294
|
-
return h("div", { class: "notice-container" }, this.
|
|
5560
|
+
return h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
|
|
4295
5561
|
}
|
|
4296
5562
|
return filteredVariables.map((variable) => this.renderEditorVariable(variable));
|
|
4297
5563
|
}
|
|
@@ -4301,18 +5567,18 @@ const ArcgisArcadeVariables = class {
|
|
|
4301
5567
|
// Group is a collection but we represent it differently
|
|
4302
5568
|
return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
|
|
4303
5569
|
default:
|
|
4304
|
-
return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this.
|
|
5570
|
+
return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (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 ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
|
|
4305
5571
|
}
|
|
4306
5572
|
}
|
|
4307
5573
|
render() {
|
|
4308
5574
|
const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
|
|
4309
5575
|
if (!this.loading && !profile?.variables.length) {
|
|
4310
|
-
return (h("calcite-flow", null, h("calcite-flow-item", { heading: this.
|
|
5576
|
+
return (h("calcite-flow", null, h("calcite-flow-item", { heading: this.messages.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this.messages.noprofilevariablesmessage ?? ""))));
|
|
4311
5577
|
}
|
|
4312
5578
|
return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
|
|
4313
5579
|
}
|
|
4314
5580
|
static get assetsDirs() { return ["assets"]; }
|
|
4315
|
-
get
|
|
5581
|
+
get el() { return getElement(this); }
|
|
4316
5582
|
static get watchers() { return {
|
|
4317
5583
|
"modelId": ["modelIdPropChanged"]
|
|
4318
5584
|
}; }
|
|
@@ -4330,74 +5596,74 @@ const EditorOptionsDefaults = {
|
|
|
4330
5596
|
renderLineHighlight: "none",
|
|
4331
5597
|
suggest: {
|
|
4332
5598
|
snippetsPreventQuickSuggestions: false,
|
|
4333
|
-
showWords: false
|
|
5599
|
+
showWords: false,
|
|
4334
5600
|
},
|
|
4335
5601
|
tabSize: 2,
|
|
4336
|
-
useShadowDOM: true
|
|
5602
|
+
useShadowDOM: true,
|
|
4337
5603
|
};
|
|
4338
5604
|
const ArcgisCodeEditor = class {
|
|
4339
5605
|
constructor(hostRef) {
|
|
4340
5606
|
registerInstance(this, hostRef);
|
|
4341
|
-
this.
|
|
4342
|
-
this.
|
|
5607
|
+
this.arcgisValueChange = createEvent(this, "arcgisValueChange", 3);
|
|
5608
|
+
this.arcgisSelectionChange = createEvent(this, "arcgisSelectionChange", 3);
|
|
5609
|
+
this.manager = useControllerManager(this);
|
|
5610
|
+
this._componentReadyDefer = new Deferred();
|
|
4343
5611
|
this._disposables = [];
|
|
4344
|
-
this.value =
|
|
5612
|
+
this.value = this.manager.getSet("", {
|
|
5613
|
+
set: (newValue) => {
|
|
5614
|
+
newValue ?? (newValue = "");
|
|
5615
|
+
if (!this._editorInstance) {
|
|
5616
|
+
return newValue;
|
|
5617
|
+
}
|
|
5618
|
+
const model = this._editorInstance.getModel();
|
|
5619
|
+
if (!model) {
|
|
5620
|
+
return newValue;
|
|
5621
|
+
}
|
|
5622
|
+
if (model.getValue() === newValue) {
|
|
5623
|
+
return newValue;
|
|
5624
|
+
}
|
|
5625
|
+
// Set the value and preserve the undo stack
|
|
5626
|
+
const range = model.getFullModelRange();
|
|
5627
|
+
this._editorInstance.executeEdits("", [{ range, text: newValue, forceMoveMarkers: true }]);
|
|
5628
|
+
this._editorInstance.pushUndoStop();
|
|
5629
|
+
return newValue;
|
|
5630
|
+
},
|
|
5631
|
+
});
|
|
4345
5632
|
this.language = undefined;
|
|
4346
|
-
this.modelId =
|
|
5633
|
+
this.modelId = generateGuid();
|
|
4347
5634
|
this.options = undefined;
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
}
|
|
4353
|
-
this._editorInstance.setValue(newValue ?? "");
|
|
5635
|
+
this.editorInstance = this.manager.getSet(undefined, {
|
|
5636
|
+
get: () => this._editorInstance,
|
|
5637
|
+
set: (_value, prevValue) => prevValue,
|
|
5638
|
+
});
|
|
4354
5639
|
}
|
|
4355
5640
|
languagePropChange() {
|
|
4356
|
-
if (!this._editorInstance) {
|
|
4357
|
-
return;
|
|
4358
|
-
}
|
|
4359
5641
|
this.updateModel();
|
|
4360
5642
|
}
|
|
4361
5643
|
modelIdPropChange() {
|
|
4362
|
-
if (!this._editorInstance) {
|
|
4363
|
-
return;
|
|
4364
|
-
}
|
|
4365
5644
|
this.updateModel();
|
|
4366
5645
|
}
|
|
4367
5646
|
optionsPropChange(newValue) {
|
|
4368
|
-
if (!
|
|
5647
|
+
if (!newValue) {
|
|
4369
5648
|
return;
|
|
4370
5649
|
}
|
|
4371
|
-
this._editorInstance
|
|
5650
|
+
this._editorInstance?.updateOptions(newValue);
|
|
4372
5651
|
}
|
|
4373
5652
|
//#endregion
|
|
4374
5653
|
// #region Public methods API
|
|
4375
5654
|
/**
|
|
4376
|
-
*
|
|
4377
|
-
* @returns {Promise<string>}
|
|
5655
|
+
* @deprecated Use `value` property instead.
|
|
4378
5656
|
*/
|
|
4379
5657
|
async getValue() {
|
|
4380
5658
|
await this._componentReadyDefer.promise;
|
|
4381
|
-
return this.
|
|
5659
|
+
return this.value;
|
|
4382
5660
|
}
|
|
4383
5661
|
/**
|
|
4384
|
-
*
|
|
4385
|
-
* on the model to preserve undo/redo stack.
|
|
4386
|
-
* @param text
|
|
4387
|
-
* @returns {Promise<void>}
|
|
5662
|
+
* @deprecated Use `value` property instead.
|
|
4388
5663
|
*/
|
|
4389
5664
|
async setValue(text) {
|
|
4390
5665
|
await this._componentReadyDefer.promise;
|
|
4391
|
-
|
|
4392
|
-
return;
|
|
4393
|
-
}
|
|
4394
|
-
const model = this._editorInstance.getModel();
|
|
4395
|
-
if (!model) {
|
|
4396
|
-
return;
|
|
4397
|
-
}
|
|
4398
|
-
const range = model.getFullModelRange();
|
|
4399
|
-
this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
|
|
4400
|
-
this._editorInstance.pushUndoStop();
|
|
5666
|
+
this.value = text ?? "";
|
|
4401
5667
|
}
|
|
4402
5668
|
/**
|
|
4403
5669
|
* Inserts a text at the current position in the editor.
|
|
@@ -4432,8 +5698,7 @@ const ArcgisCodeEditor = class {
|
|
|
4432
5698
|
}
|
|
4433
5699
|
/**
|
|
4434
5700
|
* @internal
|
|
4435
|
-
*
|
|
4436
|
-
* @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
|
|
5701
|
+
* @deprecated Use `editorInstance` property instead.
|
|
4437
5702
|
*/
|
|
4438
5703
|
async getEditorInstance() {
|
|
4439
5704
|
await this._componentReadyDefer.promise;
|
|
@@ -4464,33 +5729,33 @@ const ArcgisCodeEditor = class {
|
|
|
4464
5729
|
// Create the model without the value.
|
|
4465
5730
|
// Since it's not yet attached to the editor the diagnostic service will not process it.
|
|
4466
5731
|
// We will set the value after the editor has been created to trigger the diagnostic again.
|
|
4467
|
-
const model = editor.createModel(
|
|
5732
|
+
const model = editor.createModel(this.value, this.language, this.getUri());
|
|
4468
5733
|
// Create the editor for the host element.
|
|
4469
5734
|
// This will not trigger a diagnostic.
|
|
4470
|
-
this._editorInstance = editor.create(this.
|
|
5735
|
+
this._editorInstance = editor.create(this.el, {
|
|
4471
5736
|
...(this.options ?? {}),
|
|
4472
5737
|
model,
|
|
4473
5738
|
fixedOverflowWidgets: true,
|
|
4474
|
-
scrollBeyondLastLine: false
|
|
5739
|
+
scrollBeyondLastLine: false,
|
|
4475
5740
|
});
|
|
4476
5741
|
this._disposables.push(this._editorInstance);
|
|
4477
|
-
//
|
|
4478
|
-
model.setValue(this.value ?? "");
|
|
4479
|
-
// Now we can set are component as ready
|
|
5742
|
+
// Now we indicate that the component is ready
|
|
4480
5743
|
this._componentReadyDefer.resolve();
|
|
4481
5744
|
this._editorInstance.updateOptions(EditorOptionsDefaults);
|
|
4482
|
-
// Listen to the Monaco Editor content change event and propagate
|
|
4483
5745
|
this._editorInstance.onDidChangeModelContent(() => {
|
|
4484
|
-
|
|
4485
|
-
this.
|
|
5746
|
+
this.value = this._editorInstance?.getValue() ?? "";
|
|
5747
|
+
this.arcgisValueChange.emit(this.value);
|
|
5748
|
+
});
|
|
5749
|
+
this._editorInstance.onDidChangeCursorSelection((e) => {
|
|
5750
|
+
this.arcgisSelectionChange.emit({ selection: e.selection, model: this._editorInstance?.getModel() });
|
|
4486
5751
|
});
|
|
4487
5752
|
// Detect if the host element or its ancestors got a theme attribute mutation
|
|
4488
|
-
this._themeObserver =
|
|
5753
|
+
this._themeObserver = observeAncestorsMutation(this.el, ["class"], () => this.updateTheme());
|
|
4489
5754
|
// Update the theme of the Monaco Editor
|
|
4490
5755
|
this.updateTheme();
|
|
4491
5756
|
// Creates a resize observer to re-layout the editor on size changing
|
|
4492
5757
|
const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
|
|
4493
|
-
resizeObserver.observe(this.
|
|
5758
|
+
resizeObserver.observe(this.el);
|
|
4494
5759
|
// Add common actions to the Monaco Editor's context menu and command palette
|
|
4495
5760
|
this.addCommonEditorActions();
|
|
4496
5761
|
}
|
|
@@ -4498,7 +5763,14 @@ const ArcgisCodeEditor = class {
|
|
|
4498
5763
|
while (this._disposables.length) {
|
|
4499
5764
|
this._disposables.pop()?.dispose();
|
|
4500
5765
|
}
|
|
4501
|
-
this._themeObserver?.
|
|
5766
|
+
this._themeObserver?.remove();
|
|
5767
|
+
}
|
|
5768
|
+
componentShouldUpdate(_newVal, _oldVal, propName) {
|
|
5769
|
+
if (propName === "value" || propName === "language" || propName === "modelId" || propName === "options") {
|
|
5770
|
+
// These are properties that we directly pass to the editor
|
|
5771
|
+
return false;
|
|
5772
|
+
}
|
|
5773
|
+
return true;
|
|
4502
5774
|
}
|
|
4503
5775
|
//#endregion
|
|
4504
5776
|
// #region Private methods API
|
|
@@ -4507,7 +5779,7 @@ const ArcgisCodeEditor = class {
|
|
|
4507
5779
|
return;
|
|
4508
5780
|
}
|
|
4509
5781
|
this._editorInstance.getModel()?.dispose();
|
|
4510
|
-
this._editorInstance.setModel(editor.createModel(this.value
|
|
5782
|
+
this._editorInstance.setModel(editor.createModel(this.value, this.language, this.getUri()));
|
|
4511
5783
|
}
|
|
4512
5784
|
getUri() {
|
|
4513
5785
|
return this.modelId ? Uri.parse(this.modelId) : Uri.parse("");
|
|
@@ -4516,7 +5788,7 @@ const ArcgisCodeEditor = class {
|
|
|
4516
5788
|
// This is called the first time and subsequently by the Mutation Observer
|
|
4517
5789
|
// Figure out the theme by walking the ancestor path.
|
|
4518
5790
|
// If no theme is found then default to light.
|
|
4519
|
-
const theme =
|
|
5791
|
+
const theme = getElementTheme(this.el) === "light" ? "vs" : "vs-dark";
|
|
4520
5792
|
if (theme === this._currentTheme) {
|
|
4521
5793
|
return;
|
|
4522
5794
|
}
|
|
@@ -4541,7 +5813,7 @@ const ArcgisCodeEditor = class {
|
|
|
4541
5813
|
contextMenuOrder: 1,
|
|
4542
5814
|
// Method that will be executed when the action is triggered.
|
|
4543
5815
|
// @param editor The editor instance is passed in as a convenience
|
|
4544
|
-
run: async () => await zoomInFn?.run()
|
|
5816
|
+
run: async () => await zoomInFn?.run(),
|
|
4545
5817
|
});
|
|
4546
5818
|
this._editorInstance?.addAction({
|
|
4547
5819
|
id: "editor.action.fontZoomOut",
|
|
@@ -4549,7 +5821,7 @@ const ArcgisCodeEditor = class {
|
|
|
4549
5821
|
keybindings: [KeyMod.CtrlCmd | KeyCode.Minus],
|
|
4550
5822
|
contextMenuGroupId: "zooming",
|
|
4551
5823
|
contextMenuOrder: 2,
|
|
4552
|
-
run: async () => await zoomOutFn?.run()
|
|
5824
|
+
run: async () => await zoomOutFn?.run(),
|
|
4553
5825
|
});
|
|
4554
5826
|
}
|
|
4555
5827
|
//#endregion
|
|
@@ -4558,9 +5830,8 @@ const ArcgisCodeEditor = class {
|
|
|
4558
5830
|
return h(Host, null);
|
|
4559
5831
|
}
|
|
4560
5832
|
static get assetsDirs() { return ["assets"]; }
|
|
4561
|
-
get
|
|
5833
|
+
get el() { return getElement(this); }
|
|
4562
5834
|
static get watchers() { return {
|
|
4563
|
-
"value": ["valuePropChange"],
|
|
4564
5835
|
"language": ["languagePropChange"],
|
|
4565
5836
|
"modelId": ["modelIdPropChange"],
|
|
4566
5837
|
"options": ["optionsPropChange"]
|