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 de0e2f2d4f
12 changed files with 30 additions and 21 deletions
-1
View File
@@ -1,7 +1,6 @@
export * from './app-config-storage'; export * from './app-config-storage';
export * from './atom'; export * from './atom';
export * from './framework'; export * from './framework';
export * from './initialization';
export * from './livedata'; export * from './livedata';
export * from './orm'; export * from './orm';
export * from './storage'; export * from './storage';
+9 -3
View File
@@ -1,5 +1,5 @@
import { DebugLogger } from '@affine/debug'; import { DebugLogger } from '@affine/debug';
import { Slot } from '@blocksuite/affine/global/utils'; import EventEmitter2 from 'eventemitter2';
import { difference } from 'lodash-es'; import { difference } from 'lodash-es';
import { LiveData } from '../../livedata'; import { LiveData } from '../../livedata';
@@ -32,13 +32,19 @@ export interface BlobStatus {
export class BlobEngine { export class BlobEngine {
readonly name = 'blob-engine'; readonly name = 'blob-engine';
readonly readonly = this.local.readonly; readonly readonly = this.local.readonly;
readonly event = new EventEmitter2();
private abort: AbortController | null = null; private abort: AbortController | null = null;
readonly isStorageOverCapacity$ = new LiveData(false); readonly isStorageOverCapacity$ = new LiveData(false);
singleBlobSizeLimit: number = 100 * 1024 * 1024; 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( constructor(
private readonly local: BlobStorage, private readonly local: BlobStorage,
@@ -153,7 +159,7 @@ export class BlobEngine {
} }
if (value.size > this.singleBlobSizeLimit) { if (value.size > this.singleBlobSizeLimit) {
this.onAbortLargeBlob.emit(value); this.event.emit('abort-large-blob', value);
logger.error('blob over limit, abort set'); logger.error('blob over limit, abort set');
return key; return key;
} }
-3
View File
@@ -12,9 +12,6 @@
}, },
{ {
"path": "../debug" "path": "../debug"
},
{
"path": "../../../blocksuite/affine/all"
} }
] ]
} }
+3
View File
@@ -15,6 +15,9 @@
}, },
{ {
"path": "../infra" "path": "../infra"
},
{
"path": "../../../blocksuite/affine/all"
} }
] ]
} }
@@ -88,9 +88,9 @@ export const CloudQuotaModal = () => {
currentWorkspace.engine.blob.singleBlobSizeLimit = workspaceQuota.blobLimit; currentWorkspace.engine.blob.singleBlobSizeLimit = workspaceQuota.blobLimit;
const disposable = const disposable =
currentWorkspace.engine.blob.onAbortLargeBlob.on(onAbortLargeBlob); currentWorkspace.engine.blob.onAbortLargeBlob(onAbortLargeBlob);
return () => { return () => {
disposable?.dispose(); disposable();
}; };
}, [currentWorkspace.engine.blob, onAbortLargeBlob, workspaceQuota]); }, [currentWorkspace.engine.blob, onAbortLargeBlob, workspaceQuota]);
@@ -16,13 +16,13 @@ export const LocalQuotaModal = () => {
}, [setOpen]); }, [setOpen]);
useEffect(() => { useEffect(() => {
const disposable = currentWorkspace.engine.blob.onAbortLargeBlob.on(() => { const disposable = currentWorkspace.engine.blob.onAbortLargeBlob(() => {
setOpen(true); setOpen(true);
}); });
return () => { return () => {
disposable?.dispose(); disposable();
}; };
}, [currentWorkspace.engine.blob.onAbortLargeBlob, setOpen]); }, [currentWorkspace.engine.blob, setOpen]);
return ( return (
<ConfirmModal <ConfirmModal
@@ -67,12 +67,13 @@ import {
import { Bound } from '@blocksuite/affine/global/utils'; import { Bound } from '@blocksuite/affine/global/utils';
import { type BlockSnapshot, Text } from '@blocksuite/affine/store'; import { type BlockSnapshot, Text } from '@blocksuite/affine/store';
import type { ReferenceParams } from '@blocksuite/affine-model'; import type { ReferenceParams } from '@blocksuite/affine-model';
import { type DocProps, type FrameworkProvider } from '@toeverything/infra'; import { type FrameworkProvider } from '@toeverything/infra';
import { type TemplateResult } from 'lit'; import { type TemplateResult } from 'lit';
import { customElement } from 'lit/decorators.js'; import { customElement } from 'lit/decorators.js';
import { literal } from 'lit/static-html.js'; import { literal } from 'lit/static-html.js';
import { pick } from 'lodash-es'; import { pick } from 'lodash-es';
import type { DocProps } from '../../../../../blocksuite/initialization';
import { generateUrl } from '../../../../hooks/affine/use-share-url'; import { generateUrl } from '../../../../hooks/affine/use-share-url';
import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar'; import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';
@@ -1,11 +1,12 @@
import { toast } from '@affine/component'; import { toast } from '@affine/component';
import type { DocProps } from '@affine/core/blocksuite/initialization';
import { AppSidebarService } from '@affine/core/modules/app-sidebar'; import { AppSidebarService } from '@affine/core/modules/app-sidebar';
import { DocsService } from '@affine/core/modules/doc'; import { DocsService } from '@affine/core/modules/doc';
import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { EditorSettingService } from '@affine/core/modules/editor-setting';
import { WorkbenchService } from '@affine/core/modules/workbench'; import { WorkbenchService } from '@affine/core/modules/workbench';
import { type DocMode } from '@blocksuite/affine/blocks'; import { type DocMode } from '@blocksuite/affine/blocks';
import type { DocCollection } from '@blocksuite/affine/store'; import type { DocCollection } from '@blocksuite/affine/store';
import { type DocProps, useServices } from '@toeverything/infra'; import { useServices } from '@toeverything/infra';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
export const usePageHelper = (docCollection: DocCollection) => { export const usePageHelper = (docCollection: DocCollection) => {
@@ -3,13 +3,12 @@ import { Unreachable } from '@affine/env/constant';
import type { DocMode } from '@blocksuite/affine/blocks'; import type { DocMode } from '@blocksuite/affine/blocks';
import type { DeltaInsert } from '@blocksuite/affine/inline'; import type { DeltaInsert } from '@blocksuite/affine/inline';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types'; import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ObjectPool, Service } from '@toeverything/infra';
import { import {
type DocProps, type DocProps,
initDocFromProps, initDocFromProps,
ObjectPool, } from '../../../blocksuite/initialization';
Service,
} from '@toeverything/infra';
import type { Doc } from '../entities/doc'; import type { Doc } from '../entities/doc';
import { DocPropertyList } from '../entities/property-list'; import { DocPropertyList } from '../entities/property-list';
import { DocRecordList } from '../entities/record-list'; import { DocRecordList } from '../entities/record-list';
@@ -1,8 +1,11 @@
import { Text } from '@blocksuite/affine/store'; import { Text } from '@blocksuite/affine/store';
import type { DocProps } from '@toeverything/infra'; import { LiveData, Service } from '@toeverything/infra';
import { initDocFromProps, LiveData, Service } from '@toeverything/infra';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import {
type DocProps,
initDocFromProps,
} from '../../../blocksuite/initialization';
import type { DocsService } from '../../doc'; import type { DocsService } from '../../doc';
import type { EditorSettingService } from '../../editor-setting'; import type { EditorSettingService } from '../../editor-setting';
import type { JournalStore } from '../store/journal'; import type { JournalStore } from '../store/journal';
@@ -1,8 +1,8 @@
import { track } from '@affine/track'; import { track } from '@affine/track';
import { Text } from '@blocksuite/affine/store'; import { Text } from '@blocksuite/affine/store';
import type { DocProps } from '@toeverything/infra';
import { Service } from '@toeverything/infra'; import { Service } from '@toeverything/infra';
import type { DocProps } from '../../../blocksuite/initialization';
import type { DocsService } from '../../doc'; import type { DocsService } from '../../doc';
import { EditorSettingService } from '../../editor-setting'; import { EditorSettingService } from '../../editor-setting';
import type { WorkbenchService } from '../../workbench'; import type { WorkbenchService } from '../../workbench';