@pstdio/workbench 0.1.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.
- package/README.md +343 -0
- package/dist/context-key-service-C--cHa0B.js +447 -0
- package/dist/context-key-service-C--cHa0B.js.map +1 -0
- package/dist/core.d.ts +1885 -0
- package/dist/core.js +64 -0
- package/dist/core.js.map +1 -0
- package/dist/extensions.d.ts +1934 -0
- package/dist/extensions.js +1728 -0
- package/dist/extensions.js.map +1 -0
- package/dist/file-renderer-view-DrrhYnb_.js +171 -0
- package/dist/file-renderer-view-DrrhYnb_.js.map +1 -0
- package/dist/icon-B9XolQG8.js +35 -0
- package/dist/icon-B9XolQG8.js.map +1 -0
- package/dist/index.d.ts +1885 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/react.d.ts +2020 -0
- package/dist/react.js +3905 -0
- package/dist/react.js.map +1 -0
- package/dist/storage.d.ts +128 -0
- package/dist/storage.js +87 -0
- package/dist/storage.js.map +1 -0
- package/dist/surface-reconcile-DkRf01ro.js +260 -0
- package/dist/surface-reconcile-DkRf01ro.js.map +1 -0
- package/dist/testing.d.ts +1620 -0
- package/dist/testing.js +46 -0
- package/dist/testing.js.map +1 -0
- package/dist/webview-runtime.d.ts +10 -0
- package/dist/webview-runtime.js +31 -0
- package/dist/webview-runtime.js.map +1 -0
- package/dist/workbench-core-DFpwi8Lo.js +2264 -0
- package/dist/workbench-core-DFpwi8Lo.js.map +1 -0
- package/dist/workbench-menu-paths-CQVH6z4_.js +11 -0
- package/dist/workbench-menu-paths-CQVH6z4_.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,1728 @@
|
|
|
1
|
+
import { jsxs as oe, jsx as W } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as y, useState as Be, useEffect as A, createElement as fe } from "react";
|
|
3
|
+
import { host as De } from "rimless";
|
|
4
|
+
import { W as be } from "./icon-B9XolQG8.js";
|
|
5
|
+
import { isLocalizedString as $e, matchesResourceWhen as He } from "@pstdio/sdk/extensions";
|
|
6
|
+
import { b as Me } from "./workbench-menu-paths-CQVH6z4_.js";
|
|
7
|
+
const L = 1, Ve = ["commands.execute", "resource.open", "notification.show", "notification.action", "notification.resolve", "notification.dismiss", "preferences.get", "preferences.set", "extension.settings.all", "extension.settings.get", "extension.settings.set", "extension.settings.delete", "terminal.session", "files.upload", "files.list", "files.delete"], he = ["host.dispatchKeyboardEvent"], Oe = [...Ve, ...he], Ne = new Set(Oe), pe = (e) => Ne.has(e), Ue = (e) => {
|
|
8
|
+
const [t, r] = e.split("@"), o = r === void 0 ? L : Number(r);
|
|
9
|
+
return {
|
|
10
|
+
capability: e,
|
|
11
|
+
name: t ?? "",
|
|
12
|
+
version: o
|
|
13
|
+
};
|
|
14
|
+
}, j = (e) => ({
|
|
15
|
+
capability: e,
|
|
16
|
+
code: "unsupported_webview_capability",
|
|
17
|
+
message: `Unsupported webview capability: ${e}`,
|
|
18
|
+
severity: "error"
|
|
19
|
+
}), Fe = (e, t, r) => ({
|
|
20
|
+
capability: e,
|
|
21
|
+
code: "unsupported_webview_capability_version",
|
|
22
|
+
message: `Unsupported webview capability version: ${t}@${r.toString()} (supported: ${L.toString()})`,
|
|
23
|
+
severity: "error"
|
|
24
|
+
}), _e = (e) => ({
|
|
25
|
+
capability: e,
|
|
26
|
+
code: "undeclared_webview_capability",
|
|
27
|
+
message: `Webview did not declare host capability: ${e}`,
|
|
28
|
+
severity: "error"
|
|
29
|
+
}), Le = (e, t = {}) => {
|
|
30
|
+
const r = [], o = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const n of he)
|
|
32
|
+
t[n] && o.add(n);
|
|
33
|
+
for (const n of e ?? []) {
|
|
34
|
+
const s = Ue(n);
|
|
35
|
+
if (!pe(s.name)) {
|
|
36
|
+
r.push(j(n));
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (s.version !== L) {
|
|
40
|
+
r.push(Fe(n, s.name, s.version));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!t[s.name]) {
|
|
44
|
+
r.push(j(n));
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
o.add(s.name);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
allowed: o,
|
|
51
|
+
diagnostics: r
|
|
52
|
+
};
|
|
53
|
+
}, ze = (e) => {
|
|
54
|
+
const {
|
|
55
|
+
allowed: t,
|
|
56
|
+
diagnostics: r
|
|
57
|
+
} = Le(e.declaredCapabilities, e.capabilities), o = (n) => {
|
|
58
|
+
e.onDiagnostic?.(n);
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
diagnostics: r,
|
|
62
|
+
async call(n) {
|
|
63
|
+
if (!pe(n.method)) {
|
|
64
|
+
const a = j(n.method);
|
|
65
|
+
throw o(a), new Error(a.message);
|
|
66
|
+
}
|
|
67
|
+
if (!t.has(n.method)) {
|
|
68
|
+
const a = _e(n.method);
|
|
69
|
+
throw o(a), new Error(a.message);
|
|
70
|
+
}
|
|
71
|
+
const s = e.capabilities[n.method];
|
|
72
|
+
if (!s) {
|
|
73
|
+
const a = j(n.method);
|
|
74
|
+
throw o(a), new Error(a.message);
|
|
75
|
+
}
|
|
76
|
+
return await s(n.params);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}, qe = (e) => typeof e == "object" && e !== null, ne = (e) => {
|
|
80
|
+
try {
|
|
81
|
+
const t = JSON.stringify(e);
|
|
82
|
+
if (typeof t == "string" && t.length > 0) return t;
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return String(e);
|
|
87
|
+
} catch {
|
|
88
|
+
return "Unknown error";
|
|
89
|
+
}
|
|
90
|
+
}, Qe = (e) => {
|
|
91
|
+
if (e instanceof Error) return {
|
|
92
|
+
message: e.message,
|
|
93
|
+
stack: e.stack
|
|
94
|
+
};
|
|
95
|
+
if (typeof e == "string") return {
|
|
96
|
+
message: e
|
|
97
|
+
};
|
|
98
|
+
if (qe(e)) {
|
|
99
|
+
const t = typeof e.message == "string" ? e.message : null, r = typeof e.stack == "string" ? e.stack : void 0;
|
|
100
|
+
return t ? r ? {
|
|
101
|
+
message: t,
|
|
102
|
+
stack: r
|
|
103
|
+
} : {
|
|
104
|
+
message: t
|
|
105
|
+
} : {
|
|
106
|
+
message: ne(e)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return e == null ? {
|
|
110
|
+
message: "Unknown error"
|
|
111
|
+
} : {
|
|
112
|
+
message: ne(e)
|
|
113
|
+
};
|
|
114
|
+
}, M = () => {
|
|
115
|
+
if (typeof document > "u") return {};
|
|
116
|
+
const e = getComputedStyle(document.documentElement), t = {};
|
|
117
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
118
|
+
const o = e.item(r);
|
|
119
|
+
o.startsWith("--chakra-") && (t[o] = e.getPropertyValue(o).trim());
|
|
120
|
+
}
|
|
121
|
+
return t;
|
|
122
|
+
}, V = (e) => {
|
|
123
|
+
if (typeof document > "u") return e;
|
|
124
|
+
const t = document.documentElement.getAttribute("data-theme");
|
|
125
|
+
if (t === "dark" || t === "light") return t;
|
|
126
|
+
const r = document.documentElement.getAttribute("data-color-mode");
|
|
127
|
+
return r === "dark" || r === "light" ? r : e;
|
|
128
|
+
}, Ge = {
|
|
129
|
+
border: 0,
|
|
130
|
+
display: "block",
|
|
131
|
+
flex: "1 1 0%",
|
|
132
|
+
height: "100%",
|
|
133
|
+
minHeight: 0,
|
|
134
|
+
width: "100%"
|
|
135
|
+
}, Xe = {
|
|
136
|
+
display: "flex",
|
|
137
|
+
height: "100%",
|
|
138
|
+
minHeight: 0,
|
|
139
|
+
position: "relative",
|
|
140
|
+
width: "100%"
|
|
141
|
+
}, Ye = {
|
|
142
|
+
alignItems: "center",
|
|
143
|
+
background: "rgba(255, 255, 255, 0.92)",
|
|
144
|
+
color: "#7a1f12",
|
|
145
|
+
display: "flex",
|
|
146
|
+
inset: 0,
|
|
147
|
+
justifyContent: "center",
|
|
148
|
+
padding: "24px",
|
|
149
|
+
position: "absolute",
|
|
150
|
+
textAlign: "center",
|
|
151
|
+
zIndex: 1
|
|
152
|
+
}, Je = "allow-scripts allow-forms allow-popups", Ze = (e) => {
|
|
153
|
+
const {
|
|
154
|
+
view: t,
|
|
155
|
+
props: r,
|
|
156
|
+
theme: o,
|
|
157
|
+
capabilities: n,
|
|
158
|
+
hostEvents: s,
|
|
159
|
+
onReady: a,
|
|
160
|
+
onError: c,
|
|
161
|
+
onDiagnostics: d,
|
|
162
|
+
title: b
|
|
163
|
+
} = e, i = y(null), l = y(null), m = y(!1), p = y(null), f = y(r), h = y(o), g = y(n), v = y(s), Y = y(t.webview.capabilities), J = y(a), S = y(c), Z = y(d), [ee, P] = Be(null);
|
|
164
|
+
return f.current = r, h.current = o, g.current = n, v.current = s, Y.current = t.webview.capabilities, J.current = a, S.current = c, Z.current = d, A(() => {
|
|
165
|
+
const w = i.current;
|
|
166
|
+
if (!w) return;
|
|
167
|
+
const C = `${t.webview.runtimeUrl}
|
|
168
|
+
${t.webview.moduleUrl}`;
|
|
169
|
+
if (p.current === C) return;
|
|
170
|
+
p.current = C, m.current = !1, l.current = null;
|
|
171
|
+
const x = t.webview.styles, T = t.webview.moduleUrl, te = (I) => {
|
|
172
|
+
I.length > 0 && Z.current?.(I);
|
|
173
|
+
}, re = () => ze({
|
|
174
|
+
capabilities: g.current ?? {},
|
|
175
|
+
declaredCapabilities: Y.current,
|
|
176
|
+
onDiagnostic: (I) => te([I])
|
|
177
|
+
});
|
|
178
|
+
te(re().diagnostics);
|
|
179
|
+
const Te = {
|
|
180
|
+
ready: () => {
|
|
181
|
+
},
|
|
182
|
+
runtimeError: (I) => {
|
|
183
|
+
P(I.message), S.current?.(I);
|
|
184
|
+
},
|
|
185
|
+
call: async (I) => await re().call(I)
|
|
186
|
+
}, je = De.connect(w, Te);
|
|
187
|
+
return w.contentWindow?.location.replace(t.webview.runtimeUrl), je.then(async (I) => {
|
|
188
|
+
const E = I.remote;
|
|
189
|
+
l.current = E, v.current?.bind((Ke) => E.hostEvent?.(Ke)), await E.init({
|
|
190
|
+
moduleUrl: T,
|
|
191
|
+
styles: x,
|
|
192
|
+
props: f.current,
|
|
193
|
+
theme: V(h.current),
|
|
194
|
+
themeVariables: M()
|
|
195
|
+
}), m.current = !0, P(null), J.current?.();
|
|
196
|
+
}).catch((I) => {
|
|
197
|
+
const E = Qe(I);
|
|
198
|
+
P(E.message), S.current?.(E);
|
|
199
|
+
}), () => {
|
|
200
|
+
};
|
|
201
|
+
}, [t.webview.runtimeUrl, t.webview.moduleUrl, t.webview.styles]), A(() => {
|
|
202
|
+
const w = l.current;
|
|
203
|
+
if (!(!w || !s))
|
|
204
|
+
return s.bind((C) => w.hostEvent?.(C)), () => s.unbind();
|
|
205
|
+
}, [s]), A(() => {
|
|
206
|
+
m.current && l.current?.propsUpdate({
|
|
207
|
+
props: r
|
|
208
|
+
});
|
|
209
|
+
}, [r]), A(() => {
|
|
210
|
+
m.current && l.current?.themeUpdate({
|
|
211
|
+
theme: V(o),
|
|
212
|
+
variables: M()
|
|
213
|
+
});
|
|
214
|
+
}, [o]), A(() => {
|
|
215
|
+
if (typeof window > "u" || typeof MutationObserver > "u") return;
|
|
216
|
+
let w = null;
|
|
217
|
+
const C = () => {
|
|
218
|
+
w !== null && cancelAnimationFrame(w), w = requestAnimationFrame(() => {
|
|
219
|
+
w = null, m.current && l.current?.themeUpdate({
|
|
220
|
+
theme: V(h.current),
|
|
221
|
+
variables: M()
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}, x = new MutationObserver(C), T = {
|
|
225
|
+
attributeFilter: ["class", "data-color-mode", "data-theme", "style"],
|
|
226
|
+
attributes: !0
|
|
227
|
+
};
|
|
228
|
+
return x.observe(document.documentElement, T), x.observe(document.body, T), () => {
|
|
229
|
+
x.disconnect(), w !== null && cancelAnimationFrame(w);
|
|
230
|
+
};
|
|
231
|
+
}, []), /* @__PURE__ */ oe("div", { style: Xe, children: [
|
|
232
|
+
ee ? /* @__PURE__ */ W("div", { role: "alert", style: Ye, children: /* @__PURE__ */ oe("div", { children: [
|
|
233
|
+
/* @__PURE__ */ W("strong", { children: "Extension view failed to load." }),
|
|
234
|
+
/* @__PURE__ */ W("div", { children: ee })
|
|
235
|
+
] }) }) : null,
|
|
236
|
+
/* @__PURE__ */ W(
|
|
237
|
+
"iframe",
|
|
238
|
+
{
|
|
239
|
+
ref: i,
|
|
240
|
+
title: b ?? t.label,
|
|
241
|
+
allow: "fullscreen",
|
|
242
|
+
allowFullScreen: !0,
|
|
243
|
+
sandbox: Je,
|
|
244
|
+
style: {
|
|
245
|
+
...Ge,
|
|
246
|
+
colorScheme: o
|
|
247
|
+
},
|
|
248
|
+
onError: () => {
|
|
249
|
+
const w = `Failed to load extension runtime at ${t.webview.runtimeUrl}`;
|
|
250
|
+
P(w), S.current?.({
|
|
251
|
+
message: w
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
] });
|
|
257
|
+
}, et = () => {
|
|
258
|
+
let e = null;
|
|
259
|
+
const t = [], r = /* @__PURE__ */ new Set();
|
|
260
|
+
return {
|
|
261
|
+
emit(o) {
|
|
262
|
+
e ? e(o) : t.push(o);
|
|
263
|
+
},
|
|
264
|
+
bind(o) {
|
|
265
|
+
for (e = o; t.length > 0; ) o(t.shift());
|
|
266
|
+
},
|
|
267
|
+
onDisconnect(o) {
|
|
268
|
+
return r.add(o), () => r.delete(o);
|
|
269
|
+
},
|
|
270
|
+
unbind() {
|
|
271
|
+
e = null;
|
|
272
|
+
for (const o of r) o();
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}, tt = "terminal.session", rt = (e) => {
|
|
276
|
+
const {
|
|
277
|
+
terminal: t,
|
|
278
|
+
hostEvents: r
|
|
279
|
+
} = e, o = (n) => {
|
|
280
|
+
r.emit({
|
|
281
|
+
scope: tt,
|
|
282
|
+
payload: n
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
return async (n) => {
|
|
286
|
+
const s = n;
|
|
287
|
+
switch (s.operation) {
|
|
288
|
+
case "open": {
|
|
289
|
+
const {
|
|
290
|
+
sessionId: a
|
|
291
|
+
} = await t.open({
|
|
292
|
+
request: s.request
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
operation: "open",
|
|
296
|
+
sessionId: a
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
case "write":
|
|
300
|
+
return t.write({
|
|
301
|
+
sessionId: s.sessionId,
|
|
302
|
+
data: s.data
|
|
303
|
+
}), {
|
|
304
|
+
operation: "write",
|
|
305
|
+
accepted: !0
|
|
306
|
+
};
|
|
307
|
+
case "resize":
|
|
308
|
+
return t.resize({
|
|
309
|
+
sessionId: s.sessionId,
|
|
310
|
+
cols: s.cols,
|
|
311
|
+
rows: s.rows
|
|
312
|
+
}), {
|
|
313
|
+
operation: "resize",
|
|
314
|
+
accepted: !0
|
|
315
|
+
};
|
|
316
|
+
case "kill":
|
|
317
|
+
return await t.kill({
|
|
318
|
+
sessionId: s.sessionId,
|
|
319
|
+
signal: s.signal
|
|
320
|
+
}), {
|
|
321
|
+
operation: "kill",
|
|
322
|
+
accepted: !0
|
|
323
|
+
};
|
|
324
|
+
case "subscribe": {
|
|
325
|
+
const {
|
|
326
|
+
sessionId: a
|
|
327
|
+
} = s;
|
|
328
|
+
let c = () => {
|
|
329
|
+
}, d = () => {
|
|
330
|
+
}, b = !1;
|
|
331
|
+
const i = () => {
|
|
332
|
+
b || (b = !0, c(), d());
|
|
333
|
+
};
|
|
334
|
+
return c = t.subscribe(a, {
|
|
335
|
+
onData: (l) => o({
|
|
336
|
+
sessionId: a,
|
|
337
|
+
kind: "data",
|
|
338
|
+
chunk: l
|
|
339
|
+
}),
|
|
340
|
+
onExit: (l) => {
|
|
341
|
+
o({
|
|
342
|
+
sessionId: a,
|
|
343
|
+
kind: "exit",
|
|
344
|
+
code: l.code,
|
|
345
|
+
signal: l.signal
|
|
346
|
+
}), i();
|
|
347
|
+
}
|
|
348
|
+
}), d = r.onDisconnect(i), {
|
|
349
|
+
operation: "subscribe",
|
|
350
|
+
accepted: !0
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}, ot = (e) => {
|
|
356
|
+
if (typeof document > "u") return;
|
|
357
|
+
const t = new KeyboardEvent("keydown", {
|
|
358
|
+
...e,
|
|
359
|
+
bubbles: !0,
|
|
360
|
+
cancelable: !0
|
|
361
|
+
});
|
|
362
|
+
document.dispatchEvent(t);
|
|
363
|
+
}, we = (e) => ({
|
|
364
|
+
"commands.execute": (t) => {
|
|
365
|
+
const r = t;
|
|
366
|
+
return e.workbench.commands.executeCommand(r.commandId, r.params);
|
|
367
|
+
},
|
|
368
|
+
"resource.open": (t) => {
|
|
369
|
+
const r = t;
|
|
370
|
+
if (!r.resource) throw new Error("resource.open requires a resource.");
|
|
371
|
+
return e.workbench.resources.openResource(r.resource, r.input);
|
|
372
|
+
},
|
|
373
|
+
"notification.show": (t) => {
|
|
374
|
+
const r = t;
|
|
375
|
+
return e.workbench.notifications.show({
|
|
376
|
+
level: r.level,
|
|
377
|
+
message: r.message,
|
|
378
|
+
title: r.title
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
"preferences.get": (t) => {
|
|
382
|
+
const r = t;
|
|
383
|
+
return e.workbench.preferences.getValue(r.name, r.scope);
|
|
384
|
+
},
|
|
385
|
+
"preferences.set": (t) => {
|
|
386
|
+
const r = t;
|
|
387
|
+
return e.workbench.preferences.setValue(r.name, r.value, r.scope ?? {
|
|
388
|
+
scope: "user"
|
|
389
|
+
}), {
|
|
390
|
+
name: r.name,
|
|
391
|
+
value: r.value
|
|
392
|
+
};
|
|
393
|
+
},
|
|
394
|
+
"host.dispatchKeyboardEvent": (t) => (e.dispatchKeyboardEvent ?? ot)(t),
|
|
395
|
+
...e.hostEvents ? {
|
|
396
|
+
"terminal.session": rt({
|
|
397
|
+
terminal: e.workbench.terminal,
|
|
398
|
+
hostEvents: e.hostEvents
|
|
399
|
+
})
|
|
400
|
+
} : {}
|
|
401
|
+
}), nt = (e, t) => {
|
|
402
|
+
for (const r of t)
|
|
403
|
+
console.warn(`[workbench.webview:${e}] ${r.code}/${r.capability}: ${r.message}`);
|
|
404
|
+
}, st = (e, t) => {
|
|
405
|
+
console.error(`[workbench.webview:${e}] runtime error: ${t}`);
|
|
406
|
+
}, B = "webview:bridge", it = (e) => {
|
|
407
|
+
if (typeof e != "object" || e === null || Array.isArray(e)) return !1;
|
|
408
|
+
const t = e;
|
|
409
|
+
return typeof t.runtimeUrl == "string" && typeof t.moduleUrl == "string";
|
|
410
|
+
}, at = ({
|
|
411
|
+
placement: e
|
|
412
|
+
}) => ({
|
|
413
|
+
placement: e,
|
|
414
|
+
resource: e.resource
|
|
415
|
+
}), ge = () => "light", se = /* @__PURE__ */ new WeakMap(), Ie = (e, t) => {
|
|
416
|
+
let r = se.get(e);
|
|
417
|
+
r || (r = /* @__PURE__ */ new Map(), se.set(e, r));
|
|
418
|
+
const o = t.widgetId;
|
|
419
|
+
let n = r.get(o);
|
|
420
|
+
return n || (n = et(), r.set(o, n)), n;
|
|
421
|
+
}, ye = (e) => {
|
|
422
|
+
const {
|
|
423
|
+
context: t,
|
|
424
|
+
createHostCapabilities: r,
|
|
425
|
+
createProps: o,
|
|
426
|
+
createTheme: n = ge,
|
|
427
|
+
ownerId: s,
|
|
428
|
+
title: a,
|
|
429
|
+
webview: c
|
|
430
|
+
} = e;
|
|
431
|
+
return /* @__PURE__ */ W(Ze, { view: {
|
|
432
|
+
extensionId: s ?? "workbench",
|
|
433
|
+
id: t.webviewId,
|
|
434
|
+
label: c.title ?? a,
|
|
435
|
+
webview: {
|
|
436
|
+
capabilities: c.capabilities,
|
|
437
|
+
moduleUrl: c.moduleUrl,
|
|
438
|
+
runtimeUrl: c.runtimeUrl,
|
|
439
|
+
styles: c.styles ?? []
|
|
440
|
+
}
|
|
441
|
+
}, props: o(t), theme: n(t), capabilities: r(t), hostEvents: t.hostEvents, onDiagnostics: (d) => nt(t.webviewId, d), onError: (d) => st(t.webviewId, d.message) });
|
|
442
|
+
}, ct = (e, t, r, o) => {
|
|
443
|
+
const {
|
|
444
|
+
workbench: n,
|
|
445
|
+
widget: s,
|
|
446
|
+
placement: a
|
|
447
|
+
} = e, c = it(s.config) ? s.config : null;
|
|
448
|
+
return c ? ye({
|
|
449
|
+
context: {
|
|
450
|
+
workbench: n,
|
|
451
|
+
webviewId: a.contributionId,
|
|
452
|
+
placement: a,
|
|
453
|
+
hostEvents: Ie(n, a)
|
|
454
|
+
},
|
|
455
|
+
createHostCapabilities: t,
|
|
456
|
+
createProps: r,
|
|
457
|
+
createTheme: o,
|
|
458
|
+
ownerId: s.ownerId,
|
|
459
|
+
title: s.title,
|
|
460
|
+
webview: c
|
|
461
|
+
}) : null;
|
|
462
|
+
}, dt = (e = {}) => {
|
|
463
|
+
const t = e.createHostCapabilities ?? we, r = e.createProps ?? at, o = e.createTheme ?? ge;
|
|
464
|
+
return {
|
|
465
|
+
id: B,
|
|
466
|
+
render: (n) => ct(n, t, r, o)
|
|
467
|
+
};
|
|
468
|
+
}, k = (e, t) => ({
|
|
469
|
+
id: e,
|
|
470
|
+
kind: t.kind,
|
|
471
|
+
label: t.label,
|
|
472
|
+
description: t.description,
|
|
473
|
+
metadata: t.metadata
|
|
474
|
+
});
|
|
475
|
+
k("project.sidebar", {
|
|
476
|
+
kind: "view"
|
|
477
|
+
}), k("project.headerPrimary", {
|
|
478
|
+
kind: "menu"
|
|
479
|
+
}), k("project.headerOverflow", {
|
|
480
|
+
kind: "menu"
|
|
481
|
+
}), k("project.settingsPanels", {
|
|
482
|
+
kind: "settings"
|
|
483
|
+
});
|
|
484
|
+
k("session.headerPrimary", {
|
|
485
|
+
kind: "menu"
|
|
486
|
+
}), k("session.headerOverflow", {
|
|
487
|
+
kind: "menu"
|
|
488
|
+
}), k("session.transcriptActions", {
|
|
489
|
+
kind: "menu"
|
|
490
|
+
});
|
|
491
|
+
k("workspace.headerPrimary", {
|
|
492
|
+
kind: "menu"
|
|
493
|
+
}), k("workspace.headerOverflow", {
|
|
494
|
+
kind: "menu"
|
|
495
|
+
}), k("workspace.sidebar", {
|
|
496
|
+
kind: "view"
|
|
497
|
+
});
|
|
498
|
+
const lt = (e) => typeof e == "object" && e !== null && "$l10n" in e && typeof e.$l10n == "string", u = (e, t = "") => e === void 0 ? t : lt(e) ? e.default ?? e.$l10n : e, D = (e) => {
|
|
499
|
+
const t = e;
|
|
500
|
+
if (!t?.outcome) return e;
|
|
501
|
+
if (t.outcome.status === "success") return t.outcome.value;
|
|
502
|
+
throw new Error(t.outcome.reason ?? t.outcome.error?.message ?? "Extension command failed.");
|
|
503
|
+
}, z = (e) => {
|
|
504
|
+
if (e)
|
|
505
|
+
return {
|
|
506
|
+
type: e.kind,
|
|
507
|
+
id: e.id ?? e.uri,
|
|
508
|
+
label: e.label,
|
|
509
|
+
metadata: e.metadata
|
|
510
|
+
};
|
|
511
|
+
}, q = (e) => ({
|
|
512
|
+
kind: e.type,
|
|
513
|
+
uri: `pstdio://extension-resource/${encodeURIComponent(e.type)}/${encodeURIComponent(e.id)}`,
|
|
514
|
+
id: e.id,
|
|
515
|
+
label: e.label,
|
|
516
|
+
metadata: e.metadata
|
|
517
|
+
}), $ = (e) => ({
|
|
518
|
+
id: e.id,
|
|
519
|
+
kind: e.kind,
|
|
520
|
+
context: {
|
|
521
|
+
projectId: e.projectId,
|
|
522
|
+
...e.context ?? {}
|
|
523
|
+
}
|
|
524
|
+
}), R = async (e, t, r = {}) => {
|
|
525
|
+
const o = z(r.resource), n = await e.executeCommand(t, {
|
|
526
|
+
projectId: e.projectId,
|
|
527
|
+
...r.params ? {
|
|
528
|
+
params: r.params
|
|
529
|
+
} : {},
|
|
530
|
+
...o ? {
|
|
531
|
+
resource: o
|
|
532
|
+
} : {},
|
|
533
|
+
...r.slot ? {
|
|
534
|
+
slot: r.slot
|
|
535
|
+
} : {},
|
|
536
|
+
source: "dashboard",
|
|
537
|
+
...r.metadata ? {
|
|
538
|
+
metadata: r.metadata
|
|
539
|
+
} : {}
|
|
540
|
+
});
|
|
541
|
+
return D(n);
|
|
542
|
+
}, mt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ut = (e) => typeof e == "string" ? e : e?.id, ft = async (e, t) => {
|
|
543
|
+
if (t.kind === "resource" && t.resource) {
|
|
544
|
+
await e.workbench.resources.openResource(q(t.resource), {
|
|
545
|
+
replaceActive: !0
|
|
546
|
+
}).catch(() => {
|
|
547
|
+
});
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
const r = ut(t.command);
|
|
551
|
+
r && (await R(e, r, {
|
|
552
|
+
params: t.params
|
|
553
|
+
}), e.workbench.commandPaletteResources.refresh());
|
|
554
|
+
}, bt = (e, t, r, o) => ({
|
|
555
|
+
id: `${t.id}:${o.id}`,
|
|
556
|
+
label: o.label,
|
|
557
|
+
description: o.description,
|
|
558
|
+
icon: o.icon,
|
|
559
|
+
keywords: o.keywords,
|
|
560
|
+
group: r,
|
|
561
|
+
activate: () => ft(e, o.target)
|
|
562
|
+
}), ht = (e, t) => {
|
|
563
|
+
const r = [];
|
|
564
|
+
for (const o of t) {
|
|
565
|
+
const n = u(o.title, o.id);
|
|
566
|
+
r.push(e.workbench.commandPaletteResources.registerProvider({
|
|
567
|
+
id: o.id,
|
|
568
|
+
title: n,
|
|
569
|
+
refreshEventIds: o.refreshEventIds,
|
|
570
|
+
query: async ({
|
|
571
|
+
query: s,
|
|
572
|
+
limit: a
|
|
573
|
+
}) => {
|
|
574
|
+
const c = e.workbench.getActiveResource(), d = await R(e, o.queryCommandId, {
|
|
575
|
+
params: {
|
|
576
|
+
projectId: e.projectId,
|
|
577
|
+
modeId: e.workbench.modes.getActiveModeId(),
|
|
578
|
+
activeResource: z(c),
|
|
579
|
+
providerId: o.id,
|
|
580
|
+
query: s,
|
|
581
|
+
limit: a
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
return mt(d) ? (d.items ?? []).map((b) => bt(e, o, n, b)) : [];
|
|
585
|
+
}
|
|
586
|
+
}));
|
|
587
|
+
}
|
|
588
|
+
return {
|
|
589
|
+
dispose() {
|
|
590
|
+
for (let o = r.length - 1; o >= 0; o -= 1) r[o]?.dispose();
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}, pt = {
|
|
594
|
+
"workbench.main": "main",
|
|
595
|
+
"workbench.main.left": "main-left",
|
|
596
|
+
"workbench.main.right": "main-right",
|
|
597
|
+
"workbench.secondary": "secondary"
|
|
598
|
+
}, wt = {
|
|
599
|
+
"workbench.left.tree": "left",
|
|
600
|
+
"workbench.main.left.tree": "main-left",
|
|
601
|
+
"workbench.main.right.tree": "main-right"
|
|
602
|
+
}, gt = {
|
|
603
|
+
"workbench.left": "left",
|
|
604
|
+
"workbench.main.left": "main-left",
|
|
605
|
+
"workbench.main": "main",
|
|
606
|
+
"workbench.main.right": "main-right",
|
|
607
|
+
"workbench.secondary": "secondary"
|
|
608
|
+
}, H = (e) => e ? pt[e] ?? "main" : "main", It = (e) => e ? wt[e] ?? "left" : "left", ke = (e) => e ? gt[e] ?? "main" : "main", O = (e, t = "") => u(e, t), yt = (e) => !!e && typeof e == "object" && !Array.isArray(e), kt = (e, t, r) => {
|
|
609
|
+
const o = (n, s, a) => n ? R(e, n, {
|
|
610
|
+
params: s,
|
|
611
|
+
resource: a
|
|
612
|
+
}) : Promise.resolve(void 0);
|
|
613
|
+
return e.workbench.renderers.registerControlsRenderer({
|
|
614
|
+
id: t.id,
|
|
615
|
+
title: O(t.title, t.id),
|
|
616
|
+
emptyTitle: O(t.emptyTitle, ""),
|
|
617
|
+
emptyDescription: O(t.emptyDescription, ""),
|
|
618
|
+
defaultValues: t.defaultValues,
|
|
619
|
+
executeQuery: async (n) => {
|
|
620
|
+
const s = await o(t.queryCommandId, {}, n ?? r.resolveResource?.(t));
|
|
621
|
+
return yt(s) ? s : {};
|
|
622
|
+
},
|
|
623
|
+
updateValue: t.updateValueCommandId ? ({
|
|
624
|
+
controlId: n,
|
|
625
|
+
value: s,
|
|
626
|
+
values: a,
|
|
627
|
+
resource: c
|
|
628
|
+
}) => o(t.updateValueCommandId, {
|
|
629
|
+
controlId: n,
|
|
630
|
+
value: s,
|
|
631
|
+
values: a
|
|
632
|
+
}, c).then(() => {
|
|
633
|
+
}) : void 0,
|
|
634
|
+
apply: t.applyCommandId ? ({
|
|
635
|
+
values: n,
|
|
636
|
+
resource: s
|
|
637
|
+
}) => o(t.applyCommandId, {
|
|
638
|
+
values: n
|
|
639
|
+
}, s).then(() => {
|
|
640
|
+
}) : void 0,
|
|
641
|
+
reset: t.resetCommandId ? ({
|
|
642
|
+
controlIds: n,
|
|
643
|
+
resource: s
|
|
644
|
+
}) => o(t.resetCommandId, {
|
|
645
|
+
controlIds: n
|
|
646
|
+
}, s).then(() => {
|
|
647
|
+
}) : void 0
|
|
648
|
+
});
|
|
649
|
+
}, vt = (e, t) => {
|
|
650
|
+
if (t.controlsRendererId)
|
|
651
|
+
return e.workbench.layout.registerWidget({
|
|
652
|
+
id: t.id,
|
|
653
|
+
title: u(t.title, t.id),
|
|
654
|
+
area: t.surface === "modal" ? "overlay" : H(t.target),
|
|
655
|
+
rendererId: t.controlsRendererId,
|
|
656
|
+
singleton: !0,
|
|
657
|
+
resourceKinds: t.resourceKind ? [t.resourceKind] : void 0
|
|
658
|
+
});
|
|
659
|
+
}, Nr = (e, t, r, o = {}) => {
|
|
660
|
+
const n = [];
|
|
661
|
+
for (const s of t) n.push(kt(e, s, o));
|
|
662
|
+
for (const s of r) {
|
|
663
|
+
const a = vt(e, s);
|
|
664
|
+
a && n.push(a);
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
dispose() {
|
|
668
|
+
for (let s = n.length - 1; s >= 0; s -= 1) n[s]?.dispose();
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}, Rt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ie = (e, t, r, o) => (t ?? []).map((n) => {
|
|
672
|
+
const s = {
|
|
673
|
+
...n,
|
|
674
|
+
label: r(n.label, n.id),
|
|
675
|
+
type: n.type.kind === "enum" || n.type.kind === "enum-multi" ? {
|
|
676
|
+
...n.type,
|
|
677
|
+
options: Array.isArray(n.type.options) ? n.type.options.map((a) => ({
|
|
678
|
+
...a,
|
|
679
|
+
label: r(a.label, a.value)
|
|
680
|
+
})) : n.type.options
|
|
681
|
+
} : n.type
|
|
682
|
+
};
|
|
683
|
+
return o(e, s);
|
|
684
|
+
}), Ct = (e, t, r, o) => {
|
|
685
|
+
let n = ie(e, t, r, o);
|
|
686
|
+
const s = /* @__PURE__ */ new Set();
|
|
687
|
+
return {
|
|
688
|
+
source: {
|
|
689
|
+
getSnapshot: () => n,
|
|
690
|
+
subscribe: (a) => (s.add(a), () => s.delete(a))
|
|
691
|
+
},
|
|
692
|
+
set(a) {
|
|
693
|
+
n = ie(e, a, r, o);
|
|
694
|
+
for (const c of s) c();
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}, Et = (e) => !!(e && typeof e == "object" && typeof e.kind == "string"), xt = (e) => !!(e && typeof e == "object" && typeof e.type == "string" && typeof e.id == "string"), At = (e, t) => `pstdio://extension-resource/${encodeURIComponent(e)}/${encodeURIComponent(t)}`, ve = (e, t) => {
|
|
698
|
+
const {
|
|
699
|
+
resource: r
|
|
700
|
+
} = t;
|
|
701
|
+
if (Et(r)) return r;
|
|
702
|
+
if (xt(r)) return q(r);
|
|
703
|
+
}, Wt = (e, t) => {
|
|
704
|
+
const r = ve(e, t);
|
|
705
|
+
if (r) return r;
|
|
706
|
+
if (e.resourceKind)
|
|
707
|
+
return {
|
|
708
|
+
kind: e.resourceKind,
|
|
709
|
+
uri: At(e.resourceKind, t.id),
|
|
710
|
+
id: t.id,
|
|
711
|
+
label: t.title
|
|
712
|
+
};
|
|
713
|
+
}, ae = (e, t) => {
|
|
714
|
+
const r = e, o = t(r);
|
|
715
|
+
return o === void 0 ? r : {
|
|
716
|
+
...r,
|
|
717
|
+
resource: o
|
|
718
|
+
};
|
|
719
|
+
}, St = (...e) => Object.assign({}, ...e.filter((t) => !!t)), Pt = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, Tt = (e) => Object.keys(e ?? {}).length > 0, jt = (e) => (r) => fe(be, {
|
|
720
|
+
name: e ?? "MoreHorizontal",
|
|
721
|
+
...r
|
|
722
|
+
}), Kt = (e, t) => ({
|
|
723
|
+
color: e?.color,
|
|
724
|
+
canDragIn: e?.canDragIn,
|
|
725
|
+
canDragOut: e?.canDragOut,
|
|
726
|
+
canCreate: e?.canCreate,
|
|
727
|
+
actions: e?.actions?.map((r) => ({
|
|
728
|
+
id: r.id,
|
|
729
|
+
label: t(r.label, r.id),
|
|
730
|
+
icon: jt(r.icon)
|
|
731
|
+
}))
|
|
732
|
+
}), Bt = (e) => e ? fe(be, {
|
|
733
|
+
name: e,
|
|
734
|
+
size: 16
|
|
735
|
+
}) : void 0, Dt = (e, t) => $({
|
|
736
|
+
id: t.id,
|
|
737
|
+
kind: "dataRenderer",
|
|
738
|
+
projectId: e.projectId,
|
|
739
|
+
context: {
|
|
740
|
+
dataRendererId: t.id
|
|
741
|
+
}
|
|
742
|
+
}), K = (e, t, r, o, n) => R(e, r, {
|
|
743
|
+
params: o,
|
|
744
|
+
resource: n ?? e.workbench.getPrimaryResource(),
|
|
745
|
+
slot: Dt(e, t),
|
|
746
|
+
metadata: {
|
|
747
|
+
dataRendererId: t.id
|
|
748
|
+
}
|
|
749
|
+
}), Re = (e, t) => `workbench.extension.dataRenderer.${e.id}.rowAction.${t.id}`, $t = (e, t, r) => (t.rowActions ?? []).map((o) => {
|
|
750
|
+
const n = e.workbench.commands.getCommand(o.commandId)?.command;
|
|
751
|
+
return e.workbench.commands.registerCommand({
|
|
752
|
+
id: Re(t, o),
|
|
753
|
+
label: r(o.label, o.id),
|
|
754
|
+
icon: o.icon,
|
|
755
|
+
params: n?.params
|
|
756
|
+
}, {
|
|
757
|
+
execute: (s, a) => K(e, t, o.commandId, St(Pt(s)), a?.resource)
|
|
758
|
+
});
|
|
759
|
+
}), Ht = (e, t, r, o, n, s) => {
|
|
760
|
+
const a = Re(t, r), c = e.workbench.commands.getCommand(a), d = {
|
|
761
|
+
rowId: o.id
|
|
762
|
+
}, b = n ? {
|
|
763
|
+
resource: n
|
|
764
|
+
} : void 0, i = s(r.label, r.id);
|
|
765
|
+
return c && Tt(c.command.params) ? (e.workbench.commandPalette.requestParams({
|
|
766
|
+
record: c,
|
|
767
|
+
label: i,
|
|
768
|
+
args: d,
|
|
769
|
+
context: b
|
|
770
|
+
}), Promise.resolve()) : c ? e.workbench.commands.executeCommand(c.command.id, d, b).then(() => {
|
|
771
|
+
}) : K(e, t, r.commandId, d, n).then(() => {
|
|
772
|
+
});
|
|
773
|
+
}, Mt = (e, t, r = {}) => {
|
|
774
|
+
const o = [], n = r.resolveLabel ?? ((i, l) => u(i, l)), s = r.decorateAttribute ?? ((i, l) => l), a = r.resolveRowResource ?? ve, c = r.resolveRowActionResource ?? Wt, d = r.onAfterMutation ?? (() => {
|
|
775
|
+
}), b = (i, l, m) => K(e, i, l, m).then((p) => (d(i), p));
|
|
776
|
+
for (const i of t) {
|
|
777
|
+
const l = Ct(i, i.attributes, n, s);
|
|
778
|
+
let m;
|
|
779
|
+
const p = (f) => a(i, f);
|
|
780
|
+
o.push(...$t(e, i, n)), o.push(e.workbench.renderers.registerDataRenderer({
|
|
781
|
+
id: i.id,
|
|
782
|
+
title: n(i.title, i.id),
|
|
783
|
+
resourceKind: i.resourceKind,
|
|
784
|
+
attributes: l.source,
|
|
785
|
+
defaultSettings: i.defaultSettings,
|
|
786
|
+
defaultFilters: i.defaultFilters,
|
|
787
|
+
emptyTitle: n(i.emptyTitle, ""),
|
|
788
|
+
emptyDescription: n(i.emptyDescription, ""),
|
|
789
|
+
hideToolbar: i.hideToolbar,
|
|
790
|
+
getBoardColumnConfig: (f) => Kt(m?.[f], n),
|
|
791
|
+
onRowClick: r.onRowClick ? (f) => r.onRowClick({
|
|
792
|
+
record: i,
|
|
793
|
+
row: f,
|
|
794
|
+
resource: a(i, f)
|
|
795
|
+
}) : void 0,
|
|
796
|
+
executeQuery: async (f) => {
|
|
797
|
+
const h = await K(e, i, i.queryCommandId, {
|
|
798
|
+
settings: f.settings,
|
|
799
|
+
filters: f.filters
|
|
800
|
+
});
|
|
801
|
+
return Array.isArray(h) ? h.map((g) => ae(g, p)) : Rt(h) ? (l.set(h.attributes), m = h.boardColumnConfigs, (h.rows ?? []).map((g) => ae(g, p))) : [];
|
|
802
|
+
},
|
|
803
|
+
onAttributeChange: i.updateAttributeCommandId ? (f, h, g) => b(i, i.updateAttributeCommandId, {
|
|
804
|
+
rowId: f,
|
|
805
|
+
attributeId: h,
|
|
806
|
+
value: g
|
|
807
|
+
}).then(() => {
|
|
808
|
+
}) : void 0,
|
|
809
|
+
onReorder: i.reorderCommandId ? (f, h) => b(i, i.reorderCommandId, {
|
|
810
|
+
rowId: f,
|
|
811
|
+
beforeRowId: h
|
|
812
|
+
}).then(() => {
|
|
813
|
+
}) : void 0,
|
|
814
|
+
onCreateRow: i.createRow ? (f) => {
|
|
815
|
+
const h = i.createRow?.columnParam ? {
|
|
816
|
+
[i.createRow.columnParam]: f
|
|
817
|
+
} : {}, g = () => b(i, i.createRow.commandId, h).then((v) => (r.onAfterCreate?.({
|
|
818
|
+
record: i,
|
|
819
|
+
created: v
|
|
820
|
+
}), v));
|
|
821
|
+
r.onCreateRow ? r.onCreateRow({
|
|
822
|
+
record: i,
|
|
823
|
+
columnId: f,
|
|
824
|
+
executeDefault: g
|
|
825
|
+
}) : g();
|
|
826
|
+
} : void 0,
|
|
827
|
+
onColumnAction: i.columnActionCommandId ? async (f, h) => {
|
|
828
|
+
await b(i, i.columnActionCommandId, {
|
|
829
|
+
columnId: f,
|
|
830
|
+
actionId: h
|
|
831
|
+
});
|
|
832
|
+
} : void 0,
|
|
833
|
+
getRowContextMenuActions: i.rowActions?.length ? (f) => i.rowActions.map((h) => {
|
|
834
|
+
const g = c(i, f), v = () => Ht(e, i, h, f, g, n);
|
|
835
|
+
return {
|
|
836
|
+
key: h.id,
|
|
837
|
+
label: n(h.label, h.id),
|
|
838
|
+
icon: Bt(h.icon),
|
|
839
|
+
onClick: () => r.executeRowAction ? r.executeRowAction({
|
|
840
|
+
record: i,
|
|
841
|
+
action: h,
|
|
842
|
+
row: f,
|
|
843
|
+
resource: g,
|
|
844
|
+
runDefault: v
|
|
845
|
+
}) : v()
|
|
846
|
+
};
|
|
847
|
+
}) : void 0
|
|
848
|
+
})), o.push(e.workbench.layout.registerWidget({
|
|
849
|
+
id: i.id,
|
|
850
|
+
title: n(i.title, i.id),
|
|
851
|
+
area: "main",
|
|
852
|
+
rendererId: i.id,
|
|
853
|
+
singleton: !0,
|
|
854
|
+
resourceKinds: i.resourceKind ? [i.resourceKind] : void 0
|
|
855
|
+
}));
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
dispose() {
|
|
859
|
+
for (let i = o.length - 1; i >= 0; i -= 1) o[i]?.dispose();
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}, Vt = {
|
|
863
|
+
first: 0,
|
|
864
|
+
default: 1,
|
|
865
|
+
last: 2
|
|
866
|
+
}, Ur = {
|
|
867
|
+
commands: [],
|
|
868
|
+
commandPaletteContributions: [],
|
|
869
|
+
diagnostics: [],
|
|
870
|
+
extensions: [],
|
|
871
|
+
menuContributions: [],
|
|
872
|
+
modes: [],
|
|
873
|
+
navigation: [],
|
|
874
|
+
routes: [],
|
|
875
|
+
dataRenderers: [],
|
|
876
|
+
treeRenderers: [],
|
|
877
|
+
fileRenderers: [],
|
|
878
|
+
settingsPanels: [],
|
|
879
|
+
settingsDefinitions: [],
|
|
880
|
+
treeItems: [],
|
|
881
|
+
views: []
|
|
882
|
+
}, Ot = (e) => `workbench.extension.menu.${e.id}`, Nt = (e) => `workbench.extension.palette.${e.id}`, Ce = (e, t) => Vt[e.placement ?? "default"] * 1e3 + t, Ee = (e) => e === void 0 ? "" : $e(e) ? e.default ?? e.$l10n : e, Ut = (e) => {
|
|
883
|
+
const {
|
|
884
|
+
commandId: t,
|
|
885
|
+
contribution: r,
|
|
886
|
+
index: o,
|
|
887
|
+
resolveString: n,
|
|
888
|
+
slot: s,
|
|
889
|
+
when: a
|
|
890
|
+
} = e;
|
|
891
|
+
return {
|
|
892
|
+
commandId: t,
|
|
893
|
+
label: n(r.label, r.extensionId),
|
|
894
|
+
icon: r.icon,
|
|
895
|
+
group: s.group ?? r.group,
|
|
896
|
+
overflowLabel: s.overflowLabel,
|
|
897
|
+
order: Ce(r, o),
|
|
898
|
+
when: a
|
|
899
|
+
};
|
|
900
|
+
}, Ft = (e) => {
|
|
901
|
+
const {
|
|
902
|
+
commandId: t,
|
|
903
|
+
contribution: r,
|
|
904
|
+
index: o,
|
|
905
|
+
resolveString: n
|
|
906
|
+
} = e;
|
|
907
|
+
return {
|
|
908
|
+
commandId: t,
|
|
909
|
+
label: n(r.label, r.extensionId),
|
|
910
|
+
icon: r.icon,
|
|
911
|
+
group: r.group,
|
|
912
|
+
order: Ce(r, o)
|
|
913
|
+
};
|
|
914
|
+
}, _t = (e) => {
|
|
915
|
+
const {
|
|
916
|
+
createCommandId: t = Ot,
|
|
917
|
+
createWhenExpression: r,
|
|
918
|
+
menuSlotsById: o,
|
|
919
|
+
menuTargetsById: n,
|
|
920
|
+
metadata: s,
|
|
921
|
+
resolveString: a = Ee
|
|
922
|
+
} = e, c = [];
|
|
923
|
+
return s.menuContributions.forEach((d, b) => {
|
|
924
|
+
const i = d.target ? n?.get(d.target) : o.get(d.slotId);
|
|
925
|
+
if (!i) return;
|
|
926
|
+
const l = t(d), m = s.commands.find((p) => p.id === d.commandId);
|
|
927
|
+
c.push({
|
|
928
|
+
command: {
|
|
929
|
+
id: l,
|
|
930
|
+
label: a(d.label, d.extensionId),
|
|
931
|
+
category: d.group,
|
|
932
|
+
description: m ? a(m.description, m.extensionId) : void 0,
|
|
933
|
+
icon: d.icon,
|
|
934
|
+
params: m?.params
|
|
935
|
+
},
|
|
936
|
+
contribution: d,
|
|
937
|
+
menuItem: Ut({
|
|
938
|
+
commandId: l,
|
|
939
|
+
contribution: d,
|
|
940
|
+
index: b,
|
|
941
|
+
resolveString: a,
|
|
942
|
+
slot: i,
|
|
943
|
+
when: r?.(d)
|
|
944
|
+
}),
|
|
945
|
+
menuPath: i.menuPath,
|
|
946
|
+
targetCommandId: d.commandId
|
|
947
|
+
});
|
|
948
|
+
}), c;
|
|
949
|
+
}, Lt = (e) => {
|
|
950
|
+
const {
|
|
951
|
+
createCommandId: t = Nt,
|
|
952
|
+
metadata: r,
|
|
953
|
+
resolveString: o = Ee
|
|
954
|
+
} = e, n = [];
|
|
955
|
+
return (r.commandPaletteContributions ?? []).forEach((s, a) => {
|
|
956
|
+
const c = t(s), d = r.commands.find((b) => b.id === s.commandId);
|
|
957
|
+
n.push({
|
|
958
|
+
command: {
|
|
959
|
+
id: c,
|
|
960
|
+
label: o(s.label, s.extensionId),
|
|
961
|
+
category: s.group,
|
|
962
|
+
description: d ? o(d.description, d.extensionId) : void 0,
|
|
963
|
+
icon: s.icon,
|
|
964
|
+
params: d?.params
|
|
965
|
+
},
|
|
966
|
+
contribution: s,
|
|
967
|
+
menuItem: Ft({
|
|
968
|
+
commandId: c,
|
|
969
|
+
contribution: s,
|
|
970
|
+
index: a,
|
|
971
|
+
resolveString: o
|
|
972
|
+
}),
|
|
973
|
+
targetCommandId: s.commandId
|
|
974
|
+
});
|
|
975
|
+
}), n;
|
|
976
|
+
}, Fr = (e) => {
|
|
977
|
+
const {
|
|
978
|
+
createResource: t,
|
|
979
|
+
metadata: r
|
|
980
|
+
} = e;
|
|
981
|
+
return r ? r.routes.map((o) => ({
|
|
982
|
+
resource: t({
|
|
983
|
+
route: o
|
|
984
|
+
})
|
|
985
|
+
})) : [];
|
|
986
|
+
}, zt = (e) => {
|
|
987
|
+
if (e)
|
|
988
|
+
return {
|
|
989
|
+
type: e.kind,
|
|
990
|
+
id: e.id ?? e.uri,
|
|
991
|
+
label: e.label,
|
|
992
|
+
metadata: e.metadata
|
|
993
|
+
};
|
|
994
|
+
}, qt = (e) => ({
|
|
995
|
+
id: e.rendererId,
|
|
996
|
+
kind: "renderer",
|
|
997
|
+
context: {
|
|
998
|
+
projectId: e.projectId,
|
|
999
|
+
...e.resource ? {
|
|
1000
|
+
resourceType: e.resource.type,
|
|
1001
|
+
resourceId: e.resource.id
|
|
1002
|
+
} : {}
|
|
1003
|
+
}
|
|
1004
|
+
}), ce = async (e, t, r, o, n = {}) => {
|
|
1005
|
+
const s = zt(o), a = await e.executeCommand(r, {
|
|
1006
|
+
projectId: e.projectId,
|
|
1007
|
+
params: {
|
|
1008
|
+
projectId: e.projectId,
|
|
1009
|
+
resource: s,
|
|
1010
|
+
...n
|
|
1011
|
+
},
|
|
1012
|
+
resource: s,
|
|
1013
|
+
slot: qt({
|
|
1014
|
+
projectId: e.projectId,
|
|
1015
|
+
rendererId: t,
|
|
1016
|
+
resource: s
|
|
1017
|
+
}),
|
|
1018
|
+
source: "dashboard"
|
|
1019
|
+
});
|
|
1020
|
+
return D(a);
|
|
1021
|
+
}, Qt = (e, t) => e.workbench.renderers.registerFileRenderer({
|
|
1022
|
+
id: t.id,
|
|
1023
|
+
title: u(t.title, t.id),
|
|
1024
|
+
resourceKind: t.resourceKind,
|
|
1025
|
+
load: async (r) => await ce(e, t.id, t.loadCommandId, r) ?? {},
|
|
1026
|
+
save: t.saveCommandId ? async (r, o) => {
|
|
1027
|
+
await ce(e, t.id, t.saveCommandId, r, {
|
|
1028
|
+
content: o
|
|
1029
|
+
});
|
|
1030
|
+
} : void 0
|
|
1031
|
+
}), Gt = (e, t) => {
|
|
1032
|
+
if (t.fileRendererId)
|
|
1033
|
+
return e.workbench.layout.registerWidget({
|
|
1034
|
+
id: t.id,
|
|
1035
|
+
title: u(t.title, t.id),
|
|
1036
|
+
area: t.surface === "modal" ? "overlay" : H(t.target),
|
|
1037
|
+
rendererId: t.fileRendererId,
|
|
1038
|
+
singleton: !0,
|
|
1039
|
+
resourceKinds: t.resourceKind ? [t.resourceKind] : void 0
|
|
1040
|
+
});
|
|
1041
|
+
}, Xt = (e) => {
|
|
1042
|
+
const t = [];
|
|
1043
|
+
for (const r of e.metadata.fileRenderers ?? [])
|
|
1044
|
+
t.push(Qt(e, r));
|
|
1045
|
+
for (const r of e.metadata.views) {
|
|
1046
|
+
const o = Gt(e, r);
|
|
1047
|
+
o && t.push(o);
|
|
1048
|
+
}
|
|
1049
|
+
return {
|
|
1050
|
+
dispose() {
|
|
1051
|
+
for (let r = t.length - 1; r >= 0; r -= 1) t[r]?.dispose();
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
}, Yt = (e, t) => e.views.filter((r) => r.treeRendererId === t.id), xe = (e, t) => t.viewId ? e.find((r) => r.id === t.viewId) : e.length === 1 ? e[0] : void 0, Jt = async (e) => {
|
|
1055
|
+
const {
|
|
1056
|
+
ctx: t,
|
|
1057
|
+
getHostTreeHeaderNodes: r,
|
|
1058
|
+
record: o,
|
|
1059
|
+
treeViews: n
|
|
1060
|
+
} = e, s = xe(n, t);
|
|
1061
|
+
return s?.hostTreeHeader !== "default" ? [] : await r?.({
|
|
1062
|
+
ctx: t,
|
|
1063
|
+
record: o,
|
|
1064
|
+
view: s
|
|
1065
|
+
}) ?? [];
|
|
1066
|
+
}, Zt = async (e) => {
|
|
1067
|
+
const {
|
|
1068
|
+
ctx: t,
|
|
1069
|
+
getHostTreeFooterNodes: r,
|
|
1070
|
+
record: o,
|
|
1071
|
+
treeViews: n
|
|
1072
|
+
} = e, s = xe(n, t);
|
|
1073
|
+
return s?.hostTreeFooter !== "default" ? [] : await r?.({
|
|
1074
|
+
ctx: t,
|
|
1075
|
+
record: o,
|
|
1076
|
+
view: s
|
|
1077
|
+
}) ?? [];
|
|
1078
|
+
}, er = (e, t) => {
|
|
1079
|
+
if (!t.treeRendererId) return;
|
|
1080
|
+
const r = H(t.target);
|
|
1081
|
+
return e.workbench.layout.registerWidget({
|
|
1082
|
+
id: t.id,
|
|
1083
|
+
title: u(t.title, t.id),
|
|
1084
|
+
area: t.surface === "modal" ? "overlay" : r,
|
|
1085
|
+
rendererId: t.treeRendererId,
|
|
1086
|
+
singleton: !0,
|
|
1087
|
+
resourceKinds: t.resourceKind ? [t.resourceKind] : void 0
|
|
1088
|
+
});
|
|
1089
|
+
}, F = (e) => {
|
|
1090
|
+
if (e)
|
|
1091
|
+
return {
|
|
1092
|
+
type: e.kind,
|
|
1093
|
+
id: e.id ?? e.uri,
|
|
1094
|
+
label: e.label,
|
|
1095
|
+
metadata: e.metadata
|
|
1096
|
+
};
|
|
1097
|
+
}, de = (e) => ({
|
|
1098
|
+
kind: e.type,
|
|
1099
|
+
uri: `pstdio://extension-resource/${encodeURIComponent(e.type)}/${encodeURIComponent(e.id)}`,
|
|
1100
|
+
id: e.id,
|
|
1101
|
+
label: e.label,
|
|
1102
|
+
metadata: e.metadata
|
|
1103
|
+
}), Ae = (e) => ({
|
|
1104
|
+
id: e.treeId,
|
|
1105
|
+
kind: "renderer",
|
|
1106
|
+
context: {
|
|
1107
|
+
projectId: e.projectId,
|
|
1108
|
+
treeId: e.treeId,
|
|
1109
|
+
...e.modeId ? {
|
|
1110
|
+
modeId: e.modeId
|
|
1111
|
+
} : {},
|
|
1112
|
+
...e.resource ? {
|
|
1113
|
+
resourceType: e.resource.type,
|
|
1114
|
+
resourceId: e.resource.id
|
|
1115
|
+
} : {}
|
|
1116
|
+
}
|
|
1117
|
+
}), N = (e, t, r, o) => {
|
|
1118
|
+
const n = F(r.resource);
|
|
1119
|
+
return {
|
|
1120
|
+
projectId: e.projectId,
|
|
1121
|
+
modeId: e.workbench.modes.getActiveModeId(),
|
|
1122
|
+
resource: n,
|
|
1123
|
+
treeId: t.id,
|
|
1124
|
+
state: e.workbench.renderers.getTreeState(t.id),
|
|
1125
|
+
...r.filter ? {
|
|
1126
|
+
filter: r.filter
|
|
1127
|
+
} : {},
|
|
1128
|
+
...o ? {
|
|
1129
|
+
node: o
|
|
1130
|
+
} : {}
|
|
1131
|
+
};
|
|
1132
|
+
}, U = async (e, t, r) => {
|
|
1133
|
+
const o = r.resource, n = await e.executeCommand(t, {
|
|
1134
|
+
projectId: e.projectId,
|
|
1135
|
+
params: r,
|
|
1136
|
+
resource: o,
|
|
1137
|
+
slot: Ae({
|
|
1138
|
+
modeId: r.modeId,
|
|
1139
|
+
projectId: e.projectId,
|
|
1140
|
+
resource: o,
|
|
1141
|
+
treeId: r.treeId
|
|
1142
|
+
}),
|
|
1143
|
+
source: "dashboard"
|
|
1144
|
+
});
|
|
1145
|
+
return D(n);
|
|
1146
|
+
}, We = async (e, t, r, o, n) => {
|
|
1147
|
+
const s = e.workbench.modes.getActiveModeId(), a = await e.executeCommand(r, {
|
|
1148
|
+
projectId: e.projectId,
|
|
1149
|
+
...o ? {
|
|
1150
|
+
params: o
|
|
1151
|
+
} : {},
|
|
1152
|
+
resource: n,
|
|
1153
|
+
slot: Ae({
|
|
1154
|
+
modeId: s,
|
|
1155
|
+
projectId: e.projectId,
|
|
1156
|
+
resource: n,
|
|
1157
|
+
treeId: t.id
|
|
1158
|
+
}),
|
|
1159
|
+
source: "dashboard",
|
|
1160
|
+
metadata: {
|
|
1161
|
+
treeId: t.id
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
return D(a);
|
|
1165
|
+
}, tr = (e, t) => e && typeof e == "object" && !Array.isArray(e) ? e : t, rr = (e, t) => {
|
|
1166
|
+
const r = /* @__PURE__ */ new WeakMap(), o = `workbench.extensionTreeRenderer.${t.id}.command`, n = (i) => {
|
|
1167
|
+
if (i.emptyState)
|
|
1168
|
+
return {
|
|
1169
|
+
title: u(i.emptyState.title),
|
|
1170
|
+
description: u(i.emptyState.description),
|
|
1171
|
+
icon: i.emptyState.icon
|
|
1172
|
+
};
|
|
1173
|
+
}, s = (i, l, m) => {
|
|
1174
|
+
if (i) {
|
|
1175
|
+
if (i.kind === "resource" && i.resource)
|
|
1176
|
+
return {
|
|
1177
|
+
kind: "resource",
|
|
1178
|
+
resource: de(i.resource),
|
|
1179
|
+
input: {
|
|
1180
|
+
replaceActive: !0
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
if (i.kind === "view" && i.widgetId) return {
|
|
1184
|
+
kind: "view",
|
|
1185
|
+
widgetId: i.widgetId
|
|
1186
|
+
};
|
|
1187
|
+
if (!(i.kind !== "command" || !i.commandId))
|
|
1188
|
+
return {
|
|
1189
|
+
kind: "command",
|
|
1190
|
+
commandId: o,
|
|
1191
|
+
args: {
|
|
1192
|
+
commandId: i.commandId,
|
|
1193
|
+
nodeId: l.id,
|
|
1194
|
+
params: i.args,
|
|
1195
|
+
resource: l.resource ?? F(m.resource),
|
|
1196
|
+
treeId: t.id
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
}, a = (i, l, m) => {
|
|
1201
|
+
const p = i.commandId;
|
|
1202
|
+
return {
|
|
1203
|
+
id: i.id,
|
|
1204
|
+
label: u(i.label),
|
|
1205
|
+
icon: i.icon,
|
|
1206
|
+
args: i.args,
|
|
1207
|
+
params: i.params,
|
|
1208
|
+
submitLabel: i.submitLabel,
|
|
1209
|
+
when: i.when,
|
|
1210
|
+
disabled: i.disabled,
|
|
1211
|
+
// Actions mutate tree data (create/delete/...), so refresh afterwards. Plain
|
|
1212
|
+
// node-target navigation runs through the runner command and must not refetch.
|
|
1213
|
+
run: p ? async (f) => {
|
|
1214
|
+
await We(e, t, p, tr(f, i.args), l?.resource ?? F(m.resource)), e.workbench.renderers.refresh(t.id);
|
|
1215
|
+
} : void 0
|
|
1216
|
+
};
|
|
1217
|
+
}, c = (i, l) => {
|
|
1218
|
+
const m = {
|
|
1219
|
+
id: i.id,
|
|
1220
|
+
label: u(i.label),
|
|
1221
|
+
icon: i.icon,
|
|
1222
|
+
iconColor: i.iconColor,
|
|
1223
|
+
iconTooltip: i.iconTooltip,
|
|
1224
|
+
resource: i.resource ? de(i.resource) : void 0,
|
|
1225
|
+
target: s(i.target, i, l),
|
|
1226
|
+
rowVariant: i.rowVariant,
|
|
1227
|
+
actions: i.actions?.map((p) => a(p, i, l)),
|
|
1228
|
+
contextMenuActions: i.contextMenuActions?.map((p) => a(p, i, l)),
|
|
1229
|
+
collapsible: i.collapsible,
|
|
1230
|
+
disabled: i.disabled,
|
|
1231
|
+
children: i.children?.map((p) => c(p, l)),
|
|
1232
|
+
description: i.description,
|
|
1233
|
+
contextValue: i.contextValue,
|
|
1234
|
+
hiddenByDefault: i.hiddenByDefault,
|
|
1235
|
+
canHide: i.canHide
|
|
1236
|
+
};
|
|
1237
|
+
return r.set(m, i), m;
|
|
1238
|
+
};
|
|
1239
|
+
return {
|
|
1240
|
+
mapNodes: (i, l) => i.map((m) => c(m, l)),
|
|
1241
|
+
mapSections: (i, l) => i.map((m) => ({
|
|
1242
|
+
id: m.id,
|
|
1243
|
+
label: u(m.label),
|
|
1244
|
+
actions: m.actions?.map((p) => a(p, void 0, l)),
|
|
1245
|
+
collapsible: m.collapsible,
|
|
1246
|
+
emptyState: n(m),
|
|
1247
|
+
nodes: m.nodes.map((p) => c(p, l)),
|
|
1248
|
+
hiddenByDefault: m.hiddenByDefault,
|
|
1249
|
+
canHide: m.canHide
|
|
1250
|
+
})),
|
|
1251
|
+
originalNodes: r,
|
|
1252
|
+
runnerCommandId: o
|
|
1253
|
+
};
|
|
1254
|
+
}, or = (e) => Array.isArray(e) && e.every((t) => t && typeof t == "object" && "nodes" in t), le = (e) => Array.isArray(e) && e.every((t) => t && typeof t == "object" && "id" in t), nr = (e) => {
|
|
1255
|
+
for (const t of e)
|
|
1256
|
+
for (const r of t.nodes)
|
|
1257
|
+
if (r.selected) return r.id;
|
|
1258
|
+
}, sr = (e, t) => {
|
|
1259
|
+
const r = rr(e, t), o = Yt(e.metadata, t), n = e.workbench.commands.registerCommand({
|
|
1260
|
+
id: r.runnerCommandId,
|
|
1261
|
+
label: `${u(t.title, t.id)} tree command`
|
|
1262
|
+
}, {
|
|
1263
|
+
execute: async (a) => {
|
|
1264
|
+
const c = a;
|
|
1265
|
+
c.nodeId && e.workbench.renderers.setSelectedNode(t.id, c.nodeId);
|
|
1266
|
+
const d = await We(e, t, c.commandId, c.params, c.resource);
|
|
1267
|
+
for (const b of e.workbench.renderers.listFileRenderers())
|
|
1268
|
+
e.workbench.renderers.refreshFileRenderer(b.id);
|
|
1269
|
+
return d;
|
|
1270
|
+
}
|
|
1271
|
+
}), s = e.workbench.renderers.registerTreeRenderer({
|
|
1272
|
+
id: t.id,
|
|
1273
|
+
title: u(t.title, t.id),
|
|
1274
|
+
icon: t.icon,
|
|
1275
|
+
defaultExpandedNodeIds: t.defaultExpandedNodeIds,
|
|
1276
|
+
defaultExpandedSectionIds: t.defaultExpandedSectionIds,
|
|
1277
|
+
getHeader: (a) => Jt({
|
|
1278
|
+
ctx: a,
|
|
1279
|
+
getHostTreeHeaderNodes: e.getHostTreeHeaderNodes,
|
|
1280
|
+
record: t,
|
|
1281
|
+
treeViews: o
|
|
1282
|
+
}),
|
|
1283
|
+
getBody: async (a) => {
|
|
1284
|
+
const c = await U(e, t.bodyCommandId, N(e, t, a));
|
|
1285
|
+
if (!or(c)) return [];
|
|
1286
|
+
const d = nr(c);
|
|
1287
|
+
return d && e.workbench.renderers.setSelectedNode(t.id, d), r.mapSections(c, a);
|
|
1288
|
+
},
|
|
1289
|
+
getFooter: async (a) => {
|
|
1290
|
+
const c = await Zt({
|
|
1291
|
+
ctx: a,
|
|
1292
|
+
getHostTreeFooterNodes: e.getHostTreeFooterNodes,
|
|
1293
|
+
record: t,
|
|
1294
|
+
treeViews: o
|
|
1295
|
+
});
|
|
1296
|
+
if (!t.footerCommandId) return c;
|
|
1297
|
+
const d = await U(e, t.footerCommandId, N(e, t, a));
|
|
1298
|
+
return [...le(d) ? r.mapNodes(d, a) : [], ...c];
|
|
1299
|
+
},
|
|
1300
|
+
getChildren: async (a, c) => {
|
|
1301
|
+
if (!t.childrenCommandId) return a.children ?? [];
|
|
1302
|
+
const d = r.originalNodes.get(a) ?? a, b = await U(e, t.childrenCommandId, N(e, t, c, d));
|
|
1303
|
+
return le(b) ? r.mapNodes(b, c) : [];
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
return {
|
|
1307
|
+
dispose() {
|
|
1308
|
+
s.dispose(), n.dispose();
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
}, ir = (e) => {
|
|
1312
|
+
const t = [];
|
|
1313
|
+
for (const r of e.metadata.treeRenderers ?? [])
|
|
1314
|
+
t.push(sr(e, r));
|
|
1315
|
+
for (const r of e.metadata.views) {
|
|
1316
|
+
const o = er(e, r);
|
|
1317
|
+
o && t.push(o);
|
|
1318
|
+
}
|
|
1319
|
+
return {
|
|
1320
|
+
dispose() {
|
|
1321
|
+
for (let r = t.length - 1; r >= 0; r -= 1) t[r]?.dispose();
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
}, ar = (e) => (t) => ({
|
|
1325
|
+
...we({
|
|
1326
|
+
workbench: t.workbench,
|
|
1327
|
+
hostEvents: t.hostEvents
|
|
1328
|
+
}),
|
|
1329
|
+
// Extension guests speak the SDK resource shape (`type`); normalize to the
|
|
1330
|
+
// workbench shape (`kind` + synthesized uri) the resource registry expects,
|
|
1331
|
+
// mirroring how commands.execute and tree targets normalize their resources.
|
|
1332
|
+
"resource.open": (o) => {
|
|
1333
|
+
const n = o;
|
|
1334
|
+
if (!n.resource) throw new Error("resource.open requires a resource.");
|
|
1335
|
+
return t.workbench.resources.openResource(q(n.resource), n.input);
|
|
1336
|
+
},
|
|
1337
|
+
"commands.execute": async (o) => {
|
|
1338
|
+
const n = o, s = n.resource ?? z(t.placement.resource);
|
|
1339
|
+
return e.executeCommand(n.commandId, {
|
|
1340
|
+
projectId: e.projectId,
|
|
1341
|
+
...n.params ? {
|
|
1342
|
+
params: n.params
|
|
1343
|
+
} : {},
|
|
1344
|
+
...s ? {
|
|
1345
|
+
resource: s
|
|
1346
|
+
} : {},
|
|
1347
|
+
slot: $({
|
|
1348
|
+
id: t.webviewId,
|
|
1349
|
+
kind: e.slotKind,
|
|
1350
|
+
projectId: e.projectId,
|
|
1351
|
+
context: {
|
|
1352
|
+
contributionId: t.webviewId
|
|
1353
|
+
}
|
|
1354
|
+
}),
|
|
1355
|
+
source: "dashboard"
|
|
1356
|
+
});
|
|
1357
|
+
},
|
|
1358
|
+
...e.files ? {
|
|
1359
|
+
"files.upload": e.files.upload,
|
|
1360
|
+
"files.list": e.files.list,
|
|
1361
|
+
"files.delete": e.files.delete
|
|
1362
|
+
} : {}
|
|
1363
|
+
}), Q = (e) => ({
|
|
1364
|
+
title: u(e.title),
|
|
1365
|
+
runtimeUrl: e.runtimeUrl,
|
|
1366
|
+
moduleUrl: e.moduleUrl,
|
|
1367
|
+
styles: e.styles,
|
|
1368
|
+
capabilities: e.capabilities
|
|
1369
|
+
}), G = (e, t) => ({
|
|
1370
|
+
kind: t,
|
|
1371
|
+
uri: `workbench://extension-route/${encodeURIComponent(e.id)}`,
|
|
1372
|
+
id: e.id,
|
|
1373
|
+
label: u(e.label, e.id),
|
|
1374
|
+
metadata: {
|
|
1375
|
+
extensionId: e.extensionId,
|
|
1376
|
+
extensionRouteId: e.id,
|
|
1377
|
+
path: e.path
|
|
1378
|
+
}
|
|
1379
|
+
}), me = (e, t) => e.routes.find((r) => t.id === r.id || t.metadata?.extensionRouteId === r.id), cr = (e) => {
|
|
1380
|
+
if (e.metadata.routes.length === 0) return [];
|
|
1381
|
+
const t = [];
|
|
1382
|
+
e.workbench.resources.getKind(e.routeResourceKind) || t.push(e.workbench.resources.registerKind({
|
|
1383
|
+
kind: e.routeResourceKind,
|
|
1384
|
+
label: "Extension route",
|
|
1385
|
+
icon: "Component"
|
|
1386
|
+
}));
|
|
1387
|
+
for (const r of e.metadata.routes)
|
|
1388
|
+
t.push(e.workbench.layout.registerWidget({
|
|
1389
|
+
id: r.id,
|
|
1390
|
+
title: u(r.label, r.id),
|
|
1391
|
+
area: "main",
|
|
1392
|
+
rendererId: B,
|
|
1393
|
+
singleton: !0,
|
|
1394
|
+
config: Q(r.webview)
|
|
1395
|
+
}));
|
|
1396
|
+
return t.push(e.workbench.resources.registerProvider({
|
|
1397
|
+
id: "workbench.extension.routes",
|
|
1398
|
+
kind: e.routeResourceKind,
|
|
1399
|
+
list: () => e.metadata.routes.map((r) => ({
|
|
1400
|
+
resource: G(r, e.routeResourceKind)
|
|
1401
|
+
}))
|
|
1402
|
+
}), e.workbench.resources.registerOpener({
|
|
1403
|
+
id: "workbench.extension.routes",
|
|
1404
|
+
canOpen: (r) => r.kind === e.routeResourceKind && !!me(e.metadata, r),
|
|
1405
|
+
open: (r, o) => {
|
|
1406
|
+
const n = me(e.metadata, r);
|
|
1407
|
+
if (n)
|
|
1408
|
+
return e.workbench.layout.openWidget(n.id, {
|
|
1409
|
+
replaceActive: o.replaceActive,
|
|
1410
|
+
title: u(n.label, n.id)
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
})), t;
|
|
1414
|
+
}, dr = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, lr = (e, t) => {
|
|
1415
|
+
if (t.action.kind === "dataRenderer") return {
|
|
1416
|
+
kind: "view",
|
|
1417
|
+
widgetId: t.action.dataRendererId
|
|
1418
|
+
};
|
|
1419
|
+
const r = t.action;
|
|
1420
|
+
if (r.kind === "route") {
|
|
1421
|
+
const o = e.metadata.routes.find((n) => n.id === r.route);
|
|
1422
|
+
return o ? {
|
|
1423
|
+
kind: "resource",
|
|
1424
|
+
resource: G(o, e.routeResourceKind)
|
|
1425
|
+
} : void 0;
|
|
1426
|
+
}
|
|
1427
|
+
return r.kind === "command" ? {
|
|
1428
|
+
kind: "command",
|
|
1429
|
+
commandId: r.commandId,
|
|
1430
|
+
args: r.args
|
|
1431
|
+
} : {
|
|
1432
|
+
kind: "command",
|
|
1433
|
+
commandId: `workbench.extension.href.${t.id}`,
|
|
1434
|
+
args: {
|
|
1435
|
+
href: r.href
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
}, mr = (e) => {
|
|
1439
|
+
const t = e.metadata.treeItems ?? [];
|
|
1440
|
+
if (t.length === 0) return [];
|
|
1441
|
+
const r = [], o = /* @__PURE__ */ new Map();
|
|
1442
|
+
for (const n of t) o.set(n.target, [...o.get(n.target) ?? [], n]);
|
|
1443
|
+
for (const [n, s] of o) {
|
|
1444
|
+
const a = `workbench.extension.treeItems.${n}`;
|
|
1445
|
+
r.push(e.workbench.renderers.registerTreeRenderer({
|
|
1446
|
+
id: a,
|
|
1447
|
+
title: "Extensions",
|
|
1448
|
+
getChildren: (c) => c.children ?? [],
|
|
1449
|
+
getBody: () => [{
|
|
1450
|
+
id: "extensions",
|
|
1451
|
+
label: "Extensions",
|
|
1452
|
+
nodes: s.map((c) => ({
|
|
1453
|
+
id: c.id,
|
|
1454
|
+
label: u(c.label, c.id),
|
|
1455
|
+
icon: c.icon,
|
|
1456
|
+
target: lr(e, c)
|
|
1457
|
+
}))
|
|
1458
|
+
}]
|
|
1459
|
+
}), e.workbench.layout.registerWidget({
|
|
1460
|
+
id: a,
|
|
1461
|
+
title: "Extensions",
|
|
1462
|
+
area: It(n),
|
|
1463
|
+
rendererId: a,
|
|
1464
|
+
singleton: !0
|
|
1465
|
+
}));
|
|
1466
|
+
}
|
|
1467
|
+
for (const n of t.filter((s) => s.action.kind === "href")) {
|
|
1468
|
+
const s = n.action;
|
|
1469
|
+
s.kind === "href" && r.push(e.workbench.commands.registerCommand({
|
|
1470
|
+
id: `workbench.extension.href.${n.id}`,
|
|
1471
|
+
label: u(n.label, n.id)
|
|
1472
|
+
}, {
|
|
1473
|
+
execute: (a) => e.openHref?.(dr(a)?.href ?? s.href)
|
|
1474
|
+
}));
|
|
1475
|
+
}
|
|
1476
|
+
return r;
|
|
1477
|
+
}, _ = "extension-route", ur = "extensions", fr = (e) => {
|
|
1478
|
+
for (let t = e.length - 1; t >= 0; t -= 1) e[t]?.dispose();
|
|
1479
|
+
}, X = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, br = (e) => e === void 0 ? void 0 : e, hr = (e) => e === "global" ? "user" : "project", pr = (e, t) => t ? (r) => ({
|
|
1480
|
+
...e(r),
|
|
1481
|
+
...t(r)
|
|
1482
|
+
}) : e, Se = (e, t) => {
|
|
1483
|
+
const r = e.createWebviewHostCapabilities ?? ar({
|
|
1484
|
+
executeCommand: e.executeCommand,
|
|
1485
|
+
files: e.webviewFiles,
|
|
1486
|
+
projectId: e.projectId,
|
|
1487
|
+
slotKind: t
|
|
1488
|
+
});
|
|
1489
|
+
return pr(r, e.createWebviewHostCapabilityOverrides);
|
|
1490
|
+
}, wr = (e, t) => {
|
|
1491
|
+
e.workbench.renderers.getRenderer(B) || t.push(e.workbench.renderers.registerRenderer(dt({
|
|
1492
|
+
createHostCapabilities: Se(e, "view"),
|
|
1493
|
+
createProps: e.createWebviewProps,
|
|
1494
|
+
createTheme: e.createWebviewTheme
|
|
1495
|
+
})));
|
|
1496
|
+
}, gr = (e, t) => t.commands.map((r) => e.workbench.commands.registerCommand({
|
|
1497
|
+
id: r.id,
|
|
1498
|
+
label: u(r.title, r.id),
|
|
1499
|
+
description: u(r.description),
|
|
1500
|
+
params: r.params
|
|
1501
|
+
}, {
|
|
1502
|
+
execute: (o, n) => R(e, r.id, {
|
|
1503
|
+
params: X(o),
|
|
1504
|
+
resource: n?.resource
|
|
1505
|
+
})
|
|
1506
|
+
})), Pe = (e, t) => t?.resource ?? e.workbench.getPrimaryResource(), Ir = (e, t) => e.menuSlotsById ? _t({
|
|
1507
|
+
metadata: e.metadata,
|
|
1508
|
+
menuSlotsById: e.menuSlotsById,
|
|
1509
|
+
menuTargetsById: e.menuTargetsById,
|
|
1510
|
+
createWhenExpression: e.createMenuWhenExpression
|
|
1511
|
+
}).flatMap((o) => [e.workbench.commands.registerCommand(o.command, {
|
|
1512
|
+
execute: (n, s) => R(t, o.targetCommandId, {
|
|
1513
|
+
params: {
|
|
1514
|
+
...o.contribution.params ?? {},
|
|
1515
|
+
...X(n) ?? {}
|
|
1516
|
+
},
|
|
1517
|
+
resource: Pe(e, s),
|
|
1518
|
+
slot: $({
|
|
1519
|
+
id: o.contribution.slotId,
|
|
1520
|
+
kind: "menu",
|
|
1521
|
+
projectId: e.projectId,
|
|
1522
|
+
context: {
|
|
1523
|
+
contributionId: o.contribution.id
|
|
1524
|
+
}
|
|
1525
|
+
})
|
|
1526
|
+
})
|
|
1527
|
+
}), e.workbench.layout.registerMenuItem(o.menuPath, o.menuItem)]) : [], yr = (e, t) => Lt({
|
|
1528
|
+
metadata: e.metadata
|
|
1529
|
+
}).flatMap((o) => [e.workbench.commands.registerCommand(o.command, {
|
|
1530
|
+
execute: (n, s) => R(t, o.targetCommandId, {
|
|
1531
|
+
params: {
|
|
1532
|
+
...o.contribution.params ?? {},
|
|
1533
|
+
...X(n) ?? {}
|
|
1534
|
+
},
|
|
1535
|
+
resource: Pe(e, s),
|
|
1536
|
+
slot: $({
|
|
1537
|
+
id: "workbench.commandPalette",
|
|
1538
|
+
kind: "menu",
|
|
1539
|
+
projectId: e.projectId,
|
|
1540
|
+
context: {
|
|
1541
|
+
contributionId: o.contribution.id
|
|
1542
|
+
}
|
|
1543
|
+
})
|
|
1544
|
+
}),
|
|
1545
|
+
isVisible: () => He(o.contribution.when, e.workbench.getPrimaryResource()?.kind)
|
|
1546
|
+
}), e.workbench.layout.registerMenuItem(Me, o.menuItem)]), kr = (e) => e.metadata.views.flatMap((t) => t.webview ? [e.workbench.layout.registerWidget({
|
|
1547
|
+
id: t.id,
|
|
1548
|
+
title: u(t.title, t.id),
|
|
1549
|
+
area: t.surface === "modal" ? "overlay" : H(t.target),
|
|
1550
|
+
rendererId: B,
|
|
1551
|
+
singleton: !0,
|
|
1552
|
+
resourceKinds: t.resourceKind ? [t.resourceKind] : void 0,
|
|
1553
|
+
config: {
|
|
1554
|
+
...Q(t.webview),
|
|
1555
|
+
...t.surface === "modal" ? {
|
|
1556
|
+
size: "lg",
|
|
1557
|
+
scrollBehavior: "inside",
|
|
1558
|
+
contentHeight: "min(560px, calc(100dvh - 48px))"
|
|
1559
|
+
} : {}
|
|
1560
|
+
}
|
|
1561
|
+
})] : []), vr = (e) => {
|
|
1562
|
+
const t = [], r = e.settingsSectionId ?? ur;
|
|
1563
|
+
e.workbench.settings.getSection(r) || t.push(e.workbench.settings.registerSection({
|
|
1564
|
+
id: r,
|
|
1565
|
+
title: e.settingsSectionTitle ?? "Extensions"
|
|
1566
|
+
}));
|
|
1567
|
+
const o = Object.fromEntries((e.metadata.settingsDefinitions ?? []).map((n) => [n.key, {
|
|
1568
|
+
type: n.type,
|
|
1569
|
+
scope: hr(n.scope),
|
|
1570
|
+
default: br(n.default),
|
|
1571
|
+
enum: n.enum,
|
|
1572
|
+
description: u(n.description)
|
|
1573
|
+
}]));
|
|
1574
|
+
Object.keys(o).length > 0 && t.push(e.workbench.preferences.registerSchema({
|
|
1575
|
+
properties: o
|
|
1576
|
+
}));
|
|
1577
|
+
for (const n of e.metadata.settingsPanels)
|
|
1578
|
+
t.push(e.workbench.settings.registerPanel({
|
|
1579
|
+
id: n.id,
|
|
1580
|
+
title: u(n.title, n.id),
|
|
1581
|
+
kind: "custom",
|
|
1582
|
+
section: r,
|
|
1583
|
+
scope: n.scope,
|
|
1584
|
+
render: (s) => ye({
|
|
1585
|
+
context: {
|
|
1586
|
+
workbench: s.workbench,
|
|
1587
|
+
webviewId: n.id,
|
|
1588
|
+
placement: {
|
|
1589
|
+
...s.placement,
|
|
1590
|
+
contributionId: n.id
|
|
1591
|
+
},
|
|
1592
|
+
hostEvents: Ie(s.workbench, s.placement)
|
|
1593
|
+
},
|
|
1594
|
+
createHostCapabilities: Se(e, "settings"),
|
|
1595
|
+
createProps: e.createWebviewProps ?? (({
|
|
1596
|
+
placement: a
|
|
1597
|
+
}) => ({
|
|
1598
|
+
placement: a,
|
|
1599
|
+
resource: a.resource
|
|
1600
|
+
})),
|
|
1601
|
+
createTheme: e.createWebviewTheme,
|
|
1602
|
+
ownerId: n.extensionId,
|
|
1603
|
+
title: u(n.title, n.id),
|
|
1604
|
+
webview: Q(n.webview)
|
|
1605
|
+
})
|
|
1606
|
+
}));
|
|
1607
|
+
return t;
|
|
1608
|
+
}, Rr = (e) => {
|
|
1609
|
+
const t = /* @__PURE__ */ new Set();
|
|
1610
|
+
for (const o of e.metadata.views) o.resourceKind && t.add(o.resourceKind);
|
|
1611
|
+
for (const o of e.metadata.dataRenderers ?? []) o.resourceKind && t.add(o.resourceKind);
|
|
1612
|
+
const r = [];
|
|
1613
|
+
for (const o of t)
|
|
1614
|
+
e.workbench.resources.getKind(o) || r.push(e.workbench.resources.registerKind({
|
|
1615
|
+
kind: o,
|
|
1616
|
+
label: o,
|
|
1617
|
+
icon: "FileText",
|
|
1618
|
+
surface: "primary"
|
|
1619
|
+
})), r.push(e.workbench.resources.registerOpener({
|
|
1620
|
+
id: `workbench.extension.resource.${o}`,
|
|
1621
|
+
canOpen: (n) => n.kind === o,
|
|
1622
|
+
open: (n) => e.metadata.views.filter((a) => a.resourceKind === o && a.surface !== "modal").map((a) => e.workbench.layout.openWidget(a.id, {
|
|
1623
|
+
resource: n,
|
|
1624
|
+
title: n.label ?? n.id ?? n.uri
|
|
1625
|
+
}))
|
|
1626
|
+
}));
|
|
1627
|
+
return r;
|
|
1628
|
+
}, Cr = (e, t) => {
|
|
1629
|
+
if (t === !0) {
|
|
1630
|
+
e.layout.resetAreas();
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
if (Array.isArray(t))
|
|
1634
|
+
for (const r of t) e.layout.clearArea(ke(r));
|
|
1635
|
+
}, Er = (e, t) => {
|
|
1636
|
+
t.view && e.layout.openWidget(t.view, {
|
|
1637
|
+
area: ke(t.target),
|
|
1638
|
+
pinned: t.pinned,
|
|
1639
|
+
title: u(t.title)
|
|
1640
|
+
});
|
|
1641
|
+
}, xr = (e, t, r) => {
|
|
1642
|
+
if (!r.resource) return;
|
|
1643
|
+
const o = e.metadata.routes.find((n) => n.id === r.resource || n.path === r.resource);
|
|
1644
|
+
o && t.resources.openResource(G(o, e.routeResourceKind ?? _));
|
|
1645
|
+
}, Ar = (e, t, r) => {
|
|
1646
|
+
Cr(t, r.layout?.reset);
|
|
1647
|
+
for (const o of r.layout?.open ?? [])
|
|
1648
|
+
Er(t, o), xr(e, t, o);
|
|
1649
|
+
}, Wr = (e) => e.metadata.modes.map((t) => e.workbench.modes.registerMode({
|
|
1650
|
+
id: t.modeId,
|
|
1651
|
+
label: u(t.label, t.modeId),
|
|
1652
|
+
activate: (r) => {
|
|
1653
|
+
Ar(e, r, t);
|
|
1654
|
+
}
|
|
1655
|
+
})), _r = (e) => {
|
|
1656
|
+
const t = [], r = e;
|
|
1657
|
+
return wr(e, t), t.push(...gr(r, e.metadata)), t.push(...Ir(e, r)), t.push(...yr(e, r)), t.push(ir(e)), t.push(Xt(e)), t.push(...kr(e)), t.push(Mt(r, e.metadata.dataRenderers ?? [])), t.push(ht(r, e.metadata.commandPaletteResources ?? [])), t.push(...vr(e)), t.push(...cr({
|
|
1658
|
+
metadata: e.metadata,
|
|
1659
|
+
routeResourceKind: e.routeResourceKind ?? _,
|
|
1660
|
+
workbench: e.workbench
|
|
1661
|
+
})), t.push(...mr({
|
|
1662
|
+
metadata: e.metadata,
|
|
1663
|
+
openHref: e.openHref,
|
|
1664
|
+
routeResourceKind: e.routeResourceKind ?? _,
|
|
1665
|
+
workbench: e.workbench
|
|
1666
|
+
})), t.push(...Rr(e)), t.push(...Wr(e)), {
|
|
1667
|
+
dispose() {
|
|
1668
|
+
fr(t);
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
}, Sr = (e) => new Set((e.treeRenderers ?? []).flatMap((t) => [t.bodyCommandId, t.childrenCommandId, t.footerCommandId].filter((r) => r))), Pr = (e) => new Set((e.dataRenderers ?? []).map((t) => t.queryCommandId)), ue = (e, t) => {
|
|
1672
|
+
const r = e.layout.getLayout();
|
|
1673
|
+
for (const o of Object.values(r.areas)) {
|
|
1674
|
+
const n = o.widgets.find((s) => s.contributionId === t);
|
|
1675
|
+
if (n) return n;
|
|
1676
|
+
}
|
|
1677
|
+
}, Tr = (e, t) => {
|
|
1678
|
+
if (t)
|
|
1679
|
+
try {
|
|
1680
|
+
e.layout.activateWidget(t);
|
|
1681
|
+
} catch {
|
|
1682
|
+
}
|
|
1683
|
+
}, jr = (e, t) => !Sr(e).has(t), Kr = (e, t) => !Pr(e).has(t), Br = (e, t) => {
|
|
1684
|
+
const r = e.layout.getLayout().activeWidgetId;
|
|
1685
|
+
for (const o of t.views) {
|
|
1686
|
+
if (!o.webview || o.surface === "modal") continue;
|
|
1687
|
+
const n = ue(e, o.id);
|
|
1688
|
+
n && e.layout.openWidget(o.id, {
|
|
1689
|
+
resource: n.resource,
|
|
1690
|
+
title: u(o.title, n.title)
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
for (const o of t.routes) {
|
|
1694
|
+
if (!o.webview) continue;
|
|
1695
|
+
const n = ue(e, o.id);
|
|
1696
|
+
n && e.layout.openWidget(o.id, {
|
|
1697
|
+
resource: n.resource,
|
|
1698
|
+
title: u(o.label, n.title)
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
Tr(e, r);
|
|
1702
|
+
}, Lr = (e, t, r) => {
|
|
1703
|
+
if (Br(e, t), jr(t, r))
|
|
1704
|
+
for (const o of t.treeRenderers ?? []) e.renderers.refresh(o.id);
|
|
1705
|
+
if (Kr(t, r))
|
|
1706
|
+
for (const o of t.dataRenderers ?? []) e.renderers.refreshDataRenderer(o.id);
|
|
1707
|
+
};
|
|
1708
|
+
export {
|
|
1709
|
+
B as BRIDGE_WEBVIEW_RENDERER_ID,
|
|
1710
|
+
Lt as buildWorkbenchExtensionCommandPaletteRegistrations,
|
|
1711
|
+
_t as buildWorkbenchExtensionMenuRegistrations,
|
|
1712
|
+
Fr as buildWorkbenchExtensionRouteEntries,
|
|
1713
|
+
dt as createBridgeWebviewRenderer,
|
|
1714
|
+
rt as createTerminalSessionCapability,
|
|
1715
|
+
we as createWorkbenchWebviewHostCapabilities,
|
|
1716
|
+
Ur as emptyWorkbenchExtensionMetadata,
|
|
1717
|
+
Br as refreshOpenWorkbenchExtensionWebviews,
|
|
1718
|
+
Lr as refreshWorkbenchExtensionContributions,
|
|
1719
|
+
ht as registerWorkbenchExtensionCommandPaletteResources,
|
|
1720
|
+
_r as registerWorkbenchExtensionContributions,
|
|
1721
|
+
Nr as registerWorkbenchExtensionControlsRenderers,
|
|
1722
|
+
Mt as registerWorkbenchExtensionDataRenderers,
|
|
1723
|
+
Xt as registerWorkbenchExtensionFileRenderers,
|
|
1724
|
+
ir as registerWorkbenchExtensionTreeRenderers,
|
|
1725
|
+
ye as renderBridgeWebviewFrame,
|
|
1726
|
+
jr as shouldRefreshWorkbenchExtensionTrees
|
|
1727
|
+
};
|
|
1728
|
+
//# sourceMappingURL=extensions.js.map
|