chore(infra): remove blocksuite from infra (#9353)

This commit is contained in:
liuyi
2024-12-26 21:43:12 +08:00
committed by GitHub
parent 126d576c3e
commit 41c8232472
12 changed files with 30 additions and 21 deletions

View File

@@ -1,7 +1,6 @@
export * from './app-config-storage';
export * from './atom';
export * from './framework';
export * from './initialization';
export * from './livedata';
export * from './orm';
export * from './storage';

View File

@@ -1,45 +0,0 @@
import type { SurfaceBlockProps } from '@blocksuite/affine/block-std/gfx';
import {
NoteDisplayMode,
type NoteProps,
type ParagraphProps,
type RootBlockProps,
} from '@blocksuite/affine/blocks';
import { type Doc, Text } from '@blocksuite/affine/store';
export interface DocProps {
page?: Partial<RootBlockProps>;
surface?: Partial<SurfaceBlockProps>;
note?: Partial<NoteProps>;
paragraph?: Partial<ParagraphProps>;
}
export function initEmptyDoc(doc: Doc, title?: string) {
doc.load(() => {
initDocFromProps(doc, {
page: {
title: new Text(title),
},
});
});
}
export function initDocFromProps(doc: Doc, props?: DocProps) {
doc.load(() => {
const pageBlockId = doc.addBlock(
'affine:page',
props?.page || { title: new Text('') }
);
doc.addBlock('affine:surface' as never, props?.surface || {}, pageBlockId);
const noteBlockId = doc.addBlock(
'affine:note',
{
...props?.note,
displayMode: NoteDisplayMode.DocAndEdgeless,
},
pageBlockId
);
doc.addBlock('affine:paragraph', props?.paragraph || {}, noteBlockId);
doc.history.clear();
});
}

View File

@@ -1,5 +1,5 @@
import { DebugLogger } from '@affine/debug';
import { Slot } from '@blocksuite/affine/global/utils';
import EventEmitter2 from 'eventemitter2';
import { difference } from 'lodash-es';
import { LiveData } from '../../livedata';
@@ -32,13 +32,19 @@ export interface BlobStatus {
export class BlobEngine {
readonly name = 'blob-engine';
readonly readonly = this.local.readonly;
readonly event = new EventEmitter2();
private abort: AbortController | null = null;
readonly isStorageOverCapacity$ = new LiveData(false);
singleBlobSizeLimit: number = 100 * 1024 * 1024;
onAbortLargeBlob = new Slot<Blob>();
onAbortLargeBlob = (callback: (blob: Blob) => void) => {
this.event.on('abort-large-blob', callback);
return () => {
this.event.off('abort-large-blob', callback);
};
};
constructor(
private readonly local: BlobStorage,
@@ -153,7 +159,7 @@ export class BlobEngine {
}
if (value.size > this.singleBlobSizeLimit) {
this.onAbortLargeBlob.emit(value);
this.event.emit('abort-large-blob', value);
logger.error('blob over limit, abort set');
return key;
}