New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@blocksuite/store

Package Overview
Dependencies
Maintainers
5
Versions
1285
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.4.0-alpha.2 to 0.4.0-alpha.3

4

dist/awareness.d.ts
/// <reference types="@blocksuite/global" />
import { Signal } from '@blocksuite/global/utils';
import type { Awareness as YAwareness } from 'y-protocols/awareness.js';
import type { RelativePosition } from 'yjs';
import type { Awareness as YAwareness } from 'y-protocols/awareness.js';
import { Signal } from '@blocksuite/global/utils';
import type { Space } from './space.js';

@@ -6,0 +6,0 @@ import type { Store } from './store.js';

@@ -1,4 +0,4 @@

import * as Y from 'yjs';
import { Signal } from '@blocksuite/global/utils';
import { merge } from 'merge';
import * as Y from 'yjs';
import { uuidv4 } from './utils/id-generator.js';

@@ -5,0 +5,0 @@ export var BlobUploadState;

/// <reference types="@blocksuite/global" />
import type { Page } from './workspace/index.js';
import type { TextType } from './text-adapter.js';
import { Signal } from '@blocksuite/global/utils';
import type * as Y from 'yjs';
import { z } from 'zod';
import type { TextType } from './text-adapter.js';
import type { Page } from './workspace/index.js';
export declare const BlockSchema: z.ZodObject<{

@@ -8,0 +8,0 @@ version: z.ZodNumber;

@@ -0,13 +1,13 @@

export * from './awareness.js';
export * from './base.js';
export * from './persistence/blob/index.js';
export * from './persistence/doc/index.js';
export * from './space.js';
export * from './store.js';
export * from './base.js';
export * from './awareness.js';
export * from './persistence/blob/index.js';
export * from './text-adapter.js';
export type { IdGenerator } from './utils/id-generator.js';
export { createAutoIncrementIdGenerator, createAutoIncrementIdGeneratorByClientId, nanoid, uuidv4, } from './utils/id-generator.js';
export * as Utils from './utils/utils.js';
export * from './workspace/index.js';
export * from '@blocksuite/global/utils';
export * from './persistence/doc/index.js';
export * from './workspace/index.js';
export * as Utils from './utils/utils.js';
export { createAutoIncrementIdGenerator, createAutoIncrementIdGeneratorByClientId, uuidv4, nanoid, } from './utils/id-generator.js';
export type { IdGenerator } from './utils/id-generator.js';
//# sourceMappingURL=index.d.ts.map
/// <reference types="@blocksuite/global" />
export * from './awareness.js';
export * from './base.js';
export * from './persistence/blob/index.js';
export * from './persistence/doc/index.js';
export * from './space.js';
export * from './store.js';
export * from './base.js';
export * from './awareness.js';
export * from './persistence/blob/index.js';
export * from './text-adapter.js';
export { createAutoIncrementIdGenerator, createAutoIncrementIdGeneratorByClientId, nanoid, uuidv4, } from './utils/id-generator.js';
export * as Utils from './utils/utils.js';
export * from './workspace/index.js';
export * from '@blocksuite/global/utils';
export * from './persistence/doc/index.js';
export * from './workspace/index.js';
export * as Utils from './utils/utils.js';
export { createAutoIncrementIdGenerator, createAutoIncrementIdGeneratorByClientId, uuidv4, nanoid, } from './utils/id-generator.js';
const env = typeof globalThis !== 'undefined'

@@ -14,0 +14,0 @@ ? globalThis

@@ -0,3 +1,3 @@

import type { BlobOptionsGetter } from './duplex-provider.js';
import type { BlobId, BlobProvider } from './types.js';
import type { BlobOptionsGetter } from './duplex-provider.js';
export declare class CloudSyncManager {

@@ -4,0 +4,0 @@ private readonly _db;

@@ -0,3 +1,3 @@

import { Signal, sleep } from '@blocksuite/global/utils';
import ky from 'ky';
import { Signal, sleep } from '@blocksuite/global/utils';
import { BlobSyncState } from './types.js';

@@ -4,0 +4,0 @@ import { getDatabase } from './utils.js';

import { Signal } from '@blocksuite/global/utils';
import type { BlobId, BlobProvider, BlobURL, BlobSyncStateChangeEvent } from './types.js';
import type { BlobId, BlobProvider, BlobSyncStateChangeEvent, BlobURL } from './types.js';
export type BlobOptions = Record<'api' | 'token', string>;

@@ -4,0 +4,0 @@ export type BlobOptionsGetter = (key: keyof BlobOptions) => string | undefined;

@@ -1,7 +0,7 @@

import type { BlobOptionsGetter, BlobOptions } from './duplex-provider.js';
import type { BlobOptions, BlobOptionsGetter } from './duplex-provider.js';
import { BlobStorage } from './storage.js';
export declare function getBlobStorage(workspace?: string, optionsGetter?: BlobOptionsGetter): Promise<BlobStorage | null>;
export { BlobStorage } from './storage.js';
export type { BlobOptionsGetter, BlobOptions };
export type { BlobOptions, BlobOptionsGetter };
export { BlobSyncState } from './types.js';
//# sourceMappingURL=index.d.ts.map
import { Signal } from '@blocksuite/global/utils';
import type { BlobId, BlobProvider, BlobURL, BlobSyncStateChangeEvent } from './types.js';
import type { BlobId, BlobProvider, BlobSyncStateChangeEvent, BlobURL } from './types.js';
export declare class BlobStorage {

@@ -4,0 +4,0 @@ private _provider;

@@ -1,3 +0,3 @@

import { createStore, del, get, keys, set, clear, values } from 'idb-keyval';
import { Buffer } from 'buffer';
import { clear, createStore, del, get, keys, set, values } from 'idb-keyval';
export async function sha(input) {

@@ -4,0 +4,0 @@ const hash = await crypto.subtle.digest('SHA-256', input);

@@ -0,11 +1,17 @@

import { Signal } from '@blocksuite/global/utils';
import type { Awareness } from 'y-protocols/awareness';
import { WebrtcProvider } from 'y-webrtc';
import type * as Y from 'yjs';
import { WebrtcProvider } from 'y-webrtc';
import type { DocProvider } from './index.js';
import type { Awareness } from 'y-protocols/awareness';
export declare class DebugDocProvider extends WebrtcProvider implements DocProvider {
private readonly _doc;
remoteUpdateSignal: Signal<unknown>;
constructor(room: string, doc: Y.Doc, options?: {
awareness?: Awareness;
});
private _handleRemoteUpdate;
connect: () => void;
disconnect: () => void;
clearData(): Promise<void>;
}
//# sourceMappingURL=debug-provider.d.ts.map

@@ -0,4 +1,4 @@

import { isWeb, Signal } from '@blocksuite/global/utils';
// @ts-ignore
import { WebrtcProvider } from 'y-webrtc';
import { isWeb } from '@blocksuite/global/utils';
import { Room, WebrtcProvider } from 'y-webrtc';
// When using playground from blocksuite repo, t./idb-provider.js "serve" script in "@blocksuite/store" package.

@@ -23,2 +23,17 @@ // We use our own sync server because a local service for sync makes everything much faster for dev.

});
this.remoteUpdateSignal = new Signal();
this._handleRemoteUpdate = (update, origin) => {
if (origin instanceof Room) {
this.remoteUpdateSignal.emit(update);
}
};
this.connect = () => {
super.connect();
this._doc.on('update', this._handleRemoteUpdate);
};
this.disconnect = () => {
super.disconnect();
this._doc.off('update', this._handleRemoteUpdate);
};
this._doc = doc;
}

@@ -25,0 +40,0 @@ clearData() {

@@ -0,3 +1,3 @@

import { Observable } from 'lib0/observable.js';
import * as Y from 'yjs';
import { Observable } from 'lib0/observable.js';
import type { DocProvider } from './index.js';

@@ -4,0 +4,0 @@ export declare class IndexedDBDocProvider extends Observable<string> implements DocProvider {

@@ -1,4 +0,4 @@

import * as Y from 'yjs';
import * as idb from 'lib0/indexeddb.js';
import { Observable } from 'lib0/observable.js';
import * as Y from 'yjs';
const customStoreName = 'custom';

@@ -5,0 +5,0 @@ const updatesStoreName = 'updates';

@@ -0,3 +1,3 @@

import type { Awareness } from 'y-protocols/awareness';
import type * as Y from 'yjs';
import type { Awareness } from 'y-protocols/awareness';
export { DebugDocProvider } from './debug-provider.js';

@@ -4,0 +4,0 @@ export { IndexedDBDocProvider } from './idb-provider.js';

/// <reference types="@blocksuite/global" />
import type * as Y from 'yjs';
import type { SelectionRange } from './awareness.js';
import type { AwarenessStore } from './awareness.js';
import type { RichTextAdapter } from './text-adapter.js';
import type { BlockSuiteDoc } from './yjs/index.js';
import type { DataInitializer } from './yjs/proxy.js';
import type { BlockSuiteDoc } from './yjs/index.js';
import type { AwarenessStore } from './awareness.js';
export interface StackItem {

@@ -9,0 +9,0 @@ meta: Map<'cursor-location', SelectionRange | undefined>;

/// <reference types="@blocksuite/global" />
import { Awareness } from 'y-protocols/awareness.js';
import { AwarenessStore, RawAwarenessState } from './awareness.js';
import type { BlobOptionsGetter } from './persistence/blob/index.js';
import type { DocProvider, DocProviderConstructor } from './persistence/doc/index.js';
import type { Space } from './space.js';
import type { IdGenerator } from './utils/id-generator.js';
import { Awareness } from 'y-protocols/awareness.js';
import type { DocProvider, DocProviderConstructor } from './persistence/doc/index.js';
import { BlockSuiteDoc } from './yjs/index.js';
import { AwarenessStore, RawAwarenessState } from './awareness.js';
import type { BlobOptionsGetter } from './persistence/blob/index.js';
export interface SerializedStore {

@@ -56,3 +56,6 @@ [key: string]: {

readonly idGenerator: IdGenerator;
connected: boolean;
constructor({ room, providers, awareness, idGenerator, defaultFlags, }?: StoreOptions);
connect: () => void;
disconnect: () => void;
addSpace(space: Space): void;

@@ -59,0 +62,0 @@ removeSpace(space: Space): void;

@@ -0,7 +1,7 @@

import { merge } from 'merge';
import { Awareness } from 'y-protocols/awareness.js';
import { AwarenessStore } from './awareness.js';
import { createAutoIncrementIdGenerator, createAutoIncrementIdGeneratorByClientId, nanoid, uuidv4, } from './utils/id-generator.js';
import { serializeYDoc, yDocToJSXNode } from './utils/jsx.js';
import { createAutoIncrementIdGenerator, createAutoIncrementIdGeneratorByClientId, uuidv4, nanoid, } from './utils/id-generator.js';
import { merge } from 'merge';
import { BlockSuiteDoc } from './yjs/index.js';
import { AwarenessStore } from './awareness.js';
export var Generator;

@@ -33,2 +33,3 @@ (function (Generator) {

enable_surface: true,
enable_edgeless_toolbar: true,
enable_slash_menu: false,

@@ -45,2 +46,11 @@ enable_append_flavor_slash: false,

this.spaces = new Map();
this.connected = false;
this.connect = () => {
this.providers.forEach(provider => provider.connect?.());
this.connected = true;
};
this.disconnect = () => {
this.providers.forEach(provider => provider.disconnect?.());
this.connected = false;
};
this.awarenessStore = new AwarenessStore(this, awareness ?? new Awareness(this.doc), merge(flagsPreset, defaultFlags));

@@ -47,0 +57,0 @@ switch (idGenerator) {

@@ -0,7 +1,7 @@

import type { DeltaOperation, Quill } from 'quill';
import * as Y from 'yjs';
import type { DeltaOperation, Quill } from 'quill';
import type { Space } from './space.js';
type PrelimTextType = 'splitLeft' | 'splitRight';
export type TextType = PrelimText | Text;
export declare function normQuillDelta(delta: any): any;
export declare function normQuillDelta(delta: DeltaOperation[]): DeltaOperation[];
export declare class PrelimText {

@@ -74,3 +74,3 @@ ready: boolean;

clear(): void;
applyDelta(delta: any): void;
applyDelta(delta: DeltaOperation[]): void;
toDelta(): DeltaOperation[];

@@ -77,0 +77,0 @@ sliceToDelta(begin: number, end?: number): DeltaOperation[];

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-explicit-any */
import * as Y from 'yjs';

@@ -3,0 +2,0 @@ // Removes the pending '\n's if it has no attributes

@@ -1,2 +0,2 @@

import { AbstractType, Map, Text, Array } from 'yjs';
import { AbstractType, Array, Map, Text } from 'yjs';
// Ad-hoc for `ReactTestComponent` identify.

@@ -16,2 +16,3 @@ // See https://github.com/facebook/jest/blob/f1263368cc85c3f8b70eaba534ddf593392c44f3/packages/pretty-format/src/plugins/ReactTestComponent.ts#L26-L29

'sys:children',
'prop:xywh',
'meta:tags',

@@ -18,0 +19,0 @@ 'meta:tagSchema',

/// <reference types="@blocksuite/global" />
import type { BlockProps, YBlock, YBlocks } from '../workspace/page.js';
import type { BaseBlockModel } from '../base.js';
import { PrelimText, Text, TextType } from '../text-adapter.js';
import type { Workspace } from '../workspace/index.js';
import type { BlockProps, YBlock, YBlocks } from '../workspace/page.js';
import type { Page } from '../workspace/page.js';
import type { BaseBlockModel } from '../base.js';
export declare function assertValidChildren(yBlocks: YBlocks, props: Partial<BlockProps>): void;

@@ -8,0 +8,0 @@ export declare function initInternalProps(yBlock: YBlock, props: Partial<BlockProps>): void;

@@ -0,5 +1,5 @@

import { isPrimitive, matchFlavours, SYS_KEYS } from '@blocksuite/global/utils';
import { fromBase64, toBase64 } from 'lib0/buffer.js';
import * as Y from 'yjs';
import { PrelimText, Text } from '../text-adapter.js';
import { fromBase64, toBase64 } from 'lib0/buffer.js';
import { isPrimitive, matchFlavours, SYS_KEYS } from '@blocksuite/global/utils';
export function assertValidChildren(yBlocks, props) {

@@ -6,0 +6,0 @@ if (!Array.isArray(props.children))

@@ -0,3 +1,3 @@

import { LitElement, PropertyValues } from 'lit';
import type { PageMeta, Workspace } from '../workspace.js';
import { LitElement, PropertyValues } from 'lit';
export declare class TestApp extends LitElement {

@@ -4,0 +4,0 @@ workspace: Workspace;

@@ -7,3 +7,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
import { LitElement, html } from 'lit';
import { html, LitElement } from 'lit';
import { customElement, property, query } from 'lit/decorators.js';

@@ -10,0 +10,0 @@ let TestApp = class TestApp extends LitElement {

// Test page entry located in playground/examples/workspace/index.html
import './test-app';
import { assertExists } from '@blocksuite/global/utils';
import { nextFrame, runOnce, testSerial, } from '../../__tests__/test-utils-dom.js';
import { Workspace } from '../workspace.js';
import { testSerial, runOnce, nextFrame, } from '../../__tests__/test-utils-dom.js';
import { assertExists } from '@blocksuite/global/utils';
import './test-app';
let i = 0;

@@ -7,0 +7,0 @@ async function testBasic() {

@@ -0,4 +1,4 @@

export { Page } from './page.js';
export type { PageMeta } from './workspace.js';
export { Workspace } from './workspace.js';
export type { PageMeta } from './workspace.js';
export { Page } from './page.js';
//# sourceMappingURL=index.d.ts.map

@@ -0,3 +1,3 @@

export { Page } from './page.js';
export { Workspace } from './workspace.js';
export { Page } from './page.js';
//# sourceMappingURL=index.js.map

@@ -0,4 +1,5 @@

import { MigrationError } from '@blocksuite/global/error';
import * as Y from 'yjs';
import { uuidv4 } from '../utils/id-generator.js';
import { initInternalProps } from '../utils/utils.js';
import { uuidv4 } from '../utils/id-generator.js';
// New migration should be added to the end of this list

@@ -89,3 +90,3 @@ const migrations = [

console.error(err);
throw new Error(`Migration "${migration.desc}" failed, please report to https://github.com/toeverything/blocksuite/issues`);
throw new MigrationError(migration.desc);
}

@@ -92,0 +93,0 @@ }

/// <reference types="@blocksuite/global" />
import type { BlockTag, TagSchema } from '@blocksuite/global/database';
import { Signal } from '@blocksuite/global/utils';
import type { Quill } from 'quill';
import * as Y from 'yjs';
import type { Quill } from 'quill';
import type { AwarenessStore } from '../awareness.js';
import { BaseBlockModel } from '../base.js';
import { Space } from '../space.js';
import { Text, PrelimText, TextType } from '../text-adapter.js';
import { PrelimText, Text, TextType } from '../text-adapter.js';
import type { IdGenerator } from '../utils/id-generator.js';
import { Signal } from '@blocksuite/global/utils';
import type { BlockSuiteDoc } from '../yjs/index.js';
import type { PageMeta, Workspace } from './workspace.js';
import type { BlockSuiteDoc } from '../yjs/index.js';
import type { AwarenessStore } from '../awareness.js';
import type { BlockTag, TagSchema } from '@blocksuite/global/database';
export type YBlock = Y.Map<unknown>;

@@ -14,0 +14,0 @@ export type YBlocks = Y.Map<YBlock>;

@@ -7,12 +7,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
import { debug } from '@blocksuite/global/debug';
import { Signal } from '@blocksuite/global/utils';
import { assertExists, matchFlavours } from '@blocksuite/global/utils';
import { uuidv4 } from 'lib0/random.js';
import * as Y from 'yjs';
import { uuidv4 } from 'lib0/random.js';
import { BaseBlockModel } from '../base.js';
import { Space } from '../space.js';
import { Text, PrelimText, RichTextAdapter, } from '../text-adapter.js';
import { Signal } from '@blocksuite/global/utils';
import { assertValidChildren, initInternalProps, syncBlockProps, trySyncTextProp, toBlockProps, } from '../utils/utils.js';
import { PrelimText, RichTextAdapter, Text, } from '../text-adapter.js';
import { assertValidChildren, initInternalProps, syncBlockProps, toBlockProps, trySyncTextProp, } from '../utils/utils.js';
import { tryMigrate } from './migrations.js';
import { assertExists, matchFlavours } from '@blocksuite/global/utils';
import { debug } from '@blocksuite/global/debug';
const isWeb = typeof window !== 'undefined';

@@ -19,0 +19,0 @@ function createChildMap(yChildIds) {

/// <reference types="@blocksuite/global" />
import { Signal } from '@blocksuite/global/utils';
import * as Y from 'yjs';
import type { z } from 'zod';
import { AwarenessStore } from '../awareness.js';
import { BlockSchema } from '../base.js';
import { BlobOptionsGetter, BlobStorage } from '../persistence/blob/index.js';
import { Space } from '../space.js';
import { StoreOptions } from '../store.js';
import { Space } from '../space.js';
import type { BlockSuiteDoc } from '../yjs/index.js';
import { Page } from './page.js';
import { Signal } from '@blocksuite/global/utils';
import { QueryContent } from './search.js';
import { BlobStorage, BlobOptionsGetter } from '../persistence/blob/index.js';
import type { BlockSuiteDoc } from '../yjs/index.js';
import { AwarenessStore } from '../awareness.js';
import type { z } from 'zod';
import { BlockSchema } from '../base.js';
export interface PageMeta {

@@ -80,2 +80,5 @@ id: string;

constructor(options: StoreOptions);
get connected(): boolean;
connect: () => void;
disconnect: () => void;
get awarenessStore(): AwarenessStore;

@@ -82,0 +85,0 @@ get providers(): import("../index.js").DocProvider[];

@@ -0,10 +1,10 @@

import { Signal } from '@blocksuite/global/utils';
import * as Y from 'yjs';
import { BlobUploadState } from '../awareness.js';
import { BlockSchema } from '../base.js';
import { BlobSyncState, getBlobStorage, } from '../persistence/blob/index.js';
import { Space } from '../space.js';
import { Store } from '../store.js';
import { Space } from '../space.js';
import { Page } from './page.js';
import { Signal } from '@blocksuite/global/utils';
import { Indexer } from './search.js';
import { getBlobStorage, BlobSyncState, } from '../persistence/blob/index.js';
import { BlobUploadState } from '../awareness.js';
import { BlockSchema } from '../base.js';
class WorkspaceMeta extends Space {

@@ -163,2 +163,8 @@ constructor(id, doc, awarenessStore) {

this.flavourInitialPropsMap = new Map();
this.connect = () => {
this._store.connect();
};
this.disconnect = () => {
this._store.disconnect();
};
this._store = new Store(options);

@@ -203,2 +209,5 @@ this._indexer = new Indexer(this.doc);

}
get connected() {
return this._store.connected;
}
get awarenessStore() {

@@ -205,0 +214,0 @@ return this._store.awarenessStore;

@@ -0,4 +1,4 @@

import type { Transaction } from 'yjs';
import * as Y from 'yjs';
import { ProxyConfig } from './proxy.js';
import type { Transaction } from 'yjs';
export type BlockSuiteDocAllowedValue = Record<string, unknown> | unknown[] | Y.Text;

@@ -5,0 +5,0 @@ export type BlockSuiteDocData = Record<string, BlockSuiteDocAllowedValue>;

@@ -7,5 +7,5 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
import { debug } from '@blocksuite/global/debug';
import * as Y from 'yjs';
import { createYMapProxy } from './proxy.js';
import { debug } from '@blocksuite/global/debug';
export class BlockSuiteDoc extends Y.Doc {

@@ -12,0 +12,0 @@ getMapProxy(key, config) {

{
"name": "@blocksuite/store",
"version": "0.4.0-alpha.2",
"version": "0.4.0-alpha.3",
"description": "BlockSuite data store built for general purpose state management.",

@@ -11,3 +11,3 @@ "main": "dist/index.js",

"dependencies": {
"@blocksuite/global": "0.4.0-alpha.2",
"@blocksuite/global": "0.4.0-alpha.3",
"@types/flexsearch": "^0.7.3",

@@ -18,5 +18,5 @@ "buffer": "^6.0.3",

"ky": "^0.33.2",
"lib0": "^0.2.60",
"lib0": "^0.2.62",
"merge": "^2.1.1",
"nanoid": "^4.0.0",
"nanoid": "^4.0.1",
"y-protocols": "^1.0.5",

@@ -28,3 +28,3 @@ "y-webrtc": "^10.2.4",

"lit": "^2.6.1",
"yjs": "^13.5.44"
"yjs": "^13.5.45"
},

@@ -36,3 +36,6 @@ "peerDependencies": {

"./src/*": "./dist/*.js",
".": "./dist/index.js"
".": {
"module": "./dist/index.js",
"import": "./dist/index.js"
}
},

@@ -39,0 +42,0 @@ "publishConfig": {

// checkout https://vitest.dev/guide/debugging.html for debugging tests
import { describe, expect, it } from 'vitest';
import { yDocToJSXNode } from '../utils/jsx.js';

@@ -5,0 +6,0 @@

@@ -0,5 +1,6 @@

import { readFile } from 'fs/promises';
import { fileURLToPath } from 'url';
import { assert, describe, expect, test } from 'vitest';
import * as Y from 'yjs';
import { describe, assert, test, expect } from 'vitest';
import { fileURLToPath } from 'url';
import { readFile } from 'fs/promises';
import { tryMigrate } from '../workspace/migrations.js';

@@ -6,0 +7,0 @@

@@ -1,2 +0,3 @@

import { Page, expect } from '@playwright/test';
import { expect, Page } from '@playwright/test';
import type { TestResult } from './test-utils-dom.js';

@@ -3,0 +4,0 @@

/* eslint-disable @typescript-eslint/no-restricted-imports */
// checkout https://vitest.dev/guide/debugging.html for debugging tests
import type { Signal } from '@blocksuite/global/utils';
import { assert, describe, expect, it } from 'vitest';
import { BaseBlockModel, Workspace, Page, Generator } from '../index.js';
import type { Signal } from '@blocksuite/global/utils';
import { DividerBlockModelSchema } from '../../../blocks/src/divider-block/divider-model.js';
import { FrameBlockModelSchema } from '../../../blocks/src/frame-block/frame-model.js';
import { ListBlockModelSchema } from '../../../blocks/src/list-block/list-model.js';
// Use manual per-module import/export to support vitest environment on Node.js
import { PageBlockModelSchema } from '../../../blocks/src/page-block/page-model.js';
import { ParagraphBlockModelSchema } from '../../../blocks/src/paragraph-block/paragraph-model.js';
import { ListBlockModelSchema } from '../../../blocks/src/list-block/list-model.js';
import { FrameBlockModelSchema } from '../../../blocks/src/frame-block/frame-model.js';
import { DividerBlockModelSchema } from '../../../blocks/src/divider-block/divider-model.js';
import { BaseBlockModel, Generator, Page, Workspace } from '../index.js';
import type { PageMeta } from '../workspace/index.js';

@@ -15,0 +15,0 @@ import { assertExists } from './test-utils-dom.js';

import { describe, expect, test } from 'vitest';
import { BlockSuiteDoc } from '../yjs/index.js';

@@ -3,0 +4,0 @@

@@ -1,9 +0,10 @@

import * as Y from 'yjs';
import type { RelativePosition } from 'yjs';
import type { Awareness as YAwareness } from 'y-protocols/awareness.js';
import { Signal } from '@blocksuite/global/utils';
import { merge } from 'merge';
import { uuidv4 } from './utils/id-generator.js';
import type { Awareness as YAwareness } from 'y-protocols/awareness.js';
import type { RelativePosition } from 'yjs';
import * as Y from 'yjs';
import type { Space } from './space.js';
import type { Store } from './store.js';
import { uuidv4 } from './utils/id-generator.js';

@@ -10,0 +11,0 @@ export interface SelectionRange {

@@ -1,3 +0,1 @@

import type { Page } from './workspace/index.js';
import type { TextType } from './text-adapter.js';
import { Signal } from '@blocksuite/global/utils';

@@ -7,2 +5,5 @@ import type * as Y from 'yjs';

import type { TextType } from './text-adapter.js';
import type { Page } from './workspace/index.js';
const FlavourSchema = z.string();

@@ -9,0 +10,0 @@ const TagSchema = z.object({

/// <reference types="@blocksuite/global" />
export * from './awareness.js';
export * from './base.js';
export * from './persistence/blob/index.js';
export * from './persistence/doc/index.js';
export * from './space.js';
export * from './store.js';
export * from './base.js';
export * from './awareness.js';
export * from './persistence/blob/index.js';
export * from './text-adapter.js';
export * from '@blocksuite/global/utils';
export * from './persistence/doc/index.js';
export * from './workspace/index.js';
export * as Utils from './utils/utils.js';
export type { IdGenerator } from './utils/id-generator.js';
export {
createAutoIncrementIdGenerator,
createAutoIncrementIdGeneratorByClientId,
nanoid,
uuidv4,
nanoid,
} from './utils/id-generator.js';
export type { IdGenerator } from './utils/id-generator.js';
export * as Utils from './utils/utils.js';
export * from './workspace/index.js';
export * from '@blocksuite/global/utils';

@@ -20,0 +20,0 @@ const env =

import { test } from '@playwright/test';
import { collectTestResult } from '../../../__tests__/test-utils-node.js';

@@ -3,0 +4,0 @@

// Test page entry located in playground/examples/blob/index.html
import { getBlobStorage } from '../index.js';
import {
testSerial,
runOnce,
loadTestImageBlob,
loadImage,
assertColor,
assertExists,
disableButtonsAfterClick,
loadImage,
loadTestImageBlob,
runOnce,
testSerial,
} from '../../../__tests__/test-utils-dom.js';
import { getBlobStorage } from '../index.js';

@@ -13,0 +13,0 @@ const optionsGetters = {

@@ -0,12 +1,13 @@

import { Signal, sleep } from '@blocksuite/global/utils';
import ky from 'ky';
import { Signal, sleep } from '@blocksuite/global/utils';
import type { BlobOptionsGetter } from './duplex-provider.js';
import type {
BlobId,
BlobProvider,
IDBInstance,
PendingTask,
SyncTask,
BlobProvider,
} from './types.js';
import { BlobSyncState } from './types.js';
import type { BlobOptionsGetter } from './duplex-provider.js';
import { getDatabase } from './utils.js';

@@ -13,0 +14,0 @@

import { assertExists, Signal } from '@blocksuite/global/utils';
import { CloudSyncManager } from './cloud-sync-manager.js';
import type {
BlobId,
BlobProvider,
BlobSyncStateChangeEvent,
BlobURL,
IDBInstance,
BlobSyncStateChangeEvent,
} from './types.js';

@@ -11,0 +11,0 @@ import { getDatabase, sha } from './utils.js';

@@ -0,3 +1,3 @@

import type { BlobOptions, BlobOptionsGetter } from './duplex-provider.js';
import { DuplexBlobProvider } from './duplex-provider.js';
import type { BlobOptionsGetter, BlobOptions } from './duplex-provider.js';
import { BlobStorage } from './storage.js';

@@ -24,3 +24,3 @@

export { BlobStorage } from './storage.js';
export type { BlobOptionsGetter, BlobOptions };
export type { BlobOptions, BlobOptionsGetter };
export { BlobSyncState } from './types.js';
import { Signal } from '@blocksuite/global/utils';
import type {
BlobId,
BlobProvider,
BlobSyncStateChangeEvent,
BlobURL,
BlobSyncStateChangeEvent,
} from './types.js';

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

@@ -1,5 +0,6 @@

import { createStore, del, get, keys, set, clear, values } from 'idb-keyval';
import type { IDBInstance } from './types.js';
import { Buffer } from 'buffer';
import { clear, createStore, del, get, keys, set, values } from 'idb-keyval';
import type { IDBInstance } from './types.js';
export async function sha(input: ArrayBuffer): Promise<string> {

@@ -6,0 +7,0 @@ const hash = await crypto.subtle.digest('SHA-256', input);

@@ -0,7 +1,8 @@

import { isWeb, Signal } from '@blocksuite/global/utils';
import type { Awareness } from 'y-protocols/awareness';
// @ts-ignore
import { Room, WebrtcProvider } from 'y-webrtc';
import type * as Y from 'yjs';
// @ts-ignore
import { WebrtcProvider } from 'y-webrtc';
import { isWeb } from '@blocksuite/global/utils';
import type { DocProvider } from './index.js';
import type { Awareness } from 'y-protocols/awareness';

@@ -26,2 +27,4 @@ // When using playground from blocksuite repo, t./idb-provider.js "serve" script in "@blocksuite/store" package.

export class DebugDocProvider extends WebrtcProvider implements DocProvider {
private readonly _doc: Y.Doc;
public remoteUpdateSignal = new Signal<unknown>();
constructor(room: string, doc: Y.Doc, options?: { awareness?: Awareness }) {

@@ -32,4 +35,21 @@ super(room, doc, {

});
this._doc = doc;
}
private _handleRemoteUpdate = (update: unknown, origin: unknown) => {
if (origin instanceof Room) {
this.remoteUpdateSignal.emit(update);
}
};
connect = () => {
super.connect();
this._doc.on('update', this._handleRemoteUpdate);
};
disconnect = () => {
super.disconnect();
this._doc.off('update', this._handleRemoteUpdate);
};
public clearData() {

@@ -36,0 +56,0 @@ // Do nothing for now

@@ -1,4 +0,5 @@

import * as Y from 'yjs';
import * as idb from 'lib0/indexeddb.js';
import { Observable } from 'lib0/observable.js';
import * as Y from 'yjs';
import type { DocProvider } from './index.js';

@@ -5,0 +6,0 @@

@@ -0,3 +1,3 @@

import type { Awareness } from 'y-protocols/awareness';
import type * as Y from 'yjs';
import type { Awareness } from 'y-protocols/awareness';

@@ -4,0 +4,0 @@ export { DebugDocProvider } from './debug-provider.js';

import type * as Y from 'yjs';
import type { SelectionRange } from './awareness.js';
import type { AwarenessStore } from './awareness.js';
import type { RichTextAdapter } from './text-adapter.js';
import type { BlockSuiteDoc } from './yjs/index.js';
import type { DataInitializer } from './yjs/proxy.js';
import type { BlockSuiteDoc } from './yjs/index.js';
import type { AwarenessStore } from './awareness.js';

@@ -8,0 +9,0 @@ export interface StackItem {

@@ -1,4 +0,6 @@

import type { Space } from './space.js';
import type { IdGenerator } from './utils/id-generator.js';
import { merge } from 'merge';
import { Awareness } from 'y-protocols/awareness.js';
import { AwarenessStore, RawAwarenessState } from './awareness.js';
import type { BlobOptionsGetter } from './persistence/blob/index.js';
import type {

@@ -8,13 +10,12 @@ DocProvider,

} from './persistence/doc/index.js';
import { serializeYDoc, yDocToJSXNode } from './utils/jsx.js';
import type { Space } from './space.js';
import type { IdGenerator } from './utils/id-generator.js';
import {
createAutoIncrementIdGenerator,
createAutoIncrementIdGeneratorByClientId,
nanoid,
uuidv4,
nanoid,
} from './utils/id-generator.js';
import { merge } from 'merge';
import { serializeYDoc, yDocToJSXNode } from './utils/jsx.js';
import { BlockSuiteDoc } from './yjs/index.js';
import { AwarenessStore, RawAwarenessState } from './awareness.js';
import type { BlobOptionsGetter } from './persistence/blob/index.js';

@@ -76,2 +77,3 @@ export interface SerializedStore {

enable_surface: true,
enable_edgeless_toolbar: true,
enable_slash_menu: false,

@@ -89,2 +91,3 @@ enable_append_flavor_slash: false,

readonly idGenerator: IdGenerator;
connected = false;

@@ -136,2 +139,12 @@ // TODO: The user cursor should be spread by the spaceId in awareness

connect = () => {
this.providers.forEach(provider => provider.connect?.());
this.connected = true;
};
disconnect = () => {
this.providers.forEach(provider => provider.disconnect?.());
this.connected = false;
};
addSpace(space: Space) {

@@ -138,0 +151,0 @@ this.spaces.set(space.prefixedId, space);

/* eslint-disable @typescript-eslint/no-explicit-any */
import type { DeltaOperation, Quill } from 'quill';
import * as Y from 'yjs';
import type { DeltaOperation, Quill } from 'quill';
import type { Space } from './space.js';

@@ -11,6 +12,6 @@

// Removes the pending '\n's if it has no attributes
export function normQuillDelta(delta: any) {
export function normQuillDelta(delta: DeltaOperation[]): DeltaOperation[] {
if (delta.length > 0) {
const d = delta[delta.length - 1];
const insert = d.insert;
const insert: string = d.insert;
if (

@@ -202,3 +203,3 @@ d.attributes === undefined &&

const yOther = other._yText;
const delta = yOther.toDelta();
const delta: DeltaOperation[] = yOther.toDelta();
delta.splice(0, 0, { retain: this._yText.length });

@@ -244,3 +245,3 @@ this._yText.applyDelta(delta);

applyDelta(delta: any) {
applyDelta(delta: DeltaOperation[]) {
this._transact(() => {

@@ -247,0 +248,0 @@ this._yText?.applyDelta(delta);

@@ -1,2 +0,3 @@

import { AbstractType, Doc, Map, Text, Array } from 'yjs';
import { AbstractType, Array, Doc, Map, Text } from 'yjs';
import type { PrefixedBlockProps } from '../workspace/page.js';

@@ -36,2 +37,3 @@

'sys:children',
'prop:xywh',
'meta:tags',

@@ -38,0 +40,0 @@ 'meta:tagSchema',

@@ -0,2 +1,8 @@

import { isPrimitive, matchFlavours, SYS_KEYS } from '@blocksuite/global/utils';
import { fromBase64, toBase64 } from 'lib0/buffer.js';
import * as Y from 'yjs';
import type { BaseBlockModel } from '../base.js';
import { PrelimText, Text, TextType } from '../text-adapter.js';
import type { Workspace } from '../workspace/index.js';
import type {

@@ -8,8 +14,3 @@ BlockProps,

} from '../workspace/page.js';
import { PrelimText, Text, TextType } from '../text-adapter.js';
import type { Workspace } from '../workspace/index.js';
import { fromBase64, toBase64 } from 'lib0/buffer.js';
import { isPrimitive, matchFlavours, SYS_KEYS } from '@blocksuite/global/utils';
import type { Page } from '../workspace/page.js';
import type { BaseBlockModel } from '../base.js';

@@ -16,0 +17,0 @@ export function assertValidChildren(

@@ -1,5 +0,6 @@

import type { PageMeta, Workspace } from '../workspace.js';
import { LitElement, html, PropertyValues } from 'lit';
import { html, LitElement, PropertyValues } from 'lit';
import { customElement, property, query } from 'lit/decorators.js';
import type { PageMeta, Workspace } from '../workspace.js';
@customElement('test-app')

@@ -6,0 +7,0 @@ export class TestApp extends LitElement {

// Test page entry located in playground/examples/workspace/index.html
import { Workspace } from '../workspace.js';
import type { TestApp } from './test-app.js';
import './test-app';
import { assertExists } from '@blocksuite/global/utils';
import {
nextFrame,
runOnce,
testSerial,
runOnce,
nextFrame,
} from '../../__tests__/test-utils-dom.js';
import { assertExists } from '@blocksuite/global/utils';
import './test-app';
import { Workspace } from '../workspace.js';
import type { TestApp } from './test-app.js';

@@ -12,0 +14,0 @@ let i = 0;

import { test } from '@playwright/test';
import { collectTestResult } from '../../__tests__/test-utils-node.js';

@@ -3,0 +4,0 @@

@@ -0,3 +1,3 @@

export { Page } from './page.js';
export type { PageMeta } from './workspace.js';
export { Workspace } from './workspace.js';
export type { PageMeta } from './workspace.js';
export { Page } from './page.js';

@@ -0,5 +1,7 @@

import { MigrationError } from '@blocksuite/global/error';
import * as Y from 'yjs';
import { uuidv4 } from '../utils/id-generator.js';
import { initInternalProps } from '../utils/utils.js';
import type { YBlock } from './page.js';
import { initInternalProps } from '../utils/utils.js';
import { uuidv4 } from '../utils/id-generator.js';

@@ -99,7 +101,5 @@ interface Migration {

console.error(err);
throw new Error(
`Migration "${migration.desc}" failed, please report to https://github.com/toeverything/blocksuite/issues`
);
throw new MigrationError(migration.desc);
}
}
}

@@ -0,14 +1,19 @@

import type { BlockTag, TagSchema } from '@blocksuite/global/database';
import { debug } from '@blocksuite/global/debug';
import { Signal } from '@blocksuite/global/utils';
import { assertExists, matchFlavours } from '@blocksuite/global/utils';
import { uuidv4 } from 'lib0/random.js';
import type { Quill } from 'quill';
import * as Y from 'yjs';
import type { Quill } from 'quill';
import { uuidv4 } from 'lib0/random.js';
import type { AwarenessStore } from '../awareness.js';
import { BaseBlockModel } from '../base.js';
import { Space, StackItem } from '../space.js';
import {
Text,
PrelimText,
RichTextAdapter,
Text,
TextType,
} from '../text-adapter.js';
import type { IdGenerator } from '../utils/id-generator.js';
import { Signal } from '@blocksuite/global/utils';
import {

@@ -18,12 +23,8 @@ assertValidChildren,

syncBlockProps,
toBlockProps,
trySyncTextProp,
toBlockProps,
} from '../utils/utils.js';
import type { PageMeta, Workspace } from './workspace.js';
import type { BlockSuiteDoc } from '../yjs/index.js';
import { tryMigrate } from './migrations.js';
import { assertExists, matchFlavours } from '@blocksuite/global/utils';
import { debug } from '@blocksuite/global/debug';
import type { AwarenessStore } from '../awareness.js';
import type { BlockTag, TagSchema } from '@blocksuite/global/database';
import type { PageMeta, Workspace } from './workspace.js';
export type YBlock = Y.Map<unknown>;

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

@@ -0,4 +1,5 @@

import type { DocumentSearchOptions } from 'flexsearch';
import FlexSearch from 'flexsearch';
import type { DocumentSearchOptions } from 'flexsearch';
import { Doc, Map as YMap, Text as YText } from 'yjs';
import type { YBlock } from './page.js';

@@ -5,0 +6,0 @@

@@ -0,17 +1,18 @@

import { Signal } from '@blocksuite/global/utils';
import * as Y from 'yjs';
import { Store, StoreOptions } from '../store.js';
import { Space } from '../space.js';
import { Page } from './page.js';
import { Signal } from '@blocksuite/global/utils';
import { Indexer, QueryContent } from './search.js';
import type { z } from 'zod';
import { AwarenessStore, BlobUploadState } from '../awareness.js';
import { BlockSchema } from '../base.js';
import {
BlobOptionsGetter,
BlobStorage,
BlobOptionsGetter,
BlobSyncState,
getBlobStorage,
BlobSyncState,
} from '../persistence/blob/index.js';
import { Space } from '../space.js';
import { Store, StoreOptions } from '../store.js';
import type { BlockSuiteDoc } from '../yjs/index.js';
import { AwarenessStore, BlobUploadState } from '../awareness.js';
import type { z } from 'zod';
import { BlockSchema } from '../base.js';
import { Page } from './page.js';
import { Indexer, QueryContent } from './search.js';

@@ -289,2 +290,14 @@ export interface PageMeta {

get connected(): boolean {
return this._store.connected;
}
connect = () => {
this._store.connect();
};
disconnect = () => {
this._store.disconnect();
};
get awarenessStore(): AwarenessStore {

@@ -291,0 +304,0 @@ return this._store.awarenessStore;

@@ -0,5 +1,6 @@

import { debug } from '@blocksuite/global/debug';
import type { Transaction } from 'yjs';
import * as Y from 'yjs';
import { createYMapProxy, ProxyConfig } from './proxy.js';
import type { Transaction } from 'yjs';
import { debug } from '@blocksuite/global/debug';

@@ -6,0 +7,0 @@ export type BlockSuiteDocAllowedValue =

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

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

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

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

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

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

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

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

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