@openvcs/sdk 0.2.13 → 0.2.14

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.
@@ -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<boolean>;
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;
@@ -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 false;
162
+ return null;
163
163
  const handler = actionHandlers.get(id);
164
164
  if (!handler)
165
- return false;
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) {
@@ -291,7 +290,7 @@ function createMenuPluginDelegates() {
291
290
  async 'plugin.handle_action'(params) {
292
291
  const actionId = String(params?.action_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
  },
@@ -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
- /** Requests the host to open the modal with the current definition. */
73
- open(): Promise<void>;
72
+ /** Returns the serialized modal payload for a host request. */
73
+ open(): Promise<PluginModalDefinition>;
74
74
  }
@@ -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
- /** Requests the host to open the modal with the current definition. */
89
+ /** Returns the serialized modal payload for a host request. */
91
90
  async open() {
92
- await (0, menu_js_1.invoke)('open_plugin_modal', { modal: this.build() });
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 && (await (0, menu_1.runRegisteredAction)(actionId))) {
31
- return null;
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);
@@ -44,7 +44,7 @@ export interface PluginDelegates<TContext = unknown> {
44
44
  /** Returns plugin-contributed menus. */
45
45
  'plugin.get_menus'?: RpcMethodHandler<RequestParams, PluginMenuDefinition[], TContext>;
46
46
  /** Handles a contributed plugin action. */
47
- 'plugin.handle_action'?: RpcMethodHandler<PluginHandleActionParams, null, TContext>;
47
+ 'plugin.handle_action'?: RpcMethodHandler<PluginHandleActionParams, unknown, TContext>;
48
48
  /** Returns the default settings values for the plugin. */
49
49
  'plugin.settings.defaults'?: RpcMethodHandler<RequestParams, PluginSettingsValue[], TContext>;
50
50
  /** Transforms settings values when they are loaded. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openvcs/sdk",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
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/",
@@ -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<null> {
51
+ async 'plugin.handle_action'(): Promise<unknown> {
52
52
  return null;
53
53
  },
54
54
  async 'plugin.settings.defaults'(): Promise<[]> {
@@ -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<boolean> {
219
+ export async function runRegisteredAction(actionId: string, ...args: unknown[]): Promise<unknown> {
220
220
  const id = String(actionId || '').trim();
221
- if (!id) return false;
221
+ if (!id) return null;
222
222
 
223
223
  const handler = actionHandlers.get(id);
224
- if (!handler) return false;
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<null> {
364
+ async 'plugin.handle_action'(params: PluginHandleActionParams): Promise<unknown> {
366
365
  const actionId = String(params?.action_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
  },
@@ -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
- /** Requests the host to open the modal with the current definition. */
169
- async open(): Promise<void> {
170
- await invoke('open_plugin_modal', { modal: this.build() });
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 && (await runRegisteredAction(actionId))) {
84
- return null;
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);
@@ -76,7 +76,7 @@ export interface PluginDelegates<TContext = unknown> {
76
76
  /** Handles a contributed plugin action. */
77
77
  'plugin.handle_action'?: RpcMethodHandler<
78
78
  PluginHandleActionParams,
79
- null,
79
+ unknown,
80
80
  TContext
81
81
  >;
82
82
  /** Returns the default settings values for the plugin. */