@anweather/game-plugin-ssdk 1.16.0 → 1.17.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.
Files changed (36) hide show
  1. package/dist-cjs/runtime/auth.js +8 -0
  2. package/dist-cjs/runtime/conformance.js +6 -0
  3. package/dist-cjs/runtime/index.js +15 -1
  4. package/dist-cjs/runtime/live/checkpoint.js +31 -0
  5. package/dist-cjs/runtime/live/conformance.js +215 -0
  6. package/dist-cjs/runtime/live/harness.js +144 -0
  7. package/dist-cjs/runtime/live/outbox.js +72 -0
  8. package/dist-cjs/runtime/live/protocol.js +227 -0
  9. package/dist-cjs/runtime/live/rooms.js +579 -0
  10. package/dist-cjs/runtime/live/server.js +105 -0
  11. package/dist-cjs/runtime/servePlugin.js +8 -2
  12. package/dist-cjs/tsconfig.cjs.tsbuildinfo +1 -1
  13. package/dist-es/runtime/auth.js +5 -0
  14. package/dist-es/runtime/conformance.js +6 -0
  15. package/dist-es/runtime/index.js +5 -0
  16. package/dist-es/runtime/live/checkpoint.js +28 -0
  17. package/dist-es/runtime/live/conformance.js +210 -0
  18. package/dist-es/runtime/live/harness.js +141 -0
  19. package/dist-es/runtime/live/outbox.js +68 -0
  20. package/dist-es/runtime/live/protocol.js +217 -0
  21. package/dist-es/runtime/live/rooms.js +575 -0
  22. package/dist-es/runtime/live/server.js +102 -0
  23. package/dist-es/runtime/servePlugin.js +8 -2
  24. package/dist-es/tsconfig.es.tsbuildinfo +1 -1
  25. package/dist-types/runtime/auth.d.ts +3 -0
  26. package/dist-types/runtime/conformance.d.ts +6 -0
  27. package/dist-types/runtime/index.d.ts +11 -0
  28. package/dist-types/runtime/live/checkpoint.d.ts +15 -0
  29. package/dist-types/runtime/live/conformance.d.ts +24 -0
  30. package/dist-types/runtime/live/harness.d.ts +71 -0
  31. package/dist-types/runtime/live/outbox.d.ts +39 -0
  32. package/dist-types/runtime/live/protocol.d.ts +169 -0
  33. package/dist-types/runtime/live/rooms.d.ts +302 -0
  34. package/dist-types/runtime/live/server.d.ts +36 -0
  35. package/dist-types/runtime/servePlugin.d.ts +8 -0
  36. package/package.json +6 -3
@@ -0,0 +1,36 @@
1
+ import type { Server } from "node:http";
2
+ import { type LiveOptions, type Room } from "./rooms";
3
+ import type { OutboxStats } from "./outbox";
4
+ export interface AttachLiveOptions {
5
+ gameType: string;
6
+ /** The X-Plugin-Auth bearer token; absent accepts every caller (local
7
+ * dev), exactly like the RPC routes. */
8
+ authToken?: string;
9
+ live: LiveOptions;
10
+ /** Protocol ping interval; the link closes after `linkTimeoutMs` with no
11
+ * frame, ping or pong from the platform. Defaults 20 s and 45 s (design
12
+ * §7.4). */
13
+ pingIntervalMs?: number;
14
+ linkTimeoutMs?: number;
15
+ log?: Pick<Console, "log" | "error">;
16
+ }
17
+ export interface LiveServer {
18
+ /** Rooms currently hosted. */
19
+ rooms(): Room[];
20
+ room(scopeKey: string): Room | undefined;
21
+ outboxStats(scopeKey: string): OutboxStats[];
22
+ /** Number of open room links. */
23
+ links(): number;
24
+ /** Text frames read off every link so far, handed to their rooms. Lets a
25
+ * test know the socket has delivered what it sent before it waits for
26
+ * the rooms to settle. */
27
+ framesReceived(): number;
28
+ /** Resolves once every room has loaded and drained its queue (tests). */
29
+ settled(): Promise<void>;
30
+ /** Checkpoint every room (onClose "shutdown"), close links with 1012, and
31
+ * stop accepting upgrades. */
32
+ close(): Promise<void>;
33
+ }
34
+ /** Serve room links on `server`'s /v1/live. servePlugin calls this when
35
+ * given `live`; a plugin with its own http.Server can call it directly. */
36
+ export declare function attachLive(server: Server, options: AttachLiveOptions): LiveServer;
@@ -4,6 +4,8 @@ import type { ValidationCustomizer } from "@aws-smithy/server-common";
4
4
  import type { GamePluginService, GamePluginServiceOperations } from "../src/server/GamePluginService";
5
5
  import type { OptionalGamePluginService, RequiredGamePluginService } from "./defaultService";
6
6
  import { type RegistrationLoop } from "./registration";
7
+ import { type LiveServer } from "./live/server";
8
+ import type { LiveOptions } from "./live/rooms";
7
9
  /** What a plugin supplies: every operation createGamePluginService requires,
8
10
  * except Health, which servePlugin answers itself unless overridden. */
9
11
  export type PluginServiceDefinition<Context> = Omit<RequiredGamePluginService<Context>, "Health"> & Partial<Pick<GamePluginService<Context>, "Health">> & OptionalGamePluginService<Context>;
@@ -41,6 +43,10 @@ export interface ServePluginOptions<Context = Record<string, never>> {
41
43
  retryDelaySeconds?: number;
42
44
  log?: Pick<Console, "log" | "error">;
43
45
  fetchImpl?: typeof fetch;
46
+ /** Host live rooms (Hosted mode, plugin-protocol/live/PROTOCOL.md): the
47
+ * platform opens one room link per active channel to /v1/live on this
48
+ * same server, behind the same X-Plugin-Auth token. Absent: no /v1/live. */
49
+ live?: LiveOptions;
44
50
  }
45
51
  export interface PluginApp {
46
52
  app: Express;
@@ -52,6 +58,8 @@ export interface PluginApp {
52
58
  }
53
59
  export interface RunningPlugin extends PluginApp {
54
60
  server: Server;
61
+ /** Present when `live` was given. */
62
+ live?: LiveServer;
55
63
  /** The port actually bound (differs from the configured one only for 0). */
56
64
  port: number;
57
65
  /** Stop renewing, deregister, close the listener. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anweather/game-plugin-ssdk",
3
3
  "description": "Generated GamePlugin RPC types/server (plugin-protocol/model/game-plugin.smithy) plus a hand-written Express bridge and default-handler wrapper (./runtime) -- see plugin-protocol/CLAUDE.md's \"Publishing for cross-repo plugins\".",
4
- "version": "1.16.0",
4
+ "version": "1.17.0",
5
5
  "scripts": {
6
6
  "build": "concurrently 'npm:build:cjs' 'npm:build:es' 'npm:build:types'",
7
7
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -60,7 +60,8 @@
60
60
  "@smithy/util-defaults-mode-browser": "^4.0.20",
61
61
  "@smithy/util-defaults-mode-node": "^4.0.20",
62
62
  "@smithy/util-endpoints": "^3.0.6",
63
- "@smithy/util-utf8": "^4.0.0"
63
+ "@smithy/util-utf8": "^4.0.0",
64
+ "ws": "^8.18.0"
64
65
  },
65
66
  "devDependencies": {
66
67
  "@tsconfig/node18": "18.2.4",
@@ -71,7 +72,9 @@
71
72
  "rimraf": "^3.0.0",
72
73
  "typescript": "~5.8.3",
73
74
  "@types/node": "^18.19.69",
74
- "tsx": "^4.19.2"
75
+ "tsx": "^4.19.2",
76
+ "@types/ws": "^8.5.12",
77
+ "ajv": "^8.17.1"
75
78
  },
76
79
  "engines": {
77
80
  "node": ">=18.0.0"