@forgeax/app-shell 0.25.0 → 0.27.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/dock.d.ts +37 -1
- package/dist/dock.js +84 -0
- package/package.json +1 -1
package/dist/dock.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ type Region = typeof REGIONS[number];
|
|
|
3
3
|
declare const DOCK_REGIONS: readonly ["DockShell", "AuxBar", "ChatDock"];
|
|
4
4
|
type DockRegion = typeof DOCK_REGIONS[number];
|
|
5
5
|
declare function isDockRegion(value: string): value is DockRegion;
|
|
6
|
+
interface DockReadyCleanup {
|
|
7
|
+
/** Register one teardown while active; late registrations are disposed immediately. */
|
|
8
|
+
add(dispose: () => void): boolean;
|
|
9
|
+
/** Dispose registered teardowns once, in reverse registration order. */
|
|
10
|
+
dispose(): void;
|
|
11
|
+
}
|
|
12
|
+
/** Own the best-effort teardown lifecycle of one dock-ready session. */
|
|
13
|
+
declare function createDockReadyCleanup(): DockReadyCleanup;
|
|
6
14
|
interface PanelDescriptorLite {
|
|
7
15
|
defaultRegion?: DockRegion;
|
|
8
16
|
}
|
|
@@ -109,6 +117,34 @@ type DesignedDockPanelPosition = {
|
|
|
109
117
|
* Returns undefined when the panel is absent or no live sibling can anchor it.
|
|
110
118
|
*/
|
|
111
119
|
declare function designedDockPanelPosition(layout: AuthoredDockLayoutLike, panelId: string, isOpen: (id: string) => boolean): DesignedDockPanelPosition | undefined;
|
|
120
|
+
interface DockCommandPanel {
|
|
121
|
+
close(): void;
|
|
122
|
+
setActive(): void;
|
|
123
|
+
}
|
|
124
|
+
interface DockPanelCommandAdapter {
|
|
125
|
+
getPanel(id: string): DockCommandPanel | undefined;
|
|
126
|
+
addPanel(options: {
|
|
127
|
+
id: string;
|
|
128
|
+
component: string;
|
|
129
|
+
title: string;
|
|
130
|
+
position?: {
|
|
131
|
+
referencePanel?: string;
|
|
132
|
+
direction: DockReopenDirection;
|
|
133
|
+
};
|
|
134
|
+
}): void;
|
|
135
|
+
canOpen(id: string): boolean;
|
|
136
|
+
titleFor(id: string): string;
|
|
137
|
+
authoredLayout?(): AuthoredDockLayoutLike | undefined;
|
|
138
|
+
fallbackPanelId?(): string | undefined;
|
|
139
|
+
}
|
|
140
|
+
interface DockPanelCommands {
|
|
141
|
+
open(id: string): boolean;
|
|
142
|
+
close(id: string): boolean;
|
|
143
|
+
focus(id: string): boolean;
|
|
144
|
+
reveal(id: string): boolean;
|
|
145
|
+
}
|
|
146
|
+
/** Own idempotent panel commands while callers retain membership and product policy. */
|
|
147
|
+
declare function createDockPanelCommands(adapter: DockPanelCommandAdapter): DockPanelCommands;
|
|
112
148
|
type SideEdge = 'left' | 'right';
|
|
113
149
|
interface RectLike {
|
|
114
150
|
left: number;
|
|
@@ -146,4 +182,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
|
|
|
146
182
|
titleFor?: (panelId: string) => string | undefined;
|
|
147
183
|
}): void;
|
|
148
184
|
|
|
149
|
-
export { type AuthoredDockLayoutLike, type AuthoredDockNodeLike, type CrossInstanceDropEvent, DOCK_REGIONS, type DesignedDockPanelPosition, type DockLayoutOrientation, type DockLayoutPersistence, type DockLayoutPersistenceAdapter, type DockLayoutPersistenceScope, type DockPanelVisibilityEventSource, type DockPanelVisibilityHooks, type DockRegion, type DockRegionEntry, type DockReopenDirection, type DockviewApiLike, type PanelDescriptorLite, REGIONS, type RectLike, type Region, type SerializedDockLayoutLike, type SerializedDockPanelLike, type SideEdge, createDockLayoutPersistence, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, resolveRegion, trackDockPanelVisibility };
|
|
185
|
+
export { type AuthoredDockLayoutLike, type AuthoredDockNodeLike, type CrossInstanceDropEvent, DOCK_REGIONS, type DesignedDockPanelPosition, type DockCommandPanel, type DockLayoutOrientation, type DockLayoutPersistence, type DockLayoutPersistenceAdapter, type DockLayoutPersistenceScope, type DockPanelCommandAdapter, type DockPanelCommands, type DockPanelVisibilityEventSource, type DockPanelVisibilityHooks, type DockReadyCleanup, type DockRegion, type DockRegionEntry, type DockReopenDirection, type DockviewApiLike, type PanelDescriptorLite, REGIONS, type RectLike, type Region, type SerializedDockLayoutLike, type SerializedDockPanelLike, type SideEdge, createDockLayoutPersistence, createDockPanelCommands, createDockReadyCleanup, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, resolveRegion, trackDockPanelVisibility };
|
package/dist/dock.js
CHANGED
|
@@ -4,6 +4,33 @@ var DOCK_REGIONS = ["DockShell", "AuxBar", "ChatDock"];
|
|
|
4
4
|
function isDockRegion(value) {
|
|
5
5
|
return DOCK_REGIONS.includes(value);
|
|
6
6
|
}
|
|
7
|
+
function createDockReadyCleanup() {
|
|
8
|
+
const disposers = [];
|
|
9
|
+
let active = true;
|
|
10
|
+
return {
|
|
11
|
+
add(dispose) {
|
|
12
|
+
if (active) {
|
|
13
|
+
disposers.push(dispose);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
dispose();
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
dispose() {
|
|
23
|
+
if (!active) return;
|
|
24
|
+
active = false;
|
|
25
|
+
while (disposers.length > 0) {
|
|
26
|
+
try {
|
|
27
|
+
disposers.pop()?.();
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
7
34
|
function resolveRegion(id, descriptor, overrides) {
|
|
8
35
|
return overrides[id] ?? descriptor.defaultRegion ?? "DockShell";
|
|
9
36
|
}
|
|
@@ -236,6 +263,61 @@ function designedDockPanelPosition(layout, panelId, isOpen) {
|
|
|
236
263
|
}
|
|
237
264
|
return void 0;
|
|
238
265
|
}
|
|
266
|
+
function createDockPanelCommands(adapter) {
|
|
267
|
+
const panel = (id) => {
|
|
268
|
+
try {
|
|
269
|
+
return adapter.getPanel(id);
|
|
270
|
+
} catch {
|
|
271
|
+
return void 0;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const focus = (id) => {
|
|
275
|
+
const target = panel(id);
|
|
276
|
+
if (!target) return false;
|
|
277
|
+
try {
|
|
278
|
+
target.setActive();
|
|
279
|
+
return true;
|
|
280
|
+
} catch {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
const open = (id) => {
|
|
285
|
+
if (panel(id)) return false;
|
|
286
|
+
try {
|
|
287
|
+
if (!adapter.canOpen(id)) return false;
|
|
288
|
+
const layout = adapter.authoredLayout?.();
|
|
289
|
+
const designed = layout ? designedDockPanelPosition(layout, id, (candidate) => panel(candidate) !== void 0) : void 0;
|
|
290
|
+
const referencePanel = designed?.kind === "relative" ? designed.referencePanel : designed === void 0 ? adapter.fallbackPanelId?.() : void 0;
|
|
291
|
+
adapter.addPanel({
|
|
292
|
+
id,
|
|
293
|
+
component: id,
|
|
294
|
+
title: adapter.titleFor(id),
|
|
295
|
+
position: designed?.kind === "edge" ? { direction: designed.direction } : referencePanel ? { referencePanel, direction: designed?.direction ?? "right" } : void 0
|
|
296
|
+
});
|
|
297
|
+
return true;
|
|
298
|
+
} catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
return {
|
|
303
|
+
open,
|
|
304
|
+
close(id) {
|
|
305
|
+
const target = panel(id);
|
|
306
|
+
if (!target) return false;
|
|
307
|
+
try {
|
|
308
|
+
target.close();
|
|
309
|
+
return true;
|
|
310
|
+
} catch {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
focus,
|
|
315
|
+
reveal(id) {
|
|
316
|
+
if (!panel(id) && !open(id)) return false;
|
|
317
|
+
return focus(id);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
239
321
|
function isOnSideEdge(location) {
|
|
240
322
|
return location.type === "edge" && (location.position === "left" || location.position === "right");
|
|
241
323
|
}
|
|
@@ -291,6 +373,8 @@ export {
|
|
|
291
373
|
DOCK_REGIONS,
|
|
292
374
|
REGIONS,
|
|
293
375
|
createDockLayoutPersistence,
|
|
376
|
+
createDockPanelCommands,
|
|
377
|
+
createDockReadyCleanup,
|
|
294
378
|
designedDockPanelPosition,
|
|
295
379
|
getDockRegions,
|
|
296
380
|
getDockviewApi,
|