@pluv/platform-node 0.44.2 → 1.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/platform-node@0.44.2 build /home/runner/work/pluv/pluv/packages/platform-node
2
+ > @pluv/platform-node@1.0.1 build /home/runner/work/pluv/pluv/packages/platform-node
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 11.28 KB
12
- CJS ⚡️ Build success in 93ms
13
- ESM dist/index.mjs 9.49 KB
14
- ESM ⚡️ Build success in 95ms
11
+ ESM dist/index.mjs 9.54 KB
12
+ ESM ⚡️ Build success in 100ms
13
+ CJS dist/index.js 11.33 KB
14
+ CJS ⚡️ Build success in 101ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5813ms
16
+ DTS ⚡️ Build success in 5324ms
17
17
  DTS dist/index.d.mts 6.50 KB
18
18
  DTS dist/index.d.ts 6.50 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @pluv/platform-node
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [c583be9]
8
+ - @pluv/io@1.0.1
9
+ - @pluv/types@1.0.1
10
+
11
+ ## 1.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - af94706: pluv.io is now stable and production ready!
16
+
17
+ With this v1 release, pluv.io will now follow [semantic versioning](https://semver.org/) with more comprehensive release notes for future changes to the library.
18
+
19
+ Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [af94706]
24
+ - @pluv/io@1.0.0
25
+ - @pluv/types@1.0.0
26
+
3
27
  ## 0.44.2
4
28
 
5
29
  ### Patch Changes
package/dist/index.js CHANGED
@@ -248,7 +248,9 @@ var NodeWebSocket = class extends import_io.AbstractWebSocket {
248
248
  case "error":
249
249
  this.webSocket.on("error", (error) => __async(this, null, function* () {
250
250
  const message = error.message;
251
- yield Promise.resolve(handler({ error, message }));
251
+ yield Promise.resolve(
252
+ handler({ error, message })
253
+ );
252
254
  }));
253
255
  return;
254
256
  case "message":
@@ -260,7 +262,9 @@ var NodeWebSocket = class extends import_io.AbstractWebSocket {
260
262
  }
261
263
  }
262
264
  close(code, reason) {
263
- const canClose = [this.CONNECTING, this.OPEN].some((readyState) => readyState === this.readyState);
265
+ const canClose = [this.CONNECTING, this.OPEN].some(
266
+ (readyState) => readyState === this.readyState
267
+ );
264
268
  if (!canClose) return;
265
269
  this.webSocket.close(code, reason);
266
270
  }
@@ -305,7 +309,11 @@ var NodePlatform = class _NodePlatform extends import_io2.AbstractPlatform {
305
309
  }
306
310
  convertWebSocket(webSocket, config) {
307
311
  const { room } = config;
308
- return new NodeWebSocket(webSocket, { persistence: this.persistence, platform: this, room });
312
+ return new NodeWebSocket(webSocket, {
313
+ persistence: this.persistence,
314
+ platform: this,
315
+ room
316
+ });
309
317
  }
310
318
  getLastPing(webSocket) {
311
319
  return null;
package/dist/index.mjs CHANGED
@@ -213,7 +213,9 @@ var NodeWebSocket = class extends AbstractWebSocket {
213
213
  case "error":
214
214
  this.webSocket.on("error", (error) => __async(this, null, function* () {
215
215
  const message = error.message;
216
- yield Promise.resolve(handler({ error, message }));
216
+ yield Promise.resolve(
217
+ handler({ error, message })
218
+ );
217
219
  }));
218
220
  return;
219
221
  case "message":
@@ -225,7 +227,9 @@ var NodeWebSocket = class extends AbstractWebSocket {
225
227
  }
226
228
  }
227
229
  close(code, reason) {
228
- const canClose = [this.CONNECTING, this.OPEN].some((readyState) => readyState === this.readyState);
230
+ const canClose = [this.CONNECTING, this.OPEN].some(
231
+ (readyState) => readyState === this.readyState
232
+ );
229
233
  if (!canClose) return;
230
234
  this.webSocket.close(code, reason);
231
235
  }
@@ -270,7 +274,11 @@ var NodePlatform = class _NodePlatform extends AbstractPlatform {
270
274
  }
271
275
  convertWebSocket(webSocket, config) {
272
276
  const { room } = config;
273
- return new NodeWebSocket(webSocket, { persistence: this.persistence, platform: this, room });
277
+ return new NodeWebSocket(webSocket, {
278
+ persistence: this.persistence,
279
+ platform: this,
280
+ room
281
+ });
274
282
  }
275
283
  getLastPing(webSocket) {
276
284
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-node",
3
- "version": "0.44.2",
3
+ "version": "1.0.1",
4
4
  "description": "@pluv/io adapter for node.js",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -20,16 +20,16 @@
20
20
  "@types/node": "^22.15.3",
21
21
  "@types/ws": "^8.18.1",
22
22
  "path-to-regexp": "^8.2.0",
23
- "@pluv/io": "^0.44.2",
24
- "@pluv/types": "^0.44.2"
23
+ "@pluv/io": "^1.0.1",
24
+ "@pluv/types": "^1.0.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "eslint": "^9.25.1",
28
28
  "tsup": "^8.4.0",
29
29
  "typescript": "^5.8.3",
30
30
  "ws": "^8.18.1",
31
- "@pluv/tsconfig": "^0.44.2",
32
- "eslint-config-pluv": "^0.44.2"
31
+ "@pluv/tsconfig": "^1.0.1",
32
+ "eslint-config-pluv": "^1.0.1"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "ws": "^8.0.0"
@@ -18,7 +18,9 @@ export type NodePlatformRoomContext<TMeta extends Record<string, Json>> = keyof
18
18
  ? { meta?: undefined }
19
19
  : { meta: TMeta };
20
20
 
21
- export type NodePlatformConfig<TMeta extends Record<string, Json>> = { mode?: WebSocketRegistrationMode } & (
21
+ export type NodePlatformConfig<TMeta extends Record<string, Json>> = {
22
+ mode?: WebSocketRegistrationMode;
23
+ } & (
22
24
  | { persistence?: undefined; pubSub?: undefined }
23
25
  | { persistence: AbstractPersistence; pubSub: AbstractPubSub }
24
26
  ) & { roomContext?: NodePlatformRoomContext<TMeta> };
@@ -80,10 +82,17 @@ export class NodePlatform<
80
82
  return Promise.resolve(undefined);
81
83
  }
82
84
 
83
- public convertWebSocket(webSocket: WebSocket, config: ConvertWebSocketConfig): NodeWebSocket<TAuthorize> {
85
+ public convertWebSocket(
86
+ webSocket: WebSocket,
87
+ config: ConvertWebSocketConfig,
88
+ ): NodeWebSocket<TAuthorize> {
84
89
  const { room } = config;
85
90
 
86
- return new NodeWebSocket<TAuthorize>(webSocket, { persistence: this.persistence, platform: this, room });
91
+ return new NodeWebSocket<TAuthorize>(webSocket, {
92
+ persistence: this.persistence,
93
+ platform: this,
94
+ room,
95
+ });
87
96
  }
88
97
 
89
98
  public getLastPing(webSocket: NodeWebSocket<TAuthorize>): number | null {
@@ -87,7 +87,10 @@ export class NodeWebSocket<
87
87
  };
88
88
  }
89
89
 
90
- public addEventListener<TType extends keyof AbstractEventMap>(type: TType, handler: AbstractListener<TType>): void {
90
+ public addEventListener<TType extends keyof AbstractEventMap>(
91
+ type: TType,
92
+ handler: AbstractListener<TType>,
93
+ ): void {
91
94
  switch (type) {
92
95
  case "close":
93
96
  this.webSocket.on("close", async (code, buffer) => {
@@ -101,7 +104,9 @@ export class NodeWebSocket<
101
104
  this.webSocket.on("error", async (error) => {
102
105
  const message = error.message;
103
106
 
104
- await Promise.resolve((handler as AbstractListener<"error">)({ error, message }));
107
+ await Promise.resolve(
108
+ (handler as AbstractListener<"error">)({ error, message }),
109
+ );
105
110
  });
106
111
 
107
112
  return;
@@ -116,7 +121,9 @@ export class NodeWebSocket<
116
121
  }
117
122
 
118
123
  public close(code?: number | undefined, reason?: string | undefined): void {
119
- const canClose = [this.CONNECTING, this.OPEN].some((readyState) => readyState === this.readyState);
124
+ const canClose = [this.CONNECTING, this.OPEN].some(
125
+ (readyState) => readyState === this.readyState,
126
+ );
120
127
 
121
128
  if (!canClose) return;
122
129
 
@@ -1,5 +1,11 @@
1
1
  import type { InferInitContextType, PluvServer } from "@pluv/io";
2
- import type { BaseUser, InferIOAuthorize, InferIOAuthorizeUser, Maybe, MaybePromise } from "@pluv/types";
2
+ import type {
3
+ BaseUser,
4
+ InferIOAuthorize,
5
+ InferIOAuthorizeUser,
6
+ Maybe,
7
+ MaybePromise,
8
+ } from "@pluv/types";
3
9
  import type { Server as HttpServer, IncomingMessage, ServerResponse } from "node:http";
4
10
  import Url from "node:url";
5
11
  import { match } from "path-to-regexp";
@@ -9,7 +15,9 @@ import { NodePlatform } from "./NodePlatform";
9
15
 
10
16
  export type AuthorizeFunctionContext<TPluvServer extends PluvServer<any, any, any, any>> = {
11
17
  room: string;
12
- } & InferInitContextType<TPluvServer extends PluvServer<infer IPlatform, any, any, any> ? IPlatform : never>;
18
+ } & InferInitContextType<
19
+ TPluvServer extends PluvServer<infer IPlatform, any, any, any> ? IPlatform : never
20
+ >;
13
21
 
14
22
  export type AuthorizeFunction<TPluvServer extends PluvServer<any, any, any, any>> = (
15
23
  ctx: AuthorizeFunctionContext<TPluvServer>,
@@ -47,7 +55,10 @@ export interface WebSocketHandlerResult {
47
55
  matched: boolean;
48
56
  }
49
57
 
50
- export type WebSocketHandler = (ws: WebSocket, req: IncomingMessage) => Promise<WebSocketHandlerResult>;
58
+ export type WebSocketHandler = (
59
+ ws: WebSocket,
60
+ req: IncomingMessage,
61
+ ) => Promise<WebSocketHandlerResult>;
51
62
 
52
63
  export interface CreatePluvHandlerResult {
53
64
  createWsServer: () => WebSocketServer;
@@ -91,7 +102,10 @@ export const createPluvHandler = <TPluvServer extends PluvServer<NodePlatform<an
91
102
  return newRoom;
92
103
  };
93
104
 
94
- const wsHandler = async (ws: WebSocket, req: IncomingMessage): Promise<WebSocketHandlerResult> => {
105
+ const wsHandler = async (
106
+ ws: WebSocket,
107
+ req: IncomingMessage,
108
+ ): Promise<WebSocketHandlerResult> => {
95
109
  const url = req.url;
96
110
  const onError = handle(ws);
97
111
 
package/src/index.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  export type { WebSocket } from "ws";
2
2
  export { createPluvHandler } from "./createPluvHandler";
3
- export type { AuthorizeFunction, AuthorizeFunctionContext, CreatePluvHandlerConfig } from "./createPluvHandler";
3
+ export type {
4
+ AuthorizeFunction,
5
+ AuthorizeFunctionContext,
6
+ CreatePluvHandlerConfig,
7
+ } from "./createPluvHandler";
4
8
  export { infer } from "./infer";
5
9
  export type { InferCallback } from "./infer";
6
10
  export type { NodePlatform, NodePlatformConfig } from "./NodePlatform";
package/src/infer.ts CHANGED
@@ -5,4 +5,5 @@ export type InferCallback<TMeta extends Record<string, Json> = {}> = (i: typeof
5
5
  meta?: (io: TMeta) => TMeta;
6
6
  };
7
7
 
8
- export const infer = <TMeta extends Record<string, Json> = {}>(callback: InferCallback<TMeta>) => callback;
8
+ export const infer = <TMeta extends Record<string, Json> = {}>(callback: InferCallback<TMeta>) =>
9
+ callback;
@@ -1,4 +1,10 @@
1
- import type { CreateIOParams, InferInitContextType, PluvContext, PluvIOAuthorize, PluvIOLimits } from "@pluv/io";
1
+ import type {
2
+ CreateIOParams,
3
+ InferInitContextType,
4
+ PluvContext,
5
+ PluvIOAuthorize,
6
+ PluvIOLimits,
7
+ } from "@pluv/io";
2
8
  import type { BaseUser, Id, IOAuthorize, Json } from "@pluv/types";
3
9
  import type { NodePlatformConfig } from "./NodePlatform";
4
10
  import { NodePlatform } from "./NodePlatform";