@forgeax/app-shell 0.23.0 → 0.24.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.
- package/dist/dock.d.ts +23 -1
- package/dist/dock.js +31 -0
- package/package.json +1 -1
package/dist/dock.d.ts
CHANGED
|
@@ -29,6 +29,28 @@ 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
|
+
captureAndSave(scope: DockLayoutPersistenceScope<Identity>, capture: () => Layout): boolean;
|
|
45
|
+
clear(scope: DockLayoutPersistenceScope<Identity>): void;
|
|
46
|
+
isRestoring(): boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Own the load-before-mutation and reentrant-save suppression required by dock
|
|
50
|
+
* layout restoration. Product callers retain key construction, identity,
|
|
51
|
+
* storage, snapshot validation, and concrete Dockview mutation.
|
|
52
|
+
*/
|
|
53
|
+
declare function createDockLayoutPersistence<Layout, Identity>(adapter: DockLayoutPersistenceAdapter<Layout, Identity>): DockLayoutPersistence<Layout, Identity>;
|
|
32
54
|
interface SerializedDockPanelLike {
|
|
33
55
|
readonly contentComponent?: string;
|
|
34
56
|
}
|
|
@@ -106,4 +128,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
|
|
|
106
128
|
titleFor?: (panelId: string) => string | undefined;
|
|
107
129
|
}): void;
|
|
108
130
|
|
|
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 };
|
|
131
|
+
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,36 @@ 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
|
+
captureAndSave(scope, capture) {
|
|
66
|
+
if (restoreDepth > 0) return false;
|
|
67
|
+
adapter.save(scope.key, scope.identity, capture());
|
|
68
|
+
return true;
|
|
69
|
+
},
|
|
70
|
+
clear(scope) {
|
|
71
|
+
adapter.remove(scope.key);
|
|
72
|
+
},
|
|
73
|
+
isRestoring() {
|
|
74
|
+
return restoreDepth > 0;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
48
78
|
function pruneSerializedDockLayout(layout, knownComponents, allowedPanelIds) {
|
|
49
79
|
if (!layout.panels) return layout;
|
|
50
80
|
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 +237,7 @@ function handleCrossInstanceDrop(event, targetRegion, moveTo, options) {
|
|
|
207
237
|
export {
|
|
208
238
|
DOCK_REGIONS,
|
|
209
239
|
REGIONS,
|
|
240
|
+
createDockLayoutPersistence,
|
|
210
241
|
designedDockPanelPosition,
|
|
211
242
|
getDockRegions,
|
|
212
243
|
getDockviewApi,
|