@zerotal/broadcasting 1.3.0 → 1.5.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/CHANGELOG.md +32 -1
- package/package.json +3 -3
- package/src/BroadcastingEvent.ts +2 -0
- package/src/ChannelRegistry.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,41 @@ All notable changes to this package are documented here. The format is
|
|
|
4
4
|
based on [Keep a Changelog](https://keepachangelog.com/); this package
|
|
5
5
|
follows the Zerotal monorepo's unified versioning.
|
|
6
6
|
|
|
7
|
-
**Maturity: `
|
|
7
|
+
**Maturity: `stable`**
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [1.5.0] — 2026-08-15
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Tests for `currentSocketId`** — the one function deciding whether a broadcast
|
|
16
|
+
excludes the connection that caused it. Both failure modes present as UI bugs
|
|
17
|
+
rather than broadcasting ones: returning nothing when a header _was_ sent makes
|
|
18
|
+
`toOthers()` exclude nobody, so the user who just made an optimistic update gets
|
|
19
|
+
their own event back and double-applies it; returning something outside a request
|
|
20
|
+
makes a queue job silently exclude an unrelated connection. Case-insensitive
|
|
21
|
+
header matching is pinned too, since Echo sends `X-Socket-ID` and hand-rolled
|
|
22
|
+
clients send it lowercase. 143 tests → 148.
|
|
23
|
+
|
|
24
|
+
- **`PendingBroadcast`, `RedisBroadcastDriver` and `PusherCompatManager` are
|
|
25
|
+
documented.** The driver table now names the class behind each `driver` key, and
|
|
26
|
+
the events guide explains why `broadcast(event)` needs no `.send()` — it returns a
|
|
27
|
+
thenable that dispatches on the next microtask, which is what lets `.toOthers()`
|
|
28
|
+
configure it first.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- **Four exports are marked `@internal`** and leave the compatibility promise:
|
|
33
|
+
`ChannelRegistry`, `channelRegistry`, `compileChannelPattern` and `broadcastOnce`
|
|
34
|
+
— pattern plumbing and process-wide wiring, the last of which says in its own
|
|
35
|
+
docblock that it is "exported for the hook". The promise is 20 exports, not 24.
|
|
36
|
+
|
|
37
|
+
- **Maturity is now `stable`** — the public API follows SemVer strictly for the rest
|
|
38
|
+
of the 1.x line. Every promised export is documented, the package has six guide
|
|
39
|
+
pages and the deepest behavioural coverage of its peer group, and its only
|
|
40
|
+
dependency is `@zerotal/core`.
|
|
41
|
+
|
|
11
42
|
## [1.0.3] — 2026-08-07
|
|
12
43
|
|
|
13
44
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerotal/broadcasting",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"maturity": "
|
|
5
|
+
"maturity": "stable",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zerotal/core": "1.
|
|
32
|
+
"@zerotal/core": "1.5.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^5.8.0"
|
package/src/BroadcastingEvent.ts
CHANGED
|
@@ -8,6 +8,8 @@ const _broadcasted = new WeakSet<object>();
|
|
|
8
8
|
/**
|
|
9
9
|
* Broadcast an event at most once (idempotent across `dispatch()` and the `Events` auto-broadcast
|
|
10
10
|
* hook), gated by `broadcastWhen()` (default true). Used by both paths; exported for the hook.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
11
13
|
*/
|
|
12
14
|
export function broadcastOnce(event: BroadcastEvent): void {
|
|
13
15
|
if (_broadcasted.has(event)) return;
|
package/src/ChannelRegistry.ts
CHANGED
|
@@ -42,7 +42,10 @@ function escapeRegex(s: string): string {
|
|
|
42
42
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/** Compile a `[param]` pattern into a regex + ordered param names.
|
|
45
|
+
/** Compile a `[param]` pattern into a regex + ordered param names.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
46
49
|
export function compileChannelPattern(pattern: string): { regex: RegExp; paramNames: string[] } {
|
|
47
50
|
const paramNames: string[] = [];
|
|
48
51
|
let regexStr = "^";
|
|
@@ -64,6 +67,7 @@ export type AuthorizeResult =
|
|
|
64
67
|
| { matched: false } // no registered pattern claims this channel
|
|
65
68
|
| { matched: true; result: boolean | PresenceMemberData | null | undefined };
|
|
66
69
|
|
|
70
|
+
/** @internal */
|
|
67
71
|
export class ChannelRegistry {
|
|
68
72
|
private _channels: CompiledChannel[] = [];
|
|
69
73
|
|
|
@@ -108,5 +112,8 @@ export class ChannelRegistry {
|
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
|
|
111
|
-
/** Process-wide registry shared by the `Broadcast` facade and `BroadcastProvider`.
|
|
115
|
+
/** Process-wide registry shared by the `Broadcast` facade and `BroadcastProvider`.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
112
119
|
export const channelRegistry = new ChannelRegistry();
|