@forgeax/app-shell 0.28.0 → 0.30.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
@@ -17,6 +17,33 @@ interface DockReadyAdapterSession extends DockReadyCleanup {
17
17
  }
18
18
  /** Replace one dock-ready adapter session with an ordered, rollback-safe transaction. */
19
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>;
30
+ interface DockScopeTransitionAdapter<Scope, Live> {
31
+ /** Resolve the currently published dock value without retaining it here. */
32
+ getLive(): Live | null;
33
+ /** Persist the previous product-owned scope before it is replaced. */
34
+ save(live: Live, scope: Scope): void;
35
+ /** Apply the next product-owned scope to the live dock value. */
36
+ apply(live: Live, scope: Scope | null): void;
37
+ }
38
+ interface DockScopeTransition<Scope> {
39
+ getCurrent(): Scope | null;
40
+ /** Save the previous scope, publish the next scope, then apply it when live. */
41
+ transition(next: Scope | null): boolean;
42
+ /** Apply the stable current scope to a newly ready or otherwise refreshed dock. */
43
+ applyCurrent(): boolean;
44
+ }
45
+ /** Own ordered, reentrant-safe scope transitions while product adapters retain policy. */
46
+ declare function createDockScopeTransition<Scope, Live>(adapter: DockScopeTransitionAdapter<Scope, Live>, initial?: Scope | null): DockScopeTransition<Scope>;
20
47
  interface PanelDescriptorLite {
21
48
  defaultRegion?: DockRegion;
22
49
  }
@@ -188,4 +215,4 @@ declare function handleCrossInstanceDrop(event: CrossInstanceDropEvent, targetRe
188
215
  titleFor?: (panelId: string) => string | undefined;
189
216
  }): void;
190
217
 
191
- 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 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, createDockReadyCleanup, designedDockPanelPosition, getDockRegions, getDockviewApi, handleCrossInstanceDrop, hasMountedPanelPlacement, installDockPanelVisibilityTracking, isDockPanelVisible, isDockRegion, isOnSideEdge, nearerSideEdge, pruneSerializedDockLayout, registerDockRegion, registerDockviewApi, replaceDockReadyAdapters, resolveRegion, trackDockPanelVisibility };
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 };
package/dist/dock.js CHANGED
@@ -48,6 +48,96 @@ function replaceDockReadyAdapters(previous, installers) {
48
48
  return { ...cleanup, installed: false };
49
49
  }
50
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
+ }
78
+ function createDockScopeTransition(adapter, initial = null) {
79
+ let current = initial;
80
+ let generation = 0;
81
+ let processing = false;
82
+ let pending = null;
83
+ const getLive = () => {
84
+ try {
85
+ return adapter.getLive();
86
+ } catch {
87
+ return null;
88
+ }
89
+ };
90
+ const enqueue = (next, savePrevious) => {
91
+ const request = { generation: ++generation, next, savePrevious };
92
+ pending = request;
93
+ if (processing) return true;
94
+ processing = true;
95
+ let requestedResult = true;
96
+ let savedPrevious = null;
97
+ try {
98
+ while (pending) {
99
+ const candidate = pending;
100
+ pending = null;
101
+ const previous = current;
102
+ const live = getLive();
103
+ if (pending) {
104
+ if (candidate === request) requestedResult = false;
105
+ continue;
106
+ }
107
+ if (candidate.savePrevious && live && previous !== null && savedPrevious !== previous) {
108
+ try {
109
+ adapter.save(live, previous);
110
+ } catch {
111
+ }
112
+ savedPrevious = previous;
113
+ if (pending) {
114
+ if (candidate === request) requestedResult = false;
115
+ continue;
116
+ }
117
+ }
118
+ current = candidate.next;
119
+ if (live) {
120
+ try {
121
+ adapter.apply(live, candidate.next);
122
+ } catch {
123
+ if (candidate === request) requestedResult = false;
124
+ }
125
+ } else if (!candidate.savePrevious && candidate === request) {
126
+ requestedResult = false;
127
+ }
128
+ if (pending && candidate === request) requestedResult = false;
129
+ }
130
+ } finally {
131
+ processing = false;
132
+ }
133
+ return requestedResult;
134
+ };
135
+ return {
136
+ getCurrent: () => current,
137
+ transition: (next) => enqueue(next, true),
138
+ applyCurrent: () => enqueue(current, false)
139
+ };
140
+ }
51
141
  function resolveRegion(id, descriptor, overrides) {
52
142
  return overrides[id] ?? descriptor.defaultRegion ?? "DockShell";
53
143
  }
@@ -391,7 +481,9 @@ export {
391
481
  REGIONS,
392
482
  createDockLayoutPersistence,
393
483
  createDockPanelCommands,
484
+ createDockReadyActivation,
394
485
  createDockReadyCleanup,
486
+ createDockScopeTransition,
395
487
  designedDockPanelPosition,
396
488
  getDockRegions,
397
489
  getDockviewApi,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/app-shell",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "Generic Dock, Panel, Window, and Slot composition primitives",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",