@pluv/platform-cloudflare 0.21.1 → 0.23.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 +8 -8
- package/CHANGELOG.md +21 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +6 -6
- package/src/CloudflarePlatform.ts +2 -2
- package/src/CloudflareWebSocket.ts +6 -0
- package/src/constants.ts +1 -1
- package/src/createPluvHandler.ts +0 -2
- package/src/platformCloudflare.ts +3 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-cloudflare@0.
|
|
2
|
+
> @pluv/platform-cloudflare@0.23.0 build /home/runner/work/pluv/pluv/packages/platform-cloudflare
|
|
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[32m14.13 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 95ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m15.18 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 96ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3590ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.15 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.15 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @pluv/platform-cloudflare
|
|
2
2
|
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c01b16f]
|
|
8
|
+
- @pluv/io@0.23.0
|
|
9
|
+
- @pluv/types@0.23.0
|
|
10
|
+
|
|
11
|
+
## 0.22.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 650e577: \* Fix `@pluv/platform-cloudflare` causing frequent disconnects due to incorrect heartbeat handling.
|
|
16
|
+
- Updated default `mode` of `@pluv/platform-cloudflare` back to `"detached"` (i.e. use Cloudflare Worker Hibernation API by default).
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [650e577]
|
|
21
|
+
- @pluv/io@0.22.0
|
|
22
|
+
- @pluv/types@0.22.0
|
|
23
|
+
|
|
3
24
|
## 0.21.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ declare class CloudflareWebSocket extends AbstractWebSocket<WebSocket> {
|
|
|
7
7
|
get readyState(): 0 | 1 | 2 | 3;
|
|
8
8
|
get sessionId(): string;
|
|
9
9
|
get state(): WebSocketSerializedState;
|
|
10
|
+
set state(state: WebSocketSerializedState);
|
|
10
11
|
constructor(webSocket: WebSocket, config: CloudflareWebSocketConfig);
|
|
11
12
|
addEventListener<TType extends keyof AbstractEventMap>(type: TType, handler: AbstractListener<TType>): void;
|
|
12
13
|
close(code?: number | undefined, reason?: string | undefined): void;
|
|
@@ -31,7 +32,7 @@ declare class CloudflarePlatform<TEnv extends Record<string, any> = {}> extends
|
|
|
31
32
|
acceptWebSocket(webSocket: CloudflareWebSocket): Promise<void>;
|
|
32
33
|
convertWebSocket(webSocket: WebSocket, config: ConvertWebSocketConfig): CloudflareWebSocket;
|
|
33
34
|
getLastPing(webSocket: CloudflareWebSocket): number | null;
|
|
34
|
-
getSerializedState(webSocket:
|
|
35
|
+
getSerializedState(webSocket: WebSocket): WebSocketSerializedState | null;
|
|
35
36
|
getSessionId(webSocket: WebSocket): string | null;
|
|
36
37
|
getWebSockets(): readonly WebSocket[];
|
|
37
38
|
initialize(config: AbstractPlatformConfig<{
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare class CloudflareWebSocket extends AbstractWebSocket<WebSocket> {
|
|
|
7
7
|
get readyState(): 0 | 1 | 2 | 3;
|
|
8
8
|
get sessionId(): string;
|
|
9
9
|
get state(): WebSocketSerializedState;
|
|
10
|
+
set state(state: WebSocketSerializedState);
|
|
10
11
|
constructor(webSocket: WebSocket, config: CloudflareWebSocketConfig);
|
|
11
12
|
addEventListener<TType extends keyof AbstractEventMap>(type: TType, handler: AbstractListener<TType>): void;
|
|
12
13
|
close(code?: number | undefined, reason?: string | undefined): void;
|
|
@@ -31,7 +32,7 @@ declare class CloudflarePlatform<TEnv extends Record<string, any> = {}> extends
|
|
|
31
32
|
acceptWebSocket(webSocket: CloudflareWebSocket): Promise<void>;
|
|
32
33
|
convertWebSocket(webSocket: WebSocket, config: ConvertWebSocketConfig): CloudflareWebSocket;
|
|
33
34
|
getLastPing(webSocket: CloudflareWebSocket): number | null;
|
|
34
|
-
getSerializedState(webSocket:
|
|
35
|
+
getSerializedState(webSocket: WebSocket): WebSocketSerializedState | null;
|
|
35
36
|
getSessionId(webSocket: WebSocket): string | null;
|
|
36
37
|
getWebSockets(): readonly WebSocket[];
|
|
37
38
|
initialize(config: AbstractPlatformConfig<{
|
package/dist/index.js
CHANGED
|
@@ -207,6 +207,10 @@ var CloudflareWebSocket = class extends import_io.AbstractWebSocket {
|
|
|
207
207
|
if (!state) throw new Error("Could not get websocket state");
|
|
208
208
|
return state;
|
|
209
209
|
}
|
|
210
|
+
set state(state) {
|
|
211
|
+
const deserialized = this.webSocket.deserializeAttachment();
|
|
212
|
+
this.webSocket.serializeAttachment(__spreadProps(__spreadValues({}, deserialized), { state }));
|
|
213
|
+
}
|
|
210
214
|
constructor(webSocket, config) {
|
|
211
215
|
const { room } = config;
|
|
212
216
|
super(webSocket, config);
|
|
@@ -333,7 +337,7 @@ var PersistanceCloudflare = class extends import_io2.AbstractPersistance {
|
|
|
333
337
|
};
|
|
334
338
|
|
|
335
339
|
// src/constants.ts
|
|
336
|
-
var DEFAULT_REGISTRATION_MODE = "
|
|
340
|
+
var DEFAULT_REGISTRATION_MODE = "detached";
|
|
337
341
|
|
|
338
342
|
// src/CloudflarePlatform.ts
|
|
339
343
|
var CloudflarePlatform = class _CloudflarePlatform extends import_io3.AbstractPlatform {
|
|
@@ -370,7 +374,7 @@ var CloudflarePlatform = class _CloudflarePlatform extends import_io3.AbstractPl
|
|
|
370
374
|
}
|
|
371
375
|
getSerializedState(webSocket) {
|
|
372
376
|
var _a;
|
|
373
|
-
const deserialized = webSocket.
|
|
377
|
+
const deserialized = webSocket.deserializeAttachment();
|
|
374
378
|
return (_a = deserialized == null ? void 0 : deserialized.state) != null ? _a : null;
|
|
375
379
|
}
|
|
376
380
|
getSessionId(webSocket) {
|
package/dist/index.mjs
CHANGED
|
@@ -183,6 +183,10 @@ var CloudflareWebSocket = class extends AbstractWebSocket {
|
|
|
183
183
|
if (!state) throw new Error("Could not get websocket state");
|
|
184
184
|
return state;
|
|
185
185
|
}
|
|
186
|
+
set state(state) {
|
|
187
|
+
const deserialized = this.webSocket.deserializeAttachment();
|
|
188
|
+
this.webSocket.serializeAttachment(__spreadProps(__spreadValues({}, deserialized), { state }));
|
|
189
|
+
}
|
|
186
190
|
constructor(webSocket, config) {
|
|
187
191
|
const { room } = config;
|
|
188
192
|
super(webSocket, config);
|
|
@@ -309,7 +313,7 @@ var PersistanceCloudflare = class extends AbstractPersistance {
|
|
|
309
313
|
};
|
|
310
314
|
|
|
311
315
|
// src/constants.ts
|
|
312
|
-
var DEFAULT_REGISTRATION_MODE = "
|
|
316
|
+
var DEFAULT_REGISTRATION_MODE = "detached";
|
|
313
317
|
|
|
314
318
|
// src/CloudflarePlatform.ts
|
|
315
319
|
var CloudflarePlatform = class _CloudflarePlatform extends AbstractPlatform {
|
|
@@ -346,7 +350,7 @@ var CloudflarePlatform = class _CloudflarePlatform extends AbstractPlatform {
|
|
|
346
350
|
}
|
|
347
351
|
getSerializedState(webSocket) {
|
|
348
352
|
var _a;
|
|
349
|
-
const deserialized = webSocket.
|
|
353
|
+
const deserialized = webSocket.deserializeAttachment();
|
|
350
354
|
return (_a = deserialized == null ? void 0 : deserialized.state) != null ? _a : null;
|
|
351
355
|
}
|
|
352
356
|
getSessionId(webSocket) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/platform-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "@pluv/io adapter for cloudflare workers",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"path-to-regexp": "^7.1.0",
|
|
21
|
-
"@pluv/io": "^0.
|
|
22
|
-
"@pluv/types": "^0.
|
|
21
|
+
"@pluv/io": "^0.23.0",
|
|
22
|
+
"@pluv/types": "^0.23.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@cloudflare/workers-types": "^4.
|
|
25
|
+
"@cloudflare/workers-types": "^4.20240815.0",
|
|
26
26
|
"eslint": "^8.57.0",
|
|
27
27
|
"tsup": "^8.2.4",
|
|
28
28
|
"typescript": "^5.5.4",
|
|
29
|
-
"@pluv/tsconfig": "^0.
|
|
30
|
-
"eslint-config-pluv": "^0.
|
|
29
|
+
"@pluv/tsconfig": "^0.23.0",
|
|
30
|
+
"eslint-config-pluv": "^0.23.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
@@ -68,8 +68,8 @@ export class CloudflarePlatform<TEnv extends Record<string, any> = {}> extends A
|
|
|
68
68
|
return timestamp?.getTime() ?? null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
public getSerializedState(webSocket:
|
|
72
|
-
const deserialized = webSocket.
|
|
71
|
+
public getSerializedState(webSocket: WebSocket): WebSocketSerializedState | null {
|
|
72
|
+
const deserialized = webSocket.deserializeAttachment();
|
|
73
73
|
|
|
74
74
|
return deserialized?.state ?? null;
|
|
75
75
|
}
|
|
@@ -46,6 +46,12 @@ export class CloudflareWebSocket extends AbstractWebSocket<WebSocket> {
|
|
|
46
46
|
return state;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
public set state(state: WebSocketSerializedState) {
|
|
50
|
+
const deserialized = this.webSocket.deserializeAttachment();
|
|
51
|
+
|
|
52
|
+
this.webSocket.serializeAttachment({ ...deserialized, state });
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
constructor(webSocket: WebSocket, config: CloudflareWebSocketConfig) {
|
|
50
56
|
const { room } = config;
|
|
51
57
|
|
package/src/constants.ts
CHANGED
package/src/createPluvHandler.ts
CHANGED
|
@@ -70,7 +70,6 @@ export const createPluvHandler = <TPluvServer extends PluvServer<CloudflarePlatf
|
|
|
70
70
|
if (io._registrationMode !== "detached") return;
|
|
71
71
|
|
|
72
72
|
const handler = this._room.onError(ws);
|
|
73
|
-
|
|
74
73
|
const eventError = error instanceof Error ? error : new Error("Internal Error");
|
|
75
74
|
|
|
76
75
|
handler({ error: eventError, message: eventError.message });
|
|
@@ -92,7 +91,6 @@ export const createPluvHandler = <TPluvServer extends PluvServer<CloudflarePlatf
|
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
const { 0: client, 1: server } = new WebSocketPair();
|
|
95
|
-
|
|
96
94
|
const token = new URL(request.url).searchParams.get("token");
|
|
97
95
|
|
|
98
96
|
await this._room.register(server, { token });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CloudflarePlatformConfig } from "./CloudflarePlatform";
|
|
2
2
|
import { CloudflarePlatform } from "./CloudflarePlatform";
|
|
3
3
|
|
|
4
|
-
export const platformCloudflare = <TEnv extends Record<string, any> = {}>(
|
|
4
|
+
export const platformCloudflare = <TEnv extends Record<string, any> = {}>(
|
|
5
|
+
config: CloudflarePlatformConfig<TEnv> = {},
|
|
6
|
+
): CloudflarePlatform<TEnv> => {
|
|
5
7
|
return new CloudflarePlatform<TEnv>(config);
|
|
6
8
|
};
|