@pluv/platform-pluv 2.2.5 → 2.2.6
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +9 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -2
- package/dist/index.mjs +5 -2
- package/package.json +6 -6
- package/src/PluvPlatform.ts +11 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-pluv@2.2.
|
|
2
|
+
> @pluv/platform-pluv@2.2.6 build /home/runner/work/pluv/pluv/packages/platform-pluv
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m12.99 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 132ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m14.82 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 132ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 6531ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.79 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.79 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @pluv/platform-pluv
|
|
2
2
|
|
|
3
|
+
## 2.2.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d5837ce: Fixed the context in `platformPluv` being declared immediately, instead of when the event listeners ran (causing errors in Cloudflare Workers).
|
|
8
|
+
- @pluv/crdt@2.2.6
|
|
9
|
+
- @pluv/io@2.2.6
|
|
10
|
+
- @pluv/types@2.2.6
|
|
11
|
+
|
|
3
12
|
## 2.2.5
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUser, AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, CreateIOParams, PluvIOAuthorize, InferInitContextType
|
|
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
|
|
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.
|
|
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 =
|
|
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.
|
|
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 =
|
|
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.
|
|
3
|
+
"version": "2.2.6",
|
|
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.
|
|
25
|
-
"@pluv/io": "^2.2.
|
|
26
|
-
"@pluv/types": "^2.2.
|
|
24
|
+
"@pluv/crdt": "^2.2.6",
|
|
25
|
+
"@pluv/io": "^2.2.6",
|
|
26
|
+
"@pluv/types": "^2.2.6"
|
|
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.
|
|
33
|
-
"eslint-config-pluv": "^2.2.
|
|
32
|
+
"@pluv/tsconfig": "^2.2.6",
|
|
33
|
+
"eslint-config-pluv": "^2.2.6"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/PluvPlatform.ts
CHANGED
|
@@ -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:
|
|
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 =
|
|
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.
|
|
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
|
|