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
1252
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.17.0-canary-202408281337-afccfb4 to 0.17.0

1

dist/store/collection.d.ts

@@ -47,2 +47,3 @@ import { type Logger, Slot } from '@blocksuite/global/utils';

docRemoved: Slot<string>;
docCreated: Slot<string>;
};

@@ -49,0 +50,0 @@ constructor({ id, schema, idGenerator, defaultFlags, awarenessSources, docSources, blobSources, logger, }: DocCollectionOptions);

5

dist/store/collection.js

@@ -38,2 +38,3 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {

import { AwarenessEngine, BlobEngine, DocEngine, MemoryBlobSource, NoopDocSource, } from '@blocksuite/sync';
import clonedeep from 'lodash.clonedeep';
import merge from 'lodash.merge';

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

docRemoved: new Slot(),
docCreated: new Slot(),
};

@@ -93,3 +95,3 @@ this._schema = schema;

this.doc = new BlockSuiteDoc({ guid: id });
this.awarenessStore = new AwarenessStore(new Awareness(this.doc), merge({ ...FLAGS_PRESET }, defaultFlags));
this.awarenessStore = new AwarenessStore(new Awareness(this.doc), merge(clonedeep(FLAGS_PRESET), defaultFlags));
this.awarenessSync = new AwarenessEngine(this.awarenessStore.awareness, awarenessSources);

@@ -150,2 +152,3 @@ this.docSync = new DocEngine(this.doc, docSources.main, docSources.shadows ?? [], logger);

});
this.slots.docCreated.emit(docId);
return this.getDoc(docId, { query });

@@ -152,0 +155,0 @@ }

@@ -30,7 +30,7 @@ import type { Awareness as YAwareness } from 'y-protocols/awareness.js';

getFlag<Key extends keyof Flags>(field: Key): Flags[Key];
getLocalSelection(blockCollection: BlockCollection): ReadonlyArray<Record<string, unknown>>;
getLocalSelection(selectionManagerId: string): ReadonlyArray<Record<string, unknown>>;
getStates(): Map<number, RawAwarenessState<Flags>>;
isReadonly(blockCollection: BlockCollection): boolean;
setFlag<Key extends keyof Flags>(field: Key, value: Flags[Key]): void;
setLocalSelection(blockCollection: BlockCollection, selection: UserSelection): void;
setLocalSelection(selectionManagerId: string, selection: UserSelection): void;
setReadonly(blockCollection: BlockCollection, value: boolean): void;

@@ -37,0 +37,0 @@ }

import { Slot } from '@blocksuite/global/utils';
import { signal } from '@preact/signals-core';
import clonedeep from 'lodash.clonedeep';
import merge from 'lodash.merge';

@@ -42,3 +43,3 @@ export class AwarenessStore {

const upstreamFlags = this.awareness.getLocalState()?.flags;
const flags = { ...defaultFlags };
const flags = clonedeep(defaultFlags);
if (upstreamFlags) {

@@ -58,4 +59,4 @@ merge(flags, upstreamFlags);

}
getLocalSelection(blockCollection) {
return ((this.awareness.getLocalState()?.selectionV2 ?? {})[blockCollection.id] ??
getLocalSelection(selectionManagerId) {
return ((this.awareness.getLocalState()?.selectionV2 ?? {})[selectionManagerId] ??
[]);

@@ -79,7 +80,7 @@ }

}
setLocalSelection(blockCollection, selection) {
setLocalSelection(selectionManagerId, selection) {
const oldSelection = this.awareness.getLocalState()?.selectionV2 ?? {};
this.awareness.setLocalStateField('selectionV2', {
...oldSelection,
[blockCollection.id]: selection,
[selectionManagerId]: selection,
});

@@ -86,0 +87,0 @@ }

{
"name": "@blocksuite/store",
"version": "0.17.0-canary-202408281337-afccfb4",
"version": "0.17.0",
"description": "BlockSuite data store built for general purpose state management.",

@@ -16,2 +16,3 @@ "type": "module",

"lib0": "^0.2.97",
"lodash.clonedeep": "^4.5.0",
"lodash.ismatch": "^4.4.0",

@@ -23,7 +24,8 @@ "lodash.merge": "^4.6.2",

"zod": "^3.23.8",
"@blocksuite/global": "0.17.0-canary-202408281337-afccfb4",
"@blocksuite/sync": "0.17.0-canary-202408281337-afccfb4",
"@blocksuite/inline": "0.17.0-canary-202408281337-afccfb4"
"@blocksuite/global": "0.17.0",
"@blocksuite/inline": "0.17.0",
"@blocksuite/sync": "0.17.0"
},
"devDependencies": {
"@types/lodash.clonedeep": "^4.5.9",
"@types/lodash.merge": "^4.6.9",

@@ -30,0 +32,0 @@ "lit": "^3.2.0",

@@ -13,2 +13,3 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';

} from '@blocksuite/sync';
import clonedeep from 'lodash.clonedeep';
import merge from 'lodash.merge';

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

docRemoved: new Slot<string>(),
docCreated: new Slot<string>(),
};

@@ -122,3 +124,3 @@

new Awareness<RawAwarenessState>(this.doc),
merge({ ...FLAGS_PRESET }, defaultFlags)
merge(clonedeep(FLAGS_PRESET), defaultFlags)
);

@@ -204,2 +206,3 @@

});
this.slots.docCreated.emit(docId);
return this.getDoc(docId, { query }) as Doc;

@@ -206,0 +209,0 @@ }

@@ -5,2 +5,3 @@ import type { Awareness as YAwareness } from 'y-protocols/awareness.js';

import { type Signal, signal } from '@preact/signals-core';
import clonedeep from 'lodash.clonedeep';
import merge from 'lodash.merge';

@@ -91,3 +92,3 @@

const upstreamFlags = this.awareness.getLocalState()?.flags;
const flags = { ...defaultFlags };
const flags = clonedeep(defaultFlags);
if (upstreamFlags) {

@@ -111,6 +112,6 @@ merge(flags, upstreamFlags);

getLocalSelection(
blockCollection: BlockCollection
selectionManagerId: string
): ReadonlyArray<Record<string, unknown>> {
return (
(this.awareness.getLocalState()?.selectionV2 ?? {})[blockCollection.id] ??
(this.awareness.getLocalState()?.selectionV2 ?? {})[selectionManagerId] ??
[]

@@ -138,10 +139,7 @@ );

setLocalSelection(
blockCollection: BlockCollection,
selection: UserSelection
) {
setLocalSelection(selectionManagerId: string, selection: UserSelection) {
const oldSelection = this.awareness.getLocalState()?.selectionV2 ?? {};
this.awareness.setLocalStateField('selectionV2', {
...oldSelection,
[blockCollection.id]: selection,
[selectionManagerId]: selection,
});

@@ -148,0 +146,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

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