@pluv/platform-node 4.1.0 → 5.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @pluv/platform-node
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@5.0.1
8
+ - @pluv/io@5.0.1
9
+ - @pluv/types@5.0.1
10
+
11
+ ## 5.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - 8f9efe9: **BREAKING**: `@pluv/platform-node` init context now uses `request` instead of `req`, aligned with `@pluv/platform-cloudflare`.
16
+
17
+ - `room.register` and `io.createToken` now take `{ request: Request | IncomingMessage }` instead of `{ req: IncomingMessage }`.
18
+ - Function-form `authorize` receives `{ request: Request }` — `IncomingMessage` values are normalized automatically.
19
+ - Optional `platformNode({ origin })` sets the base URL when converting `IncomingMessage` to `Request`.
20
+
21
+ ```ts
22
+ // Before
23
+ await room.register(ws, { req, token });
24
+ await io.createToken({ req, room, user });
25
+ authorize: ({ req }) => ({ ... });
26
+
27
+ // After
28
+ await room.register(ws, { request: req, token });
29
+ await io.createToken({ request: c.req.raw, room, user });
30
+ authorize: ({ request }) => ({ ... });
31
+ ```
32
+
33
+ See the v5 migration guide for details.
34
+
35
+ ### Patch Changes
36
+
37
+ - @pluv/crdt@5.0.0
38
+ - @pluv/io@5.0.0
39
+ - @pluv/types@5.0.0
40
+
3
41
  ## 4.1.0
4
42
 
5
43
  ### Patch Changes
@@ -1322,9 +1360,7 @@
1322
1360
  import { createClient } from "@pluv/react";
1323
1361
  import type { io } from "../backend/io";
1324
1362
 
1325
- const client = createClient<typeof io>({
1326
- /* ... */
1327
- });
1363
+ const client = createClient<typeof io>({/* ... */});
1328
1364
  ```
1329
1365
 
1330
1366
  ### Now:
@@ -1366,9 +1402,7 @@
1366
1402
  import type { ioServer } from "../backend/io";
1367
1403
 
1368
1404
  // This users the PluvServer type now
1369
- const client = createClient<typeof ioServer>({
1370
- /* ... */
1371
- });
1405
+ const client = createClient<typeof ioServer>({/* ... */});
1372
1406
  ```
1373
1407
 
1374
1408
  - `PluvRouter` instances can also be merged via the `mergeRouters` method, which effectively performs an `Object.assign` of the events object and returns a new `PluvRouter` with the correct types:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-node",
3
- "version": "4.1.0",
3
+ "version": "5.0.1",
4
4
  "description": "@pluv/io adapter for node.js",
5
5
  "author": {
6
6
  "email": "david@pluv.io",
@@ -20,20 +20,20 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@types/node": "^25.9.3",
23
+ "@pluv/crdt": "^5.0.1",
24
+ "@pluv/io": "^5.0.1",
25
+ "@pluv/types": "^5.0.1",
26
+ "@types/node": "^26.2.0",
24
27
  "@types/ws": "^8.18.1",
25
- "path-to-regexp": "^8.4.2",
26
- "@pluv/crdt": "^4.1.0",
27
- "@pluv/io": "^4.1.0",
28
- "@pluv/types": "^4.1.0"
28
+ "path-to-regexp": "^8.4.2"
29
29
  },
30
30
  "devDependencies": {
31
- "eslint": "^10.5.0",
32
- "tsdown": "0.22.2",
31
+ "@pluv/tsconfig": "^5.0.1",
32
+ "eslint": "^10.9.0",
33
+ "eslint-config-pluv": "^5.0.1",
34
+ "tsdown": "0.22.14",
33
35
  "typescript": "^5.9.3",
34
- "ws": "^8.21.0",
35
- "@pluv/tsconfig": "^4.1.0",
36
- "eslint-config-pluv": "^4.1.0"
36
+ "ws": "^8.21.3"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "ws": "^8.0.0"
@@ -9,10 +9,10 @@ import type {
9
9
  import { AbstractPlatform } from "@pluv/io";
10
10
  import type { IOAuthorize, Json } from "@pluv/types";
11
11
  import crypto from "node:crypto";
12
- import type { IncomingMessage } from "node:http";
13
12
  import { TextDecoder } from "node:util";
14
13
  import type { WebSocket } from "ws";
15
14
  import { NodeWebSocket } from "./NodeWebSocket";
15
+ import type { NodeRegisterInput } from "./types";
16
16
 
17
17
  export type NodePlatformRoomContext<TMeta extends Record<string, Json>> = keyof TMeta extends never
18
18
  ? { meta?: undefined }
@@ -20,6 +20,7 @@ export type NodePlatformRoomContext<TMeta extends Record<string, Json>> = keyof
20
20
 
21
21
  export type NodePlatformConfig<TMeta extends Record<string, Json>> = {
22
22
  mode?: WebSocketRegistrationMode;
23
+ origin?: string;
23
24
  } & (
24
25
  | { persistence?: undefined; pubSub?: undefined }
25
26
  | { persistence: AbstractPersistence; pubSub: AbstractPubSub }
@@ -30,7 +31,7 @@ export class NodePlatform<
30
31
  TMeta extends Record<string, Json> = {},
31
32
  > extends AbstractPlatform<
32
33
  NodeWebSocket<TAuthorize>,
33
- { req: IncomingMessage },
34
+ NodeRegisterInput,
34
35
  NodePlatformRoomContext<TMeta>,
35
36
  {
36
37
  authorize: {
@@ -53,15 +54,18 @@ export class NodePlatform<
53
54
  public readonly id = crypto.randomUUID();
54
55
  public readonly _config;
55
56
  public readonly _name = "platformNode";
57
+ public readonly origin: string | undefined;
56
58
 
57
59
  constructor(config: NodePlatformConfig<TMeta> = {}) {
58
- const { roomContext, mode = "attached", persistence, pubSub } = config;
60
+ const { origin, roomContext, mode = "attached", persistence, pubSub } = config;
59
61
 
60
62
  super({
61
63
  roomContext,
62
64
  ...(persistence && pubSub ? { persistence, pubSub } : {}),
63
65
  });
64
66
 
67
+ this.origin = origin;
68
+
65
69
  this._config = {
66
70
  authorize: {
67
71
  secret: true as const,
@@ -116,10 +120,11 @@ export class NodePlatform<
116
120
 
117
121
  public initialize(config: AbstractPlatformConfig<NodePlatformRoomContext<TMeta>>): this {
118
122
  return new NodePlatform({
119
- roomContext: config.roomContext,
120
123
  mode: this._config.registrationMode,
124
+ origin: this.origin,
121
125
  persistence: this.persistence.initialize(config.roomContext),
122
126
  pubSub: this.pubSub,
127
+ roomContext: config.roomContext,
123
128
  } as NodePlatformConfig<TMeta>)._initialize() as this;
124
129
  }
125
130
 
package/src/index.ts CHANGED
@@ -4,3 +4,6 @@ export type { InferCallback } from "./infer";
4
4
  export type { NodePlatform, NodePlatformConfig } from "./NodePlatform";
5
5
  export { platformNode } from "./platformNode";
6
6
  export type { PlatformNodeCreateIOParams } from "./platformNode";
7
+ export type { NodeAuthorizeContext, NodeRegisterInput } from "./types";
8
+ export { toRequest } from "./utils/toRequest";
9
+ export type { ToRequestOptions } from "./utils/toRequest";
@@ -1,9 +1,12 @@
1
1
  import type { CrdtLibraryType, NoopCrdtDocFactory } from "@pluv/crdt";
2
- import type { CreateIOParams, InferInitContextType, PluvContext, PluvIOAuthorize } from "@pluv/io";
2
+ import type { CreateIOParams, PluvContext, PluvIOAuthorize } from "@pluv/io";
3
3
  import type { BaseUser, Id, IOAuthorize, Json } from "@pluv/types";
4
+ import type { IncomingMessage } from "node:http";
4
5
  import type { NodePlatformConfig } from "./NodePlatform";
5
6
  import { NodePlatform } from "./NodePlatform";
6
7
  import type { InferCallback } from "./infer";
8
+ import type { NodeAuthorizeContext } from "./types";
9
+ import { toRequest } from "./utils/toRequest";
7
10
 
8
11
  export type PlatformNodeCreateIOParams<
9
12
  TMeta extends Record<string, Json> = {},
@@ -24,7 +27,7 @@ export type PlatformNodeCreateIOParams<
24
27
  authorize?: PluvIOAuthorize<
25
28
  NodePlatform<IOAuthorize<TUser, TContext>, TMeta>,
26
29
  TUser,
27
- InferInitContextType<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>>
30
+ NodeAuthorizeContext
28
31
  >;
29
32
  context?: PluvContext<NodePlatform<IOAuthorize<TUser, any>, TMeta>, TContext>;
30
33
  types?: InferCallback<TMeta>;
@@ -39,10 +42,16 @@ export const platformNode = <
39
42
  >(
40
43
  config: PlatformNodeCreateIOParams<TMeta, TContext, TUser, TCrdt> = {},
41
44
  ): CreateIOParams<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>, TContext, TUser, TCrdt> => {
42
- const { authorize, context, crdt, debug, limits } = config;
45
+ const { authorize, context, crdt, debug, limits, origin } = config;
46
+
47
+ const resolvedAuthorize =
48
+ typeof authorize === "function"
49
+ ? (input: { request: Request | IncomingMessage }) =>
50
+ authorize({ request: toRequest(input.request, { origin }) })
51
+ : authorize;
43
52
 
44
53
  return {
45
- authorize,
54
+ authorize: resolvedAuthorize,
46
55
  context,
47
56
  crdt,
48
57
  debug,
package/src/types.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { IncomingMessage } from "node:http";
2
+
3
+ export type NodeRegisterInput = { request: Request | IncomingMessage };
4
+
5
+ export type NodeAuthorizeContext = { request: Request };
@@ -1 +1,3 @@
1
1
  export { identity } from "./identity";
2
+ export { toRequest } from "./toRequest";
3
+ export type { ToRequestOptions } from "./toRequest";
@@ -0,0 +1,69 @@
1
+ import type { IncomingMessage } from "node:http";
2
+ import { Readable } from "node:stream";
3
+
4
+ const getHeader = (incoming: IncomingMessage, name: string): string | undefined => {
5
+ const value = incoming.headers[name];
6
+
7
+ if (Array.isArray(value)) return value[0];
8
+
9
+ return value;
10
+ };
11
+
12
+ const inferOrigin = (incoming: IncomingMessage): string => {
13
+ const host =
14
+ getHeader(incoming, "x-forwarded-host") ?? getHeader(incoming, "host") ?? "localhost";
15
+ const forwardedProto = getHeader(incoming, "x-forwarded-proto");
16
+ const protocol =
17
+ forwardedProto ??
18
+ ((incoming.socket as { encrypted?: boolean }).encrypted ? "https" : "http");
19
+
20
+ return `${protocol}://${host}`;
21
+ };
22
+
23
+ const toHeaders = (incoming: IncomingMessage): Headers => {
24
+ const headers = new Headers();
25
+
26
+ for (const [key, value] of Object.entries(incoming.headers)) {
27
+ if (value == null) continue;
28
+
29
+ if (Array.isArray(value)) {
30
+ for (const item of value) headers.append(key, item);
31
+
32
+ continue;
33
+ }
34
+
35
+ headers.append(key, value);
36
+ }
37
+
38
+ return headers;
39
+ };
40
+
41
+ export type ToRequestOptions = {
42
+ origin?: string;
43
+ };
44
+
45
+ export const toRequest = (
46
+ request: Request | IncomingMessage,
47
+ options: ToRequestOptions = {},
48
+ ): Request => {
49
+ if (request instanceof Request) return request;
50
+
51
+ const origin = options.origin ?? inferOrigin(request);
52
+ const url = new URL(request.url ?? "/", origin);
53
+ const method = request.method ?? "GET";
54
+ const headers = toHeaders(request);
55
+
56
+ if (method === "GET" || method === "HEAD") {
57
+ return new Request(url, {
58
+ headers,
59
+ method,
60
+ });
61
+ }
62
+
63
+ return new Request(url, {
64
+ body: Readable.toWeb(request) as ReadableStream,
65
+ duplex: "half",
66
+ headers,
67
+ method,
68
+ });
69
+ };
@@ -1,15 +0,0 @@
1
- $ tsdown
2
- ℹ tsdown v0.22.2 powered by rolldown v1.1.1
3
- ℹ config file: /home/runner/work/pluv/pluv/packages/platform-node/tsdown.config.ts
4
- ℹ entry: src/index.ts
5
- ℹ target: esnext
6
- ℹ tsconfig: tsconfig.json
7
- ℹ Build start
8
- ℹ dist/index.mjs  4.20 kB │ gzip: 1.42 kB
9
- ℹ dist/index.mjs.map 14.12 kB │ gzip: 3.69 kB
10
- ℹ dist/index.d.mts.map  2.79 kB │ gzip: 0.95 kB
11
- ℹ dist/index.d.mts  5.49 kB │ gzip: 1.50 kB
12
- ℹ 4 files, total: 26.60 kB
13
- [PLUGIN_TIMINGS] Your build spent significant time in plugin `rolldown-plugin-dts:generate`. See https://rolldown.rs/options/checks#plugintimings for more details.
14
-
15
- ✔ Build complete in 3850ms
package/dist/index.d.mts DELETED
@@ -1,113 +0,0 @@
1
- import { AbstractEventMap, AbstractListener, AbstractPersistence, AbstractPlatform, AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, AbstractWebSocketConfig, ConvertWebSocketConfig, CreateIOParams, InferInitContextType, PluvContext, PluvIOAuthorize, WebSocketRegistrationMode, WebSocketSerializedState, WebSocketSession } from "@pluv/io";
2
- import { WebSocket, WebSocket as WebSocket$1 } from "ws";
3
- import { BaseUser, IOAuthorize, Id, InferIOAuthorizeUser, Json, JsonObject } from "@pluv/types";
4
- import { IncomingMessage } from "node:http";
5
- import { CrdtLibraryType, NoopCrdtDocFactory } from "@pluv/crdt";
6
-
7
- //#region src/utils/identity.d.ts
8
- declare const identity: <T extends unknown>(x: T) => T;
9
- //#endregion
10
- //#region src/infer.d.ts
11
- type InferCallback<TMeta extends Record<string, Json> = {}> = (i: typeof identity) => {
12
- meta?: (io: TMeta) => TMeta;
13
- };
14
- declare const infer: <TMeta extends Record<string, Json> = {}>(callback: InferCallback<TMeta>) => InferCallback<TMeta>;
15
- //#endregion
16
- //#region src/NodeWebSocket.d.ts
17
- type NodeWebSocketConfig = AbstractWebSocketConfig;
18
- declare class NodeWebSocket<TAuthorize extends IOAuthorize<any, any> | null = null> extends AbstractWebSocket<WebSocket$1> {
19
- private _sessionId;
20
- private _state;
21
- private _user;
22
- set presence(presence: JsonObject | null);
23
- get readyState(): 0 | 1 | 2 | 3;
24
- get session(): WebSocketSession<TAuthorize>;
25
- get sessionId(): string;
26
- get state(): WebSocketSerializedState;
27
- set state(state: WebSocketSerializedState);
28
- set user(user: InferIOAuthorizeUser<TAuthorize>);
29
- constructor(webSocket: WebSocket$1, config: NodeWebSocketConfig);
30
- addEventListener<TType extends keyof AbstractEventMap>(type: TType, handler: AbstractListener<TType>): void;
31
- close(code?: number | undefined, reason?: string | undefined): void;
32
- send(message: string | ArrayBuffer | ArrayBufferView): void;
33
- terminate(): void;
34
- }
35
- //#endregion
36
- //#region src/NodePlatform.d.ts
37
- type NodePlatformRoomContext<TMeta extends Record<string, Json>> = keyof TMeta extends never ? {
38
- meta?: undefined;
39
- } : {
40
- meta: TMeta;
41
- };
42
- type NodePlatformConfig<TMeta extends Record<string, Json>> = {
43
- mode?: WebSocketRegistrationMode;
44
- } & ({
45
- persistence?: undefined;
46
- pubSub?: undefined;
47
- } | {
48
- persistence: AbstractPersistence;
49
- pubSub: AbstractPubSub;
50
- }) & {
51
- roomContext?: NodePlatformRoomContext<TMeta>;
52
- };
53
- declare class NodePlatform<TAuthorize extends IOAuthorize<any, any> | null = null, TMeta extends Record<string, Json> = {}> extends AbstractPlatform<NodeWebSocket<TAuthorize>, {
54
- req: IncomingMessage;
55
- }, NodePlatformRoomContext<TMeta>, {
56
- authorize: {
57
- secret: true;
58
- };
59
- handleMode: "io";
60
- requireAuth: false;
61
- registrationMode: WebSocketRegistrationMode;
62
- listeners: {
63
- onRoomDestroyed: true;
64
- onRoomMessage: true;
65
- onStorageDestroyed: true;
66
- onStorageUpdated: true;
67
- onUserConnected: true;
68
- onUserDisconnected: true;
69
- };
70
- router: true;
71
- }> {
72
- readonly id: `${string}-${string}-${string}-${string}-${string}`;
73
- readonly _config: {
74
- authorize: {
75
- secret: true;
76
- };
77
- handleMode: "io";
78
- registrationMode: WebSocketRegistrationMode;
79
- requireAuth: false;
80
- listeners: {
81
- onRoomDestroyed: true;
82
- onRoomMessage: true;
83
- onStorageDestroyed: true;
84
- onStorageUpdated: true;
85
- onUserConnected: true;
86
- onUserDisconnected: true;
87
- };
88
- router: true;
89
- };
90
- readonly _name = "platformNode";
91
- constructor(config?: NodePlatformConfig<TMeta>);
92
- acceptWebSocket(webSocket: NodeWebSocket<TAuthorize>): Promise<void>;
93
- convertWebSocket(webSocket: WebSocket$1, config: ConvertWebSocketConfig): NodeWebSocket<TAuthorize>;
94
- getLastPing(webSocket: NodeWebSocket<TAuthorize>): number | null;
95
- getSerializedState(webSocket: WebSocket$1): WebSocketSerializedState | null;
96
- getSessionId(webSocket: WebSocket$1): string | null;
97
- getWebSockets(): readonly WebSocket$1[];
98
- initialize(config: AbstractPlatformConfig<NodePlatformRoomContext<TMeta>>): this;
99
- parseData(data: string | ArrayBuffer): Record<string, any>;
100
- randomUUID(): string;
101
- setSerializedState(webSocket: NodeWebSocket<TAuthorize>, state: WebSocketSerializedState): WebSocketSerializedState;
102
- }
103
- //#endregion
104
- //#region src/platformNode.d.ts
105
- type PlatformNodeCreateIOParams<TMeta extends Record<string, Json> = {}, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>> = Id<NodePlatformConfig<TMeta> & Omit<CreateIOParams<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>, TContext, TUser, TCrdt>, "authorize" | "context" | "platform"> & {
106
- authorize?: PluvIOAuthorize<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>, TUser, InferInitContextType<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>>>;
107
- context?: PluvContext<NodePlatform<IOAuthorize<TUser, any>, TMeta>, TContext>;
108
- types?: InferCallback<TMeta>;
109
- }>;
110
- declare const platformNode: <TMeta extends Record<string, Json> = {}, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>>(config?: PlatformNodeCreateIOParams<TMeta, TContext, TUser, TCrdt>) => CreateIOParams<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>, TContext, TUser, TCrdt>;
111
- //#endregion
112
- export { type InferCallback, type NodePlatform, type NodePlatformConfig, type PlatformNodeCreateIOParams, type WebSocket, infer, platformNode };
113
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils/identity.ts","../src/infer.ts","../src/NodeWebSocket.ts","../src/NodePlatform.ts","../src/platformNode.ts"],"mappings":";;;;;;;cAAa,QAAA,sBAA+B,CAAA,EAAG,CAAA,KAAI,CAAM;;;KCG7C,aAAA,eAA4B,MAAA,SAAe,IAAA,WAAe,CAAA,SAAU,QAAA;EAC5E,IAAA,IAAQ,EAAA,EAAI,KAAA,KAAU,KAAA;AAAA;AAAA,cAGb,KAAA,iBAAuB,MAAA,SAAe,IAAA,QAAY,QAAA,EAAU,aAAA,CAAc,KAAA,MAAM,aAAA,CAAA,KAAA;;;KCcjF,mBAAA,GAAsB,uBAAuB;AAAA,cAE5C,aAAA,oBACU,WAAA,kCACb,iBAAA,CAAkB,WAAA;EAAA,QAChB,UAAA;EAAA,QACA,MAAA;EAAA,QACA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BAAA,GAErD,MAAA,GAAQ,0BAAA,CAA2B,KAAA,EAAO,QAAA,EAAU,KAAA,EAAO,KAAA,MAC5D,cAAA,CAAe,YAAA,CAAa,WAAA,CAAY,KAAA,EAAO,QAAA,GAAW,KAAA,GAAQ,QAAA,EAAU,KAAA,EAAO,KAAA"}
package/dist/index.mjs DELETED
@@ -1,190 +0,0 @@
1
- import { AbstractPlatform, AbstractWebSocket } from "@pluv/io";
2
- import crypto from "node:crypto";
3
- import { TextDecoder } from "node:util";
4
- //#region src/infer.ts
5
- const infer = (callback) => callback;
6
- //#endregion
7
- //#region src/NodeWebSocket.ts
8
- var NodeWebSocket = class extends AbstractWebSocket {
9
- _sessionId = null;
10
- _state;
11
- _user = null;
12
- set presence(presence) {
13
- this._state.presence = presence;
14
- }
15
- get readyState() {
16
- return this.webSocket.readyState;
17
- }
18
- get session() {
19
- const sessionId = this.sessionId;
20
- const state = this._state;
21
- const user = this._user;
22
- return {
23
- ...state,
24
- id: sessionId,
25
- user,
26
- webSocket: this
27
- };
28
- }
29
- get sessionId() {
30
- if (this._sessionId) return this._sessionId;
31
- const sessionId = this._sessionId ?? `p_${crypto.randomUUID()}`;
32
- this._sessionId = sessionId;
33
- return sessionId;
34
- }
35
- get state() {
36
- return this._state;
37
- }
38
- set state(state) {
39
- this._state = state;
40
- }
41
- set user(user) {
42
- this._user = user;
43
- }
44
- constructor(webSocket, config) {
45
- const { room } = config;
46
- super(webSocket, config);
47
- this._state = {
48
- presence: null,
49
- quit: false,
50
- room,
51
- timers: {
52
- ping: (/* @__PURE__ */ new Date()).getTime(),
53
- presence: null
54
- }
55
- };
56
- }
57
- addEventListener(type, handler) {
58
- switch (type) {
59
- case "close":
60
- this.webSocket.on("close", async (code, buffer) => {
61
- const reason = buffer.toString("utf-8");
62
- await Promise.resolve(handler({
63
- code,
64
- reason
65
- }));
66
- });
67
- return;
68
- case "error":
69
- this.webSocket.on("error", async (error) => {
70
- const message = error.message;
71
- await Promise.resolve(handler({
72
- error,
73
- message
74
- }));
75
- });
76
- return;
77
- case "message":
78
- this.webSocket.on("message", async (data) => {
79
- await Promise.resolve(handler({ data }));
80
- });
81
- return;
82
- default:
83
- }
84
- }
85
- close(code, reason) {
86
- if (![this.CONNECTING, this.OPEN].some((readyState) => readyState === this.readyState)) return;
87
- this.webSocket.close(code, reason);
88
- }
89
- send(message) {
90
- if (this.readyState !== this.OPEN) return;
91
- this.webSocket.send(message, (error) => {
92
- if (error) throw error;
93
- });
94
- }
95
- terminate() {
96
- this.webSocket.terminate();
97
- }
98
- };
99
- //#endregion
100
- //#region src/NodePlatform.ts
101
- var NodePlatform = class NodePlatform extends AbstractPlatform {
102
- id = crypto.randomUUID();
103
- _config;
104
- _name = "platformNode";
105
- constructor(config = {}) {
106
- const { roomContext, mode = "attached", persistence, pubSub } = config;
107
- super({
108
- roomContext,
109
- ...persistence && pubSub ? {
110
- persistence,
111
- pubSub
112
- } : {}
113
- });
114
- this._config = {
115
- authorize: { secret: true },
116
- handleMode: "io",
117
- registrationMode: mode,
118
- requireAuth: false,
119
- listeners: {
120
- onRoomDestroyed: true,
121
- onRoomMessage: true,
122
- onStorageDestroyed: true,
123
- onStorageUpdated: true,
124
- onUserConnected: true,
125
- onUserDisconnected: true
126
- },
127
- router: true
128
- };
129
- }
130
- acceptWebSocket(webSocket) {
131
- return Promise.resolve(void 0);
132
- }
133
- convertWebSocket(webSocket, config) {
134
- const { room } = config;
135
- return new NodeWebSocket(webSocket, {
136
- persistence: this.persistence,
137
- platform: this,
138
- room
139
- });
140
- }
141
- getLastPing(webSocket) {
142
- return null;
143
- }
144
- getSerializedState(webSocket) {
145
- return null;
146
- }
147
- getSessionId(webSocket) {
148
- return null;
149
- }
150
- getWebSockets() {
151
- return [];
152
- }
153
- initialize(config) {
154
- return new NodePlatform({
155
- roomContext: config.roomContext,
156
- mode: this._config.registrationMode,
157
- persistence: this.persistence.initialize(config.roomContext),
158
- pubSub: this.pubSub
159
- })._initialize();
160
- }
161
- parseData(data) {
162
- if (typeof data === "string") return JSON.parse(data);
163
- const decoder = new TextDecoder("utf8");
164
- return JSON.parse(decoder.decode(data));
165
- }
166
- randomUUID() {
167
- return crypto.randomUUID();
168
- }
169
- setSerializedState(webSocket, state) {
170
- webSocket.state = state;
171
- return webSocket.state;
172
- }
173
- };
174
- //#endregion
175
- //#region src/platformNode.ts
176
- const platformNode = (config = {}) => {
177
- const { authorize, context, crdt, debug, limits } = config;
178
- return {
179
- authorize,
180
- context,
181
- crdt,
182
- debug,
183
- limits,
184
- platform: () => new NodePlatform(config)
185
- };
186
- };
187
- //#endregion
188
- export { infer, platformNode };
189
-
190
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/infer.ts","../src/NodeWebSocket.ts","../src/NodePlatform.ts","../src/platformNode.ts"],"sourcesContent":["import type { Json } from \"@pluv/types\";\nimport type { identity } from \"./utils\";\n\nexport type InferCallback<TMeta extends Record<string, Json> = {}> = (i: typeof identity) => {\n meta?: (io: TMeta) => TMeta;\n};\n\nexport const infer = <TMeta extends Record<string, Json> = {}>(callback: InferCallback<TMeta>) =>\n callback;\n","import type {\n AbstractCloseEvent,\n AbstractErrorEvent,\n AbstractEventMap,\n AbstractListener,\n AbstractMessageEvent,\n AbstractWebSocketConfig,\n WebSocketSerializedState,\n WebSocketSession,\n} from \"@pluv/io\";\nimport { AbstractWebSocket } from \"@pluv/io\";\nimport type { InferIOAuthorizeUser, IOAuthorize, JsonObject } from \"@pluv/types\";\nimport crypto from \"node:crypto\";\nimport type { WebSocket } from \"ws\";\n\nexport interface NodeWebSocketEventMap {\n close: AbstractCloseEvent;\n message: AbstractMessageEvent;\n error: AbstractErrorEvent;\n}\n\nexport type NodeWebSocketConfig = AbstractWebSocketConfig;\n\nexport class NodeWebSocket<\n TAuthorize extends IOAuthorize<any, any> | null = null,\n> extends AbstractWebSocket<WebSocket> {\n private _sessionId: string | null = null;\n private _state: WebSocketSerializedState;\n private _user: InferIOAuthorizeUser<TAuthorize> = null as InferIOAuthorizeUser<TAuthorize>;\n\n public set presence(presence: JsonObject | null) {\n this._state.presence = presence;\n }\n\n public get readyState(): 0 | 1 | 2 | 3 {\n return this.webSocket.readyState;\n }\n\n public get session(): WebSocketSession<TAuthorize> {\n const sessionId = this.sessionId;\n const state = this._state;\n const user = this._user;\n\n return {\n ...state,\n id: sessionId,\n user,\n webSocket: this,\n };\n }\n\n public get sessionId(): string {\n if (this._sessionId) return this._sessionId;\n\n const sessionId = this._sessionId ?? `p_${crypto.randomUUID()}`;\n\n this._sessionId = sessionId;\n\n return sessionId;\n }\n\n public get state(): WebSocketSerializedState {\n return this._state;\n }\n\n public set state(state: WebSocketSerializedState) {\n this._state = state;\n }\n\n public set user(user: InferIOAuthorizeUser<TAuthorize>) {\n this._user = user;\n }\n\n constructor(webSocket: WebSocket, config: NodeWebSocketConfig) {\n const { room } = config;\n\n super(webSocket, config);\n\n this._state = {\n presence: null,\n quit: false,\n room,\n timers: {\n ping: new Date().getTime(),\n presence: null,\n },\n };\n }\n\n public addEventListener<TType extends keyof AbstractEventMap>(\n type: TType,\n handler: AbstractListener<TType>,\n ): void {\n switch (type) {\n case \"close\":\n this.webSocket.on(\"close\", async (code, buffer) => {\n const reason = buffer.toString(\"utf-8\");\n\n await Promise.resolve((handler as AbstractListener<\"close\">)({ code, reason }));\n });\n\n return;\n case \"error\":\n this.webSocket.on(\"error\", async (error) => {\n const message = error.message;\n\n await Promise.resolve(\n (handler as AbstractListener<\"error\">)({ error, message }),\n );\n });\n\n return;\n case \"message\":\n this.webSocket.on(\"message\", async (data) => {\n await Promise.resolve((handler as AbstractListener<\"message\">)({ data }));\n });\n\n return;\n default:\n }\n }\n\n public close(code?: number | undefined, reason?: string | undefined): void {\n const canClose = [this.CONNECTING, this.OPEN].some(\n (readyState) => readyState === this.readyState,\n );\n\n if (!canClose) return;\n\n this.webSocket.close(code, reason);\n }\n\n public send(message: string | ArrayBuffer | ArrayBufferView): void {\n if (this.readyState !== this.OPEN) return;\n\n this.webSocket.send(message, (error) => {\n if (error) throw error;\n });\n }\n\n public terminate(): void {\n this.webSocket.terminate();\n }\n}\n","import type {\n AbstractPersistence,\n AbstractPlatformConfig,\n AbstractPubSub,\n ConvertWebSocketConfig,\n WebSocketRegistrationMode,\n WebSocketSerializedState,\n} from \"@pluv/io\";\nimport { AbstractPlatform } from \"@pluv/io\";\nimport type { IOAuthorize, Json } from \"@pluv/types\";\nimport crypto from \"node:crypto\";\nimport type { IncomingMessage } from \"node:http\";\nimport { TextDecoder } from \"node:util\";\nimport type { WebSocket } from \"ws\";\nimport { NodeWebSocket } from \"./NodeWebSocket\";\n\nexport type NodePlatformRoomContext<TMeta extends Record<string, Json>> = keyof TMeta extends never\n ? { meta?: undefined }\n : { meta: TMeta };\n\nexport type NodePlatformConfig<TMeta extends Record<string, Json>> = {\n mode?: WebSocketRegistrationMode;\n} & (\n | { persistence?: undefined; pubSub?: undefined }\n | { persistence: AbstractPersistence; pubSub: AbstractPubSub }\n) & { roomContext?: NodePlatformRoomContext<TMeta> };\n\nexport class NodePlatform<\n TAuthorize extends IOAuthorize<any, any> | null = null,\n TMeta extends Record<string, Json> = {},\n> extends AbstractPlatform<\n NodeWebSocket<TAuthorize>,\n { req: IncomingMessage },\n NodePlatformRoomContext<TMeta>,\n {\n authorize: {\n secret: true;\n };\n handleMode: \"io\";\n requireAuth: false;\n registrationMode: WebSocketRegistrationMode;\n listeners: {\n onRoomDestroyed: true;\n onRoomMessage: true;\n onStorageDestroyed: true;\n onStorageUpdated: true;\n onUserConnected: true;\n onUserDisconnected: true;\n };\n router: true;\n }\n> {\n public readonly id = crypto.randomUUID();\n public readonly _config;\n public readonly _name = \"platformNode\";\n\n constructor(config: NodePlatformConfig<TMeta> = {}) {\n const { roomContext, mode = \"attached\", persistence, pubSub } = config;\n\n super({\n roomContext,\n ...(persistence && pubSub ? { persistence, pubSub } : {}),\n });\n\n this._config = {\n authorize: {\n secret: true as const,\n },\n handleMode: \"io\" as const,\n registrationMode: mode,\n requireAuth: false as const,\n listeners: {\n onRoomDestroyed: true as const,\n onRoomMessage: true as const,\n onStorageDestroyed: true as const,\n onStorageUpdated: true as const,\n onUserConnected: true as const,\n onUserDisconnected: true as const,\n },\n router: true as const,\n };\n }\n\n public acceptWebSocket(webSocket: NodeWebSocket<TAuthorize>): Promise<void> {\n return Promise.resolve(undefined);\n }\n\n public convertWebSocket(\n webSocket: WebSocket,\n config: ConvertWebSocketConfig,\n ): NodeWebSocket<TAuthorize> {\n const { room } = config;\n\n return new NodeWebSocket<TAuthorize>(webSocket, {\n persistence: this.persistence,\n platform: this,\n room,\n });\n }\n\n public getLastPing(webSocket: NodeWebSocket<TAuthorize>): number | null {\n return null;\n }\n\n public getSerializedState(webSocket: WebSocket): WebSocketSerializedState | null {\n return null;\n }\n\n public getSessionId(webSocket: WebSocket): string | null {\n return null;\n }\n\n public getWebSockets(): readonly WebSocket[] {\n return [];\n }\n\n public initialize(config: AbstractPlatformConfig<NodePlatformRoomContext<TMeta>>): this {\n return new NodePlatform({\n roomContext: config.roomContext,\n mode: this._config.registrationMode,\n persistence: this.persistence.initialize(config.roomContext),\n pubSub: this.pubSub,\n } as NodePlatformConfig<TMeta>)._initialize() as this;\n }\n\n public parseData(data: string | ArrayBuffer): Record<string, any> {\n if (typeof data === \"string\") return JSON.parse(data);\n\n const decoder = new TextDecoder(\"utf8\");\n\n return JSON.parse(decoder.decode(data));\n }\n\n public randomUUID(): string {\n return crypto.randomUUID();\n }\n\n public setSerializedState(\n webSocket: NodeWebSocket<TAuthorize>,\n state: WebSocketSerializedState,\n ): WebSocketSerializedState {\n webSocket.state = state;\n\n return webSocket.state;\n }\n}\n","import type { CrdtLibraryType, NoopCrdtDocFactory } from \"@pluv/crdt\";\nimport type { CreateIOParams, InferInitContextType, PluvContext, PluvIOAuthorize } from \"@pluv/io\";\nimport type { BaseUser, Id, IOAuthorize, Json } from \"@pluv/types\";\nimport type { NodePlatformConfig } from \"./NodePlatform\";\nimport { NodePlatform } from \"./NodePlatform\";\nimport type { InferCallback } from \"./infer\";\n\nexport type PlatformNodeCreateIOParams<\n TMeta extends Record<string, Json> = {},\n TContext extends Record<string, any> = {},\n TUser extends BaseUser | null = null,\n TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>,\n> = Id<\n NodePlatformConfig<TMeta> &\n Omit<\n CreateIOParams<\n NodePlatform<IOAuthorize<TUser, TContext>, TMeta>,\n TContext,\n TUser,\n TCrdt\n >,\n \"authorize\" | \"context\" | \"platform\"\n > & {\n authorize?: PluvIOAuthorize<\n NodePlatform<IOAuthorize<TUser, TContext>, TMeta>,\n TUser,\n InferInitContextType<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>>\n >;\n context?: PluvContext<NodePlatform<IOAuthorize<TUser, any>, TMeta>, TContext>;\n types?: InferCallback<TMeta>;\n }\n>;\n\nexport const platformNode = <\n TMeta extends Record<string, Json> = {},\n TContext extends Record<string, any> = {},\n TUser extends BaseUser | null = null,\n TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>,\n>(\n config: PlatformNodeCreateIOParams<TMeta, TContext, TUser, TCrdt> = {},\n): CreateIOParams<NodePlatform<IOAuthorize<TUser, TContext>, TMeta>, TContext, TUser, TCrdt> => {\n const { authorize, context, crdt, debug, limits } = config;\n\n return {\n authorize,\n context,\n crdt,\n debug,\n limits,\n platform: () => new NodePlatform<IOAuthorize<TUser, TContext>, TMeta>(config),\n };\n};\n"],"mappings":";;;;AAOA,MAAa,SAAkD,aAC3D;;;ACeJ,IAAa,gBAAb,cAEU,kBAA6B;CACnC,aAAoC;CACpC;CACA,QAAkD;CAElD,IAAW,SAAS,UAA6B;EAC7C,KAAK,OAAO,WAAW;CAC3B;CAEA,IAAW,aAA4B;EACnC,OAAO,KAAK,UAAU;CAC1B;CAEA,IAAW,UAAwC;EAC/C,MAAM,YAAY,KAAK;EACvB,MAAM,QAAQ,KAAK;EACnB,MA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