@graphvideo/workbench 1.0.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.
Files changed (39) hide show
  1. package/dist/commands/commandRegistry.d.ts +15 -0
  2. package/dist/context/WorkbenchHostContext.d.ts +26 -0
  3. package/dist/context/types.d.ts +26 -0
  4. package/dist/context/workbenchContextStore.d.ts +26 -0
  5. package/dist/dock/AreaShell.d.ts +9 -0
  6. package/dist/dock/Workspace.d.ts +5 -0
  7. package/dist/dock/floatingWindow.d.ts +7 -0
  8. package/dist/dock/layout.d.ts +14 -0
  9. package/dist/dock/splitResizeGesture.d.ts +23 -0
  10. package/dist/dock/workspaceTypes.d.ts +28 -0
  11. package/dist/elements/ExtensionSlot.d.ts +5 -0
  12. package/dist/elements/dispose.d.ts +3 -0
  13. package/dist/elements/elementLoader.d.ts +45 -0
  14. package/dist/elements/manifest.d.ts +2 -0
  15. package/dist/elements/runtimeManager.d.ts +28 -0
  16. package/dist/elements/sourceCatalog.d.ts +24 -0
  17. package/dist/elements/types.d.ts +133 -0
  18. package/dist/index.d.ts +36 -0
  19. package/dist/index.mjs +1809 -0
  20. package/dist/plugins/pluginManager.d.ts +20 -0
  21. package/dist/preferences/themePreferences.d.ts +9 -0
  22. package/dist/preferences/typographyPreferences.d.ts +16 -0
  23. package/dist/registry/eventRegistry.d.ts +29 -0
  24. package/dist/registry/extensionRegistry.d.ts +11 -0
  25. package/dist/registry/ownedRegistry.d.ts +21 -0
  26. package/dist/registry/panelRegistry.d.ts +13 -0
  27. package/dist/registry/serviceRegistry.d.ts +28 -0
  28. package/dist/registry/stateRegistry.d.ts +16 -0
  29. package/dist/ui/AudioPlayer.d.ts +5 -0
  30. package/dist/ui/FloatingScrollbars.d.ts +9 -0
  31. package/dist/ui/InlineSelect.d.ts +16 -0
  32. package/dist/ui/LargeTextEditorDialog.d.ts +14 -0
  33. package/dist/workbench.css +2 -0
  34. package/dist/workspaces/WorkspacePages.d.ts +5 -0
  35. package/dist/workspaces/WorkspaceTabs.d.ts +2 -0
  36. package/dist/workspaces/layoutPreferences.d.ts +10 -0
  37. package/dist/workspaces/manifest.d.ts +25 -0
  38. package/dist/workspaces/workspaceCommands.d.ts +16 -0
  39. package/package.json +35 -0
@@ -0,0 +1,15 @@
1
+ export type CommandHandler<T = unknown> = (payload: T) => void | Promise<void>;
2
+ export declare class CommandRegistry {
3
+ private readonly handlers;
4
+ register<T>(id: string, handler: CommandHandler<T>, owner?: string): void;
5
+ assertCanReplace(owner: string, entries: Array<{
6
+ id: string;
7
+ handler: CommandHandler<any>;
8
+ }>): void;
9
+ replaceOwner(owner: string, entries: Array<{
10
+ id: string;
11
+ handler: CommandHandler<any>;
12
+ }>): void;
13
+ unregisterOwner(owner: string): void;
14
+ execute<T>(id: string, payload: T): void | Promise<void>;
15
+ }
@@ -0,0 +1,26 @@
1
+ import type { CommandRegistry } from '../commands/commandRegistry';
2
+ import type { PanelRegistry } from '../registry/panelRegistry';
3
+ import type { ExtensionRegistry } from '../registry/extensionRegistry';
4
+ import type { EventRegistry } from '../registry/eventRegistry';
5
+ import type { ServiceRegistry } from '../registry/serviceRegistry';
6
+ import type { ElementStateRegistry } from '../registry/stateRegistry';
7
+ import type { ElementRuntimeManager } from '../elements/runtimeManager';
8
+ import type { WorkbenchContextStore } from './workbenchContextStore';
9
+ import type { ClientWorkspaceState } from '../dock/workspaceTypes';
10
+ export interface WorkbenchServices {
11
+ commands: CommandRegistry;
12
+ panels: PanelRegistry;
13
+ extensions: ExtensionRegistry;
14
+ elementEvents: EventRegistry;
15
+ elementServices: ServiceRegistry;
16
+ elementStates: ElementStateRegistry;
17
+ elementRuntimes: ElementRuntimeManager;
18
+ contexts: WorkbenchContextStore;
19
+ }
20
+ export interface WorkbenchHostAdapter {
21
+ services: WorkbenchServices;
22
+ useWorkspaceState<T>(selector: (state: ClientWorkspaceState) => T): T;
23
+ }
24
+ export declare const WorkbenchHostContext: import("react").Context<WorkbenchHostAdapter | null>;
25
+ export declare function useWorkbenchServices(): WorkbenchServices;
26
+ export declare function useWorkbenchWorkspace<T>(selector: (state: ClientWorkspaceState) => T): T;
@@ -0,0 +1,26 @@
1
+ declare const workbenchContextValue: unique symbol;
2
+ export type WorkbenchContextScope = 'application' | 'project' | 'workspace' | 'instance';
3
+ export interface WorkbenchContextToken<T> {
4
+ readonly id: string;
5
+ readonly scope: WorkbenchContextScope;
6
+ readonly initialValue: T;
7
+ readonly [workbenchContextValue]?: (value: T) => T;
8
+ }
9
+ export interface WorkbenchContextBinding {
10
+ projectId?: string | null;
11
+ workspaceId?: string;
12
+ instanceId?: string;
13
+ }
14
+ export interface WorkbenchContextHandle<T> {
15
+ read(): T;
16
+ write(value: T | ((current: T) => T)): void;
17
+ subscribe(listener: () => void): () => void;
18
+ }
19
+ export interface WorkbenchContextAccessor {
20
+ get<T>(token: WorkbenchContextToken<T>, binding?: WorkbenchContextBinding): WorkbenchContextHandle<T>;
21
+ }
22
+ export declare function defineWorkbenchContext<T>(id: string, options: {
23
+ scope: WorkbenchContextScope;
24
+ initialValue: T;
25
+ }): WorkbenchContextToken<T>;
26
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { WorkbenchContextBinding, WorkbenchContextHandle, WorkbenchContextToken } from './types';
2
+ /** Renderer-only shared interaction context. It never owns projected business facts. */
3
+ export declare class WorkbenchContextStore {
4
+ private readonly cells;
5
+ private getOrCreateCell;
6
+ get<T>(token: WorkbenchContextToken<T>, binding?: WorkbenchContextBinding): WorkbenchContextHandle<T>;
7
+ purgeNamespace(namespace: string): void;
8
+ clearPluginContexts(pluginOrManifest: string | {
9
+ id: string;
10
+ contributes?: {
11
+ elements?: readonly string[];
12
+ workspaces?: readonly string[];
13
+ };
14
+ }): void;
15
+ /** Final plugin teardown: notify mounted consumers, then release cells for clean reinstallation. */
16
+ disposePluginContexts(manifest: {
17
+ id: string;
18
+ contributes?: {
19
+ elements?: readonly string[];
20
+ workspaces?: readonly string[];
21
+ };
22
+ }): void;
23
+ clearScope(scope: 'workspace' | 'instance' | 'project', id: string): void;
24
+ clearAll(): void;
25
+ private cellKey;
26
+ }
@@ -0,0 +1,9 @@
1
+ import type { AreaState } from './workspaceTypes';
2
+ interface AreaShellProps {
3
+ workspaceId: string;
4
+ area: AreaState;
5
+ floating?: boolean;
6
+ onFloatToggle?(areaId: string): void;
7
+ }
8
+ export declare function AreaShell({ workspaceId, area, floating, onFloatToggle }: AreaShellProps): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface WorkspaceProps {
2
+ workspaceId: string;
3
+ active: boolean;
4
+ }
5
+ export declare const Workspace: import("react").NamedExoticComponent<WorkspaceProps>;
@@ -0,0 +1,7 @@
1
+ export interface FloatingDocument {
2
+ container: HTMLDivElement;
3
+ disconnect(): void;
4
+ }
5
+ export declare function isOutsideViewport(x: number, y: number, width: number, height: number): boolean;
6
+ export declare function synchronizeFloatingRoot(source: HTMLElement, target: HTMLElement): void;
7
+ export declare function prepareFloatingWindow(popup: Window, title: string): FloatingDocument;
@@ -0,0 +1,14 @@
1
+ import type { AreaState, DockNode, DockSplitState } from './workspaceTypes';
2
+ export declare function listAreas(node: DockNode): AreaState[];
3
+ export declare function findArea(node: DockNode, areaId: string): AreaState | null;
4
+ export declare function excludeAreas(node: DockNode, excludedAreaIds: ReadonlySet<string>): DockNode | null;
5
+ export declare function canCloseArea(layout: DockNode, areaId: string): boolean;
6
+ export declare function switchAreaPanel(layout: DockNode, areaId: string, panelId: string, instanceId: string): DockNode;
7
+ export declare function splitArea(layout: DockNode, areaId: string, direction: DockSplitState['direction'], ids: {
8
+ areaId: string;
9
+ splitId: string;
10
+ panelInstanceId: string;
11
+ }): DockNode;
12
+ export declare function closeArea(layout: DockNode, areaId: string): DockNode;
13
+ export declare function resizeSplit(layout: DockNode, splitId: string, ratio: number): DockNode;
14
+ export declare function swapAreaPanels(layout: DockNode, firstId: string, secondId: string): DockNode;
@@ -0,0 +1,23 @@
1
+ import type { DockSplitState } from './workspaceTypes';
2
+ interface SplitBounds {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ interface SplitResizeGestureOptions {
7
+ direction: DockSplitState['direction'];
8
+ bounds: SplitBounds;
9
+ initialRatio: number;
10
+ startX: number;
11
+ startY: number;
12
+ scheduleFrame(callback: () => void): number;
13
+ cancelFrame(frameId: number): void;
14
+ preview(ratio: number): void;
15
+ commit(ratio: number): void;
16
+ cancel(): void;
17
+ }
18
+ export declare function createSplitResizeGesture(options: SplitResizeGestureOptions): {
19
+ move(clientX: number, clientY: number): void;
20
+ finish(clientX: number, clientY: number): void;
21
+ abort(notify?: boolean): void;
22
+ };
23
+ export {};
@@ -0,0 +1,28 @@
1
+ export interface AreaState {
2
+ kind: 'area';
3
+ id: string;
4
+ activePanelId: string;
5
+ panelHistory: string[];
6
+ panelInstanceIds: Record<string, string>;
7
+ }
8
+ export interface DockSplitState {
9
+ kind: 'split';
10
+ id: string;
11
+ direction: 'horizontal' | 'vertical';
12
+ ratio: number;
13
+ first: DockNode;
14
+ second: DockNode;
15
+ }
16
+ export type DockNode = AreaState | DockSplitState;
17
+ export interface WorkspaceRuntimeState {
18
+ id: string;
19
+ name: string;
20
+ order: number;
21
+ layout: DockNode;
22
+ focusedAreaId: string;
23
+ maximizedAreaId: string | null;
24
+ }
25
+ export interface ClientWorkspaceState {
26
+ activeWorkspaceId: string;
27
+ items: Record<string, WorkspaceRuntimeState>;
28
+ }
@@ -0,0 +1,5 @@
1
+ import type { ExtensionProps } from './types';
2
+ export declare function ExtensionSlot({ point, className, ...props }: ExtensionProps & {
3
+ point: string;
4
+ className?: string;
5
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ import type { ElementDispose } from './types';
2
+ /** Consume owned cleanups once, in reverse acquisition order. One failure cannot leak siblings. */
3
+ export declare function disposeReverse(disposers: ElementDispose[]): Promise<void>;
@@ -0,0 +1,45 @@
1
+ import type { CommandRegistry } from '../commands/commandRegistry';
2
+ import type { ExtensionRegistry } from '../registry/extensionRegistry';
3
+ import type { EventRegistry } from '../registry/eventRegistry';
4
+ import type { PanelRegistry } from '../registry/panelRegistry';
5
+ import type { ServiceRegistry } from '../registry/serviceRegistry';
6
+ import type { ElementStateRegistry } from '../registry/stateRegistry';
7
+ import type { ElementRuntimeManager } from './runtimeManager';
8
+ import { WorkbenchContextStore } from '../context/workbenchContextStore';
9
+ import type { ElementCandidate, ElementHostApi, ElementPackageManifest } from './types';
10
+ interface ElementLoaderRegistries {
11
+ panels: PanelRegistry;
12
+ extensions: ExtensionRegistry;
13
+ commands: CommandRegistry;
14
+ states: ElementStateRegistry;
15
+ events: EventRegistry;
16
+ services: ServiceRegistry;
17
+ runtimes: ElementRuntimeManager;
18
+ host: ElementHostApi;
19
+ application?: unknown;
20
+ contexts?: WorkbenchContextStore;
21
+ }
22
+ export declare class ElementLoader {
23
+ private readonly registries;
24
+ private readonly loaded;
25
+ private readonly listeners;
26
+ private errors;
27
+ private version;
28
+ private readonly contexts;
29
+ constructor(registries: ElementLoaderRegistries);
30
+ readonly subscribe: (listener: () => void) => () => boolean;
31
+ readonly getSnapshot: () => number;
32
+ listErrors(): string[];
33
+ listLoaded(): {
34
+ manifest: ElementPackageManifest;
35
+ owner: string;
36
+ version: string;
37
+ }[];
38
+ reconcile(candidates: ElementCandidate[]): Promise<void>;
39
+ reportError(error: string): void;
40
+ unload(owner: string): Promise<void>;
41
+ private load;
42
+ private stage;
43
+ private emit;
44
+ }
45
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ElementPackageManifest } from './types';
2
+ export declare function parseElementManifest(manifestText: string): ElementPackageManifest;
@@ -0,0 +1,28 @@
1
+ import type { ElementStateRegistry } from '../registry/stateRegistry';
2
+ import type { EventRegistry } from '../registry/eventRegistry';
3
+ import type { ServiceRegistry } from '../registry/serviceRegistry';
4
+ import type { ElementHostApi, ElementRuntimeFactory, ElementRuntimeHandle } from './types';
5
+ import { WorkbenchContextStore } from '../context/workbenchContextStore';
6
+ export declare class ElementRuntimeManager {
7
+ private readonly states;
8
+ private readonly host;
9
+ private readonly services;
10
+ private readonly events;
11
+ private readonly contexts;
12
+ private readonly factories;
13
+ private readonly instances;
14
+ private readonly listeners;
15
+ private version;
16
+ private readonly pendingCleanups;
17
+ constructor(states: ElementStateRegistry, host: ElementHostApi, services: ServiceRegistry, events: EventRegistry, contexts?: WorkbenchContextStore);
18
+ readonly subscribe: (listener: () => void) => () => boolean;
19
+ readonly getSnapshot: () => number;
20
+ getOrCreate(elementId: string, instanceId: string): ElementRuntimeHandle<unknown>;
21
+ replaceFactory(elementId: string, factory: ElementRuntimeFactory | null): Promise<void>;
22
+ removeElement(elementId: string): Promise<void>;
23
+ disposeAll(): Promise<void>;
24
+ listInstances(): ElementRuntimeHandle<unknown>[];
25
+ private createEntry;
26
+ private key;
27
+ private emit;
28
+ }
@@ -0,0 +1,24 @@
1
+ export interface SourceElementDescriptor {
2
+ elementId: string;
3
+ manifestText: string;
4
+ version: string;
5
+ pluginId: string;
6
+ }
7
+ export interface SourceWorkspaceDescriptor {
8
+ workspaceId: string;
9
+ definitionText: string;
10
+ version: string;
11
+ pluginId: string;
12
+ }
13
+ export interface ElementSourceCatalog {
14
+ elements: SourceElementDescriptor[];
15
+ workspaces: SourceWorkspaceDescriptor[];
16
+ plugins: SourcePluginDescriptor[];
17
+ }
18
+ export interface SourcePluginDescriptor {
19
+ pluginId: string;
20
+ version: string;
21
+ hasBackend: boolean;
22
+ elements: string[];
23
+ workspaces: string[];
24
+ }
@@ -0,0 +1,133 @@
1
+ import type * as ReactRuntime from 'react';
2
+ import type { ComponentType } from 'react';
3
+ import type { EventListener, EventToken } from '../registry/eventRegistry';
4
+ import type { ServiceToken } from '../registry/serviceRegistry';
5
+ import type { WorkbenchContextAccessor } from '../context/types';
6
+ export type ElementStateScope = 'application' | 'project' | 'workspace' | 'instance';
7
+ export interface ElementStateDefinition<T = unknown> {
8
+ id: string;
9
+ scope: ElementStateScope;
10
+ initialValue: T;
11
+ }
12
+ export interface ElementStateBinding {
13
+ projectId?: string | null;
14
+ workspaceId?: string;
15
+ instanceId?: string;
16
+ }
17
+ export interface ElementStateHandle<T> {
18
+ read(): T;
19
+ write(value: T | ((current: T) => T)): void;
20
+ subscribe(listener: () => void): () => void;
21
+ }
22
+ export interface ElementRuntimeStateAccessor {
23
+ get<T>(stateId: string, binding?: Pick<ElementStateBinding, 'projectId' | 'workspaceId'>): ElementStateHandle<T>;
24
+ }
25
+ export interface ElementServiceAccessor {
26
+ get<T>(token: ServiceToken<T>): T;
27
+ has<T>(token: ServiceToken<T>): boolean;
28
+ }
29
+ export interface ElementServiceRegistration extends ElementServiceAccessor {
30
+ provide<T>(token: ServiceToken<T>, provider: T): void;
31
+ }
32
+ export interface ElementEventEmitter {
33
+ emit<T>(event: EventToken<T>, payload: Readonly<T>): void;
34
+ }
35
+ export interface ElementEventRegistration extends ElementEventEmitter {
36
+ on<T>(event: EventToken<T>, listener: EventListener<T>): void;
37
+ }
38
+ export interface ElementRuntimeHandle<T = unknown> {
39
+ elementId: string;
40
+ instanceId: string;
41
+ value: T;
42
+ states: ElementRuntimeStateAccessor;
43
+ attach(viewId: string): void;
44
+ detach(viewId: string): void;
45
+ }
46
+ export interface PanelProps {
47
+ workspaceId: string;
48
+ areaId: string;
49
+ viewId: string;
50
+ instanceId: string;
51
+ runtime: ElementRuntimeHandle;
52
+ }
53
+ export interface PanelIconProps {
54
+ size?: number;
55
+ className?: string;
56
+ }
57
+ export interface PanelDefinition {
58
+ id: string;
59
+ title: string;
60
+ icon: ComponentType<PanelIconProps>;
61
+ component: ComponentType<PanelProps>;
62
+ }
63
+ export interface ExtensionProps extends PanelProps {
64
+ panelId: string;
65
+ }
66
+ export interface ExtensionDefinition {
67
+ id: string;
68
+ point: string;
69
+ component: ComponentType<ExtensionProps>;
70
+ }
71
+ export interface ElementPackageManifest {
72
+ id: string;
73
+ name: string;
74
+ apiVersion: 1;
75
+ entry: string;
76
+ }
77
+ export interface ElementHostApi {
78
+ getProjectId(): string | null;
79
+ executeCommand<T>(id: string, payload: T): void | Promise<void>;
80
+ }
81
+ export interface ElementRuntimeContext {
82
+ elementId: string;
83
+ instanceId: string;
84
+ host: ElementHostApi;
85
+ events: ElementEventEmitter;
86
+ services: ElementServiceAccessor;
87
+ states: ElementRuntimeStateAccessor;
88
+ contexts: WorkbenchContextAccessor;
89
+ onDispose(dispose: ElementDispose): void;
90
+ }
91
+ export interface ElementRuntimeValue {
92
+ dispose?(): void | Promise<void>;
93
+ [key: string]: unknown;
94
+ }
95
+ export interface ElementRuntimeFactory {
96
+ create(context: ElementRuntimeContext): ElementRuntimeValue | void;
97
+ }
98
+ export interface ElementRegistrationContext<TApplication = unknown> {
99
+ readonly manifest: ElementPackageManifest;
100
+ readonly react: typeof ReactRuntime;
101
+ readonly host: ElementHostApi;
102
+ readonly application?: TApplication;
103
+ events: ElementEventRegistration;
104
+ services: ElementServiceRegistration;
105
+ contexts: WorkbenchContextAccessor;
106
+ panels: {
107
+ register(panel: PanelDefinition): void;
108
+ };
109
+ extensions: {
110
+ register(extension: ExtensionDefinition): void;
111
+ };
112
+ commands: {
113
+ register<T>(id: string, handler: (payload: T) => void | Promise<void>): void;
114
+ };
115
+ states: {
116
+ define<T>(state: ElementStateDefinition<T>): void;
117
+ };
118
+ runtime: {
119
+ define(factory: ElementRuntimeFactory): void;
120
+ };
121
+ onDispose(dispose: ElementDispose): void;
122
+ }
123
+ export type ElementDispose = () => void | Promise<void>;
124
+ export interface ElementModule<TApplication = unknown> {
125
+ register(context: ElementRegistrationContext<TApplication>): void | ElementDispose | Promise<void | ElementDispose>;
126
+ }
127
+ export interface ElementCandidate {
128
+ owner: string;
129
+ manifestText: string;
130
+ version: string;
131
+ load(manifest: ElementPackageManifest): Promise<ElementModule<any>> | ElementModule<any>;
132
+ }
133
+ export declare function defineElement<TApplication = unknown>(module: ElementModule<TApplication>): ElementModule<TApplication>;
@@ -0,0 +1,36 @@
1
+ import './styles/index.css';
2
+ export { CommandRegistry, type CommandHandler } from './commands/commandRegistry';
3
+ export { WorkbenchContextStore } from './context/workbenchContextStore';
4
+ export { defineWorkbenchContext } from './context/types';
5
+ export * from './context/WorkbenchHostContext';
6
+ export type { WorkbenchContextBinding, WorkbenchContextHandle, WorkbenchContextScope, WorkbenchContextToken, } from './context/types';
7
+ export { Workspace, type WorkspaceProps } from './dock/Workspace';
8
+ export { AreaShell } from './dock/AreaShell';
9
+ export * from './dock/workspaceTypes';
10
+ export * from './dock/layout';
11
+ export * from './dock/floatingWindow';
12
+ export * from './dock/splitResizeGesture';
13
+ export { ElementLoader } from './elements/elementLoader';
14
+ export { ElementRuntimeManager } from './elements/runtimeManager';
15
+ export { ExtensionSlot } from './elements/ExtensionSlot';
16
+ export { parseElementManifest } from './elements/manifest';
17
+ export * from './elements/types';
18
+ export * from './elements/sourceCatalog';
19
+ export { PluginRuntimeManager, type PluginRuntimeManagerOptions } from './plugins/pluginManager';
20
+ export { PanelRegistry } from './registry/panelRegistry';
21
+ export { ServiceRegistry, defineService, type ServiceToken, type ServiceProviderDefinition } from './registry/serviceRegistry';
22
+ export { EventRegistry, defineEvent, type EventToken, type EventListener, type EventListenerDefinition } from './registry/eventRegistry';
23
+ export { ElementStateRegistry } from './registry/stateRegistry';
24
+ export { ExtensionRegistry } from './registry/extensionRegistry';
25
+ export { OwnedRegistry } from './registry/ownedRegistry';
26
+ export { AudioPlayer } from './ui/AudioPlayer';
27
+ export { FloatingScrollbars } from './ui/FloatingScrollbars';
28
+ export { InlineSelect } from './ui/InlineSelect';
29
+ export { LargeTextEditorDialog, type LargeTextEditorDialogProps } from './ui/LargeTextEditorDialog';
30
+ export * from './workspaces/layoutPreferences';
31
+ export * from './workspaces/manifest';
32
+ export { WorkspaceTabs } from './workspaces/WorkspaceTabs';
33
+ export { WorkspacePages } from './workspaces/WorkspacePages';
34
+ export { registerWorkspaceCommands, type WorkspaceCommandTarget, } from './workspaces/workspaceCommands';
35
+ export * from './preferences/themePreferences';
36
+ export * from './preferences/typographyPreferences';