@forgeax/app-shell 0.23.0 → 0.24.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 +22 -1
- package/dist/dock.js +26 -0
- package/package.json +1 -1
package/dist/dock.d.ts
CHANGED
|
@@ -29,6 +29,27 @@ declare function getDockRegions(): DockRegionEntry[];
|
|
|
29
29
|
declare function trackDockPanelVisibility(panelId: string): () => void;
|
|
30
30
|
declare function isDockPanelVisible(panelId: string): boolean;
|
|
31
31
|
declare function hasMountedPanelPlacement(panelIds: readonly string[], mountedPanelIds: ReadonlySet<string>): boolean;
|
|
32
|
+
interface DockLayoutPersistenceScope<Identity> {
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly identity: Identity;
|
|
35
|
+
}
|
|
36
|
+
interface DockLayoutPersistenceAdapter<Layout, Identity> {
|
|
37
|
+
load(key: string, identity: Identity): Layout | null;
|
|
38
|
+
save(key: string, identity: Identity, layout: Layout): void;
|
|
39
|
+
remove(key: string): void;
|
|
40
|
+
}
|
|
41
|
+
interface DockLayoutPersistence<Layout, Identity> {
|
|
42
|
+
restore(scope: DockLayoutPersistenceScope<Identity>, apply: (saved: Layout | null) => void): void;
|
|
43
|
+
save(scope: DockLayoutPersistenceScope<Identity>, layout: Layout): boolean;
|
|
44
|
+
clear(scope: DockLayoutPersistenceScope<Identity>): void;
|
|
45
|
+
isRestoring(): boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Own the load-before-mutation and reentrant-save suppression required by dock
|
|
49
|
+
* layout restoration. Product callers retain key construction, identity,
|
|
50
|
+
* storage, snapshot validation, and concrete Dockview mutation.
|
|
51
|
+
*/
|
|
52
|
+
declare function createDockLayoutPersistence<Layout, Identity>(adapter: DockLayoutPersistenceAdapter<Layout, Identity>): DockLayoutPersistence<Layout, Identity>;
|
|
32
53
|
interface SerializedDockPanelLike {
|
|
33
54
|
readonly contentComponent?: string;
|
|
34
55
|
}
|
|
@@ -106,4 +127,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
|
|
|
106
127
|
titleFor?: (panelId: string) => string | undefined;
|
|
107
128
|
}): void;
|
|
108
129
|
|
|
109
|
-
export { type AuthoredDockLayoutLike, type AuthoredDockNodeLike, type CrossInstanceDropEvent, DOCK_REGIONS, type DesignedDockPanelPosition, type DockLayoutOrientation, type DockRegion, type DockRegionEntry, type DockReopenDirection, type DockviewApiLike, type PanelDescriptorLite, REGIONS, type RectLike, type Region, type SerializedDockLayoutLike, type SerializedDockPanelLike, type SideEdge, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, resolveRegion, trackDockPanelVisibility };
|
|
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 };
|
package/dist/dock.js
CHANGED
|
@@ -45,6 +45,31 @@ function isDockPanelVisible(panelId) {
|
|
|
45
45
|
function hasMountedPanelPlacement(panelIds, mountedPanelIds) {
|
|
46
46
|
return panelIds.some((id) => mountedPanelIds.has(id));
|
|
47
47
|
}
|
|
48
|
+
function createDockLayoutPersistence(adapter) {
|
|
49
|
+
let restoreDepth = 0;
|
|
50
|
+
return {
|
|
51
|
+
restore(scope, apply) {
|
|
52
|
+
const saved = adapter.load(scope.key, scope.identity);
|
|
53
|
+
restoreDepth += 1;
|
|
54
|
+
try {
|
|
55
|
+
apply(saved);
|
|
56
|
+
} finally {
|
|
57
|
+
restoreDepth -= 1;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
save(scope, layout) {
|
|
61
|
+
if (restoreDepth > 0) return false;
|
|
62
|
+
adapter.save(scope.key, scope.identity, layout);
|
|
63
|
+
return true;
|
|
64
|
+
},
|
|
65
|
+
clear(scope) {
|
|
66
|
+
adapter.remove(scope.key);
|
|
67
|
+
},
|
|
68
|
+
isRestoring() {
|
|
69
|
+
return restoreDepth > 0;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
48
73
|
function pruneSerializedDockLayout(layout, knownComponents, allowedPanelIds) {
|
|
49
74
|
if (!layout.panels) return layout;
|
|
50
75
|
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));
|
|
@@ -207,6 +232,7 @@ function handleCrossInstanceDrop(event, targetRegion, moveTo, options) {
|
|
|
207
232
|
export {
|
|
208
233
|
DOCK_REGIONS,
|
|
209
234
|
REGIONS,
|
|
235
|
+
createDockLayoutPersistence,
|
|
210
236
|
designedDockPanelPosition,
|
|
211
237
|
getDockRegions,
|
|
212
238
|
getDockviewApi,
|