@forgeax/app-shell 0.31.0 → 0.33.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
@@ -128,6 +128,27 @@ interface DockLayoutObservationAdapter<Scope> {
128
128
  * Product callers retain concrete event, scope, snapshot, persistence, and UI adapters.
129
129
  */
130
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;
131
152
  interface SerializedDockPanelLike {
132
153
  readonly contentComponent?: string;
133
154
  }
@@ -196,6 +217,25 @@ interface DockPanelCommands {
196
217
  }
197
218
  /** Own idempotent panel commands while callers retain membership and product policy. */
198
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;
199
239
  type SideEdge = 'left' | 'right';
200
240
  interface RectLike {
201
241
  left: number;
@@ -233,4 +273,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
233
273
  titleFor?: (panelId: string) => string | undefined;
234
274
  }): void;
235
275
 
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 };
276
+ 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 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, createDockLayoutPersistence, createDockPanelCommands, createDockReadyActivation, createDockReadyCleanup, createDockScopeTransition, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockLayoutObservation, installDockLayoutReset, installDockPanelCommandSubscriptions, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
package/dist/dock.js CHANGED
@@ -295,6 +295,65 @@ function installDockLayoutObservation(source, adapter) {
295
295
  }
296
296
  };
297
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
+ }
298
357
  function pruneSerializedDockLayout(layout, knownComponents, allowedPanelIds) {
299
358
  if (!layout.panels) return layout;
300
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));
@@ -458,6 +517,37 @@ function createDockPanelCommands(adapter) {
458
517
  }
459
518
  };
460
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
+ }
461
551
  function isOnSideEdge(location) {
462
552
  return location.type === "edge" && (location.position === "left" || location.position === "right");
463
553
  }
@@ -523,6 +613,8 @@ export {
523
613
  handleCrossInstanceDrop,
524
614
  hasMountedPanelPlacement,
525
615
  installDockLayoutObservation,
616
+ installDockLayoutReset,
617
+ installDockPanelCommandSubscriptions,
526
618
  installDockPanelVisibilityTracking,
527
619
  isDockPanelVisible,
528
620
  isDockRegion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",