@konitif/workbench-runtime 0.284.1

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.
Files changed (57) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +60 -0
  3. package/dist/boot/createDemoWorkbenchBootGraph.d.ts +9 -0
  4. package/dist/boot/createDemoWorkbenchBootGraph.js +180 -0
  5. package/dist/boot/createLegacyWorkbenchBootGraph.d.ts +34 -0
  6. package/dist/boot/createLegacyWorkbenchBootGraph.js +321 -0
  7. package/dist/boot/createWorkbenchBootSession.d.ts +23 -0
  8. package/dist/boot/createWorkbenchBootSession.js +90 -0
  9. package/dist/boot/index.d.ts +3 -0
  10. package/dist/boot/index.js +3 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.js +9 -0
  13. package/dist/runtime.d.ts +7 -0
  14. package/dist/runtime.js +2 -0
  15. package/dist/workbench/browserDetachedWindowHost.d.ts +3 -0
  16. package/dist/workbench/browserDetachedWindowHost.js +69 -0
  17. package/dist/workbench/browserWorkbenchHostEvents.d.ts +3 -0
  18. package/dist/workbench/browserWorkbenchHostEvents.js +35 -0
  19. package/dist/workbench/createWorkbenchStore.d.ts +129 -0
  20. package/dist/workbench/createWorkbenchStore.js +50 -0
  21. package/dist/workbench/createWorkbenchStoreRuntime.d.ts +154 -0
  22. package/dist/workbench/createWorkbenchStoreRuntime.js +242 -0
  23. package/dist/workbench/createWorkspaceModeController.d.ts +36 -0
  24. package/dist/workbench/createWorkspaceModeController.js +168 -0
  25. package/dist/workbench/workbenchDetachedWindowHost.d.ts +16 -0
  26. package/dist/workbench/workbenchDetachedWindowHost.js +1 -0
  27. package/dist/workbench/workbenchFocusPersistence.d.ts +15 -0
  28. package/dist/workbench/workbenchFocusPersistence.js +44 -0
  29. package/dist/workbench/workbenchHistoryActions.d.ts +21 -0
  30. package/dist/workbench/workbenchHistoryActions.js +45 -0
  31. package/dist/workbench/workbenchHistoryRuntime.d.ts +16 -0
  32. package/dist/workbench/workbenchHistoryRuntime.js +42 -0
  33. package/dist/workbench/workbenchHostEvents.d.ts +13 -0
  34. package/dist/workbench/workbenchHostEvents.js +1 -0
  35. package/dist/workbench/workbenchLayoutActions.d.ts +84 -0
  36. package/dist/workbench/workbenchLayoutActions.js +191 -0
  37. package/dist/workbench/workbenchPersistenceRuntime.d.ts +39 -0
  38. package/dist/workbench/workbenchPersistenceRuntime.js +168 -0
  39. package/dist/workbench/workbenchShellActions.d.ts +24 -0
  40. package/dist/workbench/workbenchShellActions.js +63 -0
  41. package/dist/workbench/workbenchShellPersistence.d.ts +18 -0
  42. package/dist/workbench/workbenchShellPersistence.js +124 -0
  43. package/dist/workbench/workbenchStateFactory.d.ts +22 -0
  44. package/dist/workbench/workbenchStateFactory.js +47 -0
  45. package/dist/workbench/workbenchToolRuntimeActions.d.ts +23 -0
  46. package/dist/workbench/workbenchToolRuntimeActions.js +98 -0
  47. package/dist/workbench/workbenchToolRuntimeUiStore.d.ts +17 -0
  48. package/dist/workbench/workbenchToolRuntimeUiStore.js +85 -0
  49. package/dist/workbench/workbenchWindowRuntime.d.ts +19 -0
  50. package/dist/workbench/workbenchWindowRuntime.js +85 -0
  51. package/dist/workbench/workbenchWorkspaceActions.d.ts +30 -0
  52. package/dist/workbench/workbenchWorkspaceActions.js +55 -0
  53. package/dist/workbench/workspaceHistoryController.d.ts +28 -0
  54. package/dist/workbench/workspaceHistoryController.js +126 -0
  55. package/dist/workbench/workspaceSyncController.d.ts +20 -0
  56. package/dist/workbench/workspaceSyncController.js +105 -0
  57. package/package.json +49 -0
@@ -0,0 +1,90 @@
1
+ import { createBootContext, createBootEventBus, createBootExecutor, createBootProjection, } from '@konitif/workbench';
2
+ import { createDemoWorkbenchBootGraph, } from "./createDemoWorkbenchBootGraph.js";
3
+ export function createWorkbenchBootSession(options = {}) {
4
+ const graph = options.graph ?? createDemoWorkbenchBootGraph(options.demoGraph);
5
+ const context = options.context ?? createBootContext({ mode: options.mode ?? 'normal' });
6
+ const eventBus = options.eventBus ?? createBootEventBus();
7
+ const executor = createBootExecutor({
8
+ eventBus,
9
+ now: options.now,
10
+ createExecutionId: options.createExecutionId,
11
+ });
12
+ const eventHistoryLimit = Math.max(1, options.eventHistoryLimit ?? 20);
13
+ const subscribers = new Set();
14
+ let lastEvent;
15
+ let eventHistory = [];
16
+ let projection = createBootProjection(createIdleBootExecutionState(graph), context.mode, undefined, eventHistory);
17
+ eventBus.subscribe((event) => {
18
+ lastEvent = event;
19
+ eventHistory = [...eventHistory, event].slice(-eventHistoryLimit);
20
+ const state = 'state' in event ? event.state : executor.getState();
21
+ projection = createBootProjection(state, context.mode, lastEvent, eventHistory);
22
+ notifySubscribers(subscribers, projection);
23
+ });
24
+ return {
25
+ graph,
26
+ context,
27
+ executor,
28
+ getProjection() {
29
+ return projection;
30
+ },
31
+ getEventHistory() {
32
+ return [...eventHistory];
33
+ },
34
+ subscribe(listener) {
35
+ subscribers.add(listener);
36
+ listener(projection);
37
+ return () => {
38
+ subscribers.delete(listener);
39
+ };
40
+ },
41
+ async start() {
42
+ const state = await executor.run(graph, context);
43
+ projection = createBootProjection(state, context.mode, lastEvent, eventHistory);
44
+ notifySubscribers(subscribers, projection);
45
+ return state;
46
+ },
47
+ async teardown() {
48
+ const state = await executor.teardown(context);
49
+ projection = createBootProjection(state, context.mode, lastEvent, eventHistory);
50
+ notifySubscribers(subscribers, projection);
51
+ return state;
52
+ },
53
+ };
54
+ }
55
+ function createIdleBootExecutionState(graph) {
56
+ const state = {
57
+ executionId: 'boot-idle',
58
+ phase: 'plan',
59
+ steps: {},
60
+ nodes: {},
61
+ failed: false,
62
+ errors: [],
63
+ };
64
+ for (const step of graph.steps) {
65
+ if (state.steps[step.id]) {
66
+ continue;
67
+ }
68
+ const stepState = {
69
+ id: step.id,
70
+ label: step.label,
71
+ phase: step.phase,
72
+ status: 'pending',
73
+ criticality: step.criticality ?? 'critical',
74
+ dependencies: step.dependsOn?.map((dependency) => ({ ...dependency })) ?? [],
75
+ };
76
+ state.steps[step.id] = stepState;
77
+ state.nodes[step.id] = {
78
+ state: stepState,
79
+ attempts: 0,
80
+ warnings: [],
81
+ metadata: {},
82
+ };
83
+ }
84
+ return state;
85
+ }
86
+ function notifySubscribers(subscribers, projection) {
87
+ for (const subscriber of subscribers) {
88
+ subscriber(projection);
89
+ }
90
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./createDemoWorkbenchBootGraph.js";
2
+ export * from "./createLegacyWorkbenchBootGraph.js";
3
+ export * from "./createWorkbenchBootSession.js";
@@ -0,0 +1,3 @@
1
+ export * from "./createDemoWorkbenchBootGraph.js";
2
+ export * from "./createLegacyWorkbenchBootGraph.js";
3
+ export * from "./createWorkbenchBootSession.js";
@@ -0,0 +1,10 @@
1
+ export * from "./boot/index.js";
2
+ export * from "./workbench/createWorkbenchStore.js";
3
+ export * from "./workbench/createWorkspaceModeController.js";
4
+ export * from "./workbench/workbenchShellPersistence.js";
5
+ export * from "./workbench/workbenchFocusPersistence.js";
6
+ export * from "./workbench/workbenchShellActions.js";
7
+ export * from "./workbench/workbenchToolRuntimeActions.js";
8
+ export * from "./workbench/workspaceHistoryController.js";
9
+ export * from "./workbench/workspaceSyncController.js";
10
+ export type { WorkbenchHostEvents, WorkbenchHostEventHandlers, WorkbenchHostStorageChange } from "./workbench/workbenchHostEvents.js";
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./boot/index.js";
2
+ export * from "./workbench/createWorkbenchStore.js";
3
+ export * from "./workbench/createWorkspaceModeController.js";
4
+ export * from "./workbench/workbenchShellPersistence.js";
5
+ export * from "./workbench/workbenchFocusPersistence.js";
6
+ export * from "./workbench/workbenchShellActions.js";
7
+ export * from "./workbench/workbenchToolRuntimeActions.js";
8
+ export * from "./workbench/workspaceHistoryController.js";
9
+ export * from "./workbench/workspaceSyncController.js";
@@ -0,0 +1,7 @@
1
+ export { createWorkbenchStoreRuntime } from "./workbench/createWorkbenchStoreRuntime.js";
2
+ export type { CreateWorkbenchStoreRuntimeOptions } from "./workbench/createWorkbenchStoreRuntime.js";
3
+ export type { WorkbenchHostEvents, WorkbenchHostEventHandlers, WorkbenchHostStorageChange } from "./workbench/workbenchHostEvents.js";
4
+ export type { WorkbenchDetachedWindowHost, WorkbenchDetachedWindowOpening } from "./workbench/workbenchDetachedWindowHost.js";
5
+ export type { WorkbenchShellPersistencePort } from "./workbench/workbenchShellPersistence.js";
6
+ export type { WorkbenchFocusPersistencePort } from "./workbench/workbenchFocusPersistence.js";
7
+ export type { WorkspaceSyncController, WorkspaceSyncSnapshot } from "./workbench/workspaceSyncController.js";
@@ -0,0 +1,2 @@
1
+ // Explicit host assembly: no default browser providers are selected here.
2
+ export { createWorkbenchStoreRuntime } from "./workbench/createWorkbenchStoreRuntime.js";
@@ -0,0 +1,3 @@
1
+ import type { WorkbenchDetachedWindowHost } from "./workbenchDetachedWindowHost.js";
2
+ /** No host access until open; each observation owns only its polling timer. */
3
+ export declare function createBrowserDetachedWindowHost(): WorkbenchDetachedWindowHost;
@@ -0,0 +1,69 @@
1
+ /** No host access until open; each observation owns only its polling timer. */
2
+ export function createBrowserDetachedWindowHost() {
3
+ return {
4
+ open(windowId) {
5
+ const handle = openDetachedBrowserWindow(windowId);
6
+ if (handle === null)
7
+ return { status: 'blocked' };
8
+ if (!handle || typeof handle.closed !== 'boolean')
9
+ return { status: 'unmanaged' };
10
+ return {
11
+ status: 'opened',
12
+ observeClosed(onClosed) {
13
+ let active = true;
14
+ let timer;
15
+ const poll = () => {
16
+ if (!active)
17
+ return;
18
+ if (handle.closed) {
19
+ active = false;
20
+ onClosed();
21
+ }
22
+ else
23
+ timer = setTimeout(poll, 500);
24
+ };
25
+ timer = setTimeout(poll, 500);
26
+ return () => {
27
+ active = false;
28
+ clearTimeout(timer);
29
+ };
30
+ }
31
+ };
32
+ }
33
+ };
34
+ }
35
+ function openDetachedBrowserWindow(windowId) {
36
+ if (typeof window === 'undefined') {
37
+ return;
38
+ }
39
+ const url = new URL(window.location.href);
40
+ url.searchParams.set('window', windowId);
41
+ const detachedWindow = window.open(url.toString(), `workbench-detached-${windowId}`, createDetachedWindowFeatures());
42
+ try {
43
+ detachedWindow?.focus();
44
+ }
45
+ catch {
46
+ // Focus denial does not undo a successful native opening.
47
+ }
48
+ return detachedWindow;
49
+ }
50
+ function createDetachedWindowFeatures() {
51
+ if (typeof window === 'undefined') {
52
+ return 'popup=yes,width=1280,height=860,resizable=yes,scrollbars=no';
53
+ }
54
+ const availableWidth = window.screen?.availWidth ?? window.outerWidth ?? 1440;
55
+ const availableHeight = window.screen?.availHeight ?? window.outerHeight ?? 960;
56
+ const width = Math.min(1280, Math.max(960, Math.round(availableWidth * 0.72)));
57
+ const height = Math.min(900, Math.max(720, Math.round(availableHeight * 0.78)));
58
+ const left = Math.max(0, Math.round((availableWidth - width) / 2));
59
+ const top = Math.max(0, Math.round((availableHeight - height) / 2));
60
+ return [
61
+ 'popup=yes',
62
+ `width=${width}`,
63
+ `height=${height}`,
64
+ `left=${left}`,
65
+ `top=${top}`,
66
+ 'resizable=yes',
67
+ 'scrollbars=no'
68
+ ].join(',');
69
+ }
@@ -0,0 +1,3 @@
1
+ import type { WorkbenchHostEvents } from "./workbenchHostEvents.js";
2
+ /** No host access or subscriptions until subscribe is called. */
3
+ export declare function createBrowserWorkbenchHostEvents(): WorkbenchHostEvents;
@@ -0,0 +1,35 @@
1
+ /** No host access or subscriptions until subscribe is called. */
2
+ export function createBrowserWorkbenchHostEvents() {
3
+ return {
4
+ subscribe(handlers) {
5
+ const hostWindow = typeof window === 'undefined' ? null : window;
6
+ const hostDocument = typeof document === 'undefined' ? null : document;
7
+ let disposed = false;
8
+ function boundary() {
9
+ if (!disposed)
10
+ handlers.onPersistenceBoundary();
11
+ }
12
+ function storage(event) {
13
+ if (!disposed)
14
+ handlers.onStorageChange({ key: event.key, newValue: event.newValue });
15
+ }
16
+ function visibility() {
17
+ if (hostDocument?.visibilityState === 'hidden')
18
+ boundary();
19
+ }
20
+ hostWindow?.addEventListener('pagehide', boundary);
21
+ hostWindow?.addEventListener('beforeunload', boundary);
22
+ hostWindow?.addEventListener('storage', storage);
23
+ hostDocument?.addEventListener('visibilitychange', visibility);
24
+ return () => {
25
+ if (disposed)
26
+ return;
27
+ disposed = true;
28
+ hostWindow?.removeEventListener('pagehide', boundary);
29
+ hostWindow?.removeEventListener('beforeunload', boundary);
30
+ hostWindow?.removeEventListener('storage', storage);
31
+ hostDocument?.removeEventListener('visibilitychange', visibility);
32
+ };
33
+ }
34
+ };
35
+ }
@@ -0,0 +1,129 @@
1
+ import { type CreateWorkbenchStoreRuntimeOptions } from "./createWorkbenchStoreRuntime.js";
2
+ type DefaultedPort = 'workspacePersistence' | 'shellPersistence' | 'focusPersistence' | 'workspaceSync' | 'hostEvents' | 'detachedWindows';
3
+ export type CreateWorkbenchStoreOptions = Omit<CreateWorkbenchStoreRuntimeOptions, DefaultedPort> & Partial<Pick<CreateWorkbenchStoreRuntimeOptions, DefaultedPort>>;
4
+ /** Compatible browser assembly. The runtime owns state, not provider selection. */
5
+ export declare function createWorkbenchStore(options: CreateWorkbenchStoreOptions): {
6
+ dispose(): void;
7
+ flushPersistence: () => void;
8
+ workspaceStore: {
9
+ subscribe: (this: void, run: import("svelte/store").Subscriber<{
10
+ toolRuntimeUi: import("./workbenchToolRuntimeUiStore.js").ToolRuntimeUiStateMap;
11
+ workspace: import("@konitif/workbench").WorkspaceSessionState["workspace"];
12
+ focus: import("@konitif/workbench").WorkspaceSessionState["focus"];
13
+ shell: import("@konitif/workbench").ShellState;
14
+ layoutInteraction: import("@konitif/workbench").LayoutInteractionState;
15
+ }>, invalidate?: import("svelte/store").Invalidator<{
16
+ toolRuntimeUi: import("./workbenchToolRuntimeUiStore.js").ToolRuntimeUiStateMap;
17
+ workspace: import("@konitif/workbench").WorkspaceSessionState["workspace"];
18
+ focus: import("@konitif/workbench").WorkspaceSessionState["focus"];
19
+ shell: import("@konitif/workbench").ShellState;
20
+ layoutInteraction: import("@konitif/workbench").LayoutInteractionState;
21
+ }> | undefined) => import("svelte/store").Unsubscriber;
22
+ };
23
+ workspaceHistoryStore: {
24
+ subscribe: (this: void, run: import("svelte/store").Subscriber<import("./workspaceHistoryController.js").WorkbenchHistoryStatus>, invalidate?: import("svelte/store").Invalidator<import("./workspaceHistoryController.js").WorkbenchHistoryStatus> | undefined) => import("svelte/store").Unsubscriber;
25
+ };
26
+ workspaceActions: {
27
+ dispatchCommand(command: import("@konitif/workbench").WorkspaceCommand): void;
28
+ toolRuntime: import("@konitif/workbench").ToolRuntimeHostActions;
29
+ beginAppHistoryTransaction: () => void;
30
+ commitAppHistoryTransaction: () => void;
31
+ cancelAppHistoryTransaction: () => void;
32
+ beginCoreHistoryTransaction: () => void;
33
+ commitCoreHistoryTransaction: () => void;
34
+ cancelCoreHistoryTransaction: () => void;
35
+ undoAppHistory: () => void;
36
+ redoAppHistory: () => void;
37
+ undoCoreHistory: () => void;
38
+ redoCoreHistory: () => void;
39
+ addShellWidgetToRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
40
+ activateShellWidget(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string): void;
41
+ moveShellWidgetToRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
42
+ removeShellWidgetFromRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string): void;
43
+ setShellRegionArrangement(regionId: import("@konitif/workbench").ShellRegionId, presentation: import("@konitif/workbench").ShellRegionPresentation, axis?: import("@konitif/workbench").ShellRegionAxis): void;
44
+ setShellRegionOpen(regionId: import("@konitif/workbench").ShellRegionId, isOpen: boolean): void;
45
+ setShellRegionVisible(regionId: import("@konitif/workbench").ShellRegionId, isVisible: boolean): void;
46
+ setShellRegionWidgetVisible(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, isVisible: boolean): void;
47
+ setShellRegionSize(regionId: import("@konitif/workbench").ShellRegionId, size: number): void;
48
+ disposeDetachedWindowTracking(): void;
49
+ detachPanelToWindow(panelId: string): string | null;
50
+ resizeSplit(splitId: string, sizes: [number, number]): void;
51
+ resizeSplitBoundary(rootSplitId: string, boundaryIndex: number, deltaRatio: number, mode?: "local" | "proportional"): void;
52
+ collapseSplit(splitId: string, removeChildIndex: 0 | 1): void;
53
+ collapseSplitBoundary(rootSplitId: string, boundaryIndex: number, removeSide: "start" | "end"): void;
54
+ openLayoutSplitMenu(panelId: string | null, edge: import("@konitif/workbench").LayoutEdge, anchor: {
55
+ x: number;
56
+ y: number;
57
+ }, targets?: import("@konitif/workbench").LayoutMenuTarget[], options?: {
58
+ source?: "workspace-edge" | "split-boundary" | "panel-menu";
59
+ initialActionId?: import("@konitif/workbench").LayoutMenuActionId | null;
60
+ }): void;
61
+ selectLayoutSplitOrientation(orientation: import("@konitif/workbench").SplitOrientation): void;
62
+ selectLayoutMenuAction(selection: import("@konitif/workbench").LayoutMenuActionSelection | null): void;
63
+ hoverLayoutSplitSide(side: import("@konitif/workbench").LayoutDockSide | null): void;
64
+ confirmLayoutSplitSide(side: import("@konitif/workbench").LayoutDockSide): void;
65
+ updateLayoutSplitPreview(panelId: string | null, pointerRatio: number): void;
66
+ adjustLayoutSplitPreviewCuts(delta: number): void;
67
+ startLayoutSplitPreview(panelId: string, edge: import("@konitif/workbench").LayoutEdge, orientation: import("@konitif/workbench").SplitOrientation, cuts: number, pointerRatio: number): void;
68
+ startBoundaryPull(params: {
69
+ windowId?: string;
70
+ anchor: {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ horizontalEdge?: "left" | "right" | null;
75
+ verticalEdge?: "top" | "bottom" | null;
76
+ source?: "edge" | "corner";
77
+ neutralThreshold?: number;
78
+ creationThreshold?: number;
79
+ }): void;
80
+ updateBoundaryPull(pointer: {
81
+ x: number;
82
+ y: number;
83
+ }, viewport: {
84
+ width: number;
85
+ height: number;
86
+ }): void;
87
+ commitBoundaryPull(): void;
88
+ startIntersectionResize(params: {
89
+ anchor: {
90
+ x: number;
91
+ y: number;
92
+ };
93
+ columnSplitId: string;
94
+ rowSplitId: string;
95
+ columnBaseSizes: [number, number];
96
+ rowBaseSizes: [number, number];
97
+ }): void;
98
+ updateIntersectionResize(pointer: {
99
+ x: number;
100
+ y: number;
101
+ }, dimensions: {
102
+ width: number;
103
+ height: number;
104
+ }): void;
105
+ commitIntersectionResize(): void;
106
+ startPanelDrag(panelId: string, sourceStackId: string, anchor: {
107
+ x: number;
108
+ y: number;
109
+ }): void;
110
+ updatePanelDrag(pointer: {
111
+ x: number;
112
+ y: number;
113
+ }, hoveredTarget: import("@konitif/workbench").LayoutDockTarget | null): void;
114
+ commitPanelDock(): void;
115
+ commitLayoutSubdivideSelection(panelId: string, edge: import("@konitif/workbench").LayoutEdge, orientation: import("@konitif/workbench").SplitOrientation, cuts: number, pointerRatio: number): void;
116
+ commitLayoutSplitPreview(): void;
117
+ cancelLayoutInteraction(): void;
118
+ applyWorkspaceSession(workspaceSession: import("@konitif/workbench").WorkspaceSessionState, historyScope?: import("./workspaceHistoryController.js").WorkbenchHistoryScope): void;
119
+ applyWorkspacePresetArtifact(artifact: import("@konitif/workbench").WorkspacePresetArtifact): void;
120
+ resetWorkspace(mode?: import("./workbenchWorkspaceActions.js").InitialWorkbenchWorkspaceMode | "initial"): void;
121
+ loadPreset(presetId: import("@konitif/workbench").WorkspacePresetId): void;
122
+ exportWorkspaceSnapshot(): string;
123
+ importWorkspaceSnapshot(source: string): import("@konitif/workbench").WorkspaceSnapshotImportResult;
124
+ setFullscreenPanel(panelId: string | null): void;
125
+ setDesignSystemThemeSession(nextSession: import("@konitif/workbench").DesignSystemThemeSession | null): void;
126
+ };
127
+ __resetWorkspaceStoreForTests: () => void;
128
+ };
129
+ export {};
@@ -0,0 +1,50 @@
1
+ import { LocalWorkspacePersistence } from '@konitif/workbench';
2
+ import { createLocalWorkbenchShellPersistence } from "./workbenchShellPersistence.js";
3
+ import { createLocalWorkbenchFocusPersistence } from "./workbenchFocusPersistence.js";
4
+ import { createBrowserWorkspaceSyncController } from "./workspaceSyncController.js";
5
+ import { createBrowserWorkbenchHostEvents } from "./browserWorkbenchHostEvents.js";
6
+ import { createBrowserDetachedWindowHost } from "./browserDetachedWindowHost.js";
7
+ import { createWorkbenchStoreRuntime } from "./createWorkbenchStoreRuntime.js";
8
+ /** Compatible browser assembly. The runtime owns state, not provider selection. */
9
+ export function createWorkbenchStore(options) {
10
+ const isEnabled = () => options.persistenceEnabled?.() ?? true;
11
+ const workspacePersistence = options.workspacePersistence ?? new LocalWorkspacePersistence(options.persistenceKey);
12
+ const shellPersistence = options.shellPersistence ?? createLocalWorkbenchShellPersistence({
13
+ storageKey: options.shellPersistenceKey ?? `${options.persistenceKey}.shell`,
14
+ isEnabled,
15
+ shellWidgetCatalog: options.shellWidgetCatalog
16
+ });
17
+ const workspaceSync = options.workspaceSync ?? createBrowserWorkspaceSyncController({
18
+ persistenceKey: options.persistenceKey,
19
+ isEnabled
20
+ });
21
+ const focusPersistence = options.focusPersistence ?? createLocalWorkbenchFocusPersistence({
22
+ storageKey: options.focusPersistenceKey ?? `${options.persistenceKey}.focus`,
23
+ isEnabled
24
+ });
25
+ const runtime = createWorkbenchStoreRuntime({
26
+ ...options,
27
+ workspacePersistence,
28
+ shellPersistence,
29
+ focusPersistence,
30
+ workspaceSync,
31
+ hostEvents: options.hostEvents === undefined ? createBrowserWorkbenchHostEvents() : options.hostEvents,
32
+ detachedWindows: options.detachedWindows === undefined ? createBrowserDetachedWindowHost() : options.detachedWindows
33
+ });
34
+ let disposed = false;
35
+ return {
36
+ ...runtime,
37
+ dispose() {
38
+ if (disposed)
39
+ return;
40
+ disposed = true;
41
+ try {
42
+ runtime.dispose();
43
+ }
44
+ finally {
45
+ if (!options.workspaceSync)
46
+ workspaceSync.dispose?.();
47
+ }
48
+ }
49
+ };
50
+ }
@@ -0,0 +1,154 @@
1
+ import type { WorkbenchHostEvents } from "./workbenchHostEvents.js";
2
+ import type { WorkbenchShellPersistencePort } from "./workbenchShellPersistence.js";
3
+ import type { WorkbenchFocusPersistencePort } from "./workbenchFocusPersistence.js";
4
+ import type { WorkbenchHistoryScope } from "./workspaceHistoryController.js";
5
+ import type { WorkspaceSyncController } from "./workspaceSyncController.js";
6
+ import { type InitialWorkbenchWorkspaceMode } from "./workbenchWorkspaceActions.js";
7
+ import type { WorkbenchDetachedWindowHost } from "./workbenchDetachedWindowHost.js";
8
+ import { type ShellRegionId, type ShellWidgetCatalog, type ToolCatalog, type WorkspaceCommand, type WorkspacePersistencePort } from '@konitif/workbench/workspace-contracts';
9
+ type InitialWorkspaceMode = InitialWorkbenchWorkspaceMode;
10
+ export interface CreateWorkbenchStoreRuntimeOptions {
11
+ initialToolId: string;
12
+ persistenceKey: string;
13
+ shellPersistenceKey?: string;
14
+ focusPersistenceKey?: string;
15
+ toolCatalog: ToolCatalog;
16
+ shellWidgetCatalog: ShellWidgetCatalog;
17
+ workspacePersistence: WorkspacePersistencePort;
18
+ shellPersistence: WorkbenchShellPersistencePort;
19
+ focusPersistence: WorkbenchFocusPersistencePort;
20
+ workspaceSync: WorkspaceSyncController;
21
+ /** Explicit provider; null disables host notifications. */
22
+ hostEvents: WorkbenchHostEvents | null;
23
+ detachedWindows: WorkbenchDetachedWindowHost | null;
24
+ persistenceDebounceMs?: number;
25
+ initialWorkspaceMode?: InitialWorkspaceMode;
26
+ initialStackHeaderVisible?: boolean;
27
+ defaultOpenShellRegions?: ShellRegionId[];
28
+ persistenceEnabled?: () => boolean;
29
+ }
30
+ export declare function createWorkbenchStoreRuntime(options: CreateWorkbenchStoreRuntimeOptions): {
31
+ dispose: () => void;
32
+ flushPersistence: () => void;
33
+ workspaceStore: {
34
+ subscribe: (this: void, run: import("svelte/store").Subscriber<{
35
+ toolRuntimeUi: import("./workbenchToolRuntimeUiStore.js").ToolRuntimeUiStateMap;
36
+ workspace: import("@konitif/workbench").WorkspaceSessionState["workspace"];
37
+ focus: import("@konitif/workbench").WorkspaceSessionState["focus"];
38
+ shell: import("@konitif/workbench").ShellState;
39
+ layoutInteraction: import("@konitif/workbench").LayoutInteractionState;
40
+ }>, invalidate?: import("svelte/store").Invalidator<{
41
+ toolRuntimeUi: import("./workbenchToolRuntimeUiStore.js").ToolRuntimeUiStateMap;
42
+ workspace: import("@konitif/workbench").WorkspaceSessionState["workspace"];
43
+ focus: import("@konitif/workbench").WorkspaceSessionState["focus"];
44
+ shell: import("@konitif/workbench").ShellState;
45
+ layoutInteraction: import("@konitif/workbench").LayoutInteractionState;
46
+ }> | undefined) => import("svelte/store").Unsubscriber;
47
+ };
48
+ workspaceHistoryStore: {
49
+ subscribe: (this: void, run: import("svelte/store").Subscriber<import("./workspaceHistoryController.js").WorkbenchHistoryStatus>, invalidate?: import("svelte/store").Invalidator<import("./workspaceHistoryController.js").WorkbenchHistoryStatus> | undefined) => import("svelte/store").Unsubscriber;
50
+ };
51
+ workspaceActions: {
52
+ dispatchCommand(command: WorkspaceCommand): void;
53
+ toolRuntime: import("@konitif/workbench").ToolRuntimeHostActions;
54
+ beginAppHistoryTransaction: () => void;
55
+ commitAppHistoryTransaction: () => void;
56
+ cancelAppHistoryTransaction: () => void;
57
+ beginCoreHistoryTransaction: () => void;
58
+ commitCoreHistoryTransaction: () => void;
59
+ cancelCoreHistoryTransaction: () => void;
60
+ undoAppHistory: () => void;
61
+ redoAppHistory: () => void;
62
+ undoCoreHistory: () => void;
63
+ redoCoreHistory: () => void;
64
+ addShellWidgetToRegion(regionId: ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
65
+ activateShellWidget(regionId: ShellRegionId, widgetId: string): void;
66
+ moveShellWidgetToRegion(regionId: ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
67
+ removeShellWidgetFromRegion(regionId: ShellRegionId, widgetId: string): void;
68
+ setShellRegionArrangement(regionId: ShellRegionId, presentation: import("@konitif/workbench").ShellRegionPresentation, axis?: import("@konitif/workbench").ShellRegionAxis): void;
69
+ setShellRegionOpen(regionId: ShellRegionId, isOpen: boolean): void;
70
+ setShellRegionVisible(regionId: ShellRegionId, isVisible: boolean): void;
71
+ setShellRegionWidgetVisible(regionId: ShellRegionId, widgetId: string, isVisible: boolean): void;
72
+ setShellRegionSize(regionId: ShellRegionId, size: number): void;
73
+ disposeDetachedWindowTracking(): void;
74
+ detachPanelToWindow(panelId: string): string | null;
75
+ resizeSplit(splitId: string, sizes: [number, number]): void;
76
+ resizeSplitBoundary(rootSplitId: string, boundaryIndex: number, deltaRatio: number, mode?: "local" | "proportional"): void;
77
+ collapseSplit(splitId: string, removeChildIndex: 0 | 1): void;
78
+ collapseSplitBoundary(rootSplitId: string, boundaryIndex: number, removeSide: "start" | "end"): void;
79
+ openLayoutSplitMenu(panelId: string | null, edge: import("@konitif/workbench").LayoutEdge, anchor: {
80
+ x: number;
81
+ y: number;
82
+ }, targets?: import("@konitif/workbench").LayoutMenuTarget[], options?: {
83
+ source?: "workspace-edge" | "split-boundary" | "panel-menu";
84
+ initialActionId?: import("@konitif/workbench").LayoutMenuActionId | null;
85
+ }): void;
86
+ selectLayoutSplitOrientation(orientation: import("@konitif/workbench").SplitOrientation): void;
87
+ selectLayoutMenuAction(selection: import("@konitif/workbench").LayoutMenuActionSelection | null): void;
88
+ hoverLayoutSplitSide(side: import("@konitif/workbench").LayoutDockSide | null): void;
89
+ confirmLayoutSplitSide(side: import("@konitif/workbench").LayoutDockSide): void;
90
+ updateLayoutSplitPreview(panelId: string | null, pointerRatio: number): void;
91
+ adjustLayoutSplitPreviewCuts(delta: number): void;
92
+ startLayoutSplitPreview(panelId: string, edge: import("@konitif/workbench").LayoutEdge, orientation: import("@konitif/workbench").SplitOrientation, cuts: number, pointerRatio: number): void;
93
+ startBoundaryPull(params: {
94
+ windowId?: string;
95
+ anchor: {
96
+ x: number;
97
+ y: number;
98
+ };
99
+ horizontalEdge?: "left" | "right" | null;
100
+ verticalEdge?: "top" | "bottom" | null;
101
+ source?: "edge" | "corner";
102
+ neutralThreshold?: number;
103
+ creationThreshold?: number;
104
+ }): void;
105
+ updateBoundaryPull(pointer: {
106
+ x: number;
107
+ y: number;
108
+ }, viewport: {
109
+ width: number;
110
+ height: number;
111
+ }): void;
112
+ commitBoundaryPull(): void;
113
+ startIntersectionResize(params: {
114
+ anchor: {
115
+ x: number;
116
+ y: number;
117
+ };
118
+ columnSplitId: string;
119
+ rowSplitId: string;
120
+ columnBaseSizes: [number, number];
121
+ rowBaseSizes: [number, number];
122
+ }): void;
123
+ updateIntersectionResize(pointer: {
124
+ x: number;
125
+ y: number;
126
+ }, dimensions: {
127
+ width: number;
128
+ height: number;
129
+ }): void;
130
+ commitIntersectionResize(): void;
131
+ startPanelDrag(panelId: string, sourceStackId: string, anchor: {
132
+ x: number;
133
+ y: number;
134
+ }): void;
135
+ updatePanelDrag(pointer: {
136
+ x: number;
137
+ y: number;
138
+ }, hoveredTarget: import("@konitif/workbench").LayoutDockTarget | null): void;
139
+ commitPanelDock(): void;
140
+ commitLayoutSubdivideSelection(panelId: string, edge: import("@konitif/workbench").LayoutEdge, orientation: import("@konitif/workbench").SplitOrientation, cuts: number, pointerRatio: number): void;
141
+ commitLayoutSplitPreview(): void;
142
+ cancelLayoutInteraction(): void;
143
+ applyWorkspaceSession(workspaceSession: import("@konitif/workbench").WorkspaceSessionState, historyScope?: WorkbenchHistoryScope): void;
144
+ applyWorkspacePresetArtifact(artifact: import("@konitif/workbench").WorkspacePresetArtifact): void;
145
+ resetWorkspace(mode?: InitialWorkbenchWorkspaceMode | "initial"): void;
146
+ loadPreset(presetId: import("@konitif/workbench").WorkspacePresetId): void;
147
+ exportWorkspaceSnapshot(): string;
148
+ importWorkspaceSnapshot(source: string): import("@konitif/workbench").WorkspaceSnapshotImportResult;
149
+ setFullscreenPanel(panelId: string | null): void;
150
+ setDesignSystemThemeSession(nextSession: import("@konitif/workbench").DesignSystemThemeSession | null): void;
151
+ };
152
+ __resetWorkspaceStoreForTests: () => void;
153
+ };
154
+ export {};