@blocksuite/sync
Advanced tools
Comparing version 0.15.0-canary-202405240632-44ff286 to 0.15.0-canary-202405240653-5a6af5e
@@ -10,3 +10,3 @@ import { type Logger, Slot } from '@blocksuite/global/utils'; | ||
main: DocPeerStatus | null; | ||
shadow: (DocPeerStatus | null)[]; | ||
shadows: (DocPeerStatus | null)[]; | ||
retrying: boolean; | ||
@@ -41,3 +41,3 @@ } | ||
* 3. start shadow sync | ||
* 4. continuously sync main and shadow | ||
* 4. continuously sync main and shadows | ||
*/ | ||
@@ -47,3 +47,3 @@ export declare class DocEngine { | ||
readonly main: DocSource; | ||
readonly shadow: DocSource[]; | ||
readonly shadows: DocSource[]; | ||
readonly logger: Logger; | ||
@@ -57,3 +57,3 @@ get rootDocId(): string; | ||
private _abort; | ||
constructor(rootDoc: Doc, main: DocSource, shadow: DocSource[], logger: Logger); | ||
constructor(rootDoc: Doc, main: DocSource, shadows: DocSource[], logger: Logger); | ||
start(): void; | ||
@@ -64,3 +64,3 @@ canGracefulStop(): boolean; | ||
sync(signal: AbortSignal): Promise<void>; | ||
updateSyncingState(local: SyncPeer | null, shadow: (SyncPeer | null)[]): void; | ||
updateSyncingState(local: SyncPeer | null, shadows: (SyncPeer | null)[]): void; | ||
waitForSynced(abort?: AbortSignal): Promise<unknown>; | ||
@@ -67,0 +67,0 @@ waitForLoadedRootDoc(abort?: AbortSignal): Promise<unknown>; |
@@ -34,3 +34,3 @@ import { Slot } from '@blocksuite/global/utils'; | ||
* 3. start shadow sync | ||
* 4. continuously sync main and shadow | ||
* 4. continuously sync main and shadows | ||
*/ | ||
@@ -49,6 +49,6 @@ export class DocEngine { | ||
} | ||
constructor(rootDoc, main, shadow, logger) { | ||
constructor(rootDoc, main, shadows, logger) { | ||
this.rootDoc = rootDoc; | ||
this.main = main; | ||
this.shadow = shadow; | ||
this.shadows = shadows; | ||
this.logger = logger; | ||
@@ -61,3 +61,3 @@ this.onStatusChange = new Slot(); | ||
main: null, | ||
shadow: shadow.map(() => null), | ||
shadows: shadows.map(() => null), | ||
retrying: false, | ||
@@ -106,3 +106,3 @@ }; | ||
main: null, | ||
shadow: this.shadow.map(() => null), | ||
shadows: this.shadows.map(() => null), | ||
retrying: false, | ||
@@ -115,3 +115,3 @@ }); | ||
mainPeer: null, | ||
shadowPeers: this.shadow.map(() => null), | ||
shadowPeers: this.shadows.map(() => null), | ||
}; | ||
@@ -130,3 +130,3 @@ const cleanUp = []; | ||
// Step 3: start shadow sync peer | ||
state.shadowPeers = this.shadow.map(shadow => { | ||
state.shadowPeers = this.shadows.map(shadow => { | ||
const peer = new SyncPeer(this.rootDoc, shadow, this.priorityTarget, this.logger); | ||
@@ -168,5 +168,5 @@ cleanUp.push(peer.onStatusChange.on(() => { | ||
} | ||
updateSyncingState(local, shadow) { | ||
updateSyncingState(local, shadows) { | ||
let step = DocEngineStep.Synced; | ||
const allPeer = [local, ...shadow]; | ||
const allPeer = [local, ...shadows]; | ||
for (const peer of allPeer) { | ||
@@ -181,3 +181,3 @@ if (!peer || peer.status.step !== DocPeerStep.Synced) { | ||
main: local?.status ?? null, | ||
shadow: shadow.map(peer => peer?.status ?? null), | ||
shadows: shadows.map(peer => peer?.status ?? null), | ||
retrying: allPeer.some(peer => peer?.status.step === DocPeerStep.Retrying), | ||
@@ -212,3 +212,3 @@ }); | ||
function isLoadedRootDoc(status) { | ||
return ![status.main, ...status.shadow].some(peer => !peer || peer.step <= DocPeerStep.LoadingRootDoc); | ||
return ![status.main, ...status.shadows].some(peer => !peer || peer.step <= DocPeerStep.LoadingRootDoc); | ||
} | ||
@@ -215,0 +215,0 @@ if (isLoadedRootDoc(this.status)) { |
export * from './awareness/index.js'; | ||
export * from './blob/index.js'; | ||
export * from './doc/index.js'; | ||
//# sourceMappingURL=index.d.ts.map |
export * from './awareness/index.js'; | ||
export * from './blob/index.js'; | ||
export * from './doc/index.js'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@blocksuite/sync", | ||
"version": "0.15.0-canary-202405240632-44ff286", | ||
"version": "0.15.0-canary-202405240653-5a6af5e", | ||
"description": "BlockSuite data synchronization engine abstraction and implementation.", | ||
@@ -11,7 +11,7 @@ "type": "module", | ||
"dependencies": { | ||
"idb": "^8.0.0", | ||
"idb-keyval": "^6.2.1", | ||
"y-protocols": "^1.0.6", | ||
"idb": "^8.0.0", | ||
"@blocksuite/global": "0.15.0-canary-202405240632-44ff286" | ||
"@blocksuite/global": "0.15.0-canary-202405240653-5a6af5e" | ||
}, | ||
"devDependencies": {}, | ||
"peerDependencies": { | ||
@@ -18,0 +18,0 @@ "yjs": "^13.6.15" |
@@ -13,3 +13,3 @@ import { type Logger, Slot } from '@blocksuite/global/utils'; | ||
main: DocPeerStatus | null; | ||
shadow: (DocPeerStatus | null)[]; | ||
shadows: (DocPeerStatus | null)[]; | ||
retrying: boolean; | ||
@@ -45,3 +45,3 @@ } | ||
* 3. start shadow sync | ||
* 4. continuously sync main and shadow | ||
* 4. continuously sync main and shadows | ||
*/ | ||
@@ -71,3 +71,3 @@ export class DocEngine { | ||
readonly main: DocSource, | ||
readonly shadow: DocSource[], | ||
readonly shadows: DocSource[], | ||
readonly logger: Logger | ||
@@ -78,3 +78,3 @@ ) { | ||
main: null, | ||
shadow: shadow.map(() => null), | ||
shadows: shadows.map(() => null), | ||
retrying: false, | ||
@@ -128,3 +128,3 @@ }; | ||
main: null, | ||
shadow: this.shadow.map(() => null), | ||
shadows: this.shadows.map(() => null), | ||
retrying: false, | ||
@@ -141,3 +141,3 @@ }); | ||
mainPeer: null, | ||
shadowPeers: this.shadow.map(() => null), | ||
shadowPeers: this.shadows.map(() => null), | ||
}; | ||
@@ -168,3 +168,3 @@ | ||
// Step 3: start shadow sync peer | ||
state.shadowPeers = this.shadow.map(shadow => { | ||
state.shadowPeers = this.shadows.map(shadow => { | ||
const peer = new SyncPeer( | ||
@@ -215,5 +215,5 @@ this.rootDoc, | ||
updateSyncingState(local: SyncPeer | null, shadow: (SyncPeer | null)[]) { | ||
updateSyncingState(local: SyncPeer | null, shadows: (SyncPeer | null)[]) { | ||
let step = DocEngineStep.Synced; | ||
const allPeer = [local, ...shadow]; | ||
const allPeer = [local, ...shadows]; | ||
for (const peer of allPeer) { | ||
@@ -228,3 +228,3 @@ if (!peer || peer.status.step !== DocPeerStep.Synced) { | ||
main: local?.status ?? null, | ||
shadow: shadow.map(peer => peer?.status ?? null), | ||
shadows: shadows.map(peer => peer?.status ?? null), | ||
retrying: allPeer.some( | ||
@@ -262,3 +262,3 @@ peer => peer?.status.step === DocPeerStep.Retrying | ||
function isLoadedRootDoc(status: DocEngineStatus) { | ||
return ![status.main, ...status.shadow].some( | ||
return ![status.main, ...status.shadows].some( | ||
peer => !peer || peer.step <= DocPeerStep.LoadingRootDoc | ||
@@ -265,0 +265,0 @@ ); |
export * from './awareness/index.js'; | ||
export * from './blob/index.js'; | ||
export * from './doc/index.js'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213444
128
2978
5
+ Addedidb-keyval@^6.2.1
+ Added@blocksuite/global@0.15.0-canary-202405240653-5a6af5e(transitive)
+ Addedidb-keyval@6.2.1(transitive)
- Removed@blocksuite/global@0.15.0-canary-202405240632-44ff286(transitive)
Updated@blocksuite/global@0.15.0-canary-202405240653-5a6af5e