@konitif/workbench-runtime 0.284.3 → 0.284.5
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/README.md +7 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -0
- package/dist/workbench/coherentWorkbenchPersistence.d.ts +43 -0
- package/dist/workbench/coherentWorkbenchPersistence.js +101 -0
- package/dist/workbench/createCoherentWorkbenchStore.d.ts +140 -0
- package/dist/workbench/createCoherentWorkbenchStore.js +33 -0
- package/dist/workbench/createWorkbenchStore.d.ts +1 -0
- package/dist/workbench/createWorkbenchStoreRuntime.d.ts +6 -0
- package/dist/workbench/createWorkbenchStoreRuntime.js +6 -5
- package/dist/workbench/workbenchShellActions.d.ts +1 -0
- package/dist/workbench/workbenchShellActions.js +4 -1
- package/dist/workbench/workbenchShellPersistence.js +8 -0
- package/package.json +2 -2
- package/reference/catalog.json +9 -2
- package/reference/diagrams.json +1 -1
package/README.md
CHANGED
|
@@ -14,15 +14,21 @@ npm install @konitif/workbench-runtime
|
|
|
14
14
|
- Reactive Workbench stores and shell actions.
|
|
15
15
|
- Workspace history and synchronization controllers.
|
|
16
16
|
- Explicit ports for persistence, host events and detached windows.
|
|
17
|
+
- Admitted, content-addressed workspace usage persistence with explicit or boundary publication.
|
|
17
18
|
- A runtime assembly entry that selects no browser providers by default.
|
|
18
19
|
|
|
19
20
|
## Authority boundary
|
|
20
21
|
|
|
21
22
|
This package adapts Workbench authorities; it does not redefine workspace
|
|
22
|
-
semantics or own
|
|
23
|
+
semantics or own hosted tools, widgets, Viewers or domain policies. Supplied providers
|
|
23
24
|
remain owned by their hosts. Runtime disposal removes subscriptions but does not
|
|
24
25
|
implicitly flush persistence or close shared native resources.
|
|
25
26
|
|
|
27
|
+
`createCoherentWorkbenchStore` restores only usage bundles admitted by the
|
|
28
|
+
public Workbench authority, then publishes immutable occurrences through a
|
|
29
|
+
host-supplied compare-and-swap port. Product storage and conflict policy remain
|
|
30
|
+
outside this adapter.
|
|
31
|
+
|
|
26
32
|
## Quick start
|
|
27
33
|
|
|
28
34
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./boot/index.js";
|
|
2
|
+
export * from "./workbench/coherentWorkbenchPersistence.js";
|
|
3
|
+
export * from "./workbench/createCoherentWorkbenchStore.js";
|
|
2
4
|
export * from "./workbench/createWorkbenchStore.js";
|
|
3
5
|
export * from "./workbench/createWorkspaceModeController.js";
|
|
4
6
|
export * from "./workbench/workbenchShellPersistence.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./boot/index.js";
|
|
2
|
+
export * from "./workbench/coherentWorkbenchPersistence.js";
|
|
3
|
+
export * from "./workbench/createCoherentWorkbenchStore.js";
|
|
2
4
|
export * from "./workbench/createWorkbenchStore.js";
|
|
3
5
|
export * from "./workbench/createWorkspaceModeController.js";
|
|
4
6
|
export * from "./workbench/workbenchShellPersistence.js";
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { createWorkbenchStoreRuntime } from "./workbench/createWorkbenchStoreRuntime.js";
|
|
2
|
+
export * from "./workbench/coherentWorkbenchPersistence.js";
|
|
3
|
+
export * from "./workbench/createCoherentWorkbenchStore.js";
|
|
2
4
|
export type { CreateWorkbenchStoreRuntimeOptions } from "./workbench/createWorkbenchStoreRuntime.js";
|
|
3
5
|
export type { WorkbenchHostEvents, WorkbenchHostEventHandlers, WorkbenchHostStorageChange } from "./workbench/workbenchHostEvents.js";
|
|
4
6
|
export type { WorkbenchDetachedWindowHost, WorkbenchDetachedWindowOpening } from "./workbench/workbenchDetachedWindowHost.js";
|
package/dist/runtime.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
// Explicit host assembly: no default browser providers are selected here.
|
|
2
2
|
export { createWorkbenchStoreRuntime } from "./workbench/createWorkbenchStoreRuntime.js";
|
|
3
|
+
export * from "./workbench/coherentWorkbenchPersistence.js";
|
|
4
|
+
export * from "./workbench/createCoherentWorkbenchStore.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type WorkspacePresetArtifact, type WorkspaceUsageBundle, type WorkspaceUsageContext, type WorkspaceUsageContentPort, type WorkspaceUsageDiagnostic } from '@konitif/workbench/workspace-contracts';
|
|
2
|
+
import type { WorkbenchPersistenceState } from "./workbenchPersistenceRuntime.js";
|
|
3
|
+
export type CoherentWorkbenchPersistenceResult = {
|
|
4
|
+
status: 'published';
|
|
5
|
+
snapshotId: string;
|
|
6
|
+
} | {
|
|
7
|
+
status: 'conflict';
|
|
8
|
+
actualSnapshotId: string | null;
|
|
9
|
+
} | {
|
|
10
|
+
status: 'refused';
|
|
11
|
+
diagnostics: WorkspaceUsageDiagnostic[];
|
|
12
|
+
} | {
|
|
13
|
+
status: 'failed';
|
|
14
|
+
message: string;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'disposed';
|
|
17
|
+
};
|
|
18
|
+
export interface CoherentWorkbenchPersistenceHost {
|
|
19
|
+
read(): Promise<unknown | null>;
|
|
20
|
+
publish(bundle: WorkspaceUsageBundle, expectedSnapshotId: string | null): Promise<CoherentWorkbenchPersistenceResult>;
|
|
21
|
+
}
|
|
22
|
+
export interface CoherentWorkbenchPersistenceInput {
|
|
23
|
+
host: CoherentWorkbenchPersistenceHost;
|
|
24
|
+
content: WorkspaceUsageContentPort;
|
|
25
|
+
context: WorkspaceUsageContext;
|
|
26
|
+
source: WorkspacePresetArtifact;
|
|
27
|
+
restored: WorkspaceUsageBundle | null;
|
|
28
|
+
captureFragments(): Record<string, unknown>;
|
|
29
|
+
onResult(result: CoherentWorkbenchPersistenceResult): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createCoherentWorkbenchPersistence(input: CoherentWorkbenchPersistenceInput): {
|
|
32
|
+
handleStateChange: (next: WorkbenchPersistenceState) => void;
|
|
33
|
+
flush(): void;
|
|
34
|
+
save: () => Promise<CoherentWorkbenchPersistenceResult>;
|
|
35
|
+
rebindSource(next: WorkspacePresetArtifact): void;
|
|
36
|
+
currentSnapshotId: () => string | null;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
};
|
|
39
|
+
export declare function restoreCoherentWorkbenchUsage(host: CoherentWorkbenchPersistenceHost, context: WorkspaceUsageContext, content: WorkspaceUsageContentPort): Promise<WorkspaceUsageBundle | null>;
|
|
40
|
+
export declare class CoherentWorkbenchAdmissionError extends Error {
|
|
41
|
+
readonly diagnostics: WorkspaceUsageDiagnostic[];
|
|
42
|
+
constructor(diagnostics: WorkspaceUsageDiagnostic[]);
|
|
43
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { admitWorkspaceUsageBundle, createWorkspaceUsageBundle, compareWorkspaceUsageSource, serializeWorkspaceUsageContent, exportWorkspaceSnapshot, validateWorkspace } from '@konitif/workbench/workspace-contracts';
|
|
2
|
+
export function createCoherentWorkbenchPersistence(input) {
|
|
3
|
+
const context = JSON.parse(serializeWorkspaceUsageContent(input.context));
|
|
4
|
+
let source = JSON.parse(serializeWorkspaceUsageContent(input.source));
|
|
5
|
+
let head = input.restored?.snapshotId ?? null;
|
|
6
|
+
let previous = input.restored?.snapshot ?? null;
|
|
7
|
+
const sourceBindings = new Map();
|
|
8
|
+
if (previous)
|
|
9
|
+
sourceBindings.set(`${previous.source.presetId}@${previous.source.revision}`, previous.source.contentId);
|
|
10
|
+
let state = null;
|
|
11
|
+
let queue = Promise.resolve({ status: 'disposed' });
|
|
12
|
+
let disposed = false;
|
|
13
|
+
function handleStateChange(next) {
|
|
14
|
+
if (!disposed)
|
|
15
|
+
state = next;
|
|
16
|
+
}
|
|
17
|
+
function save() {
|
|
18
|
+
if (disposed)
|
|
19
|
+
return Promise.resolve({ status: 'disposed' });
|
|
20
|
+
if (!state)
|
|
21
|
+
return Promise.resolve(emit({ status: 'failed', message: 'No usage state was supplied.' }));
|
|
22
|
+
let captured;
|
|
23
|
+
try {
|
|
24
|
+
if (validateWorkspace(state.workspace).length)
|
|
25
|
+
throw new TypeError('The workspace is not a valid serializable Workbench occurrence.');
|
|
26
|
+
const workspace = JSON.parse(exportWorkspaceSnapshot(state.workspace));
|
|
27
|
+
captured = JSON.parse(serializeWorkspaceUsageContent({ source, fragments: { ...input.captureFragments(), workspace, shell: state.shell, focus: state.focus } }));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return Promise.resolve(emit({ status: 'failed', message: String(error) }));
|
|
31
|
+
}
|
|
32
|
+
queue = queue.then(async () => {
|
|
33
|
+
if (disposed)
|
|
34
|
+
return { status: 'disposed' };
|
|
35
|
+
try {
|
|
36
|
+
const prepared = await createWorkspaceUsageBundle({ ...captured, context, parentSnapshotId: head }, input.content);
|
|
37
|
+
if (disposed)
|
|
38
|
+
return { status: 'disposed' };
|
|
39
|
+
if (!prepared.ok)
|
|
40
|
+
return emit({ status: 'refused', diagnostics: prepared.diagnostics });
|
|
41
|
+
const next = prepared.bundle.snapshot;
|
|
42
|
+
const known = sourceBindings.get(`${next.source.presetId}@${next.source.revision}`);
|
|
43
|
+
const diagnostics = previous ? compareWorkspaceUsageSource(previous, next) : [];
|
|
44
|
+
if (known && known !== next.source.contentId)
|
|
45
|
+
diagnostics.push({ code: 'usage.source-conflict', path: '$.source', message: 'This authored revision was already bound to other content in this session.' });
|
|
46
|
+
if (diagnostics.length)
|
|
47
|
+
return emit({ status: 'refused', diagnostics });
|
|
48
|
+
if (disposed)
|
|
49
|
+
return { status: 'disposed' };
|
|
50
|
+
const result = await input.host.publish(prepared.bundle, head);
|
|
51
|
+
if (result.status === 'published') {
|
|
52
|
+
if (result.snapshotId !== prepared.bundle.snapshotId)
|
|
53
|
+
return emit({ status: 'failed', message: 'Host returned an unexpected published identity; admission must be repeated.' });
|
|
54
|
+
head = result.snapshotId;
|
|
55
|
+
previous = next;
|
|
56
|
+
sourceBindings.set(`${next.source.presetId}@${next.source.revision}`, next.source.contentId);
|
|
57
|
+
}
|
|
58
|
+
return emit(result);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return emit({ status: 'failed', message: String(error) });
|
|
62
|
+
}
|
|
63
|
+
}, () => emit({ status: 'failed', message: 'Unexpected persistence queue rejection.' }));
|
|
64
|
+
return queue;
|
|
65
|
+
}
|
|
66
|
+
function emit(result) {
|
|
67
|
+
try {
|
|
68
|
+
input.onResult(result);
|
|
69
|
+
}
|
|
70
|
+
catch { }
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
handleStateChange,
|
|
75
|
+
flush() { void save(); },
|
|
76
|
+
save,
|
|
77
|
+
rebindSource(next) {
|
|
78
|
+
if (disposed)
|
|
79
|
+
throw new Error('Persistence is disposed.');
|
|
80
|
+
source = JSON.parse(serializeWorkspaceUsageContent(next));
|
|
81
|
+
},
|
|
82
|
+
currentSnapshotId: () => head,
|
|
83
|
+
dispose() { disposed = true; }
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export async function restoreCoherentWorkbenchUsage(host, context, content) {
|
|
87
|
+
const value = await host.read();
|
|
88
|
+
if (value === null)
|
|
89
|
+
return null;
|
|
90
|
+
const admission = await admitWorkspaceUsageBundle(value, context, content);
|
|
91
|
+
if (!admission.ok)
|
|
92
|
+
throw new CoherentWorkbenchAdmissionError(admission.diagnostics);
|
|
93
|
+
return admission.bundle;
|
|
94
|
+
}
|
|
95
|
+
export class CoherentWorkbenchAdmissionError extends Error {
|
|
96
|
+
diagnostics;
|
|
97
|
+
constructor(diagnostics) {
|
|
98
|
+
super(diagnostics.map(issue => `${issue.code}: ${issue.message}`).join('; '));
|
|
99
|
+
this.diagnostics = diagnostics;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type WorkspacePresetArtifact, type WorkspaceUsageContext, type WorkspaceUsageContentPort } from '@konitif/workbench/workspace-contracts';
|
|
2
|
+
import { type CreateWorkbenchStoreRuntimeOptions } from "./createWorkbenchStoreRuntime.js";
|
|
3
|
+
import { type CoherentWorkbenchPersistenceHost, type CoherentWorkbenchPersistenceResult } from "./coherentWorkbenchPersistence.js";
|
|
4
|
+
export declare function createCoherentWorkbenchStore(options: Omit<CreateWorkbenchStoreRuntimeOptions, 'coherentPersistence'> & {
|
|
5
|
+
usageHost: CoherentWorkbenchPersistenceHost;
|
|
6
|
+
content: WorkspaceUsageContentPort;
|
|
7
|
+
context: WorkspaceUsageContext;
|
|
8
|
+
source: WorkspacePresetArtifact;
|
|
9
|
+
publicationMode: 'explicit' | 'boundaries';
|
|
10
|
+
captureFragments(): Record<string, unknown>;
|
|
11
|
+
onPersistenceResult(result: CoherentWorkbenchPersistenceResult): void;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
restoredUsage: import("@konitif/workbench").WorkspaceUsageBundle | null;
|
|
14
|
+
saveUsage: () => Promise<CoherentWorkbenchPersistenceResult>;
|
|
15
|
+
rebindUsageSource: (next: WorkspacePresetArtifact) => void;
|
|
16
|
+
currentSnapshotId: () => string | null;
|
|
17
|
+
dispose: () => void;
|
|
18
|
+
flushPersistence: () => void;
|
|
19
|
+
workspaceStore: {
|
|
20
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<{
|
|
21
|
+
toolRuntimeUi: import("./workbenchToolRuntimeUiStore.js").ToolRuntimeUiStateMap;
|
|
22
|
+
workspace: import("@konitif/workbench").WorkspaceSessionState["workspace"];
|
|
23
|
+
focus: import("@konitif/workbench").WorkspaceSessionState["focus"];
|
|
24
|
+
shell: import("@konitif/workbench").ShellState;
|
|
25
|
+
layoutInteraction: import("@konitif/workbench").LayoutInteractionState;
|
|
26
|
+
}>, invalidate?: import("svelte/store").Invalidator<{
|
|
27
|
+
toolRuntimeUi: import("./workbenchToolRuntimeUiStore.js").ToolRuntimeUiStateMap;
|
|
28
|
+
workspace: import("@konitif/workbench").WorkspaceSessionState["workspace"];
|
|
29
|
+
focus: import("@konitif/workbench").WorkspaceSessionState["focus"];
|
|
30
|
+
shell: import("@konitif/workbench").ShellState;
|
|
31
|
+
layoutInteraction: import("@konitif/workbench").LayoutInteractionState;
|
|
32
|
+
}> | undefined) => import("svelte/store").Unsubscriber;
|
|
33
|
+
};
|
|
34
|
+
workspaceHistoryStore: {
|
|
35
|
+
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;
|
|
36
|
+
};
|
|
37
|
+
workspaceActions: {
|
|
38
|
+
dispatchCommand(command: import("@konitif/workbench").WorkspaceCommand): void;
|
|
39
|
+
toolRuntime: import("@konitif/workbench").ToolRuntimeHostActions;
|
|
40
|
+
beginAppHistoryTransaction: () => void;
|
|
41
|
+
commitAppHistoryTransaction: () => void;
|
|
42
|
+
cancelAppHistoryTransaction: () => void;
|
|
43
|
+
beginCoreHistoryTransaction: () => void;
|
|
44
|
+
commitCoreHistoryTransaction: () => void;
|
|
45
|
+
cancelCoreHistoryTransaction: () => void;
|
|
46
|
+
undoAppHistory: () => void;
|
|
47
|
+
redoAppHistory: () => void;
|
|
48
|
+
undoCoreHistory: () => void;
|
|
49
|
+
redoCoreHistory: () => void;
|
|
50
|
+
addShellWidgetToRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
|
|
51
|
+
activateShellWidget(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string): void;
|
|
52
|
+
moveShellWidgetToRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
|
|
53
|
+
removeShellWidgetFromRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string): void;
|
|
54
|
+
setShellRegionArrangement(regionId: import("@konitif/workbench").ShellRegionId, presentation: import("@konitif/workbench").ShellRegionPresentation, axis?: import("@konitif/workbench").ShellRegionAxis): void;
|
|
55
|
+
setShellRegionWidgetProportions(regionId: import("@konitif/workbench").ShellRegionId, proportions: Record<string, number>): void;
|
|
56
|
+
setShellRegionOpen(regionId: import("@konitif/workbench").ShellRegionId, isOpen: boolean): void;
|
|
57
|
+
setShellRegionVisible(regionId: import("@konitif/workbench").ShellRegionId, isVisible: boolean): void;
|
|
58
|
+
setShellRegionWidgetVisible(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, isVisible: boolean): void;
|
|
59
|
+
setShellRegionSize(regionId: import("@konitif/workbench").ShellRegionId, size: number): void;
|
|
60
|
+
disposeDetachedWindowTracking(): void;
|
|
61
|
+
detachPanelToWindow(panelId: string): string | null;
|
|
62
|
+
resizeSplit(splitId: string, sizes: [number, number]): void;
|
|
63
|
+
resizeSplitBoundary(rootSplitId: string, boundaryIndex: number, deltaRatio: number, mode?: "local" | "proportional"): void;
|
|
64
|
+
collapseSplit(splitId: string, removeChildIndex: 0 | 1): void;
|
|
65
|
+
collapseSplitBoundary(rootSplitId: string, boundaryIndex: number, removeSide: "start" | "end"): void;
|
|
66
|
+
openLayoutSplitMenu(panelId: string | null, edge: import("@konitif/workbench").LayoutEdge, anchor: {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
}, targets?: import("@konitif/workbench").LayoutMenuTarget[], options?: {
|
|
70
|
+
source?: "workspace-edge" | "split-boundary" | "panel-menu";
|
|
71
|
+
initialActionId?: import("@konitif/workbench").LayoutMenuActionId | null;
|
|
72
|
+
}): void;
|
|
73
|
+
selectLayoutSplitOrientation(orientation: import("@konitif/workbench").SplitOrientation): void;
|
|
74
|
+
selectLayoutMenuAction(selection: import("@konitif/workbench").LayoutMenuActionSelection | null): void;
|
|
75
|
+
hoverLayoutSplitSide(side: import("@konitif/workbench").LayoutDockSide | null): void;
|
|
76
|
+
confirmLayoutSplitSide(side: import("@konitif/workbench").LayoutDockSide): void;
|
|
77
|
+
updateLayoutSplitPreview(panelId: string | null, pointerRatio: number): void;
|
|
78
|
+
adjustLayoutSplitPreviewCuts(delta: number): void;
|
|
79
|
+
startLayoutSplitPreview(panelId: string, edge: import("@konitif/workbench").LayoutEdge, orientation: import("@konitif/workbench").SplitOrientation, cuts: number, pointerRatio: number): void;
|
|
80
|
+
startBoundaryPull(params: {
|
|
81
|
+
windowId?: string;
|
|
82
|
+
anchor: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
};
|
|
86
|
+
horizontalEdge?: "left" | "right" | null;
|
|
87
|
+
verticalEdge?: "top" | "bottom" | null;
|
|
88
|
+
source?: "edge" | "corner";
|
|
89
|
+
neutralThreshold?: number;
|
|
90
|
+
creationThreshold?: number;
|
|
91
|
+
}): void;
|
|
92
|
+
updateBoundaryPull(pointer: {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
}, viewport: {
|
|
96
|
+
width: number;
|
|
97
|
+
height: number;
|
|
98
|
+
}): void;
|
|
99
|
+
commitBoundaryPull(): void;
|
|
100
|
+
startIntersectionResize(params: {
|
|
101
|
+
anchor: {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
105
|
+
columnSplitId: string;
|
|
106
|
+
rowSplitId: string;
|
|
107
|
+
columnBaseSizes: [number, number];
|
|
108
|
+
rowBaseSizes: [number, number];
|
|
109
|
+
}): void;
|
|
110
|
+
updateIntersectionResize(pointer: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
}, dimensions: {
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
}): void;
|
|
117
|
+
commitIntersectionResize(): void;
|
|
118
|
+
startPanelDrag(panelId: string, sourceStackId: string, anchor: {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
}): void;
|
|
122
|
+
updatePanelDrag(pointer: {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
}, hoveredTarget: import("@konitif/workbench").LayoutDockTarget | null): void;
|
|
126
|
+
commitPanelDock(): void;
|
|
127
|
+
commitLayoutSubdivideSelection(panelId: string, edge: import("@konitif/workbench").LayoutEdge, orientation: import("@konitif/workbench").SplitOrientation, cuts: number, pointerRatio: number): void;
|
|
128
|
+
commitLayoutSplitPreview(): void;
|
|
129
|
+
cancelLayoutInteraction(): void;
|
|
130
|
+
applyWorkspaceSession(workspaceSession: import("@konitif/workbench").WorkspaceSessionState, historyScope?: import("./workspaceHistoryController.js").WorkbenchHistoryScope): void;
|
|
131
|
+
applyWorkspacePresetArtifact(artifact: WorkspacePresetArtifact): void;
|
|
132
|
+
resetWorkspace(mode?: import("./workbenchWorkspaceActions.js").InitialWorkbenchWorkspaceMode | "initial"): void;
|
|
133
|
+
loadPreset(presetId: import("@konitif/workbench").WorkspacePresetId): void;
|
|
134
|
+
exportWorkspaceSnapshot(): string;
|
|
135
|
+
importWorkspaceSnapshot(source: string): import("@konitif/workbench").WorkspaceSnapshotImportResult;
|
|
136
|
+
setFullscreenPanel(panelId: string | null): void;
|
|
137
|
+
setDesignSystemThemeSession(nextSession: import("@konitif/workbench").DesignSystemThemeSession | null): void;
|
|
138
|
+
};
|
|
139
|
+
__resetWorkspaceStoreForTests: () => void;
|
|
140
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createWorkspaceSessionState, createWorkspaceUsageBundle, serializeWorkspaceUsageContent } from '@konitif/workbench/workspace-contracts';
|
|
2
|
+
import { createWorkbenchStoreRuntime } from "./createWorkbenchStoreRuntime.js";
|
|
3
|
+
import { createWorkbenchStateFactory } from "./workbenchStateFactory.js";
|
|
4
|
+
import { createCoherentWorkbenchPersistence, restoreCoherentWorkbenchUsage, CoherentWorkbenchAdmissionError } from "./coherentWorkbenchPersistence.js";
|
|
5
|
+
export async function createCoherentWorkbenchStore(options) {
|
|
6
|
+
const context = JSON.parse(serializeWorkspaceUsageContent(options.context));
|
|
7
|
+
const source = JSON.parse(serializeWorkspaceUsageContent(options.source));
|
|
8
|
+
const publicationMode = options.publicationMode;
|
|
9
|
+
if (publicationMode !== 'explicit' && publicationMode !== 'boundaries')
|
|
10
|
+
throw new TypeError('An explicit coherent publication mode is required.');
|
|
11
|
+
const restored = await restoreCoherentWorkbenchUsage(options.usageHost, context, options.content);
|
|
12
|
+
if (!restored) {
|
|
13
|
+
const admission = await createWorkspaceUsageBundle({ source, context, fragments: { workspace: source.workspaceSession.workspace, shell: source.shellState, focus: source.workspaceSession.focus }, parentSnapshotId: null }, options.content);
|
|
14
|
+
if (!admission.ok)
|
|
15
|
+
throw new CoherentWorkbenchAdmissionError(admission.diagnostics);
|
|
16
|
+
}
|
|
17
|
+
const stateFactory = createWorkbenchStateFactory(options);
|
|
18
|
+
const initialState = restored
|
|
19
|
+
? stateFactory.createWorkbenchState(createWorkspaceSessionState(restored.fragments.workspace, restored.fragments.focus), restored.fragments.shell)
|
|
20
|
+
: stateFactory.createWorkbenchState(source.workspaceSession, source.shellState);
|
|
21
|
+
const coherent = createCoherentWorkbenchPersistence({
|
|
22
|
+
host: options.usageHost, content: options.content, context,
|
|
23
|
+
source: restored?.source ?? source, restored, captureFragments: options.captureFragments,
|
|
24
|
+
onResult: options.onPersistenceResult
|
|
25
|
+
});
|
|
26
|
+
const coordinator = {
|
|
27
|
+
handleStateChange: coherent.handleStateChange,
|
|
28
|
+
flush: publicationMode === 'boundaries' ? coherent.flush : () => { },
|
|
29
|
+
dispose: coherent.dispose
|
|
30
|
+
};
|
|
31
|
+
const runtime = createWorkbenchStoreRuntime({ ...options, coherentPersistence: { initialState, coordinator } });
|
|
32
|
+
return { ...runtime, restoredUsage: restored, saveUsage: coherent.save, rebindUsageSource: coherent.rebindSource, currentSnapshotId: coherent.currentSnapshotId };
|
|
33
|
+
}
|
|
@@ -41,6 +41,7 @@ export declare function createWorkbenchStore(options: CreateWorkbenchStoreOption
|
|
|
41
41
|
moveShellWidgetToRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
|
|
42
42
|
removeShellWidgetFromRegion(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string): void;
|
|
43
43
|
setShellRegionArrangement(regionId: import("@konitif/workbench").ShellRegionId, presentation: import("@konitif/workbench").ShellRegionPresentation, axis?: import("@konitif/workbench").ShellRegionAxis): void;
|
|
44
|
+
setShellRegionWidgetProportions(regionId: import("@konitif/workbench").ShellRegionId, proportions: Record<string, number>): void;
|
|
44
45
|
setShellRegionOpen(regionId: import("@konitif/workbench").ShellRegionId, isOpen: boolean): void;
|
|
45
46
|
setShellRegionVisible(regionId: import("@konitif/workbench").ShellRegionId, isVisible: boolean): void;
|
|
46
47
|
setShellRegionWidgetVisible(regionId: import("@konitif/workbench").ShellRegionId, widgetId: string, isVisible: boolean): void;
|
|
@@ -5,6 +5,7 @@ import type { WorkbenchHistoryScope } from "./workspaceHistoryController.js";
|
|
|
5
5
|
import type { WorkspaceSyncController } from "./workspaceSyncController.js";
|
|
6
6
|
import { type InitialWorkbenchWorkspaceMode } from "./workbenchWorkspaceActions.js";
|
|
7
7
|
import type { WorkbenchDetachedWindowHost } from "./workbenchDetachedWindowHost.js";
|
|
8
|
+
import { type WorkbenchState } from "./workbenchStateFactory.js";
|
|
8
9
|
import { type ShellRegionId, type ShellWidgetCatalog, type ToolCatalog, type WorkspaceCommand, type WorkspacePersistencePort } from '@konitif/workbench/workspace-contracts';
|
|
9
10
|
type InitialWorkspaceMode = InitialWorkbenchWorkspaceMode;
|
|
10
11
|
export interface CreateWorkbenchStoreRuntimeOptions {
|
|
@@ -26,6 +27,10 @@ export interface CreateWorkbenchStoreRuntimeOptions {
|
|
|
26
27
|
initialStackHeaderVisible?: boolean;
|
|
27
28
|
defaultOpenShellRegions?: ShellRegionId[];
|
|
28
29
|
persistenceEnabled?: () => boolean;
|
|
30
|
+
coherentPersistence?: {
|
|
31
|
+
initialState: import("./workbenchPersistenceRuntime.js").WorkbenchPersistenceState;
|
|
32
|
+
coordinator: import("./workbenchPersistenceRuntime.js").WorkbenchPersistenceCoordinator<WorkbenchState>;
|
|
33
|
+
};
|
|
29
34
|
}
|
|
30
35
|
export declare function createWorkbenchStoreRuntime(options: CreateWorkbenchStoreRuntimeOptions): {
|
|
31
36
|
dispose: () => void;
|
|
@@ -66,6 +71,7 @@ export declare function createWorkbenchStoreRuntime(options: CreateWorkbenchStor
|
|
|
66
71
|
moveShellWidgetToRegion(regionId: ShellRegionId, widgetId: string, placement?: import("@konitif/workbench").ShellWidgetPlacement): void;
|
|
67
72
|
removeShellWidgetFromRegion(regionId: ShellRegionId, widgetId: string): void;
|
|
68
73
|
setShellRegionArrangement(regionId: ShellRegionId, presentation: import("@konitif/workbench").ShellRegionPresentation, axis?: import("@konitif/workbench").ShellRegionAxis): void;
|
|
74
|
+
setShellRegionWidgetProportions(regionId: ShellRegionId, proportions: Record<string, number>): void;
|
|
69
75
|
setShellRegionOpen(regionId: ShellRegionId, isOpen: boolean): void;
|
|
70
76
|
setShellRegionVisible(regionId: ShellRegionId, isVisible: boolean): void;
|
|
71
77
|
setShellRegionWidgetVisible(regionId: ShellRegionId, widgetId: string, isVisible: boolean): void;
|
|
@@ -36,16 +36,16 @@ export function createWorkbenchStoreRuntime(options) {
|
|
|
36
36
|
defaultOpenShellRegions: options.defaultOpenShellRegions
|
|
37
37
|
});
|
|
38
38
|
const { createInitialWorkspace, createShellFallback, createWorkbenchState } = stateFactory;
|
|
39
|
-
const initialWorkspace = isPersistenceEnabled()
|
|
39
|
+
const initialWorkspace = options.coherentPersistence?.initialState.workspace ?? (isPersistenceEnabled()
|
|
40
40
|
? (persistence.load() ?? createWorkbenchState().workspace)
|
|
41
|
-
: createWorkbenchState().workspace;
|
|
42
|
-
const initialShell = shellPersistence.load(createShellFallback());
|
|
41
|
+
: createWorkbenchState().workspace);
|
|
42
|
+
const initialShell = options.coherentPersistence?.initialState.shell ?? shellPersistence.load(createShellFallback());
|
|
43
43
|
const fallbackSession = createWorkspaceSessionState(initialWorkspace);
|
|
44
|
-
const initialFocus = focusPersistence.load(initialWorkspace, fallbackSession.focus);
|
|
44
|
+
const initialFocus = options.coherentPersistence?.initialState.focus ?? focusPersistence.load(initialWorkspace, fallbackSession.focus);
|
|
45
45
|
const internalWorkspaceStore = writable(createWorkbenchState(createWorkspaceSessionState(initialWorkspace, initialFocus), initialShell));
|
|
46
46
|
const toolRuntimeUi = createWorkbenchToolRuntimeUiStore(() => get(internalWorkspaceStore).workspace);
|
|
47
47
|
const historyRuntime = createWorkbenchHistoryRuntime();
|
|
48
|
-
const persistenceCoordinator = createWorkbenchPersistenceRuntime({
|
|
48
|
+
const persistenceCoordinator = options.coherentPersistence?.coordinator ?? createWorkbenchPersistenceRuntime({
|
|
49
49
|
persistenceKey: options.persistenceKey,
|
|
50
50
|
shellPersistenceKey,
|
|
51
51
|
focusPersistenceKey,
|
|
@@ -108,6 +108,7 @@ export function createWorkbenchStoreRuntime(options) {
|
|
|
108
108
|
case 'open-tool':
|
|
109
109
|
case 'open-tool-in-panel':
|
|
110
110
|
case 'open-tool-in-new-tab':
|
|
111
|
+
case 'unassign-tool':
|
|
111
112
|
case 'split-panel-horizontal':
|
|
112
113
|
case 'split-panel-vertical':
|
|
113
114
|
case 'split-panel-to-side':
|
|
@@ -12,6 +12,7 @@ export interface WorkbenchShellActions {
|
|
|
12
12
|
moveShellWidgetToRegion(regionId: ShellRegionId, widgetId: string, placement?: ShellWidgetPlacement): void;
|
|
13
13
|
removeShellWidgetFromRegion(regionId: ShellRegionId, widgetId: string): void;
|
|
14
14
|
setShellRegionArrangement(regionId: ShellRegionId, presentation: ShellRegionPresentation, axis?: ShellRegionAxis): void;
|
|
15
|
+
setShellRegionWidgetProportions(regionId: ShellRegionId, proportions: Record<string, number>): void;
|
|
15
16
|
setShellRegionOpen(regionId: ShellRegionId, isOpen: boolean): void;
|
|
16
17
|
setShellRegionVisible(regionId: ShellRegionId, isVisible: boolean): void;
|
|
17
18
|
setShellRegionWidgetVisible(regionId: ShellRegionId, widgetId: string, isVisible: boolean): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addShellWidgetToRegion, activateShellWidget, moveShellWidgetToRegion, removeShellWidgetFromRegion, setShellRegionArrangement, setShellRegionOpen, setShellRegionSize, setShellRegionWidgetVisible, setShellRegionVisible } from '@konitif/workbench/workspace-contracts';
|
|
1
|
+
import { addShellWidgetToRegion, activateShellWidget, moveShellWidgetToRegion, removeShellWidgetFromRegion, setShellRegionArrangement, setShellRegionWidgetProportions, setShellRegionOpen, setShellRegionSize, setShellRegionWidgetVisible, setShellRegionVisible } from '@konitif/workbench/workspace-contracts';
|
|
2
2
|
export function createWorkbenchShellActions(input) {
|
|
3
3
|
function commitShellInteraction(updater) {
|
|
4
4
|
input.updateWorkbenchState(updater, 'core');
|
|
@@ -35,6 +35,9 @@ export function createWorkbenchShellActions(input) {
|
|
|
35
35
|
shell: setShellRegionArrangement(state.shell, regionId, presentation, axis)
|
|
36
36
|
}));
|
|
37
37
|
},
|
|
38
|
+
setShellRegionWidgetProportions(regionId, proportions) {
|
|
39
|
+
commitShellInteraction(state => ({ ...state, shell: setShellRegionWidgetProportions(state.shell, regionId, proportions) }));
|
|
40
|
+
},
|
|
38
41
|
setShellRegionOpen(regionId, isOpen) {
|
|
39
42
|
commitShellInteraction((state) => ({
|
|
40
43
|
...state,
|
|
@@ -70,6 +70,13 @@ export function normalizePersistedShellState(input, fallback, options = {}) {
|
|
|
70
70
|
const axis = persistedRegion.axis === 'horizontal' || persistedRegion.axis === 'vertical'
|
|
71
71
|
? persistedRegion.axis
|
|
72
72
|
: fallbackRegion.axis;
|
|
73
|
+
const rawProportions = persistedRegion.widgetProportions;
|
|
74
|
+
const widgetProportions = rawProportions && typeof rawProportions === 'object' && !Array.isArray(rawProportions)
|
|
75
|
+
? Object.fromEntries(nextWidgetIds.flatMap(id => {
|
|
76
|
+
const value = rawProportions[id];
|
|
77
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? [[id, value]] : [];
|
|
78
|
+
}))
|
|
79
|
+
: fallbackRegion.widgetProportions;
|
|
73
80
|
const visibleWidgetIds = nextWidgetIds.filter((widgetId) => !hiddenWidgetIds.includes(widgetId));
|
|
74
81
|
const visibleActiveWidgetId = activeWidgetId && visibleWidgetIds.includes(activeWidgetId)
|
|
75
82
|
? activeWidgetId
|
|
@@ -89,6 +96,7 @@ export function normalizePersistedShellState(input, fallback, options = {}) {
|
|
|
89
96
|
widgetIds: nextWidgetIds,
|
|
90
97
|
hiddenWidgetIds,
|
|
91
98
|
presentation,
|
|
99
|
+
widgetProportions,
|
|
92
100
|
axis
|
|
93
101
|
}
|
|
94
102
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konitif/workbench-runtime",
|
|
3
3
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
4
|
-
"version": "0.284.
|
|
4
|
+
"version": "0.284.5",
|
|
5
5
|
"description": "Reactive Svelte host adapter for KONITIF Workbench contracts with explicit runtime ports.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"verify:package": "node scripts/verify-package.mjs"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@konitif/workbench": "0.
|
|
45
|
+
"@konitif/workbench": "0.285.2",
|
|
46
46
|
"svelte": "^4.2.18"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
package/reference/catalog.json
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"sources": [
|
|
24
24
|
"createWorkbenchStore.ts",
|
|
25
|
-
"createWorkspaceModeController.ts"
|
|
25
|
+
"createWorkspaceModeController.ts",
|
|
26
|
+
"createCoherentWorkbenchStore.ts"
|
|
26
27
|
]
|
|
27
28
|
},
|
|
28
29
|
{
|
|
@@ -70,7 +71,13 @@
|
|
|
70
71
|
"workbenchShellPersistence.ts",
|
|
71
72
|
"workbenchFocusPersistence.ts",
|
|
72
73
|
"workspaceHistoryController.ts",
|
|
73
|
-
"workspaceSyncController.ts"
|
|
74
|
+
"workspaceSyncController.ts",
|
|
75
|
+
"coherentWorkbenchPersistence.ts"
|
|
76
|
+
],
|
|
77
|
+
"symbolNames": [
|
|
78
|
+
"WorkbenchHostEventHandlers",
|
|
79
|
+
"WorkbenchHostEvents",
|
|
80
|
+
"WorkbenchHostStorageChange"
|
|
74
81
|
]
|
|
75
82
|
}
|
|
76
83
|
]
|
package/reference/diagrams.json
CHANGED