@openvcs/sdk 0.2.13 → 0.2.15
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/menu.d.ts +1 -1
- package/lib/runtime/menu.js +5 -6
- package/lib/runtime/modal.d.ts +2 -2
- package/lib/runtime/modal.js +2 -3
- package/lib/runtime/registration.js +5 -2
- package/lib/types/plugin.d.ts +3 -1
- package/package.json +1 -1
- package/src/lib/runtime/dispatcher.ts +1 -1
- package/src/lib/runtime/menu.ts +7 -8
- package/src/lib/runtime/modal.ts +3 -5
- package/src/lib/runtime/registration.ts +5 -2
- package/src/lib/types/plugin.ts +3 -1
package/lib/runtime/menu.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type MenubarMenuOptions = {
|
|
|
6
6
|
after?: string;
|
|
7
7
|
};
|
|
8
8
|
/** Runs a registered action handler by id. */
|
|
9
|
-
export declare function runRegisteredAction(actionId: string, ...args: unknown[]): Promise<
|
|
9
|
+
export declare function runRegisteredAction(actionId: string, ...args: unknown[]): Promise<unknown>;
|
|
10
10
|
export interface MenuHandle {
|
|
11
11
|
id: string;
|
|
12
12
|
addItem(item: MenubarItem): void;
|
package/lib/runtime/menu.js
CHANGED
|
@@ -159,12 +159,11 @@ function serializeMenus() {
|
|
|
159
159
|
async function runRegisteredAction(actionId, ...args) {
|
|
160
160
|
const id = String(actionId || '').trim();
|
|
161
161
|
if (!id)
|
|
162
|
-
return
|
|
162
|
+
return null;
|
|
163
163
|
const handler = actionHandlers.get(id);
|
|
164
164
|
if (!handler)
|
|
165
|
-
return
|
|
166
|
-
await handler(...args);
|
|
167
|
-
return true;
|
|
165
|
+
return null;
|
|
166
|
+
return await handler(...args);
|
|
168
167
|
}
|
|
169
168
|
/** Creates a stable handle for one stored menu. */
|
|
170
169
|
function createMenuHandle(menuId) {
|
|
@@ -289,9 +288,9 @@ function createMenuPluginDelegates() {
|
|
|
289
288
|
return serializeMenus();
|
|
290
289
|
},
|
|
291
290
|
async 'plugin.handle_action'(params) {
|
|
292
|
-
const actionId = String(params?.action_id || '').trim();
|
|
291
|
+
const actionId = String(params?.action_id || params?.id || '').trim();
|
|
293
292
|
if (actionId) {
|
|
294
|
-
await runRegisteredAction(actionId, params?.payload);
|
|
293
|
+
return await runRegisteredAction(actionId, params?.payload);
|
|
295
294
|
}
|
|
296
295
|
return null;
|
|
297
296
|
},
|
package/lib/runtime/modal.d.ts
CHANGED
|
@@ -69,6 +69,6 @@ export declare class ModalBuilder {
|
|
|
69
69
|
list(id: string, options: ModalBuilderListOptions): this;
|
|
70
70
|
/** Returns the serialized modal payload. */
|
|
71
71
|
build(): PluginModalDefinition;
|
|
72
|
-
/**
|
|
73
|
-
open(): Promise<
|
|
72
|
+
/** Returns the serialized modal payload for a host request. */
|
|
73
|
+
open(): Promise<PluginModalDefinition>;
|
|
74
74
|
}
|
package/lib/runtime/modal.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ModalBuilder = void 0;
|
|
6
|
-
const menu_js_1 = require("./menu.js");
|
|
7
6
|
/** Builds a structured modal definition with a fluent class API. */
|
|
8
7
|
class ModalBuilder {
|
|
9
8
|
definition;
|
|
@@ -87,9 +86,9 @@ class ModalBuilder {
|
|
|
87
86
|
content: this.definition.content.map((item) => ({ ...item })),
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
|
-
/**
|
|
89
|
+
/** Returns the serialized modal payload for a host request. */
|
|
91
90
|
async open() {
|
|
92
|
-
|
|
91
|
+
return this.build();
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
exports.ModalBuilder = ModalBuilder;
|
|
@@ -27,8 +27,11 @@ function createRegisteredPluginRuntime(definition = {}) {
|
|
|
27
27
|
},
|
|
28
28
|
'plugin.handle_action': async (params, ctx) => {
|
|
29
29
|
const actionId = String(params?.action_id || '').trim();
|
|
30
|
-
if (actionId
|
|
31
|
-
|
|
30
|
+
if (actionId) {
|
|
31
|
+
const result = await (0, menu_1.runRegisteredAction)(actionId, params?.payload);
|
|
32
|
+
if (result !== null && result !== undefined) {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
if (explicitHandleAction) {
|
|
34
37
|
return explicitHandleAction(params, ctx);
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type PluginMenuDefinition = Record<string, unknown>;
|
|
|
21
21
|
export type PluginSettingsValue = Record<string, unknown>;
|
|
22
22
|
/** Describes the params shape for plugin action handling. */
|
|
23
23
|
export interface PluginHandleActionParams extends RequestParams {
|
|
24
|
+
/** Stores the action id selected by the user when provided by the transport. */
|
|
25
|
+
id?: string;
|
|
24
26
|
/** Stores the action id selected by the user. */
|
|
25
27
|
action_id?: string;
|
|
26
28
|
/** Stores an optional payload supplied by the triggering UI. */
|
|
@@ -44,7 +46,7 @@ export interface PluginDelegates<TContext = unknown> {
|
|
|
44
46
|
/** Returns plugin-contributed menus. */
|
|
45
47
|
'plugin.get_menus'?: RpcMethodHandler<RequestParams, PluginMenuDefinition[], TContext>;
|
|
46
48
|
/** Handles a contributed plugin action. */
|
|
47
|
-
'plugin.handle_action'?: RpcMethodHandler<PluginHandleActionParams,
|
|
49
|
+
'plugin.handle_action'?: RpcMethodHandler<PluginHandleActionParams, unknown, TContext>;
|
|
48
50
|
/** Returns the default settings values for the plugin. */
|
|
49
51
|
'plugin.settings.defaults'?: RpcMethodHandler<RequestParams, PluginSettingsValue[], TContext>;
|
|
50
52
|
/** Transforms settings values when they are loaded. */
|
package/package.json
CHANGED
|
@@ -48,7 +48,7 @@ export function createDefaultPluginDelegates<
|
|
|
48
48
|
async 'plugin.get_menus'(): Promise<[]> {
|
|
49
49
|
return [];
|
|
50
50
|
},
|
|
51
|
-
async 'plugin.handle_action'(): Promise<
|
|
51
|
+
async 'plugin.handle_action'(): Promise<unknown> {
|
|
52
52
|
return null;
|
|
53
53
|
},
|
|
54
54
|
async 'plugin.settings.defaults'(): Promise<[]> {
|
package/src/lib/runtime/menu.ts
CHANGED
|
@@ -216,15 +216,14 @@ function serializeMenus(): SerializedMenuDefinition[] {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/** Runs a registered action handler by id. */
|
|
219
|
-
export async function runRegisteredAction(actionId: string, ...args: unknown[]): Promise<
|
|
219
|
+
export async function runRegisteredAction(actionId: string, ...args: unknown[]): Promise<unknown> {
|
|
220
220
|
const id = String(actionId || '').trim();
|
|
221
|
-
if (!id) return
|
|
221
|
+
if (!id) return null;
|
|
222
222
|
|
|
223
223
|
const handler = actionHandlers.get(id);
|
|
224
|
-
if (!handler) return
|
|
224
|
+
if (!handler) return null;
|
|
225
225
|
|
|
226
|
-
await handler(...args);
|
|
227
|
-
return true;
|
|
226
|
+
return await handler(...args);
|
|
228
227
|
}
|
|
229
228
|
|
|
230
229
|
export interface MenuHandle {
|
|
@@ -362,10 +361,10 @@ export function createMenuPluginDelegates(): PluginDelegates<PluginRuntimeContex
|
|
|
362
361
|
async 'plugin.get_menus'(): Promise<PluginMenuDefinition[]> {
|
|
363
362
|
return serializeMenus() as unknown as PluginMenuDefinition[];
|
|
364
363
|
},
|
|
365
|
-
async 'plugin.handle_action'(params: PluginHandleActionParams): Promise<
|
|
366
|
-
const actionId = String(params?.action_id || '').trim();
|
|
364
|
+
async 'plugin.handle_action'(params: PluginHandleActionParams): Promise<unknown> {
|
|
365
|
+
const actionId = String(params?.action_id || params?.id || '').trim();
|
|
367
366
|
if (actionId) {
|
|
368
|
-
await runRegisteredAction(actionId, params?.payload);
|
|
367
|
+
return await runRegisteredAction(actionId, params?.payload);
|
|
369
368
|
}
|
|
370
369
|
return null;
|
|
371
370
|
},
|
package/src/lib/runtime/modal.ts
CHANGED
|
@@ -15,8 +15,6 @@ import type {
|
|
|
15
15
|
PluginModalDefinition,
|
|
16
16
|
} from '../types/modal.js';
|
|
17
17
|
|
|
18
|
-
import { invoke } from './menu.js';
|
|
19
|
-
|
|
20
18
|
/** Describes the options accepted by `ModalBuilder.button()`. */
|
|
21
19
|
export interface ModalBuilderButtonOptions {
|
|
22
20
|
/** Stores the optional tooltip text. */
|
|
@@ -165,8 +163,8 @@ export class ModalBuilder {
|
|
|
165
163
|
};
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
/**
|
|
169
|
-
async open(): Promise<
|
|
170
|
-
|
|
166
|
+
/** Returns the serialized modal payload for a host request. */
|
|
167
|
+
async open(): Promise<PluginModalDefinition> {
|
|
168
|
+
return this.build();
|
|
171
169
|
}
|
|
172
170
|
}
|
|
@@ -80,8 +80,11 @@ export function createRegisteredPluginRuntime(
|
|
|
80
80
|
},
|
|
81
81
|
'plugin.handle_action': async (params, ctx) => {
|
|
82
82
|
const actionId = String(params?.action_id || '').trim();
|
|
83
|
-
if (actionId
|
|
84
|
-
|
|
83
|
+
if (actionId) {
|
|
84
|
+
const result = await runRegisteredAction(actionId, params?.payload);
|
|
85
|
+
if (result !== null && result !== undefined) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
if (explicitHandleAction) {
|
|
87
90
|
return explicitHandleAction(params, ctx);
|
package/src/lib/types/plugin.ts
CHANGED
|
@@ -30,6 +30,8 @@ export type PluginSettingsValue = Record<string, unknown>;
|
|
|
30
30
|
|
|
31
31
|
/** Describes the params shape for plugin action handling. */
|
|
32
32
|
export interface PluginHandleActionParams extends RequestParams {
|
|
33
|
+
/** Stores the action id selected by the user when provided by the transport. */
|
|
34
|
+
id?: string;
|
|
33
35
|
/** Stores the action id selected by the user. */
|
|
34
36
|
action_id?: string;
|
|
35
37
|
/** Stores an optional payload supplied by the triggering UI. */
|
|
@@ -76,7 +78,7 @@ export interface PluginDelegates<TContext = unknown> {
|
|
|
76
78
|
/** Handles a contributed plugin action. */
|
|
77
79
|
'plugin.handle_action'?: RpcMethodHandler<
|
|
78
80
|
PluginHandleActionParams,
|
|
79
|
-
|
|
81
|
+
unknown,
|
|
80
82
|
TContext
|
|
81
83
|
>;
|
|
82
84
|
/** Returns the default settings values for the plugin. */
|