@s2script/sdk 0.27.0 → 0.28.0
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/README.md +51 -0
- package/config.d.ts +2 -2
- package/contracts/workshop.d.ts +1 -1
- package/db.d.ts +18 -4
- package/dist/cli.js +415 -133
- package/events.d.ts +1 -1
- package/http.d.ts +3 -1
- package/interfaces.d.ts +4 -2
- package/menu.d.ts +6 -3
- package/package.json +1 -1
- package/plugin.d.ts +12 -7
- package/topmenu.d.ts +1 -1
- package/unsafe.d.ts +1 -1
- package/usercmd.d.ts +4 -4
- package/ws.d.ts +4 -1
package/events.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare const Events: {
|
|
|
67
67
|
* re-firing a rebuilt copy per viewer does not.
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
70
|
-
*
|
|
70
|
+
* hook.onPre("player_death", () => {
|
|
71
71
|
* Events.setRecipients(traitorSlots); // only Traitors see the kill
|
|
72
72
|
* return HookResult.Handled;
|
|
73
73
|
* });
|
package/http.d.ts
CHANGED
|
@@ -34,7 +34,9 @@ export interface Response {
|
|
|
34
34
|
* @param url - Absolute `http(s)://` URL.
|
|
35
35
|
* @param options - Method, headers, body, and timeout (see {@link FetchOptions}).
|
|
36
36
|
* @returns Resolves for ANY HTTP response — a 4xx/5xx resolves with `ok=false`, it does not reject.
|
|
37
|
-
* @throws Rejects
|
|
37
|
+
* @throws Rejects on a network error or timeout, or with `AsyncQueueFull` / `AsyncPayloadTooLarge`
|
|
38
|
+
* before acceptance. `HttpResponseTooLarge` when the retained UTF-8 body plus headers exceed the
|
|
39
|
+
* configured limit.
|
|
38
40
|
* @example
|
|
39
41
|
* import { fetch } from "@s2script/sdk/http";
|
|
40
42
|
* const r = await fetch("https://httpbin.org/get", { timeoutMs: 15000 });
|
package/interfaces.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { HookResultValue } from "./events";
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Handle returned by `
|
|
8
|
+
* Handle returned by `publish(name, impl)`: lets the producer emit forwarded
|
|
9
9
|
* events to every plugin subscribed to this interface via its `on(event, …)`.
|
|
10
10
|
*/
|
|
11
11
|
export interface PublishHandle {
|
|
@@ -133,8 +133,10 @@ export type TypedInterfaceHandle<C> = ContractMethods<C> & {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
/** A consumer-owned registration. Repeated disposal is a no-op. */
|
|
136
|
-
export interface Subscription {
|
|
136
|
+
export interface Subscription { /** Remove this exact registration. Idempotent. */
|
|
137
|
+
dispose(): void; }
|
|
137
138
|
/** Resources owned by one synchronous optional-provider attachment. */
|
|
138
139
|
export interface AttachmentScope {
|
|
140
|
+
/** Return the resource and retain its disposer for this attachment. */
|
|
139
141
|
own<T extends { dispose(): void }>(resource: T): T;
|
|
140
142
|
}
|
package/menu.d.ts
CHANGED
|
@@ -51,7 +51,6 @@ export interface MenuCancelEvent {
|
|
|
51
51
|
* import { Menu, MenuStyle } from "@s2script/sdk/menu";
|
|
52
52
|
* const m = new Menu("s2script Menu Demo");
|
|
53
53
|
* m.style = MenuStyle.Center;
|
|
54
|
-
* m.freezePlayer = true; // freeze movement while the HUD menu is open
|
|
55
54
|
* m.addItem("hp", "Heal to 100");
|
|
56
55
|
* m.addItem("noclip", "Toggle Noclip");
|
|
57
56
|
* m.onSelect(e => { console.log(`picked ${e.info} (slot ${e.slot})`); });
|
|
@@ -65,8 +64,12 @@ export declare class Menu {
|
|
|
65
64
|
style: MenuStyle;
|
|
66
65
|
/** Append an auto Exit control (default true). */
|
|
67
66
|
exitButton: boolean;
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
67
|
+
/**
|
|
68
|
+
* When true, a renderer that supports it may freeze the player's movement while the menu is open
|
|
69
|
+
* and restore it on close. Default false. The CS2 center renderer currently ignores this and
|
|
70
|
+
* does not freeze movement — freezing is disabled until the menu surface can guarantee it is
|
|
71
|
+
* interactive. The chat renderer also ignores it.
|
|
72
|
+
*/
|
|
70
73
|
freezePlayer: boolean;
|
|
71
74
|
/** `"immediate"` (default) arms cursor on open. `"tab"` paints first and waits for Tab. */
|
|
72
75
|
activation: MenuActivation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s2script/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
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
|
@@ -32,7 +32,7 @@ export interface CtxEvents {
|
|
|
32
32
|
* Subscribe to a fired game event (post-phase). The {@link GameEvent} is valid only synchronously.
|
|
33
33
|
* @example
|
|
34
34
|
* // plugins/disabled/nextmap/src/plugin.ts:133
|
|
35
|
-
*
|
|
35
|
+
* hook.on("round_end", () => console.log("round ended"));
|
|
36
36
|
*/
|
|
37
37
|
on(name: string, handler: (ev: GameEvent) => void): void;
|
|
38
38
|
/** Pre-hook a game event: return a {@link HookResultValue} (`Handled`/`Stop` suppress the client broadcast). */
|
|
@@ -158,7 +158,7 @@ export interface CtxTranslations {
|
|
|
158
158
|
* client's language, then English), so list your own set before any shared one if you want to be
|
|
159
159
|
* able to override a shared phrase.
|
|
160
160
|
*
|
|
161
|
-
* @example
|
|
161
|
+
* @example translations.load("basecomm", "common");
|
|
162
162
|
*/
|
|
163
163
|
load(...names: string[]): void;
|
|
164
164
|
}
|
|
@@ -250,7 +250,11 @@ export interface PluginContext {
|
|
|
250
250
|
use<T extends object>(
|
|
251
251
|
name: keyof InterfaceContracts extends never ? string : never
|
|
252
252
|
): InterfaceHandle<T>;
|
|
253
|
-
/**
|
|
253
|
+
/**
|
|
254
|
+
* Resolve an OPTIONAL dep (must be in `optionalPluginDependencies`); null while unpublished.
|
|
255
|
+
* One-shot lookup — does not track later availability. Prefer watchOptional to follow a provider
|
|
256
|
+
* across load and reload.
|
|
257
|
+
*/
|
|
254
258
|
tryUse<N extends keyof InterfaceContracts>(
|
|
255
259
|
name: N
|
|
256
260
|
): TypedInterfaceHandle<InterfaceContracts[N]> | null;
|
|
@@ -305,10 +309,10 @@ export interface PluginHooks {
|
|
|
305
309
|
* The {@link GameEvent} is valid only synchronously.
|
|
306
310
|
*/
|
|
307
311
|
export declare const hook: {
|
|
308
|
-
/** Post-phase
|
|
312
|
+
/** Post-phase game-event subscribe. The GameEvent is valid only synchronously. */
|
|
309
313
|
on(name: string, handler: (ev: GameEvent) => void): void;
|
|
310
314
|
/**
|
|
311
|
-
* Pre-phase
|
|
315
|
+
* Pre-phase game-event subscribe. Return {@link HookResultValue} `Handled`/`Stop` to suppress
|
|
312
316
|
* the client broadcast.
|
|
313
317
|
*/
|
|
314
318
|
onPre(name: string, handler: (ev: GameEvent) => HookResultValue | void): void;
|
|
@@ -365,7 +369,8 @@ export declare function use<T extends object>(
|
|
|
365
369
|
): InterfaceHandle<T>;
|
|
366
370
|
/**
|
|
367
371
|
* Resolve an OPTIONAL dep (must be in `optionalPluginDependencies`); null while unpublished.
|
|
368
|
-
* Load-window only. Same contract as
|
|
372
|
+
* Load-window only. One-shot lookup — does not track later availability. Same contract as
|
|
373
|
+
* {@link PluginContext.tryUse}.
|
|
369
374
|
*/
|
|
370
375
|
export declare function tryUse<N extends keyof InterfaceContracts>(
|
|
371
376
|
name: N
|
|
@@ -383,7 +388,7 @@ export declare const topmenu: CtxTopMenu;
|
|
|
383
388
|
/**
|
|
384
389
|
* Load-window phrase-file declaration. Same contract as {@link PluginContext.translations}.
|
|
385
390
|
* Throws after settle. `s2s build` / `sync-phrase-types.mjs` collect `translations.load(...)`
|
|
386
|
-
* the same way they collect `
|
|
391
|
+
* the same way they collect `translations.load(...)`.
|
|
387
392
|
*/
|
|
388
393
|
export declare const translations: CtxTranslations;
|
|
389
394
|
|
package/topmenu.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface TopMenuSnapshot {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* The shared admin/top-menu registry — renderers read {@link TopMenu.snapshot} and dispatch picks
|
|
40
|
-
* through {@link TopMenu.select}; items are contributed by plugins via
|
|
40
|
+
* through {@link TopMenu.select}; items are contributed by plugins via `topmenu`.
|
|
41
41
|
* @example
|
|
42
42
|
* import { TopMenu } from "@s2script/sdk/topmenu";
|
|
43
43
|
* const snap = TopMenu.snapshot();
|
package/unsafe.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare const Engine: {
|
|
|
74
74
|
* gate (same class of reasons as {@link Engine.call}, plus a missing `validate` or an unknown
|
|
75
75
|
* thunk shape). Guard once at load; the returned function records the handler and lazily
|
|
76
76
|
* installs the detour. The owner is always the calling plugin — you cannot subscribe to
|
|
77
|
-
* another plugin's hook through this factory (game-package hooks
|
|
77
|
+
* another plugin's hook through this factory (game-package hooks are the `@s2script/cs2` exports such as `players` and `gameRules`).
|
|
78
78
|
*/
|
|
79
79
|
hook<K extends keyof EngineHooks>(name: K): EngineHooks[K] | null;
|
|
80
80
|
/** Why a hook descriptor is unavailable; `"available"` when it resolved. */
|
package/usercmd.d.ts
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
import type { QAngle } from "./math";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* A block-scoped view of the CURRENT tick's usercmd (valid only during
|
|
10
|
+
* A block-scoped view of the CURRENT tick's usercmd (valid only during an `OnPlayerRunCmd`
|
|
11
11
|
* handler — a stashed `UserCmdView` used after the handler returns, or across an `await`,
|
|
12
12
|
* reads/writes nothing). There is exactly ONE `UserCmdView` instance for the whole process; every
|
|
13
13
|
* handler call operates on it.
|
|
14
14
|
* @example
|
|
15
15
|
* import type { UserCmdView } from "@s2script/sdk/usercmd";
|
|
16
|
-
* //
|
|
17
|
-
*
|
|
16
|
+
* // read this tick's input
|
|
17
|
+
* export function OnPlayerRunCmd(cmd: UserCmdView, info: { slot: number }): void {
|
|
18
18
|
* console.log(`slot=${info.slot} fwd=${cmd.forwardMove} btn=${cmd.buttons}`);
|
|
19
|
-
* }
|
|
19
|
+
* }
|
|
20
20
|
*/
|
|
21
21
|
export interface UserCmdView {
|
|
22
22
|
/** +forward / -back. Normalized to roughly [-1, 1] (not the legacy ±450 units). */
|
package/ws.d.ts
CHANGED
|
@@ -9,7 +9,10 @@ export interface WebSocket {
|
|
|
9
9
|
/** Register a handler for a transport error; `err` is the error text. */
|
|
10
10
|
onError(handler: (err: string) => void): void;
|
|
11
11
|
/** Send a text frame. */
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Send a text frame. Returns false if closed, oversized, or the connection/global outbound
|
|
14
|
+
* budget is full.
|
|
15
|
+
*/
|
|
13
16
|
send(data: string): boolean;
|
|
14
17
|
/** Close the connection. */
|
|
15
18
|
close(): void;
|