@aurabase/realtime 0.7.2 → 0.7.4
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 +29 -3
- package/dist/index.js +29 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -536,6 +536,9 @@ var AuraChannel = class {
|
|
|
536
536
|
send(message) {
|
|
537
537
|
return new Promise((resolve) => {
|
|
538
538
|
if (message.payload && Object.prototype.hasOwnProperty.call(message.payload, "event")) {
|
|
539
|
+
console.warn(
|
|
540
|
+
`[aurabase] Warning: Broadcast payload contains reserved key 'event'. Broadcast rejected with status 'invalid_payload'. Use a distinct property like 'action'.`
|
|
541
|
+
);
|
|
539
542
|
resolve("invalid_payload");
|
|
540
543
|
return;
|
|
541
544
|
}
|
|
@@ -654,12 +657,35 @@ var AuraChannel = class {
|
|
|
654
657
|
if (!this._subscribed) break;
|
|
655
658
|
const presMsg = msg;
|
|
656
659
|
if (presMsg.presences) {
|
|
657
|
-
this._presenceState
|
|
660
|
+
const oldState = this._presenceState || {};
|
|
661
|
+
const newState = {};
|
|
658
662
|
for (const p of presMsg.presences) {
|
|
659
663
|
const key = p.user_id || p.client_id;
|
|
660
|
-
if (!
|
|
661
|
-
|
|
664
|
+
if (!newState[key]) newState[key] = [];
|
|
665
|
+
newState[key].push(p);
|
|
666
|
+
}
|
|
667
|
+
for (const key of Object.keys(newState)) {
|
|
668
|
+
const newPres = newState[key];
|
|
669
|
+
const oldPres = oldState[key];
|
|
670
|
+
if (!oldPres) {
|
|
671
|
+
for (const l of this._listeners) {
|
|
672
|
+
if (l.type === "presence" && l.filter.event === "join") {
|
|
673
|
+
l.callback({ key, currentPresences: newPres, newPresences: newPres });
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
for (const key of Object.keys(oldState)) {
|
|
679
|
+
if (!newState[key]) {
|
|
680
|
+
const leftPres = oldState[key];
|
|
681
|
+
for (const l of this._listeners) {
|
|
682
|
+
if (l.type === "presence" && l.filter.event === "leave") {
|
|
683
|
+
l.callback({ key, currentPresences: [], leftPresences: leftPres });
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
662
687
|
}
|
|
688
|
+
this._presenceState = newState;
|
|
663
689
|
for (const l of this._listeners) {
|
|
664
690
|
if (l.type === "presence" && l.filter.event === "sync") {
|
|
665
691
|
l.callback(this._presenceState);
|
package/dist/index.js
CHANGED
|
@@ -534,6 +534,9 @@ var AuraChannel = class {
|
|
|
534
534
|
send(message) {
|
|
535
535
|
return new Promise((resolve) => {
|
|
536
536
|
if (message.payload && Object.prototype.hasOwnProperty.call(message.payload, "event")) {
|
|
537
|
+
console.warn(
|
|
538
|
+
`[aurabase] Warning: Broadcast payload contains reserved key 'event'. Broadcast rejected with status 'invalid_payload'. Use a distinct property like 'action'.`
|
|
539
|
+
);
|
|
537
540
|
resolve("invalid_payload");
|
|
538
541
|
return;
|
|
539
542
|
}
|
|
@@ -652,12 +655,35 @@ var AuraChannel = class {
|
|
|
652
655
|
if (!this._subscribed) break;
|
|
653
656
|
const presMsg = msg;
|
|
654
657
|
if (presMsg.presences) {
|
|
655
|
-
this._presenceState
|
|
658
|
+
const oldState = this._presenceState || {};
|
|
659
|
+
const newState = {};
|
|
656
660
|
for (const p of presMsg.presences) {
|
|
657
661
|
const key = p.user_id || p.client_id;
|
|
658
|
-
if (!
|
|
659
|
-
|
|
662
|
+
if (!newState[key]) newState[key] = [];
|
|
663
|
+
newState[key].push(p);
|
|
664
|
+
}
|
|
665
|
+
for (const key of Object.keys(newState)) {
|
|
666
|
+
const newPres = newState[key];
|
|
667
|
+
const oldPres = oldState[key];
|
|
668
|
+
if (!oldPres) {
|
|
669
|
+
for (const l of this._listeners) {
|
|
670
|
+
if (l.type === "presence" && l.filter.event === "join") {
|
|
671
|
+
l.callback({ key, currentPresences: newPres, newPresences: newPres });
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
for (const key of Object.keys(oldState)) {
|
|
677
|
+
if (!newState[key]) {
|
|
678
|
+
const leftPres = oldState[key];
|
|
679
|
+
for (const l of this._listeners) {
|
|
680
|
+
if (l.type === "presence" && l.filter.event === "leave") {
|
|
681
|
+
l.callback({ key, currentPresences: [], leftPresences: leftPres });
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
660
685
|
}
|
|
686
|
+
this._presenceState = newState;
|
|
661
687
|
for (const l of this._listeners) {
|
|
662
688
|
if (l.type === "presence" && l.filter.event === "sync") {
|
|
663
689
|
l.callback(this._presenceState);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurabase/realtime",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Service temps réel du SDK Aurabase (postgres_changes, broadcast, presence)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"realtime"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@aurabase/core": "0.7.
|
|
48
|
+
"@aurabase/core": "0.7.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "20.14.15",
|