@openvcs/sdk 0.2.9 → 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.
- package/lib/runtime/index.d.ts +2 -0
- package/lib/runtime/index.js +13 -1
- package/lib/runtime/menu.d.ts +25 -0
- package/lib/runtime/menu.js +76 -0
- package/package.json +1 -1
- package/src/lib/runtime/index.ts +14 -0
- package/src/lib/runtime/menu.ts +103 -0
package/lib/runtime/index.d.ts
CHANGED
|
@@ -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;
|
package/lib/runtime/index.js
CHANGED
|
@@ -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
|
+
}
|
package/package.json
CHANGED
package/src/lib/runtime/index.ts
CHANGED
|
@@ -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
|
+
}
|