@powerhousedao/connect 1.0.5-dev.0 → 1.0.6-dev.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.
Files changed (23) hide show
  1. package/dist/assets/{app-D5aQi0aY.js → app-DzySetAh.js} +69 -69
  2. package/dist/assets/{app-loader-D5SWSIlq.js → app-loader-CZ0aVaYP.js} +167 -117
  3. package/dist/assets/{ccip-BmvACOxw.js → ccip-D8BqOMUI.js} +3 -3
  4. package/dist/assets/{content-CjM3gin6.js → content-BNXKwoH4.js} +3 -3
  5. package/dist/assets/{index-D60iiT4f.js → index-CHXlqTiX.js} +4 -4
  6. package/dist/assets/{index-DIYv2p_P.js → index-CWckxksG.js} +3 -3
  7. package/dist/assets/{index-d_545vU_.js → index-qnOU-Q3F.js} +3 -3
  8. package/dist/assets/{main.DnroXr_4.js → main.BQPIoivi.js} +1 -1
  9. package/dist/index.html +1 -1
  10. package/dist/modules/@powerhousedao/reactor-browser/{chunk-YSOX63EM.js → chunk-3C54663M.js} +1 -1
  11. package/dist/modules/@powerhousedao/reactor-browser/{chunk-ZWFCVUBU.js → chunk-5QJXNK35.js} +1 -1
  12. package/dist/modules/@powerhousedao/reactor-browser/{chunk-F6NNSREE.js → chunk-ISDEPHKP.js} +1 -1
  13. package/dist/modules/@powerhousedao/reactor-browser/{chunk-64UP3MVE.js → chunk-SQ5HIKYV.js} +154 -100
  14. package/dist/modules/@powerhousedao/reactor-browser/{chunk-UWJGRLW3.js → chunk-XV42KZK3.js} +1 -1
  15. package/dist/modules/@powerhousedao/reactor-browser/context/index.js +2 -2
  16. package/dist/modules/@powerhousedao/reactor-browser/context/read-mode.js +2 -2
  17. package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +3 -3
  18. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActions.js +2 -2
  19. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes.js +3 -3
  20. package/dist/modules/@powerhousedao/reactor-browser/index.js +5 -5
  21. package/dist/modules/@powerhousedao/reactor-browser/reactor.js +2 -2
  22. package/dist/vite-envs.sh +1 -1
  23. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-D5aQi0aY.js","assets/main.DnroXr_4.js","assets/app-CcH3qGge.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-DzySetAh.js","assets/main.BQPIoivi.js","assets/app-CcH3qGge.css"])))=>i.map(i=>d[i]);
2
2
  var __defProp = Object.defineProperty;
3
3
  var __typeError = (msg) => {
4
4
  throw TypeError(msg);
@@ -11,7 +11,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11
11
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
12
12
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
13
13
  var _tags, _levelString, _errorHandler, _ConsoleLogger_instances, levelValue_get, _getDocumentModelModule, _drives, _ReadModeService_instances, parseGraphQLErrors_fn, fetchDrive_fn, _a, _ServiceWorkerManager_instances, handleServiceWorkerMessage_fn, handleServiceWorker_fn;
14
- import { _ as __vitePreload } from "./main.DnroXr_4.js";
14
+ import { _ as __vitePreload } from "./main.BQPIoivi.js";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
16
  import { useState, useEffect, Suspense, lazy } from "react";
17
17
  function _mergeNamespaces(n, m) {
@@ -22517,7 +22517,14 @@ class DefaultDrivesManager {
22517
22517
  }
22518
22518
  const PULL_DRIVE_INTERVAL = 1500;
22519
22519
  const MAX_REVISIONS_PER_ACK = 100;
22520
- const _PullResponderTransmitter = class _PullResponderTransmitter {
22520
+ let _staticLogger;
22521
+ const staticLogger = () => {
22522
+ if (!_staticLogger) {
22523
+ _staticLogger = childLogger(["PullResponderTransmitter", "static"]);
22524
+ }
22525
+ return _staticLogger;
22526
+ };
22527
+ class PullResponderTransmitter {
22521
22528
  constructor(listener, manager) {
22522
22529
  __publicField(this, "logger", childLogger([
22523
22530
  "PullResponderTransmitter",
@@ -22561,16 +22568,22 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22561
22568
  }
22562
22569
  return success;
22563
22570
  }
22564
- static async registerPullResponder(driveId, url, filter) {
22571
+ static async registerPullResponder(driveId, url, filter, listenerId) {
22565
22572
  var _a2;
22566
- _PullResponderTransmitter.staticLogger.verbose(`registerPullResponder(url: ${url})`, filter);
22573
+ staticLogger().verbose(`registerPullResponder(url: ${url})`, filter);
22567
22574
  const result = await requestGraphql(url, gql`
22568
- mutation registerPullResponderListener($filter: InputListenerFilter!) {
22569
- registerPullResponderListener(filter: $filter) {
22575
+ mutation registerPullResponderListener(
22576
+ $filter: InputListenerFilter!
22577
+ $listenerId: String
22578
+ ) {
22579
+ registerPullResponderListener(
22580
+ filter: $filter
22581
+ listenerId: $listenerId
22582
+ ) {
22570
22583
  listenerId
22571
22584
  }
22572
22585
  }
22573
- `, { filter });
22586
+ `, { filter, listenerId });
22574
22587
  const error = (_a2 = result.errors) == null ? void 0 : _a2.at(0);
22575
22588
  if (error) {
22576
22589
  throw error;
@@ -22582,7 +22595,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22582
22595
  }
22583
22596
  static async pullStrands(driveId, url, listenerId, options) {
22584
22597
  var _a2;
22585
- this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${driveId}, url: ${url}, listener: ${listenerId}, options: ${JSON.stringify(options || {})}`);
22598
+ staticLogger().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${driveId}, url: ${url}, listener: ${listenerId}, options: ${JSON.stringify(options || {})}`);
22586
22599
  const result = await requestGraphql(url, gql`
22587
22600
  query strands($listenerId: ID!) {
22588
22601
  system {
@@ -22622,11 +22635,11 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22622
22635
  `, { listenerId });
22623
22636
  const error = (_a2 = result.errors) == null ? void 0 : _a2.at(0);
22624
22637
  if (error) {
22625
- this.staticLogger.verbose(`[SYNC DEBUG] Error pulling strands for drive: ${driveId}, listener: ${listenerId}, error: ${JSON.stringify(error)}`);
22638
+ staticLogger().verbose(`[SYNC DEBUG] Error pulling strands for drive: ${driveId}, listener: ${listenerId}, error: ${JSON.stringify(error)}`);
22626
22639
  throw error;
22627
22640
  }
22628
22641
  if (!result.system) {
22629
- this.staticLogger.verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${driveId}, listener: ${listenerId}`);
22642
+ staticLogger().verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${driveId}, listener: ${listenerId}`);
22630
22643
  return [];
22631
22644
  }
22632
22645
  const strands = result.system.sync.strands.map((s) => ({
@@ -22636,20 +22649,20 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22636
22649
  input: JSON.parse(o.input)
22637
22650
  }))
22638
22651
  }));
22639
- this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${strands.length} strands for drive: ${driveId}, listener: ${listenerId}`);
22652
+ staticLogger().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${strands.length} strands for drive: ${driveId}, listener: ${listenerId}`);
22640
22653
  if (strands.length > 0) {
22641
- this.staticLogger.verbose(`[SYNC DEBUG] Strands being returned: ${strands.map((s) => `${s.documentId}:${s.scope}`).join(", ")}`);
22654
+ staticLogger().verbose(`[SYNC DEBUG] Strands being returned: ${strands.map((s) => `${s.documentId}:${s.scope}`).join(", ")}`);
22642
22655
  }
22643
22656
  return strands;
22644
22657
  }
22645
22658
  static async acknowledgeStrands(url, listenerId, revisions) {
22646
- this.staticLogger.verbose(`acknowledgeStrands(url: ${url}, listener: ${listenerId})`, revisions);
22659
+ staticLogger().verbose(`acknowledgeStrands(url: ${url}, listener: ${listenerId})`, revisions);
22647
22660
  const chunks = [];
22648
22661
  for (let i = 0; i < revisions.length; i += MAX_REVISIONS_PER_ACK) {
22649
22662
  chunks.push(revisions.slice(i, i + MAX_REVISIONS_PER_ACK));
22650
22663
  }
22651
22664
  if (chunks.length > 1) {
22652
- this.staticLogger.verbose(`Breaking strand acknowledgement into ${chunks.length} chunks...`);
22665
+ staticLogger().verbose(`Breaking strand acknowledgement into ${chunks.length} chunks...`);
22653
22666
  }
22654
22667
  const results = await Promise.allSettled(chunks.map(async (chunk) => {
22655
22668
  var _a2;
@@ -22684,27 +22697,27 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22684
22697
  */
22685
22698
  static async executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
22686
22699
  var _a2, _b;
22687
- this.staticLogger.verbose(`executePull(driveId: ${driveId}), trigger:`, trigger);
22688
- this.staticLogger.info(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22700
+ staticLogger().verbose(`executePull(driveId: ${driveId}), trigger:`, trigger);
22701
+ staticLogger().info(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22689
22702
  const { url } = trigger.data;
22690
22703
  let strands;
22691
22704
  let error;
22705
+ const listenerId = trigger.data.listenerId;
22692
22706
  try {
22693
- strands = await _PullResponderTransmitter.pullStrands(driveId, url, trigger.data.listenerId);
22707
+ strands = await PullResponderTransmitter.pullStrands(driveId, url, listenerId);
22694
22708
  } catch (e) {
22695
22709
  error = e;
22696
22710
  const graphqlError = error;
22697
22711
  const errors = ((_a2 = graphqlError.response) == null ? void 0 : _a2.errors) ?? [];
22698
22712
  for (const err of errors) {
22699
22713
  if (err.message === "Listener not found") {
22700
- this.staticLogger.verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${driveId}`);
22701
- const listenerId = await _PullResponderTransmitter.registerPullResponder(trigger.driveId, url, trigger.filter);
22702
- trigger.data.listenerId = listenerId;
22714
+ staticLogger().verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${driveId}`);
22715
+ await PullResponderTransmitter.registerPullResponder(trigger.driveId, url, trigger.filter, listenerId);
22703
22716
  try {
22704
- strands = await _PullResponderTransmitter.pullStrands(driveId, url, listenerId);
22705
- this.staticLogger.verbose(`Successfully auto-registerd and pulled strands for drive: ${driveId}, listenerId: ${listenerId}`);
22717
+ strands = await PullResponderTransmitter.pullStrands(driveId, url, listenerId);
22718
+ staticLogger().verbose(`Successfully auto-registered and pulled strands for drive: ${driveId}, listenerId: ${listenerId}`);
22706
22719
  } catch (error2) {
22707
- this.staticLogger.error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${driveId}, listenerId: ${listenerId}: ${error2}`);
22720
+ staticLogger().error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${driveId}, listenerId: ${listenerId}: ${error2}`);
22708
22721
  onError(error2);
22709
22722
  return;
22710
22723
  }
@@ -22713,21 +22726,21 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22713
22726
  }
22714
22727
  }
22715
22728
  if (!strands) {
22716
- this.staticLogger.error(`Error pulling strands for drive, and could not auto-register: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
22729
+ staticLogger().error(`Error pulling strands for drive, and could not auto-register: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
22717
22730
  onError(error);
22718
22731
  return;
22719
22732
  }
22720
22733
  if (!strands.length) {
22721
- this.staticLogger.verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22734
+ staticLogger().verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22722
22735
  try {
22723
22736
  onRevisions == null ? void 0 : onRevisions([]);
22724
22737
  } catch (error2) {
22725
- this.staticLogger.error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22738
+ staticLogger().error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22726
22739
  onError(error2);
22727
22740
  }
22728
22741
  return;
22729
22742
  }
22730
- this.staticLogger.verbose(`[SYNC DEBUG] Processing ${strands.length} strands in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22743
+ staticLogger().verbose(`[SYNC DEBUG] Processing ${strands.length} strands in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22731
22744
  const listenerRevisions = [];
22732
22745
  for (const strand of strands) {
22733
22746
  const operations = strand.operations.map((op) => ({
@@ -22735,7 +22748,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22735
22748
  scope: strand.scope,
22736
22749
  branch: strand.branch
22737
22750
  }));
22738
- this.staticLogger.verbose(`[SYNC DEBUG] Processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations`);
22751
+ staticLogger().verbose(`[SYNC DEBUG] Processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations`);
22739
22752
  let error2 = void 0;
22740
22753
  try {
22741
22754
  const result = await onStrandUpdate(strand, {
@@ -22746,7 +22759,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22746
22759
  throw result.error;
22747
22760
  }
22748
22761
  } catch (e) {
22749
- this.staticLogger.error(`Error processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations: ${e}`);
22762
+ staticLogger().error(`Error processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations: ${e}`);
22750
22763
  error2 = e;
22751
22764
  onError(error2);
22752
22765
  }
@@ -22760,39 +22773,39 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22760
22773
  error: error2
22761
22774
  });
22762
22775
  }
22763
- this.staticLogger.verbose("Processed strands...");
22776
+ staticLogger().verbose("Processed strands...");
22764
22777
  try {
22765
22778
  onRevisions == null ? void 0 : onRevisions(listenerRevisions);
22766
22779
  } catch (error2) {
22767
- this.staticLogger.error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22780
+ staticLogger().error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22768
22781
  onError(error2);
22769
22782
  }
22770
- this.staticLogger.verbose(`[SYNC DEBUG] Acknowledging ${listenerRevisions.length} strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22783
+ staticLogger().verbose(`[SYNC DEBUG] Acknowledging ${listenerRevisions.length} strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22771
22784
  let success = false;
22772
22785
  try {
22773
- await _PullResponderTransmitter.acknowledgeStrands(url, trigger.data.listenerId, listenerRevisions.map((revision) => {
22786
+ await PullResponderTransmitter.acknowledgeStrands(url, trigger.data.listenerId, listenerRevisions.map((revision) => {
22774
22787
  const { error: error2, ...rest } = revision;
22775
22788
  return rest;
22776
22789
  }));
22777
22790
  success = true;
22778
22791
  } catch (error2) {
22779
- this.staticLogger.error(`Error acknowledging strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22792
+ staticLogger().error(`Error acknowledging strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22780
22793
  onError(error2);
22781
22794
  }
22782
22795
  if (success) {
22783
- this.staticLogger.verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22796
+ staticLogger().verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22784
22797
  } else {
22785
- this.staticLogger.error("Failed to acknowledge strands");
22798
+ staticLogger().error("Failed to acknowledge strands");
22786
22799
  }
22787
22800
  try {
22788
22801
  onAcknowledge == null ? void 0 : onAcknowledge(success);
22789
22802
  } catch (error2) {
22790
- this.staticLogger.error(`Error calling onAcknowledge for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22803
+ staticLogger().error(`Error calling onAcknowledge for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
22791
22804
  onError(error2);
22792
22805
  }
22793
22806
  }
22794
22807
  static setupPull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
22795
- this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22808
+ staticLogger().verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22796
22809
  const { interval } = trigger.data;
22797
22810
  let loopInterval = PULL_DRIVE_INTERVAL;
22798
22811
  if (interval) {
@@ -22804,25 +22817,25 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22804
22817
  } catch {
22805
22818
  }
22806
22819
  }
22807
- this.staticLogger.verbose(`[SYNC DEBUG] Pull interval set to ${loopInterval}ms for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22820
+ staticLogger().verbose(`[SYNC DEBUG] Pull interval set to ${loopInterval}ms for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22808
22821
  let isCancelled = false;
22809
22822
  let timeout;
22810
22823
  const executeLoop = async () => {
22811
22824
  while (!isCancelled) {
22812
- this.staticLogger.verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22825
+ staticLogger().verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22813
22826
  await this.executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge);
22814
- this.staticLogger.verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}, waiting ${loopInterval}ms for next cycle`);
22827
+ staticLogger().verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}, waiting ${loopInterval}ms for next cycle`);
22815
22828
  await new Promise((resolve) => {
22816
- this.staticLogger.verbose(`Scheduling next pull in ${loopInterval} ms`);
22829
+ staticLogger().verbose(`Scheduling next pull in ${loopInterval} ms`);
22817
22830
  timeout = setTimeout(resolve, loopInterval);
22818
22831
  });
22819
22832
  }
22820
22833
  };
22821
22834
  executeLoop().catch((error) => {
22822
- this.staticLogger.error(`Error in executeLoop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
22835
+ staticLogger().error(`Error in executeLoop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
22823
22836
  });
22824
22837
  return () => {
22825
- this.staticLogger.verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22838
+ staticLogger().verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22826
22839
  isCancelled = true;
22827
22840
  if (timeout !== void 0) {
22828
22841
  clearTimeout(timeout);
@@ -22830,7 +22843,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22830
22843
  };
22831
22844
  }
22832
22845
  static async createPullResponderTrigger(driveId, url, options) {
22833
- this.staticLogger.verbose(`createPullResponderTrigger(drive: ${driveId}, url: ${url})`);
22846
+ staticLogger().verbose(`createPullResponderTrigger(drive: ${driveId}, url: ${url})`);
22834
22847
  const { pullFilter, pullInterval } = options;
22835
22848
  const filter = pullFilter ?? {
22836
22849
  documentId: ["*"],
@@ -22838,7 +22851,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22838
22851
  branch: ["*"],
22839
22852
  scope: ["*"]
22840
22853
  };
22841
- const listenerId = await _PullResponderTransmitter.registerPullResponder(driveId, url, filter);
22854
+ const listenerId = await PullResponderTransmitter.registerPullResponder(driveId, url, filter);
22842
22855
  const pullTrigger = {
22843
22856
  id: generateUUID(),
22844
22857
  type: "PullResponder",
@@ -22855,12 +22868,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
22855
22868
  static isPullResponderTrigger(trigger) {
22856
22869
  return trigger.type === "PullResponder";
22857
22870
  }
22858
- };
22859
- __publicField(_PullResponderTransmitter, "staticLogger", childLogger([
22860
- "PullResponderTransmitter",
22861
- "static"
22862
- ]));
22863
- let PullResponderTransmitter = _PullResponderTransmitter;
22871
+ }
22864
22872
  var defaults;
22865
22873
  var hasRequiredDefaults;
22866
22874
  function requireDefaults() {
@@ -23077,6 +23085,7 @@ function isAtRevision(document, revisions) {
23077
23085
  }
23078
23086
  class BaseDocumentDriveServer {
23079
23087
  constructor(documentModelModules, storage, documentStorage, cache, queueManager, eventEmitter, synchronizationManager, listenerManager, options) {
23088
+ __publicField(this, "logger", childLogger(["BaseDocumentDriveServer"]));
23080
23089
  // external dependencies
23081
23090
  __publicField(this, "documentModelModules");
23082
23091
  __publicField(this, "storage");
@@ -23147,19 +23156,19 @@ class BaseDocumentDriveServer {
23147
23156
  async _initialize() {
23148
23157
  await this.listenerManager.initialize(this.handleListenerError);
23149
23158
  await this.queueManager.init(this.queueDelegate, (error) => {
23150
- logger$1.error(`Error initializing queue manager`, error);
23159
+ this.logger.error(`Error initializing queue manager`, error);
23151
23160
  errors.push(error);
23152
23161
  });
23153
23162
  try {
23154
23163
  await this.defaultDrivesManager.removeOldremoteDrives();
23155
23164
  } catch (error) {
23156
- logger$1.error(error);
23165
+ this.logger.error(error);
23157
23166
  }
23158
23167
  const errors = [];
23159
23168
  const drives = await this.getDrives();
23160
23169
  for (const drive of drives) {
23161
23170
  await this._initializeDrive(drive).catch((error) => {
23162
- logger$1.error(`Error initializing drive ${drive}`, error);
23171
+ this.logger.error(`Error initializing drive ${drive}`, error);
23163
23172
  errors.push(error);
23164
23173
  });
23165
23174
  }
@@ -23189,7 +23198,7 @@ class BaseDocumentDriveServer {
23189
23198
  return source.type === "local" ? "push" : "pull";
23190
23199
  }
23191
23200
  handleListenerError(error, driveId, listener) {
23192
- logger$1.error(`Listener ${listener.listener.label ?? listener.listener.listenerId} error:`, error);
23201
+ this.logger.error(`Listener ${listener.listener.label ?? listener.listener.listenerId} error:`, error);
23193
23202
  const status = error instanceof OperationError ? error.status : "ERROR";
23194
23203
  this.synchronizationManager.updateSyncStatus(driveId, { push: status }, error);
23195
23204
  }
@@ -23252,9 +23261,9 @@ class BaseDocumentDriveServer {
23252
23261
  if (pushListener) {
23253
23262
  this.getSynchronizationUnitsRevision(driveId, syncUnits).then((syncUnitRevisions) => {
23254
23263
  for (const revision of syncUnitRevisions) {
23255
- this.listenerManager.updateListenerRevision(pushListener.listenerId, driveId, revision.syncId, revision.revision).catch(logger$1.error);
23264
+ this.listenerManager.updateListenerRevision(pushListener.listenerId, driveId, revision.syncId, revision.revision).catch(this.logger.error);
23256
23265
  }
23257
- }).catch(logger$1.error);
23266
+ }).catch(this.logger.error);
23258
23267
  }
23259
23268
  }
23260
23269
  });
@@ -23275,20 +23284,20 @@ class BaseDocumentDriveServer {
23275
23284
  return this.triggerMap.delete(driveId);
23276
23285
  }
23277
23286
  async _initializeDrive(driveId) {
23278
- var _a2, _b, _c, _d, _e, _f, _g, _h;
23287
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
23279
23288
  const drive = await this.getDrive(driveId);
23280
- logger$1.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.state.global.slug}"`);
23289
+ this.logger.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.state.global.slug}"`);
23281
23290
  await this.synchronizationManager.initializeDriveSyncStatus(driveId, drive);
23282
23291
  if (this.shouldSyncRemoteDrive(drive)) {
23283
- logger$1.verbose(`[SYNC DEBUG] Starting sync for remote drive ${driveId}`);
23292
+ this.logger.verbose(`[SYNC DEBUG] Starting sync for remote drive ${driveId}`);
23284
23293
  await this.startSyncRemoteDrive(driveId);
23285
23294
  }
23286
- logger$1.verbose(`[SYNC DEBUG] Processing ${drive.state.local.listeners.length} listeners for drive ${driveId}`);
23295
+ this.logger.verbose(`[SYNC DEBUG] Processing ${drive.state.local.listeners.length} listeners for drive ${driveId}`);
23287
23296
  for (const zodListener of drive.state.local.listeners) {
23288
23297
  if (((_a2 = zodListener.callInfo) == null ? void 0 : _a2.transmitterType) === "SwitchboardPush") {
23289
- logger$1.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${zodListener.listenerId} for drive ${driveId}`);
23298
+ this.logger.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${zodListener.listenerId} for drive ${driveId}`);
23290
23299
  const transmitter = new SwitchboardPushTransmitter(((_b = zodListener.callInfo) == null ? void 0 : _b.data) ?? "");
23291
- logger$1.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${((_c = zodListener.callInfo) == null ? void 0 : _c.data) || "none"}`);
23300
+ this.logger.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${((_c = zodListener.callInfo) == null ? void 0 : _c.data) || "none"}`);
23292
23301
  await this.listenerManager.setListener(driveId, {
23293
23302
  block: zodListener.block,
23294
23303
  driveId: drive.state.global.id,
@@ -23304,10 +23313,28 @@ class BaseDocumentDriveServer {
23304
23313
  label: zodListener.label ?? "",
23305
23314
  transmitter
23306
23315
  }).then(() => {
23307
- logger$1.verbose(`[SYNC DEBUG] Successfully set up listener ${zodListener.listenerId} for drive ${driveId}`);
23316
+ this.logger.verbose(`[SYNC DEBUG] Successfully set up listener ${zodListener.listenerId} for drive ${driveId}`);
23308
23317
  });
23318
+ } else if (((_h = zodListener.callInfo) == null ? void 0 : _h.transmitterType) === "PullResponder") {
23319
+ this.logger.verbose(`[SYNC DEBUG] Setting up PullResponder listener ${zodListener.listenerId} for drive ${driveId}`);
23320
+ const pullResponderListener = {
23321
+ driveId,
23322
+ listenerId: zodListener.listenerId,
23323
+ block: false,
23324
+ filter: zodListener.filter,
23325
+ system: false,
23326
+ label: `PullResponder #${zodListener.listenerId}`,
23327
+ callInfo: {
23328
+ data: "",
23329
+ name: "PullResponder",
23330
+ transmitterType: "PullResponder"
23331
+ }
23332
+ };
23333
+ const pullResponder = new PullResponderTransmitter(pullResponderListener, this.listenerManager);
23334
+ pullResponderListener.transmitter = pullResponder;
23335
+ await this.listenerManager.setListener(driveId, pullResponderListener);
23309
23336
  } else {
23310
- logger$1.error(`Skipping listener ${zodListener.listenerId} with unsupported type ${((_h = zodListener.callInfo) == null ? void 0 : _h.transmitterType) || "unknown"}`);
23337
+ this.logger.error(`Skipping listener ${zodListener.listenerId} with unsupported type ${((_i = zodListener.callInfo) == null ? void 0 : _i.transmitterType) || "unknown"}`);
23311
23338
  }
23312
23339
  }
23313
23340
  }
@@ -23406,7 +23433,7 @@ class BaseDocumentDriveServer {
23406
23433
  }
23407
23434
  }
23408
23435
  } catch (e) {
23409
- logger$1.error("Error getting drive from cache", e);
23436
+ this.logger.error("Error getting drive from cache", e);
23410
23437
  }
23411
23438
  const driveStorage = document ?? await this.storage.getDrive(driveId);
23412
23439
  const result = this._buildDocument(driveStorage, options);
@@ -23414,7 +23441,7 @@ class BaseDocumentDriveServer {
23414
23441
  throw new Error(`Document with id ${driveId} is not a Document Drive`);
23415
23442
  } else {
23416
23443
  if (!(options == null ? void 0 : options.revisions)) {
23417
- this.cache.setDrive(driveId, result).catch(logger$1.error);
23444
+ this.cache.setDrive(driveId, result).catch(this.logger.error);
23418
23445
  }
23419
23446
  return result;
23420
23447
  }
@@ -23426,14 +23453,14 @@ class BaseDocumentDriveServer {
23426
23453
  return drive;
23427
23454
  }
23428
23455
  } catch (e) {
23429
- logger$1.error("Error getting drive from cache", e);
23456
+ this.logger.error("Error getting drive from cache", e);
23430
23457
  }
23431
23458
  const driveStorage = await this.storage.getDriveBySlug(slug);
23432
23459
  const document = this._buildDocument(driveStorage, options);
23433
23460
  if (!isDocumentDrive(document)) {
23434
23461
  throw new Error(`Document with slug ${slug} is not a Document Drive`);
23435
23462
  } else {
23436
- this.cache.setDriveBySlug(slug, document).catch(logger$1.error);
23463
+ this.cache.setDriveBySlug(slug, document).catch(this.logger.error);
23437
23464
  return document;
23438
23465
  }
23439
23466
  }
@@ -23445,12 +23472,12 @@ class BaseDocumentDriveServer {
23445
23472
  return cachedDocument;
23446
23473
  }
23447
23474
  } catch (e) {
23448
- logger$1.error("Error getting document from cache", e);
23475
+ this.logger.error("Error getting document from cache", e);
23449
23476
  }
23450
23477
  const documentStorage = cachedDocument ?? await this.storage.getDocument(driveId, documentId);
23451
23478
  const document = this._buildDocument(documentStorage, options);
23452
23479
  if (!(options == null ? void 0 : options.revisions)) {
23453
- this.cache.setDocument(documentId, document).catch(logger$1.error);
23480
+ this.cache.setDocument(documentId, document).catch(this.logger.error);
23454
23481
  }
23455
23482
  return document;
23456
23483
  }
@@ -23505,7 +23532,7 @@ class BaseDocumentDriveServer {
23505
23532
  }
23506
23533
  await this.listenerManager.removeSyncUnits(driveId, syncUnits);
23507
23534
  } catch (error) {
23508
- logger$1.warn("Error deleting document", error);
23535
+ this.logger.warn("Error deleting document", error);
23509
23536
  }
23510
23537
  await this.cache.deleteDocument(documentId);
23511
23538
  return this.storage.deleteDocument(driveId, documentId);
@@ -23679,33 +23706,35 @@ class BaseDocumentDriveServer {
23679
23706
  if (result) {
23680
23707
  return result;
23681
23708
  }
23709
+ let jobId;
23710
+ const promise = new Promise((resolve, reject) => {
23711
+ const unsubscribe = this.queueManager.on("jobCompleted", (job, result2) => {
23712
+ if (job.jobId === jobId) {
23713
+ unsubscribe();
23714
+ unsubscribeError();
23715
+ resolve(result2);
23716
+ }
23717
+ });
23718
+ const unsubscribeError = this.queueManager.on("jobFailed", (job, error) => {
23719
+ if (job.jobId === jobId) {
23720
+ unsubscribe();
23721
+ unsubscribeError();
23722
+ reject(error);
23723
+ }
23724
+ });
23725
+ });
23682
23726
  try {
23683
- const jobId = await this.queueManager.addJob({
23727
+ jobId = await this.queueManager.addJob({
23684
23728
  driveId,
23685
23729
  documentId,
23686
23730
  operations,
23687
23731
  options
23688
23732
  });
23689
- return new Promise((resolve, reject) => {
23690
- const unsubscribe = this.queueManager.on("jobCompleted", (job, result2) => {
23691
- if (job.jobId === jobId) {
23692
- unsubscribe();
23693
- unsubscribeError();
23694
- resolve(result2);
23695
- }
23696
- });
23697
- const unsubscribeError = this.queueManager.on("jobFailed", (job, error) => {
23698
- if (job.jobId === jobId) {
23699
- unsubscribe();
23700
- unsubscribeError();
23701
- reject(error);
23702
- }
23703
- });
23704
- });
23705
23733
  } catch (error) {
23706
- logger$1.error("Error adding job", error);
23734
+ this.logger.error("Error adding job", error);
23707
23735
  throw error;
23708
23736
  }
23737
+ return promise;
23709
23738
  }
23710
23739
  async queueAction(driveId, documentId, action, options) {
23711
23740
  return this.queueActions(driveId, documentId, [action], options);
@@ -23735,7 +23764,7 @@ class BaseDocumentDriveServer {
23735
23764
  });
23736
23765
  });
23737
23766
  } catch (error) {
23738
- logger$1.error("Error adding job", error);
23767
+ this.logger.error("Error adding job", error);
23739
23768
  throw error;
23740
23769
  }
23741
23770
  }
@@ -23766,7 +23795,7 @@ class BaseDocumentDriveServer {
23766
23795
  });
23767
23796
  });
23768
23797
  } catch (error) {
23769
- logger$1.error("Error adding drive job", error);
23798
+ this.logger.error("Error adding drive job", error);
23770
23799
  throw error;
23771
23800
  }
23772
23801
  }
@@ -23783,7 +23812,7 @@ class BaseDocumentDriveServer {
23783
23812
  await this._addOperations(driveId, documentId, async (documentStorage) => {
23784
23813
  const result2 = await this._processOperations(driveId, documentId, documentStorage, operations);
23785
23814
  if (!result2.document) {
23786
- logger$1.error("Invalid document");
23815
+ this.logger.error("Invalid document");
23787
23816
  throw result2.error ?? new Error("Invalid document");
23788
23817
  }
23789
23818
  document = result2.document;
@@ -23797,7 +23826,7 @@ class BaseDocumentDriveServer {
23797
23826
  };
23798
23827
  });
23799
23828
  if (document) {
23800
- this.cache.setDocument(documentId, document).catch(logger$1.error);
23829
+ this.cache.setDocument(documentId, document).catch(this.logger.error);
23801
23830
  }
23802
23831
  const { scopes, branches } = operationsApplied.reduce((acc, operation) => {
23803
23832
  if (!acc.scopes.includes(operation.scope)) {
@@ -23830,7 +23859,7 @@ class BaseDocumentDriveServer {
23830
23859
  });
23831
23860
  }
23832
23861
  }).catch((error2) => {
23833
- logger$1.error("Non handled error updating sync revision", error2);
23862
+ this.logger.error("Non handled error updating sync revision", error2);
23834
23863
  this.synchronizationManager.updateSyncStatus(driveId, {
23835
23864
  [operationSource]: "ERROR"
23836
23865
  }, error2);
@@ -23932,7 +23961,7 @@ class BaseDocumentDriveServer {
23932
23961
  });
23933
23962
  });
23934
23963
  } catch (error) {
23935
- logger$1.error("Error adding drive job", error);
23964
+ this.logger.error("Error adding drive job", error);
23936
23965
  throw error;
23937
23966
  }
23938
23967
  }
@@ -23960,7 +23989,7 @@ class BaseDocumentDriveServer {
23960
23989
  if (!document || !isDocumentDrive(document)) {
23961
23990
  throw error ?? new Error("Invalid Document Drive document");
23962
23991
  }
23963
- this.cache.setDrive(driveId, document).catch(logger$1.error);
23992
+ this.cache.setDrive(driveId, document).catch(this.logger.error);
23964
23993
  const lastOperation = operationsApplied.filter((op) => op.scope === "global").slice().pop();
23965
23994
  if (lastOperation) {
23966
23995
  const newOp = operationsApplied.find((appliedOp) => !operations.find((o) => o.id === appliedOp.id && o.index === appliedOp.index && o.skip === appliedOp.skip && o.hash === appliedOp.hash));
@@ -23987,7 +24016,7 @@ class BaseDocumentDriveServer {
23987
24016
  });
23988
24017
  }
23989
24018
  }).catch((error2) => {
23990
- logger$1.error("Non handled error updating sync revision", error2);
24019
+ this.logger.error("Non handled error updating sync revision", error2);
23991
24020
  this.synchronizationManager.updateSyncStatus(driveId, {
23992
24021
  [operationSource]: "ERROR"
23993
24022
  }, error2);
@@ -24089,9 +24118,26 @@ class BaseDocumentDriveServer {
24089
24118
  scope: strand.scope,
24090
24119
  branch: strand.branch
24091
24120
  }));
24092
- const result = await (!strand.documentId ? this.queueDriveOperations(strand.driveId, operations, { source }) : this.queueOperations(strand.driveId, strand.documentId, operations, {
24093
- source
24094
- }));
24121
+ let result;
24122
+ if (strand.documentId) {
24123
+ try {
24124
+ result = await this.queueOperations(strand.driveId, strand.documentId, operations, {
24125
+ source
24126
+ });
24127
+ } catch (error) {
24128
+ this.logger.error("Error queueing operations", error);
24129
+ throw error;
24130
+ }
24131
+ } else {
24132
+ try {
24133
+ result = await this.queueDriveOperations(strand.driveId, operations, {
24134
+ source
24135
+ });
24136
+ } catch (error) {
24137
+ this.logger.error("Error queueing operations", error);
24138
+ throw error;
24139
+ }
24140
+ }
24095
24141
  if (result.status === "ERROR") {
24096
24142
  const syncUnits = strand.documentId !== "" ? (await this.getSynchronizationUnitsIds(strand.driveId, [strand.documentId], [strand.scope], [strand.branch])).map((s) => s.syncId) : [strand.driveId];
24097
24143
  const operationSource = this.getOperationSource(source);
@@ -24465,11 +24511,10 @@ const _ListenerManager = class _ListenerManager {
24465
24511
  throw new Error("Maximum retries exhausted.");
24466
24512
  }
24467
24513
  const listenerUpdates = [];
24468
- for (const [driveId, drive] of this.listenerStateByDriveId) {
24469
- for (const [listenerId, listenerState] of drive) {
24514
+ for (const [driveId, listenerStateById] of this.listenerStateByDriveId) {
24515
+ for (const [listenerId, listenerState] of listenerStateById) {
24470
24516
  const transmitter = listenerState.listener.transmitter;
24471
24517
  if (!(transmitter == null ? void 0 : transmitter.transmit)) {
24472
- this.logger.verbose(`Transmitter not set on listener: ${listenerId}`);
24473
24518
  continue;
24474
24519
  }
24475
24520
  const syncUnits = await this.getListenerSyncUnits(driveId, listenerId);
@@ -24765,21 +24810,26 @@ class SynchronizationManager {
24765
24810
  const drive = await this.getDrive(driveId);
24766
24811
  const revisions = await this.storage.getSynchronizationUnitsRevision(syncUnitsQuery);
24767
24812
  this.logger.verbose(`getSynchronizationUnitsRevision: ${JSON.stringify(revisions)}`);
24768
- return syncUnitsQuery.map((s) => {
24769
- var _a2;
24770
- return {
24771
- ...s,
24772
- lastUpdated: drive.created,
24773
- revision: ((_a2 = revisions.find((r) => r.documentId === s.documentId && r.scope === s.scope && r.branch === s.branch)) == null ? void 0 : _a2.revision) ?? -1
24774
- };
24775
- });
24813
+ const synchronizationUnits = syncUnitsQuery.map((s) => ({
24814
+ ...s,
24815
+ lastUpdated: drive.created,
24816
+ revision: -1
24817
+ }));
24818
+ for (const revision of revisions) {
24819
+ const syncUnit = synchronizationUnits.find((s) => revision.documentId === s.documentId && revision.scope === s.scope && revision.branch === s.branch);
24820
+ if (syncUnit) {
24821
+ syncUnit.revision = revision.revision;
24822
+ syncUnit.lastUpdated = revision.lastUpdated;
24823
+ }
24824
+ }
24825
+ return synchronizationUnits;
24776
24826
  }
24777
24827
  async getSynchronizationUnitsIds(driveId, documentId, scope, branch, documentType2) {
24778
24828
  const drive = await this.getDrive(driveId);
24779
24829
  const nodes = drive.state.global.nodes.filter((node) => isFileNode(node) && (!(documentId == null ? void 0 : documentId.length) || documentId.includes(node.id) || documentId.includes("*")) && (!(documentType2 == null ? void 0 : documentType2.length) || documentType2.includes(node.documentType) || documentType2.includes("*")));
24780
24830
  if ((!documentId || documentId.includes("*") || documentId.includes("")) && (!(documentType2 == null ? void 0 : documentType2.length) || documentType2.includes("powerhouse/document-drive") || documentType2.includes("*"))) {
24781
24831
  nodes.unshift({
24782
- id: drive.state.global.id,
24832
+ id: driveId,
24783
24833
  documentType: "powerhouse/document-drive",
24784
24834
  synchronizationUnits: [
24785
24835
  {
@@ -25740,7 +25790,7 @@ const nodeOptionsMap = {
25740
25790
  };
25741
25791
  const name = "@powerhousedao/connect";
25742
25792
  const productName = "Powerhouse-Connect";
25743
- const version$1 = "1.0.5-dev.0";
25793
+ const version$1 = "1.0.6-dev.1";
25744
25794
  const description = "Powerhouse Connect";
25745
25795
  const main = "./dist/index.html";
25746
25796
  const type = "module";
@@ -31380,7 +31430,7 @@ if (window.__VITE_ENVS.MODE === "development") {
31380
31430
  } else {
31381
31431
  serviceWorkerManager.registerServiceWorker(false);
31382
31432
  }
31383
- const App = lazy(() => __vitePreload(() => import("./app-D5aQi0aY.js").then((n) => n.aN), true ? __vite__mapDeps([0,1,2]) : void 0));
31433
+ const App = lazy(() => __vitePreload(() => import("./app-DzySetAh.js").then((n) => n.aN), true ? __vite__mapDeps([0,1,2]) : void 0));
31384
31434
  const AppLoader = /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(App, {}) });
31385
31435
  const appLoader = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
31386
31436
  __proto__: null,