mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 10:31:30 +03:00
feat: fix private prefix
This commit is contained in:
parent
c63d5da4df
commit
1a43ce4d02
@ -3,8 +3,8 @@ import { Array as YArray, Map as YMap } from 'yjs';
|
|||||||
import { RemoteKvService } from '@toeverything/datasource/remote-kv';
|
import { RemoteKvService } from '@toeverything/datasource/remote-kv';
|
||||||
|
|
||||||
export class YjsRemoteBinaries {
|
export class YjsRemoteBinaries {
|
||||||
readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance
|
private readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance
|
||||||
readonly _remoteStorage?: RemoteKvService;
|
private readonly _remoteStorage?: RemoteKvService;
|
||||||
|
|
||||||
constructor(binaries: YMap<YArray<ArrayBuffer>>, remote_token?: string) {
|
constructor(binaries: YMap<YArray<ArrayBuffer>>, remote_token?: string) {
|
||||||
this._binaries = binaries;
|
this._binaries = binaries;
|
||||||
|
@ -32,19 +32,21 @@ type YjsBlockInstanceProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class YjsBlockInstance implements BlockInstance<YjsContentOperation> {
|
export class YjsBlockInstance implements BlockInstance<YjsContentOperation> {
|
||||||
readonly _id: string;
|
private readonly _id: string;
|
||||||
readonly _block: YMap<unknown>;
|
private readonly _block: YMap<unknown>;
|
||||||
readonly _binary?: YArray<ArrayBuffer>;
|
private readonly _binary?: YArray<ArrayBuffer>;
|
||||||
readonly _children: YArray<string>;
|
private readonly _children: YArray<string>;
|
||||||
readonly _setBlock: (
|
private readonly _setBlock: (
|
||||||
id: string,
|
id: string,
|
||||||
block: BlockItem<YjsContentOperation>
|
block: BlockItem<YjsContentOperation>
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
readonly _getUpdated: (id: string) => number | undefined;
|
private readonly _getUpdated: (id: string) => number | undefined;
|
||||||
readonly _getCreator: (id: string) => string | undefined;
|
private readonly _getCreator: (id: string) => string | undefined;
|
||||||
readonly _getBlockInstance: (id: string) => YjsBlockInstance | undefined;
|
private readonly _getBlockInstance: (
|
||||||
readonly _childrenListeners: Map<string, BlockListener>;
|
id: string
|
||||||
readonly _contentListeners: Map<string, BlockListener>;
|
) => YjsBlockInstance | undefined;
|
||||||
|
private readonly _childrenListeners: Map<string, BlockListener>;
|
||||||
|
private readonly _contentListeners: Map<string, BlockListener>;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
_childrenMap: Map<string, number>;
|
_childrenMap: Map<string, number>;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { Map as YMap } from 'yjs';
|
import { Map as YMap } from 'yjs';
|
||||||
|
|
||||||
export class GateKeeper {
|
export class GateKeeper {
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
private readonly _userId: string;
|
||||||
_userId: string;
|
private readonly _creators: YMap<string>;
|
||||||
_creators: YMap<string>;
|
private readonly _common: YMap<string>;
|
||||||
_common: YMap<string>;
|
|
||||||
|
|
||||||
constructor(userId: string, creators: YMap<string>, common: YMap<string>) {
|
constructor(userId: string, creators: YMap<string>, common: YMap<string>) {
|
||||||
this._userId = userId;
|
this._userId = userId;
|
||||||
|
@ -5,10 +5,10 @@ import { HistoryCallback, HistoryManager } from '../../adapter';
|
|||||||
type StackItem = UndoManager['undoStack'][0];
|
type StackItem = UndoManager['undoStack'][0];
|
||||||
|
|
||||||
export class YjsHistoryManager implements HistoryManager {
|
export class YjsHistoryManager implements HistoryManager {
|
||||||
readonly _blocks: YMap<any>;
|
private readonly _blocks: YMap<any>;
|
||||||
readonly _historyManager: UndoManager;
|
private readonly _historyManager: UndoManager;
|
||||||
readonly _pushListeners: Map<string, HistoryCallback<any>>;
|
private readonly _pushListeners: Map<string, HistoryCallback<any>>;
|
||||||
readonly _popListeners: Map<string, HistoryCallback<any>>;
|
private readonly _popListeners: Map<string, HistoryCallback<any>>;
|
||||||
|
|
||||||
constructor(scope: YMap<any>, tracker?: any[]) {
|
constructor(scope: YMap<any>, tracker?: any[]) {
|
||||||
this._blocks = scope;
|
this._blocks = scope;
|
||||||
|
@ -178,22 +178,22 @@ export type YjsInitOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
|
export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
|
||||||
readonly _provider: YjsProviders;
|
private readonly _provider: YjsProviders;
|
||||||
readonly _doc: Doc; // doc instance
|
private readonly _doc: Doc; // doc instance
|
||||||
readonly _awareness: Awareness; // lightweight state synchronization
|
private readonly _awareness: Awareness; // lightweight state synchronization
|
||||||
readonly _gatekeeper: GateKeeper; // Simple access control
|
private readonly _gatekeeper: GateKeeper; // Simple access control
|
||||||
readonly _history: YjsHistoryManager;
|
private readonly _history: YjsHistoryManager;
|
||||||
|
|
||||||
// Block Collection
|
// Block Collection
|
||||||
// key is a randomly generated global id
|
// key is a randomly generated global id
|
||||||
readonly _blocks: YMap<YMap<unknown>>;
|
private readonly _blocks: YMap<YMap<unknown>>;
|
||||||
readonly _blockUpdated: YMap<number>;
|
private readonly _blockUpdated: YMap<number>;
|
||||||
// Maximum cache Block 1024, ttl 10 minutes
|
// Maximum cache Block 1024, ttl 10 minutes
|
||||||
readonly _blockCaches: LRUCache<string, YjsBlockInstance>;
|
private readonly _blockCaches: LRUCache<string, YjsBlockInstance>;
|
||||||
|
|
||||||
readonly _binaries: YjsRemoteBinaries;
|
private readonly _binaries: YjsRemoteBinaries;
|
||||||
|
|
||||||
readonly _listener: Map<string, BlockListener<any>>;
|
private readonly _listener: Map<string, BlockListener<any>>;
|
||||||
|
|
||||||
static async init(
|
static async init(
|
||||||
workspace: string,
|
workspace: string,
|
||||||
|
@ -52,7 +52,7 @@ function auto_set(root: ContentOperation, key: string, data: BaseTypes): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class YjsContentOperation implements ContentOperation {
|
export class YjsContentOperation implements ContentOperation {
|
||||||
readonly _content: YAbstractType<unknown>;
|
private readonly _content: YAbstractType<unknown>;
|
||||||
|
|
||||||
constructor(content: YAbstractType<any>) {
|
constructor(content: YAbstractType<any>) {
|
||||||
this._content = content;
|
this._content = content;
|
||||||
@ -197,7 +197,7 @@ export class YjsContentOperation implements ContentOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YjsTextOperation extends YjsContentOperation implements TextOperation {
|
class YjsTextOperation extends YjsContentOperation implements TextOperation {
|
||||||
readonly _textContent: YText;
|
private readonly _textContent: YText;
|
||||||
|
|
||||||
constructor(content: YText) {
|
constructor(content: YText) {
|
||||||
super(content);
|
super(content);
|
||||||
@ -241,8 +241,8 @@ class YjsArrayOperation<T extends ContentTypes>
|
|||||||
extends YjsContentOperation
|
extends YjsContentOperation
|
||||||
implements ArrayOperation<T>
|
implements ArrayOperation<T>
|
||||||
{
|
{
|
||||||
readonly _arrayContent: YArray<T>;
|
private readonly _arrayContent: YArray<T>;
|
||||||
readonly _listeners: Map<string, BlockListener>;
|
private readonly _listeners: Map<string, BlockListener>;
|
||||||
|
|
||||||
constructor(content: YArray<T>) {
|
constructor(content: YArray<T>) {
|
||||||
super(content);
|
super(content);
|
||||||
@ -344,8 +344,8 @@ class YjsMapOperation<T extends ContentTypes>
|
|||||||
extends YjsContentOperation
|
extends YjsContentOperation
|
||||||
implements MapOperation<T>
|
implements MapOperation<T>
|
||||||
{
|
{
|
||||||
readonly _mapContent: YMap<T>;
|
private readonly _mapContent: YMap<T>;
|
||||||
readonly _listeners: Map<string, BlockListener>;
|
private readonly _listeners: Map<string, BlockListener>;
|
||||||
|
|
||||||
constructor(content: YMap<T>) {
|
constructor(content: YMap<T>) {
|
||||||
super(content);
|
super(content);
|
||||||
|
@ -26,11 +26,11 @@ export class AbstractBlock<
|
|||||||
B extends BlockInstance<C>,
|
B extends BlockInstance<C>,
|
||||||
C extends ContentOperation
|
C extends ContentOperation
|
||||||
> {
|
> {
|
||||||
readonly _id: string;
|
private readonly _id: string;
|
||||||
readonly #block: BlockInstance<C>;
|
readonly #block: BlockInstance<C>;
|
||||||
readonly _history: HistoryManager;
|
private readonly _history: HistoryManager;
|
||||||
readonly _root?: AbstractBlock<B, C>;
|
private readonly _root?: AbstractBlock<B, C>;
|
||||||
readonly _parentListener: Map<string, BlockListener>;
|
private readonly _parentListener: Map<string, BlockListener>;
|
||||||
|
|
||||||
_parent?: AbstractBlock<B, C>;
|
_parent?: AbstractBlock<B, C>;
|
||||||
|
|
||||||
|
@ -51,19 +51,19 @@ export class BaseBlock<
|
|||||||
B extends BlockInstance<C>,
|
B extends BlockInstance<C>,
|
||||||
C extends ContentOperation
|
C extends ContentOperation
|
||||||
> extends AbstractBlock<B, C> {
|
> extends AbstractBlock<B, C> {
|
||||||
readonly _exporters?: Exporters;
|
private readonly _exporters?: Exporters;
|
||||||
readonly _contentExportersGetter: () => Map<
|
private readonly _contentExportersGetter: () => Map<
|
||||||
string,
|
string,
|
||||||
ReadableContentExporter<string, any>
|
ReadableContentExporter<string, any>
|
||||||
>;
|
>;
|
||||||
readonly _metadataExportersGetter: () => Map<
|
private readonly _metadataExportersGetter: () => Map<
|
||||||
string,
|
string,
|
||||||
ReadableContentExporter<
|
ReadableContentExporter<
|
||||||
Array<[string, number | string | string[]]>,
|
Array<[string, number | string | string[]]>,
|
||||||
any
|
any
|
||||||
>
|
>
|
||||||
>;
|
>;
|
||||||
readonly _tagExportersGetter: () => Map<
|
private readonly _tagExportersGetter: () => Map<
|
||||||
string,
|
string,
|
||||||
ReadableContentExporter<string[], any>
|
ReadableContentExporter<string[], any>
|
||||||
>;
|
>;
|
||||||
|
@ -107,18 +107,18 @@ export class BlockIndexer<
|
|||||||
B extends BlockInstance<C>,
|
B extends BlockInstance<C>,
|
||||||
C extends ContentOperation
|
C extends ContentOperation
|
||||||
> {
|
> {
|
||||||
readonly _adapter: A;
|
private readonly _adapter: A;
|
||||||
readonly _idb: BlockIdbInstance;
|
private readonly _idb: BlockIdbInstance;
|
||||||
|
|
||||||
readonly _blockIndexer: DocumentIndexer<IndexMetadata>;
|
private readonly _blockIndexer: DocumentIndexer<IndexMetadata>;
|
||||||
readonly _blockMetadata: LRUCache<string, QueryMetadata>;
|
private readonly _blockMetadata: LRUCache<string, QueryMetadata>;
|
||||||
readonly _eventBus: BlockEventBus;
|
private readonly _eventBus: BlockEventBus;
|
||||||
|
|
||||||
readonly _blockBuilder: (
|
private readonly _blockBuilder: (
|
||||||
block: BlockInstance<C>
|
block: BlockInstance<C>
|
||||||
) => Promise<BaseBlock<B, C>>;
|
) => Promise<BaseBlock<B, C>>;
|
||||||
|
|
||||||
readonly _delayIndex: { documents: Map<string, BaseBlock<B, C>> };
|
private readonly _delayIndex: { documents: Map<string, BaseBlock<B, C>> };
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
adapter: A,
|
adapter: A,
|
||||||
|
@ -69,14 +69,14 @@ export class BlockClient<
|
|||||||
B extends BlockInstance<C>,
|
B extends BlockInstance<C>,
|
||||||
C extends ContentOperation
|
C extends ContentOperation
|
||||||
> {
|
> {
|
||||||
readonly _adapter: A;
|
private readonly _adapter: A;
|
||||||
readonly _workspace: string;
|
private readonly _workspace: string;
|
||||||
|
|
||||||
// Maximum cache Block 8192, ttl 30 minutes
|
// Maximum cache Block 8192, ttl 30 minutes
|
||||||
readonly _blockCaches: LRUCache<string, BaseBlock<B, C>>;
|
private readonly _blockCaches: LRUCache<string, BaseBlock<B, C>>;
|
||||||
readonly _blockIndexer: BlockIndexer<A, B, C>;
|
private readonly _blockIndexer: BlockIndexer<A, B, C>;
|
||||||
|
|
||||||
readonly _exporters: {
|
private readonly _exporters: {
|
||||||
readonly content: BlockExporters<string>;
|
readonly content: BlockExporters<string>;
|
||||||
readonly metadata: BlockExporters<
|
readonly metadata: BlockExporters<
|
||||||
Array<[string, number | string | string[]]>
|
Array<[string, number | string | string[]]>
|
||||||
@ -84,12 +84,12 @@ export class BlockClient<
|
|||||||
readonly tag: BlockExporters<string[]>;
|
readonly tag: BlockExporters<string[]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
readonly _eventBus: BlockEventBus;
|
private readonly _eventBus: BlockEventBus;
|
||||||
|
|
||||||
readonly _parentMapping: Map<string, string[]>;
|
private readonly _parentMapping: Map<string, string[]>;
|
||||||
readonly _pageMapping: Map<string, string>;
|
private readonly _pageMapping: Map<string, string>;
|
||||||
|
|
||||||
readonly _root: { node?: BaseBlock<B, C> };
|
private readonly _root: { node?: BaseBlock<B, C> };
|
||||||
|
|
||||||
private constructor(
|
private constructor(
|
||||||
adapter: A,
|
adapter: A,
|
||||||
|
@ -7,9 +7,9 @@ declare const JWT_DEV: boolean;
|
|||||||
const logger = getLogger('BlockDB:event_bus');
|
const logger = getLogger('BlockDB:event_bus');
|
||||||
|
|
||||||
export class BlockEventBus {
|
export class BlockEventBus {
|
||||||
readonly _eventBus: EventTarget;
|
private readonly _eventBus: EventTarget;
|
||||||
readonly _eventCallbackCache: Map<string, any>;
|
private readonly _eventCallbackCache: Map<string, any>;
|
||||||
readonly _scopedCache: Map<string, BlockScopedEventBus<any>>;
|
private readonly _scopedCache: Map<string, BlockScopedEventBus<any>>;
|
||||||
|
|
||||||
constructor(event_bus?: EventTarget) {
|
constructor(event_bus?: EventTarget) {
|
||||||
this._eventBus = event_bus || new EventTarget();
|
this._eventBus = event_bus || new EventTarget();
|
||||||
@ -68,7 +68,7 @@ type ListenerOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class BlockScopedEventBus<T> extends BlockEventBus {
|
class BlockScopedEventBus<T> extends BlockEventBus {
|
||||||
readonly _topic: string;
|
private readonly _topic: string;
|
||||||
|
|
||||||
constructor(topic: string, event_bus?: EventTarget) {
|
constructor(topic: string, event_bus?: EventTarget) {
|
||||||
super(event_bus);
|
super(event_bus);
|
||||||
|
Loading…
Reference in New Issue
Block a user