@s2script/sdk 0.24.0 → 0.25.1

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/menu.d.ts CHANGED
@@ -80,8 +80,12 @@ export declare class Menu {
80
80
  display(slot: number, seconds?: number): void;
81
81
  /** Close an open menu for `slot` early. */
82
82
  close(slot: number): void;
83
- /** Register a display backend under a MenuStyle value (used by the CS2 center renderer). */
84
- static registerRenderer(name: string, renderer: MenuRenderer): void;
83
+ /**
84
+ * Register a display backend under a MenuStyle value (used by the CS2 center renderer).
85
+ * Returns the previous renderer, or undefined if none was registered, so a replacement can
86
+ * delegate to the previous backend when its own display is unavailable.
87
+ */
88
+ static registerRenderer(name: string, renderer: MenuRenderer): MenuRenderer | undefined;
85
89
  }
86
90
 
87
91
  /** A live display of one menu to one slot, passed to a {@link MenuRenderer}. Owns the page/cursor state and exposes the input verbs a renderer drives. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s2script/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.25.1",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "description": "s2script SDK — the builtin capability types (imported as @s2script/sdk/entity, …) plus the `s2s` CLI for building Source 2 / CS2 plugins.",
6
6
  "type": "module",
package/plugin.d.ts CHANGED
@@ -12,7 +12,7 @@ import type { EntityRef, OutputEvent } from "./entity";
12
12
  import type { CommandHandler } from "./commands";
13
13
  import type { Config } from "./config";
14
14
  import type { PublishHandle } from "./interfaces";
15
- import type { TopMenuItem } from "./topmenu";
15
+ import type { TopMenuItem, TopMenuTab } from "./topmenu";
16
16
  import type { PrecacheContext } from "./sound";
17
17
  import type { UserCmdView } from "./usercmd";
18
18
 
@@ -133,9 +133,14 @@ export interface CtxConfig {
133
133
  }
134
134
  /** TopMenu (adminmenu) contribution on this plugin's load-scope ({@link PluginContext.topmenu}). */
135
135
  export interface CtxTopMenu {
136
- /** Add (or reuse) a top-level menu category. */
136
+ /** Add (or reuse) a top-level menu category. Same as {@link CtxTopMenu.addTab} with `id === title`. */
137
137
  addCategory(name: string): void;
138
- /** Add an item under an existing category. */
138
+ /**
139
+ * Declare this plugin's dashboard tab. The hub (`sm_admin` / `sm_menu`) paints one tab per
140
+ * distinct id that still has a visible item. Call before {@link CtxTopMenu.addItem}.
141
+ */
142
+ addTab(tab: TopMenuTab): void;
143
+ /** Add an item under a tab id (or a legacy shared category name). */
139
144
  addItem(category: string, item: TopMenuItem): void;
140
145
  }
141
146
 
package/topmenu.d.ts CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  export type TopMenuSheet = "admin" | "menu";
4
4
 
5
+ /**
6
+ * A plugin-owned dashboard tab. `id` is the {@link TopMenuItem} grouping key (`addItem` first
7
+ * argument); `title` is what the hub paints on the tab bar.
8
+ */
9
+ export interface TopMenuTab {
10
+ /** Stable id, e.g. `"playercommands"`. A duplicate id updates the title. */
11
+ id: string;
12
+ /** Tab label. Defaults to {@link TopMenuTab.id}. */
13
+ title?: string;
14
+ }
15
+
5
16
  /** A single registered top-menu entry (an admin command surfaced in the adminmenu). */
6
17
  export interface TopMenuItem {
7
18
  /** Plugin-namespaced unique id, e.g. "playercommands:slap". A duplicate id replaces. */
@@ -17,9 +28,11 @@ export interface TopMenuItem {
17
28
  }
18
29
  /** A handler-free copy of the whole registry — what a menu renderer reads to build the display. */
19
30
  export interface TopMenuSnapshot {
20
- /** All category names, in registration order. */
31
+ /** Tab ids, in registration order. Same sequence as {@link TopMenuSnapshot.tabs}. */
21
32
  categories: string[];
22
- /** Every registered item's metadata (no `onSelect`), tagged with its category. */
33
+ /** Dashboard tabs with display titles. `addCategory(name)` is `{ id: name, title: name }`. */
34
+ tabs: { id: string; title: string }[];
35
+ /** Every registered item's metadata (no `onSelect`), tagged with its tab id (`category`). */
23
36
  items: { id: string; category: string; name: string; flags: number; sheets: TopMenuSheet[] }[];
24
37
  }
25
38
  /**