mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
feat(nbstore): add nbstore worker (#9185)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { share } from '../../connection';
|
||||
import {
|
||||
type BlobRecord,
|
||||
BlobStorage,
|
||||
BlobStorageBase,
|
||||
type ListedBlobRecord,
|
||||
} from '../../storage';
|
||||
import { IDBConnection } from './db';
|
||||
|
||||
export class IndexedDBBlobStorage extends BlobStorage {
|
||||
export class IndexedDBBlobStorage extends BlobStorageBase {
|
||||
readonly connection = share(new IDBConnection(this.options));
|
||||
|
||||
get db() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type IDBPDatabase, openDB } from 'idb';
|
||||
|
||||
import { Connection } from '../../connection';
|
||||
import { AutoReconnectConnection } from '../../connection';
|
||||
import type { StorageOptions } from '../../storage';
|
||||
import { type DocStorageSchema, migrator } from './schema';
|
||||
|
||||
export class IDBConnection extends Connection<{
|
||||
export class IDBConnection extends AutoReconnectConnection<{
|
||||
db: IDBPDatabase<DocStorageSchema>;
|
||||
channel: BroadcastChannel;
|
||||
}> {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
type DocClock,
|
||||
type DocClocks,
|
||||
type DocRecord,
|
||||
DocStorage,
|
||||
DocStorageBase,
|
||||
type DocStorageOptions,
|
||||
type DocUpdate,
|
||||
} from '../../storage';
|
||||
@@ -15,7 +15,7 @@ interface ChannelMessage {
|
||||
origin?: string;
|
||||
}
|
||||
|
||||
export class IndexedDBDocStorage extends DocStorage {
|
||||
export class IndexedDBDocStorage extends DocStorageBase {
|
||||
readonly connection = new IDBConnection(this.options);
|
||||
|
||||
get db() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { share } from '../../connection';
|
||||
import { type DocClock, type DocClocks, SyncStorage } from '../../storage';
|
||||
import { BasicSyncStorage, type DocClock, type DocClocks } from '../../storage';
|
||||
import { IDBConnection } from './db';
|
||||
export class IndexedDBSyncStorage extends SyncStorage {
|
||||
export class IndexedDBSyncStorage extends BasicSyncStorage {
|
||||
readonly connection = share(new IDBConnection(this.options));
|
||||
|
||||
get db() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { share } from '../../../connection';
|
||||
import { BlobStorage, type ListedBlobRecord } from '../../../storage';
|
||||
import { BlobStorageBase, type ListedBlobRecord } from '../../../storage';
|
||||
import { BlobIDBConnection } from './db';
|
||||
|
||||
/**
|
||||
* @deprecated readonly
|
||||
*/
|
||||
export class IndexedDBV1BlobStorage extends BlobStorage {
|
||||
export class IndexedDBV1BlobStorage extends BlobStorageBase {
|
||||
readonly connection = share(new BlobIDBConnection(this.spaceId));
|
||||
|
||||
get db() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type DBSchema, type IDBPDatabase, openDB } from 'idb';
|
||||
|
||||
import { Connection } from '../../../connection';
|
||||
import { AutoReconnectConnection } from '../../../connection';
|
||||
|
||||
export interface DocDBSchema extends DBSchema {
|
||||
workspace: {
|
||||
@@ -15,7 +15,9 @@ export interface DocDBSchema extends DBSchema {
|
||||
};
|
||||
}
|
||||
|
||||
export class DocIDBConnection extends Connection<IDBPDatabase<DocDBSchema>> {
|
||||
export class DocIDBConnection extends AutoReconnectConnection<
|
||||
IDBPDatabase<DocDBSchema>
|
||||
> {
|
||||
override get shareId() {
|
||||
return 'idb(old):affine-local';
|
||||
}
|
||||
@@ -40,7 +42,9 @@ export interface BlobDBSchema extends DBSchema {
|
||||
};
|
||||
}
|
||||
|
||||
export class BlobIDBConnection extends Connection<IDBPDatabase<BlobDBSchema>> {
|
||||
export class BlobIDBConnection extends AutoReconnectConnection<
|
||||
IDBPDatabase<BlobDBSchema>
|
||||
> {
|
||||
constructor(private readonly workspaceId: string) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { share } from '../../../connection';
|
||||
import { type DocRecord, DocStorage, type DocUpdate } from '../../../storage';
|
||||
import {
|
||||
type DocRecord,
|
||||
DocStorageBase,
|
||||
type DocUpdate,
|
||||
} from '../../../storage';
|
||||
import { DocIDBConnection } from './db';
|
||||
|
||||
/**
|
||||
* @deprecated readonly
|
||||
*/
|
||||
export class IndexedDBV1DocStorage extends DocStorage {
|
||||
export class IndexedDBV1DocStorage extends DocStorageBase {
|
||||
readonly connection = share(new DocIDBConnection());
|
||||
|
||||
get db() {
|
||||
|
||||
Reference in New Issue
Block a user