Skip to content

Commit

Permalink
chore(infra): remove blocksuite from infra (#9353)
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo authored Dec 26, 2024
1 parent 126d576 commit 41c8232
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 21 deletions.
1 change: 0 additions & 1 deletion packages/common/infra/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
12 changes: 9 additions & 3 deletions packages/common/infra/src/sync/blob/blob.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions packages/common/infra/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
},
{
"path": "../debug"
},
{
"path": "../../../blocksuite/affine/all"
}
]
}
3 changes: 3 additions & 0 deletions packages/common/nbstore/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
},
{
"path": "../infra"
},
{
"path": "../../../blocksuite/affine/all"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export const CloudQuotaModal = () => {
currentWorkspace.engine.blob.singleBlobSizeLimit = workspaceQuota.blobLimit;

const disposable =
currentWorkspace.engine.blob.onAbortLargeBlob.on(onAbortLargeBlob);
currentWorkspace.engine.blob.onAbortLargeBlob(onAbortLargeBlob);
return () => {
disposable?.dispose();
disposable();
};
}, [currentWorkspace.engine.blob, onAbortLargeBlob, workspaceQuota]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export const LocalQuotaModal = () => {
}, [setOpen]);

useEffect(() => {
const disposable = currentWorkspace.engine.blob.onAbortLargeBlob.on(() => {
const disposable = currentWorkspace.engine.blob.onAbortLargeBlob(() => {
setOpen(true);
});
return () => {
disposable?.dispose();
disposable();
};
}, [currentWorkspace.engine.blob.onAbortLargeBlob, setOpen]);
}, [currentWorkspace.engine.blob, setOpen]);

return (
<ConfirmModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ import {
import { Bound } from '@blocksuite/affine/global/utils';
import { type BlockSnapshot, Text } from '@blocksuite/affine/store';
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 { customElement } from 'lit/decorators.js';
import { literal } from 'lit/static-html.js';
import { pick } from 'lodash-es';

import type { DocProps } from '../../../../../blocksuite/initialization';
import { generateUrl } from '../../../../hooks/affine/use-share-url';
import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { toast } from '@affine/component';
import type { DocProps } from '@affine/core/blocksuite/initialization';
import { AppSidebarService } from '@affine/core/modules/app-sidebar';
import { DocsService } from '@affine/core/modules/doc';
import { EditorSettingService } from '@affine/core/modules/editor-setting';
import { WorkbenchService } from '@affine/core/modules/workbench';
import { type DocMode } from '@blocksuite/affine/blocks';
import type { DocCollection } from '@blocksuite/affine/store';
import { type DocProps, useServices } from '@toeverything/infra';
import { useServices } from '@toeverything/infra';
import { useCallback, useMemo } from 'react';

export const usePageHelper = (docCollection: DocCollection) => {
Expand Down
7 changes: 3 additions & 4 deletions packages/frontend/core/src/modules/doc/services/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { Unreachable } from '@affine/env/constant';
import type { DocMode } from '@blocksuite/affine/blocks';
import type { DeltaInsert } from '@blocksuite/affine/inline';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ObjectPool, Service } from '@toeverything/infra';

import {
type DocProps,
initDocFromProps,
ObjectPool,
Service,
} from '@toeverything/infra';

} from '../../../blocksuite/initialization';
import type { Doc } from '../entities/doc';
import { DocPropertyList } from '../entities/property-list';
import { DocRecordList } from '../entities/record-list';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Text } from '@blocksuite/affine/store';
import type { DocProps } from '@toeverything/infra';
import { initDocFromProps, LiveData, Service } from '@toeverything/infra';
import { LiveData, Service } from '@toeverything/infra';
import dayjs from 'dayjs';

import {
type DocProps,
initDocFromProps,
} from '../../../blocksuite/initialization';
import type { DocsService } from '../../doc';
import type { EditorSettingService } from '../../editor-setting';
import type { JournalStore } from '../store/journal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { track } from '@affine/track';
import { Text } from '@blocksuite/affine/store';
import type { DocProps } from '@toeverything/infra';
import { Service } from '@toeverything/infra';

import type { DocProps } from '../../../blocksuite/initialization';
import type { DocsService } from '../../doc';
import { EditorSettingService } from '../../editor-setting';
import type { WorkbenchService } from '../../workbench';
Expand Down

0 comments on commit 41c8232

Please sign in to comment.