@forgeax/app-shell 0.32.0 → 0.34.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
@@ -217,6 +217,46 @@ interface DockPanelCommands {
217
217
  }
218
218
  /** Own idempotent panel commands while callers retain membership and product policy. */
219
219
  declare function createDockPanelCommands(adapter: DockPanelCommandAdapter): DockPanelCommands;
220
+ interface DockPanelCommandSubscriptionSource {
221
+ onOpen(listener: (panelId: string) => void): {
222
+ dispose(): void;
223
+ };
224
+ onClose(listener: (panelId: string) => void): {
225
+ dispose(): void;
226
+ };
227
+ onFocus(listener: (panelId: string) => void): {
228
+ dispose(): void;
229
+ };
230
+ onReveal(listener: (panelId: string) => void): {
231
+ dispose(): void;
232
+ };
233
+ }
234
+ /**
235
+ * Own balanced panel-command subscriptions while callers retain event names,
236
+ * payload mapping, membership, titles, layout policy, and concrete Dock APIs.
237
+ */
238
+ declare function installDockPanelCommandSubscriptions(source: DockPanelCommandSubscriptionSource, commands: DockPanelCommands): () => void;
239
+ interface DockLayoutControlSnapshot<Anchor> {
240
+ readonly open: boolean;
241
+ readonly anchor: Anchor | null;
242
+ }
243
+ interface DockLayoutControlState<Anchor> {
244
+ getSnapshot(): DockLayoutControlSnapshot<Anchor>;
245
+ subscribe(listener: () => void): () => void;
246
+ /** Toggle visibility and preserve the previous anchor when none is supplied. */
247
+ toggle(anchor?: Anchor): void;
248
+ /** Close without publishing a duplicate snapshot when already closed. */
249
+ close(): void;
250
+ }
251
+ /** Own stable external-store state for a product-presented Dock layout control. */
252
+ declare function createDockLayoutControlState<Anchor>(initialAnchor?: Anchor | null): DockLayoutControlState<Anchor>;
253
+ interface DockLayoutControlToggleSource<Anchor> {
254
+ onToggle(listener: (anchor?: Anchor) => void): {
255
+ dispose(): void;
256
+ };
257
+ }
258
+ /** Own one layout-control toggle subscription while product callers map events and payloads. */
259
+ declare function installDockLayoutControlToggle<Anchor>(source: DockLayoutControlToggleSource<Anchor>, state: Pick<DockLayoutControlState<Anchor>, 'toggle'>): () => void;
220
260
  type SideEdge = 'left' | 'right';
221
261
  interface RectLike {
222
262
  left: number;
@@ -254,4 +294,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
254
294
  titleFor?: (panelId: string) => string | undefined;
255
295
  }): void;
256
296
 
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 };
297
+ export { type AuthoredDockLayoutLike, type AuthoredDockNodeLike, type CrossInstanceDropEvent, DOCK_REGIONS, type DesignedDockPanelPosition, type DockCommandPanel, type DockLayoutControlSnapshot, type DockLayoutControlState, type DockLayoutControlToggleSource, type DockLayoutObservationAdapter, type DockLayoutObservationSource, type DockLayoutOrientation, type DockLayoutPersistence, type DockLayoutPersistenceAdapter, type DockLayoutPersistenceScope, type DockLayoutResetAdapter, type DockLayoutResetSource, type DockPanelCommandAdapter, type DockPanelCommandSubscriptionSource, 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, createDockLayoutControlState, createDockLayoutPersistence, createDockPanelCommands, createDockReadyActivation, createDockReadyCleanup, createDockScopeTransition, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockLayoutControlToggle, installDockLayoutObservation, installDockLayoutReset, installDockPanelCommandSubscriptions, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
package/dist/dock.js CHANGED
@@ -517,6 +517,86 @@ function createDockPanelCommands(adapter) {
517
517
  }
518
518
  };
519
519
  }
520
+ function installDockPanelCommandSubscriptions(source, commands) {
521
+ const subscriptions = [];
522
+ let active = true;
523
+ const cleanup = () => {
524
+ if (!active) return;
525
+ active = false;
526
+ while (subscriptions.length > 0) {
527
+ try {
528
+ subscriptions.pop()?.dispose();
529
+ } catch {
530
+ }
531
+ }
532
+ };
533
+ const route = (command) => (panelId) => {
534
+ if (!active) return;
535
+ try {
536
+ command(panelId);
537
+ } catch {
538
+ }
539
+ };
540
+ try {
541
+ subscriptions.push(source.onOpen(route((id) => commands.open(id))));
542
+ subscriptions.push(source.onClose(route((id) => commands.close(id))));
543
+ subscriptions.push(source.onFocus(route((id) => commands.focus(id))));
544
+ subscriptions.push(source.onReveal(route((id) => commands.reveal(id))));
545
+ } catch (error) {
546
+ cleanup();
547
+ throw error;
548
+ }
549
+ return cleanup;
550
+ }
551
+ function createDockLayoutControlState(initialAnchor = null) {
552
+ let snapshot = { open: false, anchor: initialAnchor };
553
+ const listeners = /* @__PURE__ */ new Set();
554
+ const commit = (open, anchor) => {
555
+ if (snapshot.open === open && snapshot.anchor === anchor) return;
556
+ snapshot = { open, anchor };
557
+ for (const listener of [...listeners]) {
558
+ try {
559
+ listener();
560
+ } catch {
561
+ }
562
+ }
563
+ };
564
+ return {
565
+ getSnapshot: () => snapshot,
566
+ subscribe(listener) {
567
+ listeners.add(listener);
568
+ let subscribed = true;
569
+ return () => {
570
+ if (!subscribed) return;
571
+ subscribed = false;
572
+ listeners.delete(listener);
573
+ };
574
+ },
575
+ toggle: (anchor) => commit(
576
+ !snapshot.open,
577
+ anchor === void 0 ? snapshot.anchor : anchor
578
+ ),
579
+ close: () => commit(false, snapshot.anchor)
580
+ };
581
+ }
582
+ function installDockLayoutControlToggle(source, state) {
583
+ let active = true;
584
+ const subscription = source.onToggle((anchor) => {
585
+ if (!active) return;
586
+ try {
587
+ state.toggle(anchor);
588
+ } catch {
589
+ }
590
+ });
591
+ return () => {
592
+ if (!active) return;
593
+ active = false;
594
+ try {
595
+ subscription.dispose();
596
+ } catch {
597
+ }
598
+ };
599
+ }
520
600
  function isOnSideEdge(location) {
521
601
  return location.type === "edge" && (location.position === "left" || location.position === "right");
522
602
  }
@@ -571,6 +651,7 @@ function handleCrossInstanceDrop(event, targetRegion, moveTo, options) {
571
651
  export {
572
652
  DOCK_REGIONS,
573
653
  REGIONS,
654
+ createDockLayoutControlState,
574
655
  createDockLayoutPersistence,
575
656
  createDockPanelCommands,
576
657
  createDockReadyActivation,
@@ -581,8 +662,10 @@ export {
581
662
  getDockviewApi,
582
663
  handleCrossInstanceDrop,
583
664
  hasMountedPanelPlacement,
665
+ installDockLayoutControlToggle,
584
666
  installDockLayoutObservation,
585
667
  installDockLayoutReset,
668
+ installDockPanelCommandSubscriptions,
586
669
  installDockPanelVisibilityTracking,
587
670
  isDockPanelVisible,
588
671
  isDockRegion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",