@arcgis/coding-components 5.1.0-next.1 → 5.1.0-next.3
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/cdn/GNJO6WNS.js +2 -0
- package/dist/cdn/{ASVCAO4G.js → HC6SQXXT.js} +1 -1
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +56 -51
- package/dist/components/arcgis-arcade-editor/customElement.js +65 -56
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/cdn/6QWZ6LSH.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { g as
|
|
3
|
-
import { css as
|
|
4
|
-
import { KeyCode as
|
|
2
|
+
import { g as y, c as I } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as D, html as s, nothing as P } from "lit";
|
|
4
|
+
import { KeyCode as C } from "monaco-editor";
|
|
5
5
|
import "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js";
|
|
6
6
|
import "monaco-editor/esm/vs/editor/standalone/common/standaloneTheme.js";
|
|
7
7
|
import "monaco-editor/esm/vs/platform/hover/browser/hover.js";
|
|
@@ -9,50 +9,59 @@ import "monaco-editor/esm/vs/editor/common/languages/supports/tokenization.js";
|
|
|
9
9
|
import "monaco-editor/esm/vs/base/browser/dom.js";
|
|
10
10
|
import "monaco-editor/esm/vs/editor/browser/editorDom.js";
|
|
11
11
|
import "monaco-editor/esm/vs/editor/browser/controller/mouseTarget.js";
|
|
12
|
-
import { LitElement as
|
|
13
|
-
import { generateGuid as
|
|
14
|
-
import { D as
|
|
15
|
-
import { s as
|
|
16
|
-
import { b as
|
|
17
|
-
import { u as
|
|
18
|
-
import { createRef as
|
|
19
|
-
import
|
|
20
|
-
import { log as
|
|
21
|
-
const
|
|
22
|
-
const { aiAssistantsEnabled: e } =
|
|
12
|
+
import { LitElement as B, createEvent as b, safeClassMap as l } from "@arcgis/lumina";
|
|
13
|
+
import { generateGuid as k } from "@arcgis/toolkit/string";
|
|
14
|
+
import { D as M, e as v } from "../../chunks/arcade-executor.js";
|
|
15
|
+
import { s as T, g as L } from "../../chunks/arcade-service-accessors.js";
|
|
16
|
+
import { b as c } from "../../chunks/arcade-defaults.js";
|
|
17
|
+
import { u as U } from "../../chunks/useT9n.js";
|
|
18
|
+
import { createRef as F, ref as N } from "lit/directives/ref.js";
|
|
19
|
+
import x from "@arcgis/core/identity/IdentityManager.js";
|
|
20
|
+
import { log as H, rethrowError as o } from "@arcgis/toolkit/log";
|
|
21
|
+
const O = D`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}.main-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}`, j = "https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0", a = (i, e) => H(i, "Arcade Assistant", e), z = (i) => {
|
|
22
|
+
const { aiAssistantsEnabled: e } = i;
|
|
23
23
|
return e === void 0 ? (a("warn", "`areAiAssistantsEnabled` is not defined in the organizations settings."), !1) : e;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
}, V = (i) => !(!i || !("id" in i)), G = async (i) => (await x.getCredential(i, { oAuthPopupConfirmation: !1 })).token, q = async (i) => {
|
|
25
|
+
try {
|
|
26
|
+
return !!await x.checkSignInStatus(i);
|
|
27
|
+
} catch {
|
|
28
|
+
return a("warn", "User is not signed in."), !1;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
async function X({
|
|
32
|
+
portalUrl: i,
|
|
27
33
|
profile: e
|
|
28
34
|
}) {
|
|
29
|
-
if (!
|
|
35
|
+
if (!V(e))
|
|
30
36
|
return a("warn", "Addon initialization failed. Reason: unsupported profile."), { shouldRender: !1 };
|
|
31
|
-
const t =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const t = i.replace(/\/sharing\/rest(\/.*)?$/iu, "").replace(/\/$/u, "");
|
|
38
|
+
if (!await q(t))
|
|
39
|
+
return { shouldRender: !1 };
|
|
40
|
+
const n = await G(i), h = `${t}/sharing/rest/portals/self?f=json&token=${n}`, p = `${t}/sharing/rest/portals/self/settings?f=json&token=${n}`, u = `${t}/sharing/rest/portals/self/signinSettings?f=json&token=${n}`, E = await Promise.allSettled([
|
|
41
|
+
fetch(h, { credentials: "include" }).then((r) => r.json()),
|
|
42
|
+
fetch(p, { credentials: "include" }).then((r) => r.json()),
|
|
43
|
+
fetch(u, { credentials: "include" }).then((r) => r.json())
|
|
44
|
+
]), [g, f, _] = E, m = g.status === "fulfilled" ? g.value : (a("warn", `Failed to fetch selfUrl. Reason: ${g.reason}.`), {}), S = f.status === "fulfilled" ? f.value : (a("warn", `Failed to fetch settingsUrl. Reason: ${f.reason}.`), {}), R = _.status === "fulfilled" ? _.value : (a("warn", `Failed to fetch signinSettingsUrl. Reason: ${_.reason}.`), {}), $ = m?.helperServices?.aiAssistantServices?.url;
|
|
39
45
|
if (!$)
|
|
46
|
+
return a("warn", "Service URL is not available in the portal self response."), { shouldRender: !1 };
|
|
47
|
+
const w = m.helpBase || "";
|
|
48
|
+
if (!S)
|
|
40
49
|
return a("warn", "Settings response is not available."), { shouldRender: !1 };
|
|
41
|
-
let A =
|
|
42
|
-
return
|
|
50
|
+
let A = z(S);
|
|
51
|
+
return R.blockBetaApps === !0 && (a(
|
|
43
52
|
"warn",
|
|
44
53
|
"Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."
|
|
45
54
|
), A = !1), m?.user?.privileges?.includes("portal:user:useAIAssistants") || (a("warn", "User does not have the required privileges to use AI Assistants."), A = !1), {
|
|
46
55
|
shouldRender: !0,
|
|
47
|
-
serviceUrl:
|
|
48
|
-
helpBase:
|
|
56
|
+
serviceUrl: $,
|
|
57
|
+
helpBase: w,
|
|
49
58
|
assistantsEnabled: A,
|
|
50
|
-
feedbackServiceUrl:
|
|
59
|
+
feedbackServiceUrl: j
|
|
51
60
|
};
|
|
52
61
|
}
|
|
53
|
-
class
|
|
62
|
+
class K extends B {
|
|
54
63
|
constructor() {
|
|
55
|
-
super(...arguments), this._codeEditorElt =
|
|
64
|
+
super(...arguments), this._codeEditorElt = F(), this._componentReadyDefer = Promise.withResolvers(), this._disposables = [], this._editorProfilePromise = Promise.resolve(void 0), this.messages = U(), this._modelId = k(), this._openArcadeHelp = () => void window.open(M, "Arcade Help"), this._toggleSidePanel = (e) => {
|
|
56
65
|
if (!e.target)
|
|
57
66
|
return;
|
|
58
67
|
const t = e.target?.dataset.panelName ?? "none";
|
|
@@ -63,7 +72,7 @@ class q extends C {
|
|
|
63
72
|
this.properties = { _apiLibrary: 16, _consoleLogs: 16, _editorProfile: 16, _executingScript: 16, _executionResult: 16, _preparingArcade: 16, _resultPanel: 16, _showExecutionPanel: 16, _arcadeAssistantRemoteState: 16, editorInstance: 32, editorOptions: 0, hideDocumentationActions: 5, hideSideBar: 5, openedSidePanel: 3, profile: 0, script: 1, sideActionBarExpanded: 7, snippets: 0, suggestions: 0, testData: 0, customPanels: 0, arcadeAssistant: 0 };
|
|
64
73
|
}
|
|
65
74
|
static {
|
|
66
|
-
this.styles = [
|
|
75
|
+
this.styles = [O];
|
|
67
76
|
}
|
|
68
77
|
get editorInstance() {
|
|
69
78
|
return this._codeEditorElt.value?.editorInstance;
|
|
@@ -82,17 +91,17 @@ class q extends C {
|
|
|
82
91
|
await this._componentReadyDefer.promise, await this._codeEditorElt.value?.setFocus();
|
|
83
92
|
}
|
|
84
93
|
async load() {
|
|
85
|
-
const e =
|
|
86
|
-
|
|
94
|
+
const e = y("./assets");
|
|
95
|
+
T(e), await this._updateDataModelDeps(), await this._updateArcadeAssistantRemoteState();
|
|
87
96
|
}
|
|
88
97
|
willUpdate(e) {
|
|
89
|
-
(e.has("messages") || e.has("profile")) && this.hasUpdated && this._updateDataModelDeps(), e.has("testData") && this._testDataChanged(), e.has("snippets") &&
|
|
98
|
+
(e.has("messages") || e.has("profile")) && this.hasUpdated && this._updateDataModelDeps(), e.has("testData") && this._testDataChanged(), e.has("snippets") && c.updateApiContextForModel(this._modelId, {
|
|
90
99
|
snippets: this.snippets
|
|
91
100
|
}), e.has("arcadeAssistant") && this._updateArcadeAssistantRemoteState();
|
|
92
101
|
}
|
|
93
102
|
async loaded() {
|
|
94
103
|
this._componentReadyDefer.resolve(), await this._updateApiLibrary();
|
|
95
|
-
const e = await
|
|
104
|
+
const e = await L();
|
|
96
105
|
this._disposables.push(e.onDiagnosticsChange((t) => !this._preparingArcade && this.arcgisDiagnosticsChange.emit(t.diagnostics))), this.testData && this._addExecuteScriptAction();
|
|
97
106
|
}
|
|
98
107
|
disconnectedCallback() {
|
|
@@ -108,10 +117,10 @@ class q extends C {
|
|
|
108
117
|
async _updateEditorProfile() {
|
|
109
118
|
this._preparingArcade = !0;
|
|
110
119
|
try {
|
|
111
|
-
await
|
|
120
|
+
await c.setProfileForModel(this._modelId, this.profile, {
|
|
112
121
|
locale: this.messages._t9nLocale,
|
|
113
122
|
snippets: this.snippets
|
|
114
|
-
}), this._editorProfile =
|
|
123
|
+
}), this._editorProfile = c.getEditorProfileForModel(this._modelId);
|
|
115
124
|
} catch {
|
|
116
125
|
this._editorProfile = void 0;
|
|
117
126
|
} finally {
|
|
@@ -119,7 +128,7 @@ class q extends C {
|
|
|
119
128
|
}
|
|
120
129
|
}
|
|
121
130
|
async _updateApiLibrary() {
|
|
122
|
-
this._apiLibrary = await
|
|
131
|
+
this._apiLibrary = await c.getApiLibraryForModel(this._modelId);
|
|
123
132
|
}
|
|
124
133
|
async _executeScript() {
|
|
125
134
|
const e = this.testData;
|
|
@@ -131,8 +140,8 @@ class q extends C {
|
|
|
131
140
|
return;
|
|
132
141
|
}
|
|
133
142
|
this._showExecutionPanel = !0, this._executingScript = !0, this._consoleLogs = [], setTimeout(() => void (async () => {
|
|
134
|
-
const
|
|
135
|
-
this._executionResult = await v(t.definition,
|
|
143
|
+
const d = this._codeEditorElt.value?.value;
|
|
144
|
+
this._executionResult = await v(t.definition, d, e, (n) => setTimeout(() => this._consoleLogs = [...this._consoleLogs, n], 0)), this._executingScript = !1;
|
|
136
145
|
})(), 0);
|
|
137
146
|
}
|
|
138
147
|
_toggleShowExecutionPanel() {
|
|
@@ -165,7 +174,7 @@ class q extends C {
|
|
|
165
174
|
// An unique identifier for the action.
|
|
166
175
|
id: "run-script",
|
|
167
176
|
label: "Run Arcade Expression",
|
|
168
|
-
keybindings: [
|
|
177
|
+
keybindings: [C.F5],
|
|
169
178
|
contextMenuGroupId: "code",
|
|
170
179
|
contextMenuOrder: 1,
|
|
171
180
|
run: () => {
|
|
@@ -179,22 +188,22 @@ class q extends C {
|
|
|
179
188
|
t !== -1 && this._disposables.splice(t, 1), e.dispose();
|
|
180
189
|
}
|
|
181
190
|
async _updateArcadeAssistantRemoteState() {
|
|
182
|
-
this.arcadeAssistant && (this._arcadeAssistantRemoteState = await
|
|
191
|
+
this.arcadeAssistant && (this._arcadeAssistantRemoteState = await X({
|
|
183
192
|
...this.arcadeAssistant,
|
|
184
193
|
profile: this.profile
|
|
185
194
|
}));
|
|
186
195
|
}
|
|
187
196
|
renderMainActionBar() {
|
|
188
|
-
return this.testData ?
|
|
197
|
+
return this.testData ? s`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run ?? ""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${() => void this._executeScript().catch(o(this))}></calcite-action>${this._executionResult ? s`<calcite-action .text=${this.messages.lastresults ?? ""} .active=${this._showExecutionPanel} text-enabled icon=access-string-results icon-flip-rtl scale=s @click=${this._toggleShowExecutionPanel}></calcite-action>` : null}</calcite-action-group></calcite-action-bar>` : null;
|
|
189
198
|
}
|
|
190
199
|
renderMainPanel() {
|
|
191
|
-
return
|
|
200
|
+
return s`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${c.languageId} .value=${this.script ?? ""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${N(this._codeEditorElt)}></arcgis-code-editor>`;
|
|
192
201
|
}
|
|
193
|
-
renderAction({ id: e, label: t, icon:
|
|
194
|
-
return
|
|
202
|
+
renderAction({ id: e, label: t, icon: d, active: n, panelName: h, iconFlipRtl: p = !1, onClick: u = this._toggleSidePanel }) {
|
|
203
|
+
return s`<calcite-action id=${e ?? P} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${d} .active=${n} @click=${u} data-panel-name=${h ?? P} .iconFlipRtl=${p}></calcite-action>${!this.sideActionBarExpanded && s`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>` || ""}`;
|
|
195
204
|
}
|
|
196
205
|
renderSideActionBar() {
|
|
197
|
-
return this.hideSideBar ? null :
|
|
206
|
+
return this.hideSideBar ? null : s`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({
|
|
198
207
|
id: "profile-variables-action",
|
|
199
208
|
label: this.messages.profilevariables ?? "",
|
|
200
209
|
icon: "profile-variables",
|
|
@@ -238,13 +247,13 @@ class q extends C {
|
|
|
238
247
|
if (this.hideSideBar)
|
|
239
248
|
return null;
|
|
240
249
|
const { openedSidePanel: e } = this;
|
|
241
|
-
return
|
|
250
|
+
return s`<arcgis-language-api-panel slot=side-panel class=${l(e === "api" ? "" : "hidden")} .loading=${this._preparingArcade} .apiLibrary=${this._apiLibrary} .hideDocumentationActions=${this.hideDocumentationActions} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .closed=${e !== "api"}></arcgis-language-api-panel><arcgis-editor-variables slot=side-panel class=${l(e === "variables" ? "" : "hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e !== "variables"}></arcgis-editor-variables>${this.suggestions?.length && s`<arcgis-arcade-suggestions slot=side-panel class=${l(e === "suggestions" ? "" : "hidden")} .closed=${e !== "suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none></arcgis-arcade-suggestions>` || ""}${this.arcadeAssistant && this._arcadeAssistantRemoteState.shouldRender && s`<arcgis-arcade-coding-assistant slot=side-panel class=${l(e === "arcade-assistant" ? "" : "hidden")} .closed=${e !== "arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._toggleSidePanel} .portalUrl=${this.arcadeAssistant.portalUrl} .serviceUrl=${this._arcadeAssistantRemoteState.serviceUrl} .helpBase=${this._arcadeAssistantRemoteState.helpBase} .assistantsEnabled=${this._arcadeAssistantRemoteState.assistantsEnabled} .feedbackServiceUrl=${this._arcadeAssistantRemoteState.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant.appVersion}></arcgis-arcade-coding-assistant>` || ""}${this.customPanels?.map((t) => s`<calcite-flow slot=side-panel class=${l(e === t.id ? "" : "hidden")}>${t?.useFlows ? t.renderer?.({
|
|
242
251
|
closePanel: this._toggleSidePanel,
|
|
243
252
|
insertText: this._insertText.bind(this),
|
|
244
253
|
closed: e !== t.id,
|
|
245
254
|
/** pass this.el instead of "this" as it is what actually gets attached to the dom */
|
|
246
255
|
editorRef: this.el
|
|
247
|
-
}) :
|
|
256
|
+
}) : s`<calcite-flow-item .heading=${t.name} heading-level=2 closable .closed=${e !== t.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${t.description}>${t.renderer?.({
|
|
248
257
|
closePanel: this._toggleSidePanel,
|
|
249
258
|
insertText: this._insertText.bind(this),
|
|
250
259
|
closed: e !== t.id,
|
|
@@ -253,13 +262,13 @@ class q extends C {
|
|
|
253
262
|
})}</calcite-flow-item>`}</calcite-flow>`)}`;
|
|
254
263
|
}
|
|
255
264
|
renderResultsPanel() {
|
|
256
|
-
return this._showExecutionPanel ?
|
|
265
|
+
return this._showExecutionPanel ? s`<arcgis-arcade-results slot=results-panel .openedResultPanel=${this._resultPanel} .loading=${this._executingScript} .result=${this._executionResult} .consoleLogs=${this._consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>` : null;
|
|
257
266
|
}
|
|
258
267
|
render() {
|
|
259
|
-
return
|
|
268
|
+
return s`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`;
|
|
260
269
|
}
|
|
261
270
|
}
|
|
262
|
-
|
|
271
|
+
I("arcgis-arcade-editor", K);
|
|
263
272
|
export {
|
|
264
|
-
|
|
273
|
+
K as ArcgisArcadeEditor
|
|
265
274
|
};
|