@pluv/platform-pluv 2.2.5 → 2.2.7

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-pluv@2.2.5 build /home/runner/work/pluv/pluv/packages/platform-pluv
2
+ > @pluv/platform-pluv@2.2.7 build /home/runner/work/pluv/pluv/packages/platform-pluv
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 14.74 KB
12
- CJS ⚡️ Build success in 83ms
13
- ESM dist/index.mjs 12.90 KB
14
- ESM ⚡️ Build success in 84ms
11
+ CJS dist/index.js 14.82 KB
12
+ CJS ⚡️ Build success in 137ms
13
+ ESM dist/index.mjs 12.99 KB
14
+ ESM ⚡️ Build success in 141ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 6655ms
17
- DTS dist/index.d.mts 3.75 KB
18
- DTS dist/index.d.ts 3.75 KB
16
+ DTS ⚡️ Build success in 7116ms
17
+ DTS dist/index.d.mts 3.79 KB
18
+ DTS dist/index.d.ts 3.79 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pluv/platform-pluv
2
2
 
3
+ ## 2.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ec2717b]
8
+ - @pluv/io@2.2.7
9
+ - @pluv/crdt@2.2.7
10
+ - @pluv/types@2.2.7
11
+
12
+ ## 2.2.6
13
+
14
+ ### Patch Changes
15
+
16
+ - d5837ce: Fixed the context in `platformPluv` being declared immediately, instead of when the event listeners ran (causing errors in Cloudflare Workers).
17
+ - @pluv/crdt@2.2.6
18
+ - @pluv/io@2.2.6
19
+ - @pluv/types@2.2.6
20
+
3
21
  ## 2.2.5
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseUser, AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, CreateIOParams, PluvIOAuthorize, InferInitContextType, PluvContext } from '@pluv/io';
1
+ import { PluvContext, BaseUser, AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, CreateIOParams, PluvIOAuthorize, InferInitContextType } from '@pluv/io';
2
2
  import { MaybePromise, BaseUser as BaseUser$1, Id } from '@pluv/types';
3
3
 
4
4
  interface PluvIOEndpoints {
@@ -19,7 +19,7 @@ interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
19
19
  endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
20
20
  };
21
21
  basePath: string;
22
- context?: TContext;
22
+ context?: PluvContext<any, TContext>;
23
23
  publicKey: PublicKey;
24
24
  secretKey: SecretKey;
25
25
  webhookSecret?: WebhookSecret;
@@ -82,6 +82,7 @@ declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser exte
82
82
  setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
83
83
  validateConfig(config: any): void;
84
84
  private _webhooksRouter;
85
+ private _getContext;
85
86
  private _logDebug;
86
87
  }
87
88
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseUser, AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, CreateIOParams, PluvIOAuthorize, InferInitContextType, PluvContext } from '@pluv/io';
1
+ import { PluvContext, BaseUser, AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, CreateIOParams, PluvIOAuthorize, InferInitContextType } from '@pluv/io';
2
2
  import { MaybePromise, BaseUser as BaseUser$1, Id } from '@pluv/types';
3
3
 
4
4
  interface PluvIOEndpoints {
@@ -19,7 +19,7 @@ interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
19
19
  endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
20
20
  };
21
21
  basePath: string;
22
- context?: TContext;
22
+ context?: PluvContext<any, TContext>;
23
23
  publicKey: PublicKey;
24
24
  secretKey: SecretKey;
25
25
  webhookSecret?: WebhookSecret;
@@ -82,6 +82,7 @@ declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser exte
82
82
  setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
83
83
  validateConfig(config: any): void;
84
84
  private _webhooksRouter;
85
+ private _getContext;
85
86
  private _logDebug;
86
87
  }
87
88
 
package/dist/index.js CHANGED
@@ -289,7 +289,7 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
289
289
  const parsed = ZodEvent.safeParse(payload);
290
290
  if (!parsed.success) throw new HttpError("Invalid request", 400);
291
291
  const { event, data } = parsed.data;
292
- const context = this._context;
292
+ const context = this._getContext();
293
293
  switch (event) {
294
294
  case "initial-storage": {
295
295
  const room = data.room;
@@ -346,7 +346,7 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
346
346
  }));
347
347
  const { _defs, basePath, context, publicKey, secretKey, webhookSecret } = params;
348
348
  this._basePath = basePath;
349
- this._context = typeof context === "function" ? context(this._roomContext) : context;
349
+ this._context = context != null ? context : {};
350
350
  this._debug = (_a = _defs == null ? void 0 : _defs.debug) != null ? _a : false;
351
351
  this._endpoints = (_b = _defs == null ? void 0 : _defs.endpoints) != null ? _b : {
352
352
  createToken: "https://rooms.pluv.io/api/room/token"
@@ -410,6 +410,9 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
410
410
  }
411
411
  };
412
412
  }
413
+ _getContext() {
414
+ return typeof this._context === "function" ? this._context(this._roomContext) : this._context;
415
+ }
413
416
  _logDebug(...args) {
414
417
  if (!this._debug) return;
415
418
  console.log("[PLATFORM PLUV]", ...args);
package/dist/index.mjs CHANGED
@@ -259,7 +259,7 @@ var PluvPlatform = class extends AbstractPlatform {
259
259
  const parsed = ZodEvent.safeParse(payload);
260
260
  if (!parsed.success) throw new HttpError("Invalid request", 400);
261
261
  const { event, data } = parsed.data;
262
- const context = this._context;
262
+ const context = this._getContext();
263
263
  switch (event) {
264
264
  case "initial-storage": {
265
265
  const room = data.room;
@@ -316,7 +316,7 @@ var PluvPlatform = class extends AbstractPlatform {
316
316
  }));
317
317
  const { _defs, basePath, context, publicKey, secretKey, webhookSecret } = params;
318
318
  this._basePath = basePath;
319
- this._context = typeof context === "function" ? context(this._roomContext) : context;
319
+ this._context = context != null ? context : {};
320
320
  this._debug = (_a = _defs == null ? void 0 : _defs.debug) != null ? _a : false;
321
321
  this._endpoints = (_b = _defs == null ? void 0 : _defs.endpoints) != null ? _b : {
322
322
  createToken: "https://rooms.pluv.io/api/room/token"
@@ -380,6 +380,9 @@ var PluvPlatform = class extends AbstractPlatform {
380
380
  }
381
381
  };
382
382
  }
383
+ _getContext() {
384
+ return typeof this._context === "function" ? this._context(this._roomContext) : this._context;
385
+ }
383
386
  _logDebug(...args) {
384
387
  if (!this._debug) return;
385
388
  console.log("[PLATFORM PLUV]", ...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-pluv",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "@pluv/io adapter for pluv.io",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -21,16 +21,16 @@
21
21
  "fast-json-stable-stringify": "^2.1.0",
22
22
  "hono": "^4.7.10",
23
23
  "zod": "^3.25.17",
24
- "@pluv/crdt": "^2.2.5",
25
- "@pluv/io": "^2.2.5",
26
- "@pluv/types": "^2.2.5"
24
+ "@pluv/crdt": "^2.2.7",
25
+ "@pluv/io": "^2.2.7",
26
+ "@pluv/types": "^2.2.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "eslint": "^9.27.0",
30
30
  "tsup": "^8.5.0",
31
31
  "typescript": "^5.8.3",
32
- "@pluv/tsconfig": "^2.2.5",
33
- "eslint-config-pluv": "^2.2.5"
32
+ "@pluv/tsconfig": "^2.2.7",
33
+ "eslint-config-pluv": "^2.2.7"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -5,6 +5,7 @@ import type {
5
5
  ConvertWebSocketConfig,
6
6
  GetInitialStorageFn,
7
7
  JWTEncodeParams,
8
+ PluvContext,
8
9
  WebSocketSerializedState,
9
10
  } from "@pluv/io";
10
11
  import { AbstractPlatform } from "@pluv/io";
@@ -33,7 +34,7 @@ export interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
33
34
  endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
34
35
  };
35
36
  basePath: string;
36
- context?: TContext;
37
+ context?: PluvContext<any, TContext>;
37
38
  publicKey: PublicKey;
38
39
  secretKey: SecretKey;
39
40
  webhookSecret?: WebhookSecret;
@@ -84,7 +85,7 @@ export class PluvPlatform<
84
85
 
85
86
  private readonly _app: Hono;
86
87
  private readonly _basePath: string;
87
- private readonly _context: any;
88
+ private readonly _context: PluvContext<this, TContext>;
88
89
  private readonly _debug: boolean;
89
90
  private readonly _endpoints: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
90
91
  private _getInitialStorage?: GetInitialStorageFn<{}>;
@@ -141,7 +142,7 @@ export class PluvPlatform<
141
142
  const { _defs, basePath, context, publicKey, secretKey, webhookSecret } = params;
142
143
 
143
144
  this._basePath = basePath;
144
- this._context = typeof context === "function" ? context(this._roomContext) : context;
145
+ this._context = (context ?? {}) as TContext;
145
146
  this._debug = _defs?.debug ?? false;
146
147
  this._endpoints = _defs?.endpoints ?? {
147
148
  createToken: "https://rooms.pluv.io/api/room/token",
@@ -243,7 +244,7 @@ export class PluvPlatform<
243
244
  if (!parsed.success) throw new HttpError("Invalid request", 400);
244
245
 
245
246
  const { event, data } = parsed.data;
246
- const context = this._context;
247
+ const context = this._getContext();
247
248
 
248
249
  switch (event) {
249
250
  case "initial-storage": {
@@ -311,6 +312,12 @@ export class PluvPlatform<
311
312
  }
312
313
  });
313
314
 
315
+ private _getContext(): TContext {
316
+ return typeof this._context === "function"
317
+ ? this._context(this._roomContext as any)
318
+ : this._context;
319
+ }
320
+
314
321
  private _logDebug(...args: any[]): void {
315
322
  if (!this._debug) return;
316
323