@gravito/ripple 3.0.1 → 3.1.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/README.md +179 -6
- package/README.zh-TW.md +104 -2
- package/dist/core/src/Application.d.ts +43 -17
- package/dist/core/src/Container.d.ts +37 -3
- package/dist/core/src/HookManager.d.ts +6 -4
- package/dist/core/src/PlanetCore.d.ts +52 -7
- package/dist/core/src/Router.d.ts +40 -2
- package/dist/core/src/ServiceProvider.d.ts +14 -8
- package/dist/core/src/adapters/types.d.ts +12 -0
- package/dist/core/src/engine/Gravito.d.ts +1 -1
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/index.d.ts +1 -0
- package/dist/index.js +531 -64
- package/dist/index.js.map +16 -10
- package/dist/photon/src/index.d.ts +55 -5
- package/dist/photon/src/middleware/binary.d.ts +12 -15
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/ripple/src/OrbitRipple.d.ts +34 -12
- package/dist/ripple/src/RippleServer.d.ts +418 -25
- package/dist/ripple/src/channels/ChannelManager.d.ts +107 -12
- package/dist/ripple/src/drivers/LocalDriver.d.ts +43 -11
- package/dist/ripple/src/drivers/RedisDriver.d.ts +106 -28
- package/dist/ripple/src/errors/RippleError.d.ts +48 -0
- package/dist/ripple/src/errors/index.d.ts +1 -0
- package/dist/ripple/src/events/BroadcastEvent.d.ts +78 -6
- package/dist/ripple/src/events/BroadcastManager.d.ts +100 -0
- package/dist/ripple/src/events/Broadcaster.d.ts +211 -14
- package/dist/ripple/src/events/index.d.ts +1 -0
- package/dist/ripple/src/health/HealthChecker.d.ts +93 -0
- package/dist/ripple/src/health/index.d.ts +1 -0
- package/dist/ripple/src/index.d.ts +40 -17
- package/dist/ripple/src/logging/Logger.d.ts +99 -0
- package/dist/ripple/src/logging/index.d.ts +1 -0
- package/dist/ripple/src/tracking/ConnectionTracker.d.ts +116 -0
- package/dist/ripple/src/tracking/index.d.ts +1 -0
- package/dist/ripple/src/types.d.ts +592 -19
- package/dist/ripple/src/utils/MessageSerializer.d.ts +44 -0
- package/dist/ripple/src/utils/index.d.ts +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ServerMessage } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Utility class for serializing server-to-client messages.
|
|
4
|
+
*
|
|
5
|
+
* Provides performance optimizations like pre-serialized common messages
|
|
6
|
+
* and a per-broadcast cache to reduce JSON.stringify overhead during
|
|
7
|
+
* multi-channel broadcasting.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MessageSerializer {
|
|
10
|
+
/** Pre-serialized pong message for heartbeat responses */
|
|
11
|
+
private static readonly PONG_MESSAGE;
|
|
12
|
+
/** Cached serialized string for the current broadcast operation */
|
|
13
|
+
private broadcastCache;
|
|
14
|
+
/**
|
|
15
|
+
* Get the pre-serialized pong message.
|
|
16
|
+
*
|
|
17
|
+
* @returns Serialized {"type":"pong"} string
|
|
18
|
+
*/
|
|
19
|
+
getPongMessage(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Serialize a server message to a JSON string.
|
|
22
|
+
*
|
|
23
|
+
* @param message - The server message object to serialize
|
|
24
|
+
* @returns Serialized JSON string
|
|
25
|
+
*/
|
|
26
|
+
serialize(message: ServerMessage): string;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize a message for broadcasting, with internal caching.
|
|
29
|
+
*
|
|
30
|
+
* If a broadcast cache already exists, it is returned immediately.
|
|
31
|
+
* Otherwise, the message is serialized and stored in the cache.
|
|
32
|
+
*
|
|
33
|
+
* @param message - The server message to serialize and cache
|
|
34
|
+
* @returns Serialized JSON string
|
|
35
|
+
*/
|
|
36
|
+
serializeForBroadcast(message: ServerMessage): string;
|
|
37
|
+
/**
|
|
38
|
+
* Clear the current broadcast cache.
|
|
39
|
+
*
|
|
40
|
+
* Should be called after a broadcast operation is complete to prepare
|
|
41
|
+
* for the next broadcast.
|
|
42
|
+
*/
|
|
43
|
+
clearBroadcastCache(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MessageSerializer } from './MessageSerializer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravito/ripple",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Bun-native WebSocket broadcasting for Gravito. Channel-based real-time communication.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"test": "bun test",
|
|
23
23
|
"typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
|
|
24
24
|
"test:coverage": "bun test --coverage --coverage-threshold=60",
|
|
25
|
-
"test:ci": "bun test --coverage --coverage-threshold=60"
|
|
25
|
+
"test:ci": "bun test --coverage --coverage-threshold=60",
|
|
26
|
+
"bench": "bun run benchmarks/index.ts"
|
|
26
27
|
},
|
|
27
28
|
"keywords": [
|
|
28
29
|
"gravito",
|
|
@@ -52,9 +53,10 @@
|
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"bun-types": "latest",
|
|
54
55
|
"ioredis": "^5.4.2",
|
|
56
|
+
"tinybench": "^6.0.0",
|
|
55
57
|
"typescript": "^5.9.3"
|
|
56
58
|
},
|
|
57
59
|
"publishConfig": {
|
|
58
60
|
"access": "public"
|
|
59
61
|
}
|
|
60
|
-
}
|
|
62
|
+
}
|