@s2script/sdk 0.17.0 → 0.19.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/entity.d.ts +9 -0
- package/package.json +1 -1
- package/ws.d.ts +21 -2
package/entity.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* NO runtime code: the engine injects the implementation at load time.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { Vector } from "./math";
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* A host-liveness-gated handle to a live entity. `id` is a HOST-MINTED monotonic liveness
|
|
8
10
|
* id — liveness is decided by the host's books (fed by engine create/delete notifications,
|
|
@@ -26,6 +28,13 @@ export declare class EntityRef {
|
|
|
26
28
|
/** This entity's target (`CBaseEntity::m_target`) — the targetname of the entity it acts on, e.g. a
|
|
27
29
|
* `func_button`'s target entity. `""` if the entity has no target; `null` if the ref is stale/invalid. */
|
|
28
30
|
readonly target: string | null;
|
|
31
|
+
/** This entity's world-space position (`CGameSceneNode::m_vecAbsOrigin`, reached via
|
|
32
|
+
* `CBaseEntity::m_CBodyComponent` -> `CBodyComponent::m_pSceneNode`) — the same field CS2's
|
|
33
|
+
* `Pawn.origin` exposes for player pawns, readable here on any entity (e.g. ranking candidate
|
|
34
|
+
* `func_button`s by distance to a reference point). There is no meaningful "empty" position, so
|
|
35
|
+
* unlike {@link EntityRef.name}/{@link EntityRef.target}, `null` means exactly one thing: could not
|
|
36
|
+
* read (the ref is stale/invalid, or the field/chain didn't resolve) — never "no position". */
|
|
37
|
+
readonly origin: Vector | null;
|
|
29
38
|
/** @internal The host mints refs; this is not part of the public API surface. */
|
|
30
39
|
private constructor();
|
|
31
40
|
/** True iff the host's books say live AND the identity slot still matches. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s2script/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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/ws.d.ts
CHANGED
|
@@ -13,17 +13,36 @@ export interface WebSocket {
|
|
|
13
13
|
/** Close the connection. */
|
|
14
14
|
close(): void;
|
|
15
15
|
}
|
|
16
|
+
/** Options for {@link WebSocket.connect}. */
|
|
17
|
+
export interface WebSocketInit {
|
|
18
|
+
/**
|
|
19
|
+
* Extra headers to send on the opening handshake — the usual reason being a
|
|
20
|
+
* credential the server requires, e.g. `Authorization: Bearer <token>`.
|
|
21
|
+
*
|
|
22
|
+
* Headers the handshake owns are refused, and the connect rejects rather than
|
|
23
|
+
* silently dropping them: `Host`, `Connection`, `Upgrade`, any
|
|
24
|
+
* `Sec-WebSocket-*`, `Content-Length`, `Transfer-Encoding`. Values containing
|
|
25
|
+
* control characters are refused for the same reason.
|
|
26
|
+
*/
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
16
30
|
/** Entry point for opening WebSocket connections. */
|
|
17
31
|
export declare const WebSocket: {
|
|
18
32
|
/**
|
|
19
33
|
* Connect to a WebSocket server (`wss://` for TLS) off the game thread.
|
|
20
34
|
* @returns Resolves on the open handshake with the live {@link WebSocket} handle.
|
|
21
|
-
* @throws Rejects on connect failure (bad URL, refused, TLS/handshake error).
|
|
35
|
+
* @throws Rejects on connect failure (bad URL, refused, TLS/handshake error, or a refused header).
|
|
22
36
|
* @example
|
|
23
37
|
* import { WebSocket } from "@s2script/sdk/ws";
|
|
24
38
|
* const ws = await WebSocket.connect("wss://ws.postman-echo.com/raw");
|
|
25
39
|
* ws.onMessage((data) => { console.log("echo:", data); ws.close(); });
|
|
26
40
|
* ws.send("hello-from-s2script");
|
|
41
|
+
* @example
|
|
42
|
+
* // A server that authenticates the handshake rather than the first frame.
|
|
43
|
+
* const ws = await WebSocket.connect("wss://maul.example/v2/ws", {
|
|
44
|
+
* headers: { Authorization: `Bearer ${jwt}` },
|
|
45
|
+
* });
|
|
27
46
|
*/
|
|
28
|
-
connect(url: string): Promise<WebSocket>;
|
|
47
|
+
connect(url: string, init?: WebSocketInit): Promise<WebSocket>;
|
|
29
48
|
};
|