@arcgis/coding-components 4.29.0-beta.47 → 4.29.0-beta.49

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.
Files changed (94) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
  2. package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +13 -13
  3. package/dist/arcgis-coding-components/index.esm.js +1 -1
  4. package/dist/arcgis-coding-components/{p-10a322ec.js → p-0d616249.js} +9 -9
  5. package/dist/arcgis-coding-components/p-2c0d6f15.js +2 -0
  6. package/dist/arcgis-coding-components/{p-71faf9a4.js → p-5802524a.js} +1 -1
  7. package/dist/arcgis-coding-components/{p-9eabda86.js → p-5ddccf04.js} +1 -1
  8. package/dist/arcgis-coding-components/p-7475f3a6.js +1 -0
  9. package/dist/arcgis-coding-components/{p-e6ede32d.js → p-7d8caba9.js} +1 -1
  10. package/dist/arcgis-coding-components/{p-f7d7d78d.js → p-9f6db08a.js} +1 -1
  11. package/dist/arcgis-coding-components/{p-e475e6cd.js → p-aefe77ce.js} +1 -1
  12. package/dist/arcgis-coding-components/p-ce2be55e.entry.js +1 -0
  13. package/dist/arcgis-coding-components/{p-ce586a8c.js → p-d425a387.js} +1 -1
  14. package/dist/arcgis-coding-components/{p-c084ada8.js → p-ff21f230.js} +1 -1
  15. package/dist/cjs/{arcade-defaults-8445d852.js → arcade-defaults-2d513b59.js} +1534 -1534
  16. package/dist/cjs/arcade-mode-6219f1b8.js +599 -0
  17. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1404 -1408
  18. package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
  19. package/dist/cjs/{cssMode-e63287bb.js → cssMode-1ec48254.js} +2 -2
  20. package/dist/cjs/{html-c0d4db3b.js → html-0e1741fe.js} +2 -2
  21. package/dist/cjs/{htmlMode-fdc44d57.js → htmlMode-279d3c29.js} +2 -2
  22. package/dist/cjs/{index-6a382a34.js → index-ac186201.js} +67 -24
  23. package/dist/cjs/index.cjs.js +2 -2
  24. package/dist/cjs/{javascript-a419d064.js → javascript-04f1bce0.js} +3 -3
  25. package/dist/cjs/{jsonMode-73aee5d2.js → jsonMode-59322f7a.js} +2 -2
  26. package/dist/cjs/loader.cjs.js +1 -1
  27. package/dist/cjs/{tsMode-37d1b053.js → tsMode-17561f70.js} +2 -2
  28. package/dist/cjs/{typescript-53f9f36a.js → typescript-b7da8629.js} +2 -2
  29. package/dist/components/arcade-api.js +160 -160
  30. package/dist/components/arcade-contribution.js +60 -60
  31. package/dist/components/arcade-defaults.js +1240 -1240
  32. package/dist/components/arcade-mode.js +514 -513
  33. package/dist/components/arcade-results.js +426 -430
  34. package/dist/components/arcade-suggestions.js +130 -132
  35. package/dist/components/arcade-variables.js +157 -155
  36. package/dist/components/arcgis-arcade-api.d.ts +2 -2
  37. package/dist/components/arcgis-arcade-editor.d.ts +2 -2
  38. package/dist/components/arcgis-arcade-editor.js +391 -391
  39. package/dist/components/arcgis-arcade-results.d.ts +2 -2
  40. package/dist/components/arcgis-arcade-suggestions.d.ts +2 -2
  41. package/dist/components/arcgis-arcade-variables.d.ts +2 -2
  42. package/dist/components/arcgis-code-editor.d.ts +2 -2
  43. package/dist/components/code-editor.js +251 -251
  44. package/dist/components/fields.js +69 -69
  45. package/dist/components/functional-components.js +1 -1
  46. package/dist/components/index2.js +2 -2
  47. package/dist/components/markdown.js +28 -28
  48. package/dist/components/utilities.js +20 -20
  49. package/dist/esm/{arcade-defaults-d7893362.js → arcade-defaults-0bafa696.js} +1534 -1534
  50. package/dist/esm/arcade-mode-c17a1fa1.js +595 -0
  51. package/dist/esm/arcgis-arcade-api_6.entry.js +1404 -1408
  52. package/dist/esm/arcgis-coding-components.js +3 -3
  53. package/dist/esm/{cssMode-b1771f92.js → cssMode-3d18bd2b.js} +2 -2
  54. package/dist/esm/{html-af635d52.js → html-2bce5d77.js} +2 -2
  55. package/dist/esm/{htmlMode-3021c301.js → htmlMode-69d56956.js} +2 -2
  56. package/dist/esm/{index-fd6b2fd8.js → index-022fb97b.js} +67 -24
  57. package/dist/esm/index.js +2 -2
  58. package/dist/esm/{javascript-70589186.js → javascript-ded5c9d7.js} +3 -3
  59. package/dist/esm/{jsonMode-cb509b79.js → jsonMode-0bf84cb2.js} +2 -2
  60. package/dist/esm/loader.js +2 -2
  61. package/dist/esm/{tsMode-ed90c9aa.js → tsMode-15d4e936.js} +2 -2
  62. package/dist/esm/{typescript-db8a0b18.js → typescript-cc4d00f0.js} +2 -2
  63. package/dist/types/components/arcade-api/arcade-api.d.ts +40 -40
  64. package/dist/types/components/arcade-api/t9n-types.d.ts +6 -6
  65. package/dist/types/components/arcade-editor/arcade-editor.d.ts +127 -127
  66. package/dist/types/components/arcade-editor/t9n-types.d.ts +6 -6
  67. package/dist/types/components/arcade-results/arcade-results.d.ts +47 -47
  68. package/dist/types/components/arcade-results/t9n-types.d.ts +11 -11
  69. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +34 -34
  70. package/dist/types/components/arcade-suggestions/t9n-types.d.ts +4 -4
  71. package/dist/types/components/arcade-variables/arcade-variables.d.ts +41 -41
  72. package/dist/types/components/arcade-variables/t9n-types.d.ts +6 -6
  73. package/dist/types/components/code-editor/code-editor.d.ts +73 -73
  74. package/dist/types/stencil-public-runtime.d.ts +8 -0
  75. package/dist/types/utils/arcade-executor.d.ts +79 -79
  76. package/dist/types/utils/arcade-monaco/arcade-defaults.d.ts +66 -66
  77. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +23 -23
  78. package/dist/types/utils/arcade-monaco/arcade-mode.d.ts +9 -9
  79. package/dist/types/utils/arcade-monaco/arcade-theme.d.ts +7 -7
  80. package/dist/types/utils/arcade-monaco/arcade-worker-manager.d.ts +9 -9
  81. package/dist/types/utils/arcade-monaco/arcade.worker.d.ts +12 -12
  82. package/dist/types/utils/arcade-monaco/types.d.ts +29 -29
  83. package/dist/types/utils/editor-suggestions.d.ts +24 -24
  84. package/dist/types/utils/functional-components.d.ts +1 -1
  85. package/dist/types/utils/markdown.d.ts +1 -1
  86. package/dist/types/utils/profile/editor-profile.d.ts +185 -185
  87. package/dist/types/utils/profile/types.d.ts +101 -101
  88. package/dist/types/utils/utilities.d.ts +1 -1
  89. package/package.json +7 -7
  90. package/dist/arcgis-coding-components/p-5d670bd2.js +0 -2
  91. package/dist/arcgis-coding-components/p-9e242e76.js +0 -1
  92. package/dist/arcgis-coding-components/p-ccdf0ac1.entry.js +0 -1
  93. package/dist/cjs/arcade-mode-b77afcc9.js +0 -598
  94. package/dist/esm/arcade-mode-70e22d22.js +0 -594
@@ -2,8 +2,8 @@ import type { Components, JSX } from "../types/components";
2
2
 
3
3
  interface ArcgisArcadeResults extends Components.ArcgisArcadeResults, HTMLElement {}
4
4
  export const ArcgisArcadeResults: {
5
- prototype: ArcgisArcadeResults;
6
- new (): ArcgisArcadeResults;
5
+ prototype: ArcgisArcadeResults;
6
+ new (): ArcgisArcadeResults;
7
7
  };
8
8
  /**
9
9
  * Used to define this component and all nested components recursively.
@@ -2,8 +2,8 @@ import type { Components, JSX } from "../types/components";
2
2
 
3
3
  interface ArcgisArcadeSuggestions extends Components.ArcgisArcadeSuggestions, HTMLElement {}
4
4
  export const ArcgisArcadeSuggestions: {
5
- prototype: ArcgisArcadeSuggestions;
6
- new (): ArcgisArcadeSuggestions;
5
+ prototype: ArcgisArcadeSuggestions;
6
+ new (): ArcgisArcadeSuggestions;
7
7
  };
8
8
  /**
9
9
  * Used to define this component and all nested components recursively.
@@ -2,8 +2,8 @@ import type { Components, JSX } from "../types/components";
2
2
 
3
3
  interface ArcgisArcadeVariables extends Components.ArcgisArcadeVariables, HTMLElement {}
4
4
  export const ArcgisArcadeVariables: {
5
- prototype: ArcgisArcadeVariables;
6
- new (): ArcgisArcadeVariables;
5
+ prototype: ArcgisArcadeVariables;
6
+ new (): ArcgisArcadeVariables;
7
7
  };
8
8
  /**
9
9
  * Used to define this component and all nested components recursively.
@@ -2,8 +2,8 @@ import type { Components, JSX } from "../types/components";
2
2
 
3
3
  interface ArcgisCodeEditor extends Components.ArcgisCodeEditor, HTMLElement {}
4
4
  export const ArcgisCodeEditor: {
5
- prototype: ArcgisCodeEditor;
6
- new (): ArcgisCodeEditor;
5
+ prototype: ArcgisCodeEditor;
6
+ new (): ArcgisCodeEditor;
7
7
  };
8
8
  /**
9
9
  * Used to define this component and all nested components recursively.
@@ -7,272 +7,272 @@ const codeEditorCss = "@charset \"UTF-8\";.monaco-action-bar{white-space:nowrap;
7
7
 
8
8
  // Our default options for the Editor
9
9
  const EditorOptionsDefaults = {
10
- autoIndent: "advanced",
11
- automaticLayout: true,
12
- bracketPairColorization: { enabled: true },
13
- minimap: { enabled: false },
14
- renderLineHighlight: "none",
15
- suggest: {
16
- snippetsPreventQuickSuggestions: false,
17
- showWords: false
18
- },
19
- tabSize: 2,
20
- useShadowDOM: true
10
+ autoIndent: "advanced",
11
+ automaticLayout: true,
12
+ bracketPairColorization: { enabled: true },
13
+ minimap: { enabled: false },
14
+ renderLineHighlight: "none",
15
+ suggest: {
16
+ snippetsPreventQuickSuggestions: false,
17
+ showWords: false
18
+ },
19
+ tabSize: 2,
20
+ useShadowDOM: true
21
21
  };
22
22
  const ArcgisCodeEditor = /*@__PURE__*/ proxyCustomElement(class ArcgisCodeEditor extends HTMLElement {
23
- constructor() {
24
- super();
25
- this.__registerHost();
26
- this.valueChange = createEvent(this, "valueChange", 3);
27
- this._componentReadyDefer = new p();
28
- this._disposables = [];
29
- this.value = undefined;
30
- this.language = undefined;
31
- this.modelId = "";
32
- }
33
- valuePropChange(newValue, oldValue) {
34
- if (!this._editorInstance || newValue === oldValue) {
35
- return;
23
+ constructor() {
24
+ super();
25
+ this.__registerHost();
26
+ this.valueChange = createEvent(this, "valueChange", 3);
27
+ this._componentReadyDefer = new p();
28
+ this._disposables = [];
29
+ this.value = undefined;
30
+ this.language = undefined;
31
+ this.modelId = "";
36
32
  }
37
- this._editorInstance.setValue(newValue ?? "");
38
- }
39
- languagePropChange(newValue, oldValue) {
40
- if (!this._editorInstance || newValue === oldValue) {
41
- return;
33
+ valuePropChange(newValue, oldValue) {
34
+ if (!this._editorInstance || newValue === oldValue) {
35
+ return;
36
+ }
37
+ this._editorInstance.setValue(newValue ?? "");
42
38
  }
43
- this.updateModel();
44
- }
45
- modelIdPropChange(newValue, oldValue) {
46
- if (!this._editorInstance || newValue === oldValue) {
47
- return;
39
+ languagePropChange(newValue, oldValue) {
40
+ if (!this._editorInstance || newValue === oldValue) {
41
+ return;
42
+ }
43
+ this.updateModel();
48
44
  }
49
- this.updateModel();
50
- }
51
- //#endregion
52
- // #region Public methods API
53
- /**
54
- * Gets the current value in the editor.
55
- * @returns {Promise<string>}
56
- */
57
- async getValue() {
58
- await this._componentReadyDefer.promise;
59
- return this._editorInstance?.getValue() ?? "";
60
- }
61
- /**
62
- * Sets the new value in the editor. Use this method instead of setting the value
63
- * on the model to preserve undo/redo stack.
64
- * @param text
65
- * @returns {Promise<void>}
66
- */
67
- async setValue(text) {
68
- await this._componentReadyDefer.promise;
69
- if (!this._editorInstance) {
70
- return;
45
+ modelIdPropChange(newValue, oldValue) {
46
+ if (!this._editorInstance || newValue === oldValue) {
47
+ return;
48
+ }
49
+ this.updateModel();
71
50
  }
72
- const model = this._editorInstance.getModel();
73
- if (!model) {
74
- return;
51
+ //#endregion
52
+ // #region Public methods API
53
+ /**
54
+ * Gets the current value in the editor.
55
+ * @returns {Promise<string>}
56
+ */
57
+ async getValue() {
58
+ await this._componentReadyDefer.promise;
59
+ return this._editorInstance?.getValue() ?? "";
75
60
  }
76
- const range = model.getFullModelRange();
77
- this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
78
- this._editorInstance.pushUndoStop();
79
- }
80
- /**
81
- * Inserts a text at the current position in the editor.
82
- * @param {string} text - The string to insert
83
- * @returns {Promise<void>}
84
- */
85
- async insertText(text) {
86
- await this._componentReadyDefer.promise;
87
- if (!this._editorInstance) {
88
- return;
61
+ /**
62
+ * Sets the new value in the editor. Use this method instead of setting the value
63
+ * on the model to preserve undo/redo stack.
64
+ * @param text
65
+ * @returns {Promise<void>}
66
+ */
67
+ async setValue(text) {
68
+ await this._componentReadyDefer.promise;
69
+ if (!this._editorInstance) {
70
+ return;
71
+ }
72
+ const model = this._editorInstance.getModel();
73
+ if (!model) {
74
+ return;
75
+ }
76
+ const range = model.getFullModelRange();
77
+ this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
78
+ this._editorInstance.pushUndoStop();
89
79
  }
90
- const model = this._editorInstance.getModel();
91
- if (!model) {
92
- return;
80
+ /**
81
+ * Inserts a text at the current position in the editor.
82
+ * @param {string} text - The string to insert
83
+ * @returns {Promise<void>}
84
+ */
85
+ async insertText(text) {
86
+ await this._componentReadyDefer.promise;
87
+ if (!this._editorInstance) {
88
+ return;
89
+ }
90
+ const model = this._editorInstance.getModel();
91
+ if (!model) {
92
+ return;
93
+ }
94
+ const range = this._editorInstance.getSelection() ?? new Range(1, 1, 1, 1);
95
+ this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
93
96
  }
94
- const range = this._editorInstance.getSelection() ?? new Range(1, 1, 1, 1);
95
- this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
96
- }
97
- /**
98
- * Inserts a snippet at the current position in the editor.
99
- * @param {string} text - The string snippet to insert
100
- * @returns {Promise<void>}
101
- */
102
- async insertSnippet(text) {
103
- await this._componentReadyDefer.promise;
104
- if (!this._editorInstance) {
105
- return;
97
+ /**
98
+ * Inserts a snippet at the current position in the editor.
99
+ * @param {string} text - The string snippet to insert
100
+ * @returns {Promise<void>}
101
+ */
102
+ async insertSnippet(text) {
103
+ await this._componentReadyDefer.promise;
104
+ if (!this._editorInstance) {
105
+ return;
106
+ }
107
+ const snippetController = this._editorInstance.getContribution("snippetController2");
108
+ snippetController.insert(text ?? "");
109
+ this._editorInstance.focus();
106
110
  }
107
- const snippetController = this._editorInstance.getContribution("snippetController2");
108
- snippetController.insert(text ?? "");
109
- this._editorInstance.focus();
110
- }
111
- /**
112
- * @internal
113
- * Returns the editor instance.
114
- * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
115
- */
116
- async getEditorInstance() {
117
- await this._componentReadyDefer.promise;
118
- return this._editorInstance;
119
- }
120
- /**
121
- * Sets the focus on the editor.
122
- * @returns {Promise<void>}
123
- */
124
- async setFocus() {
125
- await this._componentReadyDefer.promise;
126
- this._editorInstance?.focus();
127
- }
128
- //#endregion
129
- //#region Listeners
130
- //#endregion
131
- // #region Component lifecycle events
132
- componentWillLoad() {
133
- // Define the Monaco environemt.
134
- // Can only do this when assets path has been defined.
135
- // If we were placing this logic in connectedCallback, assets path would have not yet been defined.
136
- // setupMonacoEnvironment will not redefine if already defined.
137
- setupMonacoEnvironment(getAssetPath("./assets"));
138
- }
139
- componentDidLoad() {
140
- // Create and attach and instance of Monaco Editor to the inner element
141
- editor.getModel(this.getUri())?.dispose();
142
- // Create the model without the value.
143
- // Since it's not yet attached to the editor the diagnostic service will not process it.
144
- // We will set the value after the editor has been created to trigger the diagnostic again.
145
- const model = editor.createModel("", this.language, this.getUri());
146
- // Create the editor for the host element.
147
- // This will not trigger a diagnostic.
148
- this._editorInstance = editor.create(this._hostElt, {
149
- model,
150
- fixedOverflowWidgets: true,
151
- scrollBeyondLastLine: false
152
- });
153
- this._disposables.push(this._editorInstance);
154
- // Set the value now to trigger a diagnostic again
155
- model.setValue(this.value ?? "");
156
- // Now we can set are component as ready
157
- this._componentReadyDefer.resolve();
158
- this._editorInstance.updateOptions(EditorOptionsDefaults);
159
- // Listen to the Monaco Editor content change event and propagate
160
- this._editorInstance.onDidChangeModelContent(() => {
161
- const script = this._editorInstance?.getValue() ?? "";
162
- this.valueChange.emit(script);
163
- });
164
- // Detect if the host element or its ancestors got a theme attribute mutation
165
- this._themeObserver = T(this._hostElt, ["class"], () => this.updateTheme());
166
- // Update the theme of the Monaco Editor
167
- this.updateTheme();
168
- // Creates a resize observer to re-layout the editor on size changing
169
- const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
170
- resizeObserver.observe(this._hostElt);
171
- // Add common actions to the Monaco Editor's context menu and command palette
172
- this.addCommonEditorActions();
173
- }
174
- disconnectedCallback() {
175
- while (this._disposables.length) {
176
- this._disposables.pop()?.dispose();
111
+ /**
112
+ * @internal
113
+ * Returns the editor instance.
114
+ * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
115
+ */
116
+ async getEditorInstance() {
117
+ await this._componentReadyDefer.promise;
118
+ return this._editorInstance;
177
119
  }
178
- this._themeObserver?.disconnect();
179
- }
180
- //#endregion
181
- // #region Private methods API
182
- updateModel() {
183
- if (!this._editorInstance) {
184
- return;
120
+ /**
121
+ * Sets the focus on the editor.
122
+ * @returns {Promise<void>}
123
+ */
124
+ async setFocus() {
125
+ await this._componentReadyDefer.promise;
126
+ this._editorInstance?.focus();
185
127
  }
186
- this._editorInstance.getModel()?.dispose();
187
- this._editorInstance.setModel(editor.createModel(this.value ?? "", this.language, this.getUri()));
188
- }
189
- getUri() {
190
- return this.modelId ? Uri.parse(this.modelId) : Uri.parse("");
191
- }
192
- updateTheme() {
193
- // This is called the first time and subsequently by the Mutation Observer
194
- // Figure out the theme by walking the ancestor path.
195
- // If no theme is found then default to light.
196
- const theme = P(this._hostElt) === "light" ? "vs" : "vs-dark";
197
- if (theme === this._currentTheme) {
198
- return;
128
+ //#endregion
129
+ //#region Listeners
130
+ //#endregion
131
+ // #region Component lifecycle events
132
+ componentWillLoad() {
133
+ // Define the Monaco environemt.
134
+ // Can only do this when assets path has been defined.
135
+ // If we were placing this logic in connectedCallback, assets path would have not yet been defined.
136
+ // setupMonacoEnvironment will not redefine if already defined.
137
+ setupMonacoEnvironment(getAssetPath("./assets"));
199
138
  }
200
- this._currentTheme = theme;
201
- editor.setTheme(theme);
202
- }
203
- //#endregion
204
- // #region Private methods API
205
- addCommonEditorActions() {
206
- // Copy zoom in / out command functions
207
- const zoomInFn = this._editorInstance?.getAction("editor.action.fontZoomIn");
208
- const zoomOutFn = this._editorInstance?.getAction("editor.action.fontZoomOut");
209
- // Override the two existing commands so that they appear in the context menu
210
- this._editorInstance?.addAction({
211
- // Use an existing action's ID to override it
212
- id: "editor.action.fontZoomIn",
213
- // A label of the action that will be presented to the user.
214
- label: "Editor Font Zoom In",
215
- // An optional array of keybindings for the action.
216
- keybindings: [KeyMod.CtrlCmd | KeyCode.Equal],
217
- contextMenuGroupId: "zooming",
218
- contextMenuOrder: 1,
219
- // Method that will be executed when the action is triggered.
220
- // @param editor The editor instance is passed in as a convenience
221
- run: () => {
222
- zoomInFn?.run();
223
- }
224
- });
225
- this._editorInstance?.addAction({
226
- id: "editor.action.fontZoomOut",
227
- label: "Editor Font Zoom Out",
228
- keybindings: [KeyMod.CtrlCmd | KeyCode.Minus],
229
- contextMenuGroupId: "zooming",
230
- contextMenuOrder: 2,
231
- run: () => {
232
- zoomOutFn?.run();
233
- }
234
- });
235
- }
236
- //#endregion
237
- // #region Rendering
238
- render() {
239
- return h(Host, null);
240
- }
241
- static get assetsDirs() { return ["assets"]; }
242
- get _hostElt() { return this; }
243
- static get watchers() { return {
244
- "value": ["valuePropChange"],
245
- "language": ["languagePropChange"],
246
- "modelId": ["modelIdPropChange"]
247
- }; }
248
- static get style() { return codeEditorCss; }
139
+ componentDidLoad() {
140
+ // Create and attach and instance of Monaco Editor to the inner element
141
+ editor.getModel(this.getUri())?.dispose();
142
+ // Create the model without the value.
143
+ // Since it's not yet attached to the editor the diagnostic service will not process it.
144
+ // We will set the value after the editor has been created to trigger the diagnostic again.
145
+ const model = editor.createModel("", this.language, this.getUri());
146
+ // Create the editor for the host element.
147
+ // This will not trigger a diagnostic.
148
+ this._editorInstance = editor.create(this._hostElt, {
149
+ model,
150
+ fixedOverflowWidgets: true,
151
+ scrollBeyondLastLine: false
152
+ });
153
+ this._disposables.push(this._editorInstance);
154
+ // Set the value now to trigger a diagnostic again
155
+ model.setValue(this.value ?? "");
156
+ // Now we can set are component as ready
157
+ this._componentReadyDefer.resolve();
158
+ this._editorInstance.updateOptions(EditorOptionsDefaults);
159
+ // Listen to the Monaco Editor content change event and propagate
160
+ this._editorInstance.onDidChangeModelContent(() => {
161
+ const script = this._editorInstance?.getValue() ?? "";
162
+ this.valueChange.emit(script);
163
+ });
164
+ // Detect if the host element or its ancestors got a theme attribute mutation
165
+ this._themeObserver = T(this._hostElt, ["class"], () => this.updateTheme());
166
+ // Update the theme of the Monaco Editor
167
+ this.updateTheme();
168
+ // Creates a resize observer to re-layout the editor on size changing
169
+ const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
170
+ resizeObserver.observe(this._hostElt);
171
+ // Add common actions to the Monaco Editor's context menu and command palette
172
+ this.addCommonEditorActions();
173
+ }
174
+ disconnectedCallback() {
175
+ while (this._disposables.length) {
176
+ this._disposables.pop()?.dispose();
177
+ }
178
+ this._themeObserver?.disconnect();
179
+ }
180
+ //#endregion
181
+ // #region Private methods API
182
+ updateModel() {
183
+ if (!this._editorInstance) {
184
+ return;
185
+ }
186
+ this._editorInstance.getModel()?.dispose();
187
+ this._editorInstance.setModel(editor.createModel(this.value ?? "", this.language, this.getUri()));
188
+ }
189
+ getUri() {
190
+ return this.modelId ? Uri.parse(this.modelId) : Uri.parse("");
191
+ }
192
+ updateTheme() {
193
+ // This is called the first time and subsequently by the Mutation Observer
194
+ // Figure out the theme by walking the ancestor path.
195
+ // If no theme is found then default to light.
196
+ const theme = P(this._hostElt) === "light" ? "vs" : "vs-dark";
197
+ if (theme === this._currentTheme) {
198
+ return;
199
+ }
200
+ this._currentTheme = theme;
201
+ editor.setTheme(theme);
202
+ }
203
+ //#endregion
204
+ // #region Private methods API
205
+ addCommonEditorActions() {
206
+ // Copy zoom in / out command functions
207
+ const zoomInFn = this._editorInstance?.getAction("editor.action.fontZoomIn");
208
+ const zoomOutFn = this._editorInstance?.getAction("editor.action.fontZoomOut");
209
+ // Override the two existing commands so that they appear in the context menu
210
+ this._editorInstance?.addAction({
211
+ // Use an existing action's ID to override it
212
+ id: "editor.action.fontZoomIn",
213
+ // A label of the action that will be presented to the user.
214
+ label: "Editor Font Zoom In",
215
+ // An optional array of keybindings for the action.
216
+ keybindings: [KeyMod.CtrlCmd | KeyCode.Equal],
217
+ contextMenuGroupId: "zooming",
218
+ contextMenuOrder: 1,
219
+ // Method that will be executed when the action is triggered.
220
+ // @param editor The editor instance is passed in as a convenience
221
+ run: () => {
222
+ zoomInFn?.run();
223
+ }
224
+ });
225
+ this._editorInstance?.addAction({
226
+ id: "editor.action.fontZoomOut",
227
+ label: "Editor Font Zoom Out",
228
+ keybindings: [KeyMod.CtrlCmd | KeyCode.Minus],
229
+ contextMenuGroupId: "zooming",
230
+ contextMenuOrder: 2,
231
+ run: () => {
232
+ zoomOutFn?.run();
233
+ }
234
+ });
235
+ }
236
+ //#endregion
237
+ // #region Rendering
238
+ render() {
239
+ return h(Host, null);
240
+ }
241
+ static get assetsDirs() { return ["assets"]; }
242
+ get _hostElt() { return this; }
243
+ static get watchers() { return {
244
+ "value": ["valuePropChange"],
245
+ "language": ["languagePropChange"],
246
+ "modelId": ["modelIdPropChange"]
247
+ }; }
248
+ static get style() { return codeEditorCss; }
249
249
  }, [0, "arcgis-code-editor", {
250
- "value": [1],
251
- "language": [1],
252
- "modelId": [1, "model-id"],
253
- "getValue": [64],
254
- "setValue": [64],
255
- "insertText": [64],
256
- "insertSnippet": [64],
257
- "getEditorInstance": [64],
258
- "setFocus": [64]
259
- }, undefined, {
260
- "value": ["valuePropChange"],
261
- "language": ["languagePropChange"],
262
- "modelId": ["modelIdPropChange"]
263
- }]);
250
+ "value": [1],
251
+ "language": [1],
252
+ "modelId": [1, "model-id"],
253
+ "getValue": [64],
254
+ "setValue": [64],
255
+ "insertText": [64],
256
+ "insertSnippet": [64],
257
+ "getEditorInstance": [64],
258
+ "setFocus": [64]
259
+ }, undefined, {
260
+ "value": ["valuePropChange"],
261
+ "language": ["languagePropChange"],
262
+ "modelId": ["modelIdPropChange"]
263
+ }]);
264
264
  function defineCustomElement() {
265
- if (typeof customElements === "undefined") {
266
- return;
267
- }
268
- const components = ["arcgis-code-editor"];
269
- components.forEach(tagName => { switch (tagName) {
270
- case "arcgis-code-editor":
271
- if (!customElements.get(tagName)) {
272
- customElements.define(tagName, ArcgisCodeEditor);
273
- }
274
- break;
275
- } });
265
+ if (typeof customElements === "undefined") {
266
+ return;
267
+ }
268
+ const components = ["arcgis-code-editor"];
269
+ components.forEach(tagName => { switch (tagName) {
270
+ case "arcgis-code-editor":
271
+ if (!customElements.get(tagName)) {
272
+ customElements.define(tagName, ArcgisCodeEditor);
273
+ }
274
+ break;
275
+ } });
276
276
  }
277
277
  defineCustomElement();
278
278