@forgeax/app-shell 0.24.1 → 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 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;
@@ -128,4 +146,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
128
146
  titleFor?: (panelId: string) => string | undefined;
129
147
  }): void;
130
148
 
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 };
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
  }
@@ -243,6 +296,7 @@ export {
243
296
  getDockviewApi,
244
297
  handleCrossInstanceDrop,
245
298
  hasMountedPanelPlacement,
299
+ installDockPanelVisibilityTracking,
246
300
  isDockPanelVisible,
247
301
  isDockRegion,
248
302
  isOnSideEdge,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",