@openvcs/sdk 0.2.18-edge.20260422.25 → 0.2.18-edge.20260422.26

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.
@@ -21,10 +21,10 @@ export declare function getMenu(menuId: string): MenuHandle | null;
21
21
  /** Returns a menu by id, creating it if needed.
22
22
  * @param menuId - Menu identifier
23
23
  * @param label - User-visible label
24
- * @param options - Optional surface target ('menubar' or 'settings'), defaults to 'menubar'
24
+ * @param options - Surface target ('menubar' or 'settings'), MUST be explicitly provided
25
25
  */
26
- export declare function getOrCreateMenu(menuId: string, label: string, options?: MenubarMenuOptions & {
27
- surface?: MenuSurface;
26
+ export declare function getOrCreateMenu(menuId: string, label: string, options: MenubarMenuOptions & {
27
+ surface: MenuSurface;
28
28
  }): MenuHandle | null;
29
29
  /** Creates a menu at a specific position (alias for getOrCreateMenu). */
30
30
  export declare const createMenu: typeof getOrCreateMenu;
@@ -66,7 +66,7 @@ function placeMenuId(menuId, options) {
66
66
  menuOrder.push(id);
67
67
  }
68
68
  /** Ensures a menu record exists for one id. */
69
- function ensureStoredMenu(menuId, label, options, surface = 'menubar') {
69
+ function ensureStoredMenu(menuId, label, options, surface) {
70
70
  const id = normalizeMenuId(menuId);
71
71
  const safeLabel = String(label || '').trim() || id;
72
72
  let menu = menus.get(id);
@@ -76,9 +76,7 @@ function ensureStoredMenu(menuId, label, options, surface = 'menubar') {
76
76
  }
77
77
  else {
78
78
  menu.label = safeLabel;
79
- // Preserve surface if already set, otherwise use provided.
80
- if (!menu.surface)
81
- menu.surface = surface;
79
+ menu.surface = surface;
82
80
  }
83
81
  placeMenuId(id, options);
84
82
  return menu;
@@ -151,7 +149,7 @@ function serializeMenus() {
151
149
  id: menu.id,
152
150
  label: menu.label,
153
151
  order: index + 1,
154
- surface: menu.surface ?? 'menubar',
152
+ surface: menu.surface,
155
153
  elements: menu.items
156
154
  .map((item) => serializeMenuItem(item))
157
155
  .filter((item) => Boolean(item)),
@@ -179,7 +177,11 @@ function createMenuHandle(menuId) {
179
177
  const action = String(item?.action || '').trim();
180
178
  if (!label || !action)
181
179
  return;
182
- const menu = getStoredMenu(this.id) || ensureStoredMenu(this.id, this.id);
180
+ let menu = getStoredMenu(this.id);
181
+ if (!menu) {
182
+ // Default to menubar for internal menu handle operations.
183
+ menu = ensureStoredMenu(this.id, this.id, {}, 'menubar');
184
+ }
183
185
  insertMenuItem(menu, {
184
186
  kind: 'button',
185
187
  id: action,
@@ -189,7 +191,11 @@ function createMenuHandle(menuId) {
189
191
  }, item.before, item.after);
190
192
  },
191
193
  addSeparator(beforeAction) {
192
- const menu = getStoredMenu(this.id) || ensureStoredMenu(this.id, this.id);
194
+ let menu = getStoredMenu(this.id);
195
+ if (!menu) {
196
+ // Default to menubar for internal menu handle operations.
197
+ menu = ensureStoredMenu(this.id, this.id, {}, 'menubar');
198
+ }
193
199
  insertMenuItem(menu, {
194
200
  kind: 'separator',
195
201
  id: allocateSyntheticId(`${menu.id}-separator`),
@@ -232,11 +238,11 @@ function getMenu(menuId) {
232
238
  /** Returns a menu by id, creating it if needed.
233
239
  * @param menuId - Menu identifier
234
240
  * @param label - User-visible label
235
- * @param options - Optional surface target ('menubar' or 'settings'), defaults to 'menubar'
241
+ * @param options - Surface target ('menubar' or 'settings'), MUST be explicitly provided
236
242
  */
237
243
  function getOrCreateMenu(menuId, label, options) {
238
- const surface = options?.surface ?? 'menubar';
239
- const { surface: _, ...restOptions } = options ?? {};
244
+ const surface = options.surface;
245
+ const { surface: _, ...restOptions } = options;
240
246
  const stored = ensureStoredMenu(menuId, label, restOptions, surface);
241
247
  return createMenuHandle(stored.id);
242
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openvcs/sdk",
3
- "version": "0.2.18-edge.20260422.25",
3
+ "version": "0.2.18-edge.20260422.26",
4
4
  "description": "OpenVCS SDK CLI for plugin scaffolding and runtime asset builds",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "homepage": "https://openvcs.app/",
@@ -35,8 +35,8 @@ interface StoredMenuState {
35
35
  id: string;
36
36
  label: string;
37
37
  hidden?: boolean;
38
- /** Surface target for rendering (defaults to menubar for back-compat). */
39
- surface?: 'menubar' | 'settings';
38
+ /** Surface target for rendering ('menubar' or 'settings'), must be explicitly provided. */
39
+ surface: MenuSurface;
40
40
  items: StoredMenuItem[];
41
41
  }
42
42
 
@@ -119,8 +119,8 @@ function placeMenuId(menuId: string, options?: MenubarMenuOptions): void {
119
119
  function ensureStoredMenu(
120
120
  menuId: string,
121
121
  label: string,
122
- options?: MenubarMenuOptions,
123
- surface: MenuSurface = 'menubar',
122
+ options: MenubarMenuOptions,
123
+ surface: MenuSurface,
124
124
  ): StoredMenuState {
125
125
  const id = normalizeMenuId(menuId);
126
126
  const safeLabel = String(label || '').trim() || id;
@@ -131,8 +131,7 @@ function ensureStoredMenu(
131
131
  menus.set(id, menu);
132
132
  } else {
133
133
  menu.label = safeLabel;
134
- // Preserve surface if already set, otherwise use provided.
135
- if (!menu.surface) menu.surface = surface;
134
+ menu.surface = surface;
136
135
  }
137
136
 
138
137
  placeMenuId(id, options);
@@ -214,7 +213,7 @@ function serializeMenus(): SerializedMenuDefinition[] {
214
213
  id: menu.id,
215
214
  label: menu.label,
216
215
  order: index + 1,
217
- surface: menu.surface ?? 'menubar',
216
+ surface: menu.surface,
218
217
  elements: menu.items
219
218
  .map((item) => serializeMenuItem(item))
220
219
  .filter((item): item is SerializedMenuItem => Boolean(item)),
@@ -254,7 +253,11 @@ function createMenuHandle(menuId: string): MenuHandle {
254
253
  const action = String(item?.action || '').trim();
255
254
  if (!label || !action) return;
256
255
 
257
- const menu = getStoredMenu(this.id) || ensureStoredMenu(this.id, this.id);
256
+ let menu = getStoredMenu(this.id);
257
+ if (!menu) {
258
+ // Default to menubar for internal menu handle operations.
259
+ menu = ensureStoredMenu(this.id, this.id, {}, 'menubar');
260
+ }
258
261
  insertMenuItem(menu, {
259
262
  kind: 'button',
260
263
  id: action,
@@ -264,7 +267,11 @@ function createMenuHandle(menuId: string): MenuHandle {
264
267
  }, item.before, item.after);
265
268
  },
266
269
  addSeparator(beforeAction?: string) {
267
- const menu = getStoredMenu(this.id) || ensureStoredMenu(this.id, this.id);
270
+ let menu = getStoredMenu(this.id);
271
+ if (!menu) {
272
+ // Default to menubar for internal menu handle operations.
273
+ menu = ensureStoredMenu(this.id, this.id, {}, 'menubar');
274
+ }
268
275
  insertMenuItem(menu, {
269
276
  kind: 'separator',
270
277
  id: allocateSyntheticId(`${menu.id}-separator`),
@@ -303,15 +310,15 @@ export function getMenu(menuId: string): MenuHandle | null {
303
310
  /** Returns a menu by id, creating it if needed.
304
311
  * @param menuId - Menu identifier
305
312
  * @param label - User-visible label
306
- * @param options - Optional surface target ('menubar' or 'settings'), defaults to 'menubar'
313
+ * @param options - Surface target ('menubar' or 'settings'), MUST be explicitly provided
307
314
  */
308
315
  export function getOrCreateMenu(
309
316
  menuId: string,
310
317
  label: string,
311
- options?: MenubarMenuOptions & { surface?: MenuSurface },
318
+ options: MenubarMenuOptions & { surface: MenuSurface },
312
319
  ): MenuHandle | null {
313
- const surface = options?.surface ?? 'menubar';
314
- const { surface: _, ...restOptions } = options ?? {};
320
+ const surface = options.surface;
321
+ const { surface: _, ...restOptions } = options;
315
322
  const stored = ensureStoredMenu(menuId, label, restOptions, surface);
316
323
  return createMenuHandle(stored.id);
317
324
  }