diff --git a/packages/affine/block-surface/src/surface-model.ts b/packages/affine/block-surface/src/surface-model.ts index 10d837178076..25e7eb16951d 100644 --- a/packages/affine/block-surface/src/surface-model.ts +++ b/packages/affine/block-surface/src/surface-model.ts @@ -1,134 +1,15 @@ import type { ConnectorElementModel } from '@blocksuite/affine-model'; import type { SurfaceBlockProps } from '@blocksuite/block-std/gfx'; -import type { MigrationRunner, Y } from '@blocksuite/store'; import { SurfaceBlockModel as BaseSurfaceModel } from '@blocksuite/block-std/gfx'; import { DisposableGroup } from '@blocksuite/global/utils'; -import { - Boxed, - defineBlockSchema, - DocCollection, - Text, -} from '@blocksuite/store'; +import { defineBlockSchema, DocCollection } from '@blocksuite/store'; import { elementsCtorMap } from './element-model/index.js'; import { SurfaceBlockTransformer } from './surface-transformer.js'; import { connectorWatcher } from './watchers/connector.js'; import { groupRelationWatcher } from './watchers/group.js'; -const migration = { - toV4: data => { - const { elements } = data; - if (elements instanceof Boxed) { - const value = elements.getValue(); - if (!value) { - return; - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - for (const [key, element] of (value as Record).entries()) { - const type = element.get('type') as string; - if (type === 'shape' || type === 'text') { - const isBold = element.get('isBold'); - const isItalic = element.get('isItalic'); - element.delete('isBold'); - element.delete('isItalic'); - if (isBold) { - element.set('bold', true); - } - if (isItalic) { - element.set('italic', true); - } - } - if (type === 'connector') { - const source = element.get('source'); - const target = element.get('target'); - const sourceId = source['id']; - const targetId = target['id']; - if (!source['position'] && !sourceId) { - value.delete(key); - return; - } - if (!target['position'] && !targetId) { - value.delete(key); - return; - } - } - } - } else { - for (const key of Object.keys(elements)) { - const element = elements[key] as Record; - const type = element['type'] as string; - if (type === 'shape' || type === 'text') { - const isBold = element['isBold']; - const isItalic = element['isItalic']; - delete element['isBold']; - delete element['isItalic']; - if (isBold) { - element['bold'] = true; - } - if (isItalic) { - element['italic'] = true; - } - } - if (type === 'connector') { - const source = element['source'] as Record; - const target = element['target'] as Record; - const sourceId = source['id']; - const targetId = target['id']; - // @ts-expect-error - if (!source['position'] && (!sourceId || !elements[sourceId])) { - delete elements[key]; - return; - } - // @ts-expect-error - if (!target['position'] && (!targetId || !elements[targetId])) { - delete elements[key]; - return; - } - } - } - } - }, - toV5: data => { - const { elements } = data; - if (!((elements as object | Boxed) instanceof Boxed)) { - const yMap = new DocCollection.Y.Map() as Y.Map>; - - Object.entries(elements).forEach(([key, value]) => { - const map = new DocCollection.Y.Map(); - Object.entries(value).forEach(([_key, _value]) => { - map.set( - _key, - _value instanceof DocCollection.Y.Text - ? _value.clone() - : _value instanceof Text - ? _value.yText.clone() - : _value - ); - }); - yMap.set(key, map); - }); - const wrapper = new Boxed(yMap); - data.elements = wrapper; - } - - const childrenMap = data.elements.getValue() as Y.Map>; - - for (const [id, element] of childrenMap) { - if ( - element.get('type') === 'mindmap' || - element.get('type') === 'group' - ) { - const children = element.get('children') as Y.Map>; - - if (children?.size === 0) { - childrenMap.delete(id); - } - } - } - }, -} satisfies Record>; - export const SurfaceBlockSchema = defineBlockSchema({ flavour: 'affine:surface', props: (internalPrimitives): SurfaceBlockProps => ({ @@ -147,14 +28,6 @@ export const SurfaceBlockSchema = defineBlockSchema({ 'affine:edgeless-text', ], }, - onUpgrade: (data, previousVersion, version) => { - if (previousVersion < 4 && version >= 4) { - migration.toV4(data); - } - if (previousVersion < 5 && version >= 5) { - migration.toV5(data); - } - }, transformer: () => new SurfaceBlockTransformer(), toModel: () => new SurfaceBlockModel(), }); diff --git a/packages/affine/model/src/blocks/database/database-model.ts b/packages/affine/model/src/blocks/database/database-model.ts index 19b321f1e49f..a5d67a23dab9 100644 --- a/packages/affine/model/src/blocks/database/database-model.ts +++ b/packages/affine/model/src/blocks/database/database-model.ts @@ -1,6 +1,6 @@ -import type { MigrationRunner, Text } from '@blocksuite/store'; +import type { Text } from '@blocksuite/store'; -import { BlockModel, defineBlockSchema, nanoid } from '@blocksuite/store'; +import { BlockModel, defineBlockSchema } from '@blocksuite/store'; import type { Column, SerializedCells, ViewBasicDataType } from './types.js'; @@ -13,36 +13,6 @@ export type DatabaseBlockProps = { export class DatabaseBlockModel extends BlockModel {} -const migration = { - toV3: data => { - const id = nanoid(); - // @ts-expect-error - const title = data['titleColumnName']; - // @ts-expect-error - const width = data['titleColumnWidth']; - // @ts-expect-error - delete data['titleColumnName']; - // @ts-expect-error - delete data['titleColumnWidth']; - data.columns.unshift({ - id, - type: 'title', - name: title, - data: {}, - }); - data.views.forEach(view => { - if (view.mode === 'table') { - // @ts-ignore - view.columns.unshift({ - id, - width, - statCalcType: 'none', - }); - } - }); - }, -} satisfies Record>; - export const DatabaseBlockSchema = defineBlockSchema({ flavour: 'affine:database', props: (internal): DatabaseBlockProps => ({ @@ -58,9 +28,4 @@ export const DatabaseBlockSchema = defineBlockSchema({ children: ['affine:paragraph', 'affine:list'], }, toModel: () => new DatabaseBlockModel(), - onUpgrade: (data, previousVersion, latestVersion) => { - if (previousVersion < 3 && latestVersion >= 3) { - migration.toV3(data); - } - }, }); diff --git a/packages/blocks/src/__tests__/migration/migration.unit.spec.ts b/packages/blocks/src/__tests__/migration/migration.unit.spec.ts deleted file mode 100644 index 7460b7e9a03c..000000000000 --- a/packages/blocks/src/__tests__/migration/migration.unit.spec.ts +++ /dev/null @@ -1,214 +0,0 @@ -import { SurfaceBlockSchema } from '@blocksuite/affine-block-surface'; -import { - DatabaseBlockSchema, - FrameBlockSchema, - ListBlockSchema, - NoteBlockSchema, - ParagraphBlockSchema, - RootBlockSchema, -} from '@blocksuite/affine-model'; -import { DocCollection, Schema, type Y } from '@blocksuite/store'; -// normal import -import { readFile } from 'node:fs/promises'; -import { join } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { assert, describe, expect, test } from 'vitest'; - -async function loadBinary(name: string) { - const originPath = fileURLToPath(import.meta.url); - const path = join(originPath, `../ydocs/${name}.ydoc`); - const buffer = await readFile(path); - const update = new Uint8Array(buffer); - const doc = new DocCollection.Y.Doc(); - DocCollection.Y.applyUpdate(doc, update); - return doc; -} - -const schema = new Schema(); -schema.register([ - RootBlockSchema, - SurfaceBlockSchema, - NoteBlockSchema, - ParagraphBlockSchema, - ListBlockSchema, - DatabaseBlockSchema, - FrameBlockSchema, -]); - -describe('collection migration', () => { - test('add pageVersion in collection meta', async () => { - const doc = await loadBinary('workspace-v1-v2'); - - const meta = doc.getMap('meta'); - const before = meta.toJSON(); - assert.equal(before['workspaceVersion'], 1); - assert.isUndefined(before['pageVersion']); - - schema.upgradeCollection(doc); - - const after = meta.toJSON(); - assert.equal(after['workspaceVersion'], 2); - assert.equal(after['pageVersion'], 1); - }); -}); - -describe('block migration', () => { - test('update shape and text element, `isBold` -> `bold`, `isItalic` -> `italic`, surface v3 -> v4', async () => { - const doc = await loadBinary('page-surface-v3-v4'); - - // @ts-ignore - let surfaceElements = doc - .getMap('blocks') - .get('zUHGq4EHQJ') - .get('prop:elements') as Y.Map; - let text = surfaceElements.get('Cj2MNGM9UK') as Y.Map; - let shape = surfaceElements.get('Rl2IT9rGoP') as Y.Map; - - assert.equal(text.get('isBold'), true); - assert.equal(text.get('isItalic'), true); - assert.equal((text.get('text') as Y.Text).toJSON(), 'aaa'); - assert.isUndefined(text.get('bold')); - assert.isUndefined(text.get('italic')); - - assert.equal(shape.get('isBold'), true); - assert.equal(shape.get('isItalic'), true); - assert.isUndefined(shape.get('bold')); - assert.isUndefined(shape.get('italic')); - - schema.upgradeDoc( - 0, - { - 'affine:page': 1, - 'affine:note': 1, - 'affine:paragraph': 1, - 'affine:surface': 3, - }, - doc - ); - - // @ts-ignore - surfaceElements = doc - .getMap('blocks') - .get('zUHGq4EHQJ') - .get('prop:elements') - .get('value') as Y.Map; - text = surfaceElements.get('Cj2MNGM9UK') as Y.Map; - shape = surfaceElements.get('Rl2IT9rGoP') as Y.Map; - - assert.isUndefined(text.get('isBold')); - assert.isUndefined(text.get('isItalic')); - assert.equal(text.get('bold'), true); - assert.equal(text.get('italic'), true); - - assert.equal((text.get('text') as Y.Text).toJSON(), 'aaa'); - - assert.isUndefined(shape.get('isBold')); - assert.isUndefined(shape.get('isItalic')); - assert.equal(shape.get('bold'), true); - assert.equal(shape.get('italic'), true); - }); - - test('fix wrong connector data', async () => { - const doc = await loadBinary('connector'); - // @ts-ignore - const surfaceElements = doc - .getMap('blocks') - .get('BOpLR3siGx') - .get('prop:elements') as Y.Map; - - let connector = surfaceElements.get('Gt8_2oZB8h') as Y.Map; - - assert.exists(connector); - - schema.upgradeDoc( - 0, - { - 'affine:list': 1, - 'affine:page': 1, - 'affine:note': 1, - 'affine:paragraph': 1, - 'affine:surface': 3, - }, - doc - ); - - connector = surfaceElements.get('Gt8_2oZB8h') as Y.Map; - - assert.notExists(connector); - }); - - test('frame element to block', async () => { - const doc = await loadBinary('frame-element-to-block'); - - const blocks = doc.getMap('blocks'); - - const page = blocks.get('H4fVFXmGUu') as Y.Map; - - // @ts-ignore - const surfaceElements = blocks - .get('eligOTIQu-') - .get('prop:elements') - .get('value') as Y.Map; - assert.exists(surfaceElements.get('2')); - - schema.upgradeDoc( - 0, - { - 'affine:surface': 5, - }, - doc - ); - - assert.notExists(surfaceElements.get('2')); - const pageChildren = page.get('sys:children') as Y.Array; - const id = pageChildren.get(pageChildren.length - 1); - assert.equal(id, '2'); - assert.exists(blocks.get(id)); - }); - - test('update database block title data', async () => { - const doc = await loadBinary('page-database-v2-v3'); - - let databaseBlock = ( - doc.getMap('blocks').get('Y76JkP9XRn') as Y.Map - ).toJSON(); - expect(databaseBlock['prop:titleColumnName']).toBe('Title'); - expect(databaseBlock['prop:titleColumnWidth']).toBe(200); - expect( - databaseBlock['prop:columns'].find( - (v: Record) => v.type === 'title' - ) - ).toBeUndefined(); - expect(databaseBlock['prop:views'].length).toBe(2); - - schema.upgradeDoc( - 0, - { - 'affine:page': 1, - 'affine:surface': 4, - 'affine:note': 1, - 'affine:paragraph': 1, - 'affine:database': 2, - }, - doc - ); - databaseBlock = ( - doc.getMap('blocks').get('Y76JkP9XRn') as Y.Map - ).toJSON(); - expect(databaseBlock['prop:titleColumnName']).toBeUndefined(); - expect(databaseBlock['prop:titleColumnWidth']).toBeUndefined(); - const titleColumn = databaseBlock['prop:columns'].find( - (v: Record) => v.type === 'title' - ); - expect(titleColumn.type).toBe('title'); - for (const view of databaseBlock['prop:views']) { - if (view['mode'] === 'table') { - expect( - view['columns'].find( - (v: Record) => v.id === titleColumn.id - ).width - ).toBe(200); - } - } - }); -}); diff --git a/packages/blocks/src/__tests__/migration/ydocs/connector.ydoc b/packages/blocks/src/__tests__/migration/ydocs/connector.ydoc deleted file mode 100644 index 2ce30a8579c3..000000000000 Binary files a/packages/blocks/src/__tests__/migration/ydocs/connector.ydoc and /dev/null differ diff --git a/packages/blocks/src/__tests__/migration/ydocs/frame-element-to-block.ydoc b/packages/blocks/src/__tests__/migration/ydocs/frame-element-to-block.ydoc deleted file mode 100644 index 2cc63d2f80b8..000000000000 Binary files a/packages/blocks/src/__tests__/migration/ydocs/frame-element-to-block.ydoc and /dev/null differ diff --git a/packages/blocks/src/__tests__/migration/ydocs/page-database-v2-v3.ydoc b/packages/blocks/src/__tests__/migration/ydocs/page-database-v2-v3.ydoc deleted file mode 100644 index aa0b0ec722a1..000000000000 Binary files a/packages/blocks/src/__tests__/migration/ydocs/page-database-v2-v3.ydoc and /dev/null differ diff --git a/packages/blocks/src/__tests__/migration/ydocs/page-surface-v3-v4.ydoc b/packages/blocks/src/__tests__/migration/ydocs/page-surface-v3-v4.ydoc deleted file mode 100644 index ba53976c3de9..000000000000 Binary files a/packages/blocks/src/__tests__/migration/ydocs/page-surface-v3-v4.ydoc and /dev/null differ diff --git a/packages/blocks/src/__tests__/migration/ydocs/workspace-v1-v2.ydoc b/packages/blocks/src/__tests__/migration/ydocs/workspace-v1-v2.ydoc deleted file mode 100644 index 074073e5d0bd..000000000000 Binary files a/packages/blocks/src/__tests__/migration/ydocs/workspace-v1-v2.ydoc and /dev/null differ diff --git a/packages/blocks/src/_common/transformers/zip.ts b/packages/blocks/src/_common/transformers/zip.ts index 834d08d16a04..61d5d26d6bba 100644 --- a/packages/blocks/src/_common/transformers/zip.ts +++ b/packages/blocks/src/_common/transformers/zip.ts @@ -1,10 +1,4 @@ -import type { - CollectionInfoSnapshot, - Doc, - DocCollection, - DocSnapshot, - JobMiddleware, -} from '@blocksuite/store'; +import type { Doc, DocCollection, DocSnapshot } from '@blocksuite/store'; import { sha } from '@blocksuite/global/utils'; import { extMimeMap, getAssetName, Job } from '@blocksuite/store'; @@ -48,8 +42,6 @@ async function importDocs(collection: DocCollection, imported: Blob) { const assetBlobs: [string, Blob][] = []; const snapshotsBlobs: Blob[] = []; - let infoBlob: Blob | undefined; - let info: CollectionInfoSnapshot | undefined; for (const { path, content: blob } of unzip) { if (path.includes('MACOSX') || path.includes('DS_Store')) { @@ -62,7 +54,6 @@ async function importDocs(collection: DocCollection, imported: Blob) { } if (path === 'info.json') { - infoBlob = blob; continue; } @@ -72,25 +63,9 @@ async function importDocs(collection: DocCollection, imported: Blob) { } } - { - const json = (await infoBlob?.text()) ?? ''; - info = JSON.parse(json) as CollectionInfoSnapshot; - } - - const migrationMiddleware: JobMiddleware = ({ slots, collection }) => { - slots.afterImport.on(payload => { - if (payload.type === 'page') { - collection.schema.upgradeDoc( - info?.pageVersion ?? 0, - {}, - payload.page.spaceDoc - ); - } - }); - }; const job = new Job({ collection, - middlewares: [replaceIdMiddleware, migrationMiddleware, titleMiddleware], + middlewares: [replaceIdMiddleware, titleMiddleware], }); const assetsMap = job.assets; diff --git a/packages/framework/store/src/index.ts b/packages/framework/store/src/index.ts index 8570e3f12881..a7e7d8753e52 100644 --- a/packages/framework/store/src/index.ts +++ b/packages/framework/store/src/index.ts @@ -3,7 +3,6 @@ export type { Y }; export * from './adapter/index.js'; -export * from './migration/index.js'; export * from './reactive/index.js'; export * from './schema/index.js'; export * from './store/index.js'; diff --git a/packages/framework/store/src/migration/index.ts b/packages/framework/store/src/migration/index.ts deleted file mode 100644 index 0132901f3482..000000000000 --- a/packages/framework/store/src/migration/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { BlockSchemaType } from '../schema/base.js'; - -export * from './migrate-collection.js'; -export * from './migrate-doc.js'; - -export type MigrationRunner = - BlockSchema['onUpgrade']; diff --git a/packages/framework/store/src/migration/migrate-collection.ts b/packages/framework/store/src/migration/migrate-collection.ts deleted file mode 100644 index 8f19bcc1372d..000000000000 --- a/packages/framework/store/src/migration/migrate-collection.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type * as Y from 'yjs'; - -interface ICollctionMigration { - desc: string; - condition: (rootDoc: Y.Doc) => boolean; - migrate: (rootDoc: Y.Doc) => void; -} - -export const collectionMigrations: ICollctionMigration[] = [ - { - desc: 'add pageVersion in meta', - condition: (rootDoc: Y.Doc) => { - const meta = rootDoc.getMap('meta'); - const workspaceVersion = meta.get('workspaceVersion') as number; - return workspaceVersion < 2; - }, - migrate: (rootDoc: Y.Doc) => { - const meta = rootDoc.getMap('meta'); - meta.set('pageVersion', 1); - meta.set('workspaceVersion', 2); - }, - }, -]; diff --git a/packages/framework/store/src/migration/migrate-doc.ts b/packages/framework/store/src/migration/migrate-doc.ts deleted file mode 100644 index 13ba6083feb9..000000000000 --- a/packages/framework/store/src/migration/migrate-doc.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { assertExists } from '@blocksuite/global/utils'; -import * as Y from 'yjs'; - -interface IDocMigration { - desc: string; - condition: (oldPageVersion: number, docData: Y.Doc) => boolean; - migrate: (oldPageVersion: number, docData: Y.Doc) => void; -} - -export const docMigrations: IDocMigration[] = [ - { - desc: 'frame element --> frame block (doc v1 --> v2)', - condition: oldPageVersion => { - return oldPageVersion < 2; - }, - migrate: (_, docData) => { - const blocks = docData.getMap('blocks') as Y.Map>; - let rootModel!: Y.Map, surface!: Y.Map; - blocks.forEach(block => { - const flavour = block.get('sys:flavour'); - if (flavour === 'affine:page') { - rootModel = block; - } - if (flavour === 'affine:surface') { - surface = block; - } - }); - assertExists(rootModel); - assertExists(surface); - // @ts-ignore - const elements = surface.get('prop:elements').get('value') as Y.Map< - Y.Map - >; - elements.forEach(element => { - if (element.get('type') === 'frame') { - const frameModel = new Y.Map(); - const id = element.get('id') as string; - frameModel.set('sys:flavour', 'affine:frame'); - frameModel.set('sys:id', id); - frameModel.set('sys:children', new Y.Array()); - frameModel.set( - 'prop:title', - (element.get('title') as Y.Text).clone() - ); - frameModel.set('prop:xywh', element.get('xywh')); - frameModel.set('prop:index', element.get('index')); - blocks.set(id, frameModel); - (rootModel.get('sys:children') as Y.Array).push([id]); - elements.delete(id); - } - }); - }, - }, -]; diff --git a/packages/framework/store/src/schema/base.ts b/packages/framework/store/src/schema/base.ts index ec9612b3cf96..9b594d669fe3 100644 --- a/packages/framework/store/src/schema/base.ts +++ b/packages/framework/store/src/schema/base.ts @@ -49,11 +49,6 @@ export const BlockSchema = z.object({ .args() .returns(z.custom()) .optional(), - onUpgrade: z - .function() - .args(z.any(), z.number(), z.number()) - .returns(z.void()) - .optional(), }); export type BlockSchemaType = z.infer; @@ -90,11 +85,6 @@ export function defineBlockSchema< flavour: Flavour; metadata: Metadata; props?: (internalPrimitives: InternalPrimitives) => Props; - onUpgrade?: ( - data: Props, - previousVersion: number, - latestVersion: number - ) => void; toModel?: () => Model; transformer?: () => Transformer; }): { @@ -103,11 +93,6 @@ export function defineBlockSchema< props: PropsGetter; flavour: Flavour; } & Metadata; - onUpgrade?: ( - data: Props, - previousVersion: number, - latestVersion: number - ) => void; transformer?: () => Transformer; }; @@ -115,7 +100,6 @@ export function defineBlockSchema({ flavour, props, metadata, - onUpgrade, toModel, transformer, }: { @@ -127,11 +111,6 @@ export function defineBlockSchema({ children?: string[]; }; props?: (internalPrimitives: InternalPrimitives) => Record; - onUpgrade?: ( - data: Record, - previousVersion: number, - latestVersion: number - ) => void; toModel?: () => BlockModel; transformer?: () => BaseBlockTransformer; }): BlockSchemaType { @@ -145,7 +124,6 @@ export function defineBlockSchema({ props, toModel, }, - onUpgrade, transformer, } satisfies z.infer; BlockSchema.parse(schema); diff --git a/packages/framework/store/src/schema/schema.ts b/packages/framework/store/src/schema/schema.ts index 3e84db50e363..7fbf4bda4303 100644 --- a/packages/framework/store/src/schema/schema.ts +++ b/packages/framework/store/src/schema/schema.ts @@ -1,102 +1,14 @@ -import type * as Y from 'yjs'; - import { minimatch } from 'minimatch'; import type { BlockSchemaType } from './base.js'; 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; - 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(); - upgradeBlock = ( - flavour: string, - oldVersion: number, - blockData: Y.Map - ) => { - 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, - docData: Y.Doc - ) => { - // block migrations - const blocks = docData.getMap('blocks') as Y.Map>; - 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 = ( flavour: string, parentFlavour?: string, diff --git a/packages/playground/apps/_common/components/pdf/worker.ts b/packages/playground/apps/_common/components/pdf/worker.ts index 4d0b1ed84e95..daaa292fc1a1 100644 --- a/packages/playground/apps/_common/components/pdf/worker.ts +++ b/packages/playground/apps/_common/components/pdf/worker.ts @@ -36,6 +36,7 @@ function renderToImageData(index: number, scale: number) { bitmap.fill(0, 0, width, height); page.render(bitmap, 0, 0, width, height, 0, flags); + // @ts-ignore const data = new Uint8ClampedArray(bitmap.toBytes()); bitmap.close();