@pstdio/workbench 0.10.0 → 0.11.1

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