mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 01:26:37 +08:00
feat: fix private prefix
This commit is contained in:
@@ -3,8 +3,8 @@ import { Array as YArray, Map as YMap } from 'yjs';
|
||||
import { RemoteKvService } from '@toeverything/datasource/remote-kv';
|
||||
|
||||
export class YjsRemoteBinaries {
|
||||
readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance
|
||||
readonly _remoteStorage?: RemoteKvService;
|
||||
private readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance
|
||||
private readonly _remoteStorage?: RemoteKvService;
|
||||
|
||||
constructor(binaries: YMap<YArray<ArrayBuffer>>, remote_token?: string) {
|
||||
this._binaries = binaries;
|
||||
|
||||
@@ -32,19 +32,21 @@ type YjsBlockInstanceProps = {
|
||||
};
|
||||
|
||||
export class YjsBlockInstance implements BlockInstance<YjsContentOperation> {
|
||||
readonly _id: string;
|
||||
readonly _block: YMap<unknown>;
|
||||
readonly _binary?: YArray<ArrayBuffer>;
|
||||
readonly _children: YArray<string>;
|
||||
readonly _setBlock: (
|
||||
private readonly _id: string;
|
||||
private readonly _block: YMap<unknown>;
|
||||
private readonly _binary?: YArray<ArrayBuffer>;
|
||||
private readonly _children: YArray<string>;
|
||||
private readonly _setBlock: (
|
||||
id: string,
|
||||
block: BlockItem<YjsContentOperation>
|
||||
) => Promise<void>;
|
||||
readonly _getUpdated: (id: string) => number | undefined;
|
||||
readonly _getCreator: (id: string) => string | undefined;
|
||||
readonly _getBlockInstance: (id: string) => YjsBlockInstance | undefined;
|
||||
readonly _childrenListeners: Map<string, BlockListener>;
|
||||
readonly _contentListeners: Map<string, BlockListener>;
|
||||
private readonly _getUpdated: (id: string) => number | undefined;
|
||||
private readonly _getCreator: (id: string) => string | undefined;
|
||||
private readonly _getBlockInstance: (
|
||||
id: string
|
||||
) => YjsBlockInstance | undefined;
|
||||
private readonly _childrenListeners: Map<string, BlockListener>;
|
||||
private readonly _contentListeners: Map<string, BlockListener>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
_childrenMap: Map<string, number>;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Map as YMap } from 'yjs';
|
||||
|
||||
export class GateKeeper {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
_userId: string;
|
||||
_creators: YMap<string>;
|
||||
_common: YMap<string>;
|
||||
private readonly _userId: string;
|
||||
private readonly _creators: YMap<string>;
|
||||
private readonly _common: YMap<string>;
|
||||
|
||||
constructor(userId: string, creators: YMap<string>, common: YMap<string>) {
|
||||
this._userId = userId;
|
||||
|
||||
@@ -5,10 +5,10 @@ import { HistoryCallback, HistoryManager } from '../../adapter';
|
||||
type StackItem = UndoManager['undoStack'][0];
|
||||
|
||||
export class YjsHistoryManager implements HistoryManager {
|
||||
readonly _blocks: YMap<any>;
|
||||
readonly _historyManager: UndoManager;
|
||||
readonly _pushListeners: Map<string, HistoryCallback<any>>;
|
||||
readonly _popListeners: Map<string, HistoryCallback<any>>;
|
||||
private readonly _blocks: YMap<any>;
|
||||
private readonly _historyManager: UndoManager;
|
||||
private readonly _pushListeners: Map<string, HistoryCallback<any>>;
|
||||
private readonly _popListeners: Map<string, HistoryCallback<any>>;
|
||||
|
||||
constructor(scope: YMap<any>, tracker?: any[]) {
|
||||
this._blocks = scope;
|
||||
|
||||
@@ -178,22 +178,22 @@ export type YjsInitOptions = {
|
||||
};
|
||||
|
||||
export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
|
||||
readonly _provider: YjsProviders;
|
||||
readonly _doc: Doc; // doc instance
|
||||
readonly _awareness: Awareness; // lightweight state synchronization
|
||||
readonly _gatekeeper: GateKeeper; // Simple access control
|
||||
readonly _history: YjsHistoryManager;
|
||||
private readonly _provider: YjsProviders;
|
||||
private readonly _doc: Doc; // doc instance
|
||||
private readonly _awareness: Awareness; // lightweight state synchronization
|
||||
private readonly _gatekeeper: GateKeeper; // Simple access control
|
||||
private readonly _history: YjsHistoryManager;
|
||||
|
||||
// Block Collection
|
||||
// key is a randomly generated global id
|
||||
readonly _blocks: YMap<YMap<unknown>>;
|
||||
readonly _blockUpdated: YMap<number>;
|
||||
private readonly _blocks: YMap<YMap<unknown>>;
|
||||
private readonly _blockUpdated: YMap<number>;
|
||||
// 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(
|
||||
workspace: string,
|
||||
|
||||
@@ -52,7 +52,7 @@ function auto_set(root: ContentOperation, key: string, data: BaseTypes): void {
|
||||
}
|
||||
|
||||
export class YjsContentOperation implements ContentOperation {
|
||||
readonly _content: YAbstractType<unknown>;
|
||||
private readonly _content: YAbstractType<unknown>;
|
||||
|
||||
constructor(content: YAbstractType<any>) {
|
||||
this._content = content;
|
||||
@@ -197,7 +197,7 @@ export class YjsContentOperation implements ContentOperation {
|
||||
}
|
||||
|
||||
class YjsTextOperation extends YjsContentOperation implements TextOperation {
|
||||
readonly _textContent: YText;
|
||||
private readonly _textContent: YText;
|
||||
|
||||
constructor(content: YText) {
|
||||
super(content);
|
||||
@@ -241,8 +241,8 @@ class YjsArrayOperation<T extends ContentTypes>
|
||||
extends YjsContentOperation
|
||||
implements ArrayOperation<T>
|
||||
{
|
||||
readonly _arrayContent: YArray<T>;
|
||||
readonly _listeners: Map<string, BlockListener>;
|
||||
private readonly _arrayContent: YArray<T>;
|
||||
private readonly _listeners: Map<string, BlockListener>;
|
||||
|
||||
constructor(content: YArray<T>) {
|
||||
super(content);
|
||||
@@ -344,8 +344,8 @@ class YjsMapOperation<T extends ContentTypes>
|
||||
extends YjsContentOperation
|
||||
implements MapOperation<T>
|
||||
{
|
||||
readonly _mapContent: YMap<T>;
|
||||
readonly _listeners: Map<string, BlockListener>;
|
||||
private readonly _mapContent: YMap<T>;
|
||||
private readonly _listeners: Map<string, BlockListener>;
|
||||
|
||||
constructor(content: YMap<T>) {
|
||||
super(content);
|
||||
|
||||
Reference in New Issue
Block a user