@openvcs/sdk 0.2.8 → 0.2.10

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.
@@ -8,5 +8,7 @@ export { createHost } from './host';
8
8
  export { bootstrapPluginModule, createRegisteredPluginRuntime, } from './registration';
9
9
  export { VcsDelegateBase } from './vcs-delegate-base';
10
10
  export type { VcsDelegateAssignments } from './vcs-delegate-metadata';
11
+ export { getMenu, getOrCreateMenu, createMenu, addMenuItem, addMenuSeparator, removeMenu, hideMenu, showMenu, registerAction, invoke, notify, } from './menu';
12
+ export type { MenuHandle } from './menu';
11
13
  /** Starts a previously created plugin runtime on process stdio. */
12
14
  export declare function startPluginRuntime(runtime: PluginRuntime, transport?: PluginRuntimeTransport): void;
@@ -2,7 +2,7 @@
2
2
  // Copyright © 2025-2026 OpenVCS Contributors
3
3
  // SPDX-License-Identifier: GPL-3.0-or-later
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.VcsDelegateBase = exports.createRegisteredPluginRuntime = exports.bootstrapPluginModule = exports.createHost = exports.createPluginRuntime = exports.pluginError = exports.isPluginFailure = exports.createRuntimeDispatcher = exports.createDefaultPluginDelegates = void 0;
5
+ exports.notify = exports.invoke = exports.registerAction = exports.showMenu = exports.hideMenu = exports.removeMenu = exports.addMenuSeparator = exports.addMenuItem = exports.createMenu = exports.getOrCreateMenu = exports.getMenu = exports.VcsDelegateBase = exports.createRegisteredPluginRuntime = exports.bootstrapPluginModule = exports.createHost = exports.createPluginRuntime = exports.pluginError = exports.isPluginFailure = exports.createRuntimeDispatcher = exports.createDefaultPluginDelegates = void 0;
6
6
  exports.startPluginRuntime = startPluginRuntime;
7
7
  var dispatcher_1 = require("./dispatcher");
8
8
  Object.defineProperty(exports, "createDefaultPluginDelegates", { enumerable: true, get: function () { return dispatcher_1.createDefaultPluginDelegates; } });
@@ -19,6 +19,18 @@ Object.defineProperty(exports, "bootstrapPluginModule", { enumerable: true, get:
19
19
  Object.defineProperty(exports, "createRegisteredPluginRuntime", { enumerable: true, get: function () { return registration_1.createRegisteredPluginRuntime; } });
20
20
  var vcs_delegate_base_1 = require("./vcs-delegate-base");
21
21
  Object.defineProperty(exports, "VcsDelegateBase", { enumerable: true, get: function () { return vcs_delegate_base_1.VcsDelegateBase; } });
22
+ var menu_1 = require("./menu");
23
+ Object.defineProperty(exports, "getMenu", { enumerable: true, get: function () { return menu_1.getMenu; } });
24
+ Object.defineProperty(exports, "getOrCreateMenu", { enumerable: true, get: function () { return menu_1.getOrCreateMenu; } });
25
+ Object.defineProperty(exports, "createMenu", { enumerable: true, get: function () { return menu_1.createMenu; } });
26
+ Object.defineProperty(exports, "addMenuItem", { enumerable: true, get: function () { return menu_1.addMenuItem; } });
27
+ Object.defineProperty(exports, "addMenuSeparator", { enumerable: true, get: function () { return menu_1.addMenuSeparator; } });
28
+ Object.defineProperty(exports, "removeMenu", { enumerable: true, get: function () { return menu_1.removeMenu; } });
29
+ Object.defineProperty(exports, "hideMenu", { enumerable: true, get: function () { return menu_1.hideMenu; } });
30
+ Object.defineProperty(exports, "showMenu", { enumerable: true, get: function () { return menu_1.showMenu; } });
31
+ Object.defineProperty(exports, "registerAction", { enumerable: true, get: function () { return menu_1.registerAction; } });
32
+ Object.defineProperty(exports, "invoke", { enumerable: true, get: function () { return menu_1.invoke; } });
33
+ Object.defineProperty(exports, "notify", { enumerable: true, get: function () { return menu_1.notify; } });
22
34
  /** Starts a previously created plugin runtime on process stdio. */
23
35
  function startPluginRuntime(runtime, transport) {
24
36
  runtime.start(transport);
@@ -0,0 +1,25 @@
1
+ import type { MenubarItem } from '../types/menubar.js';
2
+ type MenubarMenuOptions = {
3
+ before?: string;
4
+ after?: string;
5
+ };
6
+ export interface MenuHandle {
7
+ id: string;
8
+ addItem(item: MenubarItem): void;
9
+ addSeparator(beforeAction?: string): void;
10
+ removeItem(actionId: string): void;
11
+ hideItem(actionId: string): void;
12
+ showItem(actionId: string): void;
13
+ }
14
+ export declare function getMenu(menuId: string): MenuHandle | null;
15
+ export declare function getOrCreateMenu(menuId: string, label: string): MenuHandle | null;
16
+ export declare function createMenu(menuId: string, label: string, options?: MenubarMenuOptions): MenuHandle | null;
17
+ export declare function addMenuItem(menuId: string, item: MenubarItem): void;
18
+ export declare function addMenuSeparator(menuId: string, beforeAction?: string): void;
19
+ export declare function removeMenu(menuId: string): void;
20
+ export declare function hideMenu(menuId: string): void;
21
+ export declare function showMenu(menuId: string): void;
22
+ export declare function registerAction(id: string, handler: (...args: unknown[]) => unknown): void;
23
+ export declare function invoke<T = unknown>(cmd: string, args?: unknown): Promise<T>;
24
+ export declare function notify(msg: string): void;
25
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getMenu = getMenu;
6
+ exports.getOrCreateMenu = getOrCreateMenu;
7
+ exports.createMenu = createMenu;
8
+ exports.addMenuItem = addMenuItem;
9
+ exports.addMenuSeparator = addMenuSeparator;
10
+ exports.removeMenu = removeMenu;
11
+ exports.hideMenu = hideMenu;
12
+ exports.showMenu = showMenu;
13
+ exports.registerAction = registerAction;
14
+ exports.invoke = invoke;
15
+ exports.notify = notify;
16
+ function getOpenVCS() {
17
+ return globalThis.OpenVCS;
18
+ }
19
+ function castMenuHandle(menu) {
20
+ if (!menu)
21
+ return null;
22
+ return menu;
23
+ }
24
+ function getMenu(menuId) {
25
+ const openvcs = getOpenVCS();
26
+ if (!openvcs?.menus)
27
+ return null;
28
+ return castMenuHandle(openvcs.menus.get(menuId));
29
+ }
30
+ function getOrCreateMenu(menuId, label) {
31
+ const openvcs = getOpenVCS();
32
+ if (!openvcs?.menus)
33
+ return null;
34
+ return castMenuHandle(openvcs.menus.getOrCreate(menuId, label));
35
+ }
36
+ function createMenu(menuId, label, options) {
37
+ const openvcs = getOpenVCS();
38
+ if (!openvcs?.menus)
39
+ return null;
40
+ return castMenuHandle(openvcs.menus.create(menuId, label, options));
41
+ }
42
+ function addMenuItem(menuId, item) {
43
+ const openvcs = getOpenVCS();
44
+ openvcs?.menus?.addMenuItem(menuId, item);
45
+ }
46
+ function addMenuSeparator(menuId, beforeAction) {
47
+ const openvcs = getOpenVCS();
48
+ openvcs?.menus?.addMenuSeparator(menuId, beforeAction);
49
+ }
50
+ function removeMenu(menuId) {
51
+ const openvcs = getOpenVCS();
52
+ openvcs?.menus?.remove(menuId);
53
+ }
54
+ function hideMenu(menuId) {
55
+ const openvcs = getOpenVCS();
56
+ openvcs?.menus?.hide(menuId);
57
+ }
58
+ function showMenu(menuId) {
59
+ const openvcs = getOpenVCS();
60
+ openvcs?.menus?.show(menuId);
61
+ }
62
+ function registerAction(id, handler) {
63
+ const openvcs = getOpenVCS();
64
+ openvcs?.registerAction(id, handler);
65
+ }
66
+ function invoke(cmd, args) {
67
+ const openvcs = getOpenVCS();
68
+ if (!openvcs) {
69
+ return Promise.reject(new Error('OpenVCS not available'));
70
+ }
71
+ return openvcs.invoke(cmd, args);
72
+ }
73
+ function notify(msg) {
74
+ const openvcs = getOpenVCS();
75
+ openvcs?.notify(msg);
76
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './host';
2
+ export * from './menubar';
2
3
  export * from './plugin';
3
4
  export * from './protocol';
4
5
  export * from './vcs';
@@ -17,6 +17,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  __exportStar(require("./host"), exports);
20
+ __exportStar(require("./menubar"), exports);
20
21
  __exportStar(require("./plugin"), exports);
21
22
  __exportStar(require("./protocol"), exports);
22
23
  __exportStar(require("./vcs"), exports);
@@ -0,0 +1,46 @@
1
+ /** API for manipulating top-level application menus. */
2
+ export interface MenubarManager {
3
+ /** Gets a menu by ID (e.g., 'file', 'repository', 'help'). Returns null if not found. */
4
+ get(menuId: string): MenubarMenu | null;
5
+ /** Gets a menu by ID, creating it if it doesn't exist. */
6
+ getOrCreate(menuId: string, label: string): MenubarMenu;
7
+ /** Creates a new menu at the specified position. */
8
+ create(menuId: string, label: string, options?: {
9
+ before?: string;
10
+ after?: string;
11
+ }): MenubarMenu;
12
+ /** Removes a menu entirely. */
13
+ remove(menuId: string): void;
14
+ /** Hides a menu (visibility: hidden). */
15
+ hide(menuId: string): void;
16
+ /** Shows a hidden menu. */
17
+ show(menuId: string): void;
18
+ }
19
+ /** Handle for manipulating a specific menu. */
20
+ export interface MenubarMenu {
21
+ /** Menu ID. */
22
+ id: string;
23
+ /** Adds an item to this menu. */
24
+ addItem(item: MenubarItem): void;
25
+ /** Adds a separator to this menu. */
26
+ addSeparator(beforeAction?: string): void;
27
+ /** Removes an item by action ID. */
28
+ removeItem(actionId: string): void;
29
+ /** Hides an item by action ID. */
30
+ hideItem(actionId: string): void;
31
+ /** Shows a hidden item. */
32
+ showItem(actionId: string): void;
33
+ }
34
+ /** Descriptor for a menu item. */
35
+ export interface MenubarItem {
36
+ /** Display label. */
37
+ label: string;
38
+ /** Action ID (plugin must register handler separately). */
39
+ action: string;
40
+ /** Optional tooltip. */
41
+ title?: string;
42
+ /** Insert before this action ID. */
43
+ before?: string;
44
+ /** Insert after this action ID. */
45
+ after?: string;
46
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openvcs/sdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "OpenVCS SDK CLI for plugin scaffolding and .ovcsp tar.gz packaging",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "homepage": "https://openvcs.app/",
@@ -28,6 +28,20 @@ export {
28
28
  } from './registration';
29
29
  export { VcsDelegateBase } from './vcs-delegate-base';
30
30
  export type { VcsDelegateAssignments } from './vcs-delegate-metadata';
31
+ export {
32
+ getMenu,
33
+ getOrCreateMenu,
34
+ createMenu,
35
+ addMenuItem,
36
+ addMenuSeparator,
37
+ removeMenu,
38
+ hideMenu,
39
+ showMenu,
40
+ registerAction,
41
+ invoke,
42
+ notify,
43
+ } from './menu';
44
+ export type { MenuHandle } from './menu';
31
45
 
32
46
  /** Starts a previously created plugin runtime on process stdio. */
33
47
  export function startPluginRuntime(
@@ -0,0 +1,103 @@
1
+ // Copyright © 2025-2026 OpenVCS Contributors
2
+ // SPDX-License-Identifier: GPL-3.0-or-later
3
+
4
+ import type { MenubarItem } from '../types/menubar.js';
5
+
6
+ type MenubarMenuOptions = { before?: string; after?: string };
7
+
8
+ type OpenVCSGlobal = typeof globalThis & {
9
+ OpenVCS?: {
10
+ menus?: {
11
+ get(menuId: string): unknown;
12
+ getOrCreate(menuId: string, label: string): unknown;
13
+ create(menuId: string, label: string, options?: MenubarMenuOptions): unknown;
14
+ addMenuItem(menuId: string, item: MenubarItem): void;
15
+ addMenuSeparator(menuId: string, beforeAction?: string): void;
16
+ remove(menuId: string): void;
17
+ hide(menuId: string): void;
18
+ show(menuId: string): void;
19
+ };
20
+ registerAction(id: string, handler: (...args: unknown[]) => unknown): void;
21
+ invoke<T = unknown>(cmd: string, args?: unknown): Promise<T>;
22
+ notify(msg: string): void;
23
+ };
24
+ };
25
+
26
+ function getOpenVCS() {
27
+ return (globalThis as OpenVCSGlobal).OpenVCS;
28
+ }
29
+
30
+ export interface MenuHandle {
31
+ id: string;
32
+ addItem(item: MenubarItem): void;
33
+ addSeparator(beforeAction?: string): void;
34
+ removeItem(actionId: string): void;
35
+ hideItem(actionId: string): void;
36
+ showItem(actionId: string): void;
37
+ }
38
+
39
+ function castMenuHandle(menu: unknown): MenuHandle | null {
40
+ if (!menu) return null;
41
+ return menu as MenuHandle;
42
+ }
43
+
44
+ export function getMenu(menuId: string): MenuHandle | null {
45
+ const openvcs = getOpenVCS();
46
+ if (!openvcs?.menus) return null;
47
+ return castMenuHandle(openvcs.menus.get(menuId));
48
+ }
49
+
50
+ export function getOrCreateMenu(menuId: string, label: string): MenuHandle | null {
51
+ const openvcs = getOpenVCS();
52
+ if (!openvcs?.menus) return null;
53
+ return castMenuHandle(openvcs.menus.getOrCreate(menuId, label));
54
+ }
55
+
56
+ export function createMenu(menuId: string, label: string, options?: MenubarMenuOptions): MenuHandle | null {
57
+ const openvcs = getOpenVCS();
58
+ if (!openvcs?.menus) return null;
59
+ return castMenuHandle(openvcs.menus.create(menuId, label, options));
60
+ }
61
+
62
+ export function addMenuItem(menuId: string, item: MenubarItem): void {
63
+ const openvcs = getOpenVCS();
64
+ openvcs?.menus?.addMenuItem(menuId, item);
65
+ }
66
+
67
+ export function addMenuSeparator(menuId: string, beforeAction?: string): void {
68
+ const openvcs = getOpenVCS();
69
+ openvcs?.menus?.addMenuSeparator(menuId, beforeAction);
70
+ }
71
+
72
+ export function removeMenu(menuId: string): void {
73
+ const openvcs = getOpenVCS();
74
+ openvcs?.menus?.remove(menuId);
75
+ }
76
+
77
+ export function hideMenu(menuId: string): void {
78
+ const openvcs = getOpenVCS();
79
+ openvcs?.menus?.hide(menuId);
80
+ }
81
+
82
+ export function showMenu(menuId: string): void {
83
+ const openvcs = getOpenVCS();
84
+ openvcs?.menus?.show(menuId);
85
+ }
86
+
87
+ export function registerAction(id: string, handler: (...args: unknown[]) => unknown): void {
88
+ const openvcs = getOpenVCS();
89
+ openvcs?.registerAction(id, handler);
90
+ }
91
+
92
+ export function invoke<T = unknown>(cmd: string, args?: unknown): Promise<T> {
93
+ const openvcs = getOpenVCS();
94
+ if (!openvcs) {
95
+ return Promise.reject(new Error('OpenVCS not available'));
96
+ }
97
+ return openvcs.invoke(cmd, args);
98
+ }
99
+
100
+ export function notify(msg: string): void {
101
+ const openvcs = getOpenVCS();
102
+ openvcs?.notify(msg);
103
+ }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: GPL-3.0-or-later
3
3
 
4
4
  export * from './host';
5
+ export * from './menubar';
5
6
  export * from './plugin';
6
7
  export * from './protocol';
7
8
  export * from './vcs';
@@ -0,0 +1,48 @@
1
+ // Copyright © 2025-2026 OpenVCS Contributors
2
+ // SPDX-License-Identifier: GPL-3.0-or-later
3
+
4
+ /** API for manipulating top-level application menus. */
5
+ export interface MenubarManager {
6
+ /** Gets a menu by ID (e.g., 'file', 'repository', 'help'). Returns null if not found. */
7
+ get(menuId: string): MenubarMenu | null;
8
+ /** Gets a menu by ID, creating it if it doesn't exist. */
9
+ getOrCreate(menuId: string, label: string): MenubarMenu;
10
+ /** Creates a new menu at the specified position. */
11
+ create(menuId: string, label: string, options?: { before?: string; after?: string }): MenubarMenu;
12
+ /** Removes a menu entirely. */
13
+ remove(menuId: string): void;
14
+ /** Hides a menu (visibility: hidden). */
15
+ hide(menuId: string): void;
16
+ /** Shows a hidden menu. */
17
+ show(menuId: string): void;
18
+ }
19
+
20
+ /** Handle for manipulating a specific menu. */
21
+ export interface MenubarMenu {
22
+ /** Menu ID. */
23
+ id: string;
24
+ /** Adds an item to this menu. */
25
+ addItem(item: MenubarItem): void;
26
+ /** Adds a separator to this menu. */
27
+ addSeparator(beforeAction?: string): void;
28
+ /** Removes an item by action ID. */
29
+ removeItem(actionId: string): void;
30
+ /** Hides an item by action ID. */
31
+ hideItem(actionId: string): void;
32
+ /** Shows a hidden item. */
33
+ showItem(actionId: string): void;
34
+ }
35
+
36
+ /** Descriptor for a menu item. */
37
+ export interface MenubarItem {
38
+ /** Display label. */
39
+ label: string;
40
+ /** Action ID (plugin must register handler separately). */
41
+ action: string;
42
+ /** Optional tooltip. */
43
+ title?: string;
44
+ /** Insert before this action ID. */
45
+ before?: string;
46
+ /** Insert after this action ID. */
47
+ after?: string;
48
+ }