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