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

@blocksuite/store

Package Overview
Dependencies
Maintainers
5
Versions
1264
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-20230123235526-9112dad to 0.4.0-20230124211050-22f6e52

1

dist/store.js

@@ -35,2 +35,3 @@ import { Awareness } from 'y-protocols/awareness.js';

enable_append_flavor_slash: false,
enable_database: false,
readonly: {},

@@ -37,0 +38,0 @@ };

8

dist/utils/utils.d.ts

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

import type { BlockProps, PrefixedBlockProps, YBlock, YBlocks } from '../workspace/page.js';
/// <reference types="@blocksuite/global" />
import type { BlockProps, YBlock, YBlocks } from '../workspace/page.js';
import { PrelimText, Text, TextType } from '../text-adapter.js';
import type { Workspace } from '../workspace/index.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,5 +11,6 @@ export declare function initInternalProps(yBlock: YBlock, props: Partial<BlockProps>): void;

export declare function trySyncTextProp(splitSet: Set<Text | PrelimText>, yBlock: YBlock, text?: TextType | void): void;
export declare function toBlockProps(prefixedProps: PrefixedBlockProps): Partial<BlockProps>;
export declare function toBlockProps(yBlock: YBlock): Partial<BlockProps>;
export declare function encodeWorkspaceAsYjsUpdateV2(workspace: Workspace): string;
export declare function applyYjsUpdateV2(workspace: Workspace, update: string): void;
export declare function doesInsideBlockByFlavour(page: Page, block: BaseBlockModel, flavour: keyof BlockSuiteInternal.BlockModels): boolean;
//# sourceMappingURL=utils.d.ts.map
import * as Y from 'yjs';
import { PrelimText, Text } from '../text-adapter.js';
import { fromBase64, toBase64 } from 'lib0/buffer.js';
import { isPrimitive, SYS_KEYS } from '@blocksuite/global/utils';
import { isPrimitive, matchFlavours, SYS_KEYS } from '@blocksuite/global/utils';
export function assertValidChildren(yBlocks, props) {

@@ -34,3 +34,3 @@ if (!Array.isArray(props.children))

return;
if (!isPrimitive(props[key])) {
if (!isPrimitive(props[key]) && !Array.isArray(props[key])) {
throw new Error('Only top level primitives are supported for now');

@@ -78,2 +78,11 @@ }

}
if (props.flavour === 'affine:database') {
if (!yBlock.has('prop:columns')) {
const columns = Y.Array.from(props.columns ?? []);
yBlock.set('prop:columns', columns);
}
if (!yBlock.has('prop:title')) {
yBlock.set('prop:title', '');
}
}
}

@@ -120,3 +129,4 @@ export function trySyncTextProp(splitSet, yBlock, text) {

}
export function toBlockProps(prefixedProps) {
export function toBlockProps(yBlock) {
const prefixedProps = yBlock.toJSON();
const props = {};

@@ -132,3 +142,9 @@ Object.keys(prefixedProps).forEach(key => {

const key = prefixedKey.replace('prop:', '');
props[key] = prefixedProps[prefixedKey];
const realValue = yBlock.get(prefixedKey);
if (realValue instanceof Y.Array) {
props[key] = realValue.toArray();
}
else {
props[key] = prefixedProps[prefixedKey];
}
});

@@ -143,2 +159,12 @@ return props;

}
export function doesInsideBlockByFlavour(page, block, flavour) {
const parent = page.getParent(block);
if (parent === null) {
return false;
}
else if (matchFlavours(parent, [flavour])) {
return true;
}
return doesInsideBlockByFlavour(page, parent, flavour);
}
//# sourceMappingURL=utils.js.map

@@ -70,3 +70,3 @@ /// <reference types="@blocksuite/global" />

getBlockTagByTagSchema(model: BaseBlockModel, schema: TagSchema): BlockTag | null;
getTagSchema(id: TagSchema['id']): {} | null;
getTagSchema(id: TagSchema['id']): TagSchema | null;
setTagSchema(schema: TagSchema): unknown;

@@ -73,0 +73,0 @@ getBlockById(id: string): BaseBlockModel<unknown> | null;

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

getTagSchema(id) {
return this.tagSchema.get(id) ?? null;
return (this.tagSchema.get(id) ?? null);
}

@@ -515,4 +515,3 @@ setTagSchema(schema) {

let isSurface = false;
const prefixedProps = yBlock.toJSON();
const props = toBlockProps(prefixedProps);
const props = toBlockProps(yBlock);
const model = this._createBlockModel({ ...props, id });

@@ -538,3 +537,3 @@ if (model.flavour === 'affine:surface') {

model.tags = yBlock.get('meta:tags');
model.tagSchema = yBlock.get('meta:tags');
model.tagSchema = yBlock.get('meta:tagSchema');
}

@@ -541,0 +540,0 @@ const yChildren = yBlock.get('sys:children');

{
"name": "@blocksuite/store",
"version": "0.4.0-20230123235526-9112dad",
"version": "0.4.0-20230124211050-22f6e52",
"description": "BlockSuite data store built for general purpose state management.",

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

"dependencies": {
"@blocksuite/global": "0.4.0-20230123235526-9112dad",
"@blocksuite/global": "0.4.0-20230124211050-22f6e52",
"@types/flexsearch": "^0.7.3",

@@ -14,0 +14,0 @@ "buffer": "^6.0.3",

@@ -74,2 +74,3 @@ import type { Space } from './space.js';

enable_append_flavor_slash: false,
enable_database: false,
readonly: {},

@@ -76,0 +77,0 @@ } satisfies BlockSuiteFlags;

@@ -11,3 +11,5 @@ import * as Y from 'yjs';

import { fromBase64, toBase64 } from 'lib0/buffer.js';
import { isPrimitive, SYS_KEYS } from '@blocksuite/global/utils';
import { isPrimitive, matchFlavours, SYS_KEYS } from '@blocksuite/global/utils';
import type { Page } from '../workspace/page.js';
import type { BaseBlockModel } from '../base.js';

@@ -52,4 +54,3 @@ export function assertValidChildren(

if (key === 'text') return;
if (!isPrimitive(props[key])) {
if (!isPrimitive(props[key]) && !Array.isArray(props[key])) {
throw new Error('Only top level primitives are supported for now');

@@ -102,2 +103,11 @@ }

}
if (props.flavour === 'affine:database') {
if (!yBlock.has('prop:columns')) {
const columns = Y.Array.from(props.columns ?? []);
yBlock.set('prop:columns', columns);
}
if (!yBlock.has('prop:title')) {
yBlock.set('prop:title', '');
}
}
}

@@ -160,5 +170,4 @@

export function toBlockProps(
prefixedProps: PrefixedBlockProps
): Partial<BlockProps> {
export function toBlockProps(yBlock: YBlock): Partial<BlockProps> {
const prefixedProps = yBlock.toJSON() as PrefixedBlockProps;
const props: Partial<BlockProps> = {};

@@ -175,3 +184,8 @@ Object.keys(prefixedProps).forEach(key => {

const key = prefixedKey.replace('prop:', '');
props[key] = prefixedProps[prefixedKey];
const realValue = yBlock.get(prefixedKey);
if (realValue instanceof Y.Array) {
props[key] = realValue.toArray();
} else {
props[key] = prefixedProps[prefixedKey];
}
});

@@ -189,1 +203,15 @@

}
export function doesInsideBlockByFlavour(
page: Page,
block: BaseBlockModel,
flavour: keyof BlockSuiteInternal.BlockModels
): boolean {
const parent = page.getParent(block);
if (parent === null) {
return false;
} else if (matchFlavours(parent, [flavour])) {
return true;
}
return doesInsideBlockByFlavour(page, parent, flavour);
}

@@ -220,4 +220,4 @@ import * as Y from 'yjs';

getTagSchema(id: TagSchema['id']) {
return this.tagSchema.get(id) ?? (null as TagSchema | null);
getTagSchema(id: TagSchema['id']): TagSchema | null {
return (this.tagSchema.get(id) ?? null) as TagSchema | null;
}

@@ -686,4 +686,3 @@

const prefixedProps = yBlock.toJSON() as PrefixedBlockProps;
const props = toBlockProps(prefixedProps) as BlockProps;
const props = toBlockProps(yBlock) as BlockProps;
const model = this._createBlockModel({ ...props, id });

@@ -712,3 +711,3 @@ if (model.flavour === 'affine:surface') {

model.tags = yBlock.get('meta:tags') as Y.Map<Y.Map<unknown>>;
model.tagSchema = yBlock.get('meta:tags') as Y.Map<unknown>;
model.tagSchema = yBlock.get('meta:tagSchema') as Y.Map<unknown>;
}

@@ -715,0 +714,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

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