@forgeax/app-shell 0.24.0 → 0.25.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 +20 -1
- package/dist/dock.js +59 -0
- package/package.json +1 -1
package/dist/dock.d.ts
CHANGED
|
@@ -28,6 +28,24 @@ declare function getDockRegions(): DockRegionEntry[];
|
|
|
28
28
|
/** Track one live mount of a dock panel and return an idempotent release. */
|
|
29
29
|
declare function trackDockPanelVisibility(panelId: string): () => void;
|
|
30
30
|
declare function isDockPanelVisible(panelId: string): boolean;
|
|
31
|
+
interface DockPanelVisibilityEventSource {
|
|
32
|
+
onDidAddPanel(listener: (panel: {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
}) => void): {
|
|
35
|
+
dispose(): void;
|
|
36
|
+
};
|
|
37
|
+
onDidRemovePanel(listener: (panel: {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
}) => void): {
|
|
40
|
+
dispose(): void;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface DockPanelVisibilityHooks {
|
|
44
|
+
readonly onAdded?: (panelId: string) => void;
|
|
45
|
+
readonly onRemoved?: (panelId: string) => void;
|
|
46
|
+
}
|
|
47
|
+
/** Balance one visibility lease per live panel id across an injected event source. */
|
|
48
|
+
declare function installDockPanelVisibilityTracking(source: DockPanelVisibilityEventSource, hooks?: DockPanelVisibilityHooks): () => void;
|
|
31
49
|
declare function hasMountedPanelPlacement(panelIds: readonly string[], mountedPanelIds: ReadonlySet<string>): boolean;
|
|
32
50
|
interface DockLayoutPersistenceScope<Identity> {
|
|
33
51
|
readonly key: string;
|
|
@@ -41,6 +59,7 @@ interface DockLayoutPersistenceAdapter<Layout, Identity> {
|
|
|
41
59
|
interface DockLayoutPersistence<Layout, Identity> {
|
|
42
60
|
restore(scope: DockLayoutPersistenceScope<Identity>, apply: (saved: Layout | null) => void): void;
|
|
43
61
|
save(scope: DockLayoutPersistenceScope<Identity>, layout: Layout): boolean;
|
|
62
|
+
captureAndSave(scope: DockLayoutPersistenceScope<Identity>, capture: () => Layout): boolean;
|
|
44
63
|
clear(scope: DockLayoutPersistenceScope<Identity>): void;
|
|
45
64
|
isRestoring(): boolean;
|
|
46
65
|
}
|
|
@@ -127,4 +146,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
|
|
|
127
146
|
titleFor?: (panelId: string) => string | undefined;
|
|
128
147
|
}): void;
|
|
129
148
|
|
|
130
|
-
export { type AuthoredDockLayoutLike, type AuthoredDockNodeLike, type CrossInstanceDropEvent, DOCK_REGIONS, type DesignedDockPanelPosition, type DockLayoutOrientation, type DockLayoutPersistence, type DockLayoutPersistenceAdapter, type DockLayoutPersistenceScope, 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, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, resolveRegion, trackDockPanelVisibility };
|
|
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 };
|
package/dist/dock.js
CHANGED
|
@@ -42,6 +42,59 @@ function trackDockPanelVisibility(panelId) {
|
|
|
42
42
|
function isDockPanelVisible(panelId) {
|
|
43
43
|
return visibleDockPanels.has(panelId);
|
|
44
44
|
}
|
|
45
|
+
function installDockPanelVisibilityTracking(source, hooks = {}) {
|
|
46
|
+
const releases = /* @__PURE__ */ new Map();
|
|
47
|
+
let active = true;
|
|
48
|
+
const added = source.onDidAddPanel(({ id }) => {
|
|
49
|
+
if (!active) return;
|
|
50
|
+
if (!releases.has(id)) releases.set(id, trackDockPanelVisibility(id));
|
|
51
|
+
try {
|
|
52
|
+
hooks.onAdded?.(id);
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
let removed;
|
|
57
|
+
try {
|
|
58
|
+
removed = source.onDidRemovePanel(({ id }) => {
|
|
59
|
+
if (!active) return;
|
|
60
|
+
try {
|
|
61
|
+
releases.get(id)?.();
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
releases.delete(id);
|
|
65
|
+
try {
|
|
66
|
+
hooks.onRemoved?.(id);
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
active = false;
|
|
72
|
+
try {
|
|
73
|
+
added.dispose();
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
return () => {
|
|
79
|
+
if (!active) return;
|
|
80
|
+
active = false;
|
|
81
|
+
try {
|
|
82
|
+
added.dispose();
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
removed.dispose();
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
releases.forEach((release) => {
|
|
90
|
+
try {
|
|
91
|
+
release();
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
releases.clear();
|
|
96
|
+
};
|
|
97
|
+
}
|
|
45
98
|
function hasMountedPanelPlacement(panelIds, mountedPanelIds) {
|
|
46
99
|
return panelIds.some((id) => mountedPanelIds.has(id));
|
|
47
100
|
}
|
|
@@ -62,6 +115,11 @@ function createDockLayoutPersistence(adapter) {
|
|
|
62
115
|
adapter.save(scope.key, scope.identity, layout);
|
|
63
116
|
return true;
|
|
64
117
|
},
|
|
118
|
+
captureAndSave(scope, capture) {
|
|
119
|
+
if (restoreDepth > 0) return false;
|
|
120
|
+
adapter.save(scope.key, scope.identity, capture());
|
|
121
|
+
return true;
|
|
122
|
+
},
|
|
65
123
|
clear(scope) {
|
|
66
124
|
adapter.remove(scope.key);
|
|
67
125
|
},
|
|
@@ -238,6 +296,7 @@ export {
|
|
|
238
296
|
getDockviewApi,
|
|
239
297
|
handleCrossInstanceDrop,
|
|
240
298
|
hasMountedPanelPlacement,
|
|
299
|
+
installDockPanelVisibilityTracking,
|
|
241
300
|
isDockPanelVisible,
|
|
242
301
|
isDockRegion,
|
|
243
302
|
isOnSideEdge,
|