@dxos/feed 0.8.4-main.abd8ff62ef → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/dist/lib/neutral/{chunk-CJV6NY5B.mjs → chunk-YYASRWLE.mjs} +144 -11
- package/dist/lib/neutral/{chunk-CJV6NY5B.mjs.map → chunk-YYASRWLE.mjs.map} +3 -3
- package/dist/lib/neutral/index.mjs +1 -1
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +1 -1
- package/dist/types/src/sync-client.d.ts.map +1 -1
- package/dist/types/src/sync-server.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/sync-client.ts +84 -3
- package/src/sync-server.ts +62 -8
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -541,6 +541,19 @@ var decodeCursor = (cursor) => {
|
|
|
541
541
|
|
|
542
542
|
// src/sync-server.ts
|
|
543
543
|
import * as Effect2 from "effect/Effect";
|
|
544
|
+
import { log } from "@dxos/log";
|
|
545
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/feed/src/sync-server.ts";
|
|
546
|
+
var inboundSummary = (message) => ({
|
|
547
|
+
tag: message._tag,
|
|
548
|
+
senderPeerId: message.senderPeerId,
|
|
549
|
+
recipientPeerId: message.recipientPeerId,
|
|
550
|
+
requestId: "requestId" in message ? message.requestId : void 0,
|
|
551
|
+
spaceId: "spaceId" in message ? message.spaceId : void 0,
|
|
552
|
+
feedNamespace: "feedNamespace" in message ? message.feedNamespace : void 0,
|
|
553
|
+
blockCount: "blocks" in message ? message.blocks.length : void 0,
|
|
554
|
+
position: "position" in message ? message.position : void 0,
|
|
555
|
+
limit: "limit" in message ? message.limit : void 0
|
|
556
|
+
});
|
|
544
557
|
var SyncServer = class {
|
|
545
558
|
#peerId;
|
|
546
559
|
#feedStore;
|
|
@@ -555,6 +568,10 @@ var SyncServer = class {
|
|
|
555
568
|
*/
|
|
556
569
|
handleMessage(ctx, message) {
|
|
557
570
|
const self = this;
|
|
571
|
+
log("feed sync server received message", {
|
|
572
|
+
peerId: self.#peerId,
|
|
573
|
+
...inboundSummary(message)
|
|
574
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 33, S: this });
|
|
558
575
|
const recipientPeerId = message.senderPeerId;
|
|
559
576
|
const withPeerIds = (payload) => ({
|
|
560
577
|
...payload,
|
|
@@ -566,29 +583,70 @@ var SyncServer = class {
|
|
|
566
583
|
const req = message;
|
|
567
584
|
return Effect2.gen(function* () {
|
|
568
585
|
const response = yield* self.#feedStore.query(req);
|
|
586
|
+
log("feed sync server query completed", {
|
|
587
|
+
peerId: self.#peerId,
|
|
588
|
+
recipientPeerId,
|
|
589
|
+
requestId: req.requestId,
|
|
590
|
+
spaceId: req.spaceId,
|
|
591
|
+
feedNamespace: req.feedNamespace,
|
|
592
|
+
returnedBlocks: response.blocks.length,
|
|
593
|
+
hasMore: response.hasMore
|
|
594
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 49, S: this });
|
|
569
595
|
yield* self.#sendMessage(ctx, withPeerIds({
|
|
570
596
|
_tag: "QueryResponse",
|
|
571
597
|
...response
|
|
572
598
|
}));
|
|
573
|
-
}).pipe(Effect2.catchAll((err) =>
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
599
|
+
}).pipe(Effect2.catchAll((err) => {
|
|
600
|
+
log("feed sync server query failed", {
|
|
601
|
+
peerId: self.#peerId,
|
|
602
|
+
recipientPeerId,
|
|
603
|
+
requestId: req.requestId,
|
|
604
|
+
spaceId: req.spaceId,
|
|
605
|
+
feedNamespace: req.feedNamespace,
|
|
606
|
+
cause: err instanceof Error ? err.message : String(err)
|
|
607
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 63, S: this });
|
|
608
|
+
return self.#sendMessage(ctx, withPeerIds({
|
|
609
|
+
_tag: "Error",
|
|
610
|
+
message: err instanceof Error ? err.message : String(err)
|
|
611
|
+
}));
|
|
612
|
+
}));
|
|
577
613
|
}
|
|
578
614
|
case "AppendRequest": {
|
|
579
615
|
const req = message;
|
|
580
616
|
return Effect2.gen(function* () {
|
|
581
617
|
const response = yield* self.#feedStore.append(req);
|
|
618
|
+
log("feed sync server append completed", {
|
|
619
|
+
peerId: self.#peerId,
|
|
620
|
+
recipientPeerId,
|
|
621
|
+
requestId: req.requestId,
|
|
622
|
+
spaceId: req.spaceId,
|
|
623
|
+
feedNamespace: req.feedNamespace,
|
|
624
|
+
assignedPositions: response.positions.length
|
|
625
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 82, S: this });
|
|
582
626
|
yield* self.#sendMessage(ctx, withPeerIds({
|
|
583
627
|
_tag: "AppendResponse",
|
|
584
628
|
...response
|
|
585
629
|
}));
|
|
586
|
-
}).pipe(Effect2.catchAll((err) =>
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
630
|
+
}).pipe(Effect2.catchAll((err) => {
|
|
631
|
+
log("feed sync server append failed", {
|
|
632
|
+
peerId: self.#peerId,
|
|
633
|
+
recipientPeerId,
|
|
634
|
+
requestId: req.requestId,
|
|
635
|
+
spaceId: req.spaceId,
|
|
636
|
+
feedNamespace: req.feedNamespace,
|
|
637
|
+
cause: err instanceof Error ? err.message : String(err)
|
|
638
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 95, S: this });
|
|
639
|
+
return self.#sendMessage(ctx, withPeerIds({
|
|
640
|
+
_tag: "Error",
|
|
641
|
+
message: err instanceof Error ? err.message : String(err)
|
|
642
|
+
}));
|
|
643
|
+
}));
|
|
590
644
|
}
|
|
591
645
|
default:
|
|
646
|
+
log("feed sync server ignoring unsupported message", {
|
|
647
|
+
peerId: self.#peerId,
|
|
648
|
+
tag: message._tag
|
|
649
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 110, S: this });
|
|
592
650
|
return Effect2.void;
|
|
593
651
|
}
|
|
594
652
|
}
|
|
@@ -598,6 +656,9 @@ var SyncServer = class {
|
|
|
598
656
|
import * as Array from "effect/Array";
|
|
599
657
|
import * as Deferred from "effect/Deferred";
|
|
600
658
|
import * as Effect3 from "effect/Effect";
|
|
659
|
+
import { ContextDisposedError } from "@dxos/context";
|
|
660
|
+
import { log as log2 } from "@dxos/log";
|
|
661
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/feed/src/sync-client.ts";
|
|
601
662
|
var SyncClient = class {
|
|
602
663
|
#peerId;
|
|
603
664
|
#serverPeerId;
|
|
@@ -630,13 +691,29 @@ var SyncClient = class {
|
|
|
630
691
|
handleMessage(message) {
|
|
631
692
|
const requestId = "requestId" in message && message.requestId != null ? String(message.requestId) : void 0;
|
|
632
693
|
if (requestId == null) {
|
|
694
|
+
log2.trace("feed sync client response ignored (no request id)", {
|
|
695
|
+
tag: message._tag,
|
|
696
|
+
senderPeerId: message.senderPeerId
|
|
697
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 45, S: this });
|
|
633
698
|
return Effect3.void;
|
|
634
699
|
}
|
|
635
700
|
const deferred = this.#handlers.get(requestId);
|
|
636
701
|
if (deferred == null) {
|
|
702
|
+
log2.trace("feed sync client response ignored (no pending rpc)", {
|
|
703
|
+
requestId,
|
|
704
|
+
tag: message._tag,
|
|
705
|
+
senderPeerId: message.senderPeerId
|
|
706
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 53, S: this });
|
|
637
707
|
return Effect3.void;
|
|
638
708
|
}
|
|
639
709
|
this.#handlers.delete(requestId);
|
|
710
|
+
log2("feed sync client rpc completed", {
|
|
711
|
+
requestId,
|
|
712
|
+
tag: message._tag,
|
|
713
|
+
blockCount: "blocks" in message ? message.blocks.length : void 0,
|
|
714
|
+
positionCount: "positions" in message ? message.positions.length : void 0,
|
|
715
|
+
error: message._tag === "Error" ? message.message : void 0
|
|
716
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 61, S: this });
|
|
640
717
|
if (message._tag === "Error") {
|
|
641
718
|
return Effect3.andThen(Deferred.fail(deferred, new Error(message.message)), () => Effect3.void);
|
|
642
719
|
}
|
|
@@ -652,6 +729,13 @@ var SyncClient = class {
|
|
|
652
729
|
const requestId = crypto.randomUUID();
|
|
653
730
|
const deferred = yield* Deferred.make();
|
|
654
731
|
self.#handlers.set(requestId, deferred);
|
|
732
|
+
const cleanupDispose = ctx.disposed ? () => {
|
|
733
|
+
} : ctx.onDispose(() => {
|
|
734
|
+
Effect3.runFork(Deferred.fail(deferred, new ContextDisposedError()));
|
|
735
|
+
});
|
|
736
|
+
if (ctx.disposed) {
|
|
737
|
+
yield* Deferred.fail(deferred, new ContextDisposedError());
|
|
738
|
+
}
|
|
655
739
|
const request = {
|
|
656
740
|
_tag: "QueryRequest",
|
|
657
741
|
requestId,
|
|
@@ -660,10 +744,25 @@ var SyncClient = class {
|
|
|
660
744
|
position: lastPulledPosition,
|
|
661
745
|
limit: opts.limit
|
|
662
746
|
};
|
|
747
|
+
log2("feed sync client pull rpc sending", {
|
|
748
|
+
requestId,
|
|
749
|
+
spaceId: opts.spaceId,
|
|
750
|
+
feedNamespace: opts.feedNamespace,
|
|
751
|
+
afterPosition: lastPulledPosition,
|
|
752
|
+
limit: opts.limit
|
|
753
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
663
754
|
yield* self.#sendMessage(ctx, self.#withPeerIds(request));
|
|
664
|
-
const message = yield* Deferred.await(deferred)
|
|
755
|
+
const message = yield* Effect3.ensuring(Deferred.await(deferred), Effect3.sync(() => {
|
|
756
|
+
cleanupDispose();
|
|
757
|
+
self.#handlers.delete(requestId);
|
|
758
|
+
}));
|
|
665
759
|
const response = yield* self.#expectResponse(requestId, message, "QueryResponse");
|
|
666
760
|
if (response.blocks.length === 0) {
|
|
761
|
+
log2.trace("feed sync client pull done (empty batch)", {
|
|
762
|
+
requestId,
|
|
763
|
+
spaceId: opts.spaceId,
|
|
764
|
+
feedNamespace: opts.feedNamespace
|
|
765
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 111, S: this });
|
|
667
766
|
return {
|
|
668
767
|
done: true
|
|
669
768
|
};
|
|
@@ -679,6 +778,14 @@ var SyncClient = class {
|
|
|
679
778
|
feedNamespace: opts.feedNamespace,
|
|
680
779
|
lastPulledPosition: maxPulledPosition
|
|
681
780
|
});
|
|
781
|
+
log2("feed sync client pull applied batch", {
|
|
782
|
+
requestId,
|
|
783
|
+
spaceId: opts.spaceId,
|
|
784
|
+
feedNamespace: opts.feedNamespace,
|
|
785
|
+
batchSize: response.blocks.length,
|
|
786
|
+
hasMore: response.hasMore,
|
|
787
|
+
maxPulledPosition
|
|
788
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 132, S: this });
|
|
682
789
|
return {
|
|
683
790
|
done: false
|
|
684
791
|
};
|
|
@@ -694,6 +801,10 @@ var SyncClient = class {
|
|
|
694
801
|
limit: opts.limit
|
|
695
802
|
});
|
|
696
803
|
if (unpositioned.blocks.length === 0) {
|
|
804
|
+
log2.trace("feed sync client push skipped (nothing to send)", {
|
|
805
|
+
spaceId: opts.spaceId,
|
|
806
|
+
feedNamespace: opts.feedNamespace
|
|
807
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 155, S: this });
|
|
697
808
|
return {
|
|
698
809
|
done: true
|
|
699
810
|
};
|
|
@@ -701,6 +812,13 @@ var SyncClient = class {
|
|
|
701
812
|
const requestId = crypto.randomUUID();
|
|
702
813
|
const deferred = yield* Deferred.make();
|
|
703
814
|
self.#handlers.set(requestId, deferred);
|
|
815
|
+
const cleanupDispose = ctx.disposed ? () => {
|
|
816
|
+
} : ctx.onDispose(() => {
|
|
817
|
+
Effect3.runFork(Deferred.fail(deferred, new ContextDisposedError()));
|
|
818
|
+
});
|
|
819
|
+
if (ctx.disposed) {
|
|
820
|
+
yield* Deferred.fail(deferred, new ContextDisposedError());
|
|
821
|
+
}
|
|
704
822
|
const request = {
|
|
705
823
|
_tag: "AppendRequest",
|
|
706
824
|
requestId,
|
|
@@ -708,8 +826,17 @@ var SyncClient = class {
|
|
|
708
826
|
feedNamespace: opts.feedNamespace,
|
|
709
827
|
blocks: unpositioned.blocks
|
|
710
828
|
};
|
|
829
|
+
log2("feed sync client push rpc sending", {
|
|
830
|
+
requestId,
|
|
831
|
+
spaceId: opts.spaceId,
|
|
832
|
+
feedNamespace: opts.feedNamespace,
|
|
833
|
+
blockCount: unpositioned.blocks.length
|
|
834
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 179, S: this });
|
|
711
835
|
yield* self.#sendMessage(ctx, self.#withPeerIds(request));
|
|
712
|
-
const message = yield* Deferred.await(deferred)
|
|
836
|
+
const message = yield* Effect3.ensuring(Deferred.await(deferred), Effect3.sync(() => {
|
|
837
|
+
cleanupDispose();
|
|
838
|
+
self.#handlers.delete(requestId);
|
|
839
|
+
}));
|
|
713
840
|
const response = yield* self.#expectResponse(requestId, message, "AppendResponse");
|
|
714
841
|
yield* self.#feedStore.setPosition({
|
|
715
842
|
spaceId: opts.spaceId,
|
|
@@ -721,6 +848,12 @@ var SyncClient = class {
|
|
|
721
848
|
position
|
|
722
849
|
}))
|
|
723
850
|
});
|
|
851
|
+
log2("feed sync client push positions applied", {
|
|
852
|
+
requestId,
|
|
853
|
+
spaceId: opts.spaceId,
|
|
854
|
+
feedNamespace: opts.feedNamespace,
|
|
855
|
+
positionCount: response.positions.length
|
|
856
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 201, S: this });
|
|
724
857
|
return {
|
|
725
858
|
done: false
|
|
726
859
|
};
|
|
@@ -744,4 +877,4 @@ export {
|
|
|
744
877
|
SyncServer,
|
|
745
878
|
SyncClient
|
|
746
879
|
};
|
|
747
|
-
//# sourceMappingURL=chunk-
|
|
880
|
+
//# sourceMappingURL=chunk-YYASRWLE.mjs.map
|