@s2script/sdk 0.26.0 → 0.27.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/README.md +13 -0
- package/config.d.ts +2 -2
- package/contracts/workshop.d.ts +1 -1
- package/damage.d.ts +10 -6
- package/db.d.ts +18 -4
- package/dist/cli.js +3313 -2334
- 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/sdkhooks.d.ts +11 -6
- package/topmenu.d.ts +1 -1
- package/unsafe.d.ts +28 -1
- package/usercmd.d.ts +4 -4
- package/ws.d.ts +4 -1
package/README.md
CHANGED
|
@@ -36,6 +36,19 @@ export function OnClientPostAdminCheck(client: Client): void {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
For an existing plugin with `s2script.gamedata` declarations, run
|
|
40
|
+
`npx @s2script/sdk migrate engine-functions [plugin-dir]`. The command analyzes the v1 declarations
|
|
41
|
+
and source references, reports ambiguities, and writes `gamedata/functions.jsonc` only when the
|
|
42
|
+
declared contract can be converted without loss. It refuses an existing destination unless you pass
|
|
43
|
+
`--force`. Its JSON report lists files actually changed and the package/source edits you must make
|
|
44
|
+
manually, including removal of the old `s2script.gamedata` field and authored engine permissions
|
|
45
|
+
when adopting the v2 file. A successful conversion does not verify that the v1 declaration listed
|
|
46
|
+
every native argument or that the resulting call works on the current game build. The command alone
|
|
47
|
+
does not provide the runtime compatibility facades for old source code. V1 entity hooks are refused
|
|
48
|
+
because their callbacks may receive a null receiver, which the current v2 receiver contract cannot
|
|
49
|
+
preserve. With `--force`, the report identifies the exact create-or-replace path; concurrent prior
|
|
50
|
+
existence cannot be established by the atomic rename.
|
|
51
|
+
|
|
39
52
|
This package is **types-only** — the engine injects the implementation at load time, and
|
|
40
53
|
`s2s build` marks `@s2script/*` external rather than bundling it. Capabilities are imported as
|
|
41
54
|
per-capability subpaths (`@s2script/sdk/entity`, `@s2script/sdk/timers`, `@s2script/sdk/clients`, …);
|
package/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @s2script/config — typed access to the plugin's materialized config. NO runtime code. */
|
|
2
2
|
/** A materialized config value: a scalar, or a nested section object of further values. */
|
|
3
3
|
export type ConfigValue = string | number | boolean | { [k: string]: ConfigValue };
|
|
4
|
-
/** The whole materialized config: top-level keys to {@link ConfigValue}s. Passed to `
|
|
4
|
+
/** The whole materialized config: top-level keys to {@link ConfigValue}s. Passed to `config.onChange` handlers. */
|
|
5
5
|
export type Config = Record<string, ConfigValue>;
|
|
6
6
|
/**
|
|
7
7
|
* Typed access to this plugin's materialized config values (declared under `s2script.config` in the manifest).
|
|
@@ -25,7 +25,7 @@ export declare const config: {
|
|
|
25
25
|
writeFile(name: string, content: string): void;
|
|
26
26
|
/**
|
|
27
27
|
* Fires when this plugin's config file is re-materialized on disk. Ledgered per plugin.
|
|
28
|
-
* Not load-window-gated (safe from `OnPluginStart` or from `
|
|
28
|
+
* Not load-window-gated (safe from `OnPluginStart` or from a `config.onChange` handler).
|
|
29
29
|
*/
|
|
30
30
|
onChange(handler: (cfg: Config) => void): void;
|
|
31
31
|
};
|
package/contracts/workshop.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* import type { WorkshopService } from "@s2script/sdk/contracts/workshop";
|
|
13
|
-
* const ws =
|
|
13
|
+
* const ws = tryUse<WorkshopService>("workshop"); // in OnPluginStart
|
|
14
14
|
* if (ws) {
|
|
15
15
|
* const map = await ws.currentMap();
|
|
16
16
|
* console.log(map ? `${map.title} (${map.id})` : "not a workshop map");
|
package/damage.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @s2script/damage — the
|
|
3
|
-
*
|
|
2
|
+
* @s2script/damage — the borrowed {@link DamageInfo} view of the current damage event.
|
|
3
|
+
* Type-only: the view is supplied by the selected game package (its damage function and damage-info
|
|
4
|
+
* layout are game facts; CS2 maps `CTakeDamageInfo`), through the engine-generic `SDKHook`.
|
|
4
5
|
*
|
|
5
6
|
* Subscribe with `SDKHook` (`SDKHookType.OnTakeDamage` / `OnTakeDamagePost`), not a global mux.
|
|
6
7
|
*/
|
|
7
8
|
import type { EntityRef } from "./entity";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* A
|
|
11
|
-
* `OnTakeDamagePost` SDKHook)
|
|
11
|
+
* A borrowed view of the current damage event, valid only during the synchronous `OnTakeDamage` or
|
|
12
|
+
* `OnTakeDamagePost` SDKHook callback: reading or writing it afterwards (including after an `await`)
|
|
13
|
+
* throws "expired borrowed view". Returning `HookResult.Handled`/`Stop` from `OnTakeDamage` blocks the
|
|
14
|
+
* hit by setting damage to 0 after every handler ran; the engine's damage function still runs.
|
|
12
15
|
* @example
|
|
13
16
|
* import type { DamageInfo } from "@s2script/sdk";
|
|
14
17
|
* function onTakeDamage(info: DamageInfo) { info.damage = info.damage / 2; }
|
|
15
18
|
*/
|
|
16
19
|
export interface DamageInfo {
|
|
17
20
|
/**
|
|
18
|
-
* The damage amount (`m_flDamage`). On the pre-hook, assigning MODIFIES the
|
|
19
|
-
* 0 to block.
|
|
21
|
+
* The damage amount (`m_flDamage`). On the pre-hook, assigning MODIFIES the damage the engine
|
|
22
|
+
* applies (later handlers see it); set to 0 to block. A non-finite value is refused (the damage
|
|
23
|
+
* keeps its prior value). On `OnTakeDamagePost`, assignment is ignored (the original already ran).
|
|
20
24
|
*/
|
|
21
25
|
damage: number;
|
|
22
26
|
/** The damage-type bit flags (m_bitsDamageType). */
|
package/db.d.ts
CHANGED
|
@@ -15,9 +15,16 @@ export interface ExecuteResult {
|
|
|
15
15
|
|
|
16
16
|
/** A driver-owned connection — what a {@link Driver} hands back from {@link Driver.connect}. */
|
|
17
17
|
export interface DriverConnection {
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Run a SELECT and resolve every result {@link Row}; `params` bind `?` placeholders. Rejects
|
|
20
|
+
* with `AsyncQueueFull` or `AsyncPayloadTooLarge` before acceptance; `DatabaseResultTooLarge`
|
|
21
|
+
* when rows or retained bytes exceed the configured limit.
|
|
22
|
+
*/
|
|
19
23
|
query(sql: string, params?: SqlValue[]): Promise<Row[]>;
|
|
20
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Run a non-SELECT statement and resolve its {@link ExecuteResult}; `params` bind `?`
|
|
26
|
+
* placeholders. Rejects with `AsyncQueueFull` or `AsyncPayloadTooLarge` before acceptance.
|
|
27
|
+
*/
|
|
21
28
|
execute(sql: string, params?: SqlValue[]): Promise<ExecuteResult>;
|
|
22
29
|
/** Close the underlying connection. */
|
|
23
30
|
close(): Promise<void>;
|
|
@@ -40,9 +47,16 @@ export interface Driver {
|
|
|
40
47
|
}
|
|
41
48
|
/** A live database connection (delegates to its driver). */
|
|
42
49
|
export interface Database {
|
|
43
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Run a SELECT and resolve every result {@link Row}; `params` bind `?` placeholders. Rejects
|
|
52
|
+
* with `AsyncQueueFull` or `AsyncPayloadTooLarge` before acceptance; `DatabaseResultTooLarge`
|
|
53
|
+
* when rows or retained bytes exceed the configured limit.
|
|
54
|
+
*/
|
|
44
55
|
query(sql: string, params?: SqlValue[]): Promise<Row[]>;
|
|
45
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Run a non-SELECT statement and resolve its {@link ExecuteResult}; `params` bind `?`
|
|
58
|
+
* placeholders. Rejects with `AsyncQueueFull` or `AsyncPayloadTooLarge` before acceptance.
|
|
59
|
+
*/
|
|
46
60
|
execute(sql: string, params?: SqlValue[]): Promise<ExecuteResult>;
|
|
47
61
|
/** Close the connection. */
|
|
48
62
|
close(): Promise<void>;
|