@forgeax/app-shell 0.21.0 → 0.22.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.
@@ -68,6 +68,62 @@ function createPanelWindowingController() {
68
68
  }
69
69
  };
70
70
  }
71
+ function createSurfaceWindowingController(options) {
72
+ const emptySnapshot = Object.freeze({});
73
+ const floating = /* @__PURE__ */ new Set();
74
+ const listeners = /* @__PURE__ */ new Set();
75
+ let snapshot = emptySnapshot;
76
+ const publish = () => {
77
+ snapshot = floating.size === 0 ? emptySnapshot : Object.freeze(Object.fromEntries([...floating].sort().map((key) => [key, true])));
78
+ for (const listener of listeners) {
79
+ try {
80
+ listener();
81
+ } catch {
82
+ }
83
+ }
84
+ };
85
+ const markFloating = (surface) => {
86
+ const key = surfaceKey(surface);
87
+ if (floating.has(key)) return;
88
+ floating.add(key);
89
+ publish();
90
+ };
91
+ const markDocked = (surface) => {
92
+ if (!floating.delete(surfaceKey(surface))) return;
93
+ publish();
94
+ };
95
+ return {
96
+ snapshot: () => snapshot,
97
+ onChange(listener) {
98
+ listeners.add(listener);
99
+ return () => {
100
+ listeners.delete(listener);
101
+ };
102
+ },
103
+ async detachSurface(surface, detachOptions) {
104
+ if (!options.manager.canDetach()) return false;
105
+ try {
106
+ options.beforeDetach?.(surface);
107
+ } catch {
108
+ return false;
109
+ }
110
+ markFloating(surface);
111
+ let opened = false;
112
+ try {
113
+ opened = await options.manager.openSurfaceWindow(surface, detachOptions);
114
+ } catch {
115
+ opened = false;
116
+ }
117
+ if (!opened) markDocked(surface);
118
+ return opened;
119
+ },
120
+ async redockSurface(surface) {
121
+ await options.manager.closeSurfaceWindow(surface);
122
+ markDocked(surface);
123
+ },
124
+ markSurfaceDocked: markDocked
125
+ };
126
+ }
71
127
  function currentBrowserHost() {
72
128
  if (typeof window === "undefined" || typeof window.open !== "function") return void 0;
73
129
  return {
@@ -261,6 +317,7 @@ export {
261
317
  canOpenPanelWindow,
262
318
  shouldShowDetachedPlaceholder,
263
319
  createPanelWindowingController,
320
+ createSurfaceWindowingController,
264
321
  createBrowserWindowManager,
265
322
  createExternalWindowManager,
266
323
  surfaceKey,
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  shouldShowDetachedPlaceholder
3
- } from "./chunk-ZYCR2LSP.js";
3
+ } from "./chunk-EEPX63DF.js";
4
4
 
5
5
  // src/react.tsx
6
6
  import { createElement } from "react";
package/dist/window.d.ts CHANGED
@@ -82,10 +82,23 @@ interface PanelWindowingController {
82
82
  openPanelWindow(panelId: string, capability: DetachedWindowCapability | undefined, options: OpenPanelWindowOptions): Promise<boolean>;
83
83
  panelForClosedSurface(surface: SurfaceDescriptor): string | undefined;
84
84
  }
85
+ interface CreateSurfaceWindowingControllerOptions {
86
+ readonly manager: WindowManager;
87
+ readonly beforeDetach?: (surface: SurfaceDescriptor) => void;
88
+ }
89
+ interface SurfaceWindowingController {
90
+ snapshot(): Readonly<Record<string, true>>;
91
+ onChange(listener: () => void): () => void;
92
+ detachSurface(surface: SurfaceDescriptor, options?: DetachWindowOptions): Promise<boolean>;
93
+ redockSurface(surface: SurfaceDescriptor): Promise<void>;
94
+ markSurfaceDocked(surface: SurfaceDescriptor): void;
95
+ }
85
96
  declare function canOpenPanelWindow(capability: DetachedWindowCapability | undefined, carrierAvailable: boolean): capability is DetachedWindowCapability;
86
97
  declare function shouldShowDetachedPlaceholder(floatingSurfaces: Readonly<Record<string, true>>, surface: SurfaceDescriptor): boolean;
87
98
  /** Product-neutral transaction joining a dock placement to a detached carrier. */
88
99
  declare function createPanelWindowingController(): PanelWindowingController;
100
+ /** Product-neutral state machine joining floating presentation to a carrier. */
101
+ declare function createSurfaceWindowingController(options: CreateSurfaceWindowingControllerOptions): SurfaceWindowingController;
89
102
  /** Product-neutral browser popup carrier with injected surface URL policy. */
90
103
  declare function createBrowserWindowManager(options: CreateBrowserWindowManagerOptions): WindowManager;
91
104
  /** Event-driven external-window lifecycle with all native policy injected. */
@@ -99,4 +112,4 @@ declare function encodeSurfaceQuery(surface: SurfaceDescriptor): string;
99
112
  /** Decode structural identity, or null for a normal shell/invalid entry. */
100
113
  declare function decodeSurfaceFromLocation(search?: string): SurfaceDescriptor | null;
101
114
 
102
- export { type BrowserPopupWindow, type BrowserWindowHost, type CreateBrowserWindowManagerOptions, type CreateExternalWindowManagerOptions, type DetachWindowOptions, type DetachedWindowCapability, type DetachedWindowTarget, type ExternalWindowHandle, type ExternalWindowHost, type ExternalWindowLifecycle, type OpenPanelWindowOptions, type PanelWindowingController, type SurfaceDescriptor, type SurfaceKind, type SurfacePane, type WindowManager, canOpenPanelWindow, createBrowserWindowManager, createExternalWindowManager, createPanelWindowingController, decodeSurfaceFromLocation, encodeSurfaceQuery, shouldShowDetachedPlaceholder, surfaceKey, surfaceWindowLabel };
115
+ export { type BrowserPopupWindow, type BrowserWindowHost, type CreateBrowserWindowManagerOptions, type CreateExternalWindowManagerOptions, type CreateSurfaceWindowingControllerOptions, type DetachWindowOptions, type DetachedWindowCapability, type DetachedWindowTarget, type ExternalWindowHandle, type ExternalWindowHost, type ExternalWindowLifecycle, type OpenPanelWindowOptions, type PanelWindowingController, type SurfaceDescriptor, type SurfaceKind, type SurfacePane, type SurfaceWindowingController, type WindowManager, canOpenPanelWindow, createBrowserWindowManager, createExternalWindowManager, createPanelWindowingController, createSurfaceWindowingController, decodeSurfaceFromLocation, encodeSurfaceQuery, shouldShowDetachedPlaceholder, surfaceKey, surfaceWindowLabel };
package/dist/window.js CHANGED
@@ -3,17 +3,19 @@ import {
3
3
  createBrowserWindowManager,
4
4
  createExternalWindowManager,
5
5
  createPanelWindowingController,
6
+ createSurfaceWindowingController,
6
7
  decodeSurfaceFromLocation,
7
8
  encodeSurfaceQuery,
8
9
  shouldShowDetachedPlaceholder,
9
10
  surfaceKey,
10
11
  surfaceWindowLabel
11
- } from "./chunk-ZYCR2LSP.js";
12
+ } from "./chunk-EEPX63DF.js";
12
13
  export {
13
14
  canOpenPanelWindow,
14
15
  createBrowserWindowManager,
15
16
  createExternalWindowManager,
16
17
  createPanelWindowingController,
18
+ createSurfaceWindowingController,
17
19
  decodeSurfaceFromLocation,
18
20
  encodeSurfaceQuery,
19
21
  shouldShowDetachedPlaceholder,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",