@blocksuite/sync
Advanced tools
Comparing version 0.12.0-canary-202402191436-2201798 to 0.12.0-canary-202402200831-bc2769f
@@ -8,10 +8,10 @@ import type { DocSource } from '../source.js'; | ||
constructor(channelName?: string); | ||
pull(docId: string, state: Uint8Array): Promise<{ | ||
pull(docId: string, state: Uint8Array): { | ||
data: Uint8Array; | ||
state?: Uint8Array | undefined; | ||
} | null>; | ||
push(docId: string, data: Uint8Array): Promise<void>; | ||
subscribe(cb: (docId: string, data: Uint8Array) => void): Promise<() => void>; | ||
state: Uint8Array; | ||
} | null; | ||
push(docId: string, data: Uint8Array): void; | ||
subscribe(cb: (docId: string, data: Uint8Array) => void): () => void; | ||
private _onMessage; | ||
} | ||
//# sourceMappingURL=broadcast.d.ts.map |
@@ -34,3 +34,3 @@ import { assertExists } from '@blocksuite/global/utils'; | ||
} | ||
async pull(docId, state) { | ||
pull(docId, state) { | ||
const update = this.docMap.get(docId); | ||
@@ -42,3 +42,3 @@ if (!update) | ||
} | ||
async push(docId, data) { | ||
push(docId, data) { | ||
const update = this.docMap.get(docId); | ||
@@ -58,3 +58,3 @@ if (update) { | ||
} | ||
async subscribe(cb) { | ||
subscribe(cb) { | ||
const abortController = new AbortController(); | ||
@@ -61,0 +61,0 @@ this.channel.addEventListener('message', (event) => { |
@@ -33,5 +33,5 @@ import { type DBSchema, type IDBPDatabase } from 'idb'; | ||
push(docId: string, data: Uint8Array): Promise<void>; | ||
subscribe(cb: (docId: string, data: Uint8Array) => void): Promise<() => void>; | ||
subscribe(cb: (docId: string, data: Uint8Array) => void): () => void; | ||
} | ||
export {}; | ||
//# sourceMappingURL=indexeddb.d.ts.map |
@@ -62,3 +62,3 @@ import { openDB } from 'idb'; | ||
} | ||
async subscribe(cb) { | ||
subscribe(cb) { | ||
function onMessage(event) { | ||
@@ -65,0 +65,0 @@ const { type, payload } = event.data; |
@@ -5,9 +5,8 @@ import type { DocSource } from '../source.js'; | ||
name: string; | ||
pull(docId: string, _: Uint8Array): Promise<{ | ||
pull(docId: string, _: Uint8Array): { | ||
data: Uint8Array; | ||
state?: Uint8Array | undefined; | ||
} | null>; | ||
push(docId: string, data: Uint8Array): Promise<void>; | ||
subscribe(_cb: (docId: string, data: Uint8Array) => void, _disconnect: (reason: string) => void): Promise<() => void>; | ||
} | null; | ||
push(docId: string, data: Uint8Array): void; | ||
subscribe(_cb: (docId: string, data: Uint8Array) => void, _disconnect: (reason: string) => void): () => void; | ||
} | ||
//# sourceMappingURL=memory.d.ts.map |
@@ -7,3 +7,3 @@ import { mergeUpdates } from '../../utils/merge-updates.js'; | ||
} | ||
async pull(docId, _) { | ||
pull(docId, _) { | ||
const key = docId; | ||
@@ -18,3 +18,3 @@ const data = this.memory.get(key); | ||
} | ||
async push(docId, data) { | ||
push(docId, data) { | ||
const key = docId; | ||
@@ -25,3 +25,3 @@ const oldData = this.memory.get(key); | ||
} | ||
async subscribe(_cb, _disconnect) { | ||
subscribe(_cb, _disconnect) { | ||
return () => { }; | ||
@@ -28,0 +28,0 @@ } |
@@ -9,4 +9,7 @@ export interface DocSource { | ||
state?: Uint8Array; | ||
} | null>; | ||
push(docId: string, data: Uint8Array): Promise<void>; | ||
} | null> | { | ||
data: Uint8Array; | ||
state?: Uint8Array; | ||
} | null; | ||
push(docId: string, data: Uint8Array): Promise<void> | void; | ||
/** | ||
@@ -20,4 +23,4 @@ * Subscribe to updates from peer | ||
*/ | ||
subscribe(cb: (docId: string, data: Uint8Array) => void, disconnect: (reason: string) => void): Promise<() => void>; | ||
subscribe(cb: (docId: string, data: Uint8Array) => void, disconnect: (reason: string) => void): Promise<() => void> | (() => void); | ||
} | ||
//# sourceMappingURL=source.d.ts.map |
import { describe, expect, test } from 'vitest'; | ||
import { throwIfAborted } from '../throw-if-aborted.js'; | ||
describe('throw-if-aborted', () => { | ||
test('basic', async () => { | ||
test('basic', () => { | ||
const abortController = new AbortController(); | ||
@@ -6,0 +6,0 @@ const abortSignal = abortController.signal; |
{ | ||
"name": "@blocksuite/sync", | ||
"version": "0.12.0-canary-202402191436-2201798", | ||
"version": "0.12.0-canary-202402200831-bc2769f", | ||
"description": "BlockSuite data synchronization engine abstraction and implementation.", | ||
@@ -13,3 +13,3 @@ "type": "module", | ||
"idb": "^8.0.0", | ||
"@blocksuite/global": "0.12.0-canary-202402191436-2201798" | ||
"@blocksuite/global": "0.12.0-canary-202402200831-bc2769f" | ||
}, | ||
@@ -16,0 +16,0 @@ "devDependencies": {}, |
@@ -30,6 +30,3 @@ import { assertExists } from '@blocksuite/global/utils'; | ||
async pull( | ||
docId: string, | ||
state: Uint8Array | ||
): Promise<{ data: Uint8Array; state?: Uint8Array | undefined } | null> { | ||
pull(docId: string, state: Uint8Array) { | ||
const update = this.docMap.get(docId); | ||
@@ -42,3 +39,3 @@ if (!update) return null; | ||
async push(docId: string, data: Uint8Array): Promise<void> { | ||
push(docId: string, data: Uint8Array) { | ||
const update = this.docMap.get(docId); | ||
@@ -59,3 +56,3 @@ if (update) { | ||
async subscribe(cb: (docId: string, data: Uint8Array) => void) { | ||
subscribe(cb: (docId: string, data: Uint8Array) => void) { | ||
const abortController = new AbortController(); | ||
@@ -62,0 +59,0 @@ this.channel.addEventListener( |
@@ -100,3 +100,3 @@ import { type DBSchema, type IDBPDatabase, openDB } from 'idb'; | ||
async subscribe(cb: (docId: string, data: Uint8Array) => void) { | ||
subscribe(cb: (docId: string, data: Uint8Array) => void) { | ||
function onMessage(event: MessageEvent<ChannelMessage>) { | ||
@@ -103,0 +103,0 @@ const { type, payload } = event.data; |
@@ -8,6 +8,3 @@ import { mergeUpdates } from '../../utils/merge-updates.js'; | ||
name: string = 'testing'; | ||
async pull( | ||
docId: string, | ||
_: Uint8Array | ||
): Promise<{ data: Uint8Array; state?: Uint8Array | undefined } | null> { | ||
pull(docId: string, _: Uint8Array) { | ||
const key = docId; | ||
@@ -21,3 +18,3 @@ const data = this.memory.get(key); | ||
} | ||
async push(docId: string, data: Uint8Array): Promise<void> { | ||
push(docId: string, data: Uint8Array) { | ||
const key = docId; | ||
@@ -28,8 +25,8 @@ const oldData = this.memory.get(key); | ||
} | ||
async subscribe( | ||
subscribe( | ||
_cb: (docId: string, data: Uint8Array) => void, | ||
_disconnect: (reason: string) => void | ||
): Promise<() => void> { | ||
) { | ||
return () => {}; | ||
} | ||
} |
@@ -10,4 +10,7 @@ export interface DocSource { | ||
state: Uint8Array | ||
): Promise<{ data: Uint8Array; state?: Uint8Array } | null>; | ||
push(docId: string, data: Uint8Array): Promise<void>; | ||
): | ||
| Promise<{ data: Uint8Array; state?: Uint8Array } | null> | ||
| { data: Uint8Array; state?: Uint8Array } | ||
| null; | ||
push(docId: string, data: Uint8Array): Promise<void> | void; | ||
@@ -25,3 +28,3 @@ /** | ||
disconnect: (reason: string) => void | ||
): Promise<() => void>; | ||
): Promise<() => void> | (() => void); | ||
} |
@@ -6,3 +6,3 @@ import { describe, expect, test } from 'vitest'; | ||
describe('throw-if-aborted', () => { | ||
test('basic', async () => { | ||
test('basic', () => { | ||
const abortController = new AbortController(); | ||
@@ -9,0 +9,0 @@ const abortSignal = abortController.signal; |
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
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
4930
35
147289
2533
+ Added@blocksuite/global@0.12.0-canary-202402200831-bc2769f(transitive)
- Removed@blocksuite/global@0.12.0-canary-202402191436-2201798(transitive)
Updated@blocksuite/global@0.12.0-canary-202402200831-bc2769f