@super-line/server 0.7.1 → 0.8.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/dist/index.cjs +27 -9
- package/dist/index.js +27 -9
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -17023,20 +17023,29 @@ function createSuperLineServer(contract, opts) {
|
|
|
17023
17023
|
if (inspectorEnabled) emitInspectorEvent({ type: "store.unsubscribe", connId: conn.id, store: frame.n, id: frame.id });
|
|
17024
17024
|
}
|
|
17025
17025
|
for (const [name, store] of Object.entries(storeMap)) {
|
|
17026
|
+
const isSelf = store.clustering === "self";
|
|
17026
17027
|
store.onChange((change) => {
|
|
17028
|
+
const channel = STORE + name + ":" + change.id;
|
|
17029
|
+
if (isSelf) {
|
|
17030
|
+
const set = members.get(channel);
|
|
17031
|
+
if (!set) return;
|
|
17032
|
+
const payload = serializer.encode({ t: "sch", n: name, id: change.id, u: change.update, o: change.origin });
|
|
17033
|
+
for (const conn of set) conn.sendRaw(payload);
|
|
17034
|
+
return;
|
|
17035
|
+
}
|
|
17027
17036
|
if (relaying) return;
|
|
17028
17037
|
void adapter.publish(
|
|
17029
|
-
|
|
17030
|
-
serializer.encode({
|
|
17031
|
-
t: "sch",
|
|
17032
|
-
n: name,
|
|
17033
|
-
id: change.id,
|
|
17034
|
-
u: change.update,
|
|
17035
|
-
o: change.origin,
|
|
17036
|
-
nd: instanceId
|
|
17037
|
-
})
|
|
17038
|
+
channel,
|
|
17039
|
+
serializer.encode({ t: "sch", n: name, id: change.id, u: change.update, o: change.origin, nd: instanceId })
|
|
17038
17040
|
);
|
|
17039
17041
|
});
|
|
17042
|
+
if (isSelf)
|
|
17043
|
+
store.onDelete?.((id) => {
|
|
17044
|
+
const set = members.get(STORE + name + ":" + id);
|
|
17045
|
+
if (!set) return;
|
|
17046
|
+
const payload = serializer.encode({ t: "sdel", n: name, id });
|
|
17047
|
+
for (const conn of set) conn.sendRaw(payload);
|
|
17048
|
+
});
|
|
17040
17049
|
}
|
|
17041
17050
|
function handleStoreRelay(channel, payload) {
|
|
17042
17051
|
const set = members.get(channel);
|
|
@@ -17050,6 +17059,10 @@ function createSuperLineServer(contract, opts) {
|
|
|
17050
17059
|
if (frame.nd === instanceId) return;
|
|
17051
17060
|
const store = storeMap[frame.n];
|
|
17052
17061
|
if (!store || store.clustering !== "relay") return;
|
|
17062
|
+
if (frame.t === "sdel") {
|
|
17063
|
+
void store.delete(frame.id);
|
|
17064
|
+
return;
|
|
17065
|
+
}
|
|
17053
17066
|
relaying = true;
|
|
17054
17067
|
try {
|
|
17055
17068
|
void store.apply({ id: frame.id, update: frame.u, origin: frame.o });
|
|
@@ -17196,6 +17209,11 @@ function createSuperLineServer(contract, opts) {
|
|
|
17196
17209
|
},
|
|
17197
17210
|
async delete(id) {
|
|
17198
17211
|
await store.delete(id);
|
|
17212
|
+
if (store.clustering !== "self")
|
|
17213
|
+
void adapter.publish(
|
|
17214
|
+
STORE + name + ":" + id,
|
|
17215
|
+
serializer.encode({ t: "sdel", n: name, id, nd: instanceId })
|
|
17216
|
+
);
|
|
17199
17217
|
if (inspectorEnabled) emitInspectorEvent({ type: "store.delete", store: name, id });
|
|
17200
17218
|
},
|
|
17201
17219
|
list() {
|
package/dist/index.js
CHANGED
|
@@ -755,20 +755,29 @@ function createSuperLineServer(contract, opts) {
|
|
|
755
755
|
if (inspectorEnabled) emitInspectorEvent({ type: "store.unsubscribe", connId: conn.id, store: frame.n, id: frame.id });
|
|
756
756
|
}
|
|
757
757
|
for (const [name, store] of Object.entries(storeMap)) {
|
|
758
|
+
const isSelf = store.clustering === "self";
|
|
758
759
|
store.onChange((change) => {
|
|
760
|
+
const channel = STORE + name + ":" + change.id;
|
|
761
|
+
if (isSelf) {
|
|
762
|
+
const set = members.get(channel);
|
|
763
|
+
if (!set) return;
|
|
764
|
+
const payload = serializer.encode({ t: "sch", n: name, id: change.id, u: change.update, o: change.origin });
|
|
765
|
+
for (const conn of set) conn.sendRaw(payload);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
759
768
|
if (relaying) return;
|
|
760
769
|
void adapter.publish(
|
|
761
|
-
|
|
762
|
-
serializer.encode({
|
|
763
|
-
t: "sch",
|
|
764
|
-
n: name,
|
|
765
|
-
id: change.id,
|
|
766
|
-
u: change.update,
|
|
767
|
-
o: change.origin,
|
|
768
|
-
nd: instanceId
|
|
769
|
-
})
|
|
770
|
+
channel,
|
|
771
|
+
serializer.encode({ t: "sch", n: name, id: change.id, u: change.update, o: change.origin, nd: instanceId })
|
|
770
772
|
);
|
|
771
773
|
});
|
|
774
|
+
if (isSelf)
|
|
775
|
+
store.onDelete?.((id) => {
|
|
776
|
+
const set = members.get(STORE + name + ":" + id);
|
|
777
|
+
if (!set) return;
|
|
778
|
+
const payload = serializer.encode({ t: "sdel", n: name, id });
|
|
779
|
+
for (const conn of set) conn.sendRaw(payload);
|
|
780
|
+
});
|
|
772
781
|
}
|
|
773
782
|
function handleStoreRelay(channel, payload) {
|
|
774
783
|
const set = members.get(channel);
|
|
@@ -782,6 +791,10 @@ function createSuperLineServer(contract, opts) {
|
|
|
782
791
|
if (frame.nd === instanceId) return;
|
|
783
792
|
const store = storeMap[frame.n];
|
|
784
793
|
if (!store || store.clustering !== "relay") return;
|
|
794
|
+
if (frame.t === "sdel") {
|
|
795
|
+
void store.delete(frame.id);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
785
798
|
relaying = true;
|
|
786
799
|
try {
|
|
787
800
|
void store.apply({ id: frame.id, update: frame.u, origin: frame.o });
|
|
@@ -928,6 +941,11 @@ function createSuperLineServer(contract, opts) {
|
|
|
928
941
|
},
|
|
929
942
|
async delete(id) {
|
|
930
943
|
await store.delete(id);
|
|
944
|
+
if (store.clustering !== "self")
|
|
945
|
+
void adapter.publish(
|
|
946
|
+
STORE + name + ":" + id,
|
|
947
|
+
serializer.encode({ t: "sdel", n: name, id, nd: instanceId })
|
|
948
|
+
);
|
|
931
949
|
if (inspectorEnabled) emitInspectorEvent({ type: "store.delete", store: name, id });
|
|
932
950
|
},
|
|
933
951
|
list() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-line/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Typesafe WebSocket server for super-line — rooms, topics, middleware, pluggable adapters.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@super-line/core": "^0.
|
|
50
|
+
"@super-line/core": "^0.8.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"zod": "^3.24.1",
|
|
70
70
|
"zod-to-json-schema": "^3.25.2",
|
|
71
71
|
"@super-line/adapter-libp2p": "0.5.0",
|
|
72
|
+
"@super-line/client": "0.7.0",
|
|
72
73
|
"@super-line/adapter-redis": "0.5.0",
|
|
73
74
|
"@super-line/adapter-rabbitmq": "0.5.0",
|
|
74
|
-
"@super-line/transport-websocket": "0.5.0",
|
|
75
|
-
"@super-line/transport-loopback": "0.5.0",
|
|
76
|
-
"@super-line/client": "0.6.0",
|
|
77
75
|
"@super-line/transport-http": "0.5.0",
|
|
78
|
-
"@super-line/adapter-zeromq": "0.5.0"
|
|
76
|
+
"@super-line/adapter-zeromq": "0.5.0",
|
|
77
|
+
"@super-line/transport-websocket": "0.5.0",
|
|
78
|
+
"@super-line/transport-loopback": "0.5.0"
|
|
79
79
|
},
|
|
80
80
|
"optionalDependencies": {
|
|
81
81
|
"@standard-community/standard-json": "^0.3.5"
|