@powerhousedao/connect 1.0.3-dev.0 → 1.0.4-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.
- package/LICENSE +661 -0
- package/dist/assets/{app-D9QJBr8i.css → app-CcH3qGge.css} +213 -60
- package/dist/assets/{app-BYkaiTES.js → app-CrkKw3iM.js} +2100 -1018
- package/dist/assets/{app-loader-Bnp0H-wa.css → app-loader-DGByWxSG.css} +165 -22
- package/dist/assets/{app-loader-Bkg_WUos.js → app-loader-UcJ4Us8H.js} +438 -294
- package/dist/assets/{ccip-Dn5Ob09y.js → ccip-By_pxEiI.js} +3 -3
- package/dist/assets/{content-DcF7YyCb.js → content-Cztr255I.js} +36 -6
- package/dist/assets/{index-zVQzC6z2.js → index-CIzDiBJQ.js} +4 -4
- package/dist/assets/{index-B62Phyap.js → index-DL-uHasR.js} +3 -3
- package/dist/assets/{index-CBIcU4C0.js → index-vxDIqVse.js} +670 -519
- package/dist/assets/{main.CgKmK6gL.js → main.b7W0Jdwz.js} +1 -1
- package/dist/assets/{style-D4JhTt_m.css → style-Ce3V83BE.css} +31 -36
- package/dist/hmr.js +1 -1
- package/dist/index.html +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-G6LMXRY5.js → chunk-2ONJ2PX4.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-XXFOSD4A.js → chunk-4GNNWOQN.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-PQ4UODLR.js → chunk-AEE452AO.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-FW7N6EJH.js → chunk-C7QRY43M.js} +3 -3
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-45DCPCA7.js → chunk-CO2RVWYY.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-YDERCA5J.js → chunk-N7NRLUYA.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-F3RCGUF6.js → chunk-NHD6VUCD.js} +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-UP4DC4D2.js → chunk-Q5MVFG2N.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-M2UUQ5LH.js → chunk-U34SEKEB.js} +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-A4GIWVYS.js → chunk-ZZIQ3KGW.js} +322 -183
- package/dist/modules/@powerhousedao/reactor-browser/context/index.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/context/read-mode.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +8 -8
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useAddDebouncedOperations.js +3 -3
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useConnectCrypto.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentDrives.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentEditor.js +5 -5
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActions.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes.js +3 -3
- package/dist/modules/@powerhousedao/reactor-browser/index.js +10 -10
- package/dist/modules/@powerhousedao/reactor-browser/reactor.js +2 -2
- package/dist/vite-envs.sh +1 -1
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-CrkKw3iM.js","assets/main.b7W0Jdwz.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.
|
|
14
|
+
import { _ as __vitePreload } from "./main.b7W0Jdwz.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) {
|
|
@@ -22530,8 +22530,18 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
|
|
|
22530
22530
|
this.logger.verbose(`constructor(listener: ${listener.listenerId})`);
|
|
22531
22531
|
}
|
|
22532
22532
|
getStrands(options) {
|
|
22533
|
-
this.logger.verbose(`getStrands
|
|
22534
|
-
return this.manager.getStrands(this.listener.driveId, this.listener.listenerId, options)
|
|
22533
|
+
this.logger.verbose(`[SYNC DEBUG] PullResponderTransmitter.getStrands called for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}, options: ${JSON.stringify(options || {})}`);
|
|
22534
|
+
return this.manager.getStrands(this.listener.driveId, this.listener.listenerId, options).then((strands) => {
|
|
22535
|
+
this.logger.verbose(`[SYNC DEBUG] PullResponderTransmitter.getStrands returning ${strands.length} strands for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}`);
|
|
22536
|
+
if (strands.length === 0) {
|
|
22537
|
+
this.logger.verbose(`[SYNC DEBUG] No strands returned for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}`);
|
|
22538
|
+
} else {
|
|
22539
|
+
for (const strand of strands) {
|
|
22540
|
+
this.logger.verbose(`[SYNC DEBUG] Strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, operations: ${strand.operations.length}`);
|
|
22541
|
+
}
|
|
22542
|
+
}
|
|
22543
|
+
return strands;
|
|
22544
|
+
});
|
|
22535
22545
|
}
|
|
22536
22546
|
disconnect() {
|
|
22537
22547
|
return Promise.resolve();
|
|
@@ -22572,7 +22582,7 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
|
|
|
22572
22582
|
}
|
|
22573
22583
|
static async pullStrands(driveId, url, listenerId, options) {
|
|
22574
22584
|
var _a2;
|
|
22575
|
-
this.staticLogger.verbose(`pullStrands
|
|
22585
|
+
this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${driveId}, url: ${url}, listener: ${listenerId}, options: ${JSON.stringify(options || {})}`);
|
|
22576
22586
|
const result = await requestGraphql(url, gql`
|
|
22577
22587
|
query strands($listenerId: ID!) {
|
|
22578
22588
|
system {
|
|
@@ -22612,18 +22622,25 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
|
|
|
22612
22622
|
`, { listenerId });
|
|
22613
22623
|
const error = (_a2 = result.errors) == null ? void 0 : _a2.at(0);
|
|
22614
22624
|
if (error) {
|
|
22625
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Error pulling strands for drive: ${driveId}, listener: ${listenerId}, error: ${JSON.stringify(error)}`);
|
|
22615
22626
|
throw error;
|
|
22616
22627
|
}
|
|
22617
22628
|
if (!result.system) {
|
|
22629
|
+
this.staticLogger.verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${driveId}, listener: ${listenerId}`);
|
|
22618
22630
|
return [];
|
|
22619
22631
|
}
|
|
22620
|
-
|
|
22632
|
+
const strands = result.system.sync.strands.map((s) => ({
|
|
22621
22633
|
...s,
|
|
22622
22634
|
operations: s.operations.map((o) => ({
|
|
22623
22635
|
...o,
|
|
22624
22636
|
input: JSON.parse(o.input)
|
|
22625
22637
|
}))
|
|
22626
22638
|
}));
|
|
22639
|
+
this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${strands.length} strands for drive: ${driveId}, listener: ${listenerId}`);
|
|
22640
|
+
if (strands.length > 0) {
|
|
22641
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Strands being returned: ${strands.map((s) => `${s.documentId}:${s.scope}`).join(", ")}`);
|
|
22642
|
+
}
|
|
22643
|
+
return strands;
|
|
22627
22644
|
}
|
|
22628
22645
|
static async acknowledgeStrands(url, listenerId, revisions) {
|
|
22629
22646
|
this.staticLogger.verbose(`acknowledgeStrands(url: ${url}, listener: ${listenerId})`, revisions);
|
|
@@ -22657,75 +22674,124 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
|
|
|
22657
22674
|
throw new Error("Error acknowledging strands");
|
|
22658
22675
|
}
|
|
22659
22676
|
}
|
|
22677
|
+
/**
|
|
22678
|
+
* This function will only throw if `onError` throws an error (or there is
|
|
22679
|
+
* an unintentionally unhandled error in the pull loop).
|
|
22680
|
+
*
|
|
22681
|
+
* All other errors are caught, logged, and passed to `onError`.
|
|
22682
|
+
*
|
|
22683
|
+
* Because of this, `onError` _may be called multiple times_.
|
|
22684
|
+
*/
|
|
22660
22685
|
static async executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
|
|
22661
22686
|
var _a2;
|
|
22662
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}`);
|
|
22689
|
+
const { url } = trigger.data;
|
|
22690
|
+
let strands;
|
|
22691
|
+
let error;
|
|
22663
22692
|
try {
|
|
22664
|
-
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
|
|
22668
|
-
|
|
22669
|
-
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
let error = void 0;
|
|
22681
|
-
try {
|
|
22682
|
-
const result = await onStrandUpdate(strand, {
|
|
22683
|
-
type: "trigger",
|
|
22684
|
-
trigger
|
|
22685
|
-
});
|
|
22686
|
-
if (result.error) {
|
|
22687
|
-
throw result.error;
|
|
22693
|
+
strands = await _PullResponderTransmitter.pullStrands(driveId, url, trigger.data.listenerId);
|
|
22694
|
+
} catch (e) {
|
|
22695
|
+
error = e;
|
|
22696
|
+
const errors = error.response.errors;
|
|
22697
|
+
for (const error2 of errors) {
|
|
22698
|
+
if (error2.message === "Listener not found") {
|
|
22699
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${driveId}`);
|
|
22700
|
+
const listenerId = await _PullResponderTransmitter.registerPullResponder(trigger.driveId, url, trigger.filter);
|
|
22701
|
+
trigger.data.listenerId = listenerId;
|
|
22702
|
+
try {
|
|
22703
|
+
strands = await _PullResponderTransmitter.pullStrands(driveId, url, listenerId);
|
|
22704
|
+
this.staticLogger.verbose(`Successfully auto-registerd and pulled strands for drive: ${driveId}, listenerId: ${listenerId}`);
|
|
22705
|
+
} catch (error3) {
|
|
22706
|
+
this.staticLogger.error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${driveId}, listenerId: ${listenerId}: ${error3}`);
|
|
22707
|
+
onError(error3);
|
|
22708
|
+
return;
|
|
22688
22709
|
}
|
|
22689
|
-
|
|
22690
|
-
error = e;
|
|
22691
|
-
onError(error);
|
|
22710
|
+
break;
|
|
22692
22711
|
}
|
|
22693
|
-
listenerRevisions.push({
|
|
22694
|
-
branch: strand.branch,
|
|
22695
|
-
documentId: strand.documentId || "",
|
|
22696
|
-
driveId: strand.driveId,
|
|
22697
|
-
revision: ((_a2 = operations.pop()) == null ? void 0 : _a2.index) ?? -1,
|
|
22698
|
-
scope: strand.scope,
|
|
22699
|
-
status: error ? error instanceof OperationError ? error.status : "ERROR" : "SUCCESS",
|
|
22700
|
-
error
|
|
22701
|
-
});
|
|
22702
22712
|
}
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
this.staticLogger.
|
|
22706
|
-
|
|
22713
|
+
}
|
|
22714
|
+
if (!strands) {
|
|
22715
|
+
this.staticLogger.error(`Error pulling strands for drive, and could not auto-register: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
|
|
22716
|
+
onError(error);
|
|
22717
|
+
return;
|
|
22718
|
+
}
|
|
22719
|
+
if (!strands.length) {
|
|
22720
|
+
this.staticLogger.verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22707
22721
|
try {
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
success = true;
|
|
22713
|
-
} catch (error) {
|
|
22714
|
-
this.staticLogger.error("ACK error", error);
|
|
22715
|
-
}
|
|
22716
|
-
if (success) {
|
|
22717
|
-
this.staticLogger.verbose("Acknowledged strands successfully.");
|
|
22718
|
-
} else {
|
|
22719
|
-
this.staticLogger.error("Failed to acknowledge strands");
|
|
22722
|
+
onRevisions == null ? void 0 : onRevisions([]);
|
|
22723
|
+
} catch (error2) {
|
|
22724
|
+
this.staticLogger.error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
|
|
22725
|
+
onError(error2);
|
|
22720
22726
|
}
|
|
22727
|
+
return;
|
|
22728
|
+
}
|
|
22729
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Processing ${strands.length} strands in pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22730
|
+
const listenerRevisions = [];
|
|
22731
|
+
for (const strand of strands) {
|
|
22732
|
+
const operations = strand.operations.map((op) => ({
|
|
22733
|
+
...op,
|
|
22734
|
+
scope: strand.scope,
|
|
22735
|
+
branch: strand.branch
|
|
22736
|
+
}));
|
|
22737
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations`);
|
|
22738
|
+
let error2 = void 0;
|
|
22739
|
+
try {
|
|
22740
|
+
const result = await onStrandUpdate(strand, {
|
|
22741
|
+
type: "trigger",
|
|
22742
|
+
trigger
|
|
22743
|
+
});
|
|
22744
|
+
if (result.error) {
|
|
22745
|
+
throw result.error;
|
|
22746
|
+
}
|
|
22747
|
+
} catch (e) {
|
|
22748
|
+
this.staticLogger.error(`Error processing strand for drive: ${strand.driveId}, document: ${strand.documentId}, scope: ${strand.scope}, with ${operations.length} operations: ${e}`);
|
|
22749
|
+
error2 = e;
|
|
22750
|
+
onError(error2);
|
|
22751
|
+
}
|
|
22752
|
+
listenerRevisions.push({
|
|
22753
|
+
branch: strand.branch,
|
|
22754
|
+
documentId: strand.documentId || "",
|
|
22755
|
+
driveId: strand.driveId,
|
|
22756
|
+
revision: ((_a2 = operations.pop()) == null ? void 0 : _a2.index) ?? -1,
|
|
22757
|
+
scope: strand.scope,
|
|
22758
|
+
status: error2 ? error2 instanceof OperationError ? error2.status : "ERROR" : "SUCCESS",
|
|
22759
|
+
error: error2
|
|
22760
|
+
});
|
|
22761
|
+
}
|
|
22762
|
+
this.staticLogger.verbose("Processed strands...");
|
|
22763
|
+
try {
|
|
22764
|
+
onRevisions == null ? void 0 : onRevisions(listenerRevisions);
|
|
22765
|
+
} catch (error2) {
|
|
22766
|
+
this.staticLogger.error(`Error calling onRevisions for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
|
|
22767
|
+
onError(error2);
|
|
22768
|
+
}
|
|
22769
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Acknowledging ${listenerRevisions.length} strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22770
|
+
let success = false;
|
|
22771
|
+
try {
|
|
22772
|
+
await _PullResponderTransmitter.acknowledgeStrands(url, trigger.data.listenerId, listenerRevisions.map((revision) => {
|
|
22773
|
+
const { error: error2, ...rest } = revision;
|
|
22774
|
+
return rest;
|
|
22775
|
+
}));
|
|
22776
|
+
success = true;
|
|
22777
|
+
} catch (error2) {
|
|
22778
|
+
this.staticLogger.error(`Error acknowledging strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
|
|
22779
|
+
onError(error2);
|
|
22780
|
+
}
|
|
22781
|
+
if (success) {
|
|
22782
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22783
|
+
} else {
|
|
22784
|
+
this.staticLogger.error("Failed to acknowledge strands");
|
|
22785
|
+
}
|
|
22786
|
+
try {
|
|
22721
22787
|
onAcknowledge == null ? void 0 : onAcknowledge(success);
|
|
22722
|
-
} catch (
|
|
22723
|
-
this.staticLogger.error(
|
|
22724
|
-
onError(
|
|
22788
|
+
} catch (error2) {
|
|
22789
|
+
this.staticLogger.error(`Error calling onAcknowledge for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error2}`);
|
|
22790
|
+
onError(error2);
|
|
22725
22791
|
}
|
|
22726
22792
|
}
|
|
22727
22793
|
static setupPull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
|
|
22728
|
-
this.staticLogger.verbose(`setupPull
|
|
22794
|
+
this.staticLogger.verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22729
22795
|
const { interval } = trigger.data;
|
|
22730
22796
|
let loopInterval = PULL_DRIVE_INTERVAL;
|
|
22731
22797
|
if (interval) {
|
|
@@ -22737,20 +22803,25 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
|
|
|
22737
22803
|
} catch {
|
|
22738
22804
|
}
|
|
22739
22805
|
}
|
|
22806
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Pull interval set to ${loopInterval}ms for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22740
22807
|
let isCancelled = false;
|
|
22741
22808
|
let timeout;
|
|
22742
22809
|
const executeLoop = async () => {
|
|
22743
22810
|
while (!isCancelled) {
|
|
22744
|
-
this.staticLogger.verbose(
|
|
22811
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22745
22812
|
await this.executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge);
|
|
22813
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${driveId}, listenerId: ${trigger.data.listenerId}, waiting ${loopInterval}ms for next cycle`);
|
|
22746
22814
|
await new Promise((resolve) => {
|
|
22747
22815
|
this.staticLogger.verbose(`Scheduling next pull in ${loopInterval} ms`);
|
|
22748
22816
|
timeout = setTimeout(resolve, loopInterval);
|
|
22749
22817
|
});
|
|
22750
22818
|
}
|
|
22751
22819
|
};
|
|
22752
|
-
executeLoop().catch(
|
|
22820
|
+
executeLoop().catch((error) => {
|
|
22821
|
+
this.staticLogger.error(`Error in executeLoop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}: ${error}`);
|
|
22822
|
+
});
|
|
22753
22823
|
return () => {
|
|
22824
|
+
this.staticLogger.verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
|
|
22754
22825
|
isCancelled = true;
|
|
22755
22826
|
if (timeout !== void 0) {
|
|
22756
22827
|
clearTimeout(timeout);
|
|
@@ -22760,15 +22831,18 @@ const _PullResponderTransmitter = class _PullResponderTransmitter {
|
|
|
22760
22831
|
static async createPullResponderTrigger(driveId, url, options) {
|
|
22761
22832
|
this.staticLogger.verbose(`createPullResponderTrigger(drive: ${driveId}, url: ${url})`);
|
|
22762
22833
|
const { pullFilter, pullInterval } = options;
|
|
22763
|
-
const
|
|
22834
|
+
const filter = pullFilter ?? {
|
|
22764
22835
|
documentId: ["*"],
|
|
22765
22836
|
documentType: ["*"],
|
|
22766
22837
|
branch: ["*"],
|
|
22767
22838
|
scope: ["*"]
|
|
22768
|
-
}
|
|
22839
|
+
};
|
|
22840
|
+
const listenerId = await _PullResponderTransmitter.registerPullResponder(driveId, url, filter);
|
|
22769
22841
|
const pullTrigger = {
|
|
22770
22842
|
id: generateUUID(),
|
|
22771
22843
|
type: "PullResponder",
|
|
22844
|
+
driveId,
|
|
22845
|
+
filter,
|
|
22772
22846
|
data: {
|
|
22773
22847
|
url,
|
|
22774
22848
|
listenerId,
|
|
@@ -22786,6 +22860,187 @@ __publicField(_PullResponderTransmitter, "staticLogger", childLogger([
|
|
|
22786
22860
|
"static"
|
|
22787
22861
|
]));
|
|
22788
22862
|
let PullResponderTransmitter = _PullResponderTransmitter;
|
|
22863
|
+
var defaults;
|
|
22864
|
+
var hasRequiredDefaults;
|
|
22865
|
+
function requireDefaults() {
|
|
22866
|
+
if (hasRequiredDefaults) return defaults;
|
|
22867
|
+
hasRequiredDefaults = 1;
|
|
22868
|
+
defaults = {
|
|
22869
|
+
space: "",
|
|
22870
|
+
cycles: false,
|
|
22871
|
+
replacer: (k, v) => v,
|
|
22872
|
+
stringify: JSON.stringify
|
|
22873
|
+
};
|
|
22874
|
+
return defaults;
|
|
22875
|
+
}
|
|
22876
|
+
var util;
|
|
22877
|
+
var hasRequiredUtil;
|
|
22878
|
+
function requireUtil() {
|
|
22879
|
+
if (hasRequiredUtil) return util;
|
|
22880
|
+
hasRequiredUtil = 1;
|
|
22881
|
+
util = {
|
|
22882
|
+
isArray: Array.isArray,
|
|
22883
|
+
assign: Object.assign,
|
|
22884
|
+
isObject: (v) => typeof v === "object",
|
|
22885
|
+
isFunction: (v) => typeof v === "function",
|
|
22886
|
+
isBoolean: (v) => typeof v === "boolean",
|
|
22887
|
+
isRegex: (v) => v instanceof RegExp,
|
|
22888
|
+
keys: Object.keys
|
|
22889
|
+
};
|
|
22890
|
+
return util;
|
|
22891
|
+
}
|
|
22892
|
+
var lib;
|
|
22893
|
+
var hasRequiredLib;
|
|
22894
|
+
function requireLib() {
|
|
22895
|
+
if (hasRequiredLib) return lib;
|
|
22896
|
+
hasRequiredLib = 1;
|
|
22897
|
+
const DEFAULTS = requireDefaults();
|
|
22898
|
+
const isFunction = requireUtil().isFunction;
|
|
22899
|
+
const isBoolean = requireUtil().isBoolean;
|
|
22900
|
+
const isObject = requireUtil().isObject;
|
|
22901
|
+
const isArray = requireUtil().isArray;
|
|
22902
|
+
const isRegex = requireUtil().isRegex;
|
|
22903
|
+
const assign = requireUtil().assign;
|
|
22904
|
+
const keys = requireUtil().keys;
|
|
22905
|
+
function serialize(obj) {
|
|
22906
|
+
if (obj === null || obj === void 0) return obj;
|
|
22907
|
+
if (isRegex(obj)) return obj.toString();
|
|
22908
|
+
return obj.toJSON ? obj.toJSON() : obj;
|
|
22909
|
+
}
|
|
22910
|
+
function stringifyDeterministic(obj, opts) {
|
|
22911
|
+
opts = opts || assign({}, DEFAULTS);
|
|
22912
|
+
if (isFunction(opts)) opts = { compare: opts };
|
|
22913
|
+
const space = opts.space || DEFAULTS.space;
|
|
22914
|
+
const cycles = isBoolean(opts.cycles) ? opts.cycles : DEFAULTS.cycles;
|
|
22915
|
+
const replacer = opts.replacer || DEFAULTS.replacer;
|
|
22916
|
+
const stringify2 = opts.stringify || DEFAULTS.stringify;
|
|
22917
|
+
const compare = opts.compare && /* @__PURE__ */ function(f) {
|
|
22918
|
+
return function(node) {
|
|
22919
|
+
return function(a, b) {
|
|
22920
|
+
const aobj = { key: a, value: node[a] };
|
|
22921
|
+
const bobj = { key: b, value: node[b] };
|
|
22922
|
+
return f(aobj, bobj);
|
|
22923
|
+
};
|
|
22924
|
+
};
|
|
22925
|
+
}(opts.compare);
|
|
22926
|
+
if (!cycles) stringify2(obj);
|
|
22927
|
+
const seen = [];
|
|
22928
|
+
return function _deterministic(parent, key, node, level) {
|
|
22929
|
+
const indent2 = space ? "\n" + new Array(level + 1).join(space) : "";
|
|
22930
|
+
const colonSeparator = space ? ": " : ":";
|
|
22931
|
+
node = serialize(node);
|
|
22932
|
+
node = replacer.call(parent, key, node);
|
|
22933
|
+
if (node === void 0) return;
|
|
22934
|
+
if (!isObject(node) || node === null) return stringify2(node);
|
|
22935
|
+
if (isArray(node)) {
|
|
22936
|
+
const out = [];
|
|
22937
|
+
for (let i = 0; i < node.length; i++) {
|
|
22938
|
+
const item = _deterministic(node, i, node[i], level + 1) || stringify2(null);
|
|
22939
|
+
out.push(indent2 + space + item);
|
|
22940
|
+
}
|
|
22941
|
+
return "[" + out.join(",") + indent2 + "]";
|
|
22942
|
+
} else {
|
|
22943
|
+
if (cycles) {
|
|
22944
|
+
if (seen.indexOf(node) !== -1) {
|
|
22945
|
+
return stringify2("[Circular]");
|
|
22946
|
+
} else {
|
|
22947
|
+
seen.push(node);
|
|
22948
|
+
}
|
|
22949
|
+
}
|
|
22950
|
+
const nodeKeys = keys(node).sort(compare && compare(node));
|
|
22951
|
+
const out = [];
|
|
22952
|
+
for (let i = 0; i < nodeKeys.length; i++) {
|
|
22953
|
+
const key2 = nodeKeys[i];
|
|
22954
|
+
const value = _deterministic(node, key2, node[key2], level + 1);
|
|
22955
|
+
if (!value) continue;
|
|
22956
|
+
const keyValue = stringify2(key2) + colonSeparator + value;
|
|
22957
|
+
out.push(indent2 + space + keyValue);
|
|
22958
|
+
}
|
|
22959
|
+
seen.splice(seen.indexOf(node), 1);
|
|
22960
|
+
return "{" + out.join(",") + indent2 + "}";
|
|
22961
|
+
}
|
|
22962
|
+
}({ "": obj }, "", obj, 0);
|
|
22963
|
+
}
|
|
22964
|
+
lib = stringifyDeterministic;
|
|
22965
|
+
return lib;
|
|
22966
|
+
}
|
|
22967
|
+
var libExports = requireLib();
|
|
22968
|
+
const stringify = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
22969
|
+
const SYNC_OPS_BATCH_LIMIT = 10;
|
|
22970
|
+
class SwitchboardPushTransmitter {
|
|
22971
|
+
constructor(targetURL) {
|
|
22972
|
+
__publicField(this, "targetURL");
|
|
22973
|
+
__publicField(this, "logger", childLogger([
|
|
22974
|
+
"SwitchboardPushTransmitter",
|
|
22975
|
+
Math.floor(Math.random() * 999).toString()
|
|
22976
|
+
]));
|
|
22977
|
+
this.targetURL = targetURL;
|
|
22978
|
+
}
|
|
22979
|
+
async transmit(strands, source) {
|
|
22980
|
+
var _a2;
|
|
22981
|
+
if (source.type === "trigger" && ((_a2 = source.trigger.data) == null ? void 0 : _a2.url) === this.targetURL) {
|
|
22982
|
+
this.logger.verbose(`Cutting trigger loop from ${this.targetURL}.`);
|
|
22983
|
+
return strands.map((strand) => {
|
|
22984
|
+
var _a3;
|
|
22985
|
+
return {
|
|
22986
|
+
driveId: strand.driveId,
|
|
22987
|
+
documentId: strand.documentId,
|
|
22988
|
+
scope: strand.scope,
|
|
22989
|
+
branch: strand.branch,
|
|
22990
|
+
status: "SUCCESS",
|
|
22991
|
+
revision: ((_a3 = strand.operations.at(-1)) == null ? void 0 : _a3.index) ?? -1
|
|
22992
|
+
};
|
|
22993
|
+
});
|
|
22994
|
+
}
|
|
22995
|
+
const culledStrands = [];
|
|
22996
|
+
let opsCounter = 0;
|
|
22997
|
+
for (let s = 0; opsCounter <= SYNC_OPS_BATCH_LIMIT && s < strands.length; s++) {
|
|
22998
|
+
const currentStrand = strands.at(s);
|
|
22999
|
+
if (!currentStrand) {
|
|
23000
|
+
break;
|
|
23001
|
+
}
|
|
23002
|
+
const newOps = Math.min(SYNC_OPS_BATCH_LIMIT - opsCounter, currentStrand.operations.length);
|
|
23003
|
+
culledStrands.push({
|
|
23004
|
+
...currentStrand,
|
|
23005
|
+
operations: currentStrand.operations.slice(0, newOps)
|
|
23006
|
+
});
|
|
23007
|
+
opsCounter += newOps;
|
|
23008
|
+
}
|
|
23009
|
+
this.logger.verbose(` Total update: [${strands.map((s) => s.operations.length).join(", ")}] operations`);
|
|
23010
|
+
this.logger.verbose(`Culled update: [${culledStrands.map((s) => s.operations.length).join(", ")}] operations`);
|
|
23011
|
+
try {
|
|
23012
|
+
const { pushUpdates } = await requestGraphql(this.targetURL, gql`
|
|
23013
|
+
mutation pushUpdates($strands: [InputStrandUpdate!]) {
|
|
23014
|
+
pushUpdates(strands: $strands) {
|
|
23015
|
+
driveId
|
|
23016
|
+
documentId
|
|
23017
|
+
scope
|
|
23018
|
+
branch
|
|
23019
|
+
status
|
|
23020
|
+
revision
|
|
23021
|
+
error
|
|
23022
|
+
}
|
|
23023
|
+
}
|
|
23024
|
+
`, {
|
|
23025
|
+
strands: culledStrands.map((strand) => ({
|
|
23026
|
+
...strand,
|
|
23027
|
+
operations: strand.operations.map((op) => ({
|
|
23028
|
+
...op,
|
|
23029
|
+
input: stringify(op.input)
|
|
23030
|
+
}))
|
|
23031
|
+
}))
|
|
23032
|
+
});
|
|
23033
|
+
if (!pushUpdates) {
|
|
23034
|
+
throw new Error("Couldn't update listener revision");
|
|
23035
|
+
}
|
|
23036
|
+
return pushUpdates;
|
|
23037
|
+
} catch (e) {
|
|
23038
|
+
this.logger.error(e);
|
|
23039
|
+
throw e;
|
|
23040
|
+
}
|
|
23041
|
+
return [];
|
|
23042
|
+
}
|
|
23043
|
+
}
|
|
22789
23044
|
var TransmitterType;
|
|
22790
23045
|
(function(TransmitterType2) {
|
|
22791
23046
|
TransmitterType2[TransmitterType2["Internal"] = 0] = "Internal";
|
|
@@ -23019,11 +23274,41 @@ class BaseDocumentDriveServer {
|
|
|
23019
23274
|
return this.triggerMap.delete(driveId);
|
|
23020
23275
|
}
|
|
23021
23276
|
async _initializeDrive(driveId) {
|
|
23277
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
23022
23278
|
const drive = await this.getDrive(driveId);
|
|
23279
|
+
logger$1.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.state.global.slug}"`);
|
|
23023
23280
|
await this.synchronizationManager.initializeDriveSyncStatus(driveId, drive);
|
|
23024
23281
|
if (this.shouldSyncRemoteDrive(drive)) {
|
|
23282
|
+
logger$1.verbose(`[SYNC DEBUG] Starting sync for remote drive ${driveId}`);
|
|
23025
23283
|
await this.startSyncRemoteDrive(driveId);
|
|
23026
23284
|
}
|
|
23285
|
+
logger$1.verbose(`[SYNC DEBUG] Processing ${drive.state.local.listeners.length} listeners for drive ${driveId}`);
|
|
23286
|
+
for (const zodListener of drive.state.local.listeners) {
|
|
23287
|
+
if (((_a2 = zodListener.callInfo) == null ? void 0 : _a2.transmitterType) === "SwitchboardPush") {
|
|
23288
|
+
logger$1.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${zodListener.listenerId} for drive ${driveId}`);
|
|
23289
|
+
const transmitter = new SwitchboardPushTransmitter(((_b = zodListener.callInfo) == null ? void 0 : _b.data) ?? "");
|
|
23290
|
+
logger$1.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${((_c = zodListener.callInfo) == null ? void 0 : _c.data) || "none"}`);
|
|
23291
|
+
await this.listenerManager.setListener(driveId, {
|
|
23292
|
+
block: zodListener.block,
|
|
23293
|
+
driveId: drive.state.global.id,
|
|
23294
|
+
filter: {
|
|
23295
|
+
branch: ((_d = zodListener.filter) == null ? void 0 : _d.branch) ?? [],
|
|
23296
|
+
documentId: ((_e = zodListener.filter) == null ? void 0 : _e.documentId) ?? [],
|
|
23297
|
+
documentType: ((_f = zodListener.filter) == null ? void 0 : _f.documentType) ?? [],
|
|
23298
|
+
scope: ((_g = zodListener.filter) == null ? void 0 : _g.scope) ?? []
|
|
23299
|
+
},
|
|
23300
|
+
listenerId: zodListener.listenerId,
|
|
23301
|
+
callInfo: zodListener.callInfo,
|
|
23302
|
+
system: zodListener.system,
|
|
23303
|
+
label: zodListener.label ?? "",
|
|
23304
|
+
transmitter
|
|
23305
|
+
}).then(() => {
|
|
23306
|
+
logger$1.verbose(`[SYNC DEBUG] Successfully set up listener ${zodListener.listenerId} for drive ${driveId}`);
|
|
23307
|
+
});
|
|
23308
|
+
} else {
|
|
23309
|
+
logger$1.error(`Skipping listener ${zodListener.listenerId} with unsupported type ${((_h = zodListener.callInfo) == null ? void 0 : _h.transmitterType) || "unknown"}`);
|
|
23310
|
+
}
|
|
23311
|
+
}
|
|
23027
23312
|
}
|
|
23028
23313
|
// Delegate synchronization methods to synchronizationManager
|
|
23029
23314
|
getSynchronizationUnits(driveId, documentId, scope, branch, documentType2) {
|
|
@@ -24337,57 +24622,78 @@ const _ListenerManager = class _ListenerManager {
|
|
|
24337
24622
|
}
|
|
24338
24623
|
}
|
|
24339
24624
|
async getStrands(driveId, listenerId, options) {
|
|
24340
|
-
|
|
24625
|
+
this.logger.verbose(`[SYNC DEBUG] ListenerManager.getStrands called for drive: ${driveId}, listener: ${listenerId}, options: ${JSON.stringify(options || {})}`);
|
|
24626
|
+
let listenerState;
|
|
24627
|
+
try {
|
|
24628
|
+
listenerState = this.getListenerState(driveId, listenerId);
|
|
24629
|
+
this.logger.verbose(`[SYNC DEBUG] Found listener state for drive: ${driveId}, listener: ${listenerId}, status: ${listenerState.listenerStatus}`);
|
|
24630
|
+
} catch (error) {
|
|
24631
|
+
this.logger.error(`[SYNC DEBUG] Failed to find listener state for drive: ${driveId}, listener: ${listenerId}. Error: ${error}`);
|
|
24632
|
+
throw error;
|
|
24633
|
+
}
|
|
24341
24634
|
const strands = [];
|
|
24342
|
-
|
|
24343
|
-
|
|
24344
|
-
|
|
24345
|
-
|
|
24346
|
-
|
|
24347
|
-
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
|
-
|
|
24351
|
-
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
|
|
24356
|
-
|
|
24357
|
-
|
|
24358
|
-
|
|
24359
|
-
|
|
24360
|
-
|
|
24361
|
-
|
|
24362
|
-
{
|
|
24363
|
-
|
|
24364
|
-
|
|
24365
|
-
|
|
24635
|
+
try {
|
|
24636
|
+
const syncUnits = await this.getListenerSyncUnits(driveId, listenerId);
|
|
24637
|
+
this.logger.verbose(`[SYNC DEBUG] Retrieved ${syncUnits.length} sync units for drive: ${driveId}, listener: ${listenerId}`);
|
|
24638
|
+
const limit = options == null ? void 0 : options.limit;
|
|
24639
|
+
let operationsCount = 0;
|
|
24640
|
+
const tasks = syncUnits.map((syncUnit) => async () => {
|
|
24641
|
+
if (limit && operationsCount >= limit) {
|
|
24642
|
+
return;
|
|
24643
|
+
}
|
|
24644
|
+
if (syncUnit.revision < 0) {
|
|
24645
|
+
this.logger.verbose(`[SYNC DEBUG] Skipping sync unit with negative revision: ${syncUnit.syncId}, revision: ${syncUnit.revision}`);
|
|
24646
|
+
return;
|
|
24647
|
+
}
|
|
24648
|
+
const entry = listenerState.syncUnits.get(syncUnit.syncId);
|
|
24649
|
+
if (entry && entry.listenerRev >= syncUnit.revision) {
|
|
24650
|
+
this.logger.verbose(`[SYNC DEBUG] Skipping sync unit - listener already up to date: ${syncUnit.syncId}, listenerRev: ${entry.listenerRev}, revision: ${syncUnit.revision}`);
|
|
24651
|
+
return;
|
|
24652
|
+
}
|
|
24653
|
+
const { documentId, scope, branch } = syncUnit;
|
|
24654
|
+
try {
|
|
24655
|
+
this.logger.verbose(`[SYNC DEBUG] Getting operations for syncUnit: ${syncUnit.syncId}, documentId: ${documentId}, scope: ${scope}, branch: ${branch}`);
|
|
24656
|
+
const operations = await this.syncManager.getOperationData(
|
|
24657
|
+
// DEAL WITH INVALID SYNC ID ERROR
|
|
24658
|
+
driveId,
|
|
24659
|
+
syncUnit.syncId,
|
|
24660
|
+
{
|
|
24661
|
+
since: options == null ? void 0 : options.since,
|
|
24662
|
+
fromRevision: (options == null ? void 0 : options.fromRevision) ?? (entry == null ? void 0 : entry.listenerRev),
|
|
24663
|
+
limit: limit ? limit - operationsCount : void 0
|
|
24664
|
+
}
|
|
24665
|
+
);
|
|
24666
|
+
this.logger.verbose(`[SYNC DEBUG] Retrieved ${operations.length} operations for syncUnit: ${syncUnit.syncId}`);
|
|
24667
|
+
if (!operations.length) {
|
|
24668
|
+
return;
|
|
24366
24669
|
}
|
|
24367
|
-
|
|
24368
|
-
|
|
24670
|
+
operationsCount += operations.length;
|
|
24671
|
+
strands.push({
|
|
24672
|
+
driveId,
|
|
24673
|
+
documentId,
|
|
24674
|
+
scope,
|
|
24675
|
+
branch,
|
|
24676
|
+
operations
|
|
24677
|
+
});
|
|
24678
|
+
this.logger.verbose(`[SYNC DEBUG] Added strand with ${operations.length} operations for syncUnit: ${syncUnit.syncId}`);
|
|
24679
|
+
} catch (error) {
|
|
24680
|
+
this.logger.error(`Error getting operations for syncUnit: ${syncUnit.syncId}, error: ${error}`);
|
|
24369
24681
|
return;
|
|
24370
24682
|
}
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
});
|
|
24379
|
-
|
|
24380
|
-
this.logger.error(error);
|
|
24381
|
-
return;
|
|
24382
|
-
}
|
|
24383
|
-
});
|
|
24384
|
-
if (this.options.sequentialUpdates) {
|
|
24385
|
-
for (const task of tasks) {
|
|
24386
|
-
await task();
|
|
24683
|
+
});
|
|
24684
|
+
if (this.options.sequentialUpdates) {
|
|
24685
|
+
this.logger.verbose(`[SYNC DEBUG] Processing ${tasks.length} sync units sequentially`);
|
|
24686
|
+
for (const task of tasks) {
|
|
24687
|
+
await task();
|
|
24688
|
+
}
|
|
24689
|
+
} else {
|
|
24690
|
+
this.logger.verbose(`[SYNC DEBUG] Processing ${tasks.length} sync units in parallel`);
|
|
24691
|
+
await Promise.all(tasks.map((task) => task()));
|
|
24387
24692
|
}
|
|
24388
|
-
}
|
|
24389
|
-
|
|
24693
|
+
} catch (error) {
|
|
24694
|
+
this.logger.error(`Error in getStrands: ${error}`);
|
|
24390
24695
|
}
|
|
24696
|
+
this.logger.verbose(`ListenerManager.getStrands returning ${strands.length} strands for drive: ${driveId}, listener: ${listenerId}`);
|
|
24391
24697
|
return strands;
|
|
24392
24698
|
}
|
|
24393
24699
|
getListenerState(driveId, listenerId) {
|
|
@@ -24413,187 +24719,6 @@ const _ListenerManager = class _ListenerManager {
|
|
|
24413
24719
|
};
|
|
24414
24720
|
__publicField(_ListenerManager, "LISTENER_UPDATE_DELAY", 250);
|
|
24415
24721
|
let ListenerManager = _ListenerManager;
|
|
24416
|
-
var defaults;
|
|
24417
|
-
var hasRequiredDefaults;
|
|
24418
|
-
function requireDefaults() {
|
|
24419
|
-
if (hasRequiredDefaults) return defaults;
|
|
24420
|
-
hasRequiredDefaults = 1;
|
|
24421
|
-
defaults = {
|
|
24422
|
-
space: "",
|
|
24423
|
-
cycles: false,
|
|
24424
|
-
replacer: (k, v) => v,
|
|
24425
|
-
stringify: JSON.stringify
|
|
24426
|
-
};
|
|
24427
|
-
return defaults;
|
|
24428
|
-
}
|
|
24429
|
-
var util;
|
|
24430
|
-
var hasRequiredUtil;
|
|
24431
|
-
function requireUtil() {
|
|
24432
|
-
if (hasRequiredUtil) return util;
|
|
24433
|
-
hasRequiredUtil = 1;
|
|
24434
|
-
util = {
|
|
24435
|
-
isArray: Array.isArray,
|
|
24436
|
-
assign: Object.assign,
|
|
24437
|
-
isObject: (v) => typeof v === "object",
|
|
24438
|
-
isFunction: (v) => typeof v === "function",
|
|
24439
|
-
isBoolean: (v) => typeof v === "boolean",
|
|
24440
|
-
isRegex: (v) => v instanceof RegExp,
|
|
24441
|
-
keys: Object.keys
|
|
24442
|
-
};
|
|
24443
|
-
return util;
|
|
24444
|
-
}
|
|
24445
|
-
var lib;
|
|
24446
|
-
var hasRequiredLib;
|
|
24447
|
-
function requireLib() {
|
|
24448
|
-
if (hasRequiredLib) return lib;
|
|
24449
|
-
hasRequiredLib = 1;
|
|
24450
|
-
const DEFAULTS = requireDefaults();
|
|
24451
|
-
const isFunction = requireUtil().isFunction;
|
|
24452
|
-
const isBoolean = requireUtil().isBoolean;
|
|
24453
|
-
const isObject = requireUtil().isObject;
|
|
24454
|
-
const isArray = requireUtil().isArray;
|
|
24455
|
-
const isRegex = requireUtil().isRegex;
|
|
24456
|
-
const assign = requireUtil().assign;
|
|
24457
|
-
const keys = requireUtil().keys;
|
|
24458
|
-
function serialize(obj) {
|
|
24459
|
-
if (obj === null || obj === void 0) return obj;
|
|
24460
|
-
if (isRegex(obj)) return obj.toString();
|
|
24461
|
-
return obj.toJSON ? obj.toJSON() : obj;
|
|
24462
|
-
}
|
|
24463
|
-
function stringifyDeterministic(obj, opts) {
|
|
24464
|
-
opts = opts || assign({}, DEFAULTS);
|
|
24465
|
-
if (isFunction(opts)) opts = { compare: opts };
|
|
24466
|
-
const space = opts.space || DEFAULTS.space;
|
|
24467
|
-
const cycles = isBoolean(opts.cycles) ? opts.cycles : DEFAULTS.cycles;
|
|
24468
|
-
const replacer = opts.replacer || DEFAULTS.replacer;
|
|
24469
|
-
const stringify2 = opts.stringify || DEFAULTS.stringify;
|
|
24470
|
-
const compare = opts.compare && /* @__PURE__ */ function(f) {
|
|
24471
|
-
return function(node) {
|
|
24472
|
-
return function(a, b) {
|
|
24473
|
-
const aobj = { key: a, value: node[a] };
|
|
24474
|
-
const bobj = { key: b, value: node[b] };
|
|
24475
|
-
return f(aobj, bobj);
|
|
24476
|
-
};
|
|
24477
|
-
};
|
|
24478
|
-
}(opts.compare);
|
|
24479
|
-
if (!cycles) stringify2(obj);
|
|
24480
|
-
const seen = [];
|
|
24481
|
-
return function _deterministic(parent, key, node, level) {
|
|
24482
|
-
const indent2 = space ? "\n" + new Array(level + 1).join(space) : "";
|
|
24483
|
-
const colonSeparator = space ? ": " : ":";
|
|
24484
|
-
node = serialize(node);
|
|
24485
|
-
node = replacer.call(parent, key, node);
|
|
24486
|
-
if (node === void 0) return;
|
|
24487
|
-
if (!isObject(node) || node === null) return stringify2(node);
|
|
24488
|
-
if (isArray(node)) {
|
|
24489
|
-
const out = [];
|
|
24490
|
-
for (let i = 0; i < node.length; i++) {
|
|
24491
|
-
const item = _deterministic(node, i, node[i], level + 1) || stringify2(null);
|
|
24492
|
-
out.push(indent2 + space + item);
|
|
24493
|
-
}
|
|
24494
|
-
return "[" + out.join(",") + indent2 + "]";
|
|
24495
|
-
} else {
|
|
24496
|
-
if (cycles) {
|
|
24497
|
-
if (seen.indexOf(node) !== -1) {
|
|
24498
|
-
return stringify2("[Circular]");
|
|
24499
|
-
} else {
|
|
24500
|
-
seen.push(node);
|
|
24501
|
-
}
|
|
24502
|
-
}
|
|
24503
|
-
const nodeKeys = keys(node).sort(compare && compare(node));
|
|
24504
|
-
const out = [];
|
|
24505
|
-
for (let i = 0; i < nodeKeys.length; i++) {
|
|
24506
|
-
const key2 = nodeKeys[i];
|
|
24507
|
-
const value = _deterministic(node, key2, node[key2], level + 1);
|
|
24508
|
-
if (!value) continue;
|
|
24509
|
-
const keyValue = stringify2(key2) + colonSeparator + value;
|
|
24510
|
-
out.push(indent2 + space + keyValue);
|
|
24511
|
-
}
|
|
24512
|
-
seen.splice(seen.indexOf(node), 1);
|
|
24513
|
-
return "{" + out.join(",") + indent2 + "}";
|
|
24514
|
-
}
|
|
24515
|
-
}({ "": obj }, "", obj, 0);
|
|
24516
|
-
}
|
|
24517
|
-
lib = stringifyDeterministic;
|
|
24518
|
-
return lib;
|
|
24519
|
-
}
|
|
24520
|
-
var libExports = requireLib();
|
|
24521
|
-
const stringify = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
24522
|
-
const SYNC_OPS_BATCH_LIMIT = 10;
|
|
24523
|
-
class SwitchboardPushTransmitter {
|
|
24524
|
-
constructor(targetURL) {
|
|
24525
|
-
__publicField(this, "targetURL");
|
|
24526
|
-
__publicField(this, "logger", childLogger([
|
|
24527
|
-
"SwitchboardPushTransmitter",
|
|
24528
|
-
Math.floor(Math.random() * 999).toString()
|
|
24529
|
-
]));
|
|
24530
|
-
this.targetURL = targetURL;
|
|
24531
|
-
}
|
|
24532
|
-
async transmit(strands, source) {
|
|
24533
|
-
var _a2;
|
|
24534
|
-
if (source.type === "trigger" && ((_a2 = source.trigger.data) == null ? void 0 : _a2.url) === this.targetURL) {
|
|
24535
|
-
this.logger.verbose(`Cutting trigger loop from ${this.targetURL}.`);
|
|
24536
|
-
return strands.map((strand) => {
|
|
24537
|
-
var _a3;
|
|
24538
|
-
return {
|
|
24539
|
-
driveId: strand.driveId,
|
|
24540
|
-
documentId: strand.documentId,
|
|
24541
|
-
scope: strand.scope,
|
|
24542
|
-
branch: strand.branch,
|
|
24543
|
-
status: "SUCCESS",
|
|
24544
|
-
revision: ((_a3 = strand.operations.at(-1)) == null ? void 0 : _a3.index) ?? -1
|
|
24545
|
-
};
|
|
24546
|
-
});
|
|
24547
|
-
}
|
|
24548
|
-
const culledStrands = [];
|
|
24549
|
-
let opsCounter = 0;
|
|
24550
|
-
for (let s = 0; opsCounter <= SYNC_OPS_BATCH_LIMIT && s < strands.length; s++) {
|
|
24551
|
-
const currentStrand = strands.at(s);
|
|
24552
|
-
if (!currentStrand) {
|
|
24553
|
-
break;
|
|
24554
|
-
}
|
|
24555
|
-
const newOps = Math.min(SYNC_OPS_BATCH_LIMIT - opsCounter, currentStrand.operations.length);
|
|
24556
|
-
culledStrands.push({
|
|
24557
|
-
...currentStrand,
|
|
24558
|
-
operations: currentStrand.operations.slice(0, newOps)
|
|
24559
|
-
});
|
|
24560
|
-
opsCounter += newOps;
|
|
24561
|
-
}
|
|
24562
|
-
this.logger.verbose(` Total update: [${strands.map((s) => s.operations.length).join(", ")}] operations`);
|
|
24563
|
-
this.logger.verbose(`Culled update: [${culledStrands.map((s) => s.operations.length).join(", ")}] operations`);
|
|
24564
|
-
try {
|
|
24565
|
-
const { pushUpdates } = await requestGraphql(this.targetURL, gql`
|
|
24566
|
-
mutation pushUpdates($strands: [InputStrandUpdate!]) {
|
|
24567
|
-
pushUpdates(strands: $strands) {
|
|
24568
|
-
driveId
|
|
24569
|
-
documentId
|
|
24570
|
-
scope
|
|
24571
|
-
branch
|
|
24572
|
-
status
|
|
24573
|
-
revision
|
|
24574
|
-
error
|
|
24575
|
-
}
|
|
24576
|
-
}
|
|
24577
|
-
`, {
|
|
24578
|
-
strands: culledStrands.map((strand) => ({
|
|
24579
|
-
...strand,
|
|
24580
|
-
operations: strand.operations.map((op) => ({
|
|
24581
|
-
...op,
|
|
24582
|
-
input: stringify(op.input)
|
|
24583
|
-
}))
|
|
24584
|
-
}))
|
|
24585
|
-
});
|
|
24586
|
-
if (!pushUpdates) {
|
|
24587
|
-
throw new Error("Couldn't update listener revision");
|
|
24588
|
-
}
|
|
24589
|
-
return pushUpdates;
|
|
24590
|
-
} catch (e) {
|
|
24591
|
-
this.logger.error(e);
|
|
24592
|
-
throw e;
|
|
24593
|
-
}
|
|
24594
|
-
return [];
|
|
24595
|
-
}
|
|
24596
|
-
}
|
|
24597
24722
|
class TransmitterFactory {
|
|
24598
24723
|
constructor(listenerManager) {
|
|
24599
24724
|
__publicField(this, "listenerManager");
|
|
@@ -24632,11 +24757,13 @@ class SynchronizationManager {
|
|
|
24632
24757
|
}
|
|
24633
24758
|
async getSynchronizationUnits(driveId, documentId, scope, branch, documentType2) {
|
|
24634
24759
|
const synchronizationUnitsQuery = await this.getSynchronizationUnitsIds(driveId, documentId, scope, branch, documentType2);
|
|
24760
|
+
this.logger.verbose(`getSynchronizationUnits query: ${JSON.stringify(synchronizationUnitsQuery)}`);
|
|
24635
24761
|
return this.getSynchronizationUnitsRevision(driveId, synchronizationUnitsQuery);
|
|
24636
24762
|
}
|
|
24637
24763
|
async getSynchronizationUnitsRevision(driveId, syncUnitsQuery) {
|
|
24638
24764
|
const drive = await this.getDrive(driveId);
|
|
24639
24765
|
const revisions = await this.storage.getSynchronizationUnitsRevision(syncUnitsQuery);
|
|
24766
|
+
this.logger.verbose(`getSynchronizationUnitsRevision: ${JSON.stringify(revisions)}`);
|
|
24640
24767
|
return syncUnitsQuery.map((s) => {
|
|
24641
24768
|
var _a2;
|
|
24642
24769
|
return {
|
|
@@ -24717,14 +24844,27 @@ class SynchronizationManager {
|
|
|
24717
24844
|
};
|
|
24718
24845
|
}
|
|
24719
24846
|
async getOperationData(driveId, syncId, filter) {
|
|
24847
|
+
this.logger.verbose(`[SYNC DEBUG] SynchronizationManager.getOperationData called for drive: ${driveId}, syncId: ${syncId}, filter: ${JSON.stringify(filter)}`);
|
|
24720
24848
|
const syncUnit = syncId === "0" ? { documentId: "", scope: "global" } : await this.getSynchronizationUnitIdInfo(driveId, syncId);
|
|
24721
24849
|
if (!syncUnit) {
|
|
24850
|
+
this.logger.error(`SYNC DEBUG] Invalid Sync Id ${syncId} in drive ${driveId}`);
|
|
24722
24851
|
throw new Error(`Invalid Sync Id ${syncId} in drive ${driveId}`);
|
|
24723
24852
|
}
|
|
24853
|
+
this.logger.verbose(`[SYNC DEBUG] Found sync unit: documentId: ${syncUnit.documentId}, scope: ${syncUnit.scope}`);
|
|
24724
24854
|
const document = syncId === "0" ? await this.getDrive(driveId) : await this.getDocument(driveId, syncUnit.documentId);
|
|
24855
|
+
this.logger.verbose(`[SYNC DEBUG] Retrieved document ${syncUnit.documentId} with type: ${document.documentType}`);
|
|
24725
24856
|
const operations = document.operations[syncUnit.scope] ?? [];
|
|
24857
|
+
this.logger.verbose(`[SYNC DEBUG] Found ${operations.length} total operations in scope ${syncUnit.scope}`);
|
|
24726
24858
|
const filteredOperations = operations.filter((operation) => Object.keys(filter).length === 0 || (filter.since === void 0 || isBefore(filter.since, operation.timestamp)) && (filter.fromRevision === void 0 || operation.index > filter.fromRevision));
|
|
24859
|
+
this.logger.verbose(`[SYNC DEBUG] Filtered to ${filteredOperations.length} operations based on filter criteria` + (filter.fromRevision !== void 0 ? ` (fromRevision: ${filter.fromRevision})` : ""));
|
|
24727
24860
|
const limitedOperations = filter.limit ? filteredOperations.slice(0, filter.limit) : filteredOperations;
|
|
24861
|
+
this.logger.verbose(`[SYNC DEBUG] Returning ${limitedOperations.length} operations after applying limit`);
|
|
24862
|
+
if (limitedOperations.length > 0) {
|
|
24863
|
+
const firstOp = limitedOperations[0];
|
|
24864
|
+
const lastOp = limitedOperations[limitedOperations.length - 1];
|
|
24865
|
+
this.logger.verbose(`[SYNC DEBUG] First operation: index=${firstOp.index}, type=${firstOp.type}`);
|
|
24866
|
+
this.logger.verbose(`[SYNC DEBUG] Last operation: index=${lastOp.index}, type=${lastOp.type}`);
|
|
24867
|
+
}
|
|
24728
24868
|
return limitedOperations.map((operation) => ({
|
|
24729
24869
|
hash: operation.hash,
|
|
24730
24870
|
index: operation.index,
|
|
@@ -25230,6 +25370,9 @@ function Modified(props) {
|
|
|
25230
25370
|
function Moved(props) {
|
|
25231
25371
|
return jsxs("svg", { ...props, width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { d: "M7.07143 1.96429C7.07143 2.2207 6.86356 2.42857 6.60714 2.42857H5.21429C3.67578 2.42857 2.42857 3.67578 2.42857 5.21429V10.7857C2.42857 12.3242 3.67578 13.5714 5.21429 13.5714H10.7857C12.3242 13.5714 13.5714 12.3242 13.5714 10.7857V9.39286C13.5714 9.13644 13.7793 8.92857 14.0357 8.92857C14.2921 8.92857 14.5 9.13644 14.5 9.39286V10.7857C14.5 12.8371 12.8371 14.5 10.7857 14.5H5.21429C3.16294 14.5 1.5 12.8371 1.5 10.7857V5.21429C1.5 3.16294 3.16294 1.5 5.21429 1.5H6.60714C6.86356 1.5 7.07143 1.70787 7.07143 1.96429Z", fill: "currentcolor" }), jsx("path", { d: "M14 6.5V2.5C14 2.22386 13.7761 2 13.5 2H9.5", stroke: "currentcolor", strokeLinecap: "round" }), jsx("path", { d: "M7 10L7.28346 9.29136C8.39378 6.51556 10.4269 4.20728 13.0403 2.75539L13.5 2.5", stroke: "currentcolor", strokeLinecap: "round" })] });
|
|
25232
25372
|
}
|
|
25373
|
+
function Npm(props) {
|
|
25374
|
+
return jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 128 128", children: jsx("path", { fill: "#cb3837", d: "M2 38.5h124v43.71H64v7.29H36.44v-7.29H2zm6.89 36.43h13.78V53.07h6.89v21.86h6.89V45.79H8.89zm34.44-29.14v36.42h13.78v-7.28h13.78V45.79zm13.78 7.29H64v14.56h-6.89zm20.67-7.29v29.14h13.78V53.07h6.89v21.86h6.89V53.07h6.89v21.86h6.89V45.79z" }) });
|
|
25375
|
+
}
|
|
25233
25376
|
function PackageManager(props) {
|
|
25234
25377
|
return jsx("svg", { ...props, width: "12", height: "12", viewBox: "0 0 12 12", fill: "currentcolor", children: jsx("path", { d: "M1.22323 -0.00109863C0.549226 -0.00109863 -0.00610352 0.533576 -0.00610352 1.20691V2.79089C-0.00610352 3.46423 0.549226 3.9989 1.22323 3.9989H4.0979C4.7719 3.9989 5.32723 3.46423 5.32723 2.79089V1.20691C5.32723 0.533576 4.7719 -0.00109863 4.0979 -0.00109863H1.22323ZM7.9939 -0.00109863C7.25723 -0.00109863 6.66056 0.595568 6.66056 1.33223V5.33223C6.66056 6.0689 7.25723 6.66557 7.9939 6.66557H10.6606C11.3972 6.66557 11.9939 6.0689 11.9939 5.33223V1.33223C11.9939 0.595568 11.3972 -0.00109863 10.6606 -0.00109863H7.9939ZM1.32723 5.33223C0.590563 5.33223 -0.00610352 5.9289 -0.00610352 6.66557V10.6656C-0.00610352 11.4022 0.590563 11.9989 1.32723 11.9989H3.9939C4.73056 11.9989 5.32723 11.4022 5.32723 10.6656V6.66557C5.32723 5.9289 4.73056 5.33223 3.9939 5.33223H1.32723ZM7.88989 7.9989C7.21589 7.9989 6.66056 8.53358 6.66056 9.20691V10.7909C6.66056 11.4642 7.21589 11.9989 7.88989 11.9989H10.7646C11.4386 11.9989 11.9939 11.4642 11.9939 10.7909V9.20691C11.9939 8.53358 11.4386 7.9989 10.7646 7.9989H7.88989Z" }) });
|
|
25235
25378
|
}
|
|
@@ -25418,6 +25561,7 @@ const iconComponents = {
|
|
|
25418
25561
|
M,
|
|
25419
25562
|
Modified,
|
|
25420
25563
|
Moved,
|
|
25564
|
+
Npm,
|
|
25421
25565
|
PackageManager,
|
|
25422
25566
|
Pencil,
|
|
25423
25567
|
PeopleFill,
|
|
@@ -25595,7 +25739,7 @@ const nodeOptionsMap = {
|
|
|
25595
25739
|
};
|
|
25596
25740
|
const name = "@powerhousedao/connect";
|
|
25597
25741
|
const productName = "Powerhouse-Connect";
|
|
25598
|
-
const version$1 = "1.0.
|
|
25742
|
+
const version$1 = "1.0.4-dev.1";
|
|
25599
25743
|
const description = "Powerhouse Connect";
|
|
25600
25744
|
const main = "./dist/index.html";
|
|
25601
25745
|
const type = "module";
|
|
@@ -31235,7 +31379,7 @@ if (window.__VITE_ENVS.MODE === "development") {
|
|
|
31235
31379
|
} else {
|
|
31236
31380
|
serviceWorkerManager.registerServiceWorker(false);
|
|
31237
31381
|
}
|
|
31238
|
-
const App = lazy(() => __vitePreload(() => import("./app-
|
|
31382
|
+
const App = lazy(() => __vitePreload(() => import("./app-CrkKw3iM.js").then((n) => n.aN), true ? __vite__mapDeps([0,1,2]) : void 0));
|
|
31239
31383
|
const AppLoader = /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(App, {}) });
|
|
31240
31384
|
const appLoader = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
31241
31385
|
__proto__: null,
|