@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
@@ -11898,11 +11898,14 @@ var PULL_DRIVE_INTERVAL = 1500;
11898
11898
 
11899
11899
  // ../../packages/document-drive/dist/src/server/listener/transmitter/pull-responder.js
11900
11900
  var MAX_REVISIONS_PER_ACK = 100;
11901
+ var _staticLogger;
11902
+ var staticLogger = () => {
11903
+ if (!_staticLogger) {
11904
+ _staticLogger = childLogger(["PullResponderTransmitter", "static"]);
11905
+ }
11906
+ return _staticLogger;
11907
+ };
11901
11908
  var PullResponderTransmitter = class _PullResponderTransmitter {
11902
- static staticLogger = childLogger([
11903
- "PullResponderTransmitter",
11904
- "static"
11905
- ]);
11906
11909
  logger = childLogger([
11907
11910
  "PullResponderTransmitter",
11908
11911
  Math.floor(Math.random() * 999).toString()
@@ -11946,15 +11949,21 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
11946
11949
  }
11947
11950
  return success;
11948
11951
  }
11949
- static async registerPullResponder(driveId, url, filter) {
11950
- _PullResponderTransmitter.staticLogger.verbose(`registerPullResponder(url: ${url})`, filter);
11952
+ static async registerPullResponder(driveId, url, filter, listenerId) {
11953
+ staticLogger().verbose(`registerPullResponder(url: ${url})`, filter);
11951
11954
  const result = await requestGraphql(url, gql`
11952
- mutation registerPullResponderListener($filter: InputListenerFilter!) {
11953
- registerPullResponderListener(filter: $filter) {
11955
+ mutation registerPullResponderListener(
11956
+ $filter: InputListenerFilter!
11957
+ $listenerId: String
11958
+ ) {
11959
+ registerPullResponderListener(
11960
+ filter: $filter
11961
+ listenerId: $listenerId
11962
+ ) {
11954
11963
  listenerId
11955
11964
  }
11956
11965
  }
11957
- `, { filter });
11966
+ `, { filter, listenerId });
11958
11967
  const error = result.errors?.at(0);
11959
11968
  if (error) {
11960
11969
  throw error;
@@ -11965,7 +11974,7 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
11965
11974
  return result.registerPullResponderListener.listenerId;
11966
11975
  }
11967
11976
  static async pullStrands(driveId, url, listenerId, options) {
11968
- this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${driveId}, url: ${url}, listener: ${listenerId}, options: ${JSON.stringify(options || {})}`);
11977
+ staticLogger().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${driveId}, url: ${url}, listener: ${listenerId}, options: ${JSON.stringify(options || {})}`);
11969
11978
  const result = await requestGraphql(url, gql`
11970
11979
  query strands($listenerId: ID!) {
11971
11980
  system {
@@ -12005,11 +12014,11 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12005
12014
  `, { listenerId });
12006
12015
  const error = result.errors?.at(0);
12007
12016
  if (error) {
12008
- this.staticLogger.verbose(`[SYNC DEBUG] Error pulling strands for drive: ${driveId}, listener: ${listenerId}, error: ${JSON.stringify(error)}`);
12017
+ staticLogger().verbose(`[SYNC DEBUG] Error pulling strands for drive: ${driveId}, listener: ${listenerId}, error: ${JSON.stringify(error)}`);
12009
12018
  throw error;
12010
12019
  }
12011
12020
  if (!result.system) {
12012
- this.staticLogger.verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${driveId}, listener: ${listenerId}`);
12021
+ staticLogger().verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${driveId}, listener: ${listenerId}`);
12013
12022
  return [];
12014
12023
  }
12015
12024
  const strands = result.system.sync.strands.map((s) => ({
@@ -12019,20 +12028,20 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12019
12028
  input: JSON.parse(o.input)
12020
12029
  }))
12021
12030
  }));
12022
- this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${strands.length} strands for drive: ${driveId}, listener: ${listenerId}`);
12031
+ staticLogger().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${strands.length} strands for drive: ${driveId}, listener: ${listenerId}`);
12023
12032
  if (strands.length > 0) {
12024
- this.staticLogger.verbose(`[SYNC DEBUG] Strands being returned: ${strands.map((s) => `${s.documentId}:${s.scope}`).join(", ")}`);
12033
+ staticLogger().verbose(`[SYNC DEBUG] Strands being returned: ${strands.map((s) => `${s.documentId}:${s.scope}`).join(", ")}`);
12025
12034
  }
12026
12035
  return strands;
12027
12036
  }
12028
12037
  static async acknowledgeStrands(url, listenerId, revisions) {
12029
- this.staticLogger.verbose(`acknowledgeStrands(url: ${url}, listener: ${listenerId})`, revisions);
12038
+ staticLogger().verbose(`acknowledgeStrands(url: ${url}, listener: ${listenerId})`, revisions);
12030
12039
  const chunks = [];
12031
12040
  for (let i = 0; i < revisions.length; i += MAX_REVISIONS_PER_ACK) {
12032
12041
  chunks.push(revisions.slice(i, i + MAX_REVISIONS_PER_ACK));
12033
12042
  }
12034
12043
  if (chunks.length > 1) {
12035
- this.staticLogger.verbose(`Breaking strand acknowledgement into ${chunks.length} chunks...`);
12044
+ staticLogger().verbose(`Breaking strand acknowledgement into ${chunks.length} chunks...`);
12036
12045
  }
12037
12046
  const results = await Promise.allSettled(chunks.map(async (chunk) => {
12038
12047
  const result = await requestGraphql(url, gql`
@@ -12065,27 +12074,27 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12065
12074
  * Because of this, `onError` _may be called multiple times_.
12066
12075
  */
12067
12076
  static async executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
12068
- this.staticLogger.verbose(`executePull(driveId: ${driveId}), trigger:`, trigger);
12069
- this.staticLogger.info(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12077
+ staticLogger().verbose(`executePull(driveId: ${driveId}), trigger:`, trigger);
12078
+ staticLogger().info(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12070
12079
  const { url } = trigger.data;
12071
12080
  let strands;
12072
12081
  let error;
12082
+ const listenerId = trigger.data.listenerId;
12073
12083
  try {
12074
- strands = await _PullResponderTransmitter.pullStrands(driveId, url, trigger.data.listenerId);
12084
+ strands = await _PullResponderTransmitter.pullStrands(driveId, url, listenerId);
12075
12085
  } catch (e) {
12076
12086
  error = e;
12077
12087
  const graphqlError = error;
12078
12088
  const errors = graphqlError.response?.errors ?? [];
12079
12089
  for (const err of errors) {
12080
12090
  if (err.message === "Listener not found") {
12081
- this.staticLogger.verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${driveId}`);
12082
- const listenerId = await _PullResponderTransmitter.registerPullResponder(trigger.driveId, url, trigger.filter);
12083
- trigger.data.listenerId = listenerId;
12091
+ staticLogger().verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${driveId}`);
12092
+ await _PullResponderTransmitter.registerPullResponder(trigger.driveId, url, trigger.filter, listenerId);
12084
12093
  try {
12085
12094
  strands = await _PullResponderTransmitter.pullStrands(driveId, url, listenerId);
12086
- this.staticLogger.verbose(`Successfully auto-registerd and pulled strands for drive: ${driveId}, listenerId: ${listenerId}`);
12095
+ staticLogger().verbose(`Successfully auto-registered and pulled strands for drive: ${driveId}, listenerId: ${listenerId}`);
12087
12096
  } catch (error2) {
12088
- this.staticLogger.error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${driveId}, listenerId: ${listenerId}: ${error2}`);
12097
+ staticLogger().error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${driveId}, listenerId: ${listenerId}: ${error2}`);
12089
12098
  onError(error2);
12090
12099
  return;
12091
12100
  }
@@ -12094,21 +12103,21 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12094
12103
  }
12095
12104
  }
12096
12105
  if (!strands) {
12097
- this.staticLogger.error(`Error pulling strands for drive, and could not auto-register: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
12106
+ staticLogger().error(`Error pulling strands for drive, and could not auto-register: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
12098
12107
  onError(error);
12099
12108
  return;
12100
12109
  }
12101
12110
  if (!strands.length) {
12102
- this.staticLogger.verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12111
+ staticLogger().verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12103
12112
  try {
12104
12113
  onRevisions?.([]);
12105
12114
  } catch (error2) {
12106
- this.staticLogger.error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12115
+ staticLogger().error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12107
12116
  onError(error2);
12108
12117
  }
12109
12118
  return;
12110
12119
  }
12111
- this.staticLogger.verbose(`[SYNC DEBUG] Processing ${strands.length} strands in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12120
+ staticLogger().verbose(`[SYNC DEBUG] Processing ${strands.length} strands in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12112
12121
  const listenerRevisions = [];
12113
12122
  for (const strand of strands) {
12114
12123
  const operations = strand.operations.map((op) => ({
@@ -12116,7 +12125,7 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12116
12125
  scope: strand.scope,
12117
12126
  branch: strand.branch
12118
12127
  }));
12119
- this.staticLogger.verbose(`[SYNC DEBUG] Processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations`);
12128
+ staticLogger().verbose(`[SYNC DEBUG] Processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations`);
12120
12129
  let error2 = void 0;
12121
12130
  try {
12122
12131
  const result = await onStrandUpdate(strand, {
@@ -12127,7 +12136,7 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12127
12136
  throw result.error;
12128
12137
  }
12129
12138
  } catch (e) {
12130
- this.staticLogger.error(`Error processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations: ${e}`);
12139
+ staticLogger().error(`Error processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations: ${e}`);
12131
12140
  error2 = e;
12132
12141
  onError(error2);
12133
12142
  }
@@ -12141,14 +12150,14 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12141
12150
  error: error2
12142
12151
  });
12143
12152
  }
12144
- this.staticLogger.verbose("Processed strands...");
12153
+ staticLogger().verbose("Processed strands...");
12145
12154
  try {
12146
12155
  onRevisions?.(listenerRevisions);
12147
12156
  } catch (error2) {
12148
- this.staticLogger.error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12157
+ staticLogger().error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12149
12158
  onError(error2);
12150
12159
  }
12151
- this.staticLogger.verbose(`[SYNC DEBUG] Acknowledging ${listenerRevisions.length} strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12160
+ staticLogger().verbose(`[SYNC DEBUG] Acknowledging ${listenerRevisions.length} strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12152
12161
  let success = false;
12153
12162
  try {
12154
12163
  await _PullResponderTransmitter.acknowledgeStrands(url, trigger.data.listenerId, listenerRevisions.map((revision) => {
@@ -12157,23 +12166,23 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12157
12166
  }));
12158
12167
  success = true;
12159
12168
  } catch (error2) {
12160
- this.staticLogger.error(`Error acknowledging strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12169
+ staticLogger().error(`Error acknowledging strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12161
12170
  onError(error2);
12162
12171
  }
12163
12172
  if (success) {
12164
- this.staticLogger.verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12173
+ staticLogger().verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12165
12174
  } else {
12166
- this.staticLogger.error("Failed to acknowledge strands");
12175
+ staticLogger().error("Failed to acknowledge strands");
12167
12176
  }
12168
12177
  try {
12169
12178
  onAcknowledge?.(success);
12170
12179
  } catch (error2) {
12171
- this.staticLogger.error(`Error calling onAcknowledge for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12180
+ staticLogger().error(`Error calling onAcknowledge for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
12172
12181
  onError(error2);
12173
12182
  }
12174
12183
  }
12175
12184
  static setupPull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
12176
- this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12185
+ staticLogger().verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12177
12186
  const { interval } = trigger.data;
12178
12187
  let loopInterval = PULL_DRIVE_INTERVAL;
12179
12188
  if (interval) {
@@ -12185,25 +12194,25 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12185
12194
  } catch {
12186
12195
  }
12187
12196
  }
12188
- this.staticLogger.verbose(`[SYNC DEBUG] Pull interval set to ${loopInterval}ms for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12197
+ staticLogger().verbose(`[SYNC DEBUG] Pull interval set to ${loopInterval}ms for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12189
12198
  let isCancelled = false;
12190
12199
  let timeout;
12191
12200
  const executeLoop = async () => {
12192
12201
  while (!isCancelled) {
12193
- this.staticLogger.verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12202
+ staticLogger().verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12194
12203
  await this.executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge);
12195
- this.staticLogger.verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}, waiting ${loopInterval}ms for next cycle`);
12204
+ staticLogger().verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}, waiting ${loopInterval}ms for next cycle`);
12196
12205
  await new Promise((resolve) => {
12197
- this.staticLogger.verbose(`Scheduling next pull in ${loopInterval} ms`);
12206
+ staticLogger().verbose(`Scheduling next pull in ${loopInterval} ms`);
12198
12207
  timeout = setTimeout(resolve, loopInterval);
12199
12208
  });
12200
12209
  }
12201
12210
  };
12202
12211
  executeLoop().catch((error) => {
12203
- this.staticLogger.error(`Error in executeLoop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
12212
+ staticLogger().error(`Error in executeLoop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
12204
12213
  });
12205
12214
  return () => {
12206
- this.staticLogger.verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12215
+ staticLogger().verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
12207
12216
  isCancelled = true;
12208
12217
  if (timeout !== void 0) {
12209
12218
  clearTimeout(timeout);
@@ -12211,7 +12220,7 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12211
12220
  };
12212
12221
  }
12213
12222
  static async createPullResponderTrigger(driveId, url, options) {
12214
- this.staticLogger.verbose(`createPullResponderTrigger(drive: ${driveId}, url: ${url})`);
12223
+ staticLogger().verbose(`createPullResponderTrigger(drive: ${driveId}, url: ${url})`);
12215
12224
  const { pullFilter, pullInterval } = options;
12216
12225
  const filter = pullFilter ?? {
12217
12226
  documentId: ["*"],
@@ -12351,6 +12360,7 @@ function isAtRevision(document, revisions) {
12351
12360
 
12352
12361
  // ../../packages/document-drive/dist/src/server/base-server.js
12353
12362
  var BaseDocumentDriveServer = class {
12363
+ logger = childLogger(["BaseDocumentDriveServer"]);
12354
12364
  // external dependencies
12355
12365
  documentModelModules;
12356
12366
  storage;
@@ -12422,19 +12432,19 @@ var BaseDocumentDriveServer = class {
12422
12432
  async _initialize() {
12423
12433
  await this.listenerManager.initialize(this.handleListenerError);
12424
12434
  await this.queueManager.init(this.queueDelegate, (error) => {
12425
- logger.error(`Error initializing queue manager`, error);
12435
+ this.logger.error(`Error initializing queue manager`, error);
12426
12436
  errors.push(error);
12427
12437
  });
12428
12438
  try {
12429
12439
  await this.defaultDrivesManager.removeOldremoteDrives();
12430
12440
  } catch (error) {
12431
- logger.error(error);
12441
+ this.logger.error(error);
12432
12442
  }
12433
12443
  const errors = [];
12434
12444
  const drives = await this.getDrives();
12435
12445
  for (const drive of drives) {
12436
12446
  await this._initializeDrive(drive).catch((error) => {
12437
- logger.error(`Error initializing drive ${drive}`, error);
12447
+ this.logger.error(`Error initializing drive ${drive}`, error);
12438
12448
  errors.push(error);
12439
12449
  });
12440
12450
  }
@@ -12464,7 +12474,7 @@ var BaseDocumentDriveServer = class {
12464
12474
  return source.type === "local" ? "push" : "pull";
12465
12475
  }
12466
12476
  handleListenerError(error, driveId, listener) {
12467
- logger.error(`Listener ${listener.listener.label ?? listener.listener.listenerId} error:`, error);
12477
+ this.logger.error(`Listener ${listener.listener.label ?? listener.listener.listenerId} error:`, error);
12468
12478
  const status = error instanceof OperationError ? error.status : "ERROR";
12469
12479
  this.synchronizationManager.updateSyncStatus(driveId, { push: status }, error);
12470
12480
  }
@@ -12524,9 +12534,9 @@ var BaseDocumentDriveServer = class {
12524
12534
  if (pushListener) {
12525
12535
  this.getSynchronizationUnitsRevision(driveId, syncUnits).then((syncUnitRevisions) => {
12526
12536
  for (const revision of syncUnitRevisions) {
12527
- this.listenerManager.updateListenerRevision(pushListener.listenerId, driveId, revision.syncId, revision.revision).catch(logger.error);
12537
+ this.listenerManager.updateListenerRevision(pushListener.listenerId, driveId, revision.syncId, revision.revision).catch(this.logger.error);
12528
12538
  }
12529
- }).catch(logger.error);
12539
+ }).catch(this.logger.error);
12530
12540
  }
12531
12541
  }
12532
12542
  });
@@ -12548,18 +12558,18 @@ var BaseDocumentDriveServer = class {
12548
12558
  }
12549
12559
  async _initializeDrive(driveId) {
12550
12560
  const drive = await this.getDrive(driveId);
12551
- logger.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.state.global.slug}"`);
12561
+ this.logger.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.state.global.slug}"`);
12552
12562
  await this.synchronizationManager.initializeDriveSyncStatus(driveId, drive);
12553
12563
  if (this.shouldSyncRemoteDrive(drive)) {
12554
- logger.verbose(`[SYNC DEBUG] Starting sync for remote drive ${driveId}`);
12564
+ this.logger.verbose(`[SYNC DEBUG] Starting sync for remote drive ${driveId}`);
12555
12565
  await this.startSyncRemoteDrive(driveId);
12556
12566
  }
12557
- logger.verbose(`[SYNC DEBUG] Processing ${drive.state.local.listeners.length} listeners for drive ${driveId}`);
12567
+ this.logger.verbose(`[SYNC DEBUG] Processing ${drive.state.local.listeners.length} listeners for drive ${driveId}`);
12558
12568
  for (const zodListener of drive.state.local.listeners) {
12559
12569
  if (zodListener.callInfo?.transmitterType === "SwitchboardPush") {
12560
- logger.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${zodListener.listenerId} for drive ${driveId}`);
12570
+ this.logger.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${zodListener.listenerId} for drive ${driveId}`);
12561
12571
  const transmitter = new SwitchboardPushTransmitter(zodListener.callInfo?.data ?? "");
12562
- logger.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${zodListener.callInfo?.data || "none"}`);
12572
+ this.logger.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${zodListener.callInfo?.data || "none"}`);
12563
12573
  await this.listenerManager.setListener(driveId, {
12564
12574
  block: zodListener.block,
12565
12575
  driveId: drive.state.global.id,
@@ -12575,10 +12585,28 @@ var BaseDocumentDriveServer = class {
12575
12585
  label: zodListener.label ?? "",
12576
12586
  transmitter
12577
12587
  }).then(() => {
12578
- logger.verbose(`[SYNC DEBUG] Successfully set up listener ${zodListener.listenerId} for drive ${driveId}`);
12588
+ this.logger.verbose(`[SYNC DEBUG] Successfully set up listener ${zodListener.listenerId} for drive ${driveId}`);
12579
12589
  });
12590
+ } else if (zodListener.callInfo?.transmitterType === "PullResponder") {
12591
+ this.logger.verbose(`[SYNC DEBUG] Setting up PullResponder listener ${zodListener.listenerId} for drive ${driveId}`);
12592
+ const pullResponderListener = {
12593
+ driveId,
12594
+ listenerId: zodListener.listenerId,
12595
+ block: false,
12596
+ filter: zodListener.filter,
12597
+ system: false,
12598
+ label: `PullResponder #${zodListener.listenerId}`,
12599
+ callInfo: {
12600
+ data: "",
12601
+ name: "PullResponder",
12602
+ transmitterType: "PullResponder"
12603
+ }
12604
+ };
12605
+ const pullResponder = new PullResponderTransmitter(pullResponderListener, this.listenerManager);
12606
+ pullResponderListener.transmitter = pullResponder;
12607
+ await this.listenerManager.setListener(driveId, pullResponderListener);
12580
12608
  } else {
12581
- logger.error(`Skipping listener ${zodListener.listenerId} with unsupported type ${zodListener.callInfo?.transmitterType || "unknown"}`);
12609
+ this.logger.error(`Skipping listener ${zodListener.listenerId} with unsupported type ${zodListener.callInfo?.transmitterType || "unknown"}`);
12582
12610
  }
12583
12611
  }
12584
12612
  }
@@ -12677,7 +12705,7 @@ var BaseDocumentDriveServer = class {
12677
12705
  }
12678
12706
  }
12679
12707
  } catch (e) {
12680
- logger.error("Error getting drive from cache", e);
12708
+ this.logger.error("Error getting drive from cache", e);
12681
12709
  }
12682
12710
  const driveStorage = document ?? await this.storage.getDrive(driveId);
12683
12711
  const result = this._buildDocument(driveStorage, options);
@@ -12685,7 +12713,7 @@ var BaseDocumentDriveServer = class {
12685
12713
  throw new Error(`Document with id ${driveId} is not a Document Drive`);
12686
12714
  } else {
12687
12715
  if (!options?.revisions) {
12688
- this.cache.setDrive(driveId, result).catch(logger.error);
12716
+ this.cache.setDrive(driveId, result).catch(this.logger.error);
12689
12717
  }
12690
12718
  return result;
12691
12719
  }
@@ -12697,14 +12725,14 @@ var BaseDocumentDriveServer = class {
12697
12725
  return drive;
12698
12726
  }
12699
12727
  } catch (e) {
12700
- logger.error("Error getting drive from cache", e);
12728
+ this.logger.error("Error getting drive from cache", e);
12701
12729
  }
12702
12730
  const driveStorage = await this.storage.getDriveBySlug(slug);
12703
12731
  const document = this._buildDocument(driveStorage, options);
12704
12732
  if (!isDocumentDrive(document)) {
12705
12733
  throw new Error(`Document with slug ${slug} is not a Document Drive`);
12706
12734
  } else {
12707
- this.cache.setDriveBySlug(slug, document).catch(logger.error);
12735
+ this.cache.setDriveBySlug(slug, document).catch(this.logger.error);
12708
12736
  return document;
12709
12737
  }
12710
12738
  }
@@ -12716,12 +12744,12 @@ var BaseDocumentDriveServer = class {
12716
12744
  return cachedDocument;
12717
12745
  }
12718
12746
  } catch (e) {
12719
- logger.error("Error getting document from cache", e);
12747
+ this.logger.error("Error getting document from cache", e);
12720
12748
  }
12721
12749
  const documentStorage = cachedDocument ?? await this.storage.getDocument(driveId, documentId);
12722
12750
  const document = this._buildDocument(documentStorage, options);
12723
12751
  if (!options?.revisions) {
12724
- this.cache.setDocument(documentId, document).catch(logger.error);
12752
+ this.cache.setDocument(documentId, document).catch(this.logger.error);
12725
12753
  }
12726
12754
  return document;
12727
12755
  }
@@ -12776,7 +12804,7 @@ var BaseDocumentDriveServer = class {
12776
12804
  }
12777
12805
  await this.listenerManager.removeSyncUnits(driveId, syncUnits);
12778
12806
  } catch (error) {
12779
- logger.warn("Error deleting document", error);
12807
+ this.logger.warn("Error deleting document", error);
12780
12808
  }
12781
12809
  await this.cache.deleteDocument(documentId);
12782
12810
  return this.storage.deleteDocument(driveId, documentId);
@@ -12948,33 +12976,35 @@ var BaseDocumentDriveServer = class {
12948
12976
  if (result) {
12949
12977
  return result;
12950
12978
  }
12979
+ let jobId;
12980
+ const promise = new Promise((resolve, reject) => {
12981
+ const unsubscribe = this.queueManager.on("jobCompleted", (job, result2) => {
12982
+ if (job.jobId === jobId) {
12983
+ unsubscribe();
12984
+ unsubscribeError();
12985
+ resolve(result2);
12986
+ }
12987
+ });
12988
+ const unsubscribeError = this.queueManager.on("jobFailed", (job, error) => {
12989
+ if (job.jobId === jobId) {
12990
+ unsubscribe();
12991
+ unsubscribeError();
12992
+ reject(error);
12993
+ }
12994
+ });
12995
+ });
12951
12996
  try {
12952
- const jobId = await this.queueManager.addJob({
12997
+ jobId = await this.queueManager.addJob({
12953
12998
  driveId,
12954
12999
  documentId,
12955
13000
  operations,
12956
13001
  options
12957
13002
  });
12958
- return new Promise((resolve, reject) => {
12959
- const unsubscribe = this.queueManager.on("jobCompleted", (job, result2) => {
12960
- if (job.jobId === jobId) {
12961
- unsubscribe();
12962
- unsubscribeError();
12963
- resolve(result2);
12964
- }
12965
- });
12966
- const unsubscribeError = this.queueManager.on("jobFailed", (job, error) => {
12967
- if (job.jobId === jobId) {
12968
- unsubscribe();
12969
- unsubscribeError();
12970
- reject(error);
12971
- }
12972
- });
12973
- });
12974
13003
  } catch (error) {
12975
- logger.error("Error adding job", error);
13004
+ this.logger.error("Error adding job", error);
12976
13005
  throw error;
12977
13006
  }
13007
+ return promise;
12978
13008
  }
12979
13009
  async queueAction(driveId, documentId, action, options) {
12980
13010
  return this.queueActions(driveId, documentId, [action], options);
@@ -13004,7 +13034,7 @@ var BaseDocumentDriveServer = class {
13004
13034
  });
13005
13035
  });
13006
13036
  } catch (error) {
13007
- logger.error("Error adding job", error);
13037
+ this.logger.error("Error adding job", error);
13008
13038
  throw error;
13009
13039
  }
13010
13040
  }
@@ -13035,7 +13065,7 @@ var BaseDocumentDriveServer = class {
13035
13065
  });
13036
13066
  });
13037
13067
  } catch (error) {
13038
- logger.error("Error adding drive job", error);
13068
+ this.logger.error("Error adding drive job", error);
13039
13069
  throw error;
13040
13070
  }
13041
13071
  }
@@ -13052,7 +13082,7 @@ var BaseDocumentDriveServer = class {
13052
13082
  await this._addOperations(driveId, documentId, async (documentStorage) => {
13053
13083
  const result2 = await this._processOperations(driveId, documentId, documentStorage, operations);
13054
13084
  if (!result2.document) {
13055
- logger.error("Invalid document");
13085
+ this.logger.error("Invalid document");
13056
13086
  throw result2.error ?? new Error("Invalid document");
13057
13087
  }
13058
13088
  document = result2.document;
@@ -13066,7 +13096,7 @@ var BaseDocumentDriveServer = class {
13066
13096
  };
13067
13097
  });
13068
13098
  if (document) {
13069
- this.cache.setDocument(documentId, document).catch(logger.error);
13099
+ this.cache.setDocument(documentId, document).catch(this.logger.error);
13070
13100
  }
13071
13101
  const { scopes, branches } = operationsApplied.reduce((acc, operation) => {
13072
13102
  if (!acc.scopes.includes(operation.scope)) {
@@ -13099,7 +13129,7 @@ var BaseDocumentDriveServer = class {
13099
13129
  });
13100
13130
  }
13101
13131
  }).catch((error2) => {
13102
- logger.error("Non handled error updating sync revision", error2);
13132
+ this.logger.error("Non handled error updating sync revision", error2);
13103
13133
  this.synchronizationManager.updateSyncStatus(driveId, {
13104
13134
  [operationSource]: "ERROR"
13105
13135
  }, error2);
@@ -13200,7 +13230,7 @@ var BaseDocumentDriveServer = class {
13200
13230
  });
13201
13231
  });
13202
13232
  } catch (error) {
13203
- logger.error("Error adding drive job", error);
13233
+ this.logger.error("Error adding drive job", error);
13204
13234
  throw error;
13205
13235
  }
13206
13236
  }
@@ -13228,7 +13258,7 @@ var BaseDocumentDriveServer = class {
13228
13258
  if (!document || !isDocumentDrive(document)) {
13229
13259
  throw error ?? new Error("Invalid Document Drive document");
13230
13260
  }
13231
- this.cache.setDrive(driveId, document).catch(logger.error);
13261
+ this.cache.setDrive(driveId, document).catch(this.logger.error);
13232
13262
  const lastOperation = operationsApplied.filter((op) => op.scope === "global").slice().pop();
13233
13263
  if (lastOperation) {
13234
13264
  const newOp = operationsApplied.find((appliedOp) => !operations.find((o) => o.id === appliedOp.id && o.index === appliedOp.index && o.skip === appliedOp.skip && o.hash === appliedOp.hash));
@@ -13255,7 +13285,7 @@ var BaseDocumentDriveServer = class {
13255
13285
  });
13256
13286
  }
13257
13287
  }).catch((error2) => {
13258
- logger.error("Non handled error updating sync revision", error2);
13288
+ this.logger.error("Non handled error updating sync revision", error2);
13259
13289
  this.synchronizationManager.updateSyncStatus(driveId, {
13260
13290
  [operationSource]: "ERROR"
13261
13291
  }, error2);
@@ -13357,9 +13387,26 @@ var BaseDocumentDriveServer = class {
13357
13387
  scope: strand.scope,
13358
13388
  branch: strand.branch
13359
13389
  }));
13360
- const result = await (!strand.documentId ? this.queueDriveOperations(strand.driveId, operations, { source }) : this.queueOperations(strand.driveId, strand.documentId, operations, {
13361
- source
13362
- }));
13390
+ let result;
13391
+ if (strand.documentId) {
13392
+ try {
13393
+ result = await this.queueOperations(strand.driveId, strand.documentId, operations, {
13394
+ source
13395
+ });
13396
+ } catch (error) {
13397
+ this.logger.error("Error queueing operations", error);
13398
+ throw error;
13399
+ }
13400
+ } else {
13401
+ try {
13402
+ result = await this.queueDriveOperations(strand.driveId, operations, {
13403
+ source
13404
+ });
13405
+ } catch (error) {
13406
+ this.logger.error("Error queueing operations", error);
13407
+ throw error;
13408
+ }
13409
+ }
13363
13410
  if (result.status === "ERROR") {
13364
13411
  const syncUnits = strand.documentId !== "" ? (await this.getSynchronizationUnitsIds(strand.driveId, [strand.documentId], [strand.scope], [strand.branch])).map((s) => s.syncId) : [strand.driveId];
13365
13412
  const operationSource = this.getOperationSource(source);
@@ -13531,11 +13578,10 @@ var ListenerManager = class _ListenerManager {
13531
13578
  throw new Error("Maximum retries exhausted.");
13532
13579
  }
13533
13580
  const listenerUpdates = [];
13534
- for (const [driveId, drive] of this.listenerStateByDriveId) {
13535
- for (const [listenerId, listenerState] of drive) {
13581
+ for (const [driveId, listenerStateById] of this.listenerStateByDriveId) {
13582
+ for (const [listenerId, listenerState] of listenerStateById) {
13536
13583
  const transmitter = listenerState.listener.transmitter;
13537
13584
  if (!transmitter?.transmit) {
13538
- this.logger.verbose(`Transmitter not set on listener: ${listenerId}`);
13539
13585
  continue;
13540
13586
  }
13541
13587
  const syncUnits = await this.getListenerSyncUnits(driveId, listenerId);
@@ -13829,18 +13875,26 @@ var SynchronizationManager = class {
13829
13875
  const drive = await this.getDrive(driveId);
13830
13876
  const revisions = await this.storage.getSynchronizationUnitsRevision(syncUnitsQuery);
13831
13877
  this.logger.verbose(`getSynchronizationUnitsRevision: ${JSON.stringify(revisions)}`);
13832
- return syncUnitsQuery.map((s) => ({
13878
+ const synchronizationUnits = syncUnitsQuery.map((s) => ({
13833
13879
  ...s,
13834
13880
  lastUpdated: drive.created,
13835
- revision: revisions.find((r) => r.documentId === s.documentId && r.scope === s.scope && r.branch === s.branch)?.revision ?? -1
13881
+ revision: -1
13836
13882
  }));
13883
+ for (const revision of revisions) {
13884
+ const syncUnit = synchronizationUnits.find((s) => revision.documentId === s.documentId && revision.scope === s.scope && revision.branch === s.branch);
13885
+ if (syncUnit) {
13886
+ syncUnit.revision = revision.revision;
13887
+ syncUnit.lastUpdated = revision.lastUpdated;
13888
+ }
13889
+ }
13890
+ return synchronizationUnits;
13837
13891
  }
13838
13892
  async getSynchronizationUnitsIds(driveId, documentId, scope, branch, documentType2) {
13839
13893
  const drive = await this.getDrive(driveId);
13840
13894
  const nodes = drive.state.global.nodes.filter((node) => isFileNode(node) && (!documentId?.length || documentId.includes(node.id) || documentId.includes("*")) && (!documentType2?.length || documentType2.includes(node.documentType) || documentType2.includes("*")));
13841
13895
  if ((!documentId || documentId.includes("*") || documentId.includes("")) && (!documentType2?.length || documentType2.includes("powerhouse/document-drive") || documentType2.includes("*"))) {
13842
13896
  nodes.unshift({
13843
- id: drive.state.global.id,
13897
+ id: driveId,
13844
13898
  documentType: "powerhouse/document-drive",
13845
13899
  synchronizationUnits: [
13846
13900
  {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDriveActions
3
- } from "./chunk-ZWFCVUBU.js";
3
+ } from "./chunk-5QJXNK35.js";
4
4
  import {
5
5
  useDriveContext
6
6
  } from "./chunk-XBTEGV5M.js";
@@ -3,10 +3,10 @@ import {
3
3
  ReadModeContext,
4
4
  ReadModeContextProvider,
5
5
  useReadModeContext
6
- } from "../chunk-YSOX63EM.js";
6
+ } from "../chunk-3C54663M.js";
7
7
  import "../chunk-OVGOA2P5.js";
8
8
  import "../chunk-P6NJ6IAQ.js";
9
- import "../chunk-64UP3MVE.js";
9
+ import "../chunk-SQ5HIKYV.js";
10
10
  import "../chunk-FQF4YAVC.js";
11
11
  import "../chunk-2ESYSVXG.js";
12
12
  export {
@@ -2,10 +2,10 @@ import {
2
2
  ReadModeContext,
3
3
  ReadModeContextProvider,
4
4
  useReadModeContext
5
- } from "../chunk-YSOX63EM.js";
5
+ } from "../chunk-3C54663M.js";
6
6
  import "../chunk-OVGOA2P5.js";
7
7
  import "../chunk-P6NJ6IAQ.js";
8
- import "../chunk-64UP3MVE.js";
8
+ import "../chunk-SQ5HIKYV.js";
9
9
  import "../chunk-FQF4YAVC.js";
10
10
  import "../chunk-2ESYSVXG.js";
11
11
  export {