@pstdio/workbench 0.12.0 → 0.36.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 (36) hide show
  1. package/dist/extensions.d.ts +1133 -3590
  2. package/dist/extensions.js +2053 -2405
  3. package/dist/extensions.js.map +1 -1
  4. package/dist/file-renderer-view-DKu2l8bT.js +637 -0
  5. package/dist/file-renderer-view-DKu2l8bT.js.map +1 -0
  6. package/dist/index-DSsmgN2a.d.ts +2385 -0
  7. package/dist/index.d.ts +3 -2624
  8. package/dist/index.js +5272 -6143
  9. package/dist/index.js.map +1 -1
  10. package/dist/kanban-presentation-BWhkLbw3.d.ts +14 -0
  11. package/dist/navigation-tree-registry-CTidmvVs.js +91 -0
  12. package/dist/navigation-tree-registry-CTidmvVs.js.map +1 -0
  13. package/dist/react-BxrTklvM.js +8523 -0
  14. package/dist/react-BxrTklvM.js.map +1 -0
  15. package/dist/react.d.ts +398 -2849
  16. package/dist/react.js +2 -54
  17. package/dist/storage.d.ts +48 -282
  18. package/dist/storage.js +218 -225
  19. package/dist/storage.js.map +1 -1
  20. package/dist/webview-runtime.d.ts +8 -7
  21. package/dist/webview-runtime.js +10 -11
  22. package/dist/webview-runtime.js.map +1 -1
  23. package/dist/workbench-renderers-RPeMVtTc.js +908 -0
  24. package/dist/workbench-renderers-RPeMVtTc.js.map +1 -0
  25. package/package.json +3 -3
  26. package/dist/file-renderer-view-BJ3LX04R.js +0 -545
  27. package/dist/file-renderer-view-BJ3LX04R.js.map +0 -1
  28. package/dist/index-DwNKY4fO.js +0 -5286
  29. package/dist/index-DwNKY4fO.js.map +0 -1
  30. package/dist/react.js.map +0 -1
  31. package/dist/workbench-menu-paths-B_QJzcNU.js +0 -12
  32. package/dist/workbench-menu-paths-B_QJzcNU.js.map +0 -1
  33. package/dist/workbench-renderers-BAPxtfpZ.js +0 -877
  34. package/dist/workbench-renderers-BAPxtfpZ.js.map +0 -1
  35. package/dist/workspaces-DdUPyzkL.js +0 -1886
  36. package/dist/workspaces-DdUPyzkL.js.map +0 -1
@@ -1,2410 +1,2058 @@
1
- import { jsxs as ue, jsx as N } from "react/jsx-runtime";
2
- import { useRef as k, useState as be, useEffect as O, createElement as V } from "react";
3
- import { host as Ge } from "rimless";
4
- import { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES as Qe, WEBVIEW_HOST_CAPABILITY_VERSION as re, WEBVIEW_HOST_CAPABILITIES as Xe, WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES as Ye, isNavigationTarget as ie, qualifyNavigationTarget as Je, resourceKey as M, isLocalizedString as Ze, matchesResourceWhen as et } from "@pstdio/sdk/extensions";
5
- import { b as tt, W as K, a as nt } from "./workspaces-DdUPyzkL.js";
6
- import { renderBadgeListDisplay as ot } from "@pstdio/ui/kanban-renderer";
7
- import { w as st } from "./workbench-menu-paths-B_QJzcNU.js";
8
- const rt = (e) => typeof e == "object" && e !== null && "$l10n" in e && typeof e.$l10n == "string", it = new Set(Xe), at = new Set(Ye), Re = (e) => it.has(e), Ee = (e) => at.has(e), dt = (e) => {
9
- const [t = "", n] = e.split("@"), o = t.indexOf(":"), r = o === -1 ? t : t.slice(0, o), s = o === -1 ? void 0 : t.slice(o + 1), i = n === void 0 ? re : Number(n);
10
- return {
11
- capability: e,
12
- name: r,
13
- scope: s,
14
- version: i
15
- };
16
- }, ct = (e) => Ee(e.name) ? !!e.scope : e.scope === void 0, F = (e) => ({
17
- capability: e,
18
- code: "unsupported_webview_capability",
19
- message: `Unsupported webview capability: ${e}`,
20
- severity: "error"
21
- }), lt = (e, t, n) => ({
22
- capability: e,
23
- code: "unsupported_webview_capability_version",
24
- message: `Unsupported webview capability version: ${t}@${n.toString()} (supported: ${re.toString()})`,
25
- severity: "error"
26
- }), pe = (e) => ({
27
- capability: e,
28
- code: "undeclared_webview_capability",
29
- message: `Webview did not declare host capability: ${e}`,
30
- severity: "error"
31
- }), mt = (e, t = {}) => {
32
- const n = [], o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
33
- for (const s of Qe)
34
- t[s] && o.add(s);
35
- for (const s of e ?? []) {
36
- const i = dt(s);
37
- if (!Re(i.name) || !ct(i)) {
38
- n.push(F(s));
39
- continue;
40
- }
41
- if (i.version !== re) {
42
- n.push(lt(s, i.name, i.version));
43
- continue;
44
- }
45
- if (!t[i.name]) {
46
- n.push(F(s));
47
- continue;
48
- }
49
- if (i.scope === void 0) {
50
- o.add(i.name);
51
- continue;
52
- }
53
- const a = r.get(i.name) ?? /* @__PURE__ */ new Set();
54
- a.add(i.scope), r.set(i.name, a);
55
- }
56
- return {
57
- allowed: o,
58
- allowedScopes: r,
59
- diagnostics: n
60
- };
61
- }, ut = (e) => {
62
- const t = e.params;
63
- return typeof t?.mount == "string" && t.mount.length > 0 ? t.mount : void 0;
64
- }, bt = (e) => {
65
- const {
66
- allowed: t,
67
- allowedScopes: n,
68
- diagnostics: o
69
- } = mt(e.declaredCapabilities, e.capabilities), r = (i) => {
70
- e.onDiagnostic?.(i);
71
- }, s = (i) => (r(i), new Error(i.message));
72
- return {
73
- diagnostics: o,
74
- async call(i) {
75
- if (!Re(i.method)) throw s(F(i.method));
76
- if (Ee(i.method)) {
77
- const d = ut(i);
78
- if (!d) throw s(F(i.method));
79
- if (!n.get(i.method)?.has(d))
80
- throw s(pe(`${i.method}:${d}`));
81
- } else if (!t.has(i.method))
82
- throw s(pe(i.method));
83
- const a = e.capabilities[i.method];
84
- if (!a) throw s(F(i.method));
85
- return await a(i.params);
86
- }
87
- };
88
- }, pt = (e) => typeof e == "object" && e !== null, fe = (e) => {
89
- try {
90
- const t = JSON.stringify(e);
91
- if (typeof t == "string" && t.length > 0) return t;
92
- } catch {
93
- }
94
- try {
95
- return String(e);
96
- } catch {
97
- return "Unknown error";
98
- }
99
- }, ft = (e) => {
100
- if (e instanceof Error) return {
101
- message: e.message,
102
- stack: e.stack
103
- };
104
- if (typeof e == "string") return {
105
- message: e
106
- };
107
- if (pt(e)) {
108
- const t = typeof e.message == "string" ? e.message : null, n = typeof e.stack == "string" ? e.stack : void 0;
109
- return t ? n ? {
110
- message: t,
111
- stack: n
112
- } : {
113
- message: t
114
- } : {
115
- message: fe(e)
116
- };
117
- }
118
- return e == null ? {
119
- message: "Unknown error"
120
- } : {
121
- message: fe(e)
122
- };
123
- }, ee = () => {
124
- if (typeof document > "u") return {};
125
- const e = getComputedStyle(document.documentElement), t = {};
126
- for (let n = 0; n < e.length; n += 1) {
127
- const o = e.item(n);
128
- o.startsWith("--chakra-") && (t[o] = e.getPropertyValue(o).trim());
129
- }
130
- return t;
131
- }, te = (e) => {
132
- if (typeof document > "u") return e;
133
- const t = document.documentElement.getAttribute("data-theme");
134
- if (t === "dark" || t === "light") return t;
135
- const n = document.documentElement.getAttribute("data-color-mode");
136
- return n === "dark" || n === "light" ? n : e;
137
- }, ht = {
138
- border: 0,
139
- display: "block",
140
- flex: "1 1 0%",
141
- height: "100%",
142
- minHeight: 0,
143
- width: "100%"
144
- }, wt = {
145
- display: "flex",
146
- height: "100%",
147
- minHeight: 0,
148
- position: "relative",
149
- width: "100%"
150
- }, gt = {
151
- alignItems: "center",
152
- background: "rgba(255, 255, 255, 0.92)",
153
- color: "#7a1f12",
154
- display: "flex",
155
- inset: 0,
156
- justifyContent: "center",
157
- padding: "24px",
158
- position: "absolute",
159
- textAlign: "center",
160
- zIndex: 1
161
- }, It = "allow-scripts allow-forms allow-popups", vt = (e) => {
162
- const {
163
- view: t,
164
- props: n,
165
- theme: o,
166
- capabilities: r,
167
- hostEvents: s,
168
- onReady: i,
169
- onError: a,
170
- onDiagnostics: d,
171
- title: m
172
- } = e, c = k(null), l = k(null), b = k(null), u = k(!1), w = k(null), R = k(n), E = k(o), T = k(r), H = k(s), U = k(t.webview.capabilities), J = k(i), j = k(a), f = k(d), [x, g] = be(null), [P, q] = be(0);
173
- return R.current = n, E.current = o, T.current = r, H.current = s, U.current = t.webview.capabilities, J.current = i, j.current = a, f.current = d, O(() => {
174
- const h = c.current;
175
- if (!h) return;
176
- const A = () => {
177
- l.current === h ? q((y) => y + 1) : l.current = h;
178
- };
179
- h.addEventListener("load", A);
180
- const C = () => h.removeEventListener("load", A), D = `${P}
181
- ${t.webview.runtimeUrl}
182
- ${t.webview.moduleUrl}`;
183
- if (w.current === D) return C;
184
- w.current = D;
185
- const _e = t.webview.styles, Ue = t.webview.moduleUrl, le = (y) => {
186
- y.length > 0 && f.current?.(y);
187
- }, me = () => bt({
188
- capabilities: T.current ?? {},
189
- declaredCapabilities: U.current,
190
- onDiagnostic: (y) => le([y])
191
- });
192
- le(me().diagnostics);
193
- const qe = {
194
- ready: () => {
195
- },
196
- runtimeError: (y) => {
197
- g(y.message), j.current?.(y);
198
- },
199
- call: async (y) => await me().call(y)
200
- };
201
- return (() => {
202
- u.current = !1, b.current = null;
203
- const y = Ge.connect(h, qe);
204
- h.contentWindow?.location.replace(t.webview.runtimeUrl), y.then(async (Z) => {
205
- if (c.current !== h) return;
206
- const W = Z.remote;
207
- b.current = W, H.current?.bind((ze) => W.hostEvent?.(ze)), await W.init({
208
- moduleUrl: Ue,
209
- styles: _e,
210
- props: R.current,
211
- theme: te(E.current),
212
- themeVariables: ee(),
213
- extensionId: t.extensionId
214
- }), c.current === h && (u.current = !0, g(null), J.current?.());
215
- }).catch((Z) => {
216
- if (c.current !== h) return;
217
- const W = ft(Z);
218
- g(W.message), j.current?.(W);
219
- });
220
- })(), C;
221
- }, [P, t.extensionId, t.webview.runtimeUrl, t.webview.moduleUrl, t.webview.styles]), O(() => {
222
- const h = b.current;
223
- if (!(!h || !s))
224
- return s.bind((A) => h.hostEvent?.(A)), () => s.unbind();
225
- }, [s]), O(() => {
226
- u.current && b.current?.propsUpdate({
227
- props: n
228
- });
229
- }, [n]), O(() => {
230
- u.current && b.current?.themeUpdate({
231
- theme: te(o),
232
- variables: ee()
233
- });
234
- }, [o]), O(() => {
235
- if (typeof window > "u" || typeof MutationObserver > "u") return;
236
- let h = null;
237
- const A = () => {
238
- h !== null && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
239
- h = null, u.current && b.current?.themeUpdate({
240
- theme: te(E.current),
241
- variables: ee()
242
- });
243
- });
244
- }, C = new MutationObserver(A), D = {
245
- attributeFilter: ["class", "data-color-mode", "data-theme", "style"],
246
- attributes: !0
247
- };
248
- return C.observe(document.documentElement, D), C.observe(document.body, D), () => {
249
- C.disconnect(), h !== null && cancelAnimationFrame(h);
250
- };
251
- }, []), /* @__PURE__ */ ue("div", { style: wt, children: [
252
- x ? /* @__PURE__ */ N("div", { role: "alert", style: gt, children: /* @__PURE__ */ ue("div", { children: [
253
- /* @__PURE__ */ N("strong", { children: "Extension view failed to load." }),
254
- /* @__PURE__ */ N("div", { children: x })
255
- ] }) }) : null,
256
- /* @__PURE__ */ N(
257
- "iframe",
258
- {
259
- ref: c,
260
- title: m ?? t.label,
261
- allow: "fullscreen",
262
- allowFullScreen: !0,
263
- sandbox: It,
264
- style: {
265
- ...ht,
266
- colorScheme: o
267
- },
268
- onError: () => {
269
- const h = `Failed to load extension runtime at ${t.webview.runtimeUrl}`;
270
- g(h), j.current?.({
271
- message: h
272
- });
273
- }
274
- },
275
- `${P}
276
- ${t.webview.runtimeUrl}
277
- ${t.webview.moduleUrl}`
278
- )
279
- ] });
280
- }, yt = "[pstdio.extension-host] ", kt = (e, t = console.info) => {
281
- t(`${yt}${JSON.stringify(e)}`);
282
- }, xt = (e, t) => {
283
- const n = (o) => kt({
284
- extensionId: e.extensionId,
285
- contributionId: e.id,
286
- ...o
287
- }, t);
288
- return {
289
- onReady: () => n({
290
- event: "webview-ready"
291
- }),
292
- onError: (o) => n({
293
- event: "webview-error",
294
- ...o
295
- }),
296
- onDiagnostics: (o) => {
297
- for (const r of o) n({
298
- event: "webview-diagnostic",
299
- ...r
300
- });
301
- }
302
- };
303
- }, Rt = () => {
304
- let e = null;
305
- const t = [], n = /* @__PURE__ */ new Set();
306
- return {
307
- emit(o) {
308
- e ? e(o) : t.push(o);
309
- },
310
- bind(o) {
311
- for (e = o; t.length > 0; ) o(t.shift());
312
- },
313
- onDisconnect(o) {
314
- return n.add(o), () => n.delete(o);
315
- },
316
- unbind() {
317
- e = null;
318
- for (const o of n) o();
319
- }
320
- };
321
- }, Et = "terminal.session", At = (e) => {
322
- const {
323
- terminal: t,
324
- hostEvents: n
325
- } = e, o = (r) => {
326
- n.emit({
327
- scope: Et,
328
- payload: r
329
- });
330
- };
331
- return async (r) => {
332
- const s = r;
333
- switch (s.operation) {
334
- case "open": {
335
- const {
336
- sessionId: i
337
- } = await t.open({
338
- request: s.request
339
- });
340
- return {
341
- operation: "open",
342
- sessionId: i
343
- };
344
- }
345
- case "write":
346
- return t.write({
347
- sessionId: s.sessionId,
348
- data: s.data
349
- }), {
350
- operation: "write",
351
- accepted: !0
352
- };
353
- case "resize":
354
- return t.resize({
355
- sessionId: s.sessionId,
356
- cols: s.cols,
357
- rows: s.rows
358
- }), {
359
- operation: "resize",
360
- accepted: !0
361
- };
362
- case "kill":
363
- return await t.kill({
364
- sessionId: s.sessionId,
365
- signal: s.signal
366
- }), {
367
- operation: "kill",
368
- accepted: !0
369
- };
370
- case "subscribe": {
371
- const {
372
- sessionId: i
373
- } = s;
374
- let a = () => {
375
- }, d = () => {
376
- }, m = !1;
377
- const c = () => {
378
- m || (m = !0, a(), d());
379
- };
380
- return a = t.subscribe(i, {
381
- onData: (l) => o({
382
- sessionId: i,
383
- kind: "data",
384
- chunk: l
385
- }),
386
- onExit: (l) => {
387
- o({
388
- sessionId: i,
389
- kind: "exit",
390
- code: l.code,
391
- signal: l.signal
392
- }), c();
393
- }
394
- }), d = n.onDisconnect(c), {
395
- operation: "subscribe",
396
- accepted: !0
397
- };
398
- }
399
- }
400
- };
401
- }, Ct = (e) => {
402
- if (typeof document > "u") return;
403
- const t = new KeyboardEvent("keydown", {
404
- ...e,
405
- bubbles: !0,
406
- cancelable: !0
407
- });
408
- document.dispatchEvent(t);
409
- }, St = (e) => ({
410
- ...e.placement?.placementIdentity ? {
411
- "placement.close": (t) => {
412
- if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t) || Object.keys(t).length > 0))
413
- throw new Error("placement.close takes no parameters; the host supplies the calling placement.");
414
- e.workbench.closePlacement(e.placement.placementIdentity);
415
- }
416
- } : {},
417
- "commands.execute": (t) => {
418
- const n = t;
419
- return e.workbench.commands.executeCommand(n.commandId, n.params);
420
- },
421
- "navigation.open": (t) => {
422
- const n = t;
423
- if (!n.target) throw new Error("navigation.open requires a target.");
424
- return e.workbench.navigation.openTarget(n.target);
425
- },
426
- "notification.show": (t) => {
427
- const n = t;
428
- return e.workbench.notifications.show({
429
- level: n.level,
430
- message: n.message,
431
- title: n.title
432
- });
433
- },
434
- "preferences.get": (t) => {
435
- const n = t;
436
- return e.workbench.preferences.getValue(n.name, n.scope);
437
- },
438
- "preferences.set": (t) => {
439
- const n = t;
440
- return e.workbench.preferences.setValue(n.name, n.value, n.scope ?? {
441
- scope: "user"
442
- }), {
443
- name: n.name,
444
- value: n.value
445
- };
446
- },
447
- "host.dispatchKeyboardEvent": (t) => (e.dispatchKeyboardEvent ?? Ct)(t),
448
- ...e.hostEvents ? {
449
- "terminal.session": At({
450
- terminal: e.workbench.terminal,
451
- hostEvents: e.hostEvents
452
- })
453
- } : {}
454
- }), Tt = () => "light", he = /* @__PURE__ */ new WeakMap(), Pt = (e, t) => {
455
- let n = he.get(e);
456
- n || (n = /* @__PURE__ */ new Map(), he.set(e, n));
457
- const o = t.instanceId;
458
- let r = n.get(o);
459
- return r || (r = Rt(), n.set(o, r)), r;
460
- }, jt = (e) => {
461
- const {
462
- context: t,
463
- createHostCapabilities: n,
464
- createProps: o,
465
- createTheme: r = Tt,
466
- ownerId: s,
467
- title: i,
468
- webview: a
469
- } = e;
470
- return /* @__PURE__ */ N(vt, { view: {
471
- extensionId: s ?? "workbench",
472
- id: t.webviewId,
473
- label: a.title ?? i,
474
- webview: {
475
- capabilities: a.capabilities,
476
- moduleUrl: a.moduleUrl,
477
- runtimeUrl: a.runtimeUrl,
478
- styles: a.styles ?? []
479
- }
480
- }, props: o(t), theme: r(t), capabilities: n(t), hostEvents: t.hostEvents, ...xt({
481
- extensionId: s ?? "workbench",
482
- id: t.webviewId
483
- }) });
484
- }, p = (e, t = "") => e === void 0 ? t : rt(e) ? e.default ?? e.$l10n : e, $t = (e, t) => {
485
- const n = t.commandTargetOf?.(e);
486
- if (n) return n;
487
- const o = e.target.command, r = o.extensionId ?? t.extensionId;
488
- return {
489
- kind: "command",
490
- commandId: t.commandIdOf?.(o) ?? (r && r !== "pstdio" ? `${r}.command.${o.id}` : o.id),
491
- args: e.target.params
492
- };
1
+ import { x as e } from "./workbench-renderers-RPeMVtTc.js";
2
+ import { n as t } from "./navigation-tree-registry-CTidmvVs.js";
3
+ import { b as n, c as r, rt as i } from "./react-BxrTklvM.js";
4
+ import { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES as a, WEBVIEW_HOST_CAPABILITIES as o, WEBVIEW_HOST_CAPABILITY_VERSION as s, WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES as c, isLocalizedString as l, isNavigationTarget as u, matchesResourceWhen as d, qualifyNavigationTarget as f, resourceKey as p } from "@pstdio/sdk/extensions";
5
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
+ import { createElement as g, useEffect as _, useRef as v, useState as ee } from "react";
7
+ import { renderBadgeListDisplay as y } from "@pstdio/ui/kanban-renderer";
8
+ import { host as te } from "rimless";
9
+ //#region ../pstdio-api-contracts/src/extension-kernel/l10n.ts
10
+ var b = (e) => typeof e == "object" && !!e && "$l10n" in e && typeof e.$l10n == "string", x = new Set(o), S = new Set(c), C = (e) => x.has(e), w = (e) => S.has(e), T = (e) => {
11
+ let [t = "", n] = e.split("@"), r = t.indexOf(":");
12
+ return {
13
+ capability: e,
14
+ name: r === -1 ? t : t.slice(0, r),
15
+ scope: r === -1 ? void 0 : t.slice(r + 1),
16
+ version: n === void 0 ? s : Number(n)
17
+ };
18
+ }, E = (e) => w(e.name) ? !!e.scope : e.scope === void 0, D = (e) => ({
19
+ capability: e,
20
+ code: "unsupported_webview_capability",
21
+ message: `Unsupported webview capability: ${e}`,
22
+ severity: "error"
23
+ }), O = (e, t, n) => ({
24
+ capability: e,
25
+ code: "unsupported_webview_capability_version",
26
+ message: `Unsupported webview capability version: ${t}@${n.toString()} (supported: ${s.toString()})`,
27
+ severity: "error"
28
+ }), k = (e) => ({
29
+ capability: e,
30
+ code: "undeclared_webview_capability",
31
+ message: `Webview did not declare host capability: ${e}`,
32
+ severity: "error"
33
+ }), ne = (e, t = {}) => {
34
+ let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
35
+ for (let e of a) t[e] && r.add(e);
36
+ for (let a of e ?? []) {
37
+ let e = T(a);
38
+ if (!C(e.name) || !E(e)) {
39
+ n.push(D(a));
40
+ continue;
41
+ }
42
+ if (e.version !== s) {
43
+ n.push(O(a, e.name, e.version));
44
+ continue;
45
+ }
46
+ if (!t[e.name]) {
47
+ n.push(D(a));
48
+ continue;
49
+ }
50
+ if (e.scope === void 0) {
51
+ r.add(e.name);
52
+ continue;
53
+ }
54
+ let o = i.get(e.name) ?? /* @__PURE__ */ new Set();
55
+ o.add(e.scope), i.set(e.name, o);
56
+ }
57
+ return {
58
+ allowed: r,
59
+ allowedScopes: i,
60
+ diagnostics: n
61
+ };
62
+ }, re = (e) => {
63
+ let t = e.params;
64
+ return typeof t?.mount == "string" && t.mount.length > 0 ? t.mount : void 0;
65
+ }, ie = (e) => {
66
+ let { allowed: t, allowedScopes: n, diagnostics: r } = ne(e.declaredCapabilities, e.capabilities), i = (t) => {
67
+ e.onDiagnostic?.(t);
68
+ }, a = (e) => (i(e), Error(e.message));
69
+ return {
70
+ diagnostics: r,
71
+ async call(r) {
72
+ if (!C(r.method)) throw a(D(r.method));
73
+ if (w(r.method)) {
74
+ let e = re(r);
75
+ if (!e) throw a(D(r.method));
76
+ if (!n.get(r.method)?.has(e)) throw a(k(`${r.method}:${e}`));
77
+ } else if (!t.has(r.method)) throw a(k(r.method));
78
+ let i = e.capabilities[r.method];
79
+ if (!i) throw a(D(r.method));
80
+ return await i(r.params);
81
+ }
82
+ };
83
+ }, ae = (e) => typeof e == "object" && !!e, oe = (e) => {
84
+ try {
85
+ let t = JSON.stringify(e);
86
+ if (typeof t == "string" && t.length > 0) return t;
87
+ } catch {}
88
+ try {
89
+ return String(e);
90
+ } catch {
91
+ return "Unknown error";
92
+ }
93
+ }, se = (e) => {
94
+ if (e instanceof Error) return {
95
+ message: e.message,
96
+ stack: e.stack
97
+ };
98
+ if (typeof e == "string") return { message: e };
99
+ if (ae(e)) {
100
+ let t = typeof e.message == "string" ? e.message : null, n = typeof e.stack == "string" ? e.stack : void 0;
101
+ return t ? n ? {
102
+ message: t,
103
+ stack: n
104
+ } : { message: t } : { message: oe(e) };
105
+ }
106
+ return e == null ? { message: "Unknown error" } : { message: oe(e) };
107
+ }, A = () => {
108
+ if (typeof document > "u") return {};
109
+ let e = getComputedStyle(document.documentElement), t = {};
110
+ for (let n = 0; n < e.length; n += 1) {
111
+ let r = e.item(n);
112
+ r.startsWith("--chakra-") && (t[r] = e.getPropertyValue(r).trim());
113
+ }
114
+ return t;
115
+ }, j = (e) => {
116
+ if (typeof document > "u") return e;
117
+ let t = document.documentElement.getAttribute("data-theme");
118
+ if (t === "dark" || t === "light") return t;
119
+ let n = document.documentElement.getAttribute("data-color-mode");
120
+ return n === "dark" || n === "light" ? n : e;
121
+ }, ce = {
122
+ border: 0,
123
+ display: "block",
124
+ flex: "1 1 0%",
125
+ height: "100%",
126
+ minHeight: 0,
127
+ width: "100%"
128
+ }, le = {
129
+ display: "flex",
130
+ height: "100%",
131
+ minHeight: 0,
132
+ position: "relative",
133
+ width: "100%"
134
+ }, ue = {
135
+ alignItems: "center",
136
+ background: "rgba(255, 255, 255, 0.92)",
137
+ color: "#7a1f12",
138
+ display: "flex",
139
+ inset: 0,
140
+ justifyContent: "center",
141
+ padding: "24px",
142
+ position: "absolute",
143
+ textAlign: "center",
144
+ zIndex: 1
145
+ }, de = "allow-scripts allow-forms allow-popups", fe = (e) => {
146
+ let { view: t, props: n, theme: r, capabilities: i, hostEvents: a, onReady: o, onError: s, onDiagnostics: c, title: l } = e, u = v(null), d = v(null), f = v(null), p = v(!1), g = v(null), y = v(n), b = v(r), x = v(i), S = v(a), C = v(t.webview.capabilities), w = v(o), T = v(s), E = v(c), [D, O] = ee(null), [k, ne] = ee(0);
147
+ return y.current = n, b.current = r, x.current = i, S.current = a, C.current = t.webview.capabilities, w.current = o, T.current = s, E.current = c, _(() => {
148
+ let e = u.current;
149
+ if (!e) return;
150
+ let n = () => {
151
+ d.current === e ? ne((e) => e + 1) : d.current = e;
152
+ };
153
+ e.addEventListener("load", n);
154
+ let r = () => e.removeEventListener("load", n), i = `${k}\n${t.webview.runtimeUrl}\n${t.webview.moduleUrl}`;
155
+ if (g.current === i) return r;
156
+ g.current = i;
157
+ let a = t.webview.styles, o = t.webview.moduleUrl, s = (e) => {
158
+ e.length > 0 && E.current?.(e);
159
+ }, c = () => ie({
160
+ capabilities: x.current ?? {},
161
+ declaredCapabilities: C.current,
162
+ onDiagnostic: (e) => s([e])
163
+ });
164
+ s(c().diagnostics);
165
+ let l = {
166
+ ready: () => {},
167
+ runtimeError: (e) => {
168
+ O(e.message), T.current?.(e);
169
+ },
170
+ call: async (e) => await c().call(e)
171
+ };
172
+ return (() => {
173
+ p.current = !1, f.current = null;
174
+ let n = te.connect(e, l);
175
+ e.contentWindow?.location.replace(t.webview.runtimeUrl), n.then(async (n) => {
176
+ if (u.current !== e) return;
177
+ let r = n.remote;
178
+ f.current = r, S.current?.bind((e) => r.hostEvent?.(e)), await r.init({
179
+ moduleUrl: o,
180
+ styles: a,
181
+ props: y.current,
182
+ theme: j(b.current),
183
+ themeVariables: A(),
184
+ extensionId: t.extensionId
185
+ }), u.current === e && (p.current = !0, O(null), w.current?.());
186
+ }).catch((t) => {
187
+ if (u.current !== e) return;
188
+ let n = se(t);
189
+ O(n.message), T.current?.(n);
190
+ });
191
+ })(), r;
192
+ }, [
193
+ k,
194
+ t.extensionId,
195
+ t.webview.runtimeUrl,
196
+ t.webview.moduleUrl,
197
+ t.webview.styles
198
+ ]), _(() => {
199
+ let e = f.current;
200
+ if (e && a) return a.bind((t) => e.hostEvent?.(t)), () => a.unbind();
201
+ }, [a]), _(() => {
202
+ p.current && f.current?.propsUpdate({ props: n });
203
+ }, [n]), _(() => {
204
+ p.current && f.current?.themeUpdate({
205
+ theme: j(r),
206
+ variables: A()
207
+ });
208
+ }, [r]), _(() => {
209
+ if (typeof window > "u" || typeof MutationObserver > "u") return;
210
+ let e = null, t = new MutationObserver(() => {
211
+ e !== null && cancelAnimationFrame(e), e = requestAnimationFrame(() => {
212
+ e = null, p.current && f.current?.themeUpdate({
213
+ theme: j(b.current),
214
+ variables: A()
215
+ });
216
+ });
217
+ }), n = {
218
+ attributeFilter: [
219
+ "class",
220
+ "data-color-mode",
221
+ "data-theme",
222
+ "style"
223
+ ],
224
+ attributes: !0
225
+ };
226
+ return t.observe(document.documentElement, n), t.observe(document.body, n), () => {
227
+ t.disconnect(), e !== null && cancelAnimationFrame(e);
228
+ };
229
+ }, []), /* @__PURE__ */ h("div", {
230
+ style: le,
231
+ children: [D ? /* @__PURE__ */ m("div", {
232
+ role: "alert",
233
+ style: ue,
234
+ children: /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("strong", { children: "Extension view failed to load." }), /* @__PURE__ */ m("div", { children: D })] })
235
+ }) : null, /* @__PURE__ */ m("iframe", {
236
+ ref: u,
237
+ title: l ?? t.label,
238
+ allow: "fullscreen",
239
+ allowFullScreen: !0,
240
+ sandbox: de,
241
+ style: {
242
+ ...ce,
243
+ colorScheme: r
244
+ },
245
+ onError: () => {
246
+ let e = `Failed to load extension runtime at ${t.webview.runtimeUrl}`;
247
+ O(e), T.current?.({ message: e });
248
+ }
249
+ }, `${k}\n${t.webview.runtimeUrl}\n${t.webview.moduleUrl}`)]
250
+ });
251
+ }, pe = "[pstdio.extension-host] ", me = (e, t = console.info) => {
252
+ t(`${pe}${JSON.stringify(e)}`);
253
+ }, he = (e, t) => {
254
+ let n = (n) => me({
255
+ extensionId: e.extensionId,
256
+ contributionId: e.id,
257
+ ...n
258
+ }, t);
259
+ return {
260
+ onReady: () => n({ event: "webview-ready" }),
261
+ onError: (e) => n({
262
+ event: "webview-error",
263
+ ...e
264
+ }),
265
+ onDiagnostics: (e) => {
266
+ for (let t of e) n({
267
+ event: "webview-diagnostic",
268
+ ...t
269
+ });
270
+ }
271
+ };
272
+ }, ge = () => {
273
+ let e = null, t = [], n = /* @__PURE__ */ new Set();
274
+ return {
275
+ emit(n) {
276
+ e ? e(n) : t.push(n);
277
+ },
278
+ bind(n) {
279
+ for (e = n; t.length > 0;) n(t.shift());
280
+ },
281
+ onDisconnect(e) {
282
+ return n.add(e), () => n.delete(e);
283
+ },
284
+ unbind() {
285
+ e = null;
286
+ for (let e of n) e();
287
+ }
288
+ };
289
+ }, _e = "terminal.session", ve = (e) => {
290
+ let { terminal: t, hostEvents: n } = e, r = (e) => {
291
+ n.emit({
292
+ scope: _e,
293
+ payload: e
294
+ });
295
+ };
296
+ return async (e) => {
297
+ let i = e;
298
+ switch (i.operation) {
299
+ case "open": {
300
+ let { sessionId: e } = await t.open({ request: i.request });
301
+ return {
302
+ operation: "open",
303
+ sessionId: e
304
+ };
305
+ }
306
+ case "write": return t.write({
307
+ sessionId: i.sessionId,
308
+ data: i.data
309
+ }), {
310
+ operation: "write",
311
+ accepted: !0
312
+ };
313
+ case "resize": return t.resize({
314
+ sessionId: i.sessionId,
315
+ cols: i.cols,
316
+ rows: i.rows
317
+ }), {
318
+ operation: "resize",
319
+ accepted: !0
320
+ };
321
+ case "kill": return await t.kill({
322
+ sessionId: i.sessionId,
323
+ signal: i.signal
324
+ }), {
325
+ operation: "kill",
326
+ accepted: !0
327
+ };
328
+ case "subscribe": {
329
+ let { sessionId: e } = i, a = () => {}, o = () => {}, s = !1, c = () => {
330
+ s || (s = !0, a(), o());
331
+ };
332
+ return a = t.subscribe(e, {
333
+ onData: (t) => r({
334
+ sessionId: e,
335
+ kind: "data",
336
+ chunk: t
337
+ }),
338
+ onExit: (t) => {
339
+ r({
340
+ sessionId: e,
341
+ kind: "exit",
342
+ code: t.code,
343
+ signal: t.signal
344
+ }), c();
345
+ }
346
+ }), o = n.onDisconnect(c), {
347
+ operation: "subscribe",
348
+ accepted: !0
349
+ };
350
+ }
351
+ }
352
+ };
353
+ }, ye = (e) => {
354
+ if (typeof document > "u") return;
355
+ let t = new KeyboardEvent("keydown", {
356
+ ...e,
357
+ bubbles: !0,
358
+ cancelable: !0
359
+ });
360
+ document.dispatchEvent(t);
361
+ }, be = (e) => ({
362
+ ...e.placement?.placementIdentity ? { "placement.close": (t) => {
363
+ if (t !== void 0 && (typeof t != "object" || !t || Array.isArray(t) || Object.keys(t).length > 0)) throw Error("placement.close takes no parameters; the host supplies the calling placement.");
364
+ e.workbench.closePlacement(e.placement.placementIdentity);
365
+ } } : {},
366
+ "commands.execute": (t) => {
367
+ let n = t;
368
+ return e.workbench.commands.executeCommand(n.commandId, n.params);
369
+ },
370
+ "navigation.open": (t) => {
371
+ let n = t;
372
+ if (!n.target) throw Error("navigation.open requires a target.");
373
+ return e.workbench.navigation.openTarget(n.target);
374
+ },
375
+ "notification.show": (t) => {
376
+ let n = t;
377
+ return e.workbench.notifications.show({
378
+ level: n.level,
379
+ message: n.message,
380
+ title: n.title
381
+ });
382
+ },
383
+ "preferences.get": (t) => {
384
+ let n = t;
385
+ return e.workbench.preferences.getValue(n.name, n.scope);
386
+ },
387
+ "preferences.set": (t) => {
388
+ let n = t;
389
+ return e.workbench.preferences.setValue(n.name, n.value, n.scope ?? { scope: "user" }), {
390
+ name: n.name,
391
+ value: n.value
392
+ };
393
+ },
394
+ "host.dispatchKeyboardEvent": (t) => (e.dispatchKeyboardEvent ?? ye)(t),
395
+ ...e.hostEvents ? { "terminal.session": ve({
396
+ terminal: e.workbench.terminal,
397
+ hostEvents: e.hostEvents
398
+ }) } : {}
399
+ }), xe = () => "light", Se = /* @__PURE__ */ new WeakMap(), Ce = (e, t) => {
400
+ let n = Se.get(e);
401
+ n || (n = /* @__PURE__ */ new Map(), Se.set(e, n));
402
+ let r = t.instanceId, i = n.get(r);
403
+ return i || (i = ge(), n.set(r, i)), i;
404
+ }, we = (e) => {
405
+ let { context: t, createHostCapabilities: n, createProps: r, createTheme: i = xe, ownerId: a, title: o, webview: s } = e;
406
+ return /* @__PURE__ */ m(fe, {
407
+ view: {
408
+ extensionId: a ?? "workbench",
409
+ id: t.webviewId,
410
+ label: s.title ?? o,
411
+ webview: {
412
+ capabilities: s.capabilities,
413
+ moduleUrl: s.moduleUrl,
414
+ runtimeUrl: s.runtimeUrl,
415
+ styles: s.styles ?? []
416
+ }
417
+ },
418
+ props: r(t),
419
+ theme: i(t),
420
+ capabilities: n(t),
421
+ hostEvents: t.hostEvents,
422
+ ...he({
423
+ extensionId: a ?? "workbench",
424
+ id: t.webviewId
425
+ })
426
+ });
427
+ }, M = (e, t = "") => e === void 0 ? t : b(e) ? e.default ?? e.$l10n : e, Te = (e, t) => {
428
+ let n = t.commandTargetOf?.(e);
429
+ if (n) return n;
430
+ let r = e.target.command, i = r.extensionId ?? t.extensionId;
431
+ return {
432
+ kind: "command",
433
+ commandId: t.commandIdOf?.(r) ?? (i && i !== "pstdio" ? `${i}.command.${r.id}` : r.id),
434
+ args: e.target.params
435
+ };
493
436
  };
494
- function S(e, t = {}) {
495
- if (!ie(e)) throw new Error("Invalid navigation target.");
496
- return t.extensionId && (e = Je(e, t.extensionId, t.projectId)), e.kind === "command" ? $t(e, t) : e.kind === "href" || e.kind === "page" || e.kind === "panel" ? e : {
497
- kind: "compound",
498
- targets: e.targets.map((n) => S(n, t))
499
- };
437
+ function N(e, t = {}) {
438
+ if (!u(e)) throw Error("Invalid navigation target.");
439
+ return t.extensionId && (e = f(e, t.extensionId, t.projectId)), e.kind === "command" ? Te(e, t) : e.kind === "href" || e.kind === "page" || e.kind === "panel" ? e : {
440
+ kind: "compound",
441
+ targets: e.targets.map((e) => N(e, t))
442
+ };
500
443
  }
501
- const Ae = ie, Ce = (e, t = {}) => {
502
- if (e != null) {
503
- if (!Ae(e)) throw new Error("Renderer callback returned an invalid navigation target.");
504
- return S(e, t);
505
- }
506
- }, Se = (e) => {
507
- const t = e;
508
- if (!t?.outcome) return e;
509
- if (t.outcome.status === "success") return t.outcome.value;
510
- throw new Error(t.outcome.reason ?? t.outcome.error?.message ?? "Extension command failed.");
511
- }, B = (e) => ({
512
- id: e.id,
513
- kind: e.kind,
514
- context: {
515
- projectId: e.projectId,
516
- ...e.context ?? {}
517
- }
518
- }), Ht = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Wt = (e) => {
519
- if (!(!Ht(e) || e.deleted !== !0))
520
- return typeof e.id == "string" ? e.id : void 0;
521
- }, Mt = async (e, t, n) => {
522
- if (!t || Wt(n) !== (t.id ?? M(t)) || M(e.workbench.getPrimaryResource()) !== M(t)) return;
523
- const o = e.workbench.pageLocations.navigateToParent();
524
- if (!o.ok) throw new Error(o.diagnostic.message);
525
- }, Te = async (e, t, n = {}) => {
526
- const o = n.resource, r = await e.executeCommand(t, {
527
- projectId: e.projectId,
528
- ...n.params ? {
529
- params: n.params
530
- } : {},
531
- ...o ? {
532
- resource: o
533
- } : {},
534
- ...n.slot ? {
535
- slot: n.slot
536
- } : {},
537
- source: "dashboard",
538
- ...n.metadata ? {
539
- metadata: n.metadata
540
- } : {}
541
- });
542
- Se(r);
543
- const s = r?.outcome;
544
- if (s?.status === "success")
545
- for (const i of s.navigationRequests ?? [])
546
- try {
547
- await e.workbench.navigation.openTarget(S(i));
548
- } catch (a) {
549
- e.workbench.notifications.show({
550
- level: "warning",
551
- title: "Command completed, but navigation failed",
552
- message: a instanceof Error ? a.message : String(a)
553
- });
554
- }
555
- return r;
556
- }, v = async (e, t, n = {}) => {
557
- const o = Se(await Te(e, t, n));
558
- return await Mt(e, n.resource, o), o;
559
- }, Vt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Bt = (e, t) => `${e.extensionId ?? t}.command.${e.id}`, Dt = async (e, t, n) => {
560
- const {
561
- target: o
562
- } = n;
563
- if (o.kind === "command") {
564
- await v(e, Bt(o.target.command, t.extensionId), {
565
- params: o.target.params
566
- }), e.workbench.commandPaletteResources.refresh();
567
- return;
568
- }
569
- await e.workbench.navigation.openTarget(S(o, {
570
- extensionId: t.extensionId
571
- }));
572
- }, Ot = (e, t, n, o) => ({
573
- id: `${t.id}:${o.id}`,
574
- label: o.label,
575
- description: o.description,
576
- icon: o.icon,
577
- keywords: o.keywords,
578
- group: n,
579
- activate: () => Dt(e, t, o)
580
- }), Nt = (e, t) => {
581
- const n = [];
582
- for (const o of t) {
583
- const r = p(o.title, o.id);
584
- n.push(e.workbench.commandPaletteResources.registerProvider({
585
- id: o.id,
586
- title: r,
587
- refreshEventIds: o.refreshEventIds,
588
- query: async ({
589
- query: s,
590
- limit: i
591
- }) => {
592
- const a = e.workbench.getActiveResource(), d = await v(e, o.queryHandlerId, {
593
- params: {
594
- projectId: e.projectId,
595
- modeId: e.workbench.modes.getActiveModeId(),
596
- activeResource: a,
597
- providerId: o.id,
598
- query: s,
599
- limit: i
600
- }
601
- });
602
- return Vt(d) ? (d.items ?? []).map((m) => Ot(e, o, r, m)) : [];
603
- }
604
- }));
605
- }
606
- return {
607
- dispose() {
608
- for (let o = n.length - 1; o >= 0; o -= 1) n[o]?.dispose();
609
- }
610
- };
611
- }, ne = (e, t = "") => p(e, t), Ft = (e, t, n) => {
612
- const o = B({
613
- id: t.id,
614
- kind: "renderer",
615
- projectId: e.projectId,
616
- context: {
617
- controlsRendererId: t.id
618
- }
619
- }), r = (s, i, a) => s ? v(e, s, {
620
- params: {
621
- renderer: {
622
- rendererId: t.id,
623
- projectId: e.projectId,
624
- ...a ? {
625
- resource: a
626
- } : {},
627
- invocation: {
628
- placement: "visible"
629
- }
630
- },
631
- ...i
632
- },
633
- resource: a,
634
- slot: o,
635
- metadata: {
636
- controlsRendererId: t.id
637
- }
638
- }) : Promise.resolve(void 0);
639
- return e.workbench.views.registerView({
640
- id: t.id,
641
- title: ne(t.title, t.id),
642
- icon: t.icon,
643
- body: {
644
- kind: "controls",
645
- emptyTitle: ne(t.emptyTitle, ""),
646
- emptyDescription: ne(t.emptyDescription, ""),
647
- defaultValues: t.defaultValues,
648
- executeQuery: async (s) => {
649
- const i = await r(t.queryHandlerId, {}, s ?? n.resolveResource?.(t)), a = tt.safeParse(i);
650
- if (!a.success) {
651
- const d = a.error.issues.map((m) => `body.query.${m.path.join(".")}: ${m.message}`).join("; ");
652
- throw new Error(`Extension "${t.extensionId}" view "${t.id}" has invalid controls. Expected serializable control declarations. ${d}`);
653
- }
654
- return a.data;
655
- },
656
- updateValue: t.valueChangeHandlerId ? ({
657
- controlId: s,
658
- value: i,
659
- values: a,
660
- resource: d
661
- }) => r(t.valueChangeHandlerId, {
662
- controlId: s,
663
- value: i,
664
- values: a
665
- }, d).then(() => {
666
- }) : void 0,
667
- apply: t.applyHandlerId ? ({
668
- values: s,
669
- resource: i
670
- }) => r(t.applyHandlerId, {
671
- values: s
672
- }, i).then(() => {
673
- }) : void 0,
674
- reset: t.resetHandlerId ? ({
675
- controlIds: s,
676
- resource: i
677
- }) => r(t.resetHandlerId, {
678
- controlIds: s
679
- }, i).then(() => {
680
- }) : void 0
681
- }
682
- });
683
- }, Kt = (e, t, n = {}) => {
684
- const o = [];
685
- for (const r of t) o.push(Ft(e, r, n));
686
- return {
687
- dispose() {
688
- for (let r = o.length - 1; r >= 0; r -= 1) o[r]?.dispose();
689
- }
690
- };
691
- }, $ = (e, t = "") => p(e, t), we = (e) => ({
692
- ...e,
693
- label: $(e.label, e.id),
694
- description: e.description ? $(e.description) : void 0,
695
- icon: e.icon ? V(K, {
696
- name: e.icon,
697
- size: 14
698
- }) : void 0
699
- }), Lt = (e) => !!(e && typeof e == "object" && Array.isArray(e.rows)), _t = (e) => ({
700
- id: e.id,
701
- values: e.values,
702
- resource: e.resource ? e.resource : void 0
703
- }), Ut = (e, t) => {
704
- const n = /* @__PURE__ */ new WeakMap(), o = B({
705
- id: t.id,
706
- kind: "dataTableRenderer",
707
- projectId: e.projectId,
708
- context: {
709
- dataTableRendererId: t.id
710
- }
711
- }), r = (s, i, a, d) => v(e, s, {
712
- params: {
713
- renderer: {
714
- rendererId: t.id,
715
- projectId: e.projectId,
716
- ...d ? {
717
- modeId: d
718
- } : {},
719
- ...a ? {
720
- resource: a
721
- } : {},
722
- invocation: {
723
- placement: "visible"
724
- }
725
- },
726
- ...i
727
- },
728
- resource: a,
729
- slot: o,
730
- metadata: {
731
- dataTableRendererId: t.id
732
- }
733
- });
734
- return e.workbench.views.registerView({
735
- id: t.id,
736
- title: $(t.title, t.id),
737
- icon: t.icon,
738
- body: {
739
- kind: "dataTable",
740
- resourceKind: t.resourceKind,
741
- columns: t.columns?.map(we),
742
- initialPageSize: t.initialPageSize,
743
- pageSizeOptions: t.pageSizeOptions,
744
- selectionMode: t.selectionMode,
745
- selectionActions: t.selectionActions?.map((s) => ({
746
- id: s.id,
747
- label: $(s.label, s.id),
748
- icon: s.icon ? V(K, {
749
- name: s.icon,
750
- size: 16
751
- }) : void 0,
752
- destructive: s.destructive,
753
- run: (i) => r(s.commandId, {
754
- rowIds: i.map((a) => a.id)
755
- }).then(() => {
756
- })
757
- })),
758
- emptyTitle: t.emptyTitle ? $(t.emptyTitle) : void 0,
759
- emptyDescription: t.emptyDescription ? $(t.emptyDescription) : void 0,
760
- executeQuery: async ({
761
- resource: s,
762
- modeId: i
763
- }) => {
764
- const a = await r(t.queryHandlerId, {}, s, i);
765
- return Lt(a) ? {
766
- rows: a.rows.map((m) => {
767
- const c = _t(m);
768
- return n.set(c, m), c;
769
- }),
770
- columns: a.columns?.map(we)
771
- } : {
772
- rows: []
773
- };
774
- },
775
- rowActions: t.rowActions?.map((s) => ({
776
- id: s.id,
777
- label: $(s.label, s.id),
778
- icon: s.icon ? V(K, {
779
- name: s.icon,
780
- size: 16
781
- }) : void 0,
782
- destructive: s.destructive,
783
- run: async (i) => {
784
- await r(s.commandId, {
785
- rowId: i.id
786
- }, i.resource), e.workbench.views.refreshView(t.id);
787
- }
788
- })),
789
- onRowActivate: t.rowActivationHandlerId ? async (s) => {
790
- const i = await r(t.rowActivationHandlerId, {
791
- row: n.get(s) ?? s
792
- }, s.resource), a = Ce(i, {
793
- extensionId: t.extensionId
794
- });
795
- a && await e.workbench.navigation.openTarget(a);
796
- } : void 0
797
- }
798
- });
799
- }, qt = (e, t) => {
800
- const n = t.map((o) => Ut(e, o));
801
- return {
802
- dispose() {
803
- for (let o = n.length - 1; o >= 0; o -= 1) n[o]?.dispose();
804
- }
805
- };
806
- }, zt = {
807
- first: 0,
808
- default: 1,
809
- last: 2
810
- }, Ko = {
811
- commands: [],
812
- commandPaletteContributions: [],
813
- diagnostics: [],
814
- extensions: [],
815
- menuContributions: [],
816
- modes: [],
817
- pages: [],
818
- views: [],
819
- viewMenus: [],
820
- placements: [],
821
- resourceKinds: [],
822
- navigationItems: [],
823
- navigationTrees: [],
824
- statusBarItems: [],
825
- statuses: [],
826
- settingsPanels: [],
827
- settingsDefinitions: []
828
- }, Gt = (e) => `workbench.extension.menu.${e.id}`, Qt = (e) => `workbench.extension.palette.${e.id}`, Pe = (e, t) => zt[e.placement ?? "default"] * 1e3 + t, je = (e) => e === void 0 ? "" : Ze(e) ? e.default ?? e.$l10n : e, Xt = (e) => {
829
- const {
830
- commandId: t,
831
- contribution: n,
832
- index: o,
833
- resolveString: r,
834
- slot: s,
835
- when: i
836
- } = e;
837
- return {
838
- commandId: t,
839
- sourceCommandId: n.commandId,
840
- label: r(n.label, n.extensionId),
841
- icon: n.icon,
842
- group: s.group ?? n.group,
843
- args: n.params,
844
- overflowLabel: s.overflowLabel,
845
- order: Pe(n, o),
846
- when: i
847
- };
848
- }, Yt = (e) => {
849
- const {
850
- commandId: t,
851
- contribution: n,
852
- index: o,
853
- resolveString: r
854
- } = e;
855
- return {
856
- commandId: t,
857
- label: r(n.label, n.extensionId),
858
- icon: n.icon,
859
- group: n.group,
860
- args: n.params,
861
- order: Pe(n, o)
862
- };
863
- }, Jt = (e) => {
864
- const {
865
- createCommandId: t = Gt,
866
- createWhenExpression: n,
867
- menuSlotsById: o,
868
- menuTargetsById: r,
869
- metadata: s,
870
- resolveString: i = je
871
- } = e, a = [], d = [];
872
- return s.menuContributions.forEach((m, c) => {
873
- const l = m.target ? r?.get(m.target) : o.get(m.slotId);
874
- if (!l) {
875
- d.push({
876
- contribution: m,
877
- targetId: m.target ?? m.slotId
878
- });
879
- return;
880
- }
881
- const b = t(m), u = s.commands.find((w) => w.id === m.commandId);
882
- a.push({
883
- command: {
884
- id: b,
885
- label: i(m.label, m.extensionId),
886
- category: m.group,
887
- description: u ? i(u.description, u.extensionId) : void 0,
888
- icon: m.icon,
889
- params: u?.params
890
- },
891
- contribution: m,
892
- menuItem: Xt({
893
- commandId: b,
894
- contribution: m,
895
- index: c,
896
- resolveString: i,
897
- slot: l,
898
- when: n?.(m)
899
- }),
900
- menuPath: l.menuPath,
901
- targetCommandId: m.commandId
902
- });
903
- }), {
904
- registrations: a,
905
- unresolved: d
906
- };
444
+ var P = u, F = (e, t = {}) => {
445
+ if (e != null) {
446
+ if (!P(e)) throw Error("Renderer callback returned an invalid navigation target.");
447
+ return N(e, t);
448
+ }
449
+ }, Ee = (e) => {
450
+ let t = e;
451
+ if (!t?.outcome) return e;
452
+ if (t.outcome.status === "success") return t.outcome.value;
453
+ throw Error(t.outcome.reason ?? t.outcome.error?.message ?? "Extension command failed.");
454
+ }, I = (e) => ({
455
+ id: e.id,
456
+ kind: e.kind,
457
+ context: {
458
+ projectId: e.projectId,
459
+ ...e.context ?? {}
460
+ }
461
+ }), De = (e) => typeof e == "object" && !!e && !Array.isArray(e), Oe = (e) => {
462
+ if (De(e) && e.deleted === !0) return typeof e.id == "string" ? e.id : void 0;
463
+ }, ke = async (e, t, n) => {
464
+ if (!t || Oe(n) !== (t.id ?? p(t)) || p(e.workbench.getPrimaryResource()) !== p(t)) return;
465
+ let r = e.workbench.pageLocations.navigateToParent();
466
+ if (!r.ok) throw Error(r.diagnostic.message);
467
+ }, L = async (e, t, n = {}) => {
468
+ let r = n.resource, i = await e.executeCommand(t, {
469
+ projectId: e.projectId,
470
+ ...n.workspaceId ? { workspaceId: n.workspaceId } : {},
471
+ ...n.params ? { params: n.params } : {},
472
+ ...r ? { resource: r } : {},
473
+ ...n.slot ? { slot: n.slot } : {},
474
+ source: "dashboard",
475
+ ...n.metadata ? { metadata: n.metadata } : {}
476
+ }, n.signal);
477
+ Ee(i);
478
+ let a = i?.outcome;
479
+ if (a?.status === "success") for (let t of a.navigationRequests ?? []) try {
480
+ await e.workbench.navigation.openTarget(N(t));
481
+ } catch (t) {
482
+ e.workbench.notifications.show({
483
+ level: "warning",
484
+ title: "Command completed, but navigation failed",
485
+ message: t instanceof Error ? t.message : String(t)
486
+ });
487
+ }
488
+ return i;
489
+ }, R = async (e, t, n = {}) => {
490
+ let r = Ee(await L(e, t, n));
491
+ return await ke(e, n.resource, r), r;
492
+ }, Ae = (e) => typeof e == "object" && !!e && !Array.isArray(e), je = (e, t) => `${e.extensionId ?? t}.command.${e.id}`, Me = async (e, t, n) => {
493
+ let { target: r } = n;
494
+ if (r.kind === "command") {
495
+ await R(e, je(r.target.command, t.extensionId), { params: r.target.params }), e.workbench.commandPaletteResources.refresh();
496
+ return;
497
+ }
498
+ await e.workbench.navigation.openTarget(N(r, { extensionId: t.extensionId }));
499
+ }, Ne = (e, t, n, r) => ({
500
+ id: `${t.id}:${r.id}`,
501
+ label: r.label,
502
+ description: r.description,
503
+ icon: r.icon,
504
+ keywords: r.keywords,
505
+ group: n,
506
+ activate: () => Me(e, t, r)
507
+ }), Pe = (e, t) => {
508
+ let n = [];
509
+ for (let r of t) {
510
+ let t = M(r.title, r.id);
511
+ n.push(e.workbench.commandPaletteResources.registerProvider({
512
+ id: r.id,
513
+ title: t,
514
+ refreshEventIds: r.refreshEventIds,
515
+ query: async ({ query: n, limit: i }) => {
516
+ let a = e.workbench.getActiveResource(), o = await R(e, r.queryHandlerId, { params: {
517
+ projectId: e.projectId,
518
+ modeId: e.workbench.modes.getActiveModeId(),
519
+ activeResource: a,
520
+ providerId: r.id,
521
+ query: n,
522
+ limit: i
523
+ } });
524
+ return Ae(o) ? (o.items ?? []).map((n) => Ne(e, r, t, n)) : [];
525
+ }
526
+ }));
527
+ }
528
+ return { dispose() {
529
+ for (let e = n.length - 1; e >= 0; --e) n[e]?.dispose();
530
+ } };
531
+ }, z = (e, t = "") => M(e, t), Fe = (e, t, n) => {
532
+ let i = I({
533
+ id: t.id,
534
+ kind: "renderer",
535
+ projectId: e.projectId,
536
+ context: { controlsRendererId: t.id }
537
+ }), a = (n, r, a, o) => n ? R(e, n, {
538
+ params: {
539
+ renderer: {
540
+ rendererId: t.id,
541
+ projectId: e.projectId,
542
+ ...a ? { resource: a } : {},
543
+ invocation: { placement: "visible" }
544
+ },
545
+ ...r
546
+ },
547
+ resource: a,
548
+ signal: o,
549
+ slot: i,
550
+ metadata: { controlsRendererId: t.id }
551
+ }) : Promise.resolve(void 0);
552
+ return e.workbench.views.registerView({
553
+ id: t.id,
554
+ title: z(t.title, t.id),
555
+ icon: t.icon,
556
+ body: {
557
+ kind: "controls",
558
+ emptyTitle: z(t.emptyTitle, ""),
559
+ emptyDescription: z(t.emptyDescription, ""),
560
+ defaultValues: t.defaultValues,
561
+ executeQuery: async (e, i) => {
562
+ let o = await a(t.queryHandlerId, {}, e ?? n.resolveResource?.(t), i), s = r.safeParse(o);
563
+ if (!s.success) {
564
+ let e = s.error.issues.map((e) => `body.query.${e.path.join(".")}: ${e.message}`).join("; ");
565
+ throw Error(`Extension "${t.extensionId}" view "${t.id}" has invalid controls. Expected serializable control declarations. ${e}`);
566
+ }
567
+ return s.data;
568
+ },
569
+ updateValue: t.valueChangeHandlerId ? ({ controlId: e, value: n, values: r, resource: i }) => a(t.valueChangeHandlerId, {
570
+ controlId: e,
571
+ value: n,
572
+ values: r
573
+ }, i).then(() => void 0) : void 0,
574
+ apply: t.applyHandlerId ? ({ values: e, resource: n }) => a(t.applyHandlerId, { values: e }, n).then(() => void 0) : void 0,
575
+ reset: t.resetHandlerId ? ({ controlIds: e, resource: n }) => a(t.resetHandlerId, { controlIds: e }, n).then(() => void 0) : void 0
576
+ }
577
+ });
578
+ }, Ie = (e, t, n = {}) => {
579
+ let r = [];
580
+ for (let i of t) r.push(Fe(e, i, n));
581
+ return { dispose() {
582
+ for (let e = r.length - 1; e >= 0; --e) r[e]?.dispose();
583
+ } };
584
+ }, B = (e, t = "") => M(e, t), Le = (e) => ({
585
+ ...e,
586
+ label: B(e.label, e.id),
587
+ description: e.description ? B(e.description) : void 0,
588
+ icon: e.icon ? g(i, {
589
+ name: e.icon,
590
+ size: 14
591
+ }) : void 0
592
+ }), Re = (e) => !!(e && typeof e == "object" && Array.isArray(e.rows)), ze = (e) => ({
593
+ id: e.id,
594
+ values: e.values,
595
+ resource: e.resource ? e.resource : void 0
596
+ }), Be = (e, t) => {
597
+ let n = /* @__PURE__ */ new WeakMap(), r = I({
598
+ id: t.id,
599
+ kind: "dataTableRenderer",
600
+ projectId: e.projectId,
601
+ context: { dataTableRendererId: t.id }
602
+ }), a = (n, i, a, o, s) => R(e, n, {
603
+ params: {
604
+ renderer: {
605
+ rendererId: t.id,
606
+ projectId: e.projectId,
607
+ ...o ? { modeId: o } : {},
608
+ ...a ? { resource: a } : {},
609
+ invocation: { placement: "visible" }
610
+ },
611
+ ...i
612
+ },
613
+ resource: a,
614
+ signal: s,
615
+ slot: r,
616
+ metadata: { dataTableRendererId: t.id }
617
+ });
618
+ return e.workbench.views.registerView({
619
+ id: t.id,
620
+ title: B(t.title, t.id),
621
+ icon: t.icon,
622
+ body: {
623
+ kind: "dataTable",
624
+ resourceKind: t.resourceKind,
625
+ columns: t.columns?.map(Le),
626
+ initialPageSize: t.initialPageSize,
627
+ pageSizeOptions: t.pageSizeOptions,
628
+ selectionMode: t.selectionMode,
629
+ selectionActions: t.selectionActions?.map((e) => ({
630
+ id: e.id,
631
+ label: B(e.label, e.id),
632
+ icon: e.icon ? g(i, {
633
+ name: e.icon,
634
+ size: 16
635
+ }) : void 0,
636
+ destructive: e.destructive,
637
+ run: (t) => a(e.commandId, { rowIds: t.map((e) => e.id) }).then(() => void 0)
638
+ })),
639
+ emptyTitle: t.emptyTitle ? B(t.emptyTitle) : void 0,
640
+ emptyDescription: t.emptyDescription ? B(t.emptyDescription) : void 0,
641
+ executeQuery: async ({ resource: e, modeId: r }, i) => {
642
+ let o = await a(t.queryHandlerId, {}, e, r, i);
643
+ return Re(o) ? {
644
+ rows: o.rows.map((e) => {
645
+ let t = ze(e);
646
+ return n.set(t, e), t;
647
+ }),
648
+ columns: o.columns?.map(Le)
649
+ } : { rows: [] };
650
+ },
651
+ rowActions: t.rowActions?.map((n) => ({
652
+ id: n.id,
653
+ label: B(n.label, n.id),
654
+ icon: n.icon ? g(i, {
655
+ name: n.icon,
656
+ size: 16
657
+ }) : void 0,
658
+ destructive: n.destructive,
659
+ run: async (r) => {
660
+ await a(n.commandId, { rowId: r.id }, r.resource), e.workbench.views.refreshView(t.id);
661
+ }
662
+ })),
663
+ onRowActivate: t.rowActivationHandlerId ? async (r) => {
664
+ let i = F(await a(t.rowActivationHandlerId, { row: n.get(r) ?? r }, r.resource), { extensionId: t.extensionId });
665
+ i && await e.workbench.navigation.openTarget(i);
666
+ } : void 0
667
+ }
668
+ });
669
+ }, Ve = (e, t) => {
670
+ let n = t.map((t) => Be(e, t));
671
+ return { dispose() {
672
+ for (let e = n.length - 1; e >= 0; --e) n[e]?.dispose();
673
+ } };
674
+ }, He = {
675
+ first: 0,
676
+ default: 1,
677
+ last: 2
678
+ }, Ue = {
679
+ commands: [],
680
+ commandPaletteContributions: [],
681
+ diagnostics: [],
682
+ extensions: [],
683
+ menuContributions: [],
684
+ modes: [],
685
+ pages: [],
686
+ views: [],
687
+ viewMenus: [],
688
+ placements: [],
689
+ resourceKinds: [],
690
+ navigationItems: [],
691
+ navigationTrees: [],
692
+ statusBarItems: [],
693
+ statuses: [],
694
+ settingsPanels: [],
695
+ settingsDefinitions: []
696
+ }, We = (e) => `workbench.extension.menu.${e.id}`, Ge = (e) => `workbench.extension.palette.${e.id}`, Ke = (e, t) => He[e.placement ?? "default"] * 1e3 + t, qe = (e) => e === void 0 ? "" : l(e) ? e.default ?? e.$l10n : e, Je = (e) => {
697
+ let { commandId: t, contribution: n, index: r, resolveString: i, slot: a, when: o } = e;
698
+ return {
699
+ commandId: t,
700
+ sourceCommandId: n.commandId,
701
+ label: i(n.label, n.extensionId),
702
+ icon: n.icon,
703
+ group: a.group ?? n.group,
704
+ args: n.params,
705
+ overflowLabel: a.overflowLabel,
706
+ order: Ke(n, r),
707
+ when: o
708
+ };
709
+ }, Ye = (e) => {
710
+ let { commandId: t, contribution: n, index: r, resolveString: i } = e;
711
+ return {
712
+ commandId: t,
713
+ label: i(n.label, n.extensionId),
714
+ icon: n.icon,
715
+ group: n.group,
716
+ args: n.params,
717
+ order: Ke(n, r)
718
+ };
719
+ }, Xe = (e) => {
720
+ let { createCommandId: t = We, createWhenExpression: n, menuSlotsById: r, menuTargetsById: i, metadata: a, resolveString: o = qe } = e, s = [], c = [];
721
+ return a.menuContributions.forEach((e, l) => {
722
+ let u = e.target ? i?.get(e.target) : r.get(e.slotId);
723
+ if (!u) {
724
+ c.push({
725
+ contribution: e,
726
+ targetId: e.target ?? e.slotId
727
+ });
728
+ return;
729
+ }
730
+ let d = t(e), f = a.commands.find((t) => t.id === e.commandId);
731
+ s.push({
732
+ command: {
733
+ id: d,
734
+ label: o(e.label, e.extensionId),
735
+ category: e.group,
736
+ description: f ? o(f.description, f.extensionId) : void 0,
737
+ icon: e.icon,
738
+ params: f?.params
739
+ },
740
+ contribution: e,
741
+ menuItem: Je({
742
+ commandId: d,
743
+ contribution: e,
744
+ index: l,
745
+ resolveString: o,
746
+ slot: u,
747
+ when: n?.(e)
748
+ }),
749
+ menuPath: u.menuPath,
750
+ targetCommandId: e.commandId
751
+ });
752
+ }), {
753
+ registrations: s,
754
+ unresolved: c
755
+ };
756
+ }, Ze = (e) => {
757
+ let { createCommandId: t = Ge, metadata: n, resolveString: r = qe } = e, i = [];
758
+ return (n.commandPaletteContributions ?? []).forEach((e, a) => {
759
+ let o = t(e), s = n.commands.find((t) => t.id === e.commandId);
760
+ i.push({
761
+ command: {
762
+ id: o,
763
+ label: r(e.label, e.extensionId),
764
+ category: e.group,
765
+ description: s ? r(s.description, s.extensionId) : void 0,
766
+ icon: e.icon,
767
+ params: s?.params
768
+ },
769
+ contribution: e,
770
+ menuItem: Ye({
771
+ commandId: o,
772
+ contribution: e,
773
+ index: a,
774
+ resolveString: r
775
+ }),
776
+ targetCommandId: e.commandId
777
+ });
778
+ }), i;
779
+ }, Qe = (e) => ({
780
+ id: e.rendererId,
781
+ kind: "renderer",
782
+ context: {
783
+ projectId: e.projectId,
784
+ ...e.resource ? {
785
+ resourceType: e.resource.type,
786
+ resourceId: e.resource.id
787
+ } : {}
788
+ }
789
+ }), $e = async (e, t, n, r, i = {}, a, o) => {
790
+ let s = r;
791
+ return R(e, n, {
792
+ params: {
793
+ renderer: {
794
+ rendererId: t,
795
+ projectId: e.projectId,
796
+ ...s ? { resource: s } : {},
797
+ invocation: { placement: "visible" }
798
+ },
799
+ ...i
800
+ },
801
+ resource: s,
802
+ signal: o,
803
+ slot: Qe({
804
+ projectId: e.projectId,
805
+ rendererId: t,
806
+ resource: s
807
+ }),
808
+ ...a ? { metadata: a } : {}
809
+ });
810
+ }, et = (e) => {
811
+ if (!e || typeof e != "object") return;
812
+ let t = e.revision;
813
+ return typeof t == "string" ? t : void 0;
814
+ }, tt = (e, t) => {
815
+ let n = e.metadata, r = n?.fileRendererOrigin;
816
+ if (!r || typeof r != "object") return;
817
+ let i = r;
818
+ if (typeof i.rendererId != "string" || typeof i.instanceId != "string" || typeof i.operationId != "string") return;
819
+ let a = n?.fileRendererResourceKey, o = et(t.outcome.value);
820
+ return {
821
+ origin: {
822
+ rendererId: i.rendererId,
823
+ instanceId: i.instanceId,
824
+ operationId: i.operationId
825
+ },
826
+ ...typeof a == "string" ? { resourceKey: a } : {},
827
+ ...o ? { revision: o } : {}
828
+ };
829
+ }, nt = (e, t) => e.workbench.views.registerView({
830
+ id: t.id,
831
+ title: M(t.title, t.id),
832
+ icon: t.icon,
833
+ body: {
834
+ kind: "file",
835
+ resourceKind: t.resourceKind,
836
+ load: async (n, r) => await $e(e, t.id, t.loadHandlerId, n, {}, void 0, r) ?? {},
837
+ save: t.saveHandlerId ? async (n, r, i) => {
838
+ let a = et(await $e(e, t.id, t.saveHandlerId, n, { content: r }, {
839
+ ...i ? { fileRendererOrigin: i } : {},
840
+ ...p(n) ? { fileRendererResourceKey: p(n) } : {}
841
+ }));
842
+ return a ? { revision: a } : void 0;
843
+ } : void 0
844
+ }
845
+ }), rt = (e) => {
846
+ let t = [];
847
+ for (let n of e.metadata.fileRenderers ?? []) t.push(nt(e, n));
848
+ return { dispose() {
849
+ for (let e = t.length - 1; e >= 0; --e) t[e]?.dispose();
850
+ } };
851
+ }, it = (e) => (t) => g(i, {
852
+ name: e ?? "MoreHorizontal",
853
+ ...t
854
+ }), at = (e, t) => ({
855
+ color: e?.color,
856
+ canDragIn: e?.canDragIn,
857
+ canDragOut: e?.canDragOut,
858
+ canCreate: e?.canCreate,
859
+ actions: e?.actions?.map((e) => ({
860
+ id: e.id,
861
+ label: t(e.label, e.id),
862
+ icon: it(e.icon)
863
+ }))
864
+ }), ot = (e, t) => `${t.extensionId ?? e.extensionId}.status.${t.id}`, st = (e, t) => {
865
+ let n = /* @__PURE__ */ new Map();
866
+ return (r) => {
867
+ let i = ot(t, r), a = n.get(i);
868
+ if (a) return a;
869
+ let o = {
870
+ getSnapshot: () => (e.workbench.statuses.getStatuses(i) ?? []).map((e) => ({
871
+ value: e.id,
872
+ label: e.label,
873
+ color: e.color,
874
+ icon: e.icon
875
+ })),
876
+ subscribe: (t) => e.workbench.statuses.store.subscribeSelector((e) => e.values[i], t)
877
+ };
878
+ return n.set(i, o), e.workbench.statuses.load(i).catch(() => void 0), o;
879
+ };
880
+ }, ct = (e, t, n, r, i) => {
881
+ let a = n?.find((e) => e.id === r);
882
+ if (a?.type.kind !== "status") return;
883
+ let o = ot(t, a.type.statuses), s = e.workbench.statuses.getStatuses(o)?.find((e) => e.id === i);
884
+ return s ? { color: s.color } : void 0;
885
+ }, lt = (e) => {
886
+ if (e.defaultSettings?.columnGrouping) return e.defaultSettings.columnGrouping;
887
+ let t = e.attributes?.filter((e) => e.type.kind === "status") ?? [];
888
+ return t.length === 1 ? t[0]?.id : void 0;
889
+ }, ut = (e) => typeof e == "object" && !!e && !Array.isArray(e), dt = (e, t, n, r, i, a) => (t ?? []).map((t) => {
890
+ let o = t.display, s = o?.kind === "badge-list" && typeof o.itemsAttributeId == "string" ? {
891
+ kind: "badge-list",
892
+ itemsAttributeId: o.itemsAttributeId
893
+ } : void 0;
894
+ return o && !s && a?.(t.id, o.kind), r(e, {
895
+ ...t,
896
+ label: n(t.label, t.id),
897
+ type: t.type.kind === "status" ? {
898
+ kind: "enum",
899
+ options: i(t.type.statuses)
900
+ } : t.type.kind === "enum" || t.type.kind === "enum-multi" ? {
901
+ ...t.type,
902
+ options: Array.isArray(t.type.options) ? t.type.options.map((e) => ({
903
+ ...e,
904
+ label: n(e.label, e.value)
905
+ })) : t.type.options
906
+ } : t.type,
907
+ display: s
908
+ });
909
+ }), ft = (e, t, n, r, i = () => [], a) => {
910
+ let o = dt(e, t, n, r, i, a), s = /* @__PURE__ */ new Set();
911
+ return {
912
+ source: {
913
+ getSnapshot: () => o,
914
+ subscribe: (e) => (s.add(e), () => s.delete(e))
915
+ },
916
+ set(t) {
917
+ o = dt(e, t, n, r, i, a);
918
+ for (let e of s) e();
919
+ }
920
+ };
921
+ }, pt = (e) => !!(e && typeof e == "object" && typeof e.type == "string" && typeof e.id == "string"), mt = (e, t) => {
922
+ let { resource: n } = t;
923
+ if (pt(n)) return n;
924
+ }, ht = (e, t) => {
925
+ let n = mt(e, t);
926
+ if (n) return n;
927
+ if (e.resourceKind) return {
928
+ type: e.resourceKind,
929
+ id: t.id,
930
+ label: t.title
931
+ };
932
+ }, gt = (e, t) => {
933
+ let n = e, r = t(n);
934
+ return r === void 0 ? n : {
935
+ ...n,
936
+ resource: r
937
+ };
938
+ }, _t = (...e) => Object.assign({}, ...e.filter((e) => !!e)), vt = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, yt = (e) => Object.keys(e ?? {}).length > 0, bt = /* @__PURE__ */ new Set([
939
+ "text",
940
+ "longtext",
941
+ "markdown",
942
+ "number",
943
+ "boolean",
944
+ "select",
945
+ "multi-select",
946
+ "files"
947
+ ]), xt = (e, t, n) => {
948
+ if (!bt.has(t.type)) return;
949
+ let r = "options" in t && Array.isArray(t.options) ? t.options : [], i = t;
950
+ return {
951
+ id: e,
952
+ label: n(t.label, e),
953
+ description: t.description === void 0 ? void 0 : n(t.description),
954
+ placeholder: i.placeholder === void 0 ? void 0 : n(i.placeholder),
955
+ type: t.type,
956
+ required: t.required === !0,
957
+ defaultValue: t.defaultValue,
958
+ options: t.type === "select" || t.type === "multi-select" ? r.map((e) => ({
959
+ value: e.value,
960
+ label: n(e.label, e.value),
961
+ icon: e.icon
962
+ })) : void 0,
963
+ multiple: t.type === "files" ? i.multiple !== !1 : void 0,
964
+ accept: t.type === "files" && typeof i.accept == "string" ? i.accept : void 0
965
+ };
966
+ }, St = (e, t) => Object.entries(e.createRow?.params ?? {}).flatMap(([e, n]) => {
967
+ let r = xt(e, n, t);
968
+ return r ? [r] : [];
969
+ }), Ct = (e, t) => I({
970
+ id: t.id,
971
+ kind: "kanbanRenderer",
972
+ projectId: e.projectId,
973
+ context: { kanbanRendererId: t.id }
974
+ }), V = (e, t, n, r, i, a) => {
975
+ let o = i ?? e.workbench.getPrimaryResource();
976
+ return R(e, n, {
977
+ params: {
978
+ renderer: {
979
+ rendererId: t.id,
980
+ projectId: e.projectId,
981
+ ...o ? { resource: o } : {},
982
+ invocation: { placement: "visible" }
983
+ },
984
+ ...r
985
+ },
986
+ resource: o,
987
+ signal: a,
988
+ slot: Ct(e, t),
989
+ metadata: { kanbanRendererId: t.id }
990
+ });
991
+ }, wt = (e, t) => `workbench.extension.kanbanRenderer.${e.id}.rowAction.${t.id}`, Tt = (e, t, n) => (t.rowActions ?? []).map((r) => {
992
+ let i = e.workbench.commands.getCommand(r.commandId)?.command;
993
+ return e.workbench.commands.registerCommand({
994
+ id: wt(t, r),
995
+ label: n(r.label, r.id),
996
+ icon: r.icon,
997
+ params: i?.params
998
+ }, { execute: (n, i) => V(e, t, r.commandId, _t(vt(n)), i?.resource) });
999
+ }), Et = (e, t, n, r, i, a) => {
1000
+ let o = wt(t, n), s = e.workbench.commands.getCommand(o), c = { rowId: r.id }, l = i ? { resource: i } : void 0, u = a(n.label, n.id);
1001
+ return s && yt(s.command.params) ? (e.workbench.commandPalette.requestParams({
1002
+ record: s,
1003
+ label: u,
1004
+ args: c,
1005
+ context: l
1006
+ }), Promise.resolve()) : s ? e.workbench.commands.executeCommand(s.command.id, c, l).then(() => void 0) : V(e, t, n.commandId, c, i).then(() => void 0);
1007
+ }, Dt = (e) => e ? g(i, {
1008
+ name: e,
1009
+ size: 16
1010
+ }) : void 0, Ot = (e, t) => {
1011
+ if (e.createRow) return {
1012
+ title: t(e.createRow.title, "Create row"),
1013
+ submitLabel: t(e.createRow.submitLabel, "Create"),
1014
+ fields: St(e, t),
1015
+ labels: {
1016
+ cancel: t(e.createRow.labels?.cancel, "Cancel"),
1017
+ properties: t(e.createRow.labels?.properties, "Properties"),
1018
+ submitError: t(e.createRow.labels?.submitError, "Could not create resource."),
1019
+ removeFile: t(e.createRow.labels?.removeFile, "Remove file")
1020
+ }
1021
+ };
1022
+ }, kt = (e, t, n, r, i) => {
1023
+ if (t.rowActivationHandlerId) return async (n) => {
1024
+ let a = r(t, n), o = F(await V(e, t, t.rowActivationHandlerId, { row: i(n) }, a), { extensionId: t.extensionId });
1025
+ o && await e.workbench.navigation.openTarget(o);
1026
+ };
1027
+ if (n.onRowClick) return (e) => n.onRowClick?.({
1028
+ record: t,
1029
+ row: e,
1030
+ resource: r(t, e)
1031
+ });
1032
+ }, At = (e, t, n, r) => {
1033
+ let i = e.createRow;
1034
+ if (i) return async (a) => {
1035
+ let o = _t(a.values, i.columnParam ? { [i.columnParam]: a.columnId } : void 0, i.attributesParam ? { [i.attributesParam]: a.attributeValues } : void 0), s = await n(e, i.commandId, o);
1036
+ if (await t.onAfterCreate?.({
1037
+ record: e,
1038
+ created: s,
1039
+ submission: a
1040
+ }), !r || typeof s != "object" || !s) return;
1041
+ let c = s;
1042
+ typeof c.id == "string" && typeof c.title == "string" && await r({
1043
+ ...c,
1044
+ id: c.id,
1045
+ title: c.title,
1046
+ attributes: c.attributes ?? {}
1047
+ });
1048
+ };
1049
+ }, jt = (e, t, n, r, i) => {
1050
+ let a = t.rowActions;
1051
+ if (a?.length) return (o) => a.map((a) => {
1052
+ let s = i(t, o), c = () => Et(e, t, a, o, s, r);
1053
+ return {
1054
+ key: a.id,
1055
+ label: r(a.label, a.id),
1056
+ commandId: a.commandId,
1057
+ icon: Dt(a.icon),
1058
+ onClick: () => n.executeRowAction ? n.executeRowAction({
1059
+ record: t,
1060
+ action: a,
1061
+ row: o,
1062
+ resource: s,
1063
+ runDefault: c
1064
+ }) : c()
1065
+ };
1066
+ });
1067
+ }, Mt = (e, t, n = {}) => {
1068
+ let r = [], i = n.resolveLabel ?? ((e, t) => M(e, t)), a = (e, t) => {
1069
+ let r = t.display?.kind === "badge-list" ? {
1070
+ ...t,
1071
+ render: (e, n) => y(t, e, n)
1072
+ } : t;
1073
+ return n.decorateAttribute?.(e, r) ?? r;
1074
+ }, o = n.resolveRowResource ?? mt, s = n.resolveRowActionResource ?? ht, c = n.onAfterMutation ?? (() => {}), l = (t, n, r) => V(e, t, n, r).then((e) => (c(t), e));
1075
+ for (let c of t) {
1076
+ let t = st(e, c), u = ft(c, c.attributes, i, a, t, (t, n) => e.workbench.notifications.show({
1077
+ id: `workbench.extension.${c.extensionId}.kanban.${c.id}.display.${t}`,
1078
+ level: "error",
1079
+ title: "Extension display is not available",
1080
+ message: `Attribute "${t}" in renderer "${c.id}" uses unknown display kind "${n}".`
1081
+ })), d = c.attributes, f = lt(c), p = /* @__PURE__ */ new WeakMap(), m, h = 0, g = (e) => o(c, e), _ = kt(e, c, n, o, (e) => p.get(e) ?? e);
1082
+ r.push(...Tt(e, c, i)), r.push(e.workbench.views.registerView({
1083
+ id: c.id,
1084
+ title: i(c.title, c.id),
1085
+ icon: c.icon,
1086
+ body: {
1087
+ kind: "kanban",
1088
+ resourceKind: c.resourceKind,
1089
+ storageScope: e.projectId,
1090
+ attributes: u.source,
1091
+ defaultSettings: c.defaultSettings,
1092
+ defaultFilters: c.defaultFilters,
1093
+ defaultViews: c.defaultViews?.map((e) => ({
1094
+ ...e,
1095
+ title: i(e.title, e.id)
1096
+ })),
1097
+ defaultActiveViewId: c.defaultActiveViewId,
1098
+ emptyTitle: i(c.emptyTitle, ""),
1099
+ emptyDescription: i(c.emptyDescription, ""),
1100
+ hideToolbar: c.hideToolbar,
1101
+ createRow: Ot(c, i),
1102
+ getBoardColumnConfig: (t) => at(m?.[t] ?? ct(e, c, d, f, t), i),
1103
+ onRowActivate: _,
1104
+ executeQuery: async (t, n) => {
1105
+ h += 1;
1106
+ let r = h, i = await V(e, c, c.queryHandlerId, {
1107
+ settings: t.settings,
1108
+ filters: t.filters
1109
+ }, void 0, n), a = (e) => e.map((e) => {
1110
+ let t = gt(e, g);
1111
+ return p.set(t, e), t;
1112
+ });
1113
+ if (r !== h) return Array.isArray(i) ? a(i) : ut(i) ? a(i.rows ?? []) : [];
1114
+ if (f = t.settings.columnGrouping, Array.isArray(i)) return a(i);
1115
+ if (!ut(i)) return [];
1116
+ let o = i.attributes ?? d;
1117
+ return d = o, u.set(o), m = i.boardColumnConfigs, a(i.rows ?? []);
1118
+ },
1119
+ onAttributeChange: c.attributeChangeHandlerId ? (e, t, n) => l(c, c.attributeChangeHandlerId, {
1120
+ rowId: e,
1121
+ attributeId: t,
1122
+ value: n
1123
+ }).then(() => void 0) : void 0,
1124
+ onReorder: c.reorderHandlerId ? (e, t) => l(c, c.reorderHandlerId, {
1125
+ rowId: e,
1126
+ beforeRowId: t
1127
+ }).then(() => void 0) : void 0,
1128
+ onCreateRow: At(c, n, l, c.rowActivationHandlerId ? _ : void 0),
1129
+ onColumnAction: c.columnActionHandlerId ? async (e, t) => {
1130
+ await l(c, c.columnActionHandlerId, {
1131
+ columnId: e,
1132
+ actionId: t
1133
+ });
1134
+ } : void 0,
1135
+ getRowContextMenuActions: jt(e, c, n, i, s)
1136
+ }
1137
+ }));
1138
+ }
1139
+ return { dispose() {
1140
+ for (let e = r.length - 1; e >= 0; --e) r[e]?.dispose();
1141
+ } };
1142
+ }, H = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.${e.kind}.${e.id}`, U = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.command.${e.id}`, Nt = (e) => {
1143
+ if (!e) return;
1144
+ let t = (e) => {
1145
+ if (e) return Array.isArray(e) ? e.map(H) : H(e);
1146
+ };
1147
+ return {
1148
+ mode: t(e.mode),
1149
+ source: e.source,
1150
+ viewId: t(e.view),
1151
+ resourceType: e.resourceType?.map((e) => e.id),
1152
+ metadata: e.metadata
1153
+ };
1154
+ }, Pt = Nt, Ft = (e, t) => {
1155
+ if (e) return Object.fromEntries(Object.entries(e).map(([e, n]) => [e, {
1156
+ ...n,
1157
+ label: n.label === void 0 ? void 0 : t(n.label, e),
1158
+ description: n.description === void 0 ? void 0 : t(n.description)
1159
+ }]));
1160
+ }, It = (e) => ({
1161
+ id: e.treeId,
1162
+ kind: "renderer",
1163
+ context: {
1164
+ projectId: e.projectId,
1165
+ treeId: e.treeId,
1166
+ ...e.modeId ? { modeId: e.modeId } : {},
1167
+ ...e.resource ? {
1168
+ resourceType: e.resource.type,
1169
+ resourceId: e.resource.id
1170
+ } : {}
1171
+ }
1172
+ }), W = (e, t, n, r) => {
1173
+ let i = n.resource, a = e.workbench.modes.getActiveModeId();
1174
+ return {
1175
+ renderer: {
1176
+ rendererId: t.id,
1177
+ projectId: e.projectId,
1178
+ ...a ? { modeId: a } : {},
1179
+ ...i ? { resource: i } : {},
1180
+ invocation: { placement: "visible" }
1181
+ },
1182
+ state: n.state,
1183
+ ...n.filter ? { filter: n.filter } : {},
1184
+ ...r ? { node: r } : {}
1185
+ };
1186
+ }, G = async (e, t, n, r, i) => {
1187
+ let a = r.renderer, o = a?.resource;
1188
+ return R(e, n, {
1189
+ params: r,
1190
+ signal: i,
1191
+ resource: o,
1192
+ slot: It({
1193
+ modeId: a?.modeId,
1194
+ projectId: e.projectId,
1195
+ resource: o,
1196
+ treeId: t.id
1197
+ })
1198
+ });
1199
+ }, Lt = async (e, t, n, r, i) => {
1200
+ let a = e.workbench.modes.getActiveModeId();
1201
+ return R(e, n, {
1202
+ params: {
1203
+ ...r ?? {},
1204
+ renderer: {
1205
+ rendererId: t.id,
1206
+ projectId: e.projectId,
1207
+ ...a ? { modeId: a } : {},
1208
+ ...i ? { resource: i } : {},
1209
+ invocation: { placement: "visible" }
1210
+ }
1211
+ },
1212
+ resource: i,
1213
+ slot: It({
1214
+ modeId: a,
1215
+ projectId: e.projectId,
1216
+ resource: i,
1217
+ treeId: t.id
1218
+ }),
1219
+ metadata: { treeId: t.id }
1220
+ });
1221
+ }, Rt = (e, t) => e.panels.flatMap((e) => [e, ...e.panelMenus ?? []]).filter((e) => e.renderer?.kind === "tree" && e.renderer.id === t.id), zt = (e, t) => t.viewId ? e.find((e) => e.id === t.viewId) : e.length === 1 ? e[0] : void 0, Bt = async (e) => {
1222
+ let { ctx: t, getHostTreeHeaderNodes: n, record: r, treeViews: i } = e, a = zt(i, t);
1223
+ return !a || !("hostTreeHeader" in a) || a.hostTreeHeader !== "default" ? [] : await n?.({
1224
+ ctx: t,
1225
+ record: r,
1226
+ panel: a
1227
+ }) ?? [];
1228
+ }, Vt = async (e) => {
1229
+ let { ctx: t, getHostTreeFooterNodes: n, record: r, treeViews: i } = e, a = zt(i, t);
1230
+ return !a || !("hostTreeFooter" in a) || a.hostTreeFooter !== "default" ? [] : await n?.({
1231
+ ctx: t,
1232
+ record: r,
1233
+ panel: a
1234
+ }) ?? [];
1235
+ }, Ht = (e, t) => e && typeof e == "object" && !Array.isArray(e) ? e : t, Ut = (e) => e && !Array.isArray(e) ? e : void 0, Wt = (e, t) => {
1236
+ let n = /* @__PURE__ */ new WeakMap(), r = `workbench.extensionTreeRenderer.${t.id}.command`, i = (t) => e.resolveNodeResource?.(t) ?? t, a = (e) => {
1237
+ if (e.emptyState) return {
1238
+ title: M(e.emptyState.title),
1239
+ description: M(e.emptyState.description),
1240
+ icon: e.emptyState.icon
1241
+ };
1242
+ }, o = (n, i, a) => n ? N(n, {
1243
+ commandTargetOf: (e) => ({
1244
+ kind: "command",
1245
+ commandId: r,
1246
+ args: {
1247
+ commandId: `${e.target.command.extensionId ?? t.extensionId}.command.${e.target.command.id}`,
1248
+ ...i ? { nodeId: i.id } : {},
1249
+ params: e.target.params,
1250
+ resource: i?.resource ?? a.resource,
1251
+ treeId: t.id
1252
+ }
1253
+ }),
1254
+ extensionId: t.extensionId,
1255
+ projectId: e.projectId
1256
+ }) : void 0, s = (n, r, i) => {
1257
+ let a = n.command ? U({
1258
+ ...n.command,
1259
+ extensionId: n.command.extensionId ?? t.extensionId
1260
+ }) : void 0;
1261
+ return {
1262
+ id: n.id,
1263
+ label: M(n.label),
1264
+ icon: n.icon,
1265
+ args: Ut(n.params),
1266
+ params: Ft(n.input, M),
1267
+ submitLabel: n.submitLabel,
1268
+ when: n.when,
1269
+ disabled: n.disabled,
1270
+ run: a ? async (s) => {
1271
+ let c = Ht(s, Ut(n.params));
1272
+ if (n.command?.extensionId === "pstdio") {
1273
+ await e.workbench.commands.executeCommand(a, c, { resource: r?.resource ?? i.resource });
1274
+ return;
1275
+ }
1276
+ let l = await Lt(e, t, a, c, r?.resource ?? i.resource);
1277
+ i.refresh();
1278
+ let u = P(l) ? o(l, r, i) : void 0;
1279
+ u && await e.workbench.navigation.openTarget(u);
1280
+ } : void 0
1281
+ };
1282
+ }, c = (e, t) => {
1283
+ let r = {
1284
+ id: e.id,
1285
+ selected: e.selected,
1286
+ label: M(e.label),
1287
+ icon: e.icon,
1288
+ iconColor: e.iconColor,
1289
+ iconTooltip: e.iconTooltip,
1290
+ resource: e.resource ? i(e.resource) : void 0,
1291
+ target: o(e.target, e, t),
1292
+ rowVariant: e.rowVariant,
1293
+ actions: e.actions?.map((n) => s(n, e, t)),
1294
+ contextMenuActions: e.contextMenuActions?.map((n) => s(n, e, t)),
1295
+ collapsible: e.collapsible,
1296
+ disabled: e.disabled,
1297
+ children: e.children?.map((e) => c(e, t)),
1298
+ description: e.description,
1299
+ contextValue: e.contextValue,
1300
+ hiddenByDefault: e.hiddenByDefault,
1301
+ canHide: e.canHide
1302
+ };
1303
+ return n.set(r, e), r;
1304
+ };
1305
+ return {
1306
+ mapNodes: (e, t) => e.map((e) => c(e, t)),
1307
+ mapSections: (e, t) => e.map((e) => ({
1308
+ id: e.id,
1309
+ label: M(e.label),
1310
+ actions: e.actions?.map((e) => s(e, void 0, t)),
1311
+ collapsible: e.collapsible,
1312
+ emptyState: a(e),
1313
+ nodes: e.nodes.map((e) => c(e, t)),
1314
+ hiddenByDefault: e.hiddenByDefault,
1315
+ canHide: e.canHide
1316
+ })),
1317
+ originalNodes: n,
1318
+ runnerCommandId: r
1319
+ };
1320
+ }, K = (e) => Array.isArray(e) && e.every((e) => e && typeof e == "object" && "nodes" in e), Gt = (e) => Array.isArray(e) && e.every((e) => e && typeof e == "object" && "id" in e), q = (e, t) => t.length > 0 ? [{
1321
+ id: e,
1322
+ nodes: t,
1323
+ canReorder: !1
1324
+ }] : [], Kt = (e, t) => {
1325
+ let n = Wt(e, t), r = Rt(e.metadata, t), i = e.workbench.commands.registerCommand({
1326
+ id: n.runnerCommandId,
1327
+ label: `${M(t.title, t.id)} tree command`
1328
+ }, { execute: async (n) => {
1329
+ let r = n, i = await Lt(e, t, r.commandId, r.params, r.resource);
1330
+ for (let t of e.workbench.views.listViews()) t.body.kind === "file" && e.workbench.views.refreshView(t.id);
1331
+ return i;
1332
+ } }), a = e.workbench.views.registerView({
1333
+ id: t.id,
1334
+ title: M(t.title, t.id),
1335
+ icon: t.icon,
1336
+ body: {
1337
+ kind: "tree",
1338
+ searchable: t.searchable,
1339
+ searchPlaceholder: M(t.searchPlaceholder, "Search files"),
1340
+ defaultExpandedNodeIds: t.defaultExpandedNodeIds,
1341
+ defaultExpandedSectionIds: t.defaultExpandedSectionIds,
1342
+ getHeader: async (i) => {
1343
+ let a = await Bt({
1344
+ ctx: i,
1345
+ getHostTreeHeaderNodes: e.getHostTreeHeaderNodes,
1346
+ record: t,
1347
+ treeViews: r
1348
+ });
1349
+ if (!t.headerHandlerId) return q(`${t.id}:host-header`, a);
1350
+ let o = await G(e, t, t.headerHandlerId, W(e, t, i), i.signal), s = K(o) ? n.mapSections(o, i) : [];
1351
+ return [...q(`${t.id}:host-header`, a), ...s];
1352
+ },
1353
+ getBody: async (r) => {
1354
+ let i = await G(e, t, t.bodyHandlerId, W(e, t, r), r.signal);
1355
+ return K(i) ? n.mapSections(i, r) : [];
1356
+ },
1357
+ getFooter: async (i) => {
1358
+ let a = await Vt({
1359
+ ctx: i,
1360
+ getHostTreeFooterNodes: e.getHostTreeFooterNodes,
1361
+ record: t,
1362
+ treeViews: r
1363
+ });
1364
+ if (!t.footerHandlerId) return q(`${t.id}:host-footer`, a);
1365
+ let o = await G(e, t, t.footerHandlerId, W(e, t, i), i.signal);
1366
+ return [...K(o) ? n.mapSections(o, i) : [], ...q(`${t.id}:host-footer`, a)];
1367
+ },
1368
+ getChildren: async (r, i) => {
1369
+ if (!t.childrenHandlerId) return r.children ?? [];
1370
+ let a = n.originalNodes.get(r);
1371
+ if (!a) return r.children ?? [];
1372
+ let o = await G(e, t, t.childrenHandlerId, W(e, t, i, a), i.signal);
1373
+ return Gt(o) ? n.mapNodes(o, i) : [];
1374
+ }
1375
+ }
1376
+ });
1377
+ return { dispose() {
1378
+ a.dispose(), i.dispose();
1379
+ } };
1380
+ }, qt = (e) => {
1381
+ let t = [];
1382
+ for (let n of e.metadata.treeRenderers ?? []) t.push(Kt(e, n));
1383
+ return { dispose() {
1384
+ for (let e = t.length - 1; e >= 0; --e) t[e]?.dispose();
1385
+ } };
1386
+ }, J = (e) => ({
1387
+ kind: e.kind,
1388
+ id: H(e),
1389
+ extensionId: e.extensionId
1390
+ }), Jt = (e, t, n) => {
1391
+ let r = n?.(t.when);
1392
+ return !r || e.context.matches(r);
1393
+ }, Yt = (e) => ({
1394
+ id: e.id,
1395
+ label: M(e.label, e.id),
1396
+ icon: e.icon,
1397
+ canHide: !0,
1398
+ canReorder: !0,
1399
+ target: N(e.action, { extensionId: e.extensionId })
1400
+ }), Xt = (e, n, r) => {
1401
+ let i = /* @__PURE__ */ new Map();
1402
+ for (let a of n) {
1403
+ if (!Jt(e, a, r)) continue;
1404
+ let n = a.group || void 0, o = n ? `${a.extensionId}:${n}` : t, s = i.get(o) ?? {
1405
+ id: o,
1406
+ label: n,
1407
+ collapsible: !!n,
1408
+ canHide: !0,
1409
+ canReorder: !0,
1410
+ nodes: []
1411
+ };
1412
+ s.nodes.push(Yt(a)), i.set(o, s);
1413
+ }
1414
+ return [...i.values()];
907
1415
  }, Zt = (e) => {
908
- const {
909
- createCommandId: t = Qt,
910
- metadata: n,
911
- resolveString: o = je
912
- } = e, r = [];
913
- return (n.commandPaletteContributions ?? []).forEach((s, i) => {
914
- const a = t(s), d = n.commands.find((m) => m.id === s.commandId);
915
- r.push({
916
- command: {
917
- id: a,
918
- label: o(s.label, s.extensionId),
919
- category: s.group,
920
- description: d ? o(d.description, d.extensionId) : void 0,
921
- icon: s.icon,
922
- params: d?.params
923
- },
924
- contribution: s,
925
- menuItem: Yt({
926
- commandId: a,
927
- contribution: s,
928
- index: i,
929
- resolveString: o
930
- }),
931
- targetCommandId: s.commandId
932
- });
933
- }), r;
934
- }, en = (e) => ({
935
- id: e.rendererId,
936
- kind: "renderer",
937
- context: {
938
- projectId: e.projectId,
939
- ...e.resource ? {
940
- resourceType: e.resource.type,
941
- resourceId: e.resource.id
942
- } : {}
943
- }
944
- }), ge = async (e, t, n, o, r = {}, s) => {
945
- const i = o;
946
- return v(e, n, {
947
- params: {
948
- renderer: {
949
- rendererId: t,
950
- projectId: e.projectId,
951
- ...i ? {
952
- resource: i
953
- } : {},
954
- invocation: {
955
- placement: "visible"
956
- }
957
- },
958
- ...r
959
- },
960
- resource: i,
961
- slot: en({
962
- projectId: e.projectId,
963
- rendererId: t,
964
- resource: i
965
- }),
966
- ...s ? {
967
- metadata: s
968
- } : {}
969
- });
970
- }, $e = (e) => {
971
- if (!e || typeof e != "object") return;
972
- const t = e.revision;
973
- return typeof t == "string" ? t : void 0;
974
- }, Lo = (e, t) => {
975
- const n = e.metadata, o = n?.fileRendererOrigin;
976
- if (!o || typeof o != "object") return;
977
- const r = o;
978
- if (typeof r.rendererId != "string" || typeof r.instanceId != "string" || typeof r.operationId != "string")
979
- return;
980
- const s = n?.fileRendererResourceKey, i = $e(t.outcome.value);
981
- return {
982
- origin: {
983
- rendererId: r.rendererId,
984
- instanceId: r.instanceId,
985
- operationId: r.operationId
986
- },
987
- ...typeof s == "string" ? {
988
- resourceKey: s
989
- } : {},
990
- ...i ? {
991
- revision: i
992
- } : {}
993
- };
994
- }, tn = (e, t) => e.workbench.views.registerView({
995
- id: t.id,
996
- title: p(t.title, t.id),
997
- icon: t.icon,
998
- body: {
999
- kind: "file",
1000
- resourceKind: t.resourceKind,
1001
- load: async (n) => await ge(e, t.id, t.loadHandlerId, n) ?? {},
1002
- save: t.saveHandlerId ? async (n, o, r) => {
1003
- const s = await ge(e, t.id, t.saveHandlerId, n, {
1004
- content: o
1005
- }, {
1006
- ...r ? {
1007
- fileRendererOrigin: r
1008
- } : {},
1009
- ...M(n) ? {
1010
- fileRendererResourceKey: M(n)
1011
- } : {}
1012
- }), i = $e(s);
1013
- return i ? {
1014
- revision: i
1015
- } : void 0;
1016
- } : void 0
1017
- }
1018
- }), nn = (e) => {
1019
- const t = [];
1020
- for (const n of e.metadata.fileRenderers ?? [])
1021
- t.push(tn(e, n));
1022
- return {
1023
- dispose() {
1024
- for (let n = t.length - 1; n >= 0; n -= 1) t[n]?.dispose();
1025
- }
1026
- };
1027
- }, on = (e) => (n) => V(K, {
1028
- name: e ?? "MoreHorizontal",
1029
- ...n
1030
- }), sn = (e, t) => ({
1031
- color: e?.color,
1032
- canDragIn: e?.canDragIn,
1033
- canDragOut: e?.canDragOut,
1034
- canCreate: e?.canCreate,
1035
- actions: e?.actions?.map((n) => ({
1036
- id: n.id,
1037
- label: t(n.label, n.id),
1038
- icon: on(n.icon)
1039
- }))
1040
- }), He = (e, t) => `${t.extensionId ?? e.extensionId}.status.${t.id}`, rn = (e, t) => {
1041
- const n = /* @__PURE__ */ new Map();
1042
- return (o) => {
1043
- const r = He(t, o), s = n.get(r);
1044
- if (s) return s;
1045
- const i = {
1046
- getSnapshot: () => (e.workbench.statuses.getStatuses(r) ?? []).map((a) => ({
1047
- value: a.id,
1048
- label: a.label,
1049
- color: a.color,
1050
- icon: a.icon
1051
- })),
1052
- subscribe: (a) => e.workbench.statuses.store.subscribeSelector((d) => d.values[r], a)
1053
- };
1054
- return n.set(r, i), e.workbench.statuses.load(r).catch(() => {
1055
- }), i;
1056
- };
1057
- }, an = (e, t, n, o, r) => {
1058
- const s = n?.find((d) => d.id === o);
1059
- if (s?.type.kind !== "status") return;
1060
- const i = He(t, s.type.statuses), a = e.workbench.statuses.getStatuses(i)?.find((d) => d.id === r);
1061
- return a ? {
1062
- color: a.color
1063
- } : void 0;
1064
- }, dn = (e) => {
1065
- if (e.defaultSettings?.columnGrouping) return e.defaultSettings.columnGrouping;
1066
- const t = e.attributes?.filter((n) => n.type.kind === "status") ?? [];
1067
- return t.length === 1 ? t[0]?.id : void 0;
1068
- }, Ie = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ve = (e, t, n, o, r, s) => (t ?? []).map((i) => {
1069
- const a = i.display, d = a?.kind === "badge-list" && typeof a.itemsAttributeId == "string" ? {
1070
- kind: "badge-list",
1071
- itemsAttributeId: a.itemsAttributeId
1072
- } : void 0;
1073
- a && !d && s?.(i.id, a.kind);
1074
- const m = {
1075
- ...i,
1076
- label: n(i.label, i.id),
1077
- type: i.type.kind === "status" ? {
1078
- kind: "enum",
1079
- options: r(i.type.statuses)
1080
- } : i.type.kind === "enum" || i.type.kind === "enum-multi" ? {
1081
- ...i.type,
1082
- options: Array.isArray(i.type.options) ? i.type.options.map((c) => ({
1083
- ...c,
1084
- label: n(c.label, c.value)
1085
- })) : i.type.options
1086
- } : i.type,
1087
- display: d
1088
- };
1089
- return o(e, m);
1090
- }), cn = (e, t, n, o, r = () => [], s) => {
1091
- let i = ve(e, t, n, o, r, s);
1092
- const a = /* @__PURE__ */ new Set();
1093
- return {
1094
- source: {
1095
- getSnapshot: () => i,
1096
- subscribe: (d) => (a.add(d), () => a.delete(d))
1097
- },
1098
- set(d) {
1099
- i = ve(e, d, n, o, r, s);
1100
- for (const m of a) m();
1101
- }
1102
- };
1103
- }, ln = (e) => !!(e && typeof e == "object" && typeof e.type == "string" && typeof e.id == "string"), We = (e, t) => {
1104
- const {
1105
- resource: n
1106
- } = t;
1107
- if (ln(n)) return n;
1108
- }, mn = (e, t) => {
1109
- const n = We(e, t);
1110
- if (n) return n;
1111
- if (e.resourceKind)
1112
- return {
1113
- type: e.resourceKind,
1114
- id: t.id,
1115
- label: t.title
1116
- };
1117
- }, un = (e, t) => {
1118
- const n = e, o = t(n);
1119
- return o === void 0 ? n : {
1120
- ...n,
1121
- resource: o
1122
- };
1123
- }, Me = (...e) => Object.assign({}, ...e.filter((t) => !!t)), bn = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, pn = (e) => Object.keys(e ?? {}).length > 0, fn = /* @__PURE__ */ new Set(["text", "longtext", "markdown", "number", "boolean", "select", "multi-select", "files"]), hn = (e, t, n) => {
1124
- if (!fn.has(t.type)) return;
1125
- const o = "options" in t && Array.isArray(t.options) ? t.options : [], r = t;
1126
- return {
1127
- id: e,
1128
- label: n(t.label, e),
1129
- description: t.description === void 0 ? void 0 : n(t.description),
1130
- placeholder: r.placeholder === void 0 ? void 0 : n(r.placeholder),
1131
- type: t.type,
1132
- required: t.required === !0,
1133
- defaultValue: t.defaultValue,
1134
- options: t.type === "select" || t.type === "multi-select" ? o.map((s) => ({
1135
- value: s.value,
1136
- label: n(s.label, s.value),
1137
- icon: s.icon
1138
- })) : void 0,
1139
- multiple: t.type === "files" ? r.multiple !== !1 : void 0,
1140
- accept: t.type === "files" && typeof r.accept == "string" ? r.accept : void 0
1141
- };
1142
- }, wn = (e, t) => Object.entries(e.createRow?.params ?? {}).flatMap(([n, o]) => {
1143
- const r = hn(n, o, t);
1144
- return r ? [r] : [];
1145
- }), gn = (e, t) => B({
1146
- id: t.id,
1147
- kind: "kanbanRenderer",
1148
- projectId: e.projectId,
1149
- context: {
1150
- kanbanRendererId: t.id
1151
- }
1152
- }), L = (e, t, n, o, r) => {
1153
- const s = r ?? e.workbench.getPrimaryResource();
1154
- return v(e, n, {
1155
- params: {
1156
- renderer: {
1157
- rendererId: t.id,
1158
- projectId: e.projectId,
1159
- ...s ? {
1160
- resource: s
1161
- } : {},
1162
- invocation: {
1163
- placement: "visible"
1164
- }
1165
- },
1166
- ...o
1167
- },
1168
- resource: s,
1169
- slot: gn(e, t),
1170
- metadata: {
1171
- kanbanRendererId: t.id
1172
- }
1173
- });
1174
- }, Ve = (e, t) => `workbench.extension.kanbanRenderer.${e.id}.rowAction.${t.id}`, In = (e, t, n) => (t.rowActions ?? []).map((o) => {
1175
- const r = e.workbench.commands.getCommand(o.commandId)?.command;
1176
- return e.workbench.commands.registerCommand({
1177
- id: Ve(t, o),
1178
- label: n(o.label, o.id),
1179
- icon: o.icon,
1180
- params: r?.params
1181
- }, {
1182
- execute: (s, i) => L(e, t, o.commandId, Me(bn(s)), i?.resource)
1183
- });
1184
- }), vn = (e, t, n, o, r, s) => {
1185
- const i = Ve(t, n), a = e.workbench.commands.getCommand(i), d = {
1186
- rowId: o.id
1187
- }, m = r ? {
1188
- resource: r
1189
- } : void 0, c = s(n.label, n.id);
1190
- return a && pn(a.command.params) ? (e.workbench.commandPalette.requestParams({
1191
- record: a,
1192
- label: c,
1193
- args: d,
1194
- context: m
1195
- }), Promise.resolve()) : a ? e.workbench.commands.executeCommand(a.command.id, d, m).then(() => {
1196
- }) : L(e, t, n.commandId, d, r).then(() => {
1197
- });
1198
- }, yn = (e) => e ? V(K, {
1199
- name: e,
1200
- size: 16
1201
- }) : void 0, kn = (e, t) => {
1202
- if (e.createRow)
1203
- return {
1204
- title: t(e.createRow.title, "Create row"),
1205
- submitLabel: t(e.createRow.submitLabel, "Create"),
1206
- fields: wn(e, t),
1207
- labels: {
1208
- cancel: t(e.createRow.labels?.cancel, "Cancel"),
1209
- properties: t(e.createRow.labels?.properties, "Properties"),
1210
- submitError: t(e.createRow.labels?.submitError, "Could not create resource."),
1211
- removeFile: t(e.createRow.labels?.removeFile, "Remove file")
1212
- }
1213
- };
1214
- }, xn = (e, t, n, o, r) => {
1215
- if (t.rowActivationHandlerId)
1216
- return async (s) => {
1217
- const i = o(t, s), a = await L(e, t, t.rowActivationHandlerId, {
1218
- row: r(s)
1219
- }, i), d = Ce(a, {
1220
- extensionId: t.extensionId
1221
- });
1222
- d && await e.workbench.navigation.openTarget(d);
1223
- };
1224
- if (n.onRowClick)
1225
- return (s) => n.onRowClick?.({
1226
- record: t,
1227
- row: s,
1228
- resource: o(t, s)
1229
- });
1230
- }, Rn = (e, t, n, o) => {
1231
- const r = e.createRow;
1232
- if (r)
1233
- return async (s) => {
1234
- const i = Me(s.values, r.columnParam ? {
1235
- [r.columnParam]: s.columnId
1236
- } : void 0, r.attributesParam ? {
1237
- [r.attributesParam]: s.attributeValues
1238
- } : void 0), a = await n(e, r.commandId, i);
1239
- if (await t.onAfterCreate?.({
1240
- record: e,
1241
- created: a,
1242
- submission: s
1243
- }), !o || typeof a != "object" || a === null) return;
1244
- const d = a;
1245
- typeof d.id != "string" || typeof d.title != "string" || await o({
1246
- ...d,
1247
- id: d.id,
1248
- title: d.title,
1249
- attributes: d.attributes ?? {}
1250
- });
1251
- };
1252
- }, En = (e, t, n, o, r) => {
1253
- const s = t.rowActions;
1254
- if (s?.length)
1255
- return (i) => s.map((a) => {
1256
- const d = r(t, i), m = () => vn(e, t, a, i, d, o);
1257
- return {
1258
- key: a.id,
1259
- label: o(a.label, a.id),
1260
- commandId: a.commandId,
1261
- icon: yn(a.icon),
1262
- onClick: () => n.executeRowAction ? n.executeRowAction({
1263
- record: t,
1264
- action: a,
1265
- row: i,
1266
- resource: d,
1267
- runDefault: m
1268
- }) : m()
1269
- };
1270
- });
1271
- }, An = (e, t, n = {}) => {
1272
- const o = [], r = n.resolveLabel ?? ((c, l) => p(c, l)), s = (c, l) => {
1273
- const b = l.display?.kind === "badge-list" ? {
1274
- ...l,
1275
- render: (u, w) => ot(l, u, w)
1276
- } : l;
1277
- return n.decorateAttribute?.(c, b) ?? b;
1278
- }, i = n.resolveRowResource ?? We, a = n.resolveRowActionResource ?? mn, d = n.onAfterMutation ?? (() => {
1279
- }), m = (c, l, b) => L(e, c, l, b).then((u) => (d(c), u));
1280
- for (const c of t) {
1281
- const l = rn(e, c), b = (f, x) => e.workbench.notifications.show({
1282
- id: `workbench.extension.${c.extensionId}.kanban.${c.id}.display.${f}`,
1283
- level: "error",
1284
- title: "Extension display is not available",
1285
- message: `Attribute "${f}" in renderer "${c.id}" uses unknown display kind "${x}".`
1286
- }), u = cn(c, c.attributes, r, s, l, b);
1287
- let w = c.attributes, R = dn(c);
1288
- const E = /* @__PURE__ */ new WeakMap();
1289
- let T, H = 0;
1290
- const U = (f) => i(c, f), j = xn(e, c, n, i, (f) => E.get(f) ?? f);
1291
- o.push(...In(e, c, r)), o.push(e.workbench.views.registerView({
1292
- id: c.id,
1293
- title: r(c.title, c.id),
1294
- icon: c.icon,
1295
- body: {
1296
- kind: "kanban",
1297
- resourceKind: c.resourceKind,
1298
- storageScope: e.projectId,
1299
- attributes: u.source,
1300
- defaultSettings: c.defaultSettings,
1301
- defaultFilters: c.defaultFilters,
1302
- defaultViews: c.defaultViews?.map((f) => ({
1303
- ...f,
1304
- title: r(f.title, f.id)
1305
- })),
1306
- defaultActiveViewId: c.defaultActiveViewId,
1307
- emptyTitle: r(c.emptyTitle, ""),
1308
- emptyDescription: r(c.emptyDescription, ""),
1309
- hideToolbar: c.hideToolbar,
1310
- createRow: kn(c, r),
1311
- getBoardColumnConfig: (f) => sn(T?.[f] ?? an(e, c, w, R, f), r),
1312
- onRowActivate: j,
1313
- executeQuery: async (f) => {
1314
- H += 1;
1315
- const x = H, g = await L(e, c, c.queryHandlerId, {
1316
- settings: f.settings,
1317
- filters: f.filters
1318
- }), P = (h) => h.map((A) => {
1319
- const C = un(A, U);
1320
- return E.set(C, A), C;
1321
- });
1322
- if (x !== H)
1323
- return Array.isArray(g) ? P(g) : Ie(g) ? P(g.rows ?? []) : [];
1324
- if (R = f.settings.columnGrouping, Array.isArray(g)) return P(g);
1325
- if (!Ie(g)) return [];
1326
- const q = g.attributes ?? w;
1327
- return w = q, u.set(q), T = g.boardColumnConfigs, P(g.rows ?? []);
1328
- },
1329
- onAttributeChange: c.attributeChangeHandlerId ? (f, x, g) => m(c, c.attributeChangeHandlerId, {
1330
- rowId: f,
1331
- attributeId: x,
1332
- value: g
1333
- }).then(() => {
1334
- }) : void 0,
1335
- onReorder: c.reorderHandlerId ? (f, x) => m(c, c.reorderHandlerId, {
1336
- rowId: f,
1337
- beforeRowId: x
1338
- }).then(() => {
1339
- }) : void 0,
1340
- onCreateRow: Rn(c, n, m, c.rowActivationHandlerId ? j : void 0),
1341
- onColumnAction: c.columnActionHandlerId ? async (f, x) => {
1342
- await m(c, c.columnActionHandlerId, {
1343
- columnId: f,
1344
- actionId: x
1345
- });
1346
- } : void 0,
1347
- getRowContextMenuActions: En(e, c, n, r, a)
1348
- }
1349
- }));
1350
- }
1351
- return {
1352
- dispose() {
1353
- for (let c = o.length - 1; c >= 0; c -= 1) o[c]?.dispose();
1354
- }
1355
- };
1356
- }, Cn = (e, t) => {
1357
- if (e)
1358
- return Object.fromEntries(Object.entries(e).map(([n, o]) => [n, {
1359
- ...o,
1360
- label: o.label === void 0 ? void 0 : t(o.label, n),
1361
- description: o.description === void 0 ? void 0 : t(o.description)
1362
- }]));
1363
- }, Be = (e) => ({
1364
- id: e.treeId,
1365
- kind: "renderer",
1366
- context: {
1367
- projectId: e.projectId,
1368
- treeId: e.treeId,
1369
- ...e.modeId ? {
1370
- modeId: e.modeId
1371
- } : {},
1372
- ...e.resource ? {
1373
- resourceType: e.resource.type,
1374
- resourceId: e.resource.id
1375
- } : {}
1376
- }
1377
- }), z = (e, t, n, o) => {
1378
- const r = n.resource, s = e.workbench.modes.getActiveModeId();
1379
- return {
1380
- renderer: {
1381
- rendererId: t.id,
1382
- projectId: e.projectId,
1383
- ...s ? {
1384
- modeId: s
1385
- } : {},
1386
- ...r ? {
1387
- resource: r
1388
- } : {},
1389
- invocation: {
1390
- placement: "visible"
1391
- }
1392
- },
1393
- state: n.state,
1394
- ...n.filter ? {
1395
- filter: n.filter
1396
- } : {},
1397
- ...o ? {
1398
- node: o
1399
- } : {}
1400
- };
1401
- }, G = async (e, t, n, o) => {
1402
- const r = o.renderer, s = r?.resource;
1403
- return v(e, n, {
1404
- params: o,
1405
- resource: s,
1406
- slot: Be({
1407
- modeId: r?.modeId,
1408
- projectId: e.projectId,
1409
- resource: s,
1410
- treeId: t.id
1411
- })
1412
- });
1413
- }, De = async (e, t, n, o, r) => {
1414
- const s = e.workbench.modes.getActiveModeId(), i = {
1415
- ...o ?? {},
1416
- renderer: {
1417
- rendererId: t.id,
1418
- projectId: e.projectId,
1419
- ...s ? {
1420
- modeId: s
1421
- } : {},
1422
- ...r ? {
1423
- resource: r
1424
- } : {},
1425
- invocation: {
1426
- placement: "visible"
1427
- }
1428
- }
1429
- };
1430
- return v(e, n, {
1431
- params: i,
1432
- resource: r,
1433
- slot: Be({
1434
- modeId: s,
1435
- projectId: e.projectId,
1436
- resource: r,
1437
- treeId: t.id
1438
- }),
1439
- metadata: {
1440
- treeId: t.id
1441
- }
1442
- });
1443
- }, Sn = (e, t) => e.panels.flatMap((n) => [n, ...n.panelMenus ?? []]).filter((n) => n.renderer?.kind === "tree" && n.renderer.id === t.id), Oe = (e, t) => t.viewId ? e.find((n) => n.id === t.viewId) : e.length === 1 ? e[0] : void 0, Tn = async (e) => {
1444
- const {
1445
- ctx: t,
1446
- getHostTreeHeaderNodes: n,
1447
- record: o,
1448
- treeViews: r
1449
- } = e, s = Oe(r, t);
1450
- return !s || !("hostTreeHeader" in s) || s.hostTreeHeader !== "default" ? [] : await n?.({
1451
- ctx: t,
1452
- record: o,
1453
- panel: s
1454
- }) ?? [];
1455
- }, Pn = async (e) => {
1456
- const {
1457
- ctx: t,
1458
- getHostTreeFooterNodes: n,
1459
- record: o,
1460
- treeViews: r
1461
- } = e, s = Oe(r, t);
1462
- return !s || !("hostTreeFooter" in s) || s.hostTreeFooter !== "default" ? [] : await n?.({
1463
- ctx: t,
1464
- record: o,
1465
- panel: s
1466
- }) ?? [];
1467
- }, jn = (e, t) => e && typeof e == "object" && !Array.isArray(e) ? e : t, ye = (e) => e && !Array.isArray(e) ? e : void 0, $n = (e, t) => {
1468
- const n = /* @__PURE__ */ new WeakMap(), o = `workbench.extensionTreeRenderer.${t.id}.command`, r = (l) => e.resolveNodeResource?.(l) ?? l, s = (l) => {
1469
- if (l.emptyState)
1470
- return {
1471
- title: p(l.emptyState.title),
1472
- description: p(l.emptyState.description),
1473
- icon: l.emptyState.icon
1474
- };
1475
- }, i = (l, b, u) => l ? S(l, {
1476
- commandTargetOf: (R) => ({
1477
- kind: "command",
1478
- commandId: o,
1479
- args: {
1480
- commandId: `${R.target.command.extensionId ?? t.extensionId}.command.${R.target.command.id}`,
1481
- ...b ? {
1482
- nodeId: b.id
1483
- } : {},
1484
- params: R.target.params,
1485
- resource: b?.resource ?? u.resource,
1486
- treeId: t.id
1487
- }
1488
- }),
1489
- extensionId: t.extensionId,
1490
- projectId: e.projectId
1491
- }) : void 0, a = (l, b, u) => {
1492
- const w = l.command ? `${l.command.extensionId ?? t.extensionId}.command.${l.command.id}` : void 0;
1493
- return {
1494
- id: l.id,
1495
- label: p(l.label),
1496
- icon: l.icon,
1497
- args: ye(l.params),
1498
- params: Cn(l.input, p),
1499
- submitLabel: l.submitLabel,
1500
- when: l.when,
1501
- disabled: l.disabled,
1502
- // Actions mutate tree data (create/delete/...), so refresh afterwards. Plain
1503
- // node-target navigation runs through the runner command and must not refetch.
1504
- run: w ? async (R) => {
1505
- const E = await De(e, t, w, jn(R, ye(l.params)), b?.resource ?? u.resource);
1506
- u.refresh();
1507
- const T = Ae(E) ? i(E, b, u) : void 0;
1508
- T && await e.workbench.navigation.openTarget(T);
1509
- } : void 0
1510
- };
1511
- }, d = (l, b) => {
1512
- const u = {
1513
- id: l.id,
1514
- selected: l.selected,
1515
- label: p(l.label),
1516
- icon: l.icon,
1517
- iconColor: l.iconColor,
1518
- iconTooltip: l.iconTooltip,
1519
- resource: l.resource ? r(l.resource) : void 0,
1520
- target: i(l.target, l, b),
1521
- rowVariant: l.rowVariant,
1522
- actions: l.actions?.map((w) => a(w, l, b)),
1523
- contextMenuActions: l.contextMenuActions?.map((w) => a(w, l, b)),
1524
- collapsible: l.collapsible,
1525
- disabled: l.disabled,
1526
- children: l.children?.map((w) => d(w, b)),
1527
- description: l.description,
1528
- contextValue: l.contextValue,
1529
- hiddenByDefault: l.hiddenByDefault,
1530
- canHide: l.canHide
1531
- };
1532
- return n.set(u, l), u;
1533
- };
1534
- return {
1535
- mapNodes: (l, b) => l.map((u) => d(u, b)),
1536
- mapSections: (l, b) => l.map((u) => ({
1537
- id: u.id,
1538
- label: p(u.label),
1539
- actions: u.actions?.map((w) => a(w, void 0, b)),
1540
- collapsible: u.collapsible,
1541
- emptyState: s(u),
1542
- nodes: u.nodes.map((w) => d(w, b)),
1543
- hiddenByDefault: u.hiddenByDefault,
1544
- canHide: u.canHide
1545
- })),
1546
- originalNodes: n,
1547
- runnerCommandId: o
1548
- };
1549
- }, oe = (e) => Array.isArray(e) && e.every((t) => t && typeof t == "object" && "nodes" in t), Hn = (e) => Array.isArray(e) && e.every((t) => t && typeof t == "object" && "id" in t), Q = (e, t) => t.length > 0 ? [{
1550
- id: e,
1551
- nodes: t,
1552
- canReorder: !1
1553
- }] : [], Wn = (e, t) => {
1554
- const n = $n(e, t), o = Sn(e.metadata, t), r = e.workbench.commands.registerCommand({
1555
- id: n.runnerCommandId,
1556
- label: `${p(t.title, t.id)} tree command`
1557
- }, {
1558
- execute: async (i) => {
1559
- const a = i, d = await De(e, t, a.commandId, a.params, a.resource);
1560
- for (const m of e.workbench.views.listViews())
1561
- m.body.kind === "file" && e.workbench.views.refreshView(m.id);
1562
- return d;
1563
- }
1564
- }), s = e.workbench.views.registerView({
1565
- id: t.id,
1566
- title: p(t.title, t.id),
1567
- icon: t.icon,
1568
- body: {
1569
- kind: "tree",
1570
- searchable: t.searchable,
1571
- searchPlaceholder: p(t.searchPlaceholder, "Search files"),
1572
- defaultExpandedNodeIds: t.defaultExpandedNodeIds,
1573
- defaultExpandedSectionIds: t.defaultExpandedSectionIds,
1574
- getHeader: async (i) => {
1575
- const a = await Tn({
1576
- ctx: i,
1577
- getHostTreeHeaderNodes: e.getHostTreeHeaderNodes,
1578
- record: t,
1579
- treeViews: o
1580
- });
1581
- if (!t.headerHandlerId) return Q(`${t.id}:host-header`, a);
1582
- const d = await G(e, t, t.headerHandlerId, z(e, t, i)), m = oe(d) ? n.mapSections(d, i) : [];
1583
- return [...Q(`${t.id}:host-header`, a), ...m];
1584
- },
1585
- getBody: async (i) => {
1586
- const a = await G(e, t, t.bodyHandlerId, z(e, t, i));
1587
- return oe(a) ? n.mapSections(a, i) : [];
1588
- },
1589
- getFooter: async (i) => {
1590
- const a = await Pn({
1591
- ctx: i,
1592
- getHostTreeFooterNodes: e.getHostTreeFooterNodes,
1593
- record: t,
1594
- treeViews: o
1595
- });
1596
- if (!t.footerHandlerId) return Q(`${t.id}:host-footer`, a);
1597
- const d = await G(e, t, t.footerHandlerId, z(e, t, i));
1598
- return [...oe(d) ? n.mapSections(d, i) : [], ...Q(`${t.id}:host-footer`, a)];
1599
- },
1600
- getChildren: async (i, a) => {
1601
- if (!t.childrenHandlerId) return i.children ?? [];
1602
- const d = n.originalNodes.get(i);
1603
- if (!d) return i.children ?? [];
1604
- const m = await G(e, t, t.childrenHandlerId, z(e, t, a, d));
1605
- return Hn(m) ? n.mapNodes(m, a) : [];
1606
- }
1607
- }
1608
- });
1609
- return {
1610
- dispose() {
1611
- s.dispose(), r.dispose();
1612
- }
1613
- };
1614
- }, Mn = (e) => {
1615
- const t = [];
1616
- for (const n of e.metadata.treeRenderers ?? [])
1617
- t.push(Wn(e, n));
1618
- return {
1619
- dispose() {
1620
- for (let n = t.length - 1; n >= 0; n -= 1) t[n]?.dispose();
1621
- }
1622
- };
1623
- }, I = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.${e.kind}.${e.id}`, Y = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.command.${e.id}`, Ne = (e) => {
1624
- if (!e) return;
1625
- const t = (n) => {
1626
- if (n)
1627
- return Array.isArray(n) ? n.map(I) : I(n);
1628
- };
1629
- return {
1630
- mode: t(e.mode),
1631
- source: e.source,
1632
- viewId: t(e.view),
1633
- resourceType: e.resourceType?.map((n) => n.id),
1634
- metadata: e.metadata
1635
- };
1636
- }, _o = Ne, ae = (e) => ({
1637
- kind: e.kind,
1638
- id: I(e),
1639
- extensionId: e.extensionId
1640
- }), Vn = (e, t, n) => {
1641
- const o = n?.(t.when);
1642
- return o ? e.context.matches(o) : !0;
1643
- }, Bn = (e) => ({
1644
- id: e.id,
1645
- label: p(e.label, e.id),
1646
- icon: e.icon,
1647
- canHide: !0,
1648
- canReorder: !0,
1649
- target: S(e.action, {
1650
- extensionId: e.extensionId
1651
- })
1652
- }), Dn = (e, t, n) => {
1653
- const o = /* @__PURE__ */ new Map();
1654
- for (const r of t) {
1655
- if (!Vn(e, r, n)) continue;
1656
- const s = r.group || void 0, i = s ? `${r.extensionId}:${s}` : "navigation.root", a = o.get(i) ?? {
1657
- id: i,
1658
- label: s,
1659
- collapsible: !!s,
1660
- canHide: !0,
1661
- canReorder: !0,
1662
- nodes: []
1663
- };
1664
- a.nodes.push(Bn(r)), o.set(i, a);
1665
- }
1666
- return [...o.values()];
1667
- }, On = (e) => {
1668
- const t = /* @__PURE__ */ new Map();
1669
- for (const n of e) {
1670
- const o = ae(n.owner), r = `${n.extensionId}:${o.kind}:${o.id}:${n.slot}`;
1671
- t.set(r, [...t.get(r) ?? [], n]);
1672
- }
1673
- return [...t.values()];
1674
- }, Nn = (e) => [...new Set(e.flatMap((t) => t.group ? [`${t.extensionId}:${t.group}`] : []))], Fn = (e) => On(e.metadata.navigationItems).map((t) => {
1675
- const n = t[0];
1676
- return e.workbench.navigationTrees.registerContribution({
1677
- id: `${n.extensionId}.navigation-items.${n.owner.kind}.${I(n.owner)}.${n.slot}`,
1678
- owner: ae(n.owner),
1679
- sourceExtensionId: n.extensionId,
1680
- declarationIndex: e.metadata.navigationItems.indexOf(n),
1681
- slot: n.slot,
1682
- defaultExpandedSectionIds: Nn(t),
1683
- getSections: () => Dn(e.workbench, t, e.createWhenExpression)
1684
- });
1685
- }), Kn = (e) => e.metadata.navigationTrees.map((t, n) => {
1686
- const o = I(t.view);
1687
- return e.workbench.navigationTrees.registerContribution({
1688
- id: t.id,
1689
- idScope: t.id,
1690
- owner: ae(t.owner),
1691
- sourceExtensionId: t.extensionId,
1692
- declarationIndex: e.metadata.navigationItems.length + n,
1693
- slot: t.slot,
1694
- viewId: o
1695
- });
1696
- }), Ln = (e) => [...Fn(e), ...Kn(e)], _n = () => {
1697
- if (typeof navigator > "u") return;
1698
- const e = `${navigator.platform} ${navigator.userAgent}`.toLowerCase();
1699
- if (e.includes("mac")) return "mac";
1700
- if (e.includes("win")) return "win";
1701
- if (e.includes("linux")) return "linux";
1702
- }, Un = (e, t = _n()) => (t ? e.platformOverrides?.[t] : void 0) ?? e.key, qn = (e) => e.bindings.map((t) => e.workbench.keybindings.registerKeybinding({
1703
- action: S(t.action, {
1704
- commandIdOf: (n) => n.extensionId ? Y({
1705
- extensionId: n.extensionId,
1706
- id: n.id
1707
- }) : void 0
1708
- }),
1709
- keybinding: Un(t),
1710
- when: e.createWhenExpression?.(t.when)
1711
- })), zn = (e, t) => ({
1712
- ...e,
1713
- tab: e.tab && t.createTab ? t.createTab({
1714
- ...e.tab,
1715
- extensionId: t.extensionId,
1716
- placementId: t.placementId
1717
- }) : void 0
1718
- }), Gn = (e, t) => e.kind === "panels" ? e : {
1719
- ...e,
1720
- tab: e.tab && t.createTab ? t.createTab({
1721
- ...e.tab,
1722
- extensionId: t.extensionId,
1723
- placementId: t.placementId
1724
- }) : void 0
1725
- }, Qn = (e, t) => e.pages.map((n) => ({
1726
- id: n.id,
1727
- ref: {
1728
- extensionId: n.extensionId,
1729
- kind: "page",
1730
- id: n.localId
1731
- },
1732
- title: n.title,
1733
- path: n.path,
1734
- modeId: I(n.mode),
1735
- resource: n.resource,
1736
- main: Gn(n.main, {
1737
- extensionId: n.extensionId,
1738
- placementId: `${n.id}.$main`,
1739
- createTab: t
1740
- }),
1741
- slots: n.slots.map((o) => zn(o, {
1742
- extensionId: n.extensionId,
1743
- placementId: `${n.id}.${o.id}`,
1744
- createTab: t
1745
- })),
1746
- ...n.icon ? {
1747
- icon: n.icon
1748
- } : {},
1749
- ...n.parent ? {
1750
- parentId: I(n.parent)
1751
- } : {}
1752
- })), _ = (e, t) => {
1753
- const n = e.pages.flatMap((o) => [...o.main.kind === "view" && o.resource ? [{
1754
- ...o.resource,
1755
- view: o.main.view
1756
- }] : [], ...o.slots.flatMap((r) => r.item.kind === "binding" ? [r.item.binding] : [])]);
1757
- return n.push(...e.placements.flatMap((o) => o.item.kind === "binding" ? [o.item.binding] : [])), n.find((o) => I(o.view) === t)?.kinds[0]?.id;
1758
- }, Fe = (e) => e.body.kind === "webview" ? {
1759
- webview: e.body.webview
1760
- } : {
1761
- renderer: {
1762
- kind: e.body.kind,
1763
- id: e.id
1764
- }
1765
- }, Xn = (e, t) => e.viewMenus.flatMap((n) => {
1766
- if (I(n.owner) !== t.id) return [];
1767
- const o = e.views.find((r) => r.id === I(n.view));
1768
- return o ? [{
1769
- id: n.id,
1770
- extensionId: n.extensionId,
1771
- ownerPanelId: t.id,
1772
- viewId: o.id,
1773
- title: o.title,
1774
- side: n.side,
1775
- group: n.group,
1776
- placement: n.placement,
1777
- hostTreeHeader: n.hostTreeHeader,
1778
- hostTreeFooter: n.hostTreeFooter,
1779
- ...Fe(o)
1780
- }] : [];
1781
- }), Yn = (e) => e.views.map((t) => {
1782
- const n = Xn(e, t);
1783
- return {
1784
- id: t.id,
1785
- extensionId: t.extensionId,
1786
- title: t.title,
1787
- icon: t.icon,
1788
- panelMenus: n.length > 0 ? n : void 0,
1789
- ...Fe(t)
1790
- };
1791
- }), se = (e) => e?.map(({
1792
- command: t,
1793
- ...n
1794
- }) => ({
1795
- ...n,
1796
- commandId: Y(t)
1797
- })), Jn = (e) => e.views.flatMap((t) => {
1798
- const n = t.body;
1799
- return n.kind !== "kanban" ? [] : [{
1800
- ...n,
1801
- id: t.id,
1802
- extensionId: t.extensionId,
1803
- title: t.title,
1804
- icon: t.icon,
1805
- resourceKind: _(e, t.id),
1806
- createRow: n.createRow ? {
1807
- title: n.createRow.title,
1808
- submitLabel: n.createRow.submitLabel,
1809
- columnParam: n.createRow.columnParam,
1810
- params: n.createRow.params,
1811
- attributesParam: n.createRow.attributesParam,
1812
- labels: n.createRow.labels,
1813
- commandId: Y(n.createRow.command),
1814
- attachments: n.createRow.attachments ? {
1815
- resourceParam: n.createRow.attachments.resourceParam,
1816
- fileParam: n.createRow.attachments.fileParam,
1817
- commandId: Y(n.createRow.attachments.command)
1818
- } : void 0
1819
- } : void 0,
1820
- rowActions: se(n.rowActions)
1821
- }];
1822
- }), Zn = (e) => e.views.flatMap((t) => {
1823
- const n = t.body;
1824
- return n.kind !== "dataTable" ? [] : [{
1825
- ...n,
1826
- id: t.id,
1827
- extensionId: t.extensionId,
1828
- title: t.title,
1829
- icon: t.icon,
1830
- resourceKind: _(e, t.id),
1831
- selectionActions: se(n.selectionActions),
1832
- rowActions: se(n.rowActions)
1833
- }];
1834
- }), eo = (e) => e.views.flatMap((t) => t.body.kind === "tree" ? [{
1835
- ...t.body,
1836
- id: t.id,
1837
- extensionId: t.extensionId,
1838
- title: t.title,
1839
- icon: t.icon,
1840
- resourceKind: _(e, t.id)
1841
- }] : []), to = (e) => e.views.flatMap((t) => t.body.kind === "file" ? [{
1842
- ...t.body,
1843
- id: t.id,
1844
- extensionId: t.extensionId,
1845
- title: t.title,
1846
- icon: t.icon,
1847
- resourceKind: _(e, t.id)
1848
- }] : []), no = (e) => e.views.flatMap((t) => t.body.kind === "controls" ? [{
1849
- ...t.body,
1850
- id: t.id,
1851
- extensionId: t.extensionId,
1852
- title: t.title,
1853
- icon: t.icon,
1854
- resourceKind: _(e, t.id)
1855
- }] : []), oo = (e) => e.modes.map((t) => ({
1856
- id: t.id,
1857
- extensionId: t.extensionId,
1858
- modeId: t.id,
1859
- label: t.label,
1860
- icon: t.icon,
1861
- panelRegions: t.regions,
1862
- regionSettings: t.regionSettings,
1863
- floatingPanels: t.floatingPanels,
1864
- ...t.defaultTheme ? {
1865
- defaultTheme: I(t.defaultTheme)
1866
- } : {},
1867
- ...t.chrome ? {
1868
- chrome: Object.fromEntries(Object.entries(t.chrome).map(([n, o]) => [n, o === !1 ? !1 : I(o)]))
1869
- } : {}
1870
- })), so = (e, t = {}) => {
1871
- const n = Yn(e);
1872
- return {
1873
- extensions: e.extensions,
1874
- commands: e.commands,
1875
- menuContributions: e.menuContributions,
1876
- commandPaletteContributions: e.commandPaletteContributions,
1877
- modes: oo(e),
1878
- pages: Qn(e, t.createTab),
1879
- placements: e.placements.map((o) => ({
1880
- id: o.id,
1881
- ref: {
1882
- extensionId: o.extensionId,
1883
- kind: "placement",
1884
- id: o.localId
1885
- },
1886
- modeId: I(o.mode),
1887
- item: o.item,
1888
- region: o.region,
1889
- order: o.order,
1890
- movableTo: o.movableTo,
1891
- mountStrategy: o.mountStrategy,
1892
- hiddenByDefault: o.hiddenByDefault,
1893
- headerBorderBottom: o.headerBorderBottom,
1894
- tab: o.tab && t.createTab ? t.createTab({
1895
- ...o.tab,
1896
- extensionId: o.extensionId,
1897
- placementId: o.id
1898
- }) : void 0
1899
- })),
1900
- panels: n,
1901
- resourceKinds: e.resourceKinds.map((o) => ({
1902
- id: o.id,
1903
- extensionId: o.extensionId,
1904
- label: o.label,
1905
- icon: o.icon,
1906
- menuSlots: Object.fromEntries((o.menuSlots ?? []).map((r) => [r.id, {
1907
- placement: r.placement,
1908
- label: r.label,
1909
- external: r.access === "public",
1910
- order: r.order
1911
- }]))
1912
- })),
1913
- resourceHierarchyProviders: (e.resourceHierarchyProviders ?? []).map((o) => ({
1914
- id: o.id,
1915
- extensionId: o.extensionId,
1916
- resourceKind: o.resourceKind.id
1917
- })),
1918
- settingsSections: e.settingsSections ?? [],
1919
- settingsPanels: e.settingsPanels.flatMap((o) => {
1920
- const r = e.views.find((s) => s.id === I(o.view));
1921
- return r ? [{
1922
- id: o.id,
1923
- viewId: r.id,
1924
- extensionId: o.extensionId,
1925
- slotId: o.slot.id,
1926
- scope: o.slot.id.includes("global") ? "global" : "project",
1927
- title: r.title,
1928
- icon: r.icon,
1929
- section: o.section ? I(o.section) : void 0
1930
- }] : [];
1931
- }),
1932
- kanbanRenderers: Jn(e),
1933
- dataTableRenderers: Zn(e),
1934
- commandPaletteResources: e.commandPaletteResources ?? [],
1935
- treeRenderers: eo(e),
1936
- fileRenderers: to(e),
1937
- controlsRenderers: no(e),
1938
- keybindings: e.keybindings ?? [],
1939
- settingsDefinitions: e.settingsDefinitions ?? [],
1940
- statuses: e.statuses,
1941
- statusBarItems: e.statusBarItems.map((o) => ({
1942
- id: o.id,
1943
- extensionId: o.extensionId,
1944
- viewId: I(o.view),
1945
- slot: o.slot.id.endsWith("leading") ? "leading" : "trailing",
1946
- order: o.order,
1947
- when: Ne(o.when)
1948
- })),
1949
- diagnostics: e.diagnostics
1950
- };
1951
- }, ro = (e, t, n = {}) => {
1952
- e.views.refreshView(t.id, t.kind === "file" ? n : void 0);
1953
- }, io = (e) => {
1954
- const t = /* @__PURE__ */ new Map(), n = (o, r) => {
1955
- for (const s of new Set(r.refreshEventIds ?? [])) {
1956
- const i = t.get(s) ?? [];
1957
- i.some((a) => a.kind === o && a.id === r.id) || i.push({
1958
- id: r.id,
1959
- kind: o
1960
- }), t.set(s, i);
1961
- }
1962
- };
1963
- for (const o of e.views)
1964
- o.body.kind !== "webview" && n(o.body.kind, {
1965
- id: o.id,
1966
- refreshEventIds: o.body.refreshEventIds
1967
- });
1968
- return t;
1969
- }, ao = (e) => {
1970
- const t = io(e.metadata);
1971
- return e.subscribe((n) => {
1972
- const {
1973
- id: o,
1974
- ...r
1975
- } = n;
1976
- for (const s of t.get(o) ?? []) ro(e.workbench, s, r);
1977
- });
1978
- }, Uo = (e, t) => {
1979
- for (const n of t.views)
1980
- n.body.kind === "webview" && e.views.getView(n.id) && e.views.refreshView(n.id);
1981
- }, co = (e) => (t) => ({
1982
- ...St({
1983
- workbench: t.workbench,
1984
- placement: t.placement,
1985
- hostEvents: t.hostEvents
1986
- }),
1987
- "navigation.open": (o) => {
1988
- const r = o;
1989
- if (!r.target) throw new Error("navigation.open requires a target.");
1990
- return t.workbench.navigation.openTarget(S(r.target, {
1991
- extensionId: e.extensionIdForWebview(t.webviewId),
1992
- projectId: e.projectId
1993
- }));
1994
- },
1995
- "commands.execute": async (o) => {
1996
- const r = o, s = r.resource ?? t.placement.resource;
1997
- return Te({
1998
- ...e,
1999
- workbench: t.workbench
2000
- }, r.commandId, {
2001
- ...r.params ? {
2002
- params: r.params
2003
- } : {},
2004
- ...s ? {
2005
- resource: s
2006
- } : {},
2007
- slot: B({
2008
- id: t.webviewId,
2009
- kind: e.slotKind,
2010
- projectId: e.projectId,
2011
- context: {
2012
- panelId: t.webviewId
2013
- }
2014
- })
2015
- });
2016
- },
2017
- ...e.files ? {
2018
- "files.upload": e.files.upload,
2019
- "files.list": e.files.list,
2020
- "files.delete": e.files.delete
2021
- } : {},
2022
- ...e.artifacts ? {
2023
- // The image-url grant is bound to the requesting webview, so the host
2024
- // resolves the webview id instead of trusting the guest to name one.
2025
- "artifacts.read": (o) => e.artifacts.read(o, {
2026
- webviewId: t.webviewId
2027
- })
2028
- } : {}
2029
- }), lo = (e) => ({
2030
- title: p(e.title) || void 0,
2031
- runtimeUrl: e.runtimeUrl,
2032
- moduleUrl: e.moduleUrl,
2033
- styles: e.styles,
2034
- capabilities: e.capabilities
2035
- }), Ke = "extensions", mo = 1e3, uo = 25, bo = (e) => e === void 0 ? void 0 : e, po = (e) => e === "global" ? "user" : "project", fo = (e, t) => t ? (n) => ({
2036
- ...e(n),
2037
- ...t(n)
2038
- }) : e, ho = (e, t) => {
2039
- const n = e.createWebviewHostCapabilities ?? co({
2040
- artifacts: e.webviewArtifacts,
2041
- executeCommand: e.executeCommand,
2042
- extensionIdForWebview: (o) => e.metadata.panels.find((r) => r.id === o)?.extensionId,
2043
- files: e.webviewFiles,
2044
- projectId: e.projectId,
2045
- slotKind: t
2046
- });
2047
- return fo(n, e.createWebviewHostCapabilityOverrides);
2048
- }, wo = (e) => e.metadata.panels.flatMap((t) => {
2049
- if (!t.webview) return [];
2050
- const n = lo(t.webview);
2051
- return [e.workbench.views.registerView({
2052
- id: t.id,
2053
- title: p(t.title, t.id),
2054
- icon: t.icon,
2055
- body: {
2056
- kind: "react",
2057
- render: (o) => {
2058
- const r = e.metadata.settingsPanels.some((s) => s.id === o.instance.panelId && s.viewId === t.id) ? "settings" : "panel";
2059
- return e.renderWebview?.(o) ?? jt({
2060
- context: {
2061
- workbench: o.workbench,
2062
- webviewId: t.id,
2063
- placement: o.instance,
2064
- hostEvents: Pt(o.workbench, o.instance)
2065
- },
2066
- createHostCapabilities: ho(e, r),
2067
- createProps: e.createWebviewProps ?? (({
2068
- placement: s
2069
- }) => ({
2070
- placement: s,
2071
- resource: s.resource
2072
- })),
2073
- createTheme: e.createWebviewTheme,
2074
- ownerId: t.extensionId,
2075
- title: p(t.title, t.id),
2076
- webview: n
2077
- });
2078
- }
2079
- }
2080
- })];
2081
- }), go = {
2082
- first: 1e6,
2083
- default: 0,
2084
- last: -1e6
2085
- }, Io = (e) => e.metadata.panels.flatMap((t) => t.panelMenus ?? []).map((t, n) => e.workbench.viewMenus.registerViewMenu({
2086
- id: t.id,
2087
- ownerViewId: t.ownerPanelId,
2088
- viewId: t.viewId,
2089
- side: t.side,
2090
- priority: go[t.placement ?? "default"] - n
2091
- })), ke = (e) => {
2092
- if (!e || typeof e != "object" || !("statuses" in e) || !Array.isArray(e.statuses))
2093
- throw new Error("Status provider returned an invalid response");
2094
- return e.statuses;
2095
- }, vo = (e, t) => {
2096
- const n = e.metadata.statuses ?? [];
2097
- if (n.length === 0) return [];
2098
- const o = "workbench.extension-statuses.settings", r = n.map((s, i) => e.workbench.statuses.registerStatusSet({
2099
- id: s.id,
2100
- title: p(s.title, s.id),
2101
- actions: s.actions?.map((a) => ({
2102
- id: a.id,
2103
- label: p(a.label, a.id),
2104
- icon: a.icon
2105
- })),
2106
- query: async () => ke(await v(t, s.queryHandlerId, {
2107
- params: {}
2108
- })),
2109
- save: s.saveHandlerId ? async (a) => ke(await v(t, s.saveHandlerId, {
2110
- params: {
2111
- statuses: a
2112
- }
2113
- })) : void 0
2114
- }, {
2115
- ownerId: s.extensionId,
2116
- priority: -i
2117
- }));
2118
- return r.push(e.workbench.views.registerView({
2119
- id: o,
2120
- title: "Statuses",
2121
- body: {
2122
- kind: "react",
2123
- render: () => V(nt, {
2124
- workbench: e.workbench
2125
- })
2126
- }
2127
- })), r.push(e.workbench.settings.registerPanel({
2128
- id: "workbench.statuses",
2129
- title: "Statuses",
2130
- icon: "list-checks",
2131
- kind: "view",
2132
- order: uo,
2133
- section: e.settingsSectionId ?? Ke,
2134
- scope: "project",
2135
- viewId: o
2136
- })), r;
2137
- }, yo = (e) => {
2138
- const t = [], n = e.settingsSectionId ?? Ke;
2139
- e.workbench.settings.getSection(n) || t.push(e.workbench.settings.registerSection({
2140
- id: n,
2141
- title: e.settingsSectionTitle ?? "Extensions"
2142
- }));
2143
- const o = [...e.metadata.settingsSections].sort((i, a) => (i.order ?? 0) - (a.order ?? 0) || i.extensionId.localeCompare(a.extensionId) || i.id.localeCompare(a.id));
2144
- for (const i of o)
2145
- t.push(e.workbench.settings.registerSection({
2146
- id: i.id,
2147
- title: p(i.title, i.id),
2148
- order: i.order,
2149
- scope: i.scope
2150
- }));
2151
- const r = Object.fromEntries((e.metadata.settingsDefinitions ?? []).map((i) => [i.key, {
2152
- type: i.type,
2153
- scope: po(i.scope),
2154
- default: bo(i.default),
2155
- enum: i.enum,
2156
- description: p(i.description)
2157
- }]));
2158
- Object.keys(r).length > 0 && t.push(e.workbench.preferences.registerSchema({
2159
- properties: r
2160
- }));
2161
- const s = [...e.metadata.settingsPanels].sort((i, a) => i.extensionId.localeCompare(a.extensionId) || i.id.localeCompare(a.id));
2162
- for (const [i, a] of s.entries())
2163
- t.push(e.workbench.settings.registerPanel({
2164
- id: a.id,
2165
- title: p(a.title, a.id),
2166
- icon: a.icon,
2167
- kind: "view",
2168
- order: mo + i,
2169
- section: a.section ?? n,
2170
- scope: a.scope,
2171
- viewId: a.viewId
2172
- }));
2173
- return t;
2174
- }, X = (e) => !!(e && typeof e == "object" && !Array.isArray(e)), ko = (e, t, n) => ie(e) ? S(e, {
2175
- extensionId: t,
2176
- projectId: n
2177
- }) : void 0, xo = (e, t, n) => {
2178
- if (!X(e)) return {};
2179
- const o = X(e.indicator) ? {
2180
- icon: String(e.indicator.icon ?? ""),
2181
- color: typeof e.indicator.color == "string" ? e.indicator.color : void 0,
2182
- label: p(e.indicator.label)
2183
- } : void 0, r = Array.isArray(e.menu) ? e.menu.flatMap((s) => !X(s) || typeof s.id != "string" || !Array.isArray(s.rows) ? [] : [{
2184
- id: s.id,
2185
- rows: s.rows.flatMap((i) => {
2186
- if (!X(i) || typeof i.id != "string") return [];
2187
- const a = ko(i.action, t, n);
2188
- return [{
2189
- id: i.id,
2190
- label: p(i.label, i.id),
2191
- icon: typeof i.icon == "string" ? i.icon : void 0,
2192
- iconColor: typeof i.iconColor == "string" ? i.iconColor : void 0,
2193
- selected: i.selected === !0,
2194
- disabled: i.disabled === !0,
2195
- action: a ? {
2196
- kind: "navigation",
2197
- target: a
2198
- } : void 0
2199
- }];
2200
- })
2201
- }]) : void 0;
2202
- return {
2203
- label: p(e.label),
2204
- icon: typeof e.icon == "string" ? e.icon : void 0,
2205
- indicator: o?.icon ? o : void 0,
2206
- menu: r
2207
- };
2208
- }, Ro = (e, t) => {
2209
- const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = new Set(t.refreshEventIds ?? []), i = (a) => {
2210
- if (o.has(a.instanceId)) return;
2211
- o.add(a.instanceId);
2212
- const d = a.resource ? {
2213
- type: a.resource.type,
2214
- id: a.resource.id ?? M(a.resource),
2215
- label: a.resource.label,
2216
- metadata: a.resource.metadata
2217
- } : void 0;
2218
- Promise.resolve(v(e, t.queryHandlerId, {
2219
- resource: d,
2220
- params: {
2221
- renderer: {
2222
- rendererId: t.placementId,
2223
- projectId: e.projectId,
2224
- ...d ? {
2225
- resource: d
2226
- } : {},
2227
- invocation: {
2228
- placement: "visible"
2229
- }
2230
- }
2231
- }
2232
- })).then((m) => {
2233
- n.set(a.instanceId, xo(m, t.extensionId, e.projectId));
2234
- for (const c of r) c();
2235
- }).finally(() => o.delete(a.instanceId));
2236
- };
2237
- return {
2238
- refreshEvents: t.refreshEventIds,
2239
- getSnapshot(a) {
2240
- return i(a), n.get(a.instanceId) ?? {};
2241
- },
2242
- subscribe(a) {
2243
- r.add(a);
2244
- const d = e.subscribeRefreshEvents?.((c) => {
2245
- s.has(c.id) && (n.clear(), a());
2246
- });
2247
- return {
2248
- dispose() {
2249
- r.delete(a), d?.dispose();
2250
- }
2251
- };
2252
- }
2253
- };
2254
- }, xe = (e) => {
2255
- for (let t = e.length - 1; t >= 0; t -= 1) e[t]?.dispose();
2256
- }, de = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, ce = (e, t, n, o, r) => e.prepareCommandArgs?.(t, n, o, r) ?? n, Eo = (e, t) => t.commands.map((n) => e.workbench.commands.registerCommand({
2257
- id: n.id,
2258
- label: p(n.title, n.id),
2259
- description: p(n.description),
2260
- params: n.params
1416
+ let t = /* @__PURE__ */ new Map();
1417
+ for (let n of e) {
1418
+ let e = J(n.owner), r = `${n.extensionId}:${e.kind}:${e.id}:${n.slot}`;
1419
+ t.set(r, [...t.get(r) ?? [], n]);
1420
+ }
1421
+ return [...t.values()];
1422
+ }, Qt = (e) => [...new Set(e.flatMap((e) => e.group ? [`${e.extensionId}:${e.group}`] : []))], $t = (e) => Zt(e.metadata.navigationItems).map((t) => {
1423
+ let n = t[0];
1424
+ return e.workbench.navigationTrees.registerContribution({
1425
+ id: `${n.extensionId}.navigation-items.${n.owner.kind}.${H(n.owner)}.${n.slot}`,
1426
+ owner: J(n.owner),
1427
+ sourceExtensionId: n.extensionId,
1428
+ declarationIndex: e.metadata.navigationItems.indexOf(n),
1429
+ slot: n.slot,
1430
+ defaultExpandedSectionIds: Qt(t),
1431
+ getSections: () => Xt(e.workbench, t, e.createWhenExpression)
1432
+ });
1433
+ }), en = (e) => e.metadata.navigationTrees.map((t, n) => {
1434
+ let r = H(t.view);
1435
+ return e.workbench.navigationTrees.registerContribution({
1436
+ id: t.id,
1437
+ idScope: t.id,
1438
+ owner: J(t.owner),
1439
+ sourceExtensionId: t.extensionId,
1440
+ declarationIndex: e.metadata.navigationItems.length + n,
1441
+ slot: t.slot,
1442
+ viewId: r
1443
+ });
1444
+ }), tn = (e) => [...$t(e), ...en(e)], nn = () => {
1445
+ if (typeof navigator > "u") return;
1446
+ let e = `${navigator.platform} ${navigator.userAgent}`.toLowerCase();
1447
+ if (e.includes("mac")) return "mac";
1448
+ if (e.includes("win")) return "win";
1449
+ if (e.includes("linux")) return "linux";
1450
+ }, rn = (e, t = nn()) => (t ? e.platformOverrides?.[t] : void 0) ?? e.key, an = (e) => e.bindings.map((t) => e.workbench.keybindings.registerKeybinding({
1451
+ action: N(t.action, { commandIdOf: (e) => e.extensionId ? U({
1452
+ extensionId: e.extensionId,
1453
+ id: e.id
1454
+ }) : void 0 }),
1455
+ keybinding: rn(t),
1456
+ when: e.createWhenExpression?.(t.when)
1457
+ })), on = (e, t) => ({
1458
+ ...e,
1459
+ tab: e.tab && t.createTab ? t.createTab({
1460
+ ...e.tab,
1461
+ extensionId: t.extensionId,
1462
+ placementId: t.placementId
1463
+ }) : void 0
1464
+ }), sn = (e, t) => e.kind === "panels" ? e : {
1465
+ ...e,
1466
+ tab: e.tab && t.createTab ? t.createTab({
1467
+ ...e.tab,
1468
+ extensionId: t.extensionId,
1469
+ placementId: t.placementId
1470
+ }) : void 0
1471
+ }, cn = (e, t) => e.pages.map((e) => ({
1472
+ id: e.id,
1473
+ ref: {
1474
+ extensionId: e.extensionId,
1475
+ kind: "page",
1476
+ id: e.localId
1477
+ },
1478
+ title: e.title,
1479
+ path: e.path,
1480
+ modeId: H(e.mode),
1481
+ resource: e.resource,
1482
+ main: sn(e.main, {
1483
+ extensionId: e.extensionId,
1484
+ placementId: `${e.id}.$main`,
1485
+ createTab: t
1486
+ }),
1487
+ slots: e.slots.map((n) => on(n, {
1488
+ extensionId: e.extensionId,
1489
+ placementId: `${e.id}.${n.id}`,
1490
+ createTab: t
1491
+ })),
1492
+ ...e.icon ? { icon: e.icon } : {},
1493
+ ...e.parent ? { parentId: H(e.parent) } : {}
1494
+ })), Y = (e, t) => {
1495
+ let n = e.pages.flatMap((e) => [...e.main.kind === "view" && e.resource ? [{
1496
+ ...e.resource,
1497
+ view: e.main.view
1498
+ }] : [], ...e.slots.flatMap((e) => e.item.kind === "binding" ? [e.item.binding] : [])]);
1499
+ return n.push(...e.placements.flatMap((e) => e.item.kind === "binding" ? [e.item.binding] : [])), n.find((e) => H(e.view) === t)?.kinds[0]?.id;
1500
+ }, ln = (e) => e.body.kind === "webview" ? { webview: e.body.webview } : { renderer: {
1501
+ kind: e.body.kind,
1502
+ id: e.id
1503
+ } }, un = (e, t) => e.viewMenus.flatMap((n) => {
1504
+ if (H(n.owner) !== t.id) return [];
1505
+ let r = e.views.find((e) => e.id === H(n.view));
1506
+ return r ? [{
1507
+ id: n.id,
1508
+ extensionId: n.extensionId,
1509
+ ownerPanelId: t.id,
1510
+ viewId: r.id,
1511
+ title: r.title,
1512
+ side: n.side,
1513
+ group: n.group,
1514
+ placement: n.placement,
1515
+ hostTreeHeader: n.hostTreeHeader,
1516
+ hostTreeFooter: n.hostTreeFooter,
1517
+ ...ln(r)
1518
+ }] : [];
1519
+ }), dn = (e) => e.views.map((t) => {
1520
+ let n = un(e, t);
1521
+ return {
1522
+ id: t.id,
1523
+ extensionId: t.extensionId,
1524
+ title: t.title,
1525
+ icon: t.icon,
1526
+ panelMenus: n.length > 0 ? n : void 0,
1527
+ ...ln(t)
1528
+ };
1529
+ }), X = (e) => e?.map(({ command: e, ...t }) => ({
1530
+ ...t,
1531
+ commandId: U(e)
1532
+ })), fn = (e) => e.views.flatMap((t) => {
1533
+ let n = t.body;
1534
+ return n.kind === "kanban" ? [{
1535
+ ...n,
1536
+ id: t.id,
1537
+ extensionId: t.extensionId,
1538
+ title: t.title,
1539
+ icon: t.icon,
1540
+ resourceKind: Y(e, t.id),
1541
+ createRow: n.createRow ? {
1542
+ title: n.createRow.title,
1543
+ submitLabel: n.createRow.submitLabel,
1544
+ columnParam: n.createRow.columnParam,
1545
+ params: n.createRow.params,
1546
+ attributesParam: n.createRow.attributesParam,
1547
+ labels: n.createRow.labels,
1548
+ commandId: U(n.createRow.command),
1549
+ attachments: n.createRow.attachments ? {
1550
+ resourceParam: n.createRow.attachments.resourceParam,
1551
+ fileParam: n.createRow.attachments.fileParam,
1552
+ commandId: U(n.createRow.attachments.command)
1553
+ } : void 0
1554
+ } : void 0,
1555
+ rowActions: X(n.rowActions)
1556
+ }] : [];
1557
+ }), pn = (e) => e.views.flatMap((t) => {
1558
+ let n = t.body;
1559
+ return n.kind === "dataTable" ? [{
1560
+ ...n,
1561
+ id: t.id,
1562
+ extensionId: t.extensionId,
1563
+ title: t.title,
1564
+ icon: t.icon,
1565
+ resourceKind: Y(e, t.id),
1566
+ selectionActions: X(n.selectionActions),
1567
+ rowActions: X(n.rowActions)
1568
+ }] : [];
1569
+ }), mn = (e) => e.views.flatMap((t) => t.body.kind === "tree" ? [{
1570
+ ...t.body,
1571
+ id: t.id,
1572
+ extensionId: t.extensionId,
1573
+ title: t.title,
1574
+ icon: t.icon,
1575
+ resourceKind: Y(e, t.id)
1576
+ }] : []), hn = (e) => e.views.flatMap((t) => t.body.kind === "file" ? [{
1577
+ ...t.body,
1578
+ id: t.id,
1579
+ extensionId: t.extensionId,
1580
+ title: t.title,
1581
+ icon: t.icon,
1582
+ resourceKind: Y(e, t.id)
1583
+ }] : []), gn = (e) => e.views.flatMap((t) => t.body.kind === "controls" ? [{
1584
+ ...t.body,
1585
+ id: t.id,
1586
+ extensionId: t.extensionId,
1587
+ title: t.title,
1588
+ icon: t.icon,
1589
+ resourceKind: Y(e, t.id)
1590
+ }] : []), _n = (e) => e.modes.map((e) => ({
1591
+ id: e.id,
1592
+ extensionId: e.extensionId,
1593
+ modeId: e.id,
1594
+ label: e.label,
1595
+ icon: e.icon,
1596
+ panelRegions: e.regions,
1597
+ regionSettings: e.regionSettings,
1598
+ floatingPanels: e.floatingPanels,
1599
+ ...e.defaultTheme ? { defaultTheme: H(e.defaultTheme) } : {},
1600
+ ...e.chrome ? { chrome: Object.fromEntries(Object.entries(e.chrome).map(([e, t]) => [e, t !== !1 && H(t)])) } : {}
1601
+ })), vn = (e, t = {}) => {
1602
+ let n = dn(e);
1603
+ return {
1604
+ extensions: e.extensions,
1605
+ commands: e.commands,
1606
+ menuContributions: e.menuContributions,
1607
+ commandPaletteContributions: e.commandPaletteContributions,
1608
+ modes: _n(e),
1609
+ pages: cn(e, t.createTab),
1610
+ placements: e.placements.map((e) => ({
1611
+ id: e.id,
1612
+ ref: {
1613
+ extensionId: e.extensionId,
1614
+ kind: "placement",
1615
+ id: e.localId
1616
+ },
1617
+ modeId: H(e.mode),
1618
+ item: e.item,
1619
+ region: e.region,
1620
+ order: e.order,
1621
+ movableTo: e.movableTo,
1622
+ mountStrategy: e.mountStrategy,
1623
+ hiddenByDefault: e.hiddenByDefault,
1624
+ headerBorderBottom: e.headerBorderBottom,
1625
+ tab: e.tab && t.createTab ? t.createTab({
1626
+ ...e.tab,
1627
+ extensionId: e.extensionId,
1628
+ placementId: e.id
1629
+ }) : void 0
1630
+ })),
1631
+ panels: n,
1632
+ resourceKinds: e.resourceKinds.map((e) => ({
1633
+ id: e.id,
1634
+ extensionId: e.extensionId,
1635
+ label: e.label,
1636
+ icon: e.icon,
1637
+ menuSlots: Object.fromEntries((e.menuSlots ?? []).map((e) => [e.id, {
1638
+ placement: e.placement,
1639
+ label: e.label,
1640
+ external: e.access === "public",
1641
+ order: e.order
1642
+ }]))
1643
+ })),
1644
+ resourceHierarchyProviders: (e.resourceHierarchyProviders ?? []).map((e) => ({
1645
+ id: e.id,
1646
+ extensionId: e.extensionId,
1647
+ resourceKind: e.resourceKind.id
1648
+ })),
1649
+ settingsSections: e.settingsSections ?? [],
1650
+ settingsPanels: e.settingsPanels.flatMap((t) => {
1651
+ let n = e.views.find((e) => e.id === H(t.view));
1652
+ return n ? [{
1653
+ id: t.id,
1654
+ viewId: n.id,
1655
+ extensionId: t.extensionId,
1656
+ slotId: t.slot.id,
1657
+ scope: t.slot.id.includes("global") ? "global" : "project",
1658
+ title: n.title,
1659
+ icon: n.icon,
1660
+ section: t.section ? H(t.section) : void 0
1661
+ }] : [];
1662
+ }),
1663
+ kanbanRenderers: fn(e),
1664
+ dataTableRenderers: pn(e),
1665
+ commandPaletteResources: e.commandPaletteResources ?? [],
1666
+ treeRenderers: mn(e),
1667
+ fileRenderers: hn(e),
1668
+ controlsRenderers: gn(e),
1669
+ keybindings: e.keybindings ?? [],
1670
+ settingsDefinitions: e.settingsDefinitions ?? [],
1671
+ statuses: e.statuses,
1672
+ statusBarItems: e.statusBarItems.map((e) => ({
1673
+ id: e.id,
1674
+ extensionId: e.extensionId,
1675
+ viewId: H(e.view),
1676
+ slot: e.slot.id.endsWith("leading") ? "leading" : "trailing",
1677
+ order: e.order,
1678
+ when: Nt(e.when)
1679
+ })),
1680
+ diagnostics: e.diagnostics
1681
+ };
1682
+ }, yn = (e, t, n = {}) => {
1683
+ e.views.refreshView(t.id, t.kind === "file" ? n : void 0);
1684
+ }, bn = (e) => {
1685
+ let t = /* @__PURE__ */ new Map(), n = (e, n) => {
1686
+ for (let r of new Set(n.refreshEventIds ?? [])) {
1687
+ let i = t.get(r) ?? [];
1688
+ i.some((t) => t.kind === e && t.id === n.id) || i.push({
1689
+ id: n.id,
1690
+ kind: e
1691
+ }), t.set(r, i);
1692
+ }
1693
+ };
1694
+ for (let t of e.views) t.body.kind !== "webview" && n(t.body.kind, {
1695
+ id: t.id,
1696
+ refreshEventIds: t.body.refreshEventIds
1697
+ });
1698
+ return t;
1699
+ }, xn = (e) => {
1700
+ let t = bn(e.metadata);
1701
+ return e.subscribe((n) => {
1702
+ let { id: r, ...i } = n;
1703
+ for (let n of t.get(r) ?? []) yn(e.workbench, n, i);
1704
+ });
1705
+ }, Sn = (e, t) => {
1706
+ for (let n of t.views) n.body.kind === "webview" && e.views.getView(n.id) && e.views.refreshView(n.id);
1707
+ }, Cn = (e) => (t) => ({
1708
+ ...be({
1709
+ workbench: t.workbench,
1710
+ placement: t.placement,
1711
+ hostEvents: t.hostEvents
1712
+ }),
1713
+ "navigation.open": (n) => {
1714
+ let r = n;
1715
+ if (!r.target) throw Error("navigation.open requires a target.");
1716
+ return t.workbench.navigation.openTarget(N(r.target, {
1717
+ extensionId: e.extensionIdForWebview(t.webviewId),
1718
+ projectId: e.projectId
1719
+ }));
1720
+ },
1721
+ "commands.execute": async (n) => {
1722
+ let r = n, i = r.resource ?? t.placement.resource;
1723
+ return L({
1724
+ ...e,
1725
+ workbench: t.workbench
1726
+ }, r.commandId, {
1727
+ ...r.params ? { params: r.params } : {},
1728
+ ...r.workspaceId ? { workspaceId: r.workspaceId } : {},
1729
+ ...r.metadata ? { metadata: r.metadata } : {},
1730
+ ...i ? { resource: i } : {},
1731
+ slot: I({
1732
+ id: t.webviewId,
1733
+ kind: e.slotKind,
1734
+ projectId: e.projectId,
1735
+ context: { panelId: t.webviewId }
1736
+ })
1737
+ });
1738
+ },
1739
+ ...e.files ? {
1740
+ "files.upload": e.files.upload,
1741
+ "files.list": e.files.list,
1742
+ "files.delete": e.files.delete
1743
+ } : {},
1744
+ ...e.artifacts ? { "artifacts.read": (n) => e.artifacts.read(n, { webviewId: t.webviewId }) } : {}
1745
+ }), wn = (e) => ({
1746
+ title: M(e.title) || void 0,
1747
+ runtimeUrl: e.runtimeUrl,
1748
+ moduleUrl: e.moduleUrl,
1749
+ styles: e.styles,
1750
+ capabilities: e.capabilities
1751
+ }), Tn = "extensions", En = 1e3, Dn = 25, On = (e) => e === void 0 ? void 0 : e, kn = (e) => e === "global" ? "user" : "project", An = (e, t) => t ? (n) => ({
1752
+ ...e(n),
1753
+ ...t(n)
1754
+ }) : e, jn = (e, t) => An(e.createWebviewHostCapabilities ?? Cn({
1755
+ artifacts: e.webviewArtifacts,
1756
+ executeCommand: e.executeCommand,
1757
+ extensionIdForWebview: (t) => e.metadata.panels.find((e) => e.id === t)?.extensionId,
1758
+ files: e.webviewFiles,
1759
+ projectId: e.projectId,
1760
+ slotKind: t
1761
+ }), e.createWebviewHostCapabilityOverrides), Mn = (e) => e.metadata.panels.flatMap((t) => {
1762
+ if (!t.webview) return [];
1763
+ let n = wn(t.webview);
1764
+ return [e.workbench.views.registerView({
1765
+ id: t.id,
1766
+ title: M(t.title, t.id),
1767
+ icon: t.icon,
1768
+ body: {
1769
+ kind: "react",
1770
+ render: (r) => {
1771
+ let i = e.metadata.settingsPanels.some((e) => e.id === r.instance.panelId && e.viewId === t.id) ? "settings" : "panel";
1772
+ return e.renderWebview?.(r) ?? we({
1773
+ context: {
1774
+ workbench: r.workbench,
1775
+ webviewId: t.id,
1776
+ placement: r.instance,
1777
+ hostEvents: Ce(r.workbench, r.instance)
1778
+ },
1779
+ createHostCapabilities: jn(e, i),
1780
+ createProps: e.createWebviewProps ?? (({ placement: e }) => ({
1781
+ placement: e,
1782
+ resource: e.resource
1783
+ })),
1784
+ createTheme: e.createWebviewTheme,
1785
+ ownerId: t.extensionId,
1786
+ title: M(t.title, t.id),
1787
+ webview: n
1788
+ });
1789
+ }
1790
+ }
1791
+ })];
1792
+ }), Nn = {
1793
+ first: 1e6,
1794
+ default: 0,
1795
+ last: -1e6
1796
+ }, Pn = (e) => e.metadata.panels.flatMap((e) => e.panelMenus ?? []).map((t, n) => e.workbench.viewMenus.registerViewMenu({
1797
+ id: t.id,
1798
+ ownerViewId: t.ownerPanelId,
1799
+ viewId: t.viewId,
1800
+ side: t.side,
1801
+ priority: Nn[t.placement ?? "default"] - n
1802
+ })), Fn = (e) => {
1803
+ if (!e || typeof e != "object" || !("statuses" in e) || !Array.isArray(e.statuses)) throw Error("Status provider returned an invalid response");
1804
+ return e.statuses;
1805
+ }, In = (e, t) => {
1806
+ let r = e.metadata.statuses ?? [];
1807
+ if (r.length === 0) return [];
1808
+ let i = "workbench.extension-statuses.settings", a = r.map((n, r) => e.workbench.statuses.registerStatusSet({
1809
+ id: n.id,
1810
+ title: M(n.title, n.id),
1811
+ actions: n.actions?.map((e) => ({
1812
+ id: e.id,
1813
+ label: M(e.label, e.id),
1814
+ icon: e.icon
1815
+ })),
1816
+ query: async () => Fn(await R(t, n.queryHandlerId, { params: {} })),
1817
+ save: n.saveHandlerId ? async (e) => Fn(await R(t, n.saveHandlerId, { params: { statuses: e } })) : void 0
1818
+ }, {
1819
+ ownerId: n.extensionId,
1820
+ priority: -r
1821
+ }));
1822
+ return a.push(e.workbench.views.registerView({
1823
+ id: i,
1824
+ title: "Statuses",
1825
+ body: {
1826
+ kind: "react",
1827
+ render: () => g(n, { workbench: e.workbench })
1828
+ }
1829
+ })), a.push(e.workbench.settings.registerPanel({
1830
+ id: "workbench.statuses",
1831
+ title: "Statuses",
1832
+ icon: "list-checks",
1833
+ kind: "view",
1834
+ order: Dn,
1835
+ section: e.settingsSectionId ?? Tn,
1836
+ scope: "project",
1837
+ viewId: i
1838
+ })), a;
1839
+ }, Ln = (e) => {
1840
+ let t = [], n = e.settingsSectionId ?? Tn;
1841
+ e.workbench.settings.getSection(n) || t.push(e.workbench.settings.registerSection({
1842
+ id: n,
1843
+ title: e.settingsSectionTitle ?? "Extensions"
1844
+ }));
1845
+ let r = [...e.metadata.settingsSections].sort((e, t) => (e.order ?? 0) - (t.order ?? 0) || e.extensionId.localeCompare(t.extensionId) || e.id.localeCompare(t.id));
1846
+ for (let n of r) t.push(e.workbench.settings.registerSection({
1847
+ id: n.id,
1848
+ title: M(n.title, n.id),
1849
+ order: n.order,
1850
+ scope: n.scope
1851
+ }));
1852
+ let i = Object.fromEntries((e.metadata.settingsDefinitions ?? []).map((e) => [e.key, {
1853
+ type: e.type,
1854
+ scope: kn(e.scope),
1855
+ default: On(e.default),
1856
+ enum: e.enum,
1857
+ description: M(e.description)
1858
+ }]));
1859
+ Object.keys(i).length > 0 && t.push(e.workbench.preferences.registerSchema({ properties: i }));
1860
+ let a = [...e.metadata.settingsPanels].sort((e, t) => e.extensionId.localeCompare(t.extensionId) || e.id.localeCompare(t.id));
1861
+ for (let [r, i] of a.entries()) t.push(e.workbench.settings.registerPanel({
1862
+ id: i.id,
1863
+ title: M(i.title, i.id),
1864
+ icon: i.icon,
1865
+ kind: "view",
1866
+ order: En + r,
1867
+ section: i.section ?? n,
1868
+ scope: i.scope,
1869
+ viewId: i.viewId
1870
+ }));
1871
+ return t;
1872
+ }, Z = (e) => !(!e || typeof e != "object" || Array.isArray(e)), Rn = (e, t, n) => u(e) ? N(e, {
1873
+ extensionId: t,
1874
+ projectId: n
1875
+ }) : void 0, zn = (e, t, n) => {
1876
+ if (!Z(e)) return {};
1877
+ let r = Z(e.indicator) ? {
1878
+ icon: String(e.indicator.icon ?? ""),
1879
+ color: typeof e.indicator.color == "string" ? e.indicator.color : void 0,
1880
+ label: M(e.indicator.label)
1881
+ } : void 0, i = Array.isArray(e.menu) ? e.menu.flatMap((e) => !Z(e) || typeof e.id != "string" || !Array.isArray(e.rows) ? [] : [{
1882
+ id: e.id,
1883
+ rows: e.rows.flatMap((e) => {
1884
+ if (!Z(e) || typeof e.id != "string") return [];
1885
+ let r = Rn(e.action, t, n);
1886
+ return [{
1887
+ id: e.id,
1888
+ label: M(e.label, e.id),
1889
+ icon: typeof e.icon == "string" ? e.icon : void 0,
1890
+ iconColor: typeof e.iconColor == "string" ? e.iconColor : void 0,
1891
+ selected: e.selected === !0,
1892
+ disabled: e.disabled === !0,
1893
+ action: r ? {
1894
+ kind: "navigation",
1895
+ target: r
1896
+ } : void 0
1897
+ }];
1898
+ })
1899
+ }]) : void 0;
1900
+ return {
1901
+ label: M(e.label),
1902
+ icon: typeof e.icon == "string" ? e.icon : void 0,
1903
+ indicator: r?.icon ? r : void 0,
1904
+ menu: i
1905
+ };
1906
+ }, Bn = (e, t) => {
1907
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = new Set(t.refreshEventIds ?? []), o = (a) => {
1908
+ if (r.has(a.instanceId)) return;
1909
+ r.add(a.instanceId);
1910
+ let o = a.resource ? {
1911
+ type: a.resource.type,
1912
+ id: a.resource.id ?? p(a.resource),
1913
+ label: a.resource.label,
1914
+ metadata: a.resource.metadata
1915
+ } : void 0;
1916
+ Promise.resolve(R(e, t.queryHandlerId, {
1917
+ resource: o,
1918
+ params: { renderer: {
1919
+ rendererId: t.placementId,
1920
+ projectId: e.projectId,
1921
+ ...o ? { resource: o } : {},
1922
+ invocation: { placement: "visible" }
1923
+ } }
1924
+ })).then((r) => {
1925
+ n.set(a.instanceId, zn(r, t.extensionId, e.projectId));
1926
+ for (let e of i) e();
1927
+ }).finally(() => r.delete(a.instanceId));
1928
+ };
1929
+ return {
1930
+ refreshEvents: t.refreshEventIds,
1931
+ getSnapshot(e) {
1932
+ return o(e), n.get(e.instanceId) ?? {};
1933
+ },
1934
+ subscribe(t) {
1935
+ i.add(t);
1936
+ let r = e.subscribeRefreshEvents?.((e) => {
1937
+ a.has(e.id) && (n.clear(), t());
1938
+ });
1939
+ return { dispose() {
1940
+ i.delete(t), r?.dispose();
1941
+ } };
1942
+ }
1943
+ };
1944
+ }, Vn = (e) => {
1945
+ for (let t = e.length - 1; t >= 0; --t) e[t]?.dispose();
1946
+ }, Q = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, $ = (e, t, n, r, i) => e.prepareCommandArgs?.(t, n, r, i) ?? n, Hn = (e, t) => t.commands.map((t) => e.workbench.commands.registerCommand({
1947
+ id: t.id,
1948
+ label: M(t.title, t.id),
1949
+ description: M(t.description),
1950
+ params: t.params
2261
1951
  }, {
2262
- prepareArgs: (o, r, s) => ce(e, n.id, o, r, s),
2263
- execute: (o, r) => v(e, n.id, {
2264
- params: de(o),
2265
- resource: r?.resource
2266
- })
2267
- })), Le = (e, t) => t?.resource ?? e.workbench.getPrimaryResource(), Ao = (e, t) => {
2268
- if (!e.menuSlotsById) return [];
2269
- const {
2270
- registrations: n
2271
- } = Jt({
2272
- metadata: e.metadata,
2273
- menuSlotsById: e.menuSlotsById,
2274
- menuTargetsById: e.menuTargetsById,
2275
- createWhenExpression: e.createMenuWhenExpression
2276
- }), o = n.map(({
2277
- menuItem: s,
2278
- menuPath: i,
2279
- ...a
2280
- }) => ({
2281
- ...a,
2282
- menuItems: [{
2283
- menuItem: s,
2284
- menuPath: i
2285
- }]
2286
- }));
2287
- return (e.menuRegistrations ?? o).flatMap((s) => [e.workbench.commands.registerCommand(s.command, {
2288
- prepareArgs: (i, a, d) => ce(t, s.targetCommandId, i, a, d),
2289
- execute: (i, a) => v(t, s.targetCommandId, {
2290
- params: {
2291
- ...s.contribution.params ?? {},
2292
- ...de(i) ?? {}
2293
- },
2294
- resource: Le(e, a),
2295
- slot: B({
2296
- id: s.contribution.slotId,
2297
- kind: "menu",
2298
- projectId: e.projectId,
2299
- context: {
2300
- panelId: s.contribution.id
2301
- }
2302
- })
2303
- })
2304
- }), ...s.menuItems.map(({
2305
- menuPath: i,
2306
- menuItem: a
2307
- }) => e.workbench.layout.registerMenuItem(i, a))]);
2308
- }, Co = (e, t) => Zt({
2309
- metadata: e.metadata
2310
- }).flatMap((o) => [e.workbench.commands.registerCommand(o.command, {
2311
- prepareArgs: (r, s, i) => ce(t, o.targetCommandId, r, s, i),
2312
- execute: (r, s) => v(t, o.targetCommandId, {
2313
- params: {
2314
- ...o.contribution.params ?? {},
2315
- ...de(r) ?? {}
2316
- },
2317
- resource: Le(e, s),
2318
- slot: B({
2319
- id: "workbench.commandPalette",
2320
- kind: "menu",
2321
- projectId: e.projectId,
2322
- context: {
2323
- panelId: o.contribution.id
2324
- }
2325
- })
2326
- }),
2327
- isVisible: () => et(o.contribution.when, e.workbench.getPrimaryResource()?.type)
2328
- }), e.workbench.layout.registerMenuItem(st, o.menuItem)]), So = (e, t) => {
2329
- const n = t?.mode;
2330
- if (!n) return !0;
2331
- const o = e.workbench.modes.getActiveModeId() ?? "";
2332
- return Array.isArray(n) ? n.includes(o) : n === o;
2333
- }, To = (e) => (e.metadata.statusBarItems ?? []).map((t) => e.workbench.statusBar.registerItem({
2334
- id: t.id,
2335
- viewId: t.viewId,
2336
- slot: t.slot,
2337
- order: t.order,
2338
- isVisible: () => So(e, t.when)
2339
- })), Po = (e) => e.metadata.pages.map((t) => e.workbench.pages.registerPage(t)), jo = (e) => e.metadata.resourceKinds.map((t) => e.workbench.resources.registerKind({
2340
- kind: t.id,
2341
- label: p(t.label, t.id),
2342
- icon: t.icon ?? "FileText"
2343
- })), $o = (e) => e.metadata.modes.map((t) => e.workbench.modes.registerMode({
2344
- id: t.modeId,
2345
- label: p(t.label, t.modeId),
2346
- panels: t.panelRegions,
2347
- regionSettings: t.regionSettings,
2348
- floatingPanels: t.floatingPanels,
2349
- defaultTheme: t.defaultTheme,
2350
- chrome: t.chrome,
2351
- activate: () => {
2352
- }
2353
- })), Ho = (e) => e.metadata.placements.map((t) => e.workbench.modePlacements.registerPlacement(t)), qo = (e) => {
2354
- const t = {
2355
- ...e,
2356
- metadata: so(e.metadata, {
2357
- createTab: (r) => Ro(e, r)
2358
- })
2359
- }, n = [], o = t;
2360
- try {
2361
- return n.push(...Eo(o, t.metadata)), n.push(...qn({
2362
- bindings: t.metadata.keybindings,
2363
- createWhenExpression: t.createKeybindingWhenExpression,
2364
- workbench: t.workbench
2365
- })), n.push(...Ao(t, o)), n.push(...Co(t, o)), n.push(Mn({
2366
- ...t,
2367
- resolveNodeResource: t.resolveTreeNodeResource
2368
- })), n.push(nn(t)), n.push(Kt(o, t.metadata.controlsRenderers ?? [])), n.push(...wo(t)), n.push(...yo(t)), n.push(...vo(t, o)), n.push(An(o, t.metadata.kanbanRenderers ?? [], t.kanbanAdapter)), n.push(qt(o, t.metadata.dataTableRenderers ?? [])), n.push(...Io(t)), n.push(Nt(o, t.metadata.commandPaletteResources ?? [])), n.push(...Ln({
2369
- createWhenExpression: e.createNavigationWhenExpression,
2370
- metadata: e.metadata,
2371
- workbench: e.workbench
2372
- })), e.subscribeRefreshEvents && n.push(ao({
2373
- metadata: e.metadata,
2374
- subscribe: e.subscribeRefreshEvents,
2375
- workbench: e.workbench
2376
- })), n.push(...To(t)), n.push(...jo(t)), n.push(...Po(t)), n.push(...$o(t)), n.push(...Ho(t)), {
2377
- dispose() {
2378
- xe(n);
2379
- }
2380
- };
2381
- } catch (r) {
2382
- throw xe(n), r;
2383
- }
1952
+ prepareArgs: (n, r, i) => $(e, t.id, n, r, i),
1953
+ execute: (n, r) => R(e, t.id, {
1954
+ params: Q(n),
1955
+ resource: r?.resource
1956
+ })
1957
+ })), Un = (e, t) => t?.resource ?? e.workbench.getPrimaryResource(), Wn = (e, t) => {
1958
+ if (!e.menuSlotsById) return [];
1959
+ let { registrations: n } = Xe({
1960
+ metadata: e.metadata,
1961
+ menuSlotsById: e.menuSlotsById,
1962
+ menuTargetsById: e.menuTargetsById,
1963
+ createWhenExpression: e.createMenuWhenExpression
1964
+ }), r = n.map(({ menuItem: e, menuPath: t, ...n }) => ({
1965
+ ...n,
1966
+ menuItems: [{
1967
+ menuItem: e,
1968
+ menuPath: t
1969
+ }]
1970
+ }));
1971
+ return (e.menuRegistrations ?? r).flatMap((n) => [e.workbench.commands.registerCommand(n.command, {
1972
+ prepareArgs: (e, r, i) => $(t, n.targetCommandId, e, r, i),
1973
+ execute: (r, i) => R(t, n.targetCommandId, {
1974
+ params: {
1975
+ ...n.contribution.params ?? {},
1976
+ ...Q(r) ?? {}
1977
+ },
1978
+ resource: Un(e, i),
1979
+ slot: I({
1980
+ id: n.contribution.slotId,
1981
+ kind: "menu",
1982
+ projectId: e.projectId,
1983
+ context: { panelId: n.contribution.id }
1984
+ })
1985
+ })
1986
+ }), ...n.menuItems.map(({ menuPath: t, menuItem: n }) => e.workbench.layout.registerMenuItem(t, n))]);
1987
+ }, Gn = (t, n) => Ze({ metadata: t.metadata }).flatMap((r) => [t.workbench.commands.registerCommand(r.command, {
1988
+ prepareArgs: (e, t, i) => $(n, r.targetCommandId, e, t, i),
1989
+ execute: (e, i) => R(n, r.targetCommandId, {
1990
+ params: {
1991
+ ...r.contribution.params ?? {},
1992
+ ...Q(e) ?? {}
1993
+ },
1994
+ resource: Un(t, i),
1995
+ slot: I({
1996
+ id: "workbench.commandPalette",
1997
+ kind: "menu",
1998
+ projectId: t.projectId,
1999
+ context: { panelId: r.contribution.id }
2000
+ })
2001
+ }),
2002
+ isVisible: () => d(r.contribution.when, t.workbench.getPrimaryResource()?.type)
2003
+ }), t.workbench.layout.registerMenuItem(e, r.menuItem)]), Kn = (e, t) => {
2004
+ let n = t?.mode;
2005
+ if (!n) return !0;
2006
+ let r = e.workbench.modes.getActiveModeId() ?? "";
2007
+ return Array.isArray(n) ? n.includes(r) : n === r;
2008
+ }, qn = (e) => (e.metadata.statusBarItems ?? []).map((t) => e.workbench.statusBar.registerItem({
2009
+ id: t.id,
2010
+ viewId: t.viewId,
2011
+ slot: t.slot,
2012
+ order: t.order,
2013
+ isVisible: () => Kn(e, t.when)
2014
+ })), Jn = (e) => e.metadata.pages.map((t) => e.workbench.pages.registerPage(t)), Yn = (e) => e.metadata.resourceKinds.map((t) => e.workbench.resources.registerKind({
2015
+ kind: t.id,
2016
+ label: M(t.label, t.id),
2017
+ icon: t.icon ?? "FileText"
2018
+ })), Xn = (e) => e.metadata.modes.map((t) => e.workbench.modes.registerMode({
2019
+ id: t.modeId,
2020
+ label: M(t.label, t.modeId),
2021
+ panels: t.panelRegions,
2022
+ regionSettings: t.regionSettings,
2023
+ floatingPanels: t.floatingPanels,
2024
+ defaultTheme: t.defaultTheme,
2025
+ chrome: t.chrome,
2026
+ activate: () => void 0
2027
+ })), Zn = (e) => e.metadata.placements.map((t) => e.workbench.modePlacements.registerPlacement(t)), Qn = (e) => {
2028
+ let t = {
2029
+ ...e,
2030
+ metadata: vn(e.metadata, { createTab: (t) => Bn(e, t) })
2031
+ }, n = [], r = t;
2032
+ try {
2033
+ return n.push(...Hn(r, t.metadata)), n.push(...an({
2034
+ bindings: t.metadata.keybindings,
2035
+ createWhenExpression: t.createKeybindingWhenExpression,
2036
+ workbench: t.workbench
2037
+ })), n.push(...Wn(t, r)), n.push(...Gn(t, r)), n.push(qt({
2038
+ ...t,
2039
+ resolveNodeResource: t.resolveTreeNodeResource
2040
+ })), n.push(rt(t)), n.push(Ie(r, t.metadata.controlsRenderers ?? [])), n.push(...Mn(t)), n.push(...Ln(t)), n.push(...In(t, r)), n.push(Mt(r, t.metadata.kanbanRenderers ?? [], t.kanbanAdapter)), n.push(Ve(r, t.metadata.dataTableRenderers ?? [])), n.push(...Pn(t)), n.push(Pe(r, t.metadata.commandPaletteResources ?? [])), n.push(...tn({
2041
+ createWhenExpression: e.createNavigationWhenExpression,
2042
+ metadata: e.metadata,
2043
+ workbench: e.workbench
2044
+ })), e.subscribeRefreshEvents && n.push(xn({
2045
+ metadata: e.metadata,
2046
+ subscribe: e.subscribeRefreshEvents,
2047
+ workbench: e.workbench
2048
+ })), n.push(...qn(t)), n.push(...Yn(t)), n.push(...Jn(t)), n.push(...Xn(t)), n.push(...Zn(t)), { dispose() {
2049
+ Vn(n);
2050
+ } };
2051
+ } catch (e) {
2052
+ throw Vn(n), e;
2053
+ }
2384
2054
  };
2385
- export {
2386
- Zt as buildWorkbenchExtensionCommandPaletteRegistrations,
2387
- Jt as buildWorkbenchExtensionMenuRegistrations,
2388
- At as createTerminalSessionCapability,
2389
- St as createWorkbenchWebviewHostCapabilities,
2390
- Ko as emptyWorkbenchExtensionMetadata,
2391
- Te as executeWorkbenchExtensionCommandResponse,
2392
- Lo as fileRendererRefreshEnvelopeFromCommand,
2393
- Pt as getBridgeWebviewHostEventPublisher,
2394
- Ae as isExtensionNavigationTarget,
2395
- Uo as refreshOpenWorkbenchExtensionWebviews,
2396
- ro as refreshWorkbenchExtensionRenderer,
2397
- Nt as registerWorkbenchExtensionCommandPaletteResources,
2398
- qo as registerWorkbenchExtensionContributions,
2399
- Kt as registerWorkbenchExtensionControlsRenderers,
2400
- qt as registerWorkbenchExtensionDataTableRenderers,
2401
- nn as registerWorkbenchExtensionFileRenderers,
2402
- An as registerWorkbenchExtensionKanbanRenderers,
2403
- ao as registerWorkbenchExtensionRendererRefreshEvents,
2404
- Mn as registerWorkbenchExtensionTreeRenderers,
2405
- jt as renderBridgeWebviewFrame,
2406
- S as toWorkbenchNavigationTarget,
2407
- Ce as toWorkbenchNavigationTargetResult,
2408
- _o as toWorkbenchWhenExpression
2409
- };
2410
- //# sourceMappingURL=extensions.js.map
2055
+ //#endregion
2056
+ export { Ze as buildWorkbenchExtensionCommandPaletteRegistrations, Xe as buildWorkbenchExtensionMenuRegistrations, ve as createTerminalSessionCapability, be as createWorkbenchWebviewHostCapabilities, Ue as emptyWorkbenchExtensionMetadata, L as executeWorkbenchExtensionCommandResponse, tt as fileRendererRefreshEnvelopeFromCommand, Ce as getBridgeWebviewHostEventPublisher, P as isExtensionNavigationTarget, Sn as refreshOpenWorkbenchExtensionWebviews, yn as refreshWorkbenchExtensionRenderer, Pe as registerWorkbenchExtensionCommandPaletteResources, Qn as registerWorkbenchExtensionContributions, Ie as registerWorkbenchExtensionControlsRenderers, Ve as registerWorkbenchExtensionDataTableRenderers, rt as registerWorkbenchExtensionFileRenderers, Mt as registerWorkbenchExtensionKanbanRenderers, xn as registerWorkbenchExtensionRendererRefreshEvents, qt as registerWorkbenchExtensionTreeRenderers, we as renderBridgeWebviewFrame, N as toWorkbenchNavigationTarget, F as toWorkbenchNavigationTargetResult, Pt as toWorkbenchWhenExpression };
2057
+
2058
+ //# sourceMappingURL=extensions.js.map