@forgeax/app-shell 0.30.0 → 0.32.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
@@ -110,6 +110,45 @@ interface DockLayoutPersistence<Layout, Identity> {
110
110
  * storage, snapshot validation, and concrete Dockview mutation.
111
111
  */
112
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;
131
+ interface DockLayoutResetSource {
132
+ onReset(listener: () => void): {
133
+ dispose(): void;
134
+ };
135
+ }
136
+ interface DockLayoutResetAdapter<Scope, Live> {
137
+ /** Resolve the current product-owned scope at reset time. */
138
+ getCurrentScope(): Scope | null;
139
+ /** Remove the persisted layout for a concrete product-owned scope. */
140
+ clear(scope: Scope): void;
141
+ /** Resolve the currently published dock value without retaining it here. */
142
+ getLive(): Live | null;
143
+ /** Reapply the current product-owned scope after persistence is cleared. */
144
+ apply(live: Live, scope: Scope | null): void;
145
+ }
146
+ /**
147
+ * Own one reset subscription and clear-before-reapply sequencing. Reentrant
148
+ * requests are serialized so the newest reset is applied last; product callers
149
+ * retain the concrete event, scope, persistence, live dock, and layout adapters.
150
+ */
151
+ declare function installDockLayoutReset<Scope, Live>(source: DockLayoutResetSource, adapter: DockLayoutResetAdapter<Scope, Live>): () => void;
113
152
  interface SerializedDockPanelLike {
114
153
  readonly contentComponent?: string;
115
154
  }
@@ -215,4 +254,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
215
254
  titleFor?: (panelId: string) => string | undefined;
216
255
  }): void;
217
256
 
218
- 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 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, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
257
+ 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 DockLayoutResetAdapter, type DockLayoutResetSource, 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, installDockLayoutReset, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
package/dist/dock.js CHANGED
@@ -262,6 +262,98 @@ function createDockLayoutPersistence(adapter) {
262
262
  }
263
263
  };
264
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
+ }
298
+ function installDockLayoutReset(source, adapter) {
299
+ let active = true;
300
+ let processing = false;
301
+ let pending = false;
302
+ const reset = () => {
303
+ if (!active) return;
304
+ pending = true;
305
+ if (processing) return;
306
+ processing = true;
307
+ try {
308
+ while (active && pending) {
309
+ pending = false;
310
+ let scope;
311
+ try {
312
+ scope = adapter.getCurrentScope();
313
+ } catch {
314
+ continue;
315
+ }
316
+ if (!active) break;
317
+ if (pending) continue;
318
+ if (scope !== null) {
319
+ try {
320
+ adapter.clear(scope);
321
+ } catch {
322
+ continue;
323
+ }
324
+ if (!active) break;
325
+ if (pending) continue;
326
+ }
327
+ let live;
328
+ try {
329
+ live = adapter.getLive();
330
+ } catch {
331
+ continue;
332
+ }
333
+ if (!active) break;
334
+ if (pending) continue;
335
+ if (live) {
336
+ try {
337
+ adapter.apply(live, scope);
338
+ } catch {
339
+ }
340
+ }
341
+ }
342
+ } finally {
343
+ processing = false;
344
+ }
345
+ };
346
+ const subscription = source.onReset(reset);
347
+ return () => {
348
+ if (!active) return;
349
+ active = false;
350
+ pending = false;
351
+ try {
352
+ subscription.dispose();
353
+ } catch {
354
+ }
355
+ };
356
+ }
265
357
  function pruneSerializedDockLayout(layout, knownComponents, allowedPanelIds) {
266
358
  if (!layout.panels) return layout;
267
359
  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));
@@ -489,6 +581,8 @@ export {
489
581
  getDockviewApi,
490
582
  handleCrossInstanceDrop,
491
583
  hasMountedPanelPlacement,
584
+ installDockLayoutObservation,
585
+ installDockLayoutReset,
492
586
  installDockPanelVisibilityTracking,
493
587
  isDockPanelVisible,
494
588
  isDockRegion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",