@forgeax/app-shell 0.29.0 → 0.31.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 +36 -1
- package/dist/dock.js +98 -0
- package/package.json +1 -1
package/dist/dock.d.ts
CHANGED
|
@@ -27,6 +27,23 @@ interface DockReadyActivation<T> {
|
|
|
27
27
|
}
|
|
28
28
|
/** Own current-value publication and reentrant replacement for dock-ready sessions. */
|
|
29
29
|
declare function createDockReadyActivation<T>(): DockReadyActivation<T>;
|
|
30
|
+
interface DockScopeTransitionAdapter<Scope, Live> {
|
|
31
|
+
/** Resolve the currently published dock value without retaining it here. */
|
|
32
|
+
getLive(): Live | null;
|
|
33
|
+
/** Persist the previous product-owned scope before it is replaced. */
|
|
34
|
+
save(live: Live, scope: Scope): void;
|
|
35
|
+
/** Apply the next product-owned scope to the live dock value. */
|
|
36
|
+
apply(live: Live, scope: Scope | null): void;
|
|
37
|
+
}
|
|
38
|
+
interface DockScopeTransition<Scope> {
|
|
39
|
+
getCurrent(): Scope | null;
|
|
40
|
+
/** Save the previous scope, publish the next scope, then apply it when live. */
|
|
41
|
+
transition(next: Scope | null): boolean;
|
|
42
|
+
/** Apply the stable current scope to a newly ready or otherwise refreshed dock. */
|
|
43
|
+
applyCurrent(): boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Own ordered, reentrant-safe scope transitions while product adapters retain policy. */
|
|
46
|
+
declare function createDockScopeTransition<Scope, Live>(adapter: DockScopeTransitionAdapter<Scope, Live>, initial?: Scope | null): DockScopeTransition<Scope>;
|
|
30
47
|
interface PanelDescriptorLite {
|
|
31
48
|
defaultRegion?: DockRegion;
|
|
32
49
|
}
|
|
@@ -93,6 +110,24 @@ interface DockLayoutPersistence<Layout, Identity> {
|
|
|
93
110
|
* storage, snapshot validation, and concrete Dockview mutation.
|
|
94
111
|
*/
|
|
95
112
|
declare function createDockLayoutPersistence<Layout, Identity>(adapter: DockLayoutPersistenceAdapter<Layout, Identity>): DockLayoutPersistence<Layout, Identity>;
|
|
113
|
+
interface DockLayoutObservationSource {
|
|
114
|
+
onDidLayoutChange(listener: () => void): {
|
|
115
|
+
dispose(): void;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface DockLayoutObservationAdapter<Scope> {
|
|
119
|
+
/** Resolve the current product-owned scope at event time. */
|
|
120
|
+
getCurrentScope(): Scope | null;
|
|
121
|
+
/** Capture and persist a scoped layout; false identifies a suppressed capture. */
|
|
122
|
+
readonly captureAndSave?: (scope: Scope) => boolean;
|
|
123
|
+
/** Publish one stable notification only after capture succeeds or is not required. */
|
|
124
|
+
onCommitted(): void;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Own one layout-change subscription and its capture-before-notify sequencing.
|
|
128
|
+
* Product callers retain concrete event, scope, snapshot, persistence, and UI adapters.
|
|
129
|
+
*/
|
|
130
|
+
declare function installDockLayoutObservation<Scope>(source: DockLayoutObservationSource, adapter: DockLayoutObservationAdapter<Scope>): () => void;
|
|
96
131
|
interface SerializedDockPanelLike {
|
|
97
132
|
readonly contentComponent?: string;
|
|
98
133
|
}
|
|
@@ -198,4 +233,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
|
|
|
198
233
|
titleFor?: (panelId: string) => string | undefined;
|
|
199
234
|
}): void;
|
|
200
235
|
|
|
201
|
-
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 DockReadyActivation, type DockReadyAdapterInstaller, type DockReadyAdapterSession, 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, createDockReadyActivation, createDockReadyCleanup, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
|
|
236
|
+
export { type AuthoredDockLayoutLike, type AuthoredDockNodeLike, type CrossInstanceDropEvent, DOCK_REGIONS, type DesignedDockPanelPosition, type DockCommandPanel, type DockLayoutObservationAdapter, type DockLayoutObservationSource, type DockLayoutOrientation, type DockLayoutPersistence, type DockLayoutPersistenceAdapter, type DockLayoutPersistenceScope, type DockPanelCommandAdapter, type DockPanelCommands, type DockPanelVisibilityEventSource, type DockPanelVisibilityHooks, type DockReadyActivation, type DockReadyAdapterInstaller, type DockReadyAdapterSession, type DockReadyCleanup, type DockRegion, type DockRegionEntry, type DockReopenDirection, type DockScopeTransition, type DockScopeTransitionAdapter, type DockviewApiLike, type PanelDescriptorLite, REGIONS, type RectLike, type Region, type SerializedDockLayoutLike, type SerializedDockPanelLike, type SideEdge, createDockLayoutPersistence, createDockPanelCommands, createDockReadyActivation, createDockReadyCleanup, createDockScopeTransition, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockLayoutObservation, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
|
package/dist/dock.js
CHANGED
|
@@ -75,6 +75,69 @@ function createDockReadyActivation() {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
+
function createDockScopeTransition(adapter, initial = null) {
|
|
79
|
+
let current = initial;
|
|
80
|
+
let generation = 0;
|
|
81
|
+
let processing = false;
|
|
82
|
+
let pending = null;
|
|
83
|
+
const getLive = () => {
|
|
84
|
+
try {
|
|
85
|
+
return adapter.getLive();
|
|
86
|
+
} catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const enqueue = (next, savePrevious) => {
|
|
91
|
+
const request = { generation: ++generation, next, savePrevious };
|
|
92
|
+
pending = request;
|
|
93
|
+
if (processing) return true;
|
|
94
|
+
processing = true;
|
|
95
|
+
let requestedResult = true;
|
|
96
|
+
let savedPrevious = null;
|
|
97
|
+
try {
|
|
98
|
+
while (pending) {
|
|
99
|
+
const candidate = pending;
|
|
100
|
+
pending = null;
|
|
101
|
+
const previous = current;
|
|
102
|
+
const live = getLive();
|
|
103
|
+
if (pending) {
|
|
104
|
+
if (candidate === request) requestedResult = false;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (candidate.savePrevious && live && previous !== null && savedPrevious !== previous) {
|
|
108
|
+
try {
|
|
109
|
+
adapter.save(live, previous);
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
savedPrevious = previous;
|
|
113
|
+
if (pending) {
|
|
114
|
+
if (candidate === request) requestedResult = false;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
current = candidate.next;
|
|
119
|
+
if (live) {
|
|
120
|
+
try {
|
|
121
|
+
adapter.apply(live, candidate.next);
|
|
122
|
+
} catch {
|
|
123
|
+
if (candidate === request) requestedResult = false;
|
|
124
|
+
}
|
|
125
|
+
} else if (!candidate.savePrevious && candidate === request) {
|
|
126
|
+
requestedResult = false;
|
|
127
|
+
}
|
|
128
|
+
if (pending && candidate === request) requestedResult = false;
|
|
129
|
+
}
|
|
130
|
+
} finally {
|
|
131
|
+
processing = false;
|
|
132
|
+
}
|
|
133
|
+
return requestedResult;
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
getCurrent: () => current,
|
|
137
|
+
transition: (next) => enqueue(next, true),
|
|
138
|
+
applyCurrent: () => enqueue(current, false)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
78
141
|
function resolveRegion(id, descriptor, overrides) {
|
|
79
142
|
return overrides[id] ?? descriptor.defaultRegion ?? "DockShell";
|
|
80
143
|
}
|
|
@@ -199,6 +262,39 @@ function createDockLayoutPersistence(adapter) {
|
|
|
199
262
|
}
|
|
200
263
|
};
|
|
201
264
|
}
|
|
265
|
+
function installDockLayoutObservation(source, adapter) {
|
|
266
|
+
let active = true;
|
|
267
|
+
const subscription = source.onDidLayoutChange(() => {
|
|
268
|
+
if (!active) return;
|
|
269
|
+
let scope;
|
|
270
|
+
try {
|
|
271
|
+
scope = adapter.getCurrentScope();
|
|
272
|
+
} catch {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!active) return;
|
|
276
|
+
if (scope !== null && adapter.captureAndSave) {
|
|
277
|
+
try {
|
|
278
|
+
if (!adapter.captureAndSave(scope)) return;
|
|
279
|
+
} catch {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (!active) return;
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
adapter.onCommitted();
|
|
286
|
+
} catch {
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
return () => {
|
|
290
|
+
if (!active) return;
|
|
291
|
+
active = false;
|
|
292
|
+
try {
|
|
293
|
+
subscription.dispose();
|
|
294
|
+
} catch {
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
202
298
|
function pruneSerializedDockLayout(layout, knownComponents, allowedPanelIds) {
|
|
203
299
|
if (!layout.panels) return layout;
|
|
204
300
|
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));
|
|
@@ -420,11 +516,13 @@ export {
|
|
|
420
516
|
createDockPanelCommands,
|
|
421
517
|
createDockReadyActivation,
|
|
422
518
|
createDockReadyCleanup,
|
|
519
|
+
createDockScopeTransition,
|
|
423
520
|
designedDockPanelPosition,
|
|
424
521
|
getDockRegions,
|
|
425
522
|
getDockviewApi,
|
|
426
523
|
handleCrossInstanceDrop,
|
|
427
524
|
hasMountedPanelPlacement,
|
|
525
|
+
installDockLayoutObservation,
|
|
428
526
|
installDockPanelVisibilityTracking,
|
|
429
527
|
isDockPanelVisible,
|
|
430
528
|
isDockRegion,
|