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