@dxos/feed 0.8.4-main.cb12b3f963 → 0.8.4-main.d05539e30a

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 CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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) => self.#sendMessage(ctx, withPeerIds({
574
- _tag: "Error",
575
- message: err instanceof Error ? err.message : String(err)
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) => self.#sendMessage(ctx, withPeerIds({
587
- _tag: "Error",
588
- message: err instanceof Error ? err.message : String(err)
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
  }
@@ -599,6 +657,8 @@ import * as Array from "effect/Array";
599
657
  import * as Deferred from "effect/Deferred";
600
658
  import * as Effect3 from "effect/Effect";
601
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";
602
662
  var SyncClient = class {
603
663
  #peerId;
604
664
  #serverPeerId;
@@ -631,13 +691,29 @@ var SyncClient = class {
631
691
  handleMessage(message) {
632
692
  const requestId = "requestId" in message && message.requestId != null ? String(message.requestId) : void 0;
633
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 });
634
698
  return Effect3.void;
635
699
  }
636
700
  const deferred = this.#handlers.get(requestId);
637
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 });
638
707
  return Effect3.void;
639
708
  }
640
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 });
641
717
  if (message._tag === "Error") {
642
718
  return Effect3.andThen(Deferred.fail(deferred, new Error(message.message)), () => Effect3.void);
643
719
  }
@@ -668,6 +744,13 @@ var SyncClient = class {
668
744
  position: lastPulledPosition,
669
745
  limit: opts.limit
670
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 });
671
754
  yield* self.#sendMessage(ctx, self.#withPeerIds(request));
672
755
  const message = yield* Effect3.ensuring(Deferred.await(deferred), Effect3.sync(() => {
673
756
  cleanupDispose();
@@ -675,6 +758,11 @@ var SyncClient = class {
675
758
  }));
676
759
  const response = yield* self.#expectResponse(requestId, message, "QueryResponse");
677
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 });
678
766
  return {
679
767
  done: true
680
768
  };
@@ -690,6 +778,14 @@ var SyncClient = class {
690
778
  feedNamespace: opts.feedNamespace,
691
779
  lastPulledPosition: maxPulledPosition
692
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 });
693
789
  return {
694
790
  done: false
695
791
  };
@@ -705,6 +801,10 @@ var SyncClient = class {
705
801
  limit: opts.limit
706
802
  });
707
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 });
708
808
  return {
709
809
  done: true
710
810
  };
@@ -726,6 +826,12 @@ var SyncClient = class {
726
826
  feedNamespace: opts.feedNamespace,
727
827
  blocks: unpositioned.blocks
728
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 });
729
835
  yield* self.#sendMessage(ctx, self.#withPeerIds(request));
730
836
  const message = yield* Effect3.ensuring(Deferred.await(deferred), Effect3.sync(() => {
731
837
  cleanupDispose();
@@ -742,6 +848,12 @@ var SyncClient = class {
742
848
  position
743
849
  }))
744
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 });
745
857
  return {
746
858
  done: false
747
859
  };
@@ -765,4 +877,4 @@ export {
765
877
  SyncServer,
766
878
  SyncClient
767
879
  };
768
- //# sourceMappingURL=chunk-7BI3SMZT.mjs.map
880
+ //# sourceMappingURL=chunk-YYASRWLE.mjs.map