@arcgis/coding-components 4.31.0-next.4 → 4.31.0-next.40
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/README.md +22 -3
- package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ar.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bg.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bs.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ca.json +6 -6
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.cs.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.da.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.de.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.el.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.es.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.et.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fi.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.he.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.id.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.it.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ko.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nb.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nl.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pl.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-BR.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-PT.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ru.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sk.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sl.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sv.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.th.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.tr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.uk.json +5 -5
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.vi.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-CN.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-HK.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-TW.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.ca.json +2 -2
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.de.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.he.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.ca.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.it.json +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/sql-expr.worker.js +446 -7
- package/dist/arcgis-coding-components/assets/language-api-panel/t9n/language-api-panel.t9n.ca.json +1 -1
- package/dist/arcgis-coding-components/index.esm.js +2 -2
- package/dist/arcgis-coding-components/{p-a256ee9c.js → p-101c8076.js} +12 -12
- package/dist/arcgis-coding-components/{p-26c67f7c.js → p-11fa79f8.js} +2 -2
- package/dist/arcgis-coding-components/{p-8e93417c.js → p-1661235a.js} +2 -2
- package/dist/arcgis-coding-components/{p-b570d7af.js → p-17a4b887.js} +2 -2
- package/dist/arcgis-coding-components/p-2ac72ecc.js +6 -0
- package/dist/arcgis-coding-components/p-343ec29e.js +6 -0
- package/dist/arcgis-coding-components/{p-736d890c.js → p-36056ac1.js} +3 -3
- package/dist/arcgis-coding-components/{p-5da03560.js → p-3f15e8ab.js} +1 -1
- package/dist/arcgis-coding-components/p-5828aff9.js +6 -0
- package/dist/arcgis-coding-components/{p-86625411.js → p-6a013766.js} +2 -2
- package/dist/arcgis-coding-components/p-6c7fc166.entry.js +6 -0
- package/dist/arcgis-coding-components/{p-ab0f6db7.js → p-6cbe1fe3.js} +3 -3
- package/dist/arcgis-coding-components/{p-b23a3f4e.entry.js → p-7309113a.entry.js} +2 -2
- package/dist/arcgis-coding-components/{p-4e56f8ae.js → p-904ce83e.js} +1 -1
- package/dist/arcgis-coding-components/p-a2cbed14.js +7 -0
- package/dist/arcgis-coding-components/p-d9ae7973.js +6 -0
- package/dist/arcgis-coding-components/{p-5e173b51.entry.js → p-da203995.entry.js} +2 -2
- package/dist/arcgis-coding-components/{p-8d67b196.js → p-fc66eaf3.js} +3 -3
- package/dist/cjs/{app-globals-209c2310.js → app-globals-674a3a3d.js} +1 -1
- package/dist/cjs/arcade-defaults-ed0ccdc8.js +349 -0
- package/dist/cjs/{arcade-mode-f2c3951e.js → arcade-mode-e4201a06.js} +3 -3
- package/dist/cjs/arcgis-arcade-editor_6.cjs.entry.js +20 -26
- package/dist/cjs/arcgis-coding-components.cjs.js +5 -5
- package/dist/cjs/arcgis-sql-expression-editor.cjs.entry.js +4 -4
- package/dist/cjs/arcgis-sql-expression-fields.cjs.entry.js +4 -4
- package/dist/cjs/{css-bbd000cd.js → css-c33c006f.js} +1 -1
- package/dist/cjs/{cssMode-ad163e66.js → cssMode-cf6c5365.js} +2 -3
- package/dist/cjs/{html-5c67b9d0.js → html-2ef85c79.js} +2 -3
- package/dist/cjs/{htmlMode-e32a97bd.js → htmlMode-07dcb544.js} +2 -3
- package/dist/cjs/{index-8b891c40.js → index-b1aa4d20.js} +43 -15
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/{javascript-e159fa2f.js → javascript-61e9d53f.js} +3 -4
- package/dist/cjs/{jsonMode-5c107443.js → jsonMode-eec500bc.js} +2 -3
- package/dist/cjs/{language-defaults-base-4300e691.js → language-defaults-base-e8f93cb5.js} +822 -1062
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/{sql-expr-defaults-783d9c24.js → sql-expr-defaults-1d7415d0.js} +106 -44
- package/dist/cjs/sql-expr-mode-de9f89a8.js +467 -0
- package/dist/cjs/{tsMode-83c4587f.js → tsMode-213dbfe4.js} +2 -3
- package/dist/cjs/{typescript-f6ca5d84.js → typescript-c668fe11.js} +2 -3
- package/dist/components/arcade-defaults.js +238 -4
- package/dist/components/arcade-mode.js +2 -1
- package/dist/components/arcade-results.js +3 -3
- package/dist/components/arcade-suggestions.js +2 -2
- package/dist/components/arcade-variables.js +2 -2
- package/dist/components/arcgis-arcade-editor.js +7 -6
- 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 +26 -26
- package/dist/components/arcgis-assets.js +2 -2
- package/dist/components/arcgis-code-editor.js +1 -1
- package/dist/components/arcgis-language-api-panel.js +1 -1
- package/dist/components/arcgis-sql-expression-editor.js +2 -2
- package/dist/components/arcgis-sql-expression-fields.js +1 -1
- package/dist/components/{chunk-6TARY3NN.js → chunk-656WPE3G.js} +30 -22
- package/dist/components/code-editor.js +16 -23
- package/dist/components/fields.js +4 -4
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/language-api-panel.js +2 -2
- package/dist/components/language-defaults-base.js +81 -323
- package/dist/components/markdown.js +1 -1
- package/dist/components/sql-expr-defaults.js +77 -24
- package/dist/components/sql-expr-mode.js +282 -24951
- package/dist/components/sql-expression-fields.js +2 -2
- package/dist/components/useT9n.js +2 -2
- package/dist/components/utilities.js +1 -1
- package/dist/esm/{app-globals-60a61d0d.js → app-globals-b8e72633.js} +1 -1
- package/dist/esm/arcade-defaults-f7df9442.js +344 -0
- package/dist/esm/{arcade-mode-7e6764ac.js → arcade-mode-efe99f12.js} +3 -3
- package/dist/esm/arcgis-arcade-editor_6.entry.js +21 -27
- package/dist/esm/arcgis-coding-components.js +6 -6
- package/dist/esm/arcgis-sql-expression-editor.entry.js +4 -4
- package/dist/esm/arcgis-sql-expression-fields.entry.js +4 -4
- package/dist/esm/{css-7d75b7ca.js → css-08c12296.js} +1 -1
- package/dist/esm/{cssMode-95305ae2.js → cssMode-f536f753.js} +2 -3
- package/dist/esm/{html-84fc596c.js → html-6618281c.js} +2 -3
- package/dist/esm/{htmlMode-c961f619.js → htmlMode-cf1a7867.js} +2 -3
- package/dist/esm/{index-1c1754c0.js → index-438d6c73.js} +43 -15
- package/dist/esm/index.js +4 -4
- package/dist/esm/{javascript-0aa4505f.js → javascript-3c2117eb.js} +3 -4
- package/dist/esm/{jsonMode-86b234eb.js → jsonMode-913faa2d.js} +2 -3
- package/dist/esm/{language-defaults-base-949fa7fb.js → language-defaults-base-8712f6ef.js} +819 -1062
- package/dist/esm/loader.js +5 -5
- package/dist/esm/{sql-expr-defaults-f2f50289.js → sql-expr-defaults-36f45c7c.js} +106 -45
- package/dist/esm/sql-expr-mode-63d572b1.js +463 -0
- package/dist/esm/{tsMode-ee945c40.js → tsMode-8aeb228a.js} +2 -3
- package/dist/esm/{typescript-8bd2bb48.js → typescript-91a0d6c0.js} +2 -3
- package/dist/loader/cdn.js +2 -3
- package/dist/loader/index.cjs.js +2 -3
- package/dist/loader/index.es2017.js +2 -3
- package/dist/loader/index.js +2 -3
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +13 -3
- package/dist/types/components/arcade-results/arcade-results.d.ts +1 -1
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +1 -1
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +1 -1
- package/dist/types/components/code-editor/code-editor.d.ts +14 -4
- package/dist/types/components/language-api-panel/language-api-panel.d.ts +1 -1
- package/dist/types/components.d.ts +13 -13
- 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 +8 -1
- 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 +5 -1
- package/dist/types/stencil-public-runtime.d.ts +3 -8
- package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -0
- package/dist/types/utils/arcade-monaco/arcade-profile-strategy.d.ts +9 -0
- package/dist/types/utils/fields.d.ts +2 -2
- package/dist/types/utils/profile/editor-profile.d.ts +7 -6
- package/dist/types/utils/profile/types.d.ts +53 -65
- package/dist/types/utils/profile/utils.d.ts +9 -8
- package/dist/types/utils/sql-expr-monaco/sql-expr-completion.d.ts +56 -5
- package/dist/types/utils/sql-expr-monaco/sql-expr-constants.d.ts +61 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-contribution.d.ts +1 -11
- package/dist/types/utils/sql-expr-monaco/sql-expr-defaults.d.ts +0 -1
- package/dist/types/utils/sql-expr-monaco/sql-expr-language-features.d.ts +18 -534
- package/dist/types/utils/sql-expr-monaco/sql-expr-mode.d.ts +34 -1
- package/dist/types/utils/sql-expr-monaco/sql-expr-parser-utils.d.ts +30 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-service-accessors.d.ts +19 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation-diagnostic-adapter.d.ts +0 -7
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation-utils.d.ts +73 -77
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation.d.ts +5 -6
- package/dist/types/utils/sql-expr-monaco/sql-expr-worker-manager.d.ts +2 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr.worker.d.ts +11 -8
- package/dist/types/utils/sql-expr-monaco/sql-expression-profile-strategy.d.ts +13 -0
- package/dist/types/utils/sql-expr-monaco/types.d.ts +30 -28
- package/package.json +19 -19
- package/dist/arcgis-coding-components/p-103bdac3.js +0 -6
- package/dist/arcgis-coding-components/p-2d14950e.js +0 -7
- package/dist/arcgis-coding-components/p-374b59c1.js +0 -6
- package/dist/arcgis-coding-components/p-a36c357f.js +0 -6
- package/dist/arcgis-coding-components/p-de5cabbb.js +0 -6
- package/dist/arcgis-coding-components/p-e6cac921.entry.js +0 -6
- package/dist/cjs/arcade-defaults-ee308e3a.js +0 -116
- package/dist/cjs/sql-expr-mode-6cac37ed.js +0 -25135
- package/dist/esm/arcade-defaults-b1a5f013.js +0 -111
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/sql-expr-mode-14c94be3.js +0 -25132
- package/dist/types/utils/profile/predefined-profile.d.ts +0 -4
- package/dist/types/utils/sql-expr-monaco/DependentFiles/DateOnly.d.ts +0 -41
- package/dist/types/utils/sql-expr-monaco/DependentFiles/SqlInterval.d.ts +0 -16
- package/dist/types/utils/sql-expr-monaco/DependentFiles/SqlTimestampOffset.d.ts +0 -26
- package/dist/types/utils/sql-expr-monaco/DependentFiles/TimeOnly.d.ts +0 -37
- package/dist/types/utils/sql-expr-monaco/DependentFiles/UnknownTimeZone.d.ts +0 -11
- package/dist/types/utils/sql-expr-monaco/DependentFiles/WhereGrammar.d.ts +0 -122
- package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlCompareUtils.d.ts +0 -5
- package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlDateParsingUtils.d.ts +0 -18
- package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlUtils.d.ts +0 -6
- package/dist/types/utils/sql-expr-monaco/DependentFiles/standardizedFunctions.d.ts +0 -156
- package/dist/types/utils/sql-expr-monaco/DependentFiles/support.d.ts +0 -150
- package/dist/types/utils/sql-expr-monaco/PeggyGrammar/sql92grammar.d.ts +0 -1397
- package/dist/types/utils/sql-expr-monaco/libraries/date/properties/index.d.ts +0 -59
- package/dist/types/utils/sql-expr-monaco/libraries/numeric/properties/index.d.ts +0 -295
- package/dist/types/utils/sql-expr-monaco/libraries/string/properties/index.d.ts +0 -135
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation-adapter.d.ts +0 -3
- package/dist/types/utils/sql-expr-profile/predefined-profile.d.ts +0 -2
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
* See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
+
* v4.31.0-next.40
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const languageDefaultsBase = require('./language-defaults-base-e8f93cb5.js');
|
|
9
|
+
const index = require('./index-b1aa4d20.js');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the arcade diagnostic service.
|
|
13
|
+
* Example:
|
|
14
|
+
* ```ts
|
|
15
|
+
* const diagnosticService = await getArcadeDiagnosticService();
|
|
16
|
+
* diagnosticService.onDidChangeDiagnostics(({uri, diaganostics }) => {
|
|
17
|
+
* // Filter the diagnostics for the uri of interest
|
|
18
|
+
* // Do something with the diagnostics
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
async function getArcadeDiagnosticService() {
|
|
23
|
+
const mode = await getMode();
|
|
24
|
+
return mode.getArcadeDiagnosticService();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the arcade worker for the model.
|
|
28
|
+
* Example:
|
|
29
|
+
* ```ts
|
|
30
|
+
* const arcadeWorker = await getArcadeWorker(model.uri);
|
|
31
|
+
* ```
|
|
32
|
+
* @returns arcade worker
|
|
33
|
+
*/
|
|
34
|
+
async function getArcadeWorker(uri) {
|
|
35
|
+
const mode = await getMode();
|
|
36
|
+
return await mode.getArcadeWorker(uri);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Request the arcade mode
|
|
40
|
+
* @returns arcade mode module
|
|
41
|
+
*/
|
|
42
|
+
async function getMode() {
|
|
43
|
+
return await Promise.resolve().then(function () { return require('./arcade-mode-e4201a06.js'); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// #region convert editor profile to apiProfile
|
|
47
|
+
/**
|
|
48
|
+
* Converts an editor profile to an api profile.
|
|
49
|
+
* The api profile is an optimized version of the editor profile designed for minimal data transfer between the main thread and the worker.
|
|
50
|
+
*/
|
|
51
|
+
async function arcadeEditorToApiProfile(editorProfile) {
|
|
52
|
+
const { apiVersion, bundles, hiddenApiItems } = editorProfile.toEditorProfileDefinition();
|
|
53
|
+
const variables = await variablesToLSVariable(editorProfile.dictionaryVariables);
|
|
54
|
+
return { apiVersion, bundles, variables, hiddenApiItems: hiddenApiItems?.map((s) => s.toLowerCase()) };
|
|
55
|
+
}
|
|
56
|
+
async function variablesToLSVariable(editorVariables, kind = languageDefaultsBase.main.exports.CompletionItemKind.Variable) {
|
|
57
|
+
return await Promise.all(editorVariables.map(async (editorVariable) => {
|
|
58
|
+
switch (editorVariable.type) {
|
|
59
|
+
case "dictionary":
|
|
60
|
+
return await dictionaryToLSDictionary(editorVariable, kind);
|
|
61
|
+
case "feature":
|
|
62
|
+
return await featureToLSFeature(editorVariable, kind);
|
|
63
|
+
default:
|
|
64
|
+
return variableToLSVariable(editorVariable, kind);
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function variableToLSVariable(editorVariable, kind) {
|
|
69
|
+
const { name, type } = editorVariable;
|
|
70
|
+
const description = editorVariable.getDescription();
|
|
71
|
+
return {
|
|
72
|
+
name,
|
|
73
|
+
description,
|
|
74
|
+
type,
|
|
75
|
+
completion: {
|
|
76
|
+
label: name,
|
|
77
|
+
detail: name,
|
|
78
|
+
insertText: name,
|
|
79
|
+
insertTextMode: languageDefaultsBase.main.exports.InsertTextMode.asIs,
|
|
80
|
+
insertTextFormat: languageDefaultsBase.main.exports.InsertTextFormat.PlainText,
|
|
81
|
+
kind,
|
|
82
|
+
documentation: { kind: "markdown", value: description },
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async function featureToLSFeature(editorFeature, kind) {
|
|
87
|
+
// Get the source for the definition
|
|
88
|
+
const source = await editorFeature.loadSource();
|
|
89
|
+
const { name } = editorFeature;
|
|
90
|
+
const description = editorFeature.getDescription();
|
|
91
|
+
const resultCompletion = {
|
|
92
|
+
label: name,
|
|
93
|
+
detail: name,
|
|
94
|
+
insertText: name,
|
|
95
|
+
insertTextMode: languageDefaultsBase.main.exports.InsertTextMode.asIs,
|
|
96
|
+
insertTextFormat: languageDefaultsBase.main.exports.InsertTextFormat.PlainText,
|
|
97
|
+
kind,
|
|
98
|
+
};
|
|
99
|
+
const result = {
|
|
100
|
+
name,
|
|
101
|
+
description,
|
|
102
|
+
type: "dictionary",
|
|
103
|
+
properties: [],
|
|
104
|
+
completion: resultCompletion,
|
|
105
|
+
};
|
|
106
|
+
// No source definition, then it will be a feature without any known fields
|
|
107
|
+
if (!source) {
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
// Create properties for the fields and the aliases
|
|
111
|
+
// Also improve the feature completion documentation
|
|
112
|
+
const [properties, featureCompletionDescription] = languageDefaultsBase.fieldsToProfileValues(source.fields, description, true);
|
|
113
|
+
result.properties = properties;
|
|
114
|
+
resultCompletion.documentation = { kind: "markdown", value: featureCompletionDescription };
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
async function dictionaryToLSDictionary(editorDictionary, kind) {
|
|
118
|
+
const { name, dictionaryVariables: variables } = editorDictionary;
|
|
119
|
+
const description = editorDictionary.getDescription();
|
|
120
|
+
const completionDescription = variables.reduce((previous, p) => {
|
|
121
|
+
if (previous !== "") {
|
|
122
|
+
previous += " \n \n";
|
|
123
|
+
}
|
|
124
|
+
previous += `**${p.name}** \n${p.type}`;
|
|
125
|
+
const description = p.getDescription();
|
|
126
|
+
if (description) {
|
|
127
|
+
previous += ` \n${description}`;
|
|
128
|
+
}
|
|
129
|
+
return previous;
|
|
130
|
+
}, description);
|
|
131
|
+
return {
|
|
132
|
+
name,
|
|
133
|
+
description,
|
|
134
|
+
type: "dictionary",
|
|
135
|
+
properties: await variablesToLSVariable(variables, languageDefaultsBase.main.exports.CompletionItemKind.Field),
|
|
136
|
+
completion: {
|
|
137
|
+
label: name,
|
|
138
|
+
detail: name,
|
|
139
|
+
insertText: name,
|
|
140
|
+
insertTextMode: languageDefaultsBase.main.exports.InsertTextMode.asIs,
|
|
141
|
+
insertTextFormat: languageDefaultsBase.main.exports.InsertTextFormat.PlainText,
|
|
142
|
+
kind,
|
|
143
|
+
documentation: { kind: "markdown", value: completionDescription },
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// #endregion
|
|
148
|
+
// #region predefined profile to editor profile definition
|
|
149
|
+
/**
|
|
150
|
+
* Get a PredefinedProfile for a locale. If not already loaded then fetch it.
|
|
151
|
+
* If the locale doesn't exist or the locale profile file doesn't exist then returns
|
|
152
|
+
* the english version of the profile.
|
|
153
|
+
*/
|
|
154
|
+
async function getSdkPredefinedProfiles(locale = "en") {
|
|
155
|
+
const profiles = sdkPredefinedProfilesMap.get(locale);
|
|
156
|
+
if (profiles) {
|
|
157
|
+
return profiles;
|
|
158
|
+
}
|
|
159
|
+
if (!languageDefaultsBase.supportedLocales.has(locale)) {
|
|
160
|
+
return await getSdkPredefinedProfiles("en");
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const response = await fetch(index.getAssetPath(`./assets/arcade-language/profiles/arcade-profiles.t9n.${locale}.json`));
|
|
164
|
+
if (response.ok) {
|
|
165
|
+
return cacheSdkPredefinedProfiles(locale, (await response.json()));
|
|
166
|
+
}
|
|
167
|
+
if (locale === "en") {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return await getSdkPredefinedProfiles("en");
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const sdkPredefinedProfilesMap = new Map();
|
|
177
|
+
/**
|
|
178
|
+
* Convert a stored profile into a PredefinedProfile and add it to the in-memory
|
|
179
|
+
* Map of profiles per locale.
|
|
180
|
+
*/
|
|
181
|
+
function cacheSdkPredefinedProfiles(locale, profiles) {
|
|
182
|
+
const map = new Map();
|
|
183
|
+
profiles.forEach((profile) => {
|
|
184
|
+
map.set(profile.id, profile);
|
|
185
|
+
});
|
|
186
|
+
sdkPredefinedProfilesMap.set(locale, map);
|
|
187
|
+
return map;
|
|
188
|
+
}
|
|
189
|
+
async function getSdkPredefinedProfile(id, locale = "en") {
|
|
190
|
+
const profiles = await getSdkPredefinedProfiles(locale);
|
|
191
|
+
return profiles?.get(id) ?? null;
|
|
192
|
+
}
|
|
193
|
+
function isExtendedPredefinedProfileDefinition(item) {
|
|
194
|
+
return !!item && typeof item === "object" && "additionalVariables" in item && Array.isArray(item.additionalVariables);
|
|
195
|
+
}
|
|
196
|
+
function convertApiVariables(variables) {
|
|
197
|
+
return variables?.map(convertApiVariable);
|
|
198
|
+
}
|
|
199
|
+
function convertApiVariable(variable) {
|
|
200
|
+
switch (variable.type) {
|
|
201
|
+
case "dictionary":
|
|
202
|
+
return {
|
|
203
|
+
...variable,
|
|
204
|
+
type: variable.type,
|
|
205
|
+
properties: convertApiVariables(variable.properties),
|
|
206
|
+
};
|
|
207
|
+
case "array": {
|
|
208
|
+
return {
|
|
209
|
+
...variable,
|
|
210
|
+
type: variable.type,
|
|
211
|
+
elementType: { type: "number", name: "number" },
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
default:
|
|
215
|
+
return { ...variable, type: variable.type };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async function convertToEditorProfileDefinition(predefinedProfile, locale = "en") {
|
|
219
|
+
if (!languageDefaultsBase.isPredefinedProfile(predefinedProfile)) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
const sdkPredefinedProfile = await getSdkPredefinedProfile(predefinedProfile.id, locale);
|
|
223
|
+
if (!sdkPredefinedProfile) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
const editorProfile = {
|
|
227
|
+
bundles: [...sdkPredefinedProfile.bundles],
|
|
228
|
+
variables: [],
|
|
229
|
+
hiddenApiItems: predefinedProfile.hiddenApiItems?.map((s) => s.toLowerCase()),
|
|
230
|
+
};
|
|
231
|
+
// Merge the SDK variables' definitions/properties with the predefined profile definitions.
|
|
232
|
+
sdkPredefinedProfile.variables.forEach((predefinedVariable) => {
|
|
233
|
+
// Don't include disabled variables
|
|
234
|
+
if (predefinedProfile.disabledVariables?.includes(predefinedVariable.name)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
// Try to get a definition from the predefined profile, for the variable that needs one.
|
|
238
|
+
const definition = predefinedProfile.definitions[predefinedVariable.name];
|
|
239
|
+
// Note: Something is weird with TS. The sdkVariables are being casted to the wrong type
|
|
240
|
+
// despite the type checking from the switch statement.
|
|
241
|
+
switch (predefinedVariable.type) {
|
|
242
|
+
case "dictionary": {
|
|
243
|
+
// For dictionary, we support properties overrride
|
|
244
|
+
return editorProfile.variables.push(convertApiVariable({
|
|
245
|
+
...predefinedVariable,
|
|
246
|
+
type: predefinedVariable.type,
|
|
247
|
+
properties: Array.isArray(definition) ? [...definition] : predefinedVariable.properties,
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
case "feature":
|
|
251
|
+
// If the definition is not valid, then we don't include it.
|
|
252
|
+
if (!languageDefaultsBase.isFeatureDefinition(definition)) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
return editorProfile.variables.push({ ...predefinedVariable, type: predefinedVariable.type, definition });
|
|
256
|
+
case "featureSet":
|
|
257
|
+
// If the definition is not valid, then we don't include it.
|
|
258
|
+
if (!languageDefaultsBase.isFeatureSetDefinition(definition)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
return editorProfile.variables.push({ ...predefinedVariable, type: predefinedVariable.type, definition });
|
|
262
|
+
case "featureSetCollection":
|
|
263
|
+
// If the definition is not valid, then we don't include it.
|
|
264
|
+
if (!languageDefaultsBase.isFeatureSetCollectionDefinition(definition)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
return editorProfile.variables.push({ ...predefinedVariable, type: predefinedVariable.type, definition });
|
|
268
|
+
default:
|
|
269
|
+
return editorProfile.variables.push(convertApiVariable(predefinedVariable));
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (isExtendedPredefinedProfileDefinition(predefinedProfile)) {
|
|
273
|
+
editorProfile.variables.push(...(predefinedProfile.additionalVariables ?? []));
|
|
274
|
+
}
|
|
275
|
+
return editorProfile;
|
|
276
|
+
}
|
|
277
|
+
// #endregion
|
|
278
|
+
|
|
279
|
+
const arcadeLanguageId = "arcade";
|
|
280
|
+
class ArcadeLanguageServiceDefaults extends languageDefaultsBase.LanguageDefaultsBase {
|
|
281
|
+
constructor() {
|
|
282
|
+
super(...arguments);
|
|
283
|
+
this._languageId = arcadeLanguageId;
|
|
284
|
+
this._languageOptions = {};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Create an EditorProfile for the given model id using the given definition and locale.
|
|
288
|
+
* The EditorProfile is used by the the Arcade Language service as well by the cosing components.
|
|
289
|
+
* The definition can be a pre-defined profile or an editor profile definition.
|
|
290
|
+
* If the locale is not provided then the 'en' locale is used.
|
|
291
|
+
* @param modelId The model id for which to create the context.
|
|
292
|
+
* @param definition The definition to use for the model context.
|
|
293
|
+
* @param locale The locale to use for the model context.
|
|
294
|
+
* @returns The EditorProfile for the model.
|
|
295
|
+
*/
|
|
296
|
+
async setProfileForModel(modelId, definition, apiContext = { locale: "en" }) {
|
|
297
|
+
// Convert pre-defined profile to a runtime profile
|
|
298
|
+
if (languageDefaultsBase.isPredefinedProfile(definition)) {
|
|
299
|
+
definition = await convertToEditorProfileDefinition(definition, apiContext.locale);
|
|
300
|
+
}
|
|
301
|
+
const profileStrings = await languageDefaultsBase.fetchT9nStringsBundle(apiContext.locale, index.getAssetPath("./assets/arcade-language/t9n"), "profile.t9n.");
|
|
302
|
+
if (!profileStrings) {
|
|
303
|
+
throw new Error(`Failed to load the language bundle for ${apiContext.locale}`);
|
|
304
|
+
}
|
|
305
|
+
this.disposeForModel(modelId);
|
|
306
|
+
const key = this._getApiKey(modelId);
|
|
307
|
+
const editorProfile = new languageDefaultsBase.EditorProfile(definition, profileStrings);
|
|
308
|
+
this._profileMap.set(key, editorProfile);
|
|
309
|
+
const apiProfile = await arcadeEditorToApiProfile(editorProfile);
|
|
310
|
+
this.updateApiContextForModel(modelId, {
|
|
311
|
+
locale: apiContext.locale,
|
|
312
|
+
profile: apiProfile,
|
|
313
|
+
snippets: apiContext.snippets,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Set or update the Arcade language service options.
|
|
318
|
+
* @param languageOptions The language options to set.
|
|
319
|
+
*/
|
|
320
|
+
setLanguageOptions(languageOptions = {}) {
|
|
321
|
+
// Check if options have actually changed.
|
|
322
|
+
// Avoid restarting the worker when no updates.
|
|
323
|
+
// Today we only have the 'assetsPath' as a property
|
|
324
|
+
if (this._languageOptions.assetsPath === languageOptions.assetsPath) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
this._languageOptions = { ...this._languageOptions, ...languageOptions };
|
|
328
|
+
this._onDidChange.fire(this);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Gets the API library for the given model id.
|
|
332
|
+
* @param modelId The model id for which to get the API library.
|
|
333
|
+
* @returns The API library for the model.
|
|
334
|
+
*/
|
|
335
|
+
async getApiLibrary(modelId) {
|
|
336
|
+
const uri = languageDefaultsBase.Uri.parse(modelId);
|
|
337
|
+
const worker = await getArcadeWorker(uri);
|
|
338
|
+
return await worker.getApiLibrary(this.getApiContextForModel(uri));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const arcadeDefaults = new ArcadeLanguageServiceDefaults();
|
|
342
|
+
const arcade = {
|
|
343
|
+
setProfileForModel: arcadeDefaults.setProfileForModel.bind(arcadeDefaults),
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
exports.arcade = arcade;
|
|
347
|
+
exports.arcadeDefaults = arcadeDefaults;
|
|
348
|
+
exports.getArcadeDiagnosticService = getArcadeDiagnosticService;
|
|
349
|
+
exports.getMode = getMode;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
* See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
-
* v4.31.0-next.
|
|
4
|
+
* v4.31.0-next.40
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const languageDefaultsBase = require('./language-defaults-base-
|
|
9
|
-
require('./index-8b891c40.js');
|
|
8
|
+
const languageDefaultsBase = require('./language-defaults-base-e8f93cb5.js');
|
|
10
9
|
|
|
11
10
|
var V={False:"false",Null:"null",True:"true"},f={Break:"break",Continue:"continue",Else:"else",For:"for",From:"from",Function:"function",If:"if",Import:"import",Export:"export",In:"in",Return:"return",Var:"var",While:"while"},Ee=["++","--"],Je=["-","+","!","~"],Qe=["=","/=","*=","%=","+=","-="],Ze=["||","&&"],Lt=["|","&",">>","<<",">>>","^","==","!=","<","<=",">",">=","+","-","*","/","%"];var U=[[],[],[]];Ee.forEach(t=>U[t.length-1]?.push(t));Je.forEach(t=>U[t.length-1]?.push(t));Ze.forEach(t=>U[t.length-1]?.push(t));Qe.forEach(t=>U[t.length-1]?.push(t));Lt.forEach(t=>U[t.length-1]?.push(t));var ft=Object.values(f),gt=Object.values(V);gt.map(t=>({label:t,kind:languageDefaultsBase.main.exports.CompletionItemKind.Constant}));ft.map(t=>({label:t,kind:languageDefaultsBase.main.exports.CompletionItemKind.Keyword}));
|
|
12
11
|
|
|
@@ -345,6 +344,7 @@ function isInsertReplaceEdit(edit) {
|
|
|
345
344
|
return (typeof edit.insert !== "undefined" &&
|
|
346
345
|
typeof edit.replace !== "undefined");
|
|
347
346
|
}
|
|
347
|
+
// TODO: extract this function to common util
|
|
348
348
|
function toCompletionItemKind(kind) {
|
|
349
349
|
const mItemKind = languageDefaultsBase.languages.CompletionItemKind;
|
|
350
350
|
switch (kind) {
|