@fairfox/polly 0.59.0 → 0.60.0
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/dist/src/mesh.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export type { MeshKeyring, MeshNetworkAdapterOptions, } from "./shared/lib/mesh-
|
|
|
27
27
|
export { DEFAULT_MESH_KEY_ID, MeshNetworkAdapter, } from "./shared/lib/mesh-network-adapter";
|
|
28
28
|
export type { MeshSignalingClientOptions, SignalingMessage as MeshSignalingMessage, } from "./shared/lib/mesh-signaling-client";
|
|
29
29
|
export { MeshSignalingClient } from "./shared/lib/mesh-signaling-client";
|
|
30
|
-
export type { MeshStateLoadedRejectionBreadcrumb, MeshStateOptions, } from "./shared/lib/mesh-state";
|
|
31
|
-
export { $meshCounter, $meshList, $meshState, $meshText, configureMeshState, getLastConfiguredRepoPeerId, getLastLoadedRejection, getLazyInvocations, getLazyReachedRepo, getMeshStateModuleId, isMeshStateConfigured, MESH_STATE_MODULE_ID, resetMeshState, wasMeshStateResolved, } from "./shared/lib/mesh-state";
|
|
30
|
+
export type { LazyWrapperExitReason, MeshStateLazyWrapperRecord, MeshStateLoadedRejectionBreadcrumb, MeshStateOptions, } from "./shared/lib/mesh-state";
|
|
31
|
+
export { $meshCounter, $meshList, $meshState, $meshText, configureMeshState, getLastConfiguredRepoPeerId, getLastLoadedRejection, getLazyInvocations, getLazyReachedRepo, getLazyWrappers, getMeshStateModuleId, isMeshStateConfigured, MESH_STATE_MODULE_ID, resetMeshState, wasMeshStateResolved, } from "./shared/lib/mesh-state";
|
|
32
32
|
export type { HandleSyncSnapshot, InFlightSyncSnapshot, MeshWebRTCAdapterOptions, SlotInitiationDecision, SlotInitiationRejectionReason, SweepSnapshot, SyncHandshakeAttemptSnapshot, SyncProgressEvent, TransportSnapshot, } from "./shared/lib/mesh-webrtc-adapter";
|
|
33
33
|
export { DEFAULT_ICE_SERVERS, MeshWebRTCAdapter } from "./shared/lib/mesh-webrtc-adapter";
|
|
34
34
|
export type { CreatePairingTokenOptions, PairingToken, } from "./shared/lib/pairing";
|
package/dist/src/mesh.js
CHANGED
|
@@ -1783,6 +1783,7 @@ function resetMeshState() {
|
|
|
1783
1783
|
lazyInvocations = 0;
|
|
1784
1784
|
lazyReachedRepo = 0;
|
|
1785
1785
|
lastLoadedRejection = undefined;
|
|
1786
|
+
lazyWrappers = [];
|
|
1786
1787
|
}
|
|
1787
1788
|
function isMeshStateConfigured() {
|
|
1788
1789
|
return defaultRepo !== undefined;
|
|
@@ -1812,6 +1813,23 @@ function recordLoadedRejection(thrown) {
|
|
|
1812
1813
|
at: Date.now()
|
|
1813
1814
|
};
|
|
1814
1815
|
}
|
|
1816
|
+
var LAZY_WRAPPER_LOG_CAP = 64;
|
|
1817
|
+
var lazyWrappers = [];
|
|
1818
|
+
function getLazyWrappers() {
|
|
1819
|
+
return lazyWrappers.slice();
|
|
1820
|
+
}
|
|
1821
|
+
function recordLazyWrapper(record) {
|
|
1822
|
+
lazyWrappers.push(record);
|
|
1823
|
+
if (lazyWrappers.length > LAZY_WRAPPER_LOG_CAP) {
|
|
1824
|
+
lazyWrappers = lazyWrappers.slice(-LAZY_WRAPPER_LOG_CAP);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function peekHandleState(repo, documentId) {
|
|
1828
|
+
const handle = repo.handles[documentId];
|
|
1829
|
+
if (!handle)
|
|
1830
|
+
return;
|
|
1831
|
+
return typeof handle.state === "string" ? handle.state : String(handle.state ?? "unknown");
|
|
1832
|
+
}
|
|
1815
1833
|
function resolveRepo(option) {
|
|
1816
1834
|
meshStateEverResolved = true;
|
|
1817
1835
|
const repo = option ?? defaultRepo;
|
|
@@ -1834,26 +1852,43 @@ function buildHandleFactory(repo, key, initialDoc) {
|
|
|
1834
1852
|
const documentId = deriveDocumentId(key);
|
|
1835
1853
|
return async () => {
|
|
1836
1854
|
lazyInvocations++;
|
|
1855
|
+
let exitReason = "threw";
|
|
1856
|
+
let errorMessage;
|
|
1837
1857
|
try {
|
|
1838
1858
|
const cached = repo.handles[documentId];
|
|
1839
1859
|
lazyReachedRepo++;
|
|
1840
1860
|
if (cached) {
|
|
1841
1861
|
await cached.whenReady(["ready", "unavailable"]);
|
|
1842
1862
|
if (cached.state === "ready") {
|
|
1863
|
+
exitReason = "returned-cached";
|
|
1843
1864
|
return cached;
|
|
1844
1865
|
}
|
|
1845
1866
|
}
|
|
1846
1867
|
const stored = await repo.storageSubsystem?.loadDoc(documentId);
|
|
1847
1868
|
if (stored) {
|
|
1869
|
+
exitReason = "loaded-from-storage";
|
|
1848
1870
|
return repo.find(documentId, { allowableStates: ["ready"] });
|
|
1849
1871
|
}
|
|
1850
1872
|
const seeded = Automerge.save(Automerge.from(initialDoc));
|
|
1851
1873
|
const handle = repo.import(seeded, { docId: documentId });
|
|
1852
1874
|
handle.doneLoading();
|
|
1875
|
+
exitReason = "seeded-and-imported";
|
|
1853
1876
|
return handle;
|
|
1854
1877
|
} catch (err) {
|
|
1878
|
+
errorMessage = err instanceof Error ? err.message : String(err);
|
|
1855
1879
|
recordLoadedRejection(err);
|
|
1856
1880
|
throw err;
|
|
1881
|
+
} finally {
|
|
1882
|
+
const handleState = peekHandleState(repo, documentId);
|
|
1883
|
+
recordLazyWrapper({
|
|
1884
|
+
key,
|
|
1885
|
+
docId: documentId,
|
|
1886
|
+
at: Date.now(),
|
|
1887
|
+
exitReason,
|
|
1888
|
+
handleRegistered: handleState !== undefined,
|
|
1889
|
+
handleState,
|
|
1890
|
+
errorMessage
|
|
1891
|
+
});
|
|
1857
1892
|
}
|
|
1858
1893
|
};
|
|
1859
1894
|
}
|
|
@@ -2951,6 +2986,18 @@ function getReevaluateDocumentShare(repo) {
|
|
|
2951
2986
|
return;
|
|
2952
2987
|
return () => fn.call(sync);
|
|
2953
2988
|
}
|
|
2989
|
+
function buildMeshStateModuleDiagnostics() {
|
|
2990
|
+
return {
|
|
2991
|
+
moduleId: getMeshStateModuleId(),
|
|
2992
|
+
configured: isMeshStateConfigured(),
|
|
2993
|
+
lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),
|
|
2994
|
+
wasResolved: wasMeshStateResolved(),
|
|
2995
|
+
lazyInvocations: getLazyInvocations(),
|
|
2996
|
+
lazyReachedRepo: getLazyReachedRepo(),
|
|
2997
|
+
lastLoadedRejection: getLastLoadedRejection(),
|
|
2998
|
+
lazyWrappers: getLazyWrappers()
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
2954
3001
|
function installPolly107SyncReevaluation(networkAdapter, repo) {
|
|
2955
3002
|
const disable = typeof process !== "undefined" && process.env?.["POLLY_107_DISABLE_FIX"] === "1";
|
|
2956
3003
|
if (disable)
|
|
@@ -3060,15 +3107,7 @@ async function createMeshClient(options) {
|
|
|
3060
3107
|
lastRunAt: undefined
|
|
3061
3108
|
},
|
|
3062
3109
|
peers: [],
|
|
3063
|
-
meshStateModule:
|
|
3064
|
-
moduleId: getMeshStateModuleId(),
|
|
3065
|
-
configured: isMeshStateConfigured(),
|
|
3066
|
-
lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),
|
|
3067
|
-
wasResolved: wasMeshStateResolved(),
|
|
3068
|
-
lazyInvocations: getLazyInvocations(),
|
|
3069
|
-
lazyReachedRepo: getLazyReachedRepo(),
|
|
3070
|
-
lastLoadedRejection: getLastLoadedRejection()
|
|
3071
|
-
},
|
|
3110
|
+
meshStateModule: buildMeshStateModuleDiagnostics(),
|
|
3072
3111
|
repoHandleCount: Object.keys(repo.handles).length,
|
|
3073
3112
|
repoHandleIds: Object.keys(repo.handles)
|
|
3074
3113
|
};
|
|
@@ -3083,15 +3122,7 @@ async function createMeshClient(options) {
|
|
|
3083
3122
|
presentPeerIds: base.presentPeerIds,
|
|
3084
3123
|
sweep: base.sweep,
|
|
3085
3124
|
peers: enrichedPeers,
|
|
3086
|
-
meshStateModule:
|
|
3087
|
-
moduleId: getMeshStateModuleId(),
|
|
3088
|
-
configured: isMeshStateConfigured(),
|
|
3089
|
-
lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),
|
|
3090
|
-
wasResolved: wasMeshStateResolved(),
|
|
3091
|
-
lazyInvocations: getLazyInvocations(),
|
|
3092
|
-
lazyReachedRepo: getLazyReachedRepo(),
|
|
3093
|
-
lastLoadedRejection: getLastLoadedRejection()
|
|
3094
|
-
},
|
|
3125
|
+
meshStateModule: buildMeshStateModuleDiagnostics(),
|
|
3095
3126
|
repoHandleCount: knownHandleIds.length,
|
|
3096
3127
|
repoHandleIds: knownHandleIds
|
|
3097
3128
|
};
|
|
@@ -3477,6 +3508,7 @@ export {
|
|
|
3477
3508
|
isMeshStateConfigured,
|
|
3478
3509
|
isBlobRef,
|
|
3479
3510
|
getMeshStateModuleId,
|
|
3511
|
+
getLazyWrappers,
|
|
3480
3512
|
getLazyReachedRepo,
|
|
3481
3513
|
getLazyInvocations,
|
|
3482
3514
|
getLastLoadedRejection,
|
|
@@ -3530,4 +3562,4 @@ export {
|
|
|
3530
3562
|
$meshCounter
|
|
3531
3563
|
};
|
|
3532
3564
|
|
|
3533
|
-
//# debugId=
|
|
3565
|
+
//# debugId=CC67EB2297E1036764756E2164756E21
|