Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blocksuite/store

Package Overview
Dependencies
Maintainers
2
Versions
1242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/store - npm Package Compare versions

Comparing version 0.2.18 to 0.2.19

6

CHANGELOG.md
# @blocksuite/store
## 0.2.19
### Patch Changes
- d8c1df4: refactor: redesign create editor API
## 0.2.16

@@ -4,0 +10,0 @@

1

dist/index.d.ts

@@ -8,2 +8,3 @@ export * from './store';

export * from './utils/utils';
export * from './providers';
//# sourceMappingURL=index.d.ts.map

@@ -8,2 +8,3 @@ export * from './store';

export * from './utils/utils';
export * from './providers';
const env = typeof globalThis !== 'undefined'

@@ -10,0 +11,0 @@ ? globalThis

import * as Y from 'yjs';
import { WebrtcProvider } from 'y-webrtc';
export declare class DebugProvider extends WebrtcProvider {
constructor(room: string, doc: Y.Doc);
import { Awareness } from 'y-protocols/awareness';
export declare abstract class Provider {
awareness?: Awareness;
abstract connect: () => void;
abstract disconnect: () => void;
abstract clearData: () => Promise<void>;
abstract destroy: () => void;
}
export declare type ProviderFactory = new (room: string, ydoc: Y.Doc, options?: {
awareness?: Awareness;
}) => Provider;
export declare class DebugProvider extends WebrtcProvider implements Provider {
constructor(room: string, doc: Y.Doc, options?: {
awareness?: Awareness;
});
clearData(): Promise<void>;
}
//# sourceMappingURL=providers.d.ts.map
import { WebrtcProvider } from 'y-webrtc';
export class Provider {
}
// type FactoryOptions = ConstructorParameters<ProviderFactory>;
export class DebugProvider extends WebrtcProvider {
constructor(room, doc) {
constructor(room, doc, options) {
super(room, doc, {
awareness: options?.awareness,
signaling: [

@@ -13,3 +17,7 @@ 'ws://localhost:4444',

}
clearData() {
// Do nothing for now
return Promise.resolve();
}
}
//# sourceMappingURL=providers.js.map

23

dist/store.d.ts

@@ -0,8 +1,9 @@

import Quill from 'quill';
import { Awareness } from 'y-protocols/awareness.js';
import * as Y from 'yjs';
import { AwarenessAdapter, SelectionRange } from './awareness';
import { BaseBlockModel } from './base';
import { Provider, ProviderFactory } from './providers';
import { PrelimText, RichTextAdapter, Text, TextType } from './text-adapter';
import { Signal } from './utils/signal';
import { PrelimText, RichTextAdapter, Text, TextType } from './text-adapter';
import Quill from 'quill';
import { SelectionRange, AwarenessAdapter } from './awareness';
import { BaseBlockModel } from './base';
import { DebugProvider } from './providers';
export declare type YBlock = Y.Map<unknown>;

@@ -30,9 +31,10 @@ export declare type YBlocks = Y.Map<YBlock>;

}
interface StoreOptions {
room: string;
useDebugProvider: boolean;
export interface StoreOptions {
room?: string;
providers?: ProviderFactory[];
awareness?: Awareness;
}
export declare class Store {
readonly doc: Y.Doc;
readonly provider?: DebugProvider;
readonly providers: Provider[];
readonly awareness: AwarenessAdapter;

@@ -54,3 +56,3 @@ readonly richTextAdapters: Map<string, RichTextAdapter>;

private _ignoredKeys;
constructor(options: StoreOptions);
constructor({ room, providers, awareness, }?: StoreOptions);
/** key-value store of blocks */

@@ -101,3 +103,2 @@ private get _yBlocks();

}
export {};
//# sourceMappingURL=store.d.ts.map
/// <reference types="vite/client" />
import { Awareness } from 'y-protocols/awareness.js';
import * as Y from 'yjs';
import { Signal } from './utils/signal';
import { PrelimText, RichTextAdapter, Text } from './text-adapter';
import { Awareness } from 'y-protocols/awareness.js';
import { AwarenessAdapter } from './awareness';
import { assertValidChildren, initSysProps, syncBlockProps, toBlockProps, trySyncTextProp, } from './utils/utils';
import { BaseBlockModel } from './base';
import { DebugProvider } from './providers';
import { PrelimText, RichTextAdapter, Text } from './text-adapter';
import { blockRecordToJSXNode } from './utils/jsx';
import { Signal } from './utils/signal';
import { assertValidChildren, initSysProps, syncBlockProps, toBlockProps, trySyncTextProp, } from './utils/utils';
// Workaround

@@ -16,5 +15,7 @@ const IS_WEB = typeof window !== 'undefined';

}
const DEFAULT_ROOM = 'virgo-default';
export class Store {
constructor(options) {
constructor({ room = DEFAULT_ROOM, providers = [], awareness, } = {}) {
this.doc = new Y.Doc();
this.providers = [];
this.richTextAdapters = new Map();

@@ -58,9 +59,6 @@ this.signals = {

};
if (IS_WEB && options.useDebugProvider) {
this.provider = new DebugProvider(options.room, this.doc);
}
const awareness = this.provider
? this.provider.awareness
: new Awareness(this.doc);
this.awareness = new AwarenessAdapter(this, awareness);
const aware = awareness ?? new Awareness(this.doc);
this.providers =
providers.map(Provider => new Provider(room, this.doc, { awareness: aware })) ?? [];
this.awareness = new AwarenessAdapter(this, aware);
this._yBlocks.observeDeep(this._yBlocksObserver);

@@ -67,0 +65,0 @@ this._history = new Y.UndoManager([this._yBlocks], {

{
"name": "@blocksuite/store",
"version": "0.2.18",
"version": "0.2.19",
"type": "module",

@@ -5,0 +5,0 @@ "description": "BlockSuite data store built for general purpose state management.",

@@ -8,2 +8,3 @@ export * from './store';

export * from './utils/utils';
export * from './providers';

@@ -10,0 +11,0 @@ const env =

import * as Y from 'yjs';
import { WebrtcProvider } from 'y-webrtc';
import { Awareness } from 'y-protocols/awareness';
export class DebugProvider extends WebrtcProvider {
constructor(room: string, doc: Y.Doc) {
export abstract class Provider {
awareness?: Awareness;
abstract connect: () => void;
abstract disconnect: () => void;
abstract clearData: () => Promise<void>;
abstract destroy: () => void;
}
export type ProviderFactory = new (
room: string,
ydoc: Y.Doc,
options?: { awareness?: Awareness }
) => Provider;
// type FactoryOptions = ConstructorParameters<ProviderFactory>;
export class DebugProvider extends WebrtcProvider implements Provider {
constructor(room: string, doc: Y.Doc, options?: { awareness?: Awareness }) {
super(room, doc, {
awareness: options?.awareness,
signaling: [

@@ -15,2 +33,7 @@ 'ws://localhost:4444',

}
public clearData() {
// Do nothing for now
return Promise.resolve();
}
}
/// <reference types="vite/client" />
import Quill from 'quill';
import { Awareness } from 'y-protocols/awareness.js';
import * as Y from 'yjs';
import { AwarenessAdapter, SelectionRange } from './awareness';
import { BaseBlockModel } from './base';
import { Provider, ProviderFactory } from './providers';
import { PrelimText, RichTextAdapter, Text, TextType } from './text-adapter';
import { blockRecordToJSXNode } from './utils/jsx';
import { Signal } from './utils/signal';
import { PrelimText, RichTextAdapter, Text, TextType } from './text-adapter';
import Quill from 'quill';
import { Awareness } from 'y-protocols/awareness.js';
import { SelectionRange, AwarenessAdapter } from './awareness';
import {

@@ -16,5 +19,2 @@ assertValidChildren,

} from './utils/utils';
import { BaseBlockModel } from './base';
import { DebugProvider } from './providers';
import { blockRecordToJSXNode } from './utils/jsx';

@@ -56,10 +56,13 @@ export type YBlock = Y.Map<unknown>;

interface StoreOptions {
room: string;
useDebugProvider: boolean;
export interface StoreOptions {
room?: string;
providers?: ProviderFactory[];
awareness?: Awareness;
}
const DEFAULT_ROOM = 'virgo-default';
export class Store {
readonly doc = new Y.Doc();
readonly provider?: DebugProvider;
readonly providers: Provider[] = [];
readonly awareness!: AwarenessAdapter;

@@ -88,12 +91,15 @@ readonly richTextAdapters = new Map<string, RichTextAdapter>();

constructor(options: StoreOptions) {
if (IS_WEB && options.useDebugProvider) {
this.provider = new DebugProvider(options.room, this.doc);
}
constructor({
room = DEFAULT_ROOM,
providers = [],
awareness,
}: StoreOptions = {}) {
const aware = awareness ?? new Awareness(this.doc);
const awareness = this.provider
? this.provider.awareness
: new Awareness(this.doc);
this.awareness = new AwarenessAdapter(this, awareness);
this.providers =
providers.map(
Provider => new Provider(room, this.doc, { awareness: aware })
) ?? [];
this.awareness = new AwarenessAdapter(this, aware);
this._yBlocks.observeDeep(this._yBlocksObserver);

@@ -100,0 +106,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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc