@pstdio/workbench 0.7.1 → 0.8.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,17 +1,21 @@
1
- import { c as m, w as $ } from "./workbench-menu-paths-Bb0ICxeG.js";
2
- import { w as p, r as Y } from "./layout-types-DMoZz38-.js";
3
- import { r as ee, l as te, g as ie } from "./surface-map-C1pOTUmF.js";
4
- import { devtools as ne } from "zustand/middleware";
5
- import { createStore as oe } from "zustand/vanilla";
6
- const re = (e, i) => Object.is(e, i), W = (e) => {
7
- const i = oe()(ne(() => e.initialState, {
1
+ import { c as m, j as X, i as Y, s as ee, w as $ } from "./workbench-menu-paths-D-e7iscN.js";
2
+ import { w as p, r as te } from "./layout-types-DMoZz38-.js";
3
+ import { r as ie, l as ne, g as oe } from "./surface-map-C1pOTUmF.js";
4
+ import { devtools as re } from "zustand/middleware";
5
+ import { createStore as se } from "zustand/vanilla";
6
+ const ce = "workbench.core", V = (e = {}) => ({
7
+ source: e.source ?? "module",
8
+ ownerId: e.ownerId ?? ce,
9
+ priority: e.priority ?? 0
10
+ }), x = (e, i) => i.priority - e.priority || e.ownerId.localeCompare(i.ownerId), ae = (e, i) => Object.is(e, i), W = (e) => {
11
+ const i = se()(re(() => e.initialState, {
8
12
  name: e.name ?? "workbench.store"
9
- })), t = (r, s, n = {}) => {
10
- const o = n.equalityFn ?? re;
11
- let a = r(i.getState());
13
+ })), t = (o, s, n = {}) => {
14
+ const r = n.equalityFn ?? ae;
15
+ let a = o(i.getState());
12
16
  return n.fireImmediately && s(a, a), i.subscribe((c) => {
13
- const d = r(c);
14
- if (o(a, d)) return;
17
+ const d = o(c);
18
+ if (r(a, d)) return;
15
19
  const g = a;
16
20
  a = d, s(d, g);
17
21
  });
@@ -24,51 +28,250 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
24
28
  setState: i.setState,
25
29
  api: i
26
30
  };
27
- }, je = (e, i) => {
31
+ }, de = "workbench.resource.kind", le = "workbench.resource.id", ge = (e) => `workbench.resource.metadata.${e}`, _ = "workbench.selectionResourceUri", ue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", je = (e) => {
32
+ if (!e) return {};
33
+ const i = {
34
+ [de]: e.kind,
35
+ [le]: e.id ?? e.uri
36
+ };
37
+ for (const [t, o] of Object.entries(e.metadata ?? {}))
38
+ ue(o) && (i[ge(t)] = o);
39
+ return i;
40
+ }, Ke = (e) => ({
41
+ [_]: e.uri
42
+ }), Ee = (e) => {
43
+ if (!e) return [];
44
+ const i = e.metadata?.[_];
45
+ return typeof i != "string" || i === e.uri ? [e.uri] : [e.uri, i];
46
+ }, D = (e) => [...e].sort((i, t) => t.priority - i.priority || i.id.localeCompare(t.id)), fe = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", $e = (e = {}) => {
47
+ const i = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), o = e.establishLocation;
48
+ let s = 0;
49
+ const n = W({
50
+ name: "workbench.resources",
51
+ initialState: {
52
+ kinds: {},
53
+ presenters: {},
54
+ providers: {},
55
+ hierarchyProviders: {}
56
+ }
57
+ });
58
+ return {
59
+ store: n,
60
+ registerKind(r, a) {
61
+ const c = n.getState();
62
+ if (c.kinds[r.kind]) throw new Error(`Resource kind already registered: ${r.kind}`);
63
+ const d = {
64
+ ...V(a),
65
+ ...r
66
+ };
67
+ return n.setState({
68
+ ...c,
69
+ kinds: {
70
+ ...c.kinds,
71
+ [r.kind]: d
72
+ }
73
+ }, !1, "registerKind"), m(() => {
74
+ const g = n.getState();
75
+ if (g.kinds[r.kind] !== d) return;
76
+ const {
77
+ [r.kind]: u,
78
+ ...b
79
+ } = g.kinds;
80
+ n.setState({
81
+ ...g,
82
+ kinds: b
83
+ }, !1, "unregisterKind");
84
+ });
85
+ },
86
+ getKind(r) {
87
+ return n.getState().kinds[r];
88
+ },
89
+ getSurface(r) {
90
+ return n.getState().kinds[r.kind]?.surface;
91
+ },
92
+ listKinds() {
93
+ return Object.values(n.getState().kinds).sort(x);
94
+ },
95
+ registerPresenter(r) {
96
+ const a = n.getState();
97
+ if (a.presenters[r.id]) throw new Error(`Resource presenter already registered: ${r.id}`);
98
+ const c = {
99
+ ...r,
100
+ priority: r.priority ?? 0
101
+ };
102
+ return n.setState({
103
+ ...a,
104
+ presenters: {
105
+ ...a.presenters,
106
+ [r.id]: c
107
+ }
108
+ }, !1, "registerPresenter"), m(() => {
109
+ const d = n.getState();
110
+ if (d.presenters[r.id] !== c) return;
111
+ const {
112
+ [r.id]: g,
113
+ ...u
114
+ } = d.presenters;
115
+ n.setState({
116
+ ...d,
117
+ presenters: u
118
+ }, !1, "unregisterPresenter");
119
+ });
120
+ },
121
+ listPresenters() {
122
+ return D(Object.values(n.getState().presenters));
123
+ },
124
+ registerProvider(r) {
125
+ const a = n.getState();
126
+ if (a.providers[r.id]) throw new Error(`Resource provider already registered: ${r.id}`);
127
+ return n.setState({
128
+ ...a,
129
+ providers: {
130
+ ...a.providers,
131
+ [r.id]: r
132
+ }
133
+ }, !1, "registerProvider"), m(() => {
134
+ const c = n.getState();
135
+ if (c.providers[r.id] !== r) return;
136
+ const {
137
+ [r.id]: d,
138
+ ...g
139
+ } = c.providers;
140
+ n.setState({
141
+ ...c,
142
+ providers: g
143
+ }, !1, "unregisterProvider");
144
+ });
145
+ },
146
+ listProviders() {
147
+ return Object.values(n.getState().providers);
148
+ },
149
+ listResources(r) {
150
+ const a = {
151
+ primary: e.getPrimary?.()
152
+ }, c = [];
153
+ for (const d of Object.values(n.getState().providers))
154
+ c.push(...d.list(r, a));
155
+ return c;
156
+ },
157
+ registerHierarchyProvider(r) {
158
+ const a = n.getState();
159
+ if (a.hierarchyProviders[r.id])
160
+ throw new Error(`Resource hierarchy provider already registered: ${r.id}`);
161
+ const c = {
162
+ ...r,
163
+ priority: r.priority ?? 0
164
+ };
165
+ return n.setState({
166
+ ...a,
167
+ hierarchyProviders: {
168
+ ...a.hierarchyProviders,
169
+ [r.id]: c
170
+ }
171
+ }, !1, "registerHierarchyProvider"), m(() => {
172
+ const d = n.getState();
173
+ if (d.hierarchyProviders[r.id] !== c) return;
174
+ const {
175
+ [r.id]: g,
176
+ ...u
177
+ } = d.hierarchyProviders;
178
+ n.setState({
179
+ ...d,
180
+ hierarchyProviders: u
181
+ }, !1, "unregisterHierarchyProvider");
182
+ });
183
+ },
184
+ listHierarchyProviders() {
185
+ return ee(Object.values(n.getState().hierarchyProviders));
186
+ },
187
+ walkHierarchy(r) {
188
+ return r ? X(Object.values(n.getState().hierarchyProviders), r, (c) => {
189
+ for (const d of t) d(c);
190
+ }).map((c) => {
191
+ if (!Y(c)) return c;
192
+ const d = e.resolveView?.(c.viewId);
193
+ return d ? {
194
+ ...c,
195
+ label: d.label,
196
+ icon: d.icon
197
+ } : c;
198
+ }) : [];
199
+ },
200
+ onDidDetectHierarchyCycle(r) {
201
+ return t.add(r), m(() => {
202
+ t.delete(r);
203
+ });
204
+ },
205
+ isOpeningResource() {
206
+ return s > 0;
207
+ },
208
+ async openResource(r, a = {}) {
209
+ const c = n.getState();
210
+ if (!c.kinds[r.kind]) throw new Error(`Unknown resource kind: ${r.kind}`);
211
+ const d = D(Object.values(c.presenters)).find((u) => u.canOpen(r));
212
+ if (!d) throw new Error(`No presenter registered for resource kind: ${r.kind}`);
213
+ s += 1;
214
+ let g;
215
+ try {
216
+ const u = d.open(r, a);
217
+ g = fe(u) ? await u : u, g = o?.(g) ?? g, d.afterOpen?.(r, g, a);
218
+ } finally {
219
+ s -= 1;
220
+ }
221
+ for (const u of i) u(r);
222
+ return g;
223
+ },
224
+ onDidOpenResource(r) {
225
+ return i.add(r), m(() => {
226
+ i.delete(r);
227
+ });
228
+ }
229
+ };
230
+ }, De = (e, i) => {
28
231
  for (const t of Object.values(e.regions)) {
29
- const r = t.widgets.findIndex((s) => s.contributionId === i);
30
- if (r >= 0) return {
232
+ const o = t.widgets.findIndex((s) => s.contributionId === i);
233
+ if (o >= 0) return {
31
234
  regionId: t.id,
32
- index: r,
33
- placement: t.widgets[r]
235
+ index: o,
236
+ placement: t.widgets[o]
34
237
  };
35
238
  }
36
- }, Ke = (e, i, t) => {
37
- for (const r of Object.values(e.regions)) {
38
- const s = r.widgets.findIndex((n) => n.contributionId === i && n.resourceUri === t);
239
+ }, He = (e, i, t) => {
240
+ for (const o of Object.values(e.regions)) {
241
+ const s = o.widgets.findIndex((n) => n.contributionId === i && n.resourceUri === t);
39
242
  if (s >= 0) return {
40
- regionId: r.id,
243
+ regionId: o.id,
41
244
  index: s,
42
- placement: r.widgets[s]
245
+ placement: o.widgets[s]
43
246
  };
44
247
  }
45
- }, se = (e, i) => {
248
+ }, ve = (e, i) => {
46
249
  for (const t of Object.values(e.regions)) {
47
- const r = t.widgets.findIndex((s) => s.widgetId === i);
48
- if (r >= 0) return {
250
+ const o = t.widgets.findIndex((s) => s.widgetId === i);
251
+ if (o >= 0) return {
49
252
  regionId: t.id,
50
- index: r,
51
- placement: t.widgets[r]
253
+ index: o,
254
+ placement: t.widgets[o]
52
255
  };
53
256
  }
54
- }, Ee = (e, i) => {
55
- const t = new Set(Object.values(e.regions).flatMap((r) => r.widgets.map((s) => s.widgetId)));
56
- return Y(t, i);
57
- }, K = (e) => e.widgets.find((i) => i.widgetId === e.activeWidgetId) ?? e.widgets[0], P = (e) => e.role === "location", _ = (e) => e.resourceUri ?? `${e.contributionId}:${e.widgetId}`, E = (e, i, t, r) => {
257
+ }, Be = (e, i) => {
258
+ const t = new Set(Object.values(e.regions).flatMap((o) => o.widgets.map((s) => s.widgetId)));
259
+ return te(t, i);
260
+ }, K = (e) => e.widgets.find((i) => i.widgetId === e.activeWidgetId) ?? e.widgets[0], P = (e) => e.role === "location", F = (e) => e.resourceUri ?? `${e.contributionId}:${e.widgetId}`, E = (e, i, t, o) => {
58
261
  if (!i) return e;
59
- const s = _(i), o = {
262
+ const s = F(i), r = {
60
263
  ...e.locationSubPanelSelections?.[s] ?? {}
61
264
  };
62
- return r ? o[t] = r : delete o[t], {
265
+ return o ? r[t] = o : delete r[t], {
63
266
  ...e,
64
267
  locationSubPanelSelections: {
65
268
  ...e.locationSubPanelSelections,
66
- [s]: o
269
+ [s]: r
67
270
  }
68
271
  };
69
- }, F = (e, i) => {
272
+ }, N = (e, i) => {
70
273
  if (!e.locationSubPanelSelections) return e;
71
- const t = Object.fromEntries(Object.entries(e.locationSubPanelSelections).map(([r, s]) => [r, Object.fromEntries(Object.entries(s).filter(([, n]) => n !== i))]));
274
+ const t = Object.fromEntries(Object.entries(e.locationSubPanelSelections).map(([o, s]) => [o, Object.fromEntries(Object.entries(s).filter(([, n]) => n !== i))]));
72
275
  return {
73
276
  ...e,
74
277
  locationSubPanelSelections: t
@@ -76,17 +279,18 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
76
279
  }, k = (e) => {
77
280
  const i = e.regions.main.widgets.filter(P);
78
281
  return i.find((t) => t.widgetId === e.activeLocationWidgetId) ?? i.at(-1);
79
- }, $e = (e, i, t) => {
80
- const r = {
282
+ }, Te = (e, i, t) => {
283
+ const o = {
81
284
  ...e
82
285
  };
83
- return t.resource ? (r.resource = t.resource, r.resourceUri = t.resource.uri, r.title = t.title ?? t.resource.label ?? i.title) : t.title !== void 0 && (r.title = t.title), t.pinned !== void 0 && (r.pinned = t.pinned), t.closable !== void 0 && (r.closable = t.closable), t.mountStrategy !== void 0 && (r.mountStrategy = t.mountStrategy), t.hiddenByDefault !== void 0 && (r.hiddenByDefault = t.hiddenByDefault), t.tabRetention !== void 0 && (r.tabRetention = t.tabRetention), t.tab !== void 0 && (r.tab = t.tab), t.ownerId !== void 0 && (r.ownerId = t.ownerId), t.source !== void 0 && (r.source = t.source), t.role !== void 0 && (r.role = t.role), r;
84
- }, De = (e, i, t) => ({
286
+ return t.viewId !== void 0 && (o.viewId = t.viewId ?? void 0), t.resource === null ? (o.resource = void 0, o.resourceUri = void 0, o.title = t.title ?? i.title) : t.resource ? (o.resource = t.resource, o.resourceUri = t.resource.uri, o.title = t.title ?? t.resource.label ?? i.title) : t.title !== void 0 && (o.title = t.title), t.pinned !== void 0 && (o.pinned = t.pinned), t.closable !== void 0 && (o.closable = t.closable), t.mountStrategy !== void 0 && (o.mountStrategy = t.mountStrategy), t.hiddenByDefault !== void 0 && (o.hiddenByDefault = t.hiddenByDefault), t.tabRetention !== void 0 && (o.tabRetention = t.tabRetention), t.tab !== void 0 && (o.tab = t.tab), t.ownerId !== void 0 && (o.ownerId = t.ownerId), t.source !== void 0 && (o.source = t.source), t.role !== void 0 && (o.role = t.role), o;
287
+ }, Ve = (e, i, t) => ({
85
288
  widgetId: e,
86
289
  contributionId: i.id,
290
+ viewId: t.viewId ?? void 0,
87
291
  ownerId: t.ownerId ?? i.ownerId,
88
292
  source: t.source ?? i.source,
89
- resource: t.resource,
293
+ resource: t.resource ?? void 0,
90
294
  resourceUri: t.resource?.uri,
91
295
  title: t.title ?? t.resource?.label ?? i.title,
92
296
  pinned: t.pinned,
@@ -98,8 +302,8 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
98
302
  tabRetention: t.tabRetention,
99
303
  tab: t.tab ?? i.tab,
100
304
  role: t.role ?? "content"
101
- }), He = (e, i, t, r = {}) => {
102
- const s = e.regions[i], n = t(s.widgets), o = r.activeWidgetId !== void 0 ? r.activeWidgetId : r.clearActiveWidget ? void 0 : s.activeWidgetId;
305
+ }), _e = (e, i, t, o = {}) => {
306
+ const s = e.regions[i], n = t(s.widgets), r = o.activeWidgetId !== void 0 ? o.activeWidgetId : o.clearActiveWidget ? void 0 : s.activeWidgetId;
103
307
  return {
104
308
  ...e,
105
309
  activeLocationWidgetId: i === "main" && !n.some((a) => a.widgetId === e.activeLocationWidgetId) ? n.filter(P).at(-1)?.widgetId : e.activeLocationWidgetId,
@@ -108,32 +312,32 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
108
312
  [i]: {
109
313
  ...s,
110
314
  widgets: n,
111
- activeWidgetId: o
315
+ activeWidgetId: r
112
316
  }
113
317
  }
114
318
  };
115
- }, Be = (e, i) => {
319
+ }, Fe = (e, i) => {
116
320
  let t = e;
117
321
  for (const s of Object.values(e.regions)) {
118
- const n = s.widgets.filter((c) => c.contributionId === i), o = s.widgets.filter((c) => c.contributionId !== i);
119
- if (o.length === s.widgets.length) continue;
120
- const a = s.activeWidgetId && !o.some((c) => c.widgetId === s.activeWidgetId) ? void 0 : s.activeWidgetId;
322
+ const n = s.widgets.filter((c) => c.contributionId === i), r = s.widgets.filter((c) => c.contributionId !== i);
323
+ if (r.length === s.widgets.length) continue;
324
+ const a = s.activeWidgetId && !r.some((c) => c.widgetId === s.activeWidgetId) ? void 0 : s.activeWidgetId;
121
325
  t = {
122
326
  ...t,
123
327
  regions: {
124
328
  ...t.regions,
125
329
  [s.id]: {
126
330
  ...s,
127
- widgets: o,
331
+ widgets: r,
128
332
  activeWidgetId: a
129
333
  }
130
334
  }
131
335
  };
132
336
  for (const c of n)
133
- t = F(t, c.widgetId);
337
+ t = N(t, c.widgetId);
134
338
  }
135
- const r = Object.values(t.regions).some((s) => s.widgets.some((n) => n.widgetId === t.activeWidgetId));
136
- return t.activeWidgetId && (!r || t.activeWidgetId.startsWith(`${i}:`) || t.activeWidgetId === i) && (t = {
339
+ const o = Object.values(t.regions).some((s) => s.widgets.some((n) => n.widgetId === t.activeWidgetId));
340
+ return t.activeWidgetId && (!o || t.activeWidgetId.startsWith(`${i}:`) || t.activeWidgetId === i) && (t = {
137
341
  ...t,
138
342
  activeWidgetId: void 0,
139
343
  activeResourceUri: void 0
@@ -141,20 +345,20 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
141
345
  ...t,
142
346
  activeLocationWidgetId: t.regions.main.widgets.filter(P).at(-1)?.widgetId
143
347
  }), t;
144
- }, Te = (e, i) => {
145
- const t = se(e, i);
348
+ }, Ne = (e, i) => {
349
+ const t = ve(e, i);
146
350
  if (!t) return;
147
- const r = e.regions[t.regionId], s = r.widgets.filter((u) => u.widgetId !== i), n = r.activeWidgetId === i || !r.activeWidgetId && t.index === 0, a = (t.placement.role === "sub-panel" ? s.find((u) => u.role === "sub-panel" && u.ownerResourceUri === t.placement.ownerResourceUri) : void 0) ?? (t.placement.role === "sub-panel" && t.regionId === "main" ? k(e) : s[t.index] ?? s[t.index - 1]), c = n ? a?.widgetId : r.activeWidgetId, d = {
148
- ...r,
351
+ const o = e.regions[t.regionId], s = o.widgets.filter((u) => u.widgetId !== i), n = o.activeWidgetId === i || !o.activeWidgetId && t.index === 0, a = (t.placement.role === "sub-panel" ? s.find((u) => u.role === "sub-panel" && u.ownerResourceUri === t.placement.ownerResourceUri) : void 0) ?? (t.placement.role === "sub-panel" && t.regionId === "main" ? k(e) : s[t.index] ?? s[t.index - 1]), c = n ? a?.widgetId : o.activeWidgetId, d = {
352
+ ...o,
149
353
  widgets: s,
150
354
  activeWidgetId: c
151
355
  };
152
- let g = F({
356
+ let g = N({
153
357
  ...e,
154
358
  activeLocationWidgetId: e.activeLocationWidgetId === i ? e.regions.main.widgets.filter((u) => u.widgetId !== i && P(u)).at(-1)?.widgetId : e.activeLocationWidgetId,
155
359
  regions: {
156
360
  ...e.regions,
157
- [r.id]: d
361
+ [o.id]: d
158
362
  }
159
363
  }, i);
160
364
  return n && t.regionId !== "side" && p.includes(t.regionId) && (g = E(g, k(g), t.regionId, a?.role === "sub-panel" ? a.widgetId : void 0)), e.activeWidgetId === i && (g = {
@@ -167,10 +371,10 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
167
371
  activePlacement: K(d),
168
372
  layout: g
169
373
  };
170
- }, _e = (e, i, t) => {
171
- const r = e.regions[i];
374
+ }, qe = (e, i, t) => {
375
+ const o = e.regions[i];
172
376
  if (i === "main" && P(t)) {
173
- const n = e.locationSubPanelSelections?.[_(t)] ?? {}, o = Object.fromEntries(Object.entries(e.regions).map(([a, c]) => [a, {
377
+ const n = e.locationSubPanelSelections?.[F(t)] ?? {}, r = Object.fromEntries(Object.entries(e.regions).map(([a, c]) => [a, {
174
378
  ...c,
175
379
  widgets: c.widgets.map((d) => !t.resource || d.widgetId === t.widgetId || d.ownerResourceUri !== t.resourceUri || d.resourceUri !== t.resourceUri ? d : {
176
380
  ...d,
@@ -178,8 +382,8 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
178
382
  })
179
383
  }]));
180
384
  for (const a of p) {
181
- const c = o[a], d = n[a], g = c.widgets.find((u) => u.widgetId === d && u.role === "sub-panel" && (!u.ownerResourceUri || u.ownerResourceUri === t.resourceUri));
182
- o[a] = {
385
+ const c = r[a], d = n[a], g = c.widgets.find((u) => u.widgetId === d && u.role === "sub-panel" && (!u.ownerResourceUri || u.ownerResourceUri === t.resourceUri));
386
+ r[a] = {
183
387
  ...c,
184
388
  activeWidgetId: a === "side" ? c.activeWidgetId : g?.widgetId ?? (a === "main" ? t.widgetId : void 0)
185
389
  };
@@ -189,7 +393,7 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
189
393
  activeWidgetId: t.widgetId,
190
394
  activeLocationWidgetId: t.widgetId,
191
395
  activeResourceUri: t.resourceUri,
192
- regions: o
396
+ regions: r
193
397
  };
194
398
  }
195
399
  const s = t.role === "sub-panel" && i !== "side" && p.includes(i) ? E(e, k(e), i, t.widgetId) : e;
@@ -201,16 +405,16 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
201
405
  regions: {
202
406
  ...s.regions,
203
407
  [i]: {
204
- ...r,
408
+ ...o,
205
409
  activeWidgetId: t.widgetId
206
410
  }
207
411
  }
208
412
  };
209
- }, Fe = (e, i, t) => {
210
- const r = e.regions[i], s = t ? r.widgets.find((a) => a.widgetId === t) : void 0;
413
+ }, ze = (e, i, t) => {
414
+ const o = e.regions[i], s = t ? o.widgets.find((a) => a.widgetId === t) : void 0;
211
415
  if (t && !s) throw new Error(`Widget placement not found in ${i}: ${t}`);
212
- if (r.activeWidgetId === t) return;
213
- const n = e.activeWidgetId === r.activeWidgetId, o = {
416
+ if (o.activeWidgetId === t) return;
417
+ const n = e.activeWidgetId === o.activeWidgetId, r = {
214
418
  ...e,
215
419
  activeWidgetId: n ? s?.widgetId : e.activeWidgetId,
216
420
  activeResourceUri: n ? s?.resourceUri : e.activeResourceUri,
@@ -218,60 +422,63 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
218
422
  regions: {
219
423
  ...e.regions,
220
424
  [i]: {
221
- ...r,
425
+ ...o,
222
426
  activeWidgetId: s?.widgetId
223
427
  }
224
428
  }
225
429
  };
226
- return i === "side" || !p.includes(i) ? o : E(o, k(o), i, s?.role === "sub-panel" ? s.widgetId : void 0);
227
- }, ce = (e, i) => !(e.resourceKinds?.length && (!i || !e.resourceKinds.includes(i.kind)) || e.canOpen && (!i || !e.canOpen(i))), Ve = (e, i, t, r = {}) => {
430
+ return i === "side" || !p.includes(i) ? r : E(r, k(r), i, s?.role === "sub-panel" ? s.widgetId : void 0);
431
+ }, be = (e, i) => !(e.resourceKinds?.length && (!i || !e.resourceKinds.includes(i.kind)) || e.canOpen && (!i || !e.canOpen(i))), Qe = (e, i, t, o = {}) => {
228
432
  const s = e.regions[i];
229
- return s.widgets.find((n) => n.widgetId === s.activeWidgetId && n.role === "sub-panel" && (r.ignoreOwnerResourceUri || !n.ownerResourceUri || n.ownerResourceUri === t?.uri));
230
- }, Ne = (e) => k(e), ae = (e, i, t, r) => {
231
- const s = e.eligibleLocations;
232
- return !(!V(e, t) || s?.resourceKinds?.length && (!i || !s.resourceKinds.includes(i.kind)) || s?.resourceIds?.length && (!i?.id || !s.resourceIds.includes(i.id)) || s?.canOpen && (!i || !s.canOpen(i)) || r?.ownerResourceUri && r.ownerResourceUri !== i?.uri);
233
- }, V = (e, i) => {
433
+ return s.widgets.find((n) => n.widgetId === s.activeWidgetId && n.role === "sub-panel" && (o.ignoreOwnerResourceUri || !n.ownerResourceUri || n.ownerResourceUri === t?.uri));
434
+ }, Ge = (e) => k(e), he = (e, i, t, o, s) => {
435
+ const n = e.eligibleLocations;
436
+ return !(!q(e, t) || n?.resourceKinds?.length && (!i || !n.resourceKinds.includes(i.kind)) || n?.resourceIds?.length && (!i?.id || !n.resourceIds.includes(i.id)) || n?.canOpen && (!i || !n.canOpen(i)) || n?.canOpenLocation && !n.canOpenLocation({
437
+ resource: i,
438
+ viewId: s?.viewId
439
+ }) || o?.ownerResourceUri && o.ownerResourceUri !== i?.uri);
440
+ }, q = (e, i) => {
234
441
  const t = e.eligibleLocations?.modeIds;
235
442
  return !t?.length || i !== void 0 && t.includes(i);
236
- }, qe = (e, i, t, r, s = {}) => ce(e, r?.resource ?? i) ? s.ignoreResourceLocation ? V(e, t) : ae(e, i, t, r) : !1, ze = (e, i) => {
237
- const t = e.regions.main.widgets.find((r) => r.widgetId === e.regions.main.activeWidgetId) ?? k(e);
238
- return t ? i.find((r) => r.id === t.contributionId)?.floatingPanels !== "hidden" : !0;
239
- }, Qe = (e, i) => {
443
+ }, Je = (e, i, t, o, s = {}) => be(e, o?.resource ?? i) ? s.ignoreResourceLocation ? q(e, t) : he(e, i, t, o, s.location) : !1, Ze = (e, i) => {
444
+ const t = e.regions.main.widgets.find((o) => o.widgetId === e.regions.main.activeWidgetId) ?? k(e);
445
+ return t ? i.find((o) => o.id === t.contributionId)?.floatingPanels !== "hidden" : !0;
446
+ }, Xe = (e, i) => {
240
447
  const t = e.panelMenuOwner ?? {
241
448
  level: "panel"
242
449
  };
243
450
  return t.contributionId ? (i.subPanel ?? i.locationPanel)?.contributionId === t.contributionId : i.subPanel ? t.level === "sub-panel" : t.level === "panel";
244
- }, de = "workbench.core", N = (e = {}) => ({
245
- source: e.source ?? "module",
246
- ownerId: e.ownerId ?? de,
247
- priority: e.priority ?? 0
248
- }), O = (e, i) => i.priority - e.priority || e.ownerId.localeCompare(i.ownerId), Ge = (e = {}, i) => {
451
+ }, Ye = (e = {}, i) => {
249
452
  const {
250
453
  strategy: t,
251
- ...r
252
- } = e;
454
+ ...o
455
+ } = e, s = o.resource && o.viewId === void 0 ? {
456
+ ...o,
457
+ viewId: null
458
+ } : o;
253
459
  return t ? t.kind === "persistent" ? {
254
- ...r,
460
+ ...s,
255
461
  tabPosition: t.position,
256
462
  tabRetention: "persistent"
257
463
  } : t.kind === "replace-active" ? {
258
- ...r,
464
+ ...s,
259
465
  replaceActive: !0
260
466
  } : t.kind === "replace-panel" ? {
261
- ...r,
467
+ ...s,
262
468
  replaceWidgetId: t.instanceId,
263
469
  tabRetention: t.retention
264
470
  } : {
265
- ...r,
471
+ ...s,
266
472
  tabRetention: "preview",
267
473
  tabPosition: t.position
268
474
  } : {
269
- ...r,
475
+ ...s,
270
476
  tabRetention: i
271
477
  };
272
- }, Je = (e) => ({
478
+ }, et = (e) => ({
273
479
  instanceId: e.widgetId,
274
480
  panelId: e.contributionId,
481
+ viewId: e.viewId,
275
482
  ownerId: e.ownerId,
276
483
  source: e.source,
277
484
  resource: e.resource,
@@ -284,34 +491,34 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
284
491
  hiddenByDefault: e.hiddenByDefault,
285
492
  tabRetention: e.tabRetention,
286
493
  tab: e.tab
287
- }), Xe = (e) => {
494
+ }), tt = (e) => {
288
495
  const {
289
496
  closable: i,
290
497
  ownedPanelMenuIds: t,
291
- ...r
498
+ ...o
292
499
  } = e;
293
- return r;
294
- }, D = (e) => e ? Array.isArray(e) ? [...e] : [e] : [], y = {
500
+ return o;
501
+ }, H = (e) => e ? Array.isArray(e) ? [...e] : [e] : [], y = {
295
502
  main: ["main-header", "main-left-menu", "main", "main-right-menu"],
296
503
  secondary: ["secondary-header", "secondary-left-menu", "secondary", "secondary-right-menu"],
297
504
  side: ["side-header", "side-left-menu", "side", "side-right-menu"]
298
- }, H = Object.values(y).flat(), x = (e) => e.panels ?? p, Ze = (e) => Object.keys(y).find((i) => y[i].some((t) => t === e)), Ye = (e, i) => !e || x(e).includes(i), I = (e, i) => {
505
+ }, B = Object.values(y).flat(), C = (e) => e.panels ?? p, it = (e) => Object.keys(y).find((i) => y[i].some((t) => t === e)), nt = (e, i) => !e || C(e).includes(i), I = (e, i) => {
299
506
  if (i)
300
507
  return Object.values(e.regions).flatMap((t) => t.widgets).find((t) => t.widgetId === i);
301
508
  }, A = (e, i) => {
302
- const t = i.find((r) => r && I(e, r.widgetId));
509
+ const t = i.find((o) => o && I(e, o.widgetId));
303
510
  return {
304
511
  ...e,
305
512
  activeWidgetId: t?.widgetId,
306
513
  activeResourceUri: t?.resourceUri
307
514
  };
308
- }, le = (e, i) => {
515
+ }, me = (e, i) => {
309
516
  if (i.length === 0) return e;
310
- const t = new Set(Object.keys(y).filter((c) => y[c].some((d) => i.includes(d)))), r = i.some((c) => {
517
+ const t = new Set(Object.keys(y).filter((c) => y[c].some((d) => i.includes(d)))), o = i.some((c) => {
311
518
  const d = e.regions[c];
312
519
  return d.widgets.length > 0 || d.activeWidgetId !== void 0 || d.visible;
313
520
  }), s = Object.values(e.locationSubPanelSelections ?? {}).some((c) => Object.keys(c).some((d) => t.has(d)));
314
- if (!r && !s) return e;
521
+ if (!o && !s) return e;
315
522
  const n = {
316
523
  ...e.regions
317
524
  };
@@ -322,24 +529,24 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
322
529
  activeWidgetId: void 0,
323
530
  visible: !1
324
531
  };
325
- const o = Object.fromEntries(Object.entries(e.locationSubPanelSelections ?? {}).map(([c, d]) => [c, Object.fromEntries(Object.entries(d).filter(([g]) => !t.has(g)))])), a = {
532
+ const r = Object.fromEntries(Object.entries(e.locationSubPanelSelections ?? {}).map(([c, d]) => [c, Object.fromEntries(Object.entries(d).filter(([g]) => !t.has(g)))])), a = {
326
533
  ...e,
327
534
  regions: n
328
535
  };
329
536
  return {
330
537
  ...A(a, [I(a, e.activeWidgetId)]),
331
538
  activeLocationWidgetId: I(a, e.activeLocationWidgetId)?.widgetId,
332
- locationSubPanelSelections: o
539
+ locationSubPanelSelections: r
333
540
  };
334
541
  }, U = (e, i) => {
335
- const t = new Set(i), r = Object.keys(y).filter((s) => !t.has(s)).flatMap((s) => y[s]);
336
- return le(e, r);
337
- }, ge = (e, i, t) => {
542
+ const t = new Set(i), o = Object.keys(y).filter((s) => !t.has(s)).flatMap((s) => y[s]);
543
+ return me(e, o);
544
+ }, we = (e, i, t) => {
338
545
  if (!i) {
339
546
  const a = {
340
547
  ...e.regions
341
548
  };
342
- for (const d of H) {
549
+ for (const d of B) {
343
550
  const g = a[d], u = g.widgets.filter((b) => b.role !== "content");
344
551
  a[d] = {
345
552
  ...g,
@@ -356,60 +563,60 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
356
563
  activeLocationWidgetId: I(c, e.activeLocationWidgetId)?.widgetId
357
564
  }, t);
358
565
  }
359
- const r = {
566
+ const o = {
360
567
  ...e.regions
361
568
  };
362
- for (const a of H) r[a] = i.regions[a];
569
+ for (const a of B) o[a] = i.regions[a];
363
570
  const s = U({
364
571
  ...e,
365
- regions: r
366
- }, t), n = I(s, i.activeWidgetId), o = I(s, e.activeWidgetId);
572
+ regions: o
573
+ }, t), n = I(s, i.activeWidgetId), r = I(s, e.activeWidgetId);
367
574
  return {
368
- ...A(s, [n, o]),
575
+ ...A(s, [n, r]),
369
576
  activeLocationWidgetId: I(s, i.activeLocationWidgetId)?.widgetId ?? I(s, e.activeLocationWidgetId)?.widgetId,
370
577
  locationSubPanelSelections: i.locationSubPanelSelections
371
578
  };
372
- }, C = (e) => {
579
+ }, O = (e) => {
373
580
  for (let i = e.length - 1; i >= 0; i -= 1)
374
581
  e[i]?.dispose();
375
- }, B = (e, i) => {
582
+ }, T = (e, i) => {
376
583
  i !== e.layout.getLayout() && e.layout.restoreLayout(i);
377
584
  for (const t of p) e.panels.setOpen(t, i.regions[t].visible);
378
- }, et = (e) => {
585
+ }, ot = (e) => {
379
586
  const i = W({
380
587
  name: "workbench.modes",
381
588
  initialState: {
382
589
  modes: {},
383
590
  activeModeId: void 0
384
591
  }
385
- }), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
386
- let n = [], o, a, c = !1;
592
+ }), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
593
+ let n = [], r, a, c = !1;
387
594
  const d = (l) => {
388
595
  if (t.has(l.id)) return;
389
- const f = D(l.activate(e.resolveContext()));
596
+ const f = H(l.activate(e.resolveContext()));
390
597
  t.set(l.id, f);
391
598
  }, g = (l, f) => {
392
599
  let v = !1, h = () => {
393
600
  };
394
- const S = () => {
601
+ const w = () => {
395
602
  if (v) return;
396
- const w = f.layout.getActivePanel("main");
397
- if (!w) return;
398
- const L = f.layout.getLayout().regions.main.widgets.find((Z) => Z.widgetId === w.instanceId);
399
- L && (L.role === "sub-panel" || L.role === "panel-menu") || (v = !0, h(), e.establishLocation?.(w.instanceId));
603
+ const S = f.layout.getActivePanel("main");
604
+ if (!S) return;
605
+ const L = f.layout.getLayout().regions.main.widgets.find((Z) => Z.widgetId === S.instanceId);
606
+ L && (L.role === "sub-panel" || L.role === "panel-menu") || (v = !0, h(), e.establishLocation?.(S.instanceId));
400
607
  };
401
- h = f.layout.store.subscribeSelector((w) => w.layout.regions.main, S);
608
+ h = f.layout.store.subscribeSelector((S) => S.layout.regions.main, w);
402
609
  try {
403
- l.seed?.(f), S();
610
+ l.seed?.(f), w();
404
611
  } finally {
405
612
  h();
406
613
  }
407
614
  }, u = (l) => {
408
- const f = e.resolveContext(), v = `${l.id}\0${f.layout.getPersistenceScope() ?? "unscoped"}`, h = U(f.layout.getLayout(), x(l));
409
- B(f, h), f.layout.reconcilePanelMenus(), !r.has(v) && !f.layout.enteredWithPersistedLayout() && g(l, f), r.add(v);
615
+ const f = e.resolveContext(), v = `${l.id}\0${f.layout.getPersistenceScope() ?? "unscoped"}`, h = U(f.layout.getLayout(), C(l));
616
+ T(f, h), f.layout.reconcilePanelMenus(), !o.has(v) && !f.layout.enteredWithPersistedLayout() && g(l, f), o.add(v);
410
617
  }, b = (l) => {
411
618
  u(l), l.reconcile?.(e.resolveContext());
412
- }, Q = (l) => {
619
+ }, z = (l) => {
413
620
  const f = e.resolveContext(), v = i.getState().activeModeId, h = f.layout.getPersistenceScope() === void 0;
414
621
  if (v && h && s.set(v, f.layout.getLayout()), R(), l === void 0) {
415
622
  i.setState({
@@ -418,38 +625,38 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
418
625
  }, !1, "deactivateMode");
419
626
  return;
420
627
  }
421
- const S = i.getState().modes[l];
422
- if (!S) throw new Error(`Workbench mode not registered: ${l}`);
423
- h && B(f, ge(f.layout.getLayout(), s.get(l), x(S))), G(l, {
628
+ const w = i.getState().modes[l];
629
+ if (!w) throw new Error(`Workbench mode not registered: ${l}`);
630
+ h && T(f, we(f.layout.getLayout(), s.get(l), C(w))), Q(l, {
424
631
  seed: a !== l
425
632
  });
426
633
  }, R = () => {
427
- C(n), n = [], o?.dispose(), o = void 0;
428
- }, G = (l, f) => {
634
+ O(n), n = [], r?.dispose(), r = void 0;
635
+ }, Q = (l, f) => {
429
636
  const v = e.resolveContext(), h = i.getState().modes[l];
430
637
  if (!h) throw new Error(`Workbench mode not registered: ${l}`);
431
- const S = v.context.createScope("workbench.mode");
432
- S.set("activeWorkbenchMode", l), S.set(`workbenchMode.${l}`, !0), o = S;
638
+ const w = v.context.createScope("workbench.mode");
639
+ w.set("activeWorkbenchMode", l), w.set(`workbenchMode.${l}`, !0), r = w;
433
640
  try {
434
641
  d(h), i.setState({
435
642
  ...i.getState(),
436
643
  activeModeId: l
437
- }, !1, "activateMode"), f.seed && u(h), n = D(h.enter?.(v)), f.seed && h.reconcile?.(e.resolveContext());
438
- } catch (w) {
644
+ }, !1, "activateMode"), f.seed && u(h), n = H(h.enter?.(v)), f.seed && h.reconcile?.(e.resolveContext());
645
+ } catch (S) {
439
646
  throw R(), i.setState({
440
647
  ...i.getState(),
441
648
  activeModeId: void 0
442
- }, !1, "deactivateMode"), w;
649
+ }, !1, "deactivateMode"), S;
443
650
  }
444
- }, J = e.resolveContext().layout.onDidChangePersistenceScope(() => {
651
+ }, G = e.resolveContext().layout.onDidChangePersistenceScope(() => {
445
652
  const l = i.getState().activeModeId;
446
653
  if (l === a) return;
447
654
  const f = l ? i.getState().modes[l] : void 0;
448
655
  f && b(f);
449
- }), X = m(() => {
450
- J.dispose(), R();
451
- for (const l of t.values()) C(l);
452
- t.clear(), r.clear(), s.clear(), i.setState({
656
+ }), J = m(() => {
657
+ G.dispose(), R();
658
+ for (const l of t.values()) O(l);
659
+ t.clear(), o.clear(), s.clear(), i.setState({
453
660
  modes: {},
454
661
  activeModeId: void 0
455
662
  }, !1, "disposeModes");
@@ -457,7 +664,7 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
457
664
  return {
458
665
  store: i,
459
666
  dispose() {
460
- X.dispose();
667
+ J.dispose();
461
668
  },
462
669
  registerMode(l) {
463
670
  const f = i.getState();
@@ -474,16 +681,16 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
474
681
  v.activeModeId === l.id && (R(), i.setState({
475
682
  ...i.getState(),
476
683
  activeModeId: void 0
477
- }, !1, "deactivateMode")), C(t.get(l.id) ?? []), t.delete(l.id), s.delete(l.id);
478
- for (const w of r)
479
- w.startsWith(`${l.id}\0`) && r.delete(w);
684
+ }, !1, "deactivateMode")), O(t.get(l.id) ?? []), t.delete(l.id), s.delete(l.id);
685
+ for (const S of o)
686
+ S.startsWith(`${l.id}\0`) && o.delete(S);
480
687
  const {
481
688
  [l.id]: h,
482
- ...S
689
+ ...w
483
690
  } = v.modes;
484
691
  i.setState({
485
692
  ...i.getState(),
486
- modes: S
693
+ modes: w
487
694
  }, !1, "unregisterMode");
488
695
  });
489
696
  },
@@ -510,7 +717,7 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
510
717
  }
511
718
  c = !0, a = f.deferSeed ? l : void 0;
512
719
  try {
513
- Q(l);
720
+ z(l);
514
721
  } finally {
515
722
  c = !1;
516
723
  }
@@ -529,10 +736,10 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
529
736
  return m(f);
530
737
  }
531
738
  };
532
- }, ue = (e) => Array.isArray(e) ? e : e.trim().split(/\s+/).filter(Boolean), fe = (e) => {
533
- const i = ue(e);
739
+ }, Se = (e) => Array.isArray(e) ? e : e.trim().split(/\s+/).filter(Boolean), Ie = (e) => {
740
+ const i = Se(e);
534
741
  return i.length === 1 ? i[0] ?? "" : i;
535
- }, tt = (e) => {
742
+ }, rt = (e) => {
536
743
  const i = W({
537
744
  name: "workbench.keybindings",
538
745
  initialState: {
@@ -541,115 +748,115 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
541
748
  });
542
749
  return {
543
750
  store: i,
544
- registerKeybinding(t, r) {
751
+ registerKeybinding(t, o) {
545
752
  if (!e.commands.getCommand(t.commandId)) throw new Error(`Keybinding command not registered: ${t.commandId}`);
546
753
  const s = {
547
- ...N(r),
754
+ ...V(o),
548
755
  ...t,
549
- keybinding: fe(t.keybinding)
756
+ keybinding: Ie(t.keybinding)
550
757
  }, n = i.getState();
551
758
  return i.setState({
552
759
  keybindings: [...n.keybindings, s]
553
760
  }, !1, "registerKeybinding"), m(() => {
554
- const o = i.getState(), a = o.keybindings.filter((c) => c !== s);
555
- a.length !== o.keybindings.length && i.setState({
761
+ const r = i.getState(), a = r.keybindings.filter((c) => c !== s);
762
+ a.length !== r.keybindings.length && i.setState({
556
763
  keybindings: a
557
764
  }, !1, "unregisterKeybinding");
558
765
  });
559
766
  },
560
767
  listKeybindings() {
561
- return [...i.getState().keybindings].sort(O);
768
+ return [...i.getState().keybindings].sort(x);
562
769
  },
563
770
  listActiveKeybindings() {
564
- return i.getState().keybindings.filter((t) => e.context.matches(t.when)).sort(O);
771
+ return i.getState().keybindings.filter((t) => e.context.matches(t.when)).sort(x);
565
772
  }
566
773
  };
567
- }, it = (e, i) => K(e.regions[ee(i)])?.resource, nt = ({
774
+ }, st = (e, i) => K(e.regions[ie(i)])?.resource, ct = ({
568
775
  layout: e,
569
776
  primary: i,
570
777
  isInScope: t
571
778
  }) => {
572
- const r = [];
573
- for (const s of te()) {
574
- const n = ie(s);
779
+ const o = [];
780
+ for (const s of ne()) {
781
+ const n = oe(s);
575
782
  if (n.role !== "anchor" || n.persistence === "primary") continue;
576
- const o = K(e.regions[s]);
577
- if (o?.resource) {
578
- if (o.role === "sub-panel" && o.ownerResourceUri) {
579
- r.push({
783
+ const r = K(e.regions[s]);
784
+ if (r?.resource) {
785
+ if (r.role === "sub-panel" && r.ownerResourceUri) {
786
+ o.push({
580
787
  region: s,
581
788
  action: "keep"
582
789
  });
583
790
  continue;
584
791
  }
585
792
  if (n.persistence === "derived") {
586
- r.push({
793
+ o.push({
587
794
  region: s,
588
795
  action: "clear"
589
796
  });
590
797
  continue;
591
798
  }
592
- r.push({
799
+ o.push({
593
800
  region: s,
594
- action: t(o.resource, i) ? "keep" : "clear"
801
+ action: t(r.resource, i) ? "keep" : "clear"
595
802
  });
596
803
  }
597
804
  }
598
- return r;
805
+ return o;
599
806
  }, M = (e, i) => {
600
807
  const {
601
808
  [i]: t,
602
- ...r
809
+ ...o
603
810
  } = e;
604
- return r;
605
- }, ve = () => {
811
+ return o;
812
+ }, ye = () => {
606
813
  if (typeof document > "u")
607
814
  throw new Error("workbench.renderers.registerRenderer({ keepAlive: true }): no DOM available. The default host factory uses document.createElement. In a non-browser environment (Bun tests, SSR), pass a custom factory via createWorkbenchCore({ renderers: { createHost: () => myHost } }).");
608
815
  const e = document.createElement("div");
609
816
  return e.style.display = "contents", e.dataset.workbenchKeepAliveHost = "", e;
610
- }, ot = (e = {}) => {
611
- const i = e.createHost ?? ve, t = W({
817
+ }, at = (e = {}) => {
818
+ const i = e.createHost ?? ye, t = W({
612
819
  name: "workbench.renderers",
613
820
  initialState: {
614
821
  renderers: {},
615
822
  hosts: {},
616
823
  claims: {}
617
824
  }
618
- }), r = (n) => {
619
- const o = t.getState(), a = o.hosts[n], c = a?.attachedTo;
825
+ }), o = (n) => {
826
+ const r = t.getState(), a = r.hosts[n], c = a?.attachedTo;
620
827
  !a || !c || (c.contains(a.host) && c.removeChild(a.host), t.setState({
621
- ...o,
828
+ ...r,
622
829
  hosts: {
623
- ...o.hosts,
830
+ ...r.hosts,
624
831
  [n]: {
625
832
  ...a,
626
833
  attachedTo: void 0
627
834
  }
628
835
  },
629
- claims: M(o.claims, n)
836
+ claims: M(r.claims, n)
630
837
  }, !1, "renderers.detach"));
631
838
  }, s = {
632
839
  store: t,
633
840
  registerRenderer(n) {
634
- const o = t.getState();
635
- if (o.renderers[n.id]) throw new Error(`Renderer already registered: ${n.id}`);
841
+ const r = t.getState();
842
+ if (r.renderers[n.id]) throw new Error(`Renderer already registered: ${n.id}`);
636
843
  const a = n.keepAlive ? i() : void 0, c = a ? {
637
- ...o.hosts,
844
+ ...r.hosts,
638
845
  [n.id]: {
639
846
  rendererId: n.id,
640
847
  host: a
641
848
  }
642
- } : o.hosts;
849
+ } : r.hosts;
643
850
  return t.setState({
644
- ...o,
851
+ ...r,
645
852
  renderers: {
646
- ...o.renderers,
853
+ ...r.renderers,
647
854
  [n.id]: n
648
855
  },
649
856
  hosts: c
650
857
  }, !1, "registerRenderer"), m(() => {
651
858
  if (t.getState().renderers[n.id] !== n) return;
652
- n.keepAlive && r(n.id);
859
+ n.keepAlive && o(n.id);
653
860
  const g = t.getState();
654
861
  t.setState({
655
862
  ...g,
@@ -666,16 +873,16 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
666
873
  return Object.values(t.getState().renderers);
667
874
  },
668
875
  onDidChange(n) {
669
- const o = t.subscribeSelector((a) => a.renderers, () => n());
670
- return m(o);
876
+ const r = t.subscribeSelector((a) => a.renderers, () => n());
877
+ return m(r);
671
878
  },
672
- claim(n, o, a) {
879
+ claim(n, r, a) {
673
880
  const c = t.getState(), d = c.renderers[n];
674
881
  if (!d) throw new Error(`Renderer is not registered: ${n}`);
675
882
  if (!d.keepAlive) throw new Error(`Renderer ${n} is not keep-alive; cannot claim`);
676
883
  const g = c.hosts[n];
677
884
  if (!g) throw new Error(`Renderer ${n} has no host`);
678
- if (g.attachedTo === o)
885
+ if (g.attachedTo === r)
679
886
  t.setState({
680
887
  ...c,
681
888
  claims: {
@@ -684,15 +891,15 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
684
891
  }
685
892
  }, !1, "renderers.updateClaim");
686
893
  else {
687
- r(n);
894
+ o(n);
688
895
  const u = t.getState(), b = u.hosts[n];
689
- o.appendChild(b.host), t.setState({
896
+ r.appendChild(b.host), t.setState({
690
897
  ...u,
691
898
  hosts: {
692
899
  ...u.hosts,
693
900
  [n]: {
694
901
  ...b,
695
- attachedTo: o
902
+ attachedTo: r
696
903
  }
697
904
  },
698
905
  claims: {
@@ -703,7 +910,7 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
703
910
  }
704
911
  return m(() => {
705
912
  const b = t.getState().hosts[n];
706
- !b || b.attachedTo !== o || r(n);
913
+ !b || b.attachedTo !== r || o(n);
707
914
  });
708
915
  },
709
916
  getHost(n) {
@@ -715,230 +922,22 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
715
922
  };
716
923
  for (const n of e.initialRenderers ?? []) s.registerRenderer(n);
717
924
  return s;
718
- }, rt = {
925
+ }, dt = {
719
926
  project: "folder-root",
720
927
  workspace: "computer",
721
928
  worktree: "git-pull-request-draft",
722
929
  settings: "settings",
723
930
  kanbanRenderer: "table-properties"
724
- }, be = "resource_hierarchy_cycle", q = (e) => [...e].sort((i, t) => t.priority - i.priority || i.id.localeCompare(t.id)), he = (e, i, t) => {
725
- const r = q(e), s = [i], n = /* @__PURE__ */ new Set([i.uri]);
726
- let o = i;
727
- for (; ; ) {
728
- const c = r.find((d) => d.canResolve(o))?.getParent(o);
729
- if (!c) break;
730
- if (n.has(c.uri)) {
731
- t({
732
- code: be,
733
- path: [...s],
734
- repeatedUri: c.uri
735
- });
736
- break;
737
- }
738
- s.unshift(c), n.add(c.uri), o = c;
739
- }
740
- return s;
741
- }, me = "workbench.resource.kind", Se = "workbench.resource.id", we = (e) => `workbench.resource.metadata.${e}`, z = "workbench.selectionResourceUri", Ie = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", st = (e) => {
742
- if (!e) return {};
743
- const i = {
744
- [me]: e.kind,
745
- [Se]: e.id ?? e.uri
746
- };
747
- for (const [t, r] of Object.entries(e.metadata ?? {}))
748
- Ie(r) && (i[we(t)] = r);
749
- return i;
750
- }, ct = (e) => ({
751
- [z]: e.uri
752
- }), at = (e) => {
753
- if (!e) return [];
754
- const i = e.metadata?.[z];
755
- return typeof i != "string" || i === e.uri ? [e.uri] : [e.uri, i];
756
- }, T = (e) => [...e].sort((i, t) => t.priority - i.priority || i.id.localeCompare(t.id)), ye = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", dt = (e = {}) => {
757
- const i = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = e.establishLocation;
758
- let s = 0;
759
- const n = W({
760
- name: "workbench.resources",
761
- initialState: {
762
- kinds: {},
763
- presenters: {},
764
- providers: {},
765
- hierarchyProviders: {}
766
- }
767
- });
768
- return {
769
- store: n,
770
- registerKind(o, a) {
771
- const c = n.getState();
772
- if (c.kinds[o.kind]) throw new Error(`Resource kind already registered: ${o.kind}`);
773
- const d = {
774
- ...N(a),
775
- ...o
776
- };
777
- return n.setState({
778
- ...c,
779
- kinds: {
780
- ...c.kinds,
781
- [o.kind]: d
782
- }
783
- }, !1, "registerKind"), m(() => {
784
- const g = n.getState();
785
- if (g.kinds[o.kind] !== d) return;
786
- const {
787
- [o.kind]: u,
788
- ...b
789
- } = g.kinds;
790
- n.setState({
791
- ...g,
792
- kinds: b
793
- }, !1, "unregisterKind");
794
- });
795
- },
796
- getKind(o) {
797
- return n.getState().kinds[o];
798
- },
799
- getSurface(o) {
800
- return n.getState().kinds[o.kind]?.surface;
801
- },
802
- listKinds() {
803
- return Object.values(n.getState().kinds).sort(O);
804
- },
805
- registerPresenter(o) {
806
- const a = n.getState();
807
- if (a.presenters[o.id]) throw new Error(`Resource presenter already registered: ${o.id}`);
808
- const c = {
809
- ...o,
810
- priority: o.priority ?? 0
811
- };
812
- return n.setState({
813
- ...a,
814
- presenters: {
815
- ...a.presenters,
816
- [o.id]: c
817
- }
818
- }, !1, "registerPresenter"), m(() => {
819
- const d = n.getState();
820
- if (d.presenters[o.id] !== c) return;
821
- const {
822
- [o.id]: g,
823
- ...u
824
- } = d.presenters;
825
- n.setState({
826
- ...d,
827
- presenters: u
828
- }, !1, "unregisterPresenter");
829
- });
830
- },
831
- listPresenters() {
832
- return T(Object.values(n.getState().presenters));
833
- },
834
- registerProvider(o) {
835
- const a = n.getState();
836
- if (a.providers[o.id]) throw new Error(`Resource provider already registered: ${o.id}`);
837
- return n.setState({
838
- ...a,
839
- providers: {
840
- ...a.providers,
841
- [o.id]: o
842
- }
843
- }, !1, "registerProvider"), m(() => {
844
- const c = n.getState();
845
- if (c.providers[o.id] !== o) return;
846
- const {
847
- [o.id]: d,
848
- ...g
849
- } = c.providers;
850
- n.setState({
851
- ...c,
852
- providers: g
853
- }, !1, "unregisterProvider");
854
- });
855
- },
856
- listProviders() {
857
- return Object.values(n.getState().providers);
858
- },
859
- listResources(o) {
860
- const a = {
861
- primary: e.getPrimary?.()
862
- }, c = [];
863
- for (const d of Object.values(n.getState().providers))
864
- c.push(...d.list(o, a));
865
- return c;
866
- },
867
- registerHierarchyProvider(o) {
868
- const a = n.getState();
869
- if (a.hierarchyProviders[o.id])
870
- throw new Error(`Resource hierarchy provider already registered: ${o.id}`);
871
- const c = {
872
- ...o,
873
- priority: o.priority ?? 0
874
- };
875
- return n.setState({
876
- ...a,
877
- hierarchyProviders: {
878
- ...a.hierarchyProviders,
879
- [o.id]: c
880
- }
881
- }, !1, "registerHierarchyProvider"), m(() => {
882
- const d = n.getState();
883
- if (d.hierarchyProviders[o.id] !== c) return;
884
- const {
885
- [o.id]: g,
886
- ...u
887
- } = d.hierarchyProviders;
888
- n.setState({
889
- ...d,
890
- hierarchyProviders: u
891
- }, !1, "unregisterHierarchyProvider");
892
- });
893
- },
894
- listHierarchyProviders() {
895
- return q(Object.values(n.getState().hierarchyProviders));
896
- },
897
- walkHierarchy(o) {
898
- return o ? he(Object.values(n.getState().hierarchyProviders), o, (a) => {
899
- for (const c of t) c(a);
900
- }) : [];
901
- },
902
- onDidDetectHierarchyCycle(o) {
903
- return t.add(o), m(() => {
904
- t.delete(o);
905
- });
906
- },
907
- isOpeningResource() {
908
- return s > 0;
909
- },
910
- async openResource(o, a = {}) {
911
- const c = n.getState();
912
- if (!c.kinds[o.kind]) throw new Error(`Unknown resource kind: ${o.kind}`);
913
- const d = T(Object.values(c.presenters)).find((u) => u.canOpen(o));
914
- if (!d) throw new Error(`No presenter registered for resource kind: ${o.kind}`);
915
- s += 1;
916
- let g;
917
- try {
918
- const u = d.open(o, a);
919
- g = ye(u) ? await u : u, g = r?.(g) ?? g, d.afterOpen?.(o, g, a);
920
- } finally {
921
- s -= 1;
922
- }
923
- for (const u of i) u(o);
924
- return g;
925
- },
926
- onDidOpenResource(o) {
927
- return i.add(o), m(() => {
928
- i.delete(o);
929
- });
930
- }
931
- };
932
931
  }, pe = (e) => e.replace(/^['"]|['"]$/g, ""), ke = (e, i) => {
933
932
  const t = i.trim();
934
933
  if (t.length === 0) return !0;
935
- const r = t.match(/^([A-Za-z0-9_.-]+)\s*(==|!=)\s*(.+)$/);
936
- if (r) {
937
- const [, s, n, o] = r, a = e[s ?? ""], c = pe(o ?? "");
934
+ const o = t.match(/^([A-Za-z0-9_.-]+)\s*(==|!=)\s*(.+)$/);
935
+ if (o) {
936
+ const [, s, n, r] = o, a = e[s ?? ""], c = pe(r ?? "");
938
937
  return n === "==" ? String(a) === c : String(a) !== c;
939
938
  }
940
939
  return t.startsWith("!") ? !e[t.slice(1)] : !!e[t];
941
- }, We = (e, i) => i ? i.split("||").some((t) => t.split("&&").every((r) => ke(e, r))) : !0, lt = () => {
940
+ }, We = (e, i) => i ? i.split("||").some((t) => t.split("&&").every((o) => ke(e, o))) : !0, lt = () => {
942
941
  const e = W({
943
942
  name: "workbench.context",
944
943
  initialState: {
@@ -946,23 +945,23 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
946
945
  }
947
946
  });
948
947
  let i = {};
949
- const t = /* @__PURE__ */ new Map(), r = () => {
948
+ const t = /* @__PURE__ */ new Map(), o = () => {
950
949
  const n = {
951
950
  ...i
952
951
  };
953
- for (const o of t.values()) Object.assign(n, o);
952
+ for (const r of t.values()) Object.assign(n, r);
954
953
  return n;
955
954
  }, s = (n) => {
956
955
  e.setState({
957
- values: r()
956
+ values: o()
958
957
  }, !1, n);
959
958
  };
960
959
  return {
961
960
  store: e,
962
- set(n, o) {
963
- i[n] !== o && (i = {
961
+ set(n, r) {
962
+ i[n] !== r && (i = {
964
963
  ...i,
965
- [n]: o
964
+ [n]: r
966
965
  }, s("setContextKey"));
967
966
  },
968
967
  get(n) {
@@ -971,16 +970,16 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
971
970
  delete(n) {
972
971
  if (!(n in i)) return;
973
972
  const {
974
- [n]: o,
973
+ [n]: r,
975
974
  ...a
976
975
  } = i;
977
976
  i = a, s("deleteContextKey");
978
977
  },
979
978
  createScope(n) {
980
979
  t.set(n, t.get(n) ?? {});
981
- let o = !1;
980
+ let r = !1;
982
981
  const a = () => {
983
- if (o) throw new Error(`Context key scope disposed: ${n}`);
982
+ if (r) throw new Error(`Context key scope disposed: ${n}`);
984
983
  };
985
984
  return {
986
985
  ownerId: n,
@@ -1006,7 +1005,7 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
1006
1005
  t.set(n, u), s("deleteScopedContextKey");
1007
1006
  },
1008
1007
  dispose() {
1009
- o || (o = !0, t.delete(n) && s("disposeContextKeyScope"));
1008
+ r || (r = !0, t.delete(n) && s("disposeContextKeyScope"));
1010
1009
  }
1011
1010
  };
1012
1011
  },
@@ -1030,7 +1029,7 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
1030
1029
  id: "workbench.toggleCommandPalette",
1031
1030
  label: "Toggle Command Palette",
1032
1031
  icon: "Command",
1033
- keybinding: "Mod+K",
1032
+ keybinding: "Mod+P",
1034
1033
  execute: (e) => e.commandPalette.toggle()
1035
1034
  }, {
1036
1035
  id: "workbench.action.showCommands",
@@ -1121,55 +1120,54 @@ const re = (e, i) => Object.is(e, i), W = (e) => {
1121
1120
  });
1122
1121
  };
1123
1122
  export {
1124
- ot as A,
1125
- dt as B,
1126
- tt as C,
1127
- et as D,
1123
+ at as A,
1124
+ $e as B,
1125
+ rt as C,
1126
+ ot as D,
1128
1127
  ut as E,
1129
- st as F,
1130
- ct as G,
1131
- ue as H,
1128
+ je as F,
1129
+ Ke as G,
1130
+ Se as H,
1132
1131
  gt as I,
1133
- Ze as J,
1134
- at as K,
1132
+ it as J,
1133
+ Ee as K,
1135
1134
  We as L,
1136
- be as M,
1137
- rt as N,
1138
- Se as O,
1139
- me as P,
1140
- we as Q,
1141
- z as R,
1142
- j as S,
1143
- Ve as T,
1144
- Ne as U,
1145
- V,
1146
- Qe as W,
1147
- ze as X,
1148
- He as a,
1149
- O as b,
1135
+ dt as M,
1136
+ le as N,
1137
+ de as O,
1138
+ ge as P,
1139
+ _ as Q,
1140
+ j as R,
1141
+ Qe as S,
1142
+ Ge as T,
1143
+ q as U,
1144
+ Xe as V,
1145
+ Ze as W,
1146
+ _e as a,
1147
+ x as b,
1150
1148
  W as c,
1151
- F as d,
1152
- $e as e,
1153
- Ke as f,
1149
+ N as d,
1150
+ Te as e,
1151
+ He as f,
1154
1152
  K as g,
1155
1153
  k as h,
1156
- je as i,
1157
- Ee as j,
1158
- De as k,
1159
- se as l,
1160
- Te as m,
1161
- N as n,
1162
- Ge as o,
1163
- Xe as p,
1164
- Fe as q,
1165
- Be as r,
1154
+ De as i,
1155
+ Be as j,
1156
+ Ve as k,
1157
+ ve as l,
1158
+ Ne as m,
1159
+ V as n,
1160
+ Ye as o,
1161
+ tt as p,
1162
+ ze as q,
1163
+ Fe as r,
1166
1164
  E as s,
1167
- Je as t,
1168
- _e as u,
1169
- Ye as v,
1170
- qe as w,
1171
- it as x,
1172
- nt as y,
1165
+ et as t,
1166
+ qe as u,
1167
+ nt as v,
1168
+ Je as w,
1169
+ st as x,
1170
+ ct as y,
1173
1171
  lt as z
1174
1172
  };
1175
- //# sourceMappingURL=workbench-built-ins-BncLJfQA.js.map
1173
+ //# sourceMappingURL=workbench-built-ins-BCJ6-fIM.js.map