@parallelworks/ui 0.19.1 → 0.21.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.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/adapter/openai/createOpenAIStream.js +3 -2
  3. package/dist/ai/agent/diff.d.ts +0 -1
  4. package/dist/ai/agent/diff.js +3 -2
  5. package/dist/ai/agent/toolfmt.js +2 -3
  6. package/dist/ai/ai.css +5 -0
  7. package/dist/ai/components/AllocationSelector.js +3 -2
  8. package/dist/ai/components/AttachmentManager.js +5 -2
  9. package/dist/ai/components/BranchNavigator.js +4 -2
  10. package/dist/ai/components/ChatInput.d.ts +2 -5
  11. package/dist/ai/components/ChatInput.js +10 -7
  12. package/dist/ai/components/ChatMessage.js +11 -8
  13. package/dist/ai/components/ChatSidebar.d.ts +0 -1
  14. package/dist/ai/components/ChatSidebar.js +4 -6
  15. package/dist/ai/components/ChatThread.js +5 -8
  16. package/dist/ai/components/ModelSelector.js +3 -2
  17. package/dist/ai/components/ShareDialog.js +6 -3
  18. package/dist/ai/components/SlashMenu.d.ts +0 -1
  19. package/dist/ai/components/agent/ActivityLine.d.ts +0 -1
  20. package/dist/ai/components/agent/ActivityLine.js +2 -2
  21. package/dist/ai/components/agent/AgentMessageParts.d.ts +1 -26
  22. package/dist/ai/components/agent/AgentMessageParts.js +4 -5
  23. package/dist/ai/core/ChatProvider.d.ts +2 -6
  24. package/dist/ai/core/ChatProvider.js +42 -67
  25. package/dist/ai/core/KeyboardShortcutsProvider.js +1 -1
  26. package/dist/ai/core/chatReducer.d.ts +0 -6
  27. package/dist/ai/core/chatReducer.js +1 -15
  28. package/dist/ai/core/config.js +2 -1
  29. package/dist/ai/core/useKeyboardShortcuts.d.ts +3 -1
  30. package/dist/ai/core/useKeyboardShortcuts.js +9 -11
  31. package/dist/ai/core/useSSEStream.d.ts +0 -1
  32. package/dist/ai/core/useSSEStream.js +5 -17
  33. package/dist/ai/strings.d.ts +0 -1
  34. package/dist/ai/strings.js +0 -1
  35. package/dist/ai/types.d.ts +1 -1
  36. package/dist/ai/ui/Avatar.d.ts +1 -2
  37. package/dist/ai/ui/Avatar.js +7 -18
  38. package/dist/ai/ui/Markdown.d.ts +1 -3
  39. package/dist/ai/ui/Markdown.js +1 -2
  40. package/dist/ai/ui/sidebar.d.ts +0 -1
  41. package/dist/ai/ui/sidebar.js +3 -1
  42. package/dist/ai/utils.js +1 -1
  43. package/dist/assets/editor.worker-DfmPPyOL.js +60 -0
  44. package/dist/assets/json.worker-Dqgjpq9F.js +92 -0
  45. package/dist/assets/yaml.worker-DLx0whrM.js +1441 -0
  46. package/dist/components/Avatar.js +4 -2
  47. package/dist/components/BareModal.js +1 -5
  48. package/dist/components/Breadcrumbs.js +21 -14
  49. package/dist/components/CollapsiblePanel.d.ts +1 -3
  50. package/dist/components/CollapsiblePanel.js +5 -5
  51. package/dist/components/Dropdown.d.ts +0 -4
  52. package/dist/components/Dropdown.js +5 -6
  53. package/dist/components/Listbox.js +14 -18
  54. package/dist/components/MultiSelect.js +5 -8
  55. package/dist/components/Pagination.js +1 -1
  56. package/dist/components/Provider.d.ts +0 -8
  57. package/dist/components/Provider.js +12 -4
  58. package/dist/components/SwitchToggle.js +3 -5
  59. package/dist/components/Table.d.ts +1 -3
  60. package/dist/components/dropdownUtils.js +5 -6
  61. package/dist/components/relativeTime.d.ts +0 -7
  62. package/dist/components/relativeTime.js +1 -1
  63. package/dist/duration.js +1 -1
  64. package/dist/editor/Editor.d.ts +1 -1
  65. package/dist/editor/Editor.js +1 -1
  66. package/dist/editor/EditorField.d.ts +0 -1
  67. package/dist/editor/EditorField.js +8 -8
  68. package/dist/editor/FormCodePanel.js +14 -20
  69. package/dist/editor/Monaco.js +2 -25
  70. package/dist/editor/workers.d.ts +5 -0
  71. package/dist/editor/workers.js +14 -8
  72. package/dist/editor/yaml.d.ts +9 -1
  73. package/dist/editor/yaml.worker.d.ts +1 -0
  74. package/dist/editor/yamlLanguage.d.ts +6 -0
  75. package/dist/editor/yamlLanguage.js +312 -0
  76. package/dist/file-explorer/FileExplorer.js +60 -60
  77. package/dist/file-explorer/FileExplorerContext.d.ts +1 -2
  78. package/dist/file-explorer/FileExplorerContext.js +92 -125
  79. package/dist/file-explorer/FilePreview/Inline.d.ts +1 -2
  80. package/dist/file-explorer/FilePreview/Inline.js +2 -2
  81. package/dist/file-explorer/FilePreview/Viewer.js +0 -4
  82. package/dist/file-explorer/FilePreview/index.d.ts +1 -2
  83. package/dist/file-explorer/FilePreview/index.js +3 -3
  84. package/dist/file-explorer/FilePreview/parse.d.ts +2 -1
  85. package/dist/file-explorer/FilePreview/useObjectBlobUrl.d.ts +5 -4
  86. package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +23 -36
  87. package/dist/file-explorer/FilePreview/useObjectText.d.ts +1 -2
  88. package/dist/file-explorer/FilePreview/useObjectText.js +5 -7
  89. package/dist/file-explorer/FileRow.js +1 -1
  90. package/dist/file-explorer/FileRowsWindow.d.ts +5 -12
  91. package/dist/file-explorer/FileTable.d.ts +2 -6
  92. package/dist/file-explorer/LoadMoreRow.d.ts +8 -0
  93. package/dist/file-explorer/TreeView.d.ts +0 -1
  94. package/dist/file-explorer/TreeView.js +6 -6
  95. package/dist/file-explorer/helpers.js +2 -4
  96. package/dist/file-explorer/lib/fileExplorer.d.ts +0 -2
  97. package/dist/file-explorer/lib/types.d.ts +0 -1
  98. package/dist/file-explorer/lib/utils.js +15 -20
  99. package/dist/file-explorer/toasts.js +36 -34
  100. package/dist/form/Fields/BooleanField.js +5 -4
  101. package/dist/form/Fields/CheckboxGroupField.js +5 -4
  102. package/dist/form/Fields/ColorField.js +5 -4
  103. package/dist/form/Fields/DropdownField.d.ts +0 -1
  104. package/dist/form/Fields/DropdownField.js +10 -13
  105. package/dist/form/Fields/DurationField.js +2 -2
  106. package/dist/form/Fields/LabelField.js +5 -5
  107. package/dist/form/Fields/MultiDropdownField.d.ts +1 -1
  108. package/dist/form/Fields/MultiDropdownField.js +8 -11
  109. package/dist/form/Fields/NumberField.js +6 -5
  110. package/dist/form/Fields/ObjectField.d.ts +1 -2
  111. package/dist/form/Fields/ObjectField.js +22 -21
  112. package/dist/form/Fields/RadioField.js +4 -3
  113. package/dist/form/Fields/RangeField.js +7 -6
  114. package/dist/form/Fields/StringField.js +2 -1
  115. package/dist/form/Fields/TextAreaField.js +2 -1
  116. package/dist/form/Form.d.ts +7 -8
  117. package/dist/form/Form.js +52 -78
  118. package/dist/form/SpecialTypes/DropdownWrapper.d.ts +0 -2
  119. package/dist/form/SpecialTypes/DropdownWrapper.js +1 -3
  120. package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +1 -3
  121. package/dist/form/SpecialTypes/FormikCustomDropdown.js +4 -7
  122. package/dist/form/SpecialTypes/FormikCustomInput.js +13 -11
  123. package/dist/form/Wizard/WizardContainer.js +8 -25
  124. package/dist/form/Wizard/WizardNavigation.d.ts +1 -1
  125. package/dist/form/Wizard/WizardNavigation.js +5 -6
  126. package/dist/form/Wizard/WizardStepContent.d.ts +1 -1
  127. package/dist/form/Wizard/WizardStepContent.js +2 -2
  128. package/dist/form/Wizard/WizardStepIndicator.js +7 -17
  129. package/dist/form/Wizard/types.d.ts +4 -46
  130. package/dist/form/Wizard/useWizardState.d.ts +2 -10
  131. package/dist/form/Wizard/useWizardState.js +42 -92
  132. package/dist/form/Wizard/utils.js +6 -11
  133. package/dist/form/lib.js +28 -54
  134. package/dist/form/types/fieldTypes.d.ts +4 -5
  135. package/dist/form/utils/dependentOptions.d.ts +6 -0
  136. package/dist/form/utils/dependentOptions.js +21 -0
  137. package/dist/form/utils/getParentValue.d.ts +2 -1
  138. package/dist/form/utils/getParentValue.js +10 -15
  139. package/dist/form/utils/getValueUsingPath.js +1 -1
  140. package/dist/graph/AnnotationBanner.d.ts +1 -1
  141. package/dist/graph/AnnotationBanner.js +1 -1
  142. package/dist/graph/Collapse.d.ts +3 -3
  143. package/dist/graph/Collapse.js +3 -8
  144. package/dist/graph/DependencyGraph.d.ts +5 -4
  145. package/dist/graph/DependencyGraph.js +172 -222
  146. package/dist/graph/JobSummary.d.ts +10 -8
  147. package/dist/graph/JobSummary.js +13 -13
  148. package/dist/graph/MatrixGroup.d.ts +5 -17
  149. package/dist/graph/MatrixGroup.js +11 -22
  150. package/dist/graph/TreeView.d.ts +1 -3
  151. package/dist/graph/TreeView.js +104 -491
  152. package/dist/graph/types.d.ts +3 -2
  153. package/dist/graph/util.d.ts +5 -0
  154. package/dist/graph/util.js +18 -0
  155. package/dist/icons.d.ts +5 -5
  156. package/dist/icons.js +6 -6
  157. package/dist/index.d.ts +1 -1
  158. package/dist/list/ListViewControls.js +17 -35
  159. package/dist/list/RowContextMenu.js +9 -8
  160. package/dist/list/UserHoverCard.js +5 -5
  161. package/dist/logviewer/LogViewer.js +7 -9
  162. package/dist/logviewer/segments.js +2 -2
  163. package/dist/safeUrl.d.ts +6 -0
  164. package/dist/safeUrl.js +22 -0
  165. package/dist/styles/theme.css +1 -0
  166. package/dist/styles.css +1 -1
  167. package/dist/theme/index.js +5 -5
  168. package/package.json +33 -37
  169. package/dist/ai/ui/buttons.d.ts +0 -1
  170. package/dist/assets/editor.worker-BmHUIVG4.js +0 -14807
  171. package/dist/assets/json.worker-D8bJ92nw.js +0 -22207
  172. package/dist/assets/yaml.worker-C4gyGAko.js +0 -50201
@@ -4,3 +4,8 @@
4
4
  * calls this on first load only when nothing is configured.
5
5
  */
6
6
  export declare function setupMonacoWorkers(): void;
7
+ /**
8
+ * Starts the YAML language server. It is not a Monaco worker, so a host's own
9
+ * MonacoEnvironment never has to provide it.
10
+ */
11
+ export declare function createYamlWorker(): Worker;
@@ -2,17 +2,12 @@
2
2
  var monacoEnvironment = { getWorker(_moduleId, label) {
3
3
  if (label === "json") return new Worker(new URL(
4
4
  /* @vite-ignore */
5
- "/assets/json.worker-D8bJ92nw.js",
6
- "" + import.meta.url
7
- ), { type: "module" });
8
- if (label === "yaml") return new Worker(new URL(
9
- /* @vite-ignore */
10
- "/assets/yaml.worker-C4gyGAko.js",
5
+ new URL("../assets/json.worker-Dqgjpq9F.js", import.meta.url).href,
11
6
  "" + import.meta.url
12
7
  ), { type: "module" });
13
8
  return new Worker(new URL(
14
9
  /* @vite-ignore */
15
- "/assets/editor.worker-BmHUIVG4.js",
10
+ new URL("../assets/editor.worker-DfmPPyOL.js", import.meta.url).href,
16
11
  "" + import.meta.url
17
12
  ), { type: "module" });
18
13
  } };
@@ -25,5 +20,16 @@ function setupMonacoWorkers() {
25
20
  if (window.MonacoEnvironment) return;
26
21
  window.MonacoEnvironment = monacoEnvironment;
27
22
  }
23
+ /**
24
+ * Starts the YAML language server. It is not a Monaco worker, so a host's own
25
+ * MonacoEnvironment never has to provide it.
26
+ */
27
+ function createYamlWorker() {
28
+ return new Worker(new URL(
29
+ /* @vite-ignore */
30
+ new URL("../assets/yaml.worker-DLx0whrM.js", import.meta.url).href,
31
+ "" + import.meta.url
32
+ ), { type: "module" });
33
+ }
28
34
  //#endregion
29
- export { setupMonacoWorkers };
35
+ export { createYamlWorker, setupMonacoWorkers };
@@ -1,4 +1,12 @@
1
- import type { SchemasSettings } from 'monaco-yaml';
1
+ /** A JSON schema for the YAML models whose URI matches one of `fileMatch`. */
2
+ export interface SchemasSettings {
3
+ /** Identifies the schema; fetched from here when `schema` is not given. */
4
+ uri: string;
5
+ /** Globs matched against model URIs, such as `**\/workflow.yaml`. */
6
+ fileMatch?: string[];
7
+ /** The schema itself, used instead of fetching `uri`. */
8
+ schema?: object;
9
+ }
2
10
  /** Adds JSON schemas that validate and complete YAML models whose URI matches. */
3
11
  export declare function configureEditorYaml(added: SchemasSettings[]): void;
4
12
  /** Lets the loaded editor pick up schemas added before or after it loads. */
@@ -0,0 +1 @@
1
+ import 'yaml-language-server/lib/esm/webworker/yamlServerMain';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Starts the YAML language server and connects every yaml model to it. Runs
3
+ * once per page and is never torn down: a per-editor lifecycle let navigation
4
+ * stop the service, killing suggestions until reload.
5
+ */
6
+ export declare function ensureYamlLanguage(): void;
@@ -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
+ nextId = 0;
17
+ pending = /* @__PURE__ */ new Map();
18
+ notificationHandlers = /* @__PURE__ */ new Map();
19
+ worker;
20
+ onRequest;
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 };