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