@forgeax/app-shell 0.36.0 → 0.37.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/dist/chunk-MYY2LEZI.js +709 -0
- package/dist/dock.js +31 -677
- package/dist/react.d.ts +16 -1
- package/dist/react.js +28 -0
- package/package.json +1 -1
package/dist/dock.js
CHANGED
|
@@ -1,680 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function replaceDockReadyAdapters(previous, installers) {
|
|
35
|
-
try {
|
|
36
|
-
previous?.dispose();
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
const cleanup = createDockReadyCleanup();
|
|
40
|
-
try {
|
|
41
|
-
for (const install of installers) {
|
|
42
|
-
const dispose = install();
|
|
43
|
-
if (dispose) cleanup.add(dispose);
|
|
44
|
-
}
|
|
45
|
-
return { ...cleanup, installed: true };
|
|
46
|
-
} catch {
|
|
47
|
-
cleanup.dispose();
|
|
48
|
-
return { ...cleanup, installed: false };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function createDockReadyActivation() {
|
|
52
|
-
let current = null;
|
|
53
|
-
let session = null;
|
|
54
|
-
let generation = 0;
|
|
55
|
-
return {
|
|
56
|
-
getCurrent: () => current,
|
|
57
|
-
replace(value, installers) {
|
|
58
|
-
const candidateGeneration = ++generation;
|
|
59
|
-
current = null;
|
|
60
|
-
const candidate = replaceDockReadyAdapters(session, installers);
|
|
61
|
-
if (candidateGeneration !== generation) {
|
|
62
|
-
candidate.dispose();
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
session = candidate;
|
|
66
|
-
if (!candidate.installed) return false;
|
|
67
|
-
current = value;
|
|
68
|
-
return true;
|
|
69
|
-
},
|
|
70
|
-
dispose() {
|
|
71
|
-
generation += 1;
|
|
72
|
-
current = null;
|
|
73
|
-
session?.dispose();
|
|
74
|
-
session = null;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function createDockScopeTransition(adapter, initial = null) {
|
|
79
|
-
let current = initial;
|
|
80
|
-
let generation = 0;
|
|
81
|
-
let processing = false;
|
|
82
|
-
let pending = null;
|
|
83
|
-
const getLive = () => {
|
|
84
|
-
try {
|
|
85
|
-
return adapter.getLive();
|
|
86
|
-
} catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const enqueue = (next, savePrevious) => {
|
|
91
|
-
const request = { generation: ++generation, next, savePrevious };
|
|
92
|
-
pending = request;
|
|
93
|
-
if (processing) return true;
|
|
94
|
-
processing = true;
|
|
95
|
-
let requestedResult = true;
|
|
96
|
-
let savedPrevious = null;
|
|
97
|
-
try {
|
|
98
|
-
while (pending) {
|
|
99
|
-
const candidate = pending;
|
|
100
|
-
pending = null;
|
|
101
|
-
const previous = current;
|
|
102
|
-
const live = getLive();
|
|
103
|
-
if (pending) {
|
|
104
|
-
if (candidate === request) requestedResult = false;
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (candidate.savePrevious && live && previous !== null && savedPrevious !== previous) {
|
|
108
|
-
try {
|
|
109
|
-
adapter.save(live, previous);
|
|
110
|
-
} catch {
|
|
111
|
-
}
|
|
112
|
-
savedPrevious = previous;
|
|
113
|
-
if (pending) {
|
|
114
|
-
if (candidate === request) requestedResult = false;
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
current = candidate.next;
|
|
119
|
-
if (live) {
|
|
120
|
-
try {
|
|
121
|
-
adapter.apply(live, candidate.next);
|
|
122
|
-
} catch {
|
|
123
|
-
if (candidate === request) requestedResult = false;
|
|
124
|
-
}
|
|
125
|
-
} else if (!candidate.savePrevious && candidate === request) {
|
|
126
|
-
requestedResult = false;
|
|
127
|
-
}
|
|
128
|
-
if (pending && candidate === request) requestedResult = false;
|
|
129
|
-
}
|
|
130
|
-
} finally {
|
|
131
|
-
processing = false;
|
|
132
|
-
}
|
|
133
|
-
return requestedResult;
|
|
134
|
-
};
|
|
135
|
-
return {
|
|
136
|
-
getCurrent: () => current,
|
|
137
|
-
transition: (next) => enqueue(next, true),
|
|
138
|
-
applyCurrent: () => enqueue(current, false)
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function resolveRegion(id, descriptor, overrides) {
|
|
142
|
-
return overrides[id] ?? descriptor.defaultRegion ?? "DockShell";
|
|
143
|
-
}
|
|
144
|
-
var dockviewApis = /* @__PURE__ */ new Map();
|
|
145
|
-
function registerDockviewApi(api) {
|
|
146
|
-
dockviewApis.set(api.id, api);
|
|
147
|
-
return () => {
|
|
148
|
-
if (dockviewApis.get(api.id) === api) dockviewApis.delete(api.id);
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function getDockviewApi(viewId) {
|
|
152
|
-
return dockviewApis.get(viewId);
|
|
153
|
-
}
|
|
154
|
-
var dockRegions = /* @__PURE__ */ new Map();
|
|
155
|
-
function registerDockRegion(entry) {
|
|
156
|
-
dockRegions.set(entry.viewId, entry);
|
|
157
|
-
return () => {
|
|
158
|
-
if (dockRegions.get(entry.viewId) === entry) dockRegions.delete(entry.viewId);
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function getDockRegions() {
|
|
162
|
-
return [...dockRegions.values()];
|
|
163
|
-
}
|
|
164
|
-
var visibleDockPanels = /* @__PURE__ */ new Map();
|
|
165
|
-
function trackDockPanelVisibility(panelId) {
|
|
166
|
-
visibleDockPanels.set(panelId, (visibleDockPanels.get(panelId) ?? 0) + 1);
|
|
167
|
-
let active = true;
|
|
168
|
-
return () => {
|
|
169
|
-
if (!active) return;
|
|
170
|
-
active = false;
|
|
171
|
-
const next = (visibleDockPanels.get(panelId) ?? 1) - 1;
|
|
172
|
-
if (next > 0) visibleDockPanels.set(panelId, next);
|
|
173
|
-
else visibleDockPanels.delete(panelId);
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function isDockPanelVisible(panelId) {
|
|
177
|
-
return visibleDockPanels.has(panelId);
|
|
178
|
-
}
|
|
179
|
-
function installDockPanelVisibilityTracking(source, hooks = {}) {
|
|
180
|
-
const releases = /* @__PURE__ */ new Map();
|
|
181
|
-
let active = true;
|
|
182
|
-
const added = source.onDidAddPanel(({ id }) => {
|
|
183
|
-
if (!active) return;
|
|
184
|
-
if (!releases.has(id)) releases.set(id, trackDockPanelVisibility(id));
|
|
185
|
-
try {
|
|
186
|
-
hooks.onAdded?.(id);
|
|
187
|
-
} catch {
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
let removed;
|
|
191
|
-
try {
|
|
192
|
-
removed = source.onDidRemovePanel(({ id }) => {
|
|
193
|
-
if (!active) return;
|
|
194
|
-
try {
|
|
195
|
-
releases.get(id)?.();
|
|
196
|
-
} catch {
|
|
197
|
-
}
|
|
198
|
-
releases.delete(id);
|
|
199
|
-
try {
|
|
200
|
-
hooks.onRemoved?.(id);
|
|
201
|
-
} catch {
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
} catch (error) {
|
|
205
|
-
active = false;
|
|
206
|
-
try {
|
|
207
|
-
added.dispose();
|
|
208
|
-
} catch {
|
|
209
|
-
}
|
|
210
|
-
throw error;
|
|
211
|
-
}
|
|
212
|
-
return () => {
|
|
213
|
-
if (!active) return;
|
|
214
|
-
active = false;
|
|
215
|
-
try {
|
|
216
|
-
added.dispose();
|
|
217
|
-
} catch {
|
|
218
|
-
}
|
|
219
|
-
try {
|
|
220
|
-
removed.dispose();
|
|
221
|
-
} catch {
|
|
222
|
-
}
|
|
223
|
-
releases.forEach((release) => {
|
|
224
|
-
try {
|
|
225
|
-
release();
|
|
226
|
-
} catch {
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
releases.clear();
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
function hasMountedPanelPlacement(panelIds, mountedPanelIds) {
|
|
233
|
-
return panelIds.some((id) => mountedPanelIds.has(id));
|
|
234
|
-
}
|
|
235
|
-
function createDockLayoutPersistence(adapter) {
|
|
236
|
-
let restoreDepth = 0;
|
|
237
|
-
return {
|
|
238
|
-
restore(scope, apply) {
|
|
239
|
-
const saved = adapter.load(scope.key, scope.identity);
|
|
240
|
-
restoreDepth += 1;
|
|
241
|
-
try {
|
|
242
|
-
apply(saved);
|
|
243
|
-
} finally {
|
|
244
|
-
restoreDepth -= 1;
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
save(scope, layout) {
|
|
248
|
-
if (restoreDepth > 0) return false;
|
|
249
|
-
adapter.save(scope.key, scope.identity, layout);
|
|
250
|
-
return true;
|
|
251
|
-
},
|
|
252
|
-
captureAndSave(scope, capture) {
|
|
253
|
-
if (restoreDepth > 0) return false;
|
|
254
|
-
adapter.save(scope.key, scope.identity, capture());
|
|
255
|
-
return true;
|
|
256
|
-
},
|
|
257
|
-
clear(scope) {
|
|
258
|
-
adapter.remove(scope.key);
|
|
259
|
-
},
|
|
260
|
-
isRestoring() {
|
|
261
|
-
return restoreDepth > 0;
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
function installDockLayoutObservation(source, adapter) {
|
|
266
|
-
let active = true;
|
|
267
|
-
const subscription = source.onDidLayoutChange(() => {
|
|
268
|
-
if (!active) return;
|
|
269
|
-
let scope;
|
|
270
|
-
try {
|
|
271
|
-
scope = adapter.getCurrentScope();
|
|
272
|
-
} catch {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (!active) return;
|
|
276
|
-
if (scope !== null && adapter.captureAndSave) {
|
|
277
|
-
try {
|
|
278
|
-
if (!adapter.captureAndSave(scope)) return;
|
|
279
|
-
} catch {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (!active) return;
|
|
283
|
-
}
|
|
284
|
-
try {
|
|
285
|
-
adapter.onCommitted();
|
|
286
|
-
} catch {
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
return () => {
|
|
290
|
-
if (!active) return;
|
|
291
|
-
active = false;
|
|
292
|
-
try {
|
|
293
|
-
subscription.dispose();
|
|
294
|
-
} catch {
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
function installDockLayoutReset(source, adapter) {
|
|
299
|
-
let active = true;
|
|
300
|
-
let processing = false;
|
|
301
|
-
let pending = false;
|
|
302
|
-
const reset = () => {
|
|
303
|
-
if (!active) return;
|
|
304
|
-
pending = true;
|
|
305
|
-
if (processing) return;
|
|
306
|
-
processing = true;
|
|
307
|
-
try {
|
|
308
|
-
while (active && pending) {
|
|
309
|
-
pending = false;
|
|
310
|
-
let scope;
|
|
311
|
-
try {
|
|
312
|
-
scope = adapter.getCurrentScope();
|
|
313
|
-
} catch {
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
if (!active) break;
|
|
317
|
-
if (pending) continue;
|
|
318
|
-
if (scope !== null) {
|
|
319
|
-
try {
|
|
320
|
-
adapter.clear(scope);
|
|
321
|
-
} catch {
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
if (!active) break;
|
|
325
|
-
if (pending) continue;
|
|
326
|
-
}
|
|
327
|
-
let live;
|
|
328
|
-
try {
|
|
329
|
-
live = adapter.getLive();
|
|
330
|
-
} catch {
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
if (!active) break;
|
|
334
|
-
if (pending) continue;
|
|
335
|
-
if (live) {
|
|
336
|
-
try {
|
|
337
|
-
adapter.apply(live, scope);
|
|
338
|
-
} catch {
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
} finally {
|
|
343
|
-
processing = false;
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
const subscription = source.onReset(reset);
|
|
347
|
-
return () => {
|
|
348
|
-
if (!active) return;
|
|
349
|
-
active = false;
|
|
350
|
-
pending = false;
|
|
351
|
-
try {
|
|
352
|
-
subscription.dispose();
|
|
353
|
-
} catch {
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
function pruneSerializedDockLayout(layout, knownComponents, allowedPanelIds) {
|
|
358
|
-
if (!layout.panels) return layout;
|
|
359
|
-
const removed = new Set(Object.entries(layout.panels).filter(([id, panel]) => !knownComponents.has(panel.contentComponent ?? id) || allowedPanelIds !== void 0 && !allowedPanelIds.has(id)).map(([id]) => id));
|
|
360
|
-
if (removed.size === 0) return layout;
|
|
361
|
-
const panels = Object.fromEntries(
|
|
362
|
-
Object.entries(layout.panels).filter(([id]) => !removed.has(id))
|
|
363
|
-
);
|
|
364
|
-
if (Object.keys(panels).length === 0) return null;
|
|
365
|
-
const pruneNode = (node) => {
|
|
366
|
-
if (!node || typeof node !== "object") return node;
|
|
367
|
-
const value = node;
|
|
368
|
-
if (value.type === "leaf") {
|
|
369
|
-
const data = value.data;
|
|
370
|
-
if (!Array.isArray(data?.views)) return node;
|
|
371
|
-
const views = data.views.filter((id) => !removed.has(id));
|
|
372
|
-
if (views.length === 0) return null;
|
|
373
|
-
return {
|
|
374
|
-
...value,
|
|
375
|
-
data: {
|
|
376
|
-
...data,
|
|
377
|
-
views,
|
|
378
|
-
activeView: views.includes(data.activeView ?? "") ? data.activeView : views[0]
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
if (value.type === "branch" && Array.isArray(value.data)) {
|
|
383
|
-
const children = value.data.map(pruneNode).filter((child) => child !== null);
|
|
384
|
-
return children.length === 0 ? null : { ...value, data: children };
|
|
385
|
-
}
|
|
386
|
-
return node;
|
|
387
|
-
};
|
|
388
|
-
const root = pruneNode(layout.grid?.root);
|
|
389
|
-
if (root === null) return null;
|
|
390
|
-
return {
|
|
391
|
-
...layout,
|
|
392
|
-
panels,
|
|
393
|
-
grid: layout.grid ? { ...layout.grid, root } : layout.grid
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
function authoredLeafViews(node) {
|
|
397
|
-
if (node.type !== "leaf" || !node.data || typeof node.data !== "object") return [];
|
|
398
|
-
const views = node.data.views;
|
|
399
|
-
return Array.isArray(views) ? views : [];
|
|
400
|
-
}
|
|
401
|
-
function authoredBranchChildren(node) {
|
|
402
|
-
return node.type === "branch" && Array.isArray(node.data) ? node.data : [];
|
|
403
|
-
}
|
|
404
|
-
function firstOpenAuthoredPanel(node, isOpen) {
|
|
405
|
-
if (node.type === "leaf") return authoredLeafViews(node).find(isOpen);
|
|
406
|
-
for (const child of authoredBranchChildren(node)) {
|
|
407
|
-
const match = firstOpenAuthoredPanel(child, isOpen);
|
|
408
|
-
if (match) return match;
|
|
409
|
-
}
|
|
410
|
-
return void 0;
|
|
411
|
-
}
|
|
412
|
-
function findAuthoredPanelPath(root, panelId) {
|
|
413
|
-
if (root.type === "leaf") {
|
|
414
|
-
return authoredLeafViews(root).includes(panelId) ? [root] : void 0;
|
|
415
|
-
}
|
|
416
|
-
for (const child of authoredBranchChildren(root)) {
|
|
417
|
-
const path = findAuthoredPanelPath(child, panelId);
|
|
418
|
-
if (path) return [root, ...path];
|
|
419
|
-
}
|
|
420
|
-
return void 0;
|
|
421
|
-
}
|
|
422
|
-
function authoredBranchOrientation(rootOrientation, depth) {
|
|
423
|
-
if (depth % 2 === 0) return rootOrientation;
|
|
424
|
-
return rootOrientation === "HORIZONTAL" ? "VERTICAL" : "HORIZONTAL";
|
|
425
|
-
}
|
|
426
|
-
function designedDockPanelPosition(layout, panelId, isOpen) {
|
|
427
|
-
const root = layout.grid?.root;
|
|
428
|
-
if (!root) return void 0;
|
|
429
|
-
const path = findAuthoredPanelPath(root, panelId);
|
|
430
|
-
if (!path) return void 0;
|
|
431
|
-
const leaf = path[path.length - 1];
|
|
432
|
-
const tabMate = authoredLeafViews(leaf).find((id) => id !== panelId && isOpen(id));
|
|
433
|
-
if (tabMate) return { kind: "relative", referencePanel: tabMate, direction: "within" };
|
|
434
|
-
if (path.length === 2 && path[0].type === "branch") {
|
|
435
|
-
const siblings = authoredBranchChildren(path[0]);
|
|
436
|
-
const index = siblings.indexOf(leaf);
|
|
437
|
-
const horizontal = layout.grid?.orientation === "HORIZONTAL";
|
|
438
|
-
if (index === 0) return { kind: "edge", direction: horizontal ? "left" : "above" };
|
|
439
|
-
if (index === siblings.length - 1) {
|
|
440
|
-
return { kind: "edge", direction: horizontal ? "right" : "below" };
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
for (let depth = path.length - 2; depth >= 0; depth--) {
|
|
444
|
-
const branch = path[depth];
|
|
445
|
-
if (branch.type !== "branch") continue;
|
|
446
|
-
const children = authoredBranchChildren(branch);
|
|
447
|
-
const index = children.indexOf(path[depth + 1]);
|
|
448
|
-
if (index < 0) continue;
|
|
449
|
-
const horizontal = authoredBranchOrientation(layout.grid.orientation, depth) === "HORIZONTAL";
|
|
450
|
-
for (let i = index + 1; i < children.length; i++) {
|
|
451
|
-
const referencePanel = firstOpenAuthoredPanel(children[i], isOpen);
|
|
452
|
-
if (referencePanel) {
|
|
453
|
-
return { kind: "relative", referencePanel, direction: horizontal ? "left" : "above" };
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
for (let i = index - 1; i >= 0; i--) {
|
|
457
|
-
const referencePanel = firstOpenAuthoredPanel(children[i], isOpen);
|
|
458
|
-
if (referencePanel) {
|
|
459
|
-
return { kind: "relative", referencePanel, direction: horizontal ? "right" : "below" };
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
return void 0;
|
|
464
|
-
}
|
|
465
|
-
function createDockPanelCommands(adapter) {
|
|
466
|
-
const panel = (id) => {
|
|
467
|
-
try {
|
|
468
|
-
return adapter.getPanel(id);
|
|
469
|
-
} catch {
|
|
470
|
-
return void 0;
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
const focus = (id) => {
|
|
474
|
-
const target = panel(id);
|
|
475
|
-
if (!target) return false;
|
|
476
|
-
try {
|
|
477
|
-
target.setActive();
|
|
478
|
-
return true;
|
|
479
|
-
} catch {
|
|
480
|
-
return false;
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
const open = (id) => {
|
|
484
|
-
if (panel(id)) return false;
|
|
485
|
-
try {
|
|
486
|
-
if (!adapter.canOpen(id)) return false;
|
|
487
|
-
const layout = adapter.authoredLayout?.();
|
|
488
|
-
const designed = layout ? designedDockPanelPosition(layout, id, (candidate) => panel(candidate) !== void 0) : void 0;
|
|
489
|
-
const referencePanel = designed?.kind === "relative" ? designed.referencePanel : designed === void 0 ? adapter.fallbackPanelId?.() : void 0;
|
|
490
|
-
adapter.addPanel({
|
|
491
|
-
id,
|
|
492
|
-
component: id,
|
|
493
|
-
title: adapter.titleFor(id),
|
|
494
|
-
position: designed?.kind === "edge" ? { direction: designed.direction } : referencePanel ? { referencePanel, direction: designed?.direction ?? "right" } : void 0
|
|
495
|
-
});
|
|
496
|
-
return true;
|
|
497
|
-
} catch {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
return {
|
|
502
|
-
open,
|
|
503
|
-
close(id) {
|
|
504
|
-
const target = panel(id);
|
|
505
|
-
if (!target) return false;
|
|
506
|
-
try {
|
|
507
|
-
target.close();
|
|
508
|
-
return true;
|
|
509
|
-
} catch {
|
|
510
|
-
return false;
|
|
511
|
-
}
|
|
512
|
-
},
|
|
513
|
-
focus,
|
|
514
|
-
reveal(id) {
|
|
515
|
-
if (!panel(id) && !open(id)) return false;
|
|
516
|
-
return focus(id);
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
function installDockPanelCommandSubscriptions(source, commands) {
|
|
521
|
-
const subscriptions = [];
|
|
522
|
-
let active = true;
|
|
523
|
-
const cleanup = () => {
|
|
524
|
-
if (!active) return;
|
|
525
|
-
active = false;
|
|
526
|
-
while (subscriptions.length > 0) {
|
|
527
|
-
try {
|
|
528
|
-
subscriptions.pop()?.dispose();
|
|
529
|
-
} catch {
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
const route = (command) => (panelId) => {
|
|
534
|
-
if (!active) return;
|
|
535
|
-
try {
|
|
536
|
-
command(panelId);
|
|
537
|
-
} catch {
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
try {
|
|
541
|
-
subscriptions.push(source.onOpen(route((id) => commands.open(id))));
|
|
542
|
-
subscriptions.push(source.onClose(route((id) => commands.close(id))));
|
|
543
|
-
subscriptions.push(source.onFocus(route((id) => commands.focus(id))));
|
|
544
|
-
subscriptions.push(source.onReveal(route((id) => commands.reveal(id))));
|
|
545
|
-
} catch (error) {
|
|
546
|
-
cleanup();
|
|
547
|
-
throw error;
|
|
548
|
-
}
|
|
549
|
-
return cleanup;
|
|
550
|
-
}
|
|
551
|
-
function createDockLayoutPanelControl(adapter) {
|
|
552
|
-
const readOpen = (panelId) => {
|
|
553
|
-
try {
|
|
554
|
-
return { ok: true, value: adapter.isOpen(panelId) };
|
|
555
|
-
} catch {
|
|
556
|
-
return { ok: false };
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
return {
|
|
560
|
-
isOpen(panelId) {
|
|
561
|
-
const result = readOpen(panelId);
|
|
562
|
-
return result.ok ? result.value : false;
|
|
563
|
-
},
|
|
564
|
-
toggle(panelId) {
|
|
565
|
-
const result = readOpen(panelId);
|
|
566
|
-
if (!result.ok) return false;
|
|
567
|
-
try {
|
|
568
|
-
if (result.value) adapter.close(panelId);
|
|
569
|
-
else adapter.reopen(panelId);
|
|
570
|
-
return true;
|
|
571
|
-
} catch {
|
|
572
|
-
return false;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
function createDockLayoutControlState(initialAnchor = null) {
|
|
578
|
-
let snapshot = { open: false, anchor: initialAnchor };
|
|
579
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
580
|
-
const commit = (open, anchor, force = false) => {
|
|
581
|
-
if (!force && snapshot.open === open && snapshot.anchor === anchor) return;
|
|
582
|
-
snapshot = { open, anchor };
|
|
583
|
-
for (const listener of [...listeners]) {
|
|
584
|
-
try {
|
|
585
|
-
listener();
|
|
586
|
-
} catch {
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
return {
|
|
591
|
-
getSnapshot: () => snapshot,
|
|
592
|
-
subscribe(listener) {
|
|
593
|
-
listeners.add(listener);
|
|
594
|
-
let subscribed = true;
|
|
595
|
-
return () => {
|
|
596
|
-
if (!subscribed) return;
|
|
597
|
-
subscribed = false;
|
|
598
|
-
listeners.delete(listener);
|
|
599
|
-
};
|
|
600
|
-
},
|
|
601
|
-
refresh: () => commit(snapshot.open, snapshot.anchor, true),
|
|
602
|
-
toggle: (anchor) => commit(
|
|
603
|
-
!snapshot.open,
|
|
604
|
-
anchor === void 0 ? snapshot.anchor : anchor
|
|
605
|
-
),
|
|
606
|
-
close: () => commit(false, snapshot.anchor)
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function installDockLayoutControlToggle(source, state) {
|
|
610
|
-
let active = true;
|
|
611
|
-
const subscription = source.onToggle((anchor) => {
|
|
612
|
-
if (!active) return;
|
|
613
|
-
try {
|
|
614
|
-
state.toggle(anchor);
|
|
615
|
-
} catch {
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
return () => {
|
|
619
|
-
if (!active) return;
|
|
620
|
-
active = false;
|
|
621
|
-
try {
|
|
622
|
-
subscription.dispose();
|
|
623
|
-
} catch {
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
function isOnSideEdge(location) {
|
|
628
|
-
return location.type === "edge" && (location.position === "left" || location.position === "right");
|
|
629
|
-
}
|
|
630
|
-
function nearerSideEdge(panel, shell) {
|
|
631
|
-
const middle = (panel.left + panel.right) / 2;
|
|
632
|
-
return middle - shell.left <= shell.right - middle ? "left" : "right";
|
|
633
|
-
}
|
|
634
|
-
function toDirection(position) {
|
|
635
|
-
switch (position) {
|
|
636
|
-
case "top":
|
|
637
|
-
return "above";
|
|
638
|
-
case "bottom":
|
|
639
|
-
return "below";
|
|
640
|
-
case "left":
|
|
641
|
-
return "left";
|
|
642
|
-
case "right":
|
|
643
|
-
return "right";
|
|
644
|
-
case "center":
|
|
645
|
-
return "within";
|
|
646
|
-
default:
|
|
647
|
-
return void 0;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
function handleCrossInstanceDrop(event, targetRegion, moveTo, options) {
|
|
651
|
-
const transfer = event.getData();
|
|
652
|
-
if (!transfer?.panelId || transfer.viewId === event.api.id) return;
|
|
653
|
-
const sourceApi = getDockviewApi(transfer.viewId);
|
|
654
|
-
if (sourceApi) {
|
|
655
|
-
try {
|
|
656
|
-
sourceApi.getPanel(transfer.panelId)?.api.close();
|
|
657
|
-
} catch {
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
const direction = toDirection(event.position);
|
|
661
|
-
let position;
|
|
662
|
-
if (event.group && direction) {
|
|
663
|
-
position = { referenceGroup: event.group, direction };
|
|
664
|
-
} else if (direction && direction !== "within") {
|
|
665
|
-
position = { direction };
|
|
666
|
-
}
|
|
667
|
-
try {
|
|
668
|
-
event.api.addPanel({
|
|
669
|
-
id: transfer.panelId,
|
|
670
|
-
component: options?.componentFor?.(transfer.panelId) ?? transfer.panelId,
|
|
671
|
-
title: options?.titleFor?.(transfer.panelId),
|
|
672
|
-
...position ? { position } : {}
|
|
673
|
-
});
|
|
674
|
-
} catch {
|
|
675
|
-
}
|
|
676
|
-
moveTo(transfer.panelId, targetRegion);
|
|
677
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DOCK_REGIONS,
|
|
3
|
+
REGIONS,
|
|
4
|
+
createDockLayoutControlState,
|
|
5
|
+
createDockLayoutPanelControl,
|
|
6
|
+
createDockLayoutPersistence,
|
|
7
|
+
createDockPanelCommands,
|
|
8
|
+
createDockReadyActivation,
|
|
9
|
+
createDockReadyCleanup,
|
|
10
|
+
createDockScopeTransition,
|
|
11
|
+
designedDockPanelPosition,
|
|
12
|
+
getDockRegions,
|
|
13
|
+
getDockviewApi,
|
|
14
|
+
handleCrossInstanceDrop,
|
|
15
|
+
hasMountedPanelPlacement,
|
|
16
|
+
installDockLayoutControlToggle,
|
|
17
|
+
installDockLayoutObservation,
|
|
18
|
+
installDockLayoutReset,
|
|
19
|
+
installDockPanelCommandSubscriptions,
|
|
20
|
+
installDockPanelVisibilityTracking,
|
|
21
|
+
isDockPanelVisible,
|
|
22
|
+
isDockRegion,
|
|
23
|
+
isOnSideEdge,
|
|
24
|
+
nearerSideEdge,
|
|
25
|
+
pruneSerializedDockLayout,
|
|
26
|
+
registerDockRegion,
|
|
27
|
+
registerDockviewApi,
|
|
28
|
+
replaceDockReadyAdapters,
|
|
29
|
+
resolveRegion,
|
|
30
|
+
trackDockPanelVisibility
|
|
31
|
+
} from "./chunk-MYY2LEZI.js";
|
|
678
32
|
export {
|
|
679
33
|
DOCK_REGIONS,
|
|
680
34
|
REGIONS,
|