orez-lite 0.11.0 → 0.11.1
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.
|
@@ -18,7 +18,7 @@ export type RealtimeSocketHost = {
|
|
|
18
18
|
identity: RealtimeIdentity;
|
|
19
19
|
connectionID: string;
|
|
20
20
|
topics: readonly RealtimeTopic[];
|
|
21
|
-
}[]): Promise<
|
|
21
|
+
}[]): Promise<readonly HostConnection[]>;
|
|
22
22
|
flush(): void;
|
|
23
23
|
};
|
|
24
24
|
export declare function createSocketHost(options: HubOptions): RealtimeSocketHost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-host.d.ts","sourceRoot":"","sources":["../../src/realtime/socket-host.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGtC,OAAO,KAAK,EAA8B,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAOD,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,KAAK,IAAI,IAAI,CAAA;IACb,MAAM,IAAI,SAAS,aAAa,EAAE,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IAIzB,gBAAgB,CACd,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,MAAM,GACnB,cAAc,CAAA;IAIjB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"socket-host.d.ts","sourceRoot":"","sources":["../../src/realtime/socket-host.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGtC,OAAO,KAAK,EAA8B,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAOD,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,KAAK,IAAI,IAAI,CAAA;IACb,MAAM,IAAI,SAAS,aAAa,EAAE,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IAIzB,gBAAgB,CACd,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,MAAM,GACnB,cAAc,CAAA;IAIjB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CAAA;IAkBtE,SAAS,CACP,OAAO,EAAE,SAAS;QAChB,MAAM,EAAE,UAAU,CAAA;QAClB,QAAQ,EAAE,gBAAgB,CAAA;QAC1B,YAAY,EAAE,MAAM,CAAA;QACpB,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;KACjC,EAAE,GACF,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAAA;IACrC,KAAK,IAAI,IAAI,CAAA;CACd,CAAA;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,CA+FxE"}
|
|
@@ -15,6 +15,9 @@ import { RealtimeHub } from './hub.js';
|
|
|
15
15
|
import { decodeFrame, encodeFrame } from './protocol.js';
|
|
16
16
|
export function createSocketHost(options) {
|
|
17
17
|
const hub = new RealtimeHub(options);
|
|
18
|
+
// One subscriber, whether it is being accepted for the first time or rebuilt
|
|
19
|
+
// after an eviction. Both paths need the same tracking, so neither gets its
|
|
20
|
+
// own copy of it.
|
|
18
21
|
const subscriber = (socket, identity, connectionID) => {
|
|
19
22
|
// keyed for dedup, valued with the structured topic so `topics()` can hand
|
|
20
23
|
// back something `rehydrate` accepts without a second parser
|
|
@@ -26,34 +29,32 @@ export function createSocketHost(options) {
|
|
|
26
29
|
socket.send(encodeFrame(frame));
|
|
27
30
|
},
|
|
28
31
|
};
|
|
29
|
-
|
|
32
|
+
const host = {
|
|
33
|
+
handleMessage(raw) {
|
|
34
|
+
const frame = decodeFrame(raw);
|
|
35
|
+
if (!frame)
|
|
36
|
+
return;
|
|
37
|
+
// A subscriber channel is never a publish channel, whatever arrives on
|
|
38
|
+
// it. Producer frames are not merely ignored by the hub here; they are
|
|
39
|
+
// refused before reaching it.
|
|
40
|
+
if (frame[0] !== 'subscribe' && frame[0] !== 'unsubscribe')
|
|
41
|
+
return;
|
|
42
|
+
if (frame[0] === 'subscribe')
|
|
43
|
+
owned.set(topicKey(frame[1].topic), frame[1].topic);
|
|
44
|
+
else
|
|
45
|
+
owned.delete(topicKey(frame[1].topic));
|
|
46
|
+
void applyClientFrame(hub, connection, frame);
|
|
47
|
+
},
|
|
48
|
+
close() {
|
|
49
|
+
hub.dropConnection(connectionID);
|
|
50
|
+
},
|
|
51
|
+
topics: () => [...owned.values()],
|
|
52
|
+
};
|
|
53
|
+
return { connection, owned, host };
|
|
30
54
|
};
|
|
31
55
|
return {
|
|
32
56
|
hub,
|
|
33
|
-
acceptSubscriber(socket, identity, connectionID)
|
|
34
|
-
const { connection, owned } = subscriber(socket, identity, connectionID);
|
|
35
|
-
return {
|
|
36
|
-
handleMessage(raw) {
|
|
37
|
-
const frame = decodeFrame(raw);
|
|
38
|
-
if (!frame)
|
|
39
|
-
return;
|
|
40
|
-
// A subscriber channel is never a publish channel, whatever arrives
|
|
41
|
-
// on it. Producer frames are not merely ignored by the hub here; they
|
|
42
|
-
// are refused before reaching it.
|
|
43
|
-
if (frame[0] !== 'subscribe' && frame[0] !== 'unsubscribe')
|
|
44
|
-
return;
|
|
45
|
-
if (frame[0] === 'subscribe')
|
|
46
|
-
owned.set(topicKey(frame[1].topic), frame[1].topic);
|
|
47
|
-
else
|
|
48
|
-
owned.delete(topicKey(frame[1].topic));
|
|
49
|
-
void applyClientFrame(hub, connection, frame);
|
|
50
|
-
},
|
|
51
|
-
close() {
|
|
52
|
-
hub.dropConnection(connectionID);
|
|
53
|
-
},
|
|
54
|
-
topics: () => [...owned.values()],
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
+
acceptSubscriber: (socket, identity, connectionID) => subscriber(socket, identity, connectionID).host,
|
|
57
58
|
acceptProducer(socket, producerID) {
|
|
58
59
|
const producer = {
|
|
59
60
|
id: producerID,
|
|
@@ -77,11 +78,20 @@ export function createSocketHost(options) {
|
|
|
77
78
|
};
|
|
78
79
|
},
|
|
79
80
|
async rehydrate(entries) {
|
|
81
|
+
const restored = [];
|
|
80
82
|
for (const entry of entries) {
|
|
81
|
-
const { connection } = subscriber(entry.socket, entry.identity, entry.connectionID);
|
|
82
|
-
for (const topic of entry.topics)
|
|
83
|
+
const { connection, owned, host } = subscriber(entry.socket, entry.identity, entry.connectionID);
|
|
84
|
+
for (const topic of entry.topics) {
|
|
85
|
+
// recorded before the result, exactly as a live subscribe frame does:
|
|
86
|
+
// a topic denied during the gap stays the client's asserted interest,
|
|
87
|
+
// so a membership that comes back is picked up at the next eviction
|
|
88
|
+
// instead of being forgotten here.
|
|
89
|
+
owned.set(topicKey(topic), topic);
|
|
83
90
|
await hub.subscribe(connection, topic);
|
|
91
|
+
}
|
|
92
|
+
restored.push(host);
|
|
84
93
|
}
|
|
94
|
+
return restored;
|
|
85
95
|
},
|
|
86
96
|
flush: () => hub.flush(),
|
|
87
97
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-host.js","sourceRoot":"","sources":["../../src/realtime/socket-host.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,iCAAiC;AACjC,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,wCAAwC;AAExC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"socket-host.js","sourceRoot":"","sources":["../../src/realtime/socket-host.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,iCAAiC;AACjC,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,wCAAwC;AAExC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AA8DxD,MAAM,UAAU,gBAAgB,CAAC,OAAmB;IAClD,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;IAEpC,6EAA6E;IAC7E,4EAA4E;IAC5E,kBAAkB;IAClB,MAAM,UAAU,GAAG,CACjB,MAAkB,EAClB,QAA0B,EAC1B,YAAoB,EAKpB,EAAE;QACF,2EAA2E;QAC3E,6DAA6D;QAC7D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;QAC9C,MAAM,UAAU,GAAkB;YAChC,EAAE,EAAE,YAAY;YAChB,QAAQ;YACR,IAAI,EAAE,CAAC,KAAK,EAAE,EA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ACD,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE;KACzB,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,4EAA4E;AAC5E,uBAAuB;AACvB,SAAS,QAAQ,CAAC,KAAoB;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orez-lite",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "SQLite and Rust sync engine for Zero applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -90,10 +90,10 @@
|
|
|
90
90
|
"@noble/ciphers": "1.3.0",
|
|
91
91
|
"@noble/curves": "1.9.7",
|
|
92
92
|
"@noble/hashes": "1.8.0",
|
|
93
|
-
"bedrock-sqlite": "0.11.
|
|
93
|
+
"bedrock-sqlite": "0.11.1",
|
|
94
94
|
"esbuild": "^0.25.0",
|
|
95
|
-
"orez-sync-cf-host": "0.11.
|
|
96
|
-
"orez-sync-executor": "0.11.
|
|
95
|
+
"orez-sync-cf-host": "0.11.1",
|
|
96
|
+
"orez-sync-executor": "0.11.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@rocicorp/zero": ">=1.7.0",
|