@pluv/platform-pluv 3.2.2 → 4.0.0
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 +16 -16
- package/CHANGELOG.md +91 -0
- package/dist/index.d.mts +81 -74
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +433 -435
- package/dist/index.mjs.map +1 -0
- package/package.json +21 -17
- package/src/PluvPlatform.ts +32 -6
- package/src/schemas.ts +22 -7
- package/src/shared/index.ts +0 -1
- package/src/types.ts +12 -9
- package/tsdown.config.ts +14 -0
- package/dist/index.d.ts +0 -96
- package/dist/index.js +0 -500
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-pluv@
|
|
3
|
-
>
|
|
2
|
+
> @pluv/platform-pluv@4.0.0 build /home/runner/work/pluv/pluv/packages/platform-pluv
|
|
3
|
+
> tsdown
|
|
4
4
|
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
|
|
18
|
-
[
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.20.0-beta.4[22m powered by rolldown [2mv1.0.0-beta.60[22m
|
|
6
|
+
[34mℹ[39m config file: [4m/home/runner/work/pluv/pluv/packages/platform-pluv/tsdown.config.ts[24m
|
|
7
|
+
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
8
|
+
[34mℹ[39m target: [34mesnext[39m
|
|
9
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
|
+
[34mℹ[39m Build start
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m13.63 kB[22m [2m│ gzip: 3.43 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22mindex.mjs.map [2m33.64 kB[22m [2m│ gzip: 7.39 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22mindex.d.mts.map [2m 1.86 kB[22m [2m│ gzip: 0.69 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 4.21 kB[22m [2m│ gzip: 1.29 kB[22m
|
|
15
|
+
[34mℹ[39m 4 files, total: 53.34 kB
|
|
16
|
+
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugin `rolldown-plugin-dts:generate`. See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
17
|
+
|
|
18
|
+
[32m✔[39m Build complete in [32m4200ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
1
|
# @pluv/platform-pluv
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- df5c39c: Update all packages to be ESM only.
|
|
8
|
+
- 07e2a1e: ### Breaking Changes
|
|
9
|
+
|
|
10
|
+
This release includes the following breaking changes:
|
|
11
|
+
1. **Removed `onDestroy` handler** (room-level only) - replaced with `onRoomDestroyed` and `onStorageDestroyed`
|
|
12
|
+
2. **Removed `onRoomDeleted` handler** (server-level) - replaced with `onRoomDestroyed` and `onStorageDestroyed`
|
|
13
|
+
3. **Listeners can no longer be configured at room-level** - all listeners must be configured at server-level via `io.server()`
|
|
14
|
+
4. **Event type changes** - `IORoomDestroyedEvent` no longer includes `encodedState`
|
|
15
|
+
|
|
16
|
+
#### Remove `onDestroy` and `onRoomDeleted` in favor of `onRoomDestroyed` and `onStorageDestroyed`
|
|
17
|
+
|
|
18
|
+
**BREAKING**: Two event handlers have been **removed** in favor of two separate handlers that provide better control over when storage is saved. This is a breaking change that requires code updates.
|
|
19
|
+
|
|
20
|
+
**New Handlers:**
|
|
21
|
+
- **`onRoomDestroyed`**: Fires whenever a room is destroyed. This event does NOT include `encodedState` to prevent accidentally saving empty or uninitialized storage data. **Available only at server-level** via `io.server()`.
|
|
22
|
+
- **`onStorageDestroyed`**: Only fires when the storage document is about to be destroyed after it has been initialized via `initializeSession`. This event includes `encodedState` and should be used for saving storage to your database. **Available only at server-level** via `io.server()`.
|
|
23
|
+
|
|
24
|
+
**Removed Handlers:**
|
|
25
|
+
- **`onDestroy`** (room-level only, via `createRoom`): **REMOVED**. Use `onRoomDestroyed` and `onStorageDestroyed` instead.
|
|
26
|
+
- **`onRoomDeleted`** (server-level): **REMOVED**. Use `onRoomDestroyed` and `onStorageDestroyed` instead.
|
|
27
|
+
|
|
28
|
+
**Migration Guide:**
|
|
29
|
+
|
|
30
|
+
**Old (no longer works):**
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// Room-level onDestroy (removed)
|
|
34
|
+
const room = io.createRoom("room-id", {
|
|
35
|
+
onDestroy: async ({ encodedState, room }) => {
|
|
36
|
+
// This no longer works
|
|
37
|
+
await saveToDatabase(room, encodedState);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Server-level onRoomDeleted (removed)
|
|
42
|
+
io.server({
|
|
43
|
+
onRoomDeleted: async ({ encodedState, room }) => {
|
|
44
|
+
// This no longer works
|
|
45
|
+
await saveToDatabase(room, encodedState);
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**New (recommended approach):**
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// Server-level handlers (recommended - all listeners are now server-level)
|
|
54
|
+
io.server({
|
|
55
|
+
onRoomDestroyed: async ({ room }) => {
|
|
56
|
+
// Room destroyed - use for cleanup if needed
|
|
57
|
+
await cleanupRoom(room);
|
|
58
|
+
},
|
|
59
|
+
onStorageDestroyed: async ({ encodedState, room }) => {
|
|
60
|
+
// Only fires when storage was initialized via initializeSession
|
|
61
|
+
// Safe to save to database
|
|
62
|
+
await saveToDatabase(room, encodedState);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Rooms are created without listener options
|
|
67
|
+
const room = io.createRoom("room-id");
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Type Changes
|
|
71
|
+
|
|
72
|
+
**BREAKING**: The following type changes may require TypeScript code updates:
|
|
73
|
+
- **`IORoomDestroyedEvent`** no longer includes `encodedState` (breaking change if you were accessing `encodedState` from this event)
|
|
74
|
+
- **`IORoomListenerEvent`** includes `encodedState: string | null` (used by `onStorageDestroyed`)
|
|
75
|
+
- **All listeners must be configured at the server level** via `io.server()`, not at the room level via `createRoom()` (breaking change - room-level listener configuration is no longer supported)
|
|
76
|
+
- **`CreateRoomOptions`** now correctly requires platform-specific room context properties (e.g., `env` and `state` for Cloudflare) when they are required by the platform, while properly handling optional properties like `meta` (breaking change - TypeScript will now correctly enforce required properties)
|
|
77
|
+
|
|
78
|
+
### Minor Changes
|
|
79
|
+
|
|
80
|
+
- 037074e: Migrated build process from tsup to tsdown.
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- 2eb5def: Bumped dependencies.
|
|
85
|
+
- Updated dependencies [2eb5def]
|
|
86
|
+
- Updated dependencies [df5c39c]
|
|
87
|
+
- Updated dependencies [c142910]
|
|
88
|
+
- Updated dependencies [037074e]
|
|
89
|
+
- Updated dependencies [07e2a1e]
|
|
90
|
+
- @pluv/types@4.0.0
|
|
91
|
+
- @pluv/crdt@4.0.0
|
|
92
|
+
- @pluv/io@4.0.0
|
|
93
|
+
|
|
3
94
|
## 3.2.2
|
|
4
95
|
|
|
5
96
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,96 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { AbstractPlatform, AbstractPlatformConfig, AbstractWebSocket, BaseUser, ConvertWebSocketConfig, CreateIOParams, InferInitContextType, JWTEncodeParams, PluvContext, PluvIOAuthorize, WebSocketSerializedState } from "@pluv/io";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { CrdtLibraryType, NoopCrdtDocFactory } from "@pluv/crdt";
|
|
4
|
+
import { BaseUser as BaseUser$1, Id, MaybePromise } from "@pluv/types";
|
|
4
5
|
|
|
6
|
+
//#region src/types.d.ts
|
|
5
7
|
interface PluvIOEndpoints {
|
|
6
|
-
|
|
8
|
+
createToken: string;
|
|
7
9
|
}
|
|
8
|
-
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/PluvPlatform.d.ts
|
|
9
12
|
type PublicKey = string | (() => MaybePromise<string>);
|
|
10
13
|
type SecretKey = string | (() => MaybePromise<string>);
|
|
11
14
|
type WebhookSecret = string | (() => MaybePromise<string>);
|
|
12
15
|
interface PluvPlatformConfig<TContext extends Record<string, any> = {}> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @ignore
|
|
18
|
+
* @readonly
|
|
19
|
+
* @deprecated Internal use only. Changes to this will never be marked as breaking.
|
|
20
|
+
*/
|
|
21
|
+
_defs?: {
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
endpoints?: PluvIOEndpoints | (() => MaybePromise<PluvIOEndpoints>);
|
|
24
|
+
};
|
|
25
|
+
basePath: string;
|
|
26
|
+
context?: PluvContext<any, TContext>;
|
|
27
|
+
publicKey: PublicKey;
|
|
28
|
+
secretKey: SecretKey;
|
|
29
|
+
webhookSecret?: WebhookSecret;
|
|
27
30
|
}
|
|
28
31
|
declare class PluvPlatform<TContext extends Record<string, any> = {}, TUser extends BaseUser = BaseUser> extends AbstractPlatform<any, {}, {}, {
|
|
32
|
+
authorize: {
|
|
33
|
+
secret: false;
|
|
34
|
+
};
|
|
35
|
+
handleMode: "fetch";
|
|
36
|
+
registrationMode: "attached";
|
|
37
|
+
requireAuth: true;
|
|
38
|
+
listeners: {
|
|
39
|
+
onRoomDestroyed: true;
|
|
40
|
+
onRoomMessage: false;
|
|
41
|
+
onStorageDestroyed: true;
|
|
42
|
+
onStorageUpdated: false;
|
|
43
|
+
onUserConnected: true;
|
|
44
|
+
onUserDisconnected: true;
|
|
45
|
+
};
|
|
46
|
+
router: false;
|
|
47
|
+
}> {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly _config: {
|
|
29
50
|
authorize: {
|
|
30
|
-
|
|
51
|
+
secret: false;
|
|
31
52
|
};
|
|
32
53
|
handleMode: "fetch";
|
|
33
54
|
registrationMode: "attached";
|
|
34
55
|
requireAuth: true;
|
|
35
56
|
listeners: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
onRoomDestroyed: true;
|
|
58
|
+
onRoomMessage: false;
|
|
59
|
+
onStorageDestroyed: true;
|
|
60
|
+
onStorageUpdated: false;
|
|
61
|
+
onUserConnected: true;
|
|
62
|
+
onUserDisconnected: true;
|
|
41
63
|
};
|
|
42
64
|
router: false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
private readonly _webhookSecret?;
|
|
72
|
-
_createToken: (params: JWTEncodeParams<any, any>) => Promise<string>;
|
|
73
|
-
constructor(params: PluvPlatformConfig);
|
|
74
|
-
acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
75
|
-
convertWebSocket(webSocket: any, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
76
|
-
getLastPing(webSocket: AbstractWebSocket): number | null;
|
|
77
|
-
getSerializedState(webSocket: any): WebSocketSerializedState | null;
|
|
78
|
-
getSessionId(webSocket: any): string | null;
|
|
79
|
-
getWebSockets(): readonly any[];
|
|
80
|
-
initialize(config: AbstractPlatformConfig<{}>): this;
|
|
81
|
-
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
82
|
-
randomUUID(): string;
|
|
83
|
-
setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
|
|
84
|
-
validateConfig(config: any): void;
|
|
85
|
-
private _webhooksRouter;
|
|
86
|
-
private _getContext;
|
|
87
|
-
private _logDebug;
|
|
65
|
+
};
|
|
66
|
+
readonly _name = "platformPluv";
|
|
67
|
+
private readonly _app;
|
|
68
|
+
private readonly _basePath;
|
|
69
|
+
private readonly _context;
|
|
70
|
+
private readonly _debug;
|
|
71
|
+
private readonly _endpoints;
|
|
72
|
+
private _getInitialStorage?;
|
|
73
|
+
private _listeners?;
|
|
74
|
+
private readonly _publicKey;
|
|
75
|
+
private readonly _secretKey;
|
|
76
|
+
private readonly _webhookSecret?;
|
|
77
|
+
_createToken: (params: JWTEncodeParams<any, any>) => Promise<string>;
|
|
78
|
+
constructor(params: PluvPlatformConfig);
|
|
79
|
+
acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
80
|
+
convertWebSocket(webSocket: any, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
81
|
+
getLastPing(webSocket: AbstractWebSocket): number | null;
|
|
82
|
+
getSerializedState(webSocket: any): WebSocketSerializedState | null;
|
|
83
|
+
getSessionId(webSocket: any): string | null;
|
|
84
|
+
getWebSockets(): readonly any[];
|
|
85
|
+
initialize(config: AbstractPlatformConfig<{}>): this;
|
|
86
|
+
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
87
|
+
randomUUID(): string;
|
|
88
|
+
setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
|
|
89
|
+
validateConfig(config: any): void;
|
|
90
|
+
private _webhooksRouter;
|
|
91
|
+
private _getContext;
|
|
92
|
+
private _logDebug;
|
|
88
93
|
}
|
|
89
|
-
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/platformPluv.d.ts
|
|
90
96
|
type PlatformPluvCreateIOParams<TContext extends Record<string, any> = {}, TUser extends BaseUser$1 = BaseUser$1, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>> = Id<PluvPlatformConfig & Omit<CreateIOParams<PluvPlatform, TContext, TUser, TCrdt>, "authorize" | "context" | "limits" | "platform"> & {
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
authorize: PluvIOAuthorize<PluvPlatform, TUser, InferInitContextType<PluvPlatform>>;
|
|
98
|
+
context?: PluvContext<PluvPlatform, TContext>;
|
|
93
99
|
}>;
|
|
94
100
|
declare const platformPluv: <TContext extends Record<string, any> = {}, TUser extends BaseUser$1 = BaseUser$1, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>>(config: PlatformPluvCreateIOParams<TContext, TUser, TCrdt>) => CreateIOParams<PluvPlatform<TContext, TUser>, TContext, TUser, TCrdt>;
|
|
95
|
-
|
|
101
|
+
//#endregion
|
|
96
102
|
export { type PlatformPluvCreateIOParams, type PluvIOEndpoints, PluvPlatform, type PublicKey, type SecretKey, type WebhookSecret, platformPluv };
|
|
103
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/PluvPlatform.ts","../src/platformPluv.ts"],"mappings":";;;;;;UAqBiB,eAAA;EACb,WAAA;AAAA;;;KCDQ,SAAA,mBAA4B,YAAA;AAAA,KAC5B,SAAA,mBAA4B,YAAA;AAAA,KAC5B,aAAA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