@forgeax/app-shell 0.27.0 → 0.29.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
@@ -11,6 +11,22 @@ interface DockReadyCleanup {
11
11
  }
12
12
  /** Own the best-effort teardown lifecycle of one dock-ready session. */
13
13
  declare function createDockReadyCleanup(): DockReadyCleanup;
14
+ type DockReadyAdapterInstaller = () => void | (() => void);
15
+ interface DockReadyAdapterSession extends DockReadyCleanup {
16
+ readonly installed: boolean;
17
+ }
18
+ /** Replace one dock-ready adapter session with an ordered, rollback-safe transaction. */
19
+ declare function replaceDockReadyAdapters(previous: DockReadyCleanup | null | undefined, installers: readonly DockReadyAdapterInstaller[]): DockReadyAdapterSession;
20
+ interface DockReadyActivation<T> {
21
+ /** Return the current value only after its complete adapter transaction succeeds. */
22
+ getCurrent(): T | null;
23
+ /** Replace the current ready session; failed or stale transactions stay unpublished. */
24
+ replace(value: T, installers: readonly DockReadyAdapterInstaller[]): boolean;
25
+ /** Revoke the current value and dispose its ready session once. */
26
+ dispose(): void;
27
+ }
28
+ /** Own current-value publication and reentrant replacement for dock-ready sessions. */
29
+ declare function createDockReadyActivation<T>(): DockReadyActivation<T>;
14
30
  interface PanelDescriptorLite {
15
31
  defaultRegion?: DockRegion;
16
32
  }
@@ -182,4 +198,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
182
198
  titleFor?: (panelId: string) => string | undefined;
183
199
  }): void;
184
200
 
185
- 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 DockReadyCleanup, type DockRegion, type DockRegionEntry, type DockReopenDirection, type DockviewApiLike, type PanelDescriptorLite, REGIONS, type RectLike, type Region, type SerializedDockLayoutLike, type SerializedDockPanelLike, type SideEdge, createDockLayoutPersistence, createDockPanelCommands, createDockReadyCleanup, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, resolveRegion, trackDockPanelVisibility };
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 };
package/dist/dock.js CHANGED
@@ -31,6 +31,50 @@ function createDockReadyCleanup() {
31
31
  }
32
32
  };
33
33
  }
34
+ function replaceDockReadyAdapters(previous, installers) {
35
+ try {
36
+ previous?.dispose();
37
+ } catch {
38
+ }
39
+ const cleanup = createDockReadyCleanup();
40
+ try {
41
+ for (const install of installers) {
42
+ const dispose = install();
43
+ if (dispose) cleanup.add(dispose);
44
+ }
45
+ return { ...cleanup, installed: true };
46
+ } catch {
47
+ cleanup.dispose();
48
+ return { ...cleanup, installed: false };
49
+ }
50
+ }
51
+ function createDockReadyActivation() {
52
+ let current = null;
53
+ let session = null;
54
+ let generation = 0;
55
+ return {
56
+ getCurrent: () => current,
57
+ replace(value, installers) {
58
+ const candidateGeneration = ++generation;
59
+ current = null;
60
+ const candidate = replaceDockReadyAdapters(session, installers);
61
+ if (candidateGeneration !== generation) {
62
+ candidate.dispose();
63
+ return false;
64
+ }
65
+ session = candidate;
66
+ if (!candidate.installed) return false;
67
+ current = value;
68
+ return true;
69
+ },
70
+ dispose() {
71
+ generation += 1;
72
+ current = null;
73
+ session?.dispose();
74
+ session = null;
75
+ }
76
+ };
77
+ }
34
78
  function resolveRegion(id, descriptor, overrides) {
35
79
  return overrides[id] ?? descriptor.defaultRegion ?? "DockShell";
36
80
  }
@@ -374,6 +418,7 @@ export {
374
418
  REGIONS,
375
419
  createDockLayoutPersistence,
376
420
  createDockPanelCommands,
421
+ createDockReadyActivation,
377
422
  createDockReadyCleanup,
378
423
  designedDockPanelPosition,
379
424
  getDockRegions,
@@ -388,6 +433,7 @@ export {
388
433
  pruneSerializedDockLayout,
389
434
  registerDockRegion,
390
435
  registerDockviewApi,
436
+ replaceDockReadyAdapters,
391
437
  resolveRegion,
392
438
  trackDockPanelVisibility
393
439
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",