@parallelworks/ui 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunks/memoryStore-CC91S5LP.js → ai/adapter/memoryStore.js} +2 -2
- package/dist/ai/adapter/mock/index.js +2 -80
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.js +5 -333
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/{chunks/types-Yy0NrerF.js → ai/adapter/types.js} +1 -1
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.js +147 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.js +341 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.js +46 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.js +43 -6644
- package/dist/ai/strings.js +175 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.js +23 -0
- package/dist/assets/editor.worker-DfmPPyOL.js +60 -0
- package/dist/assets/json.worker-Dqgjpq9F.js +92 -0
- package/dist/assets/yaml.worker-DLx0whrM.js +1441 -0
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.js +83 -0
- package/dist/components/Button.js +83 -0
- package/dist/components/Callout.js +23 -0
- package/dist/components/Card.js +31 -0
- package/dist/components/CollapsiblePanel.js +77 -0
- package/dist/{chunks/ConfirmModal-aOR4O1QE.js → components/ConfirmModal.js} +4 -9
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/Markdown-CM-FenNE.js → components/CreateModal.js} +9 -116
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.js +27 -0
- package/dist/components/Filter.js +32 -0
- package/dist/components/FilterPill.js +13 -0
- package/dist/components/IconButton.js +34 -0
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.js +13 -0
- package/dist/components/Listbox.js +123 -0
- package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
- package/dist/components/Markdown.js +15 -0
- package/dist/components/MultiSelect.js +171 -0
- package/dist/components/Overview.js +39 -0
- package/dist/components/PageHeader.js +194 -0
- package/dist/components/Pagination.js +35 -0
- package/dist/{chunks/Provider-CDYurraE.js → components/Provider.js} +13 -5
- package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
- package/dist/components/SectionHeader.js +11 -0
- package/dist/components/SettingModeOption.js +30 -0
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.js +17 -0
- package/dist/components/Sort.js +42 -0
- package/dist/components/StatusBadge.js +63 -0
- package/dist/components/SwitchToggle.js +59 -0
- package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
- package/dist/{chunks/Table-DU2MW8xz.js → components/Table.js} +3 -3
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-K5HJr4_p.js → components/Tooltip.js} +2 -27
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/{chunks/focus-D_iZJTW1.js → components/focus.js} +1 -1
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.js +27 -0
- package/dist/components/relativeTime.js +32 -0
- package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
- package/dist/{chunks/duration-BOv8Phl8.js → duration.js} +1 -1
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/{chunks/Monaco-DJ8MW-Dq.js → editor/Monaco.js} +5 -26
- package/dist/editor/index.js +6 -1
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.d.ts +5 -0
- package/dist/editor/workers.js +35 -0
- package/dist/editor/yaml.d.ts +9 -1
- package/dist/editor/yaml.js +15 -0
- package/dist/editor/yaml.worker.d.ts +1 -0
- package/dist/editor/yamlLanguage.d.ts +6 -0
- package/dist/editor/yamlLanguage.js +312 -0
- package/dist/file-explorer/FileExplorer.js +1405 -0
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/{chunks/CodePreviewEditor-YqQBz1YL.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
- package/dist/file-explorer/FilePreview/Inline.js +45 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
- package/dist/file-explorer/FilePreview/Viewer.js +526 -0
- package/dist/file-explorer/FilePreview/index.js +266 -0
- package/dist/file-explorer/FilePreview/parse.js +63 -0
- package/dist/file-explorer/FilePreview/previewCache.js +98 -0
- package/dist/file-explorer/FilePreview/previewType.js +151 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
- package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
- package/dist/file-explorer/FileRow.js +165 -0
- package/dist/file-explorer/FileRowsWindow.js +92 -0
- package/dist/file-explorer/FileTable.js +172 -0
- package/dist/file-explorer/FileTableHeaders.js +49 -0
- package/dist/file-explorer/LoadMoreRow.js +46 -0
- package/dist/file-explorer/TreeView.js +376 -0
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.js +7 -5671
- package/dist/file-explorer/lib/batch.js +39 -0
- package/dist/file-explorer/lib/errors.js +9 -0
- package/dist/file-explorer/lib/paging.js +124 -0
- package/dist/file-explorer/lib/utils.js +322 -0
- package/dist/file-explorer/toasts.js +400 -0
- package/dist/file-explorer/treeRows.js +73 -0
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.js +54 -0
- package/dist/form/Fields/BooleanField.js +51 -0
- package/dist/form/Fields/CheckboxGroupField.js +72 -0
- package/dist/form/Fields/ColorField.js +33 -0
- package/dist/form/Fields/DropdownField.js +49 -0
- package/dist/form/Fields/DurationField.js +130 -0
- package/dist/form/Fields/LabelField.js +19 -0
- package/dist/form/Fields/MultiDropdownField.js +40 -0
- package/dist/form/Fields/NumberField.js +51 -0
- package/dist/form/Fields/ObjectField.js +54 -0
- package/dist/form/Fields/RadioField.js +49 -0
- package/dist/form/Fields/RangeField.js +58 -0
- package/dist/form/Fields/ResourceOptionIcon.js +21 -0
- package/dist/form/Fields/StepField.js +6 -0
- package/dist/form/Fields/StringField.js +37 -0
- package/dist/form/Fields/TextAreaField.js +31 -0
- package/dist/form/Fields/durationValidity.js +11 -0
- package/dist/form/Form.js +643 -0
- package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
- package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
- package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
- package/dist/form/Wizard/WizardContainer.js +138 -0
- package/dist/form/Wizard/WizardNavigation.js +92 -0
- package/dist/form/Wizard/WizardStepContent.js +35 -0
- package/dist/form/Wizard/WizardStepIndicator.js +108 -0
- package/dist/form/Wizard/useWizardState.js +118 -0
- package/dist/form/Wizard/utils.js +34 -0
- package/dist/form/fieldContext.js +26 -0
- package/dist/form/fieldRegistry.js +50 -0
- package/dist/form/index.js +17 -2321
- package/dist/{chunks/FieldWrapper-Cszwg-4B.js → form/lib.js} +2 -97
- package/dist/form/useParsedOpts.js +62 -0
- package/dist/form/usePrevious.js +11 -0
- package/dist/form/utils/checkShowIfObject.js +14 -0
- package/dist/form/utils/duration.js +69 -0
- package/dist/form/utils/getParentValue.js +23 -0
- package/dist/form/utils/getPlaceholder.js +9 -0
- package/dist/form/utils/getValueUsingPath.js +23 -0
- package/dist/form/utils/secondaryField.js +22 -0
- package/dist/graph/AnnotationBanner.js +141 -0
- package/dist/graph/Collapse.js +41 -0
- package/dist/graph/DependencyGraph.js +1398 -0
- package/dist/graph/JobSummary.js +104 -0
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/graph/index.js +1 -2519
- package/dist/graph/types.js +6 -0
- package/dist/icons.d.ts +4 -4
- package/dist/icons.js +5 -5
- package/dist/index.js +46 -599
- package/dist/list/ActionToolbar.js +184 -0
- package/dist/list/HoverCard.js +73 -0
- package/dist/list/ListPage.js +145 -0
- package/dist/list/ListPager.js +59 -0
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.js +372 -0
- package/dist/list/RowContextMenu.js +351 -0
- package/dist/list/UserHoverCard.js +117 -0
- package/dist/list/index.js +11 -2
- package/dist/list/listSearch.js +137 -0
- package/dist/list/listView.js +210 -0
- package/dist/list/textEntry.js +10 -0
- package/dist/{chunks/logviewer-BTKuQWzw.js → logviewer/LogViewer.js} +4 -82
- package/dist/logviewer/index.js +2 -1
- package/dist/logviewer/segments.js +80 -0
- package/dist/safeUrl.d.ts +6 -0
- package/dist/safeUrl.js +22 -0
- package/package.json +7 -9
- package/dist/assets/editor.worker-BmHUIVG4.js +0 -14807
- package/dist/assets/json.worker-D8bJ92nw.js +0 -22207
- package/dist/assets/yaml.worker-C4gyGAko.js +0 -50201
- package/dist/chunks/PageHeader-0kG_iypP.js +0 -692
- package/dist/chunks/SwitchToggle-DShNdcao.js +0 -758
- package/dist/chunks/editor-Dk1rbV75.js +0 -361
- package/dist/chunks/list-CJm875m7.js +0 -1418
- /package/dist/{chunks/MarkdownImpl-CyeTVvSt.js → components/MarkdownImpl.js} +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { createYamlWorker } from "./workers.js";
|
|
2
|
+
import { onYamlSchemas } from "./yaml.js";
|
|
3
|
+
import * as monaco from "monaco-editor";
|
|
4
|
+
//#region src/editor/yamlLanguage.ts
|
|
5
|
+
var LANGUAGE_ID = "yaml";
|
|
6
|
+
var MARKER_OWNER = "yaml";
|
|
7
|
+
var YAML_SETTINGS = {
|
|
8
|
+
validate: true,
|
|
9
|
+
hover: true,
|
|
10
|
+
completion: true,
|
|
11
|
+
format: { enable: true },
|
|
12
|
+
schemaStore: { enable: false }
|
|
13
|
+
};
|
|
14
|
+
/** JSON-RPC over postMessage, the transport the server's web worker build expects. */
|
|
15
|
+
var WorkerConnection = class {
|
|
16
|
+
worker;
|
|
17
|
+
onRequest;
|
|
18
|
+
nextId = 0;
|
|
19
|
+
pending = /* @__PURE__ */ new Map();
|
|
20
|
+
notificationHandlers = /* @__PURE__ */ new Map();
|
|
21
|
+
constructor(worker, onRequest) {
|
|
22
|
+
this.worker = worker;
|
|
23
|
+
this.onRequest = onRequest;
|
|
24
|
+
worker.addEventListener("message", (event) => this.receive(event.data));
|
|
25
|
+
}
|
|
26
|
+
request(method, params, token) {
|
|
27
|
+
const id = this.nextId++;
|
|
28
|
+
const result = new Promise((resolve, reject) => {
|
|
29
|
+
this.pending.set(id, {
|
|
30
|
+
resolve,
|
|
31
|
+
reject
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
this.send({
|
|
35
|
+
jsonrpc: "2.0",
|
|
36
|
+
id,
|
|
37
|
+
method,
|
|
38
|
+
params
|
|
39
|
+
});
|
|
40
|
+
token?.onCancellationRequested(() => this.notify("$/cancelRequest", { id }));
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
notify(method, params) {
|
|
44
|
+
this.send({
|
|
45
|
+
jsonrpc: "2.0",
|
|
46
|
+
method,
|
|
47
|
+
params
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
onNotification(method, handler) {
|
|
51
|
+
this.notificationHandlers.set(method, handler);
|
|
52
|
+
}
|
|
53
|
+
send(message) {
|
|
54
|
+
this.worker.postMessage(message);
|
|
55
|
+
}
|
|
56
|
+
receive(message) {
|
|
57
|
+
if (message.method === void 0) {
|
|
58
|
+
const waiter = typeof message.id === "number" ? this.pending.get(message.id) : void 0;
|
|
59
|
+
if (!waiter || typeof message.id !== "number") return;
|
|
60
|
+
this.pending.delete(message.id);
|
|
61
|
+
if (message.error) waiter.reject(new Error(message.error.message));
|
|
62
|
+
else waiter.resolve(message.result);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (message.id === void 0) {
|
|
66
|
+
this.notificationHandlers.get(message.method)?.(message.params);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
Promise.resolve().then(() => this.onRequest(message.method ?? "", message.params)).then((result) => this.send({
|
|
70
|
+
jsonrpc: "2.0",
|
|
71
|
+
id: message.id ?? null,
|
|
72
|
+
result: result ?? null
|
|
73
|
+
}), (error) => this.send({
|
|
74
|
+
jsonrpc: "2.0",
|
|
75
|
+
id: message.id ?? null,
|
|
76
|
+
error: {
|
|
77
|
+
code: -32603,
|
|
78
|
+
message: String(error)
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
function toRange(range) {
|
|
84
|
+
return {
|
|
85
|
+
startLineNumber: range.start.line + 1,
|
|
86
|
+
startColumn: range.start.character + 1,
|
|
87
|
+
endLineNumber: range.end.line + 1,
|
|
88
|
+
endColumn: range.end.character + 1
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function toPosition(position) {
|
|
92
|
+
return {
|
|
93
|
+
line: position.lineNumber - 1,
|
|
94
|
+
character: position.column - 1
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function toMarkdown(content) {
|
|
98
|
+
if (typeof content === "string") return { value: content };
|
|
99
|
+
if ("kind" in content) return { value: content.value };
|
|
100
|
+
return { value: `\`\`\`${content.language}\n${content.value}\n\`\`\`` };
|
|
101
|
+
}
|
|
102
|
+
var SEVERITY = {
|
|
103
|
+
1: monaco.MarkerSeverity.Error,
|
|
104
|
+
2: monaco.MarkerSeverity.Warning,
|
|
105
|
+
3: monaco.MarkerSeverity.Info,
|
|
106
|
+
4: monaco.MarkerSeverity.Hint
|
|
107
|
+
};
|
|
108
|
+
function toMarker(diagnostic) {
|
|
109
|
+
return {
|
|
110
|
+
...toRange(diagnostic.range),
|
|
111
|
+
severity: SEVERITY[diagnostic.severity ?? 1] ?? monaco.MarkerSeverity.Error,
|
|
112
|
+
message: diagnostic.message,
|
|
113
|
+
...diagnostic.code === void 0 ? {} : { code: String(diagnostic.code) },
|
|
114
|
+
...diagnostic.source === void 0 ? {} : { source: diagnostic.source }
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
var KIND = monaco.languages.CompletionItemKind;
|
|
118
|
+
var COMPLETION_KIND = {
|
|
119
|
+
1: KIND.Text,
|
|
120
|
+
2: KIND.Method,
|
|
121
|
+
3: KIND.Function,
|
|
122
|
+
4: KIND.Constructor,
|
|
123
|
+
5: KIND.Field,
|
|
124
|
+
6: KIND.Variable,
|
|
125
|
+
7: KIND.Class,
|
|
126
|
+
8: KIND.Interface,
|
|
127
|
+
9: KIND.Module,
|
|
128
|
+
10: KIND.Property,
|
|
129
|
+
11: KIND.Unit,
|
|
130
|
+
12: KIND.Value,
|
|
131
|
+
13: KIND.Enum,
|
|
132
|
+
14: KIND.Keyword,
|
|
133
|
+
15: KIND.Snippet,
|
|
134
|
+
16: KIND.Color,
|
|
135
|
+
17: KIND.File,
|
|
136
|
+
18: KIND.Reference,
|
|
137
|
+
19: KIND.Folder,
|
|
138
|
+
20: KIND.EnumMember,
|
|
139
|
+
21: KIND.Constant,
|
|
140
|
+
22: KIND.Struct,
|
|
141
|
+
23: KIND.Event,
|
|
142
|
+
24: KIND.Operator,
|
|
143
|
+
25: KIND.TypeParameter
|
|
144
|
+
};
|
|
145
|
+
function toCompletion(item, defaultRange) {
|
|
146
|
+
const edit = item.textEdit;
|
|
147
|
+
let range = defaultRange;
|
|
148
|
+
if (edit && "range" in edit) range = toRange(edit.range);
|
|
149
|
+
else if (edit) range = {
|
|
150
|
+
insert: toRange(edit.insert),
|
|
151
|
+
replace: toRange(edit.replace)
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
label: item.label,
|
|
155
|
+
kind: COMPLETION_KIND[item.kind ?? 1] ?? KIND.Text,
|
|
156
|
+
insertText: edit?.newText ?? item.insertText ?? item.label,
|
|
157
|
+
range,
|
|
158
|
+
...item.insertTextFormat === 2 ? { insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet } : {},
|
|
159
|
+
...item.detail === void 0 ? {} : { detail: item.detail },
|
|
160
|
+
...item.documentation === void 0 ? {} : { documentation: toMarkdown(item.documentation) },
|
|
161
|
+
...item.sortText === void 0 ? {} : { sortText: item.sortText },
|
|
162
|
+
...item.filterText === void 0 ? {} : { filterText: item.filterText },
|
|
163
|
+
...item.commitCharacters === void 0 ? {} : { commitCharacters: item.commitCharacters },
|
|
164
|
+
...item.additionalTextEdits === void 0 ? {} : { additionalTextEdits: item.additionalTextEdits.map((e) => ({
|
|
165
|
+
range: toRange(e.range),
|
|
166
|
+
text: e.newText
|
|
167
|
+
})) },
|
|
168
|
+
...item.command === void 0 ? {} : { command: {
|
|
169
|
+
id: item.command.command,
|
|
170
|
+
title: item.command.title,
|
|
171
|
+
...item.command.arguments === void 0 ? {} : { arguments: item.command.arguments }
|
|
172
|
+
} }
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function toEdits(edits) {
|
|
176
|
+
return (edits ?? []).map((edit) => ({
|
|
177
|
+
range: toRange(edit.range),
|
|
178
|
+
text: edit.newText
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
function answerServer(method, params) {
|
|
182
|
+
if (method === "workspace/configuration") {
|
|
183
|
+
const { items } = params;
|
|
184
|
+
return items.map((item) => item.section === "yaml" ? YAML_SETTINGS : null);
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
function startYamlLanguage() {
|
|
189
|
+
const worker = createYamlWorker();
|
|
190
|
+
worker.postMessage({});
|
|
191
|
+
const connection = new WorkerConnection(worker, answerServer);
|
|
192
|
+
const open = /* @__PURE__ */ new Map();
|
|
193
|
+
const ready = connection.request("initialize", {
|
|
194
|
+
processId: null,
|
|
195
|
+
rootUri: null,
|
|
196
|
+
capabilities: {
|
|
197
|
+
workspace: { configuration: true },
|
|
198
|
+
textDocument: {
|
|
199
|
+
synchronization: {},
|
|
200
|
+
completion: { completionItem: {
|
|
201
|
+
snippetSupport: true,
|
|
202
|
+
insertReplaceSupport: true,
|
|
203
|
+
documentationFormat: ["markdown", "plaintext"]
|
|
204
|
+
} },
|
|
205
|
+
hover: { contentFormat: ["markdown", "plaintext"] },
|
|
206
|
+
publishDiagnostics: {}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}).then(() => {
|
|
210
|
+
connection.notify("initialized", {});
|
|
211
|
+
connection.notify("workspace/didChangeConfiguration", { settings: null });
|
|
212
|
+
});
|
|
213
|
+
onYamlSchemas((schemas) => {
|
|
214
|
+
ready.then(() => connection.notify("json/schemaAssociations", [schemas]));
|
|
215
|
+
});
|
|
216
|
+
connection.onNotification("textDocument/publishDiagnostics", (params) => {
|
|
217
|
+
const { uri, diagnostics } = params;
|
|
218
|
+
const model = open.get(uri);
|
|
219
|
+
if (model && !model.isDisposed()) monaco.editor.setModelMarkers(model, MARKER_OWNER, diagnostics.map(toMarker));
|
|
220
|
+
});
|
|
221
|
+
function close(uri, model) {
|
|
222
|
+
open.delete(uri);
|
|
223
|
+
ready.then(() => connection.notify("textDocument/didClose", { textDocument: { uri } }));
|
|
224
|
+
if (!model.isDisposed()) monaco.editor.setModelMarkers(model, MARKER_OWNER, []);
|
|
225
|
+
}
|
|
226
|
+
function track(model) {
|
|
227
|
+
const uri = model.uri.toString();
|
|
228
|
+
const sync = () => {
|
|
229
|
+
const isYaml = model.getLanguageId() === LANGUAGE_ID;
|
|
230
|
+
if (isYaml && !open.has(uri)) {
|
|
231
|
+
open.set(uri, model);
|
|
232
|
+
const textDocument = {
|
|
233
|
+
uri,
|
|
234
|
+
languageId: LANGUAGE_ID,
|
|
235
|
+
version: model.getVersionId(),
|
|
236
|
+
text: model.getValue()
|
|
237
|
+
};
|
|
238
|
+
ready.then(() => connection.notify("textDocument/didOpen", { textDocument }));
|
|
239
|
+
} else if (!isYaml && open.has(uri)) close(uri, model);
|
|
240
|
+
};
|
|
241
|
+
model.onDidChangeLanguage(sync);
|
|
242
|
+
model.onDidChangeContent(() => {
|
|
243
|
+
if (!open.has(uri)) return;
|
|
244
|
+
const params = {
|
|
245
|
+
textDocument: {
|
|
246
|
+
uri,
|
|
247
|
+
version: model.getVersionId()
|
|
248
|
+
},
|
|
249
|
+
contentChanges: [{ text: model.getValue() }]
|
|
250
|
+
};
|
|
251
|
+
ready.then(() => connection.notify("textDocument/didChange", params));
|
|
252
|
+
});
|
|
253
|
+
model.onWillDispose(() => {
|
|
254
|
+
if (open.get(uri) === model) close(uri, model);
|
|
255
|
+
});
|
|
256
|
+
sync();
|
|
257
|
+
}
|
|
258
|
+
for (const model of monaco.editor.getModels()) track(model);
|
|
259
|
+
monaco.editor.onDidCreateModel(track);
|
|
260
|
+
async function request(method, model, params, token) {
|
|
261
|
+
await ready;
|
|
262
|
+
return connection.request(method, {
|
|
263
|
+
textDocument: { uri: model.uri.toString() },
|
|
264
|
+
...params
|
|
265
|
+
}, token);
|
|
266
|
+
}
|
|
267
|
+
monaco.languages.registerCompletionItemProvider(LANGUAGE_ID, {
|
|
268
|
+
triggerCharacters: [" ", ":"],
|
|
269
|
+
async provideCompletionItems(model, position, _context, token) {
|
|
270
|
+
const result = await request("textDocument/completion", model, { position: toPosition(position) }, token);
|
|
271
|
+
const word = model.getWordUntilPosition(position);
|
|
272
|
+
const defaultRange = {
|
|
273
|
+
startLineNumber: position.lineNumber,
|
|
274
|
+
startColumn: word.startColumn,
|
|
275
|
+
endLineNumber: position.lineNumber,
|
|
276
|
+
endColumn: word.endColumn
|
|
277
|
+
};
|
|
278
|
+
const items = Array.isArray(result) ? result : result?.items ?? [];
|
|
279
|
+
return {
|
|
280
|
+
incomplete: !Array.isArray(result) && Boolean(result?.isIncomplete),
|
|
281
|
+
suggestions: items.map((item) => toCompletion(item, defaultRange))
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
monaco.languages.registerHoverProvider(LANGUAGE_ID, { async provideHover(model, position, token) {
|
|
286
|
+
const hover = await request("textDocument/hover", model, { position: toPosition(position) }, token);
|
|
287
|
+
if (!hover) return null;
|
|
288
|
+
return {
|
|
289
|
+
contents: (Array.isArray(hover.contents) ? hover.contents : [hover.contents]).map(toMarkdown),
|
|
290
|
+
...hover.range === void 0 ? {} : { range: toRange(hover.range) }
|
|
291
|
+
};
|
|
292
|
+
} });
|
|
293
|
+
monaco.languages.registerDocumentFormattingEditProvider(LANGUAGE_ID, { async provideDocumentFormattingEdits(model, options, token) {
|
|
294
|
+
return toEdits(await request("textDocument/formatting", model, { options: {
|
|
295
|
+
tabSize: options.tabSize,
|
|
296
|
+
insertSpaces: options.insertSpaces
|
|
297
|
+
} }, token));
|
|
298
|
+
} });
|
|
299
|
+
}
|
|
300
|
+
var started = false;
|
|
301
|
+
/**
|
|
302
|
+
* Starts the YAML language server and connects every yaml model to it. Runs
|
|
303
|
+
* once per page and is never torn down: a per-editor lifecycle let navigation
|
|
304
|
+
* stop the service, killing suggestions until reload.
|
|
305
|
+
*/
|
|
306
|
+
function ensureYamlLanguage() {
|
|
307
|
+
if (started) return;
|
|
308
|
+
started = true;
|
|
309
|
+
startYamlLanguage();
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
export { ensureYamlLanguage };
|