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
0
Versions
1288
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.0.0-canary-20241122044335 to 0.0.0-canary-20241123001438

45

CHANGELOG.md
# @blocksuite/store
## 0.0.0-canary-20241122044335
## 0.0.0-canary-20241123001438
### Minor Changes
- 9daa1f3: ## Feat
- feat(blocks): markdown adapter reference serialization and deserialization (#8782)
- feat(blocks): add lazy loading to image and iframe (#8773)
## Fix
- fix(edgeless): missing reference info during edgeless card conversion (#8790)
- fix(blocks): linked popover styles (#8789)
- fix(blocks): add abortional to getMenus (#8786)
- fix(blocks): incorrect viewport of embed linked doc with edgeless mode (#8785)
- fix(database): crash in edgeless on mobile safari (#8784)
- fix(blocks): signify at menu config items (#8780)
- fix(database): update title on composition end (#8781)
- fix(database): kanban/table drag and drop (#8778)
- fix(database): prevent the default behavior of arrow keys when a progress cell is focused (#8777)
- fix(blocks): update at menu popover styles (#8774)
- fix(edgeless): frame overlay is not updated during dragging a new frame (#8771)
## Chore
- chore(blocks): bump theme (#8783)
- chore: organize gfx model (#8766)
## Refactor
- refactor(database): make Table View compatible with mobile devices (#8787)
- refactor(edgeless): remove legacy surface ref renderer (#8759)
- refactor: unify container and group (#8772)
- refactor(database): table ui (#8779)
- refactor(database): link cell icon (#8776)
- refactor(database): use Trait to manage the functionality of Views (#8775)
- refactor(database): column move (#8726)
### Patch Changes
- Release a snapshot version.
- Updated dependencies [9daa1f3]
- Updated dependencies
- @blocksuite/global@0.0.0-canary-20241122044335
- @blocksuite/inline@0.0.0-canary-20241122044335
- @blocksuite/sync@0.0.0-canary-20241122044335
- @blocksuite/global@0.0.0-canary-20241123001438
- @blocksuite/inline@0.0.0-canary-20241123001438
- @blocksuite/sync@0.0.0-canary-20241123001438

@@ -13,0 +50,0 @@ ## 0.17.33

1

dist/index.d.ts
export type { Y };
export * from './adapter/index.js';
export * from './migration/index.js';
export * from './reactive/index.js';

@@ -5,0 +4,0 @@ export * from './schema/index.js';

// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../shim.d.ts" />
export * from './adapter/index.js';
export * from './migration/index.js';
export * from './reactive/index.js';

@@ -6,0 +5,0 @@ export * from './schema/index.js';

@@ -42,3 +42,2 @@ import type { Signal } from '@preact/signals-core';

transformer: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodType<BaseBlockTransformer<object>, z.ZodTypeDef, BaseBlockTransformer<object>>>>;
onUpgrade: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodNumber, z.ZodNumber], z.ZodUnknown>, z.ZodVoid>>;
}, "strip", z.ZodTypeAny, {

@@ -55,3 +54,2 @@ version: number;

transformer?: ((...args: unknown[]) => BaseBlockTransformer<object>) | undefined;
onUpgrade?: ((args_0: any, args_1: number, args_2: number, ...args: unknown[]) => void) | undefined;
}, {

@@ -68,3 +66,2 @@ version: number;

transformer?: ((...args: unknown[]) => BaseBlockTransformer<object>) | undefined;
onUpgrade?: ((args_0: any, args_1: number, args_2: number, ...args: unknown[]) => void) | undefined;
}>;

@@ -90,3 +87,2 @@ export type BlockSchemaType = z.infer<typeof BlockSchema>;

props?: (internalPrimitives: InternalPrimitives) => Props;
onUpgrade?: (data: Props, previousVersion: number, latestVersion: number) => void;
toModel?: () => Model;

@@ -100,3 +96,2 @@ transformer?: () => Transformer;

} & Metadata;
onUpgrade?: (data: Props, previousVersion: number, latestVersion: number) => void;
transformer?: () => Transformer;

@@ -103,0 +98,0 @@ };

@@ -35,9 +35,4 @@ var _a;

.optional(),
onUpgrade: z
.function()
.args(z.any(), z.number(), z.number())
.returns(z.void())
.optional(),
});
export function defineBlockSchema({ flavour, props, metadata, onUpgrade, toModel, transformer, }) {
export function defineBlockSchema({ flavour, props, metadata, toModel, transformer, }) {
const schema = {

@@ -53,3 +48,2 @@ version: metadata.version,

},
onUpgrade,
transformer,

@@ -56,0 +50,0 @@ };

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

import type * as Y from 'yjs';
import type { BlockSchemaType } from './base.js';
export declare class Schema {
private _upgradeBlockVersions;
readonly flavourSchemaMap: Map<string, {

@@ -16,7 +14,3 @@ version: number;

transformer?: ((...args: unknown[]) => import("../index.js").BaseBlockTransformer<object>) | undefined;
onUpgrade?: ((args_0: any, args_1: number, args_2: number, ...args: unknown[]) => void) | undefined;
}>;
upgradeBlock: (flavour: string, oldVersion: number, blockData: Y.Map<unknown>) => void;
upgradeCollection: (rootData: Y.Doc) => void;
upgradeDoc: (oldPageVersion: number, oldBlockVersions: Record<string, number>, docData: Y.Doc) => void;
validate: (flavour: string, parentFlavour?: string, childFlavours?: string[]) => void;

@@ -23,0 +17,0 @@ get versions(): {

import { minimatch } from 'minimatch';
import { SCHEMA_NOT_FOUND_MESSAGE } from '../consts.js';
import { collectionMigrations, docMigrations } from '../migration/index.js';
import { Block } from '../store/doc/block/index.js';
import { BlockSchema } from './base.js';
import { MigrationError, SchemaValidateError } from './error.js';
import { SchemaValidateError } from './error.js';
export class Schema {
constructor() {
this._upgradeBlockVersions = (rootData) => {
const meta = rootData.getMap('meta');
const blockVersions = meta.get('blockVersions');
if (!blockVersions) {
return;
}
blockVersions.forEach((version, flavour) => {
const currentSchema = this.flavourSchemaMap.get(flavour);
if (currentSchema && version !== currentSchema.version) {
blockVersions.set(flavour, currentSchema.version);
}
});
};
this.flavourSchemaMap = new Map();
this.upgradeBlock = (flavour, oldVersion, blockData) => {
try {
const currentSchema = this.flavourSchemaMap.get(flavour);
if (!currentSchema) {
throw new MigrationError(`schema for flavour: ${flavour} not found`);
}
const { onUpgrade, version } = currentSchema;
if (!onUpgrade) {
return;
}
const block = new Block(this, blockData);
return onUpgrade(block.model, oldVersion, version);
}
catch (err) {
throw new MigrationError(`upgrade block ${flavour} failed.
${err}`);
}
};
this.upgradeCollection = (rootData) => {
this._upgradeBlockVersions(rootData);
collectionMigrations.forEach(migration => {
try {
if (migration.condition(rootData)) {
migration.migrate(rootData);
}
}
catch (err) {
console.error(err);
throw new MigrationError(migration.desc);
}
});
};
this.upgradeDoc = (oldPageVersion, oldBlockVersions, docData) => {
// block migrations
const blocks = docData.getMap('blocks');
Array.from(blocks.values()).forEach(block => {
const flavour = block.get('sys:flavour');
const currentVersion = block.get('sys:version') ?? oldBlockVersions[flavour] ?? 0;
if (currentVersion == null) {
throw new MigrationError(`version for flavour ${flavour} not found in block`);
}
this.upgradeBlock(flavour, currentVersion, block);
});
// doc migrations
docMigrations.forEach(migration => {
try {
if (migration.condition(oldPageVersion, docData)) {
migration.migrate(oldPageVersion, docData);
}
}
catch (err) {
throw new MigrationError(`${migration.desc}
${err}`);
}
});
};
this.validate = (flavour, parentFlavour, childFlavours) => {

@@ -80,0 +9,0 @@ const schema = this.flavourSchemaMap.get(flavour);

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

transformer?: ((...args: unknown[]) => import("../../transformer/base.js").BaseBlockTransformer<object>) | undefined;
onUpgrade?: ((args_0: any, args_1: number, args_2: number, ...args: unknown[]) => void) | undefined;
} | undefined;

@@ -139,0 +138,0 @@ hasBlock(id: string): boolean;

{
"name": "@blocksuite/store",
"version": "0.0.0-canary-20241122044335",
"version": "0.0.0-canary-20241123001438",
"description": "BlockSuite data store built for general purpose state management.",

@@ -23,5 +23,5 @@ "type": "module",

"dependencies": {
"@blocksuite/global": "0.0.0-canary-20241122044335",
"@blocksuite/inline": "0.0.0-canary-20241122044335",
"@blocksuite/sync": "0.0.0-canary-20241122044335",
"@blocksuite/global": "0.0.0-canary-20241123001438",
"@blocksuite/inline": "0.0.0-canary-20241123001438",
"@blocksuite/sync": "0.0.0-canary-20241123001438",
"@preact/signals-core": "^1.8.0",

@@ -28,0 +28,0 @@ "@types/flexsearch": "^0.7.6",

@@ -6,3 +6,2 @@ // eslint-disable-next-line @typescript-eslint/triple-slash-reference

export * from './adapter/index.js';
export * from './migration/index.js';
export * from './reactive/index.js';

@@ -9,0 +8,0 @@ export * from './schema/index.js';

@@ -52,7 +52,2 @@ import type { Signal } from '@preact/signals-core';

.optional(),
onUpgrade: z
.function()
.args(z.any(), z.number(), z.number())
.returns(z.void())
.optional(),
});

@@ -94,7 +89,2 @@

props?: (internalPrimitives: InternalPrimitives) => Props;
onUpgrade?: (
data: Props,
previousVersion: number,
latestVersion: number
) => void;
toModel?: () => Model;

@@ -108,7 +98,2 @@ transformer?: () => Transformer;

} & Metadata;
onUpgrade?: (
data: Props,
previousVersion: number,
latestVersion: number
) => void;
transformer?: () => Transformer;

@@ -121,3 +106,2 @@ };

metadata,
onUpgrade,
toModel,

@@ -134,7 +118,2 @@ transformer,

props?: (internalPrimitives: InternalPrimitives) => Record<string, unknown>;
onUpgrade?: (
data: Record<string, unknown>,
previousVersion: number,
latestVersion: number
) => void;
toModel?: () => BlockModel;

@@ -153,3 +132,2 @@ transformer?: () => BaseBlockTransformer;

},
onUpgrade,
transformer,

@@ -156,0 +134,0 @@ } satisfies z.infer<typeof BlockSchema>;

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

import type * as Y from 'yjs';
import { minimatch } from 'minimatch';

@@ -8,94 +6,8 @@

import { SCHEMA_NOT_FOUND_MESSAGE } from '../consts.js';
import { collectionMigrations, docMigrations } from '../migration/index.js';
import { Block, type YBlock } from '../store/doc/block/index.js';
import { BlockSchema } from './base.js';
import { MigrationError, SchemaValidateError } from './error.js';
import { SchemaValidateError } from './error.js';
export class Schema {
private _upgradeBlockVersions = (rootData: Y.Doc) => {
const meta = rootData.getMap('meta');
const blockVersions = meta.get('blockVersions') as Y.Map<number>;
if (!blockVersions) {
return;
}
blockVersions.forEach((version, flavour) => {
const currentSchema = this.flavourSchemaMap.get(flavour);
if (currentSchema && version !== currentSchema.version) {
blockVersions.set(flavour, currentSchema.version);
}
});
};
readonly flavourSchemaMap = new Map<string, BlockSchemaType>();
upgradeBlock = (
flavour: string,
oldVersion: number,
blockData: Y.Map<unknown>
) => {
try {
const currentSchema = this.flavourSchemaMap.get(flavour);
if (!currentSchema) {
throw new MigrationError(`schema for flavour: ${flavour} not found`);
}
const { onUpgrade, version } = currentSchema;
if (!onUpgrade) {
return;
}
const block = new Block(this, blockData as YBlock);
return onUpgrade(block.model, oldVersion, version);
} catch (err) {
throw new MigrationError(`upgrade block ${flavour} failed.
${err}`);
}
};
upgradeCollection = (rootData: Y.Doc) => {
this._upgradeBlockVersions(rootData);
collectionMigrations.forEach(migration => {
try {
if (migration.condition(rootData)) {
migration.migrate(rootData);
}
} catch (err) {
console.error(err);
throw new MigrationError(migration.desc);
}
});
};
upgradeDoc = (
oldPageVersion: number,
oldBlockVersions: Record<string, number>,
docData: Y.Doc
) => {
// block migrations
const blocks = docData.getMap('blocks') as Y.Map<Y.Map<unknown>>;
Array.from(blocks.values()).forEach(block => {
const flavour = block.get('sys:flavour') as string;
const currentVersion =
(block.get('sys:version') as number) ?? oldBlockVersions[flavour] ?? 0;
if (currentVersion == null) {
throw new MigrationError(
`version for flavour ${flavour} not found in block`
);
}
this.upgradeBlock(flavour, currentVersion, block);
});
// doc migrations
docMigrations.forEach(migration => {
try {
if (migration.condition(oldPageVersion, docData)) {
migration.migrate(oldPageVersion, docData);
}
} catch (err) {
throw new MigrationError(`${migration.desc}
${err}`);
}
});
};
validate = (

@@ -102,0 +14,0 @@ flavour: string,

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