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