@blocksuite/store
Advanced tools
Comparing version
@@ -16,3 +16,3 @@ /// <reference types="@blocksuite/global" /> | ||
} | ||
interface AwarenessState<Flags extends Record<string, boolean> = BlockSuiteFlags> { | ||
interface AwarenessState<Flags extends Record<string, unknown> = BlockSuiteFlags> { | ||
cursor?: SelectionRange; | ||
@@ -22,3 +22,3 @@ user?: UserInfo; | ||
} | ||
interface AwarenessMessage<Flags extends Record<string, boolean> = BlockSuiteFlags> { | ||
interface AwarenessMessage<Flags extends Record<string, unknown> = BlockSuiteFlags> { | ||
id: number; | ||
@@ -28,7 +28,7 @@ type: 'add' | 'update' | 'remove'; | ||
} | ||
export interface AwarenessMetadataMessage<Flags extends Record<string, boolean> = BlockSuiteFlags, Key extends keyof Flags = keyof Flags> { | ||
export interface AwarenessMetadataMessage<Flags extends Record<string, unknown> = BlockSuiteFlags, Key extends keyof Flags = keyof Flags> { | ||
field: Key; | ||
value: Flags[Key]; | ||
} | ||
export declare class AwarenessAdapter<Flags extends Record<string, boolean> = BlockSuiteFlags> { | ||
export declare class AwarenessAdapter<Flags extends Record<string, unknown> = BlockSuiteFlags> { | ||
readonly space: Space<any, Flags>; | ||
@@ -35,0 +35,0 @@ readonly awareness: Awareness; |
@@ -12,3 +12,3 @@ /// <reference types="@blocksuite/global" /> | ||
} | ||
export declare class Space<Data extends Record<string, unknown> = Record<string, any>, Flags extends Record<string, boolean> = BlockSuiteFlags> { | ||
export declare class Space<Data extends Record<string, unknown> = Record<string, any>, Flags extends Record<string, unknown> = BlockSuiteFlags> { | ||
/** unprefixed id */ | ||
@@ -15,0 +15,0 @@ readonly id: string; |
@@ -39,3 +39,3 @@ /// <reference types="@blocksuite/global" /> | ||
} | ||
export interface StoreOptions<Flags extends Record<string, boolean> = BlockSuiteFlags> extends SSROptions { | ||
export interface StoreOptions<Flags extends Record<string, unknown> = BlockSuiteFlags> extends SSROptions { | ||
room?: string; | ||
@@ -42,0 +42,0 @@ providers?: DocProviderConstructor[]; |
@@ -87,2 +87,3 @@ import * as Y from 'yjs'; | ||
focus: Y.RelativePosition; | ||
selection: import("quill").RangeStatic; | ||
} | null; | ||
@@ -89,0 +90,0 @@ destroy(): void; |
@@ -281,2 +281,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
focus, | ||
selection, | ||
}; | ||
@@ -283,0 +284,0 @@ } |
@@ -157,2 +157,5 @@ import * as Y from 'yjs'; | ||
} | ||
const flagsPreset = { | ||
enable_drag_handle: true, | ||
}; | ||
export class Workspace { | ||
@@ -171,3 +174,6 @@ constructor(options) { | ||
this.room = options.room; | ||
this.meta = new WorkspaceMeta('space:meta', this.doc, this._store.awareness, options.defaultFlags); | ||
this.meta = new WorkspaceMeta('space:meta', this.doc, this._store.awareness, { | ||
...flagsPreset, | ||
...options.defaultFlags, | ||
}); | ||
this.signals = { | ||
@@ -174,0 +180,0 @@ pagesUpdated: this.meta.pagesUpdated, |
{ | ||
"name": "@blocksuite/store", | ||
"version": "0.4.0-20230111171650-bc63456", | ||
"version": "0.4.0-20230112162116-2214e7b", | ||
"description": "BlockSuite data store built for general purpose state management.", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@blocksuite/global": "0.4.0-20230111171650-bc63456", | ||
"@blocksuite/global": "0.4.0-20230112162116-2214e7b", | ||
"@types/flexsearch": "^0.7.3", | ||
@@ -14,0 +14,0 @@ "@types/quill": "^1.3.7", |
@@ -21,3 +21,3 @@ import * as Y from 'yjs'; | ||
interface AwarenessState< | ||
Flags extends Record<string, boolean> = BlockSuiteFlags | ||
Flags extends Record<string, unknown> = BlockSuiteFlags | ||
> { | ||
@@ -30,3 +30,3 @@ cursor?: SelectionRange; | ||
interface AwarenessMessage< | ||
Flags extends Record<string, boolean> = BlockSuiteFlags | ||
Flags extends Record<string, unknown> = BlockSuiteFlags | ||
> { | ||
@@ -39,3 +39,3 @@ id: number; | ||
export interface AwarenessMetadataMessage< | ||
Flags extends Record<string, boolean> = BlockSuiteFlags, | ||
Flags extends Record<string, unknown> = BlockSuiteFlags, | ||
Key extends keyof Flags = keyof Flags | ||
@@ -48,3 +48,3 @@ > { | ||
export class AwarenessAdapter< | ||
Flags extends Record<string, boolean> = BlockSuiteFlags | ||
Flags extends Record<string, unknown> = BlockSuiteFlags | ||
> { | ||
@@ -51,0 +51,0 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any |
@@ -16,3 +16,3 @@ import type * as Y from 'yjs'; | ||
Data extends Record<string, unknown> = Record<string, any>, | ||
Flags extends Record<string, boolean> = BlockSuiteFlags | ||
Flags extends Record<string, unknown> = BlockSuiteFlags | ||
> { | ||
@@ -19,0 +19,0 @@ /** unprefixed id */ |
@@ -49,3 +49,3 @@ import type { Space } from './space.js'; | ||
export interface StoreOptions< | ||
Flags extends Record<string, boolean> = BlockSuiteFlags | ||
Flags extends Record<string, unknown> = BlockSuiteFlags | ||
> extends SSROptions { | ||
@@ -52,0 +52,0 @@ room?: string; |
@@ -396,2 +396,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
focus, | ||
selection, | ||
}; | ||
@@ -398,0 +399,0 @@ } |
@@ -216,2 +216,6 @@ import * as Y from 'yjs'; | ||
const flagsPreset: BlockSuiteFlags = { | ||
enable_drag_handle: true, | ||
} as const; | ||
export class Workspace { | ||
@@ -250,3 +254,6 @@ static Y = Y; | ||
this._store.awareness, | ||
options.defaultFlags | ||
{ | ||
...flagsPreset, | ||
...options.defaultFlags, | ||
} | ||
); | ||
@@ -253,0 +260,0 @@ |
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
469582
0.09%7708
0.19%+ Added
- Removed