@pluv/platform-pluv 2.2.2 → 2.2.4

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.2 build /home/runner/work/pluv/pluv/packages/platform-pluv
2
+ > @pluv/platform-pluv@2.2.4 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.25 KB
12
- CJS ⚡️ Build success in 96ms
13
- ESM dist/index.mjs 12.42 KB
14
- ESM ⚡️ Build success in 99ms
11
+ CJS dist/index.js 14.70 KB
12
+ CJS ⚡️ Build success in 123ms
13
+ ESM dist/index.mjs 12.86 KB
14
+ ESM ⚡️ Build success in 123ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5981ms
17
- DTS dist/index.d.mts 3.65 KB
18
- DTS dist/index.d.ts 3.65 KB
16
+ DTS ⚡️ Build success in 6713ms
17
+ DTS dist/index.d.mts 3.72 KB
18
+ DTS dist/index.d.ts 3.72 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pluv/platform-pluv
2
2
 
3
+ ## 2.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 113ec6c: Updated internal logging.
8
+ - @pluv/crdt@2.2.4
9
+ - @pluv/io@2.2.4
10
+ - @pluv/types@2.2.4
11
+
12
+ ## 2.2.3
13
+
14
+ ### Patch Changes
15
+
16
+ - feeae21: Added debug logging.
17
+ - @pluv/crdt@2.2.3
18
+ - @pluv/io@2.2.3
19
+ - @pluv/types@2.2.3
20
+
3
21
  ## 2.2.2
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -15,6 +15,7 @@ interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
15
15
  * @deprecated Internal use only. Changes to this will never be marked as breaking.
16
16
  */
17
17
  _defs?: {
18
+ debug?: boolean;
18
19
  endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
19
20
  };
20
21
  basePath: string;
@@ -59,6 +60,7 @@ declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser exte
59
60
  private readonly _app;
60
61
  private readonly _basePath;
61
62
  private readonly _context;
63
+ private readonly _debug;
62
64
  private readonly _endpoints;
63
65
  private _getInitialStorage?;
64
66
  private _listeners?;
@@ -79,6 +81,7 @@ declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser exte
79
81
  setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
80
82
  validateConfig(config: any): void;
81
83
  private _webhooksRouter;
84
+ private _logDebug;
82
85
  }
83
86
 
84
87
  type PlatformPluvCreateIOParams<TContext extends Record<string, any> = {}, TUser extends BaseUser$1 = BaseUser$1> = Id<PluvPlatformConfig & Omit<CreateIOParams<PluvPlatform, TContext, TUser>, "authorize" | "context" | "limits" | "platform"> & {
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
15
15
  * @deprecated Internal use only. Changes to this will never be marked as breaking.
16
16
  */
17
17
  _defs?: {
18
+ debug?: boolean;
18
19
  endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
19
20
  };
20
21
  basePath: string;
@@ -59,6 +60,7 @@ declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser exte
59
60
  private readonly _app;
60
61
  private readonly _basePath;
61
62
  private readonly _context;
63
+ private readonly _debug;
62
64
  private readonly _endpoints;
63
65
  private _getInitialStorage?;
64
66
  private _listeners?;
@@ -79,6 +81,7 @@ declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser exte
79
81
  setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
80
82
  validateConfig(config: any): void;
81
83
  private _webhooksRouter;
84
+ private _logDebug;
82
85
  }
83
86
 
84
87
  type PlatformPluvCreateIOParams<TContext extends Record<string, any> = {}, TUser extends BaseUser$1 = BaseUser$1> = Id<PluvPlatformConfig & Omit<CreateIOParams<PluvPlatform, TContext, TUser>, "authorize" | "context" | "limits" | "platform"> & {
package/dist/index.js CHANGED
@@ -217,7 +217,7 @@ var verifyWebhook = (params) => __async(null, null, function* () {
217
217
  // src/PluvPlatform.ts
218
218
  var PluvPlatform = class extends import_io.AbstractPlatform {
219
219
  constructor(params) {
220
- var _a;
220
+ var _a, _b;
221
221
  super();
222
222
  this._config = {
223
223
  authorize: {
@@ -237,13 +237,14 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
237
237
  };
238
238
  this._name = "platformPluv";
239
239
  this._createToken = (params) => __async(this, null, function* () {
240
- var _a;
240
+ var _a, _b;
241
241
  const parsed = params.authorize.user.parse(params.user);
242
242
  const [endpoints, publicKey, secretKey] = yield Promise.all([
243
243
  typeof this._endpoints === "object" ? this._endpoints : this._endpoints(),
244
244
  typeof this._publicKey === "string" ? this._publicKey : this._publicKey(),
245
245
  typeof this._secretKey === "string" ? this._secretKey : this._secretKey()
246
246
  ]);
247
+ this._logDebug({ endpoints, publicKey, secretKey });
247
248
  const res = yield fetch(endpoints.createToken, {
248
249
  headers: { "content-type": "application/json" },
249
250
  method: "post",
@@ -254,11 +255,16 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
254
255
  secretKey,
255
256
  user: parsed
256
257
  })
257
- }).catch(() => null);
258
+ }).catch((error) => {
259
+ this._logDebug(error);
260
+ return null;
261
+ });
262
+ this._logDebug({ response: { status: (_b = res == null ? void 0 : res.status) != null ? _b : null } });
258
263
  if (!res || !res.ok || res.status !== 200) {
259
264
  throw new Error("Authorization failed");
260
265
  }
261
266
  const token = yield res.text().catch(() => null);
267
+ this._logDebug({ token });
262
268
  if (typeof token !== "string") throw new Error("Authorization failed");
263
269
  return token;
264
270
  });
@@ -337,10 +343,11 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
337
343
  return createErrorResponse(c, { message }, status);
338
344
  }
339
345
  }));
340
- const { _defs, context, basePath, publicKey, secretKey, webhookSecret } = params;
346
+ const { _defs, basePath, context, publicKey, secretKey, webhookSecret } = params;
341
347
  this._basePath = basePath;
342
348
  this._context = typeof context === "function" ? context(this._roomContext) : context;
343
- this._endpoints = (_a = _defs == null ? void 0 : _defs.endpoints) != null ? _a : {
349
+ this._debug = (_a = _defs == null ? void 0 : _defs.debug) != null ? _a : false;
350
+ this._endpoints = (_b = _defs == null ? void 0 : _defs.endpoints) != null ? _b : {
344
351
  createToken: "https://rooms.pluv.io/api/room/token"
345
352
  };
346
353
  this._publicKey = publicKey;
@@ -402,6 +409,10 @@ var PluvPlatform = class extends import_io.AbstractPlatform {
402
409
  }
403
410
  };
404
411
  }
412
+ _logDebug(...args) {
413
+ if (!this._debug) return;
414
+ console.log("[PLATFORM PLUV]", ...args);
415
+ }
405
416
  };
406
417
 
407
418
  // src/platformPluv.ts
package/dist/index.mjs CHANGED
@@ -187,7 +187,7 @@ var verifyWebhook = (params) => __async(null, null, function* () {
187
187
  // src/PluvPlatform.ts
188
188
  var PluvPlatform = class extends AbstractPlatform {
189
189
  constructor(params) {
190
- var _a;
190
+ var _a, _b;
191
191
  super();
192
192
  this._config = {
193
193
  authorize: {
@@ -207,13 +207,14 @@ var PluvPlatform = class extends AbstractPlatform {
207
207
  };
208
208
  this._name = "platformPluv";
209
209
  this._createToken = (params) => __async(this, null, function* () {
210
- var _a;
210
+ var _a, _b;
211
211
  const parsed = params.authorize.user.parse(params.user);
212
212
  const [endpoints, publicKey, secretKey] = yield Promise.all([
213
213
  typeof this._endpoints === "object" ? this._endpoints : this._endpoints(),
214
214
  typeof this._publicKey === "string" ? this._publicKey : this._publicKey(),
215
215
  typeof this._secretKey === "string" ? this._secretKey : this._secretKey()
216
216
  ]);
217
+ this._logDebug({ endpoints, publicKey, secretKey });
217
218
  const res = yield fetch(endpoints.createToken, {
218
219
  headers: { "content-type": "application/json" },
219
220
  method: "post",
@@ -224,11 +225,16 @@ var PluvPlatform = class extends AbstractPlatform {
224
225
  secretKey,
225
226
  user: parsed
226
227
  })
227
- }).catch(() => null);
228
+ }).catch((error) => {
229
+ this._logDebug(error);
230
+ return null;
231
+ });
232
+ this._logDebug({ response: { status: (_b = res == null ? void 0 : res.status) != null ? _b : null } });
228
233
  if (!res || !res.ok || res.status !== 200) {
229
234
  throw new Error("Authorization failed");
230
235
  }
231
236
  const token = yield res.text().catch(() => null);
237
+ this._logDebug({ token });
232
238
  if (typeof token !== "string") throw new Error("Authorization failed");
233
239
  return token;
234
240
  });
@@ -307,10 +313,11 @@ var PluvPlatform = class extends AbstractPlatform {
307
313
  return createErrorResponse(c, { message }, status);
308
314
  }
309
315
  }));
310
- const { _defs, context, basePath, publicKey, secretKey, webhookSecret } = params;
316
+ const { _defs, basePath, context, publicKey, secretKey, webhookSecret } = params;
311
317
  this._basePath = basePath;
312
318
  this._context = typeof context === "function" ? context(this._roomContext) : context;
313
- this._endpoints = (_a = _defs == null ? void 0 : _defs.endpoints) != null ? _a : {
319
+ this._debug = (_a = _defs == null ? void 0 : _defs.debug) != null ? _a : false;
320
+ this._endpoints = (_b = _defs == null ? void 0 : _defs.endpoints) != null ? _b : {
314
321
  createToken: "https://rooms.pluv.io/api/room/token"
315
322
  };
316
323
  this._publicKey = publicKey;
@@ -372,6 +379,10 @@ var PluvPlatform = class extends AbstractPlatform {
372
379
  }
373
380
  };
374
381
  }
382
+ _logDebug(...args) {
383
+ if (!this._debug) return;
384
+ console.log("[PLATFORM PLUV]", ...args);
385
+ }
375
386
  };
376
387
 
377
388
  // src/platformPluv.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-pluv",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "@pluv/io adapter for pluv.io",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,20 +17,20 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@types/node": "^22.15.18",
20
+ "@types/node": "^22.15.21",
21
21
  "fast-json-stable-stringify": "^2.1.0",
22
22
  "hono": "^4.7.10",
23
- "zod": "^3.24.4",
24
- "@pluv/crdt": "^2.2.2",
25
- "@pluv/io": "^2.2.2",
26
- "@pluv/types": "^2.2.2"
23
+ "zod": "^3.25.17",
24
+ "@pluv/crdt": "^2.2.4",
25
+ "@pluv/io": "^2.2.4",
26
+ "@pluv/types": "^2.2.4"
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.2",
33
- "eslint-config-pluv": "^2.2.2"
32
+ "eslint-config-pluv": "^2.2.4",
33
+ "@pluv/tsconfig": "^2.2.4"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -29,6 +29,7 @@ export interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
29
29
  * @deprecated Internal use only. Changes to this will never be marked as breaking.
30
30
  */
31
31
  _defs?: {
32
+ debug?: boolean;
32
33
  endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
33
34
  };
34
35
  basePath: string;
@@ -83,6 +84,7 @@ export class PluvPlatform<
83
84
  private readonly _app: Hono;
84
85
  private readonly _basePath: string;
85
86
  private readonly _context: any;
87
+ private readonly _debug: boolean;
86
88
  private readonly _endpoints: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
87
89
  private _getInitialStorage?: GetInitialStorageFn<{}>;
88
90
  private _listeners?: PluvIOListeners;
@@ -99,6 +101,8 @@ export class PluvPlatform<
99
101
  typeof this._secretKey === "string" ? this._secretKey : this._secretKey(),
100
102
  ]);
101
103
 
104
+ this._logDebug({ endpoints, publicKey, secretKey });
105
+
102
106
  const res = await fetch(endpoints.createToken, {
103
107
  headers: { "content-type": "application/json" },
104
108
  method: "post",
@@ -109,7 +113,13 @@ export class PluvPlatform<
109
113
  secretKey,
110
114
  user: parsed,
111
115
  }),
112
- }).catch(() => null);
116
+ }).catch((error) => {
117
+ this._logDebug(error);
118
+
119
+ return null;
120
+ });
121
+
122
+ this._logDebug({ response: { status: res?.status ?? null } });
113
123
 
114
124
  if (!res || !res.ok || res.status !== 200) {
115
125
  throw new Error("Authorization failed");
@@ -117,6 +127,8 @@ export class PluvPlatform<
117
127
 
118
128
  const token = await res.text().catch(() => null);
119
129
 
130
+ this._logDebug({ token });
131
+
120
132
  if (typeof token !== "string") throw new Error("Authorization failed");
121
133
 
122
134
  return token;
@@ -125,10 +137,11 @@ export class PluvPlatform<
125
137
  constructor(params: PluvPlatformConfig) {
126
138
  super();
127
139
 
128
- const { _defs, context, basePath, publicKey, secretKey, webhookSecret } = params;
140
+ const { _defs, basePath, context, publicKey, secretKey, webhookSecret } = params;
129
141
 
130
142
  this._basePath = basePath;
131
143
  this._context = typeof context === "function" ? context(this._roomContext) : context;
144
+ this._debug = _defs?.debug ?? false;
132
145
  this._endpoints = _defs?.endpoints ?? {
133
146
  createToken: "https://rooms.pluv.io/api/room/token",
134
147
  };
@@ -296,4 +309,10 @@ export class PluvPlatform<
296
309
  return createErrorResponse(c, { message }, status);
297
310
  }
298
311
  });
312
+
313
+ private _logDebug(...args: any[]): void {
314
+ if (!this._debug) return;
315
+
316
+ console.log("[PLATFORM PLUV]", ...args);
317
+ }
299
318
  }