From 129f94ee781662f2cf3bf6030ac419ef7fc673a9 Mon Sep 17 00:00:00 2001 From: EYHN Date: Mon, 23 Dec 2024 04:53:59 +0000 Subject: [PATCH] refactor(core): move infra modules to core (#9207) --- packages/common/infra/src/index.ts | 37 ----- .../infra/src/modules/db/entities/table.ts | 35 ----- .../common/infra/src/modules/storage/index.ts | 35 ----- .../workspace/__tests__/workspace.spec.ts | 31 ---- .../workspace/testing/testing-provider.ts | 145 ------------------ packages/frontend/apps/android/src/app.tsx | 8 +- .../frontend/apps/electron/renderer/app.tsx | 14 +- .../apps/electron/renderer/shell/app.tsx | 9 +- packages/frontend/apps/ios/src/app.tsx | 10 +- packages/frontend/apps/mobile/src/app.tsx | 8 +- packages/frontend/apps/web/src/app.tsx | 8 +- .../error-basic/info-logger.tsx | 7 +- .../components/affine/ai-onboarding/index.tsx | 3 +- .../src/components/affine/awareness/index.tsx | 3 +- .../components/affine/empty/collections.tsx | 3 +- .../core/src/components/affine/empty/docs.tsx | 3 +- .../affine/page-history-modal/data.ts | 6 +- .../page-history-modal/history-modal.tsx | 3 +- .../quota-reached-modal/cloud-quota-modal.tsx | 3 +- .../quota-reached-modal/local-quota-modal.tsx | 3 +- .../affine/reference-link/index.tsx | 8 +- .../affine/share-page-modal/index.tsx | 2 +- .../share-menu/share-menu.tsx | 7 +- .../bi-directional-link-panel.tsx | 10 +- .../block-suite-editor/lit-adaper.tsx | 7 +- .../specs/custom/root-block.ts | 9 +- .../specs/custom/spec-patchers.tsx | 5 +- .../block-suite-editor/specs/edgeless.ts | 6 +- .../block-suite-editor/specs/page.ts | 6 +- .../menu/history-tips-modal/index.tsx | 3 +- .../block-suite-header/menu/index.tsx | 2 +- .../block-suite-header/title/index.tsx | 9 +- .../block-suite-page-list/utils.tsx | 3 +- .../icons/doc-property-icon.tsx | 2 +- .../doc-properties/icons/icons-selector.tsx | 2 +- .../doc-properties/manager/index.tsx | 11 +- .../menu/create-doc-property.tsx | 9 +- .../doc-properties/menu/edit-doc-property.tsx | 3 +- .../doc-properties/sidebar/index.tsx | 3 +- .../src/components/doc-properties/table.tsx | 8 +- .../doc-properties/tags-inline-editor.tsx | 8 +- .../types/created-updated-by.tsx | 3 +- .../components/doc-properties/types/date.tsx | 3 +- .../doc-properties/types/doc-primary-mode.tsx | 3 +- .../doc-properties/types/edgeless-theme.tsx | 3 +- .../doc-properties/types/journal.tsx | 2 +- .../doc-properties/types/page-width.tsx | 3 +- .../components/doc-properties/types/tags.tsx | 3 +- .../components/doc-properties/types/types.ts | 2 +- .../hooks/affine/use-all-page-list-config.tsx | 3 +- .../affine/use-block-suite-meta-helper.ts | 4 +- .../hooks/affine/use-enable-cloud.tsx | 9 +- ...se-register-blocksuite-editor-commands.tsx | 4 +- .../use-register-copy-link-commands.tsx | 2 +- .../components/hooks/affine/use-sign-out.ts | 9 +- .../hooks/use-block-suite-page-meta.ts | 4 +- .../core/src/components/hooks/use-journal.ts | 3 +- .../hooks/use-register-workspace-commands.ts | 7 +- .../components/hooks/use-workspace-info.ts | 7 +- .../src/components/hooks/use-workspace.ts | 8 +- .../src/components/over-capacity/index.tsx | 3 +- .../src/components/page-detail-editor.tsx | 5 +- .../virtualized-collection-list.tsx | 3 +- .../page-list/docs/page-list-header.tsx | 10 +- .../components/page-list/docs/select-page.tsx | 7 +- .../page-list/docs/virtualized-page-list.tsx | 4 +- .../components/page-list/operation-cell.tsx | 12 +- .../page-list/tags/virtualized-tag-list.tsx | 3 +- .../use-all-doc-display-properties.ts | 3 +- .../page-list/view/collection-operations.tsx | 8 +- .../page-list/virtualized-trash-list.tsx | 3 +- .../providers/workspace-side-effects.tsx | 4 +- .../src/components/pure/help-island/index.tsx | 8 +- .../pure/trash-page-footer/index.tsx | 4 +- .../src/components/root-app-sidebar/index.tsx | 2 +- .../root-app-sidebar/trash-button.tsx | 9 +- .../core/src/components/sign-in/sign-in.tsx | 7 +- .../frontend/core/src/components/top-tip.tsx | 3 +- .../src/components/workspace-avatar/index.tsx | 8 +- .../components/workspace-selector/index.tsx | 9 +- .../add-server/index.tsx | 7 +- .../add-workspace/index.tsx | 7 +- .../user-with-workspace-list/index.tsx | 13 +- .../workspace-list/index.tsx | 10 +- .../workspace-card/index.tsx | 12 +- .../workspace-card/pure-workspace-card.tsx | 4 +- .../components/ai-island/container.tsx | 9 +- .../components/app-container/index.tsx | 2 +- .../dialogs/collection-editor/rules-mode.tsx | 3 +- .../dialogs/create-workspace/index.tsx | 9 +- .../src/desktop/dialogs/doc-info/index.tsx | 4 +- .../desktop/dialogs/doc-info/info-modal.tsx | 10 +- .../src/desktop/dialogs/doc-info/time-row.tsx | 9 +- .../desktop/dialogs/enable-cloud/index.tsx | 8 +- .../desktop/dialogs/import-template/index.tsx | 11 +- .../dialogs/import-workspace/index.tsx | 3 +- .../core/src/desktop/dialogs/import/index.tsx | 3 +- .../desktop/dialogs/selectors/collection.tsx | 3 +- .../src/desktop/dialogs/selectors/tag.tsx | 3 +- .../general-setting/appearance/index.tsx | 7 +- .../general-setting/editor/general.tsx | 8 +- .../experimental-features/index.tsx | 13 +- .../dialogs/setting/general-setting/index.tsx | 7 +- .../src/desktop/dialogs/setting/index.tsx | 7 +- .../dialogs/setting/setting-sidebar/index.tsx | 16 +- .../core/src/desktop/dialogs/setting/types.ts | 2 +- .../workspace-setting/billing/index.tsx | 8 +- .../setting/workspace-setting/index.tsx | 2 +- .../delete-leave-workspace/delete/index.tsx | 2 +- .../delete-leave-workspace/index.tsx | 11 +- .../enable-cloud.tsx | 9 +- .../new-workspace-setting-detail/export.tsx | 11 +- .../new-workspace-setting-detail/labels.tsx | 3 +- .../members/index.tsx | 3 +- .../members/member-list.tsx | 2 +- .../new-workspace-setting-detail/profile.tsx | 5 +- .../new-workspace-setting-detail/sharing.tsx | 3 +- .../new-workspace-setting-detail/types.ts | 2 +- .../workspace-setting/properties/index.tsx | 8 +- .../core/src/desktop/pages/index/index.tsx | 2 +- .../desktop/pages/root/custom-theme/index.tsx | 7 +- .../core/src/desktop/pages/root/index.tsx | 7 +- .../desktop/pages/upgrade-to-team/index.tsx | 11 +- .../pages/workspace/all-collection/index.tsx | 3 +- .../workspace/all-page/all-page-filter.tsx | 3 +- .../workspace/all-page/all-page-header.tsx | 3 +- .../pages/workspace/all-page/all-page.tsx | 8 +- .../pages/workspace/attachment/index.tsx | 9 +- .../pages/workspace/collection/index.tsx | 10 +- .../detail-page/detail-page-header.tsx | 3 +- .../detail-page/detail-page-wrapper.tsx | 11 +- .../workspace/detail-page/detail-page.tsx | 10 +- .../workspace/detail-page/tabs/journal.tsx | 13 +- .../src/desktop/pages/workspace/index.tsx | 15 +- .../workspace/layouts/workspace-layout.tsx | 8 +- .../pages/workspace/share/share-page.tsx | 8 +- .../src/desktop/pages/workspace/tag/index.tsx | 9 +- .../desktop/pages/workspace/trash-page.tsx | 8 +- .../src/mobile/components/app-tabs/create.tsx | 3 +- .../mobile/components/app-tabs/tab-item.tsx | 8 +- .../mobile/components/doc-info/doc-info.tsx | 10 +- .../mobile/components/doc-info/doc-scope.tsx | 4 +- .../explorer/nodes/collection/index.tsx | 10 +- .../explorer/nodes/collection/operations.tsx | 9 +- .../components/explorer/nodes/doc/index.tsx | 6 +- .../explorer/nodes/doc/operations.tsx | 12 +- .../explorer/nodes/folder/index.tsx | 9 +- .../components/explorer/nodes/tag/index.tsx | 7 +- .../explorer/nodes/tag/operations.tsx | 14 +- .../explorer/sections/favorites/index.tsx | 7 +- .../workspace-selector/current-card.tsx | 5 +- .../components/workspace-selector/index.tsx | 3 +- .../components/workspace-selector/menu.tsx | 9 +- .../mobile/dialogs/selectors/doc-selector.tsx | 3 +- .../dialogs/setting/experimental/index.tsx | 9 +- .../core/src/mobile/modules/search/index.ts | 3 +- .../pages/workspace/collection/detail.tsx | 9 +- .../detail/journal-conflict-block.tsx | 4 +- .../detail/menu/journal-conflicts.tsx | 13 +- .../detail/menu/journal-today-activity.tsx | 13 +- .../workspace/detail/mobile-detail-page.tsx | 8 +- .../detail/page-header-more-button.tsx | 3 +- .../detail/page-header-share-button.tsx | 4 +- .../core/src/mobile/pages/workspace/index.tsx | 7 +- .../src/mobile/pages/workspace/layout.tsx | 15 +- .../src/mobile/pages/workspace/tag/detail.tsx | 7 +- .../src/mobile/views/all-docs/doc/list.tsx | 3 +- .../src/mobile/views/recent-docs/index.tsx | 3 +- .../src/modules/app-sidebar/impls/storage.ts | 7 +- .../core/src/modules/app-sidebar/index.ts | 3 +- .../app-sidebar/services/app-sidebar.ts | 3 +- .../views/add-page-button/index.tsx | 3 +- .../src/modules/app-sidebar/views/index.tsx | 4 +- .../core/src/modules/at-menu-config/index.ts | 9 +- .../modules/at-menu-config/services/index.ts | 3 +- .../modules/cloud/entities/cloud-doc-meta.ts | 3 +- .../cloud/entities/workspace-invoices.ts | 2 +- .../cloud/entities/workspace-subscription.ts | 3 +- .../frontend/core/src/modules/cloud/index.ts | 14 +- .../core/src/modules/cloud/services/auth.ts | 3 +- .../src/modules/cloud/services/websocket.ts | 3 +- .../core/src/modules/cloud/stores/auth.ts | 2 +- .../src/modules/cloud/stores/server-list.ts | 2 +- .../src/modules/cloud/stores/subscription.ts | 3 +- .../core/src/modules/collection/index.ts | 7 +- .../modules/collection/services/collection.ts | 3 +- .../core}/src/modules/db/entities/db.ts | 8 +- .../core/src/modules/db/entities/table.ts | 39 +++++ .../core}/src/modules/db/index.ts | 3 +- .../core}/src/modules/db/schema/index.ts | 0 .../core}/src/modules/db/schema/schema.ts | 8 +- .../core}/src/modules/db/services/db.ts | 11 +- .../desktop-api/service/desktop-api.ts | 3 +- .../core/src/modules/dialogs/constant.ts | 3 +- .../core/src/modules/dialogs/index.ts | 2 +- .../frontend/core/src/modules/dnd/index.ts | 9 +- .../core/src/modules/dnd/services/index.ts | 3 +- .../src/modules/doc-display-meta/index.ts | 10 +- .../services/doc-display-meta.ts | 7 +- .../core/src/modules/doc-info/index.ts | 8 +- .../services/doc-database-backlinks.ts | 2 +- .../core/src/modules/doc-info/types.ts | 4 +- .../doc-database-backlink-info.tsx | 8 +- .../doc-link/entities/doc-backlinks.ts | 2 +- .../modules/doc-link/entities/doc-links.ts | 2 +- .../core/src/modules/doc-link/index.ts | 10 +- .../core}/src/modules/doc/constants.ts | 0 .../core}/src/modules/doc/entities/doc.ts | 2 +- .../src/modules/doc/entities/property-list.ts | 9 +- .../src/modules/doc/entities/record-list.ts | 3 +- .../core}/src/modules/doc/entities/record.ts | 3 +- .../core}/src/modules/doc/events/index.ts | 3 +- .../core}/src/modules/doc/index.ts | 3 +- .../core}/src/modules/doc/scopes/doc.ts | 2 +- .../core}/src/modules/doc/services/doc.ts | 3 +- .../core}/src/modules/doc/services/docs.ts | 9 +- .../src/modules/doc/stores/doc-properties.ts | 6 +- .../core}/src/modules/doc/stores/docs.ts | 8 +- .../docs-search/entities/docs-indexer.ts | 10 +- .../core/src/modules/docs-search/index.ts | 6 +- .../docs-search/services/docs-search.ts | 10 +- .../modules/docs-search/worker/in-worker.ts | 3 +- .../__test__/editor-setting.spec.ts | 51 ------ .../editor-setting/impls/global-state.ts | 2 +- .../modules/editor-setting/impls/user-db.ts | 2 +- .../core/src/modules/editor-setting/index.ts | 7 +- .../editor-setting/services/editor-setting.ts | 11 +- .../services/spell-check-setting.ts | 2 +- .../src/modules/editor/entities/editor.ts | 3 +- .../frontend/core/src/modules/editor/index.ts | 10 +- .../explorer/entities/explore-section.ts | 2 +- .../core/src/modules/explorer/index.ts | 8 +- .../explorer/views/nodes/collection/index.tsx | 4 +- .../views/nodes/collection/operations.tsx | 9 +- .../explorer/views/nodes/doc/index.tsx | 6 +- .../explorer/views/nodes/doc/operations.tsx | 11 +- .../explorer/views/nodes/folder/index.tsx | 9 +- .../explorer/views/nodes/tag/index.tsx | 7 +- .../explorer/views/nodes/tag/operations.tsx | 11 +- .../views/sections/favorites/index.tsx | 7 +- .../sections/migration-favorites/index.tsx | 3 +- .../core/src/modules/favorite/index.ts | 9 +- .../modules/favorite/services/old/adapter.ts | 4 +- .../src/modules/favorite/stores/favorite.ts | 3 +- .../src/modules/feature-flag/constant.ts | 0 .../modules/feature-flag/entities/flags.ts | 3 +- .../core}/src/modules/feature-flag/index.ts | 3 +- .../feature-flag/services/feature-flag.ts | 2 +- .../core}/src/modules/feature-flag/types.ts | 0 .../global-context/entities/global-context.ts | 5 +- .../core}/src/modules/global-context/index.ts | 3 +- .../global-context/services/global-context.ts | 3 +- .../core/src/modules/i18n/entities/i18n.ts | 3 +- .../frontend/core/src/modules/i18n/index.ts | 3 +- .../core/src/modules/import-template/index.ts | 3 +- .../import-template/services/import.ts | 6 +- packages/frontend/core/src/modules/index.ts | 21 ++- .../core/src/modules/journal/index.ts | 10 +- .../modules/journal/services/journal-doc.ts | 3 +- .../src/modules/journal/services/journal.ts | 3 +- .../core/src/modules/journal/store/journal.ts | 3 +- .../core}/src/modules/lifecycle/index.ts | 3 +- .../modules/lifecycle/service/lifecycle.ts | 2 +- .../core/src/modules/navigation/index.ts | 3 +- .../core/src/modules/open-in-app/index.ts | 8 +- .../src/modules/open-in-app/services/index.ts | 3 +- .../core/src/modules/organize/index.ts | 8 +- .../src/modules/organize/stores/folder.ts | 3 +- .../frontend/core/src/modules/pdf/index.ts | 2 +- .../core/src/modules/peek-view/index.ts | 3 +- .../core/src/modules/peek-view/view/utils.ts | 11 +- .../modules/permissions/entities/members.ts | 2 +- .../permissions/entities/permission.ts | 2 +- .../core/src/modules/permissions/index.ts | 8 +- .../permissions/services/permission.ts | 2 +- .../src/modules/quicksearch/impls/commands.ts | 2 +- .../src/modules/quicksearch/impls/docs.ts | 2 +- .../quicksearch/impls/external-links.ts | 2 +- .../src/modules/quicksearch/impls/links.ts | 3 +- .../core/src/modules/quicksearch/index.ts | 18 +-- .../src/modules/quicksearch/services/cmdk.ts | 3 +- .../quicksearch/services/recent-pages.ts | 8 +- .../core/src/modules/quota/entities/quota.ts | 2 +- .../frontend/core/src/modules/quota/index.ts | 7 +- .../src/modules/quota/views/quota-check.tsx | 8 +- .../share-doc/entities/share-docs-list.ts | 3 +- .../modules/share-doc/entities/share-info.ts | 3 +- .../core/src/modules/share-doc/index.ts | 11 +- .../share-doc/services/share-docs-list.ts | 2 +- .../share-setting/entities/share-setting.ts | 2 +- .../core/src/modules/share-setting/index.ts | 7 +- .../src/modules/storage/impls/electron.ts | 2 +- .../core/src/modules/storage/impls/storage.ts | 7 +- .../core/src/modules/storage/index.ts | 28 +++- .../src/modules/storage/providers/global.ts | 3 +- .../src/modules/storage/services/global.ts | 3 +- .../core/src/modules/tag/entities/tag-list.ts | 2 +- .../core/src/modules/tag/entities/tag.ts | 2 +- .../frontend/core/src/modules/tag/index.ts | 9 +- .../core/src/modules/tag/stores/tag.ts | 3 +- .../core/src/modules/telemetry/index.ts | 3 +- .../modules/telemetry/services/telemetry.ts | 10 +- .../core/src/modules/theme-editor/index.ts | 3 +- .../theme-editor/services/theme-editor.ts | 2 +- .../frontend/core/src/modules/theme/index.ts | 3 +- .../modules/theme/services/edgeless-theme.ts | 5 +- .../core/src/modules/workbench/index.ts | 8 +- .../services/workbench-view-state.ts | 2 +- .../modules/workbench/view/workbench-link.tsx | 7 +- .../modules/workspace-engine/impls/cloud.ts | 18 ++- .../modules/workspace-engine/impls/local.ts | 19 ++- .../src/modules/workspace-engine/index.ts | 8 +- .../src/modules/workspace/entities/engine.ts | 10 +- .../src/modules/workspace/entities/list.ts | 3 +- .../src/modules/workspace/entities/profile.ts | 10 +- .../modules/workspace/entities/workspace.ts | 3 +- .../src/modules/workspace/events/index.ts | 3 +- .../src/modules/workspace/global-schema.ts | 3 +- .../src/modules/workspace/impls/storage.ts | 3 +- .../core}/src/modules/workspace/index.ts | 12 +- .../core}/src/modules/workspace/metadata.ts | 0 .../src/modules/workspace/open-options.ts | 0 .../modules/workspace/providers/flavour.ts | 16 +- .../modules/workspace/providers/storage.ts | 3 +- .../src/modules/workspace/scopes/workspace.ts | 3 +- .../src/modules/workspace/services/destroy.ts | 3 +- .../src/modules/workspace/services/engine.ts | 3 +- .../src/modules/workspace/services/factory.ts | 7 +- .../modules/workspace/services/flavours.ts | 3 +- .../src/modules/workspace/services/list.ts | 3 +- .../src/modules/workspace/services/profile.ts | 4 +- .../src/modules/workspace/services/repo.ts | 3 +- .../modules/workspace/services/transform.ts | 2 +- .../modules/workspace/services/workspace.ts | 3 +- .../modules/workspace/services/workspaces.ts | 3 +- .../modules/workspace/stores/profile-cache.ts | 2 +- .../frontend/core/src/utils/first-app-data.ts | 5 +- 337 files changed, 908 insertions(+), 1367 deletions(-) delete mode 100644 packages/common/infra/src/modules/db/entities/table.ts delete mode 100644 packages/common/infra/src/modules/storage/index.ts delete mode 100644 packages/common/infra/src/modules/workspace/__tests__/workspace.spec.ts delete mode 100644 packages/common/infra/src/modules/workspace/testing/testing-provider.ts rename packages/frontend/{component => core}/src/components/workspace-avatar/index.tsx (93%) rename packages/{common/infra => frontend/core}/src/modules/db/entities/db.ts (87%) create mode 100644 packages/frontend/core/src/modules/db/entities/table.ts rename packages/{common/infra => frontend/core}/src/modules/db/index.ts (92%) rename packages/{common/infra => frontend/core}/src/modules/db/schema/index.ts (100%) rename packages/{common/infra => frontend/core}/src/modules/db/schema/schema.ts (94%) rename packages/{common/infra => frontend/core}/src/modules/db/services/db.ts (95%) rename packages/{common/infra => frontend/core}/src/modules/doc/constants.ts (100%) rename packages/{common/infra => frontend/core}/src/modules/doc/entities/doc.ts (97%) rename packages/{common/infra => frontend/core}/src/modules/doc/entities/property-list.ts (93%) rename packages/{common/infra => frontend/core}/src/modules/doc/entities/record-list.ts (95%) rename packages/{common/infra => frontend/core}/src/modules/doc/entities/record.ts (95%) rename packages/{common/infra => frontend/core}/src/modules/doc/events/index.ts (69%) rename packages/{common/infra => frontend/core}/src/modules/doc/index.ts (96%) rename packages/{common/infra => frontend/core}/src/modules/doc/scopes/doc.ts (84%) rename packages/{common/infra => frontend/core}/src/modules/doc/services/doc.ts (74%) rename packages/{common/infra => frontend/core}/src/modules/doc/services/docs.ts (95%) rename packages/{common/infra => frontend/core}/src/modules/doc/stores/doc-properties.ts (98%) rename packages/{common/infra => frontend/core}/src/modules/doc/stores/docs.ts (96%) delete mode 100644 packages/frontend/core/src/modules/editor-setting/__test__/editor-setting.spec.ts rename packages/{common/infra => frontend/core}/src/modules/feature-flag/constant.ts (100%) rename packages/{common/infra => frontend/core}/src/modules/feature-flag/entities/flags.ts (95%) rename packages/{common/infra => frontend/core}/src/modules/feature-flag/index.ts (89%) rename packages/{common/infra => frontend/core}/src/modules/feature-flag/services/feature-flag.ts (95%) rename packages/{common/infra => frontend/core}/src/modules/feature-flag/types.ts (100%) rename packages/{common/infra => frontend/core}/src/modules/global-context/entities/global-context.ts (89%) rename packages/{common/infra => frontend/core}/src/modules/global-context/index.ts (85%) rename packages/{common/infra => frontend/core}/src/modules/global-context/services/global-context.ts (78%) rename packages/{common/infra => frontend/core}/src/modules/lifecycle/index.ts (82%) rename packages/{common/infra => frontend/core}/src/modules/lifecycle/service/lifecycle.ts (91%) rename packages/{common/infra => frontend/core}/src/modules/storage/providers/global.ts (89%) rename packages/{common/infra => frontend/core}/src/modules/storage/services/global.ts (91%) rename packages/{common/infra => frontend/core}/src/modules/workspace/entities/engine.ts (92%) rename packages/{common/infra => frontend/core}/src/modules/workspace/entities/list.ts (93%) rename packages/{common/infra => frontend/core}/src/modules/workspace/entities/profile.ts (97%) rename packages/{common/infra => frontend/core}/src/modules/workspace/entities/workspace.ts (96%) rename packages/{common/infra => frontend/core}/src/modules/workspace/events/index.ts (85%) rename packages/{common/infra => frontend/core}/src/modules/workspace/global-schema.ts (78%) rename packages/{common/infra => frontend/core}/src/modules/workspace/impls/storage.ts (96%) rename packages/{common/infra => frontend/core}/src/modules/workspace/index.ts (91%) rename packages/{common/infra => frontend/core}/src/modules/workspace/metadata.ts (100%) rename packages/{common/infra => frontend/core}/src/modules/workspace/open-options.ts (100%) rename packages/{common/infra => frontend/core}/src/modules/workspace/providers/flavour.ts (88%) rename packages/{common/infra => frontend/core}/src/modules/workspace/providers/storage.ts (75%) rename packages/{common/infra => frontend/core}/src/modules/workspace/scopes/workspace.ts (87%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/destroy.ts (92%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/engine.ts (92%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/factory.ts (89%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/flavours.ts (82%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/list.ts (76%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/profile.ts (85%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/repo.ts (97%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/transform.ts (97%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/workspace.ts (88%) rename packages/{common/infra => frontend/core}/src/modules/workspace/services/workspaces.ts (97%) rename packages/{common/infra => frontend/core}/src/modules/workspace/stores/profile-cache.ts (95%) diff --git a/packages/common/infra/src/index.ts b/packages/common/infra/src/index.ts index 07b6c95cb75e1..0b783016e0d1c 100644 --- a/packages/common/infra/src/index.ts +++ b/packages/common/infra/src/index.ts @@ -4,44 +4,7 @@ export * from './blocksuite'; export * from './framework'; export * from './initialization'; export * from './livedata'; -export * from './modules/db'; -export * from './modules/doc'; -export * from './modules/feature-flag'; -export * from './modules/global-context'; -export * from './modules/lifecycle'; -export * from './modules/storage'; -export * from './modules/workspace'; export * from './orm'; export * from './storage'; export * from './sync'; export * from './utils'; - -import type { Framework } from './framework'; -import { configureWorkspaceDBModule } from './modules/db'; -import { configureDocModule } from './modules/doc'; -import { configureFeatureFlagModule } from './modules/feature-flag'; -import { configureGlobalContextModule } from './modules/global-context'; -import { configureLifecycleModule } from './modules/lifecycle'; -import { - configureGlobalStorageModule, - configureTestingGlobalStorage, -} from './modules/storage'; -import { - configureTestingWorkspaceProvider, - configureWorkspaceModule, -} from './modules/workspace'; - -export function configureInfraModules(framework: Framework) { - configureWorkspaceModule(framework); - configureDocModule(framework); - configureWorkspaceDBModule(framework); - configureGlobalStorageModule(framework); - configureGlobalContextModule(framework); - configureLifecycleModule(framework); - configureFeatureFlagModule(framework); -} - -export function configureTestingInfraModules(framework: Framework) { - configureTestingGlobalStorage(framework); - configureTestingWorkspaceProvider(framework); -} diff --git a/packages/common/infra/src/modules/db/entities/table.ts b/packages/common/infra/src/modules/db/entities/table.ts deleted file mode 100644 index 348493d99cb5f..0000000000000 --- a/packages/common/infra/src/modules/db/entities/table.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Entity } from '../../../framework'; -import type { Table as OrmTable, TableSchemaBuilder } from '../../../orm'; -import type { WorkspaceService } from '../../workspace'; - -export class WorkspaceDBTable< - Schema extends TableSchemaBuilder, -> extends Entity<{ - table: OrmTable; - storageDocId: string; -}> { - readonly table = this.props.table; - - constructor(private readonly workspaceService: WorkspaceService) { - super(); - } - - isSyncing$ = this.workspaceService.workspace.engine.doc - .docState$(this.props.storageDocId) - .map(docState => docState.syncing); - - isLoading$ = this.workspaceService.workspace.engine.doc - .docState$(this.props.storageDocId) - .map(docState => docState.loading); - - create = this.table.create.bind(this.table); - update = this.table.update.bind(this.table); - get = this.table.get.bind(this.table); - // eslint-disable-next-line rxjs/finnish - get$ = this.table.get$.bind(this.table); - find = this.table.find.bind(this.table); - // eslint-disable-next-line rxjs/finnish - find$ = this.table.find$.bind(this.table); - keys = this.table.keys.bind(this.table); - delete = this.table.delete.bind(this.table); -} diff --git a/packages/common/infra/src/modules/storage/index.ts b/packages/common/infra/src/modules/storage/index.ts deleted file mode 100644 index 2032f44a663b4..0000000000000 --- a/packages/common/infra/src/modules/storage/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -export { - GlobalCache, - GlobalSessionState, - GlobalState, -} from './providers/global'; -export { - GlobalCacheService, - GlobalSessionStateService, - GlobalStateService, -} from './services/global'; - -import type { Framework } from '../../framework'; -import { MemoryMemento } from '../../storage'; -import { - GlobalCache, - GlobalSessionState, - GlobalState, -} from './providers/global'; -import { - GlobalCacheService, - GlobalSessionStateService, - GlobalStateService, -} from './services/global'; - -export const configureGlobalStorageModule = (framework: Framework) => { - framework.service(GlobalStateService, [GlobalState]); - framework.service(GlobalCacheService, [GlobalCache]); - framework.service(GlobalSessionStateService, [GlobalSessionState]); -}; - -export const configureTestingGlobalStorage = (framework: Framework) => { - framework.impl(GlobalCache, MemoryMemento); - framework.impl(GlobalState, MemoryMemento); - framework.impl(GlobalSessionState, MemoryMemento); -}; diff --git a/packages/common/infra/src/modules/workspace/__tests__/workspace.spec.ts b/packages/common/infra/src/modules/workspace/__tests__/workspace.spec.ts deleted file mode 100644 index d0f9699211e46..0000000000000 --- a/packages/common/infra/src/modules/workspace/__tests__/workspace.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { describe, expect, test } from 'vitest'; - -import { Framework } from '../../../framework'; -import { configureTestingGlobalStorage } from '../../storage'; -import { - configureTestingWorkspaceProvider, - configureWorkspaceModule, - Workspace, - WorkspacesService, -} from '..'; - -describe('Workspace System', () => { - test('create workspace', async () => { - const framework = new Framework(); - configureTestingGlobalStorage(framework); - configureWorkspaceModule(framework); - configureTestingWorkspaceProvider(framework); - - const provider = framework.provider(); - const workspaceService = provider.get(WorkspacesService); - expect(workspaceService.list.workspaces$.value.length).toBe(0); - - const workspace = workspaceService.open({ - metadata: await workspaceService.create('local'), - }); - - expect(workspace.workspace).toBeInstanceOf(Workspace); - - expect(workspaceService.list.workspaces$.value.length).toBe(1); - }); -}); diff --git a/packages/common/infra/src/modules/workspace/testing/testing-provider.ts b/packages/common/infra/src/modules/workspace/testing/testing-provider.ts deleted file mode 100644 index d71b785325114..0000000000000 --- a/packages/common/infra/src/modules/workspace/testing/testing-provider.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { DocCollection, nanoid } from '@blocksuite/affine/store'; -import { map } from 'rxjs'; -import { applyUpdate, encodeStateAsUpdate } from 'yjs'; - -import { Service } from '../../../framework'; -import { LiveData } from '../../../livedata'; -import { wrapMemento } from '../../../storage'; -import { - type BlobStorage, - type DocStorage, - MemoryDocStorage, -} from '../../../sync'; -import { MemoryBlobStorage } from '../../../sync/blob/blob'; -import type { GlobalState } from '../../storage'; -import type { WorkspaceProfileInfo } from '../entities/profile'; -import { getAFFiNEWorkspaceSchema } from '../global-schema'; -import type { WorkspaceMetadata } from '../metadata'; -import type { - WorkspaceEngineProvider, - WorkspaceFlavourProvider, - WorkspaceFlavoursProvider, -} from '../providers/flavour'; - -class TestingWorkspaceLocalProvider implements WorkspaceFlavourProvider { - flavour = 'local'; - - store = wrapMemento(this.globalStore, 'testing/'); - workspaceListStore = wrapMemento(this.store, 'workspaces/'); - docStorage = new MemoryDocStorage(wrapMemento(this.store, 'docs/')); - - constructor(private readonly globalStore: GlobalState) {} - - async deleteWorkspace(id: string): Promise { - const list = this.workspaceListStore.get('list') ?? []; - const newList = list.filter(meta => meta.id !== id); - this.workspaceListStore.set('list', newList); - } - async createWorkspace( - initial: ( - docCollection: DocCollection, - blobStorage: BlobStorage, - docStorage: DocStorage - ) => Promise - ): Promise { - const id = nanoid(); - const meta = { id, flavour: 'local' }; - - const blobStorage = new MemoryBlobStorage( - wrapMemento(this.store, id + '/blobs/') - ); - - const docCollection = new DocCollection({ - id: id, - idGenerator: () => nanoid(), - schema: getAFFiNEWorkspaceSchema(), - blobSources: { - main: blobStorage, - }, - }); - - // apply initial state - await initial(docCollection, blobStorage, this.docStorage); - - // save workspace to storage - await this.docStorage.doc.set(id, encodeStateAsUpdate(docCollection.doc)); - for (const subdocs of docCollection.doc.getSubdocs()) { - await this.docStorage.doc.set(subdocs.guid, encodeStateAsUpdate(subdocs)); - } - - const list = this.workspaceListStore.get('list') ?? []; - this.workspaceListStore.set('list', [...list, meta]); - - docCollection.dispose(); - - return { id, flavour: 'local' }; - } - workspaces$ = LiveData.from( - this.workspaceListStore - .watch('list') - .pipe(map(m => m ?? [])), - [] - ); - async getWorkspaceProfile( - id: string - ): Promise { - const data = await this.docStorage.doc.get(id); - - if (!data) { - return; - } - - const bs = new DocCollection({ - id, - schema: getAFFiNEWorkspaceSchema(), - }); - - applyUpdate(bs.doc, data); - - bs.dispose(); - - return { - name: bs.meta.name, - avatar: bs.meta.avatar, - isOwner: true, - }; - } - getWorkspaceBlob(id: string, blob: string): Promise { - return new MemoryBlobStorage(wrapMemento(this.store, id + '/blobs/')).get( - blob - ); - } - getEngineProvider(workspaceId: string): WorkspaceEngineProvider { - return { - getDocStorage: () => { - return this.docStorage; - }, - getAwarenessConnections() { - return []; - }, - getDocServer() { - return null; - }, - getLocalBlobStorage: () => { - return new MemoryBlobStorage( - wrapMemento(this.store, workspaceId + '/blobs/') - ); - }, - getRemoteBlobStorages() { - return []; - }, - }; - } -} - -export class TestingWorkspaceFlavoursProvider - extends Service - implements WorkspaceFlavoursProvider -{ - constructor(private readonly globalStore: GlobalState) { - super(); - } - workspaceFlavours$ = new LiveData([ - new TestingWorkspaceLocalProvider(this.globalStore), - ]); -} diff --git a/packages/frontend/apps/android/src/app.tsx b/packages/frontend/apps/android/src/app.tsx index 5a19af732a6e3..03f7012020b41 100644 --- a/packages/frontend/apps/android/src/app.tsx +++ b/packages/frontend/apps/android/src/app.tsx @@ -4,6 +4,7 @@ import { configureMobileModules } from '@affine/core/mobile/modules'; import { router } from '@affine/core/mobile/router'; import { configureCommonModules } from '@affine/core/modules'; import { I18nProvider } from '@affine/core/modules/i18n'; +import { LifecycleService } from '@affine/core/modules/lifecycle'; import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage'; import { configureIndexedDBUserspaceStorageProvider } from '@affine/core/modules/userspace'; import { configureBrowserWorkbenchModule } from '@affine/core/modules/workbench'; @@ -11,12 +12,7 @@ import { configureBrowserWorkspaceFlavours, configureIndexedDBWorkspaceEngineStorageProvider, } from '@affine/core/modules/workspace-engine'; -import { - Framework, - FrameworkRoot, - getCurrentStore, - LifecycleService, -} from '@toeverything/infra'; +import { Framework, FrameworkRoot, getCurrentStore } from '@toeverything/infra'; import { Suspense } from 'react'; import { RouterProvider } from 'react-router-dom'; diff --git a/packages/frontend/apps/electron/renderer/app.tsx b/packages/frontend/apps/electron/renderer/app.tsx index 75a5d3d061b9d..be4fc2ba5e994 100644 --- a/packages/frontend/apps/electron/renderer/app.tsx +++ b/packages/frontend/apps/electron/renderer/app.tsx @@ -10,12 +10,15 @@ import { DesktopApiService, } from '@affine/core/modules/desktop-api'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { configureSpellCheckSettingModule, EditorSettingService, } from '@affine/core/modules/editor-setting'; import { configureFindInPageModule } from '@affine/core/modules/find-in-page'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { I18nProvider } from '@affine/core/modules/i18n'; +import { LifecycleService } from '@affine/core/modules/lifecycle'; import { configureElectronStateStorageImpls } from '@affine/core/modules/storage'; import { ClientSchemeProvider, @@ -26,6 +29,7 @@ import { configureDesktopWorkbenchModule, WorkbenchService, } from '@affine/core/modules/workbench'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { configureBrowserWorkspaceFlavours, configureSqliteWorkspaceEngineStorageProvider, @@ -33,15 +37,7 @@ import { import createEmotionCache from '@affine/core/utils/create-emotion-cache'; import { apis, events } from '@affine/electron-api'; import { CacheProvider } from '@emotion/react'; -import { - DocsService, - Framework, - FrameworkRoot, - getCurrentStore, - GlobalContextService, - LifecycleService, - WorkspacesService, -} from '@toeverything/infra'; +import { Framework, FrameworkRoot, getCurrentStore } from '@toeverything/infra'; import { Suspense } from 'react'; import { RouterProvider } from 'react-router-dom'; diff --git a/packages/frontend/apps/electron/renderer/shell/app.tsx b/packages/frontend/apps/electron/renderer/shell/app.tsx index 6c0767a0d770f..0a4b964fc4771 100644 --- a/packages/frontend/apps/electron/renderer/shell/app.tsx +++ b/packages/frontend/apps/electron/renderer/shell/app.tsx @@ -9,13 +9,12 @@ import { } from '@affine/core/modules/app-tabs-header'; import { configureDesktopApiModule } from '@affine/core/modules/desktop-api'; import { configureI18nModule, I18nProvider } from '@affine/core/modules/i18n'; -import { configureElectronStateStorageImpls } from '@affine/core/modules/storage'; -import { configureAppThemeModule } from '@affine/core/modules/theme'; import { + configureElectronStateStorageImpls, configureGlobalStorageModule, - Framework, - FrameworkRoot, -} from '@toeverything/infra'; +} from '@affine/core/modules/storage'; +import { configureAppThemeModule } from '@affine/core/modules/theme'; +import { Framework, FrameworkRoot } from '@toeverything/infra'; import * as styles from './app.css'; diff --git a/packages/frontend/apps/ios/src/app.tsx b/packages/frontend/apps/ios/src/app.tsx index 620d1af131c51..887fe9b5c7c45 100644 --- a/packages/frontend/apps/ios/src/app.tsx +++ b/packages/frontend/apps/ios/src/app.tsx @@ -13,7 +13,9 @@ import { ValidatorProvider, WebSocketAuthProvider, } from '@affine/core/modules/cloud'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { I18nProvider } from '@affine/core/modules/i18n'; +import { LifecycleService } from '@affine/core/modules/lifecycle'; import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage'; import { PopupWindowProvider } from '@affine/core/modules/url'; import { ClientSchemeProvider } from '@affine/core/modules/url/providers/client-schema'; @@ -28,13 +30,7 @@ import { App as CapacitorApp } from '@capacitor/app'; import { Browser } from '@capacitor/browser'; import { Haptics } from '@capacitor/haptics'; import { Keyboard, KeyboardStyle } from '@capacitor/keyboard'; -import { - Framework, - FrameworkRoot, - getCurrentStore, - GlobalContextService, - LifecycleService, -} from '@toeverything/infra'; +import { Framework, FrameworkRoot, getCurrentStore } from '@toeverything/infra'; import { useTheme } from 'next-themes'; import { Suspense, useEffect } from 'react'; import { RouterProvider } from 'react-router-dom'; diff --git a/packages/frontend/apps/mobile/src/app.tsx b/packages/frontend/apps/mobile/src/app.tsx index e05bdf78b93bb..e099a50f596b7 100644 --- a/packages/frontend/apps/mobile/src/app.tsx +++ b/packages/frontend/apps/mobile/src/app.tsx @@ -5,6 +5,7 @@ import { HapticProvider } from '@affine/core/mobile/modules/haptics'; import { router } from '@affine/core/mobile/router'; import { configureCommonModules } from '@affine/core/modules'; import { I18nProvider } from '@affine/core/modules/i18n'; +import { LifecycleService } from '@affine/core/modules/lifecycle'; import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage'; import { PopupWindowProvider } from '@affine/core/modules/url'; import { configureIndexedDBUserspaceStorageProvider } from '@affine/core/modules/userspace'; @@ -13,12 +14,7 @@ import { configureBrowserWorkspaceFlavours, configureIndexedDBWorkspaceEngineStorageProvider, } from '@affine/core/modules/workspace-engine'; -import { - Framework, - FrameworkRoot, - getCurrentStore, - LifecycleService, -} from '@toeverything/infra'; +import { Framework, FrameworkRoot, getCurrentStore } from '@toeverything/infra'; import { Suspense } from 'react'; import { RouterProvider } from 'react-router-dom'; diff --git a/packages/frontend/apps/web/src/app.tsx b/packages/frontend/apps/web/src/app.tsx index 7909b8ac89889..95c16d191e5d3 100644 --- a/packages/frontend/apps/web/src/app.tsx +++ b/packages/frontend/apps/web/src/app.tsx @@ -3,6 +3,7 @@ import { AppContainer } from '@affine/core/desktop/components/app-container'; import { router } from '@affine/core/desktop/router'; import { configureCommonModules } from '@affine/core/modules'; import { I18nProvider } from '@affine/core/modules/i18n'; +import { LifecycleService } from '@affine/core/modules/lifecycle'; import { OpenInAppGuard } from '@affine/core/modules/open-in-app'; import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage'; import { PopupWindowProvider } from '@affine/core/modules/url'; @@ -14,12 +15,7 @@ import { } from '@affine/core/modules/workspace-engine'; import createEmotionCache from '@affine/core/utils/create-emotion-cache'; import { CacheProvider } from '@emotion/react'; -import { - Framework, - FrameworkRoot, - getCurrentStore, - LifecycleService, -} from '@toeverything/infra'; +import { Framework, FrameworkRoot, getCurrentStore } from '@toeverything/infra'; import { Suspense } from 'react'; import { RouterProvider } from 'react-router-dom'; diff --git a/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx b/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx index 93f2461e54b81..4ef6119caf1fd 100644 --- a/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx +++ b/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx @@ -1,8 +1,5 @@ -import { - GlobalContextService, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useEffect } from 'react'; import { useLocation, useParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/components/affine/ai-onboarding/index.tsx b/packages/frontend/core/src/components/affine/ai-onboarding/index.tsx index 5c94350c877fe..4ef7b91d20f6e 100644 --- a/packages/frontend/core/src/components/affine/ai-onboarding/index.tsx +++ b/packages/frontend/core/src/components/affine/ai-onboarding/index.tsx @@ -1,4 +1,5 @@ -import { FeatureFlagService, useService } from '@toeverything/infra'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { useService } from '@toeverything/infra'; import { Suspense, useCallback, useEffect, useState } from 'react'; import { AIOnboardingEdgeless } from './edgeless.dialog'; diff --git a/packages/frontend/core/src/components/affine/awareness/index.tsx b/packages/frontend/core/src/components/affine/awareness/index.tsx index 63bce634b436e..b1531e24894f4 100644 --- a/packages/frontend/core/src/components/affine/awareness/index.tsx +++ b/packages/frontend/core/src/components/affine/awareness/index.tsx @@ -1,4 +1,5 @@ -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect } from 'react'; import { AuthService } from '../../../modules/cloud'; diff --git a/packages/frontend/core/src/components/affine/empty/collections.tsx b/packages/frontend/core/src/components/affine/empty/collections.tsx index 8ae47d7a93e23..efd5c8927f897 100644 --- a/packages/frontend/core/src/components/affine/empty/collections.tsx +++ b/packages/frontend/core/src/components/affine/empty/collections.tsx @@ -1,9 +1,10 @@ import { usePromptModal } from '@affine/component'; import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper'; import { CollectionService } from '@affine/core/modules/collection'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { ViewLayersIcon } from '@blocksuite/icons/rc'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { nanoid } from 'nanoid'; import { useCallback } from 'react'; diff --git a/packages/frontend/core/src/components/affine/empty/docs.tsx b/packages/frontend/core/src/components/affine/empty/docs.tsx index 878020993f60f..fe09a9f210b8c 100644 --- a/packages/frontend/core/src/components/affine/empty/docs.tsx +++ b/packages/frontend/core/src/components/affine/empty/docs.tsx @@ -1,8 +1,9 @@ import { TagService } from '@affine/core/modules/tag'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { isNewTabTrigger } from '@affine/core/utils'; import { useI18n } from '@affine/i18n'; import { AllDocsIcon } from '@blocksuite/icons/rc'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { type MouseEvent, useCallback } from 'react'; import { usePageHelper } from '../../blocksuite/block-suite-page-list/utils'; diff --git a/packages/frontend/core/src/components/affine/page-history-modal/data.ts b/packages/frontend/core/src/components/affine/page-history-modal/data.ts index 588b1d591acbc..e46c04c4e7519 100644 --- a/packages/frontend/core/src/components/affine/page-history-modal/data.ts +++ b/packages/frontend/core/src/components/affine/page-history-modal/data.ts @@ -1,13 +1,14 @@ import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-page-meta'; import { useDocCollectionPage } from '@affine/core/components/hooks/use-block-suite-workspace-page'; import { FetchService, GraphQLService } from '@affine/core/modules/cloud'; +import { getAFFiNEWorkspaceSchema } from '@affine/core/modules/workspace'; import { DebugLogger } from '@affine/debug'; import type { ListHistoryQuery } from '@affine/graphql'; import { listHistoryQuery, recoverDocMutation } from '@affine/graphql'; import { i18nTime } from '@affine/i18n'; import { assertEquals } from '@blocksuite/affine/global/utils'; import { DocCollection } from '@blocksuite/affine/store'; -import { getAFFiNEWorkspaceSchema, useService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useEffect, useMemo } from 'react'; import useSWRImmutable from 'swr/immutable'; import { @@ -227,6 +228,7 @@ export function revertUpdate( snapshotStateVector ); const undoManager = new UndoManager( + // oxlint-disable array-callback-return [...snapshotDoc.share.keys()].map(key => { const type = getMetadata(key); if (type === 'Text') { @@ -236,7 +238,7 @@ export function revertUpdate( } else if (type === 'Array') { return snapshotDoc.getArray(key); } - // eslint-disable-next-line array-callback-return + throw new Error('Unknown type'); }) ); diff --git a/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx b/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx index 902a6b8c89816..e66774cebe888 100644 --- a/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx +++ b/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx @@ -7,6 +7,7 @@ import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { EditorService } from '@affine/core/modules/editor'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; import { WorkspaceQuotaService } from '@affine/core/modules/quota'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { i18nTime, Trans, useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import type { DocMode } from '@blocksuite/affine/blocks'; @@ -17,7 +18,7 @@ import type { import { CloseIcon, ToggleCollapseIcon } from '@blocksuite/icons/rc'; import * as Collapsible from '@radix-ui/react-collapsible'; import type { DialogContentProps } from '@radix-ui/react-dialog'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { atom, useAtom } from 'jotai'; import type { PropsWithChildren } from 'react'; import { diff --git a/packages/frontend/core/src/components/affine/quota-reached-modal/cloud-quota-modal.tsx b/packages/frontend/core/src/components/affine/quota-reached-modal/cloud-quota-modal.tsx index de300bb9a4910..0c375e0155a61 100644 --- a/packages/frontend/core/src/components/affine/quota-reached-modal/cloud-quota-modal.tsx +++ b/packages/frontend/core/src/components/affine/quota-reached-modal/cloud-quota-modal.tsx @@ -4,9 +4,10 @@ import { UserQuotaService } from '@affine/core/modules/cloud'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; import { WorkspaceQuotaService } from '@affine/core/modules/quota'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { type I18nString, useI18n } from '@affine/i18n'; import { track } from '@affine/track'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useAtom } from 'jotai'; import { useCallback, useEffect, useMemo } from 'react'; diff --git a/packages/frontend/core/src/components/affine/quota-reached-modal/local-quota-modal.tsx b/packages/frontend/core/src/components/affine/quota-reached-modal/local-quota-modal.tsx index 7f547cdc5bfa5..9703c672fc124 100644 --- a/packages/frontend/core/src/components/affine/quota-reached-modal/local-quota-modal.tsx +++ b/packages/frontend/core/src/components/affine/quota-reached-modal/local-quota-modal.tsx @@ -1,7 +1,8 @@ import { ConfirmModal } from '@affine/component/ui/modal'; import { openQuotaModalAtom } from '@affine/core/components/atoms'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useAtom } from 'jotai'; import { useCallback, useEffect } from 'react'; diff --git a/packages/frontend/core/src/components/affine/reference-link/index.tsx b/packages/frontend/core/src/components/affine/reference-link/index.tsx index 76f1ca891df8a..4b6a7036fd488 100644 --- a/packages/frontend/core/src/components/affine/reference-link/index.tsx +++ b/packages/frontend/core/src/components/affine/reference-link/index.tsx @@ -1,3 +1,4 @@ +import { DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { JournalService } from '@affine/core/modules/journal'; import { PeekViewService } from '@affine/core/modules/peek-view/services/peek-view'; @@ -6,12 +7,7 @@ import { WorkbenchLink } from '@affine/core/modules/workbench'; import { track } from '@affine/track'; import type { DocMode } from '@blocksuite/affine/blocks'; import type { DocCollection } from '@blocksuite/affine/store'; -import { - DocsService, - LiveData, - useLiveData, - useService, -} from '@toeverything/infra'; +import { LiveData, useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import { nanoid } from 'nanoid'; import { diff --git a/packages/frontend/core/src/components/affine/share-page-modal/index.tsx b/packages/frontend/core/src/components/affine/share-page-modal/index.tsx index 5e794ddb5ab75..b4d5947245424 100644 --- a/packages/frontend/core/src/components/affine/share-page-modal/index.tsx +++ b/packages/frontend/core/src/components/affine/share-page-modal/index.tsx @@ -1,7 +1,7 @@ import { useEnableCloud } from '@affine/core/components/hooks/affine/use-enable-cloud'; +import type { Workspace } from '@affine/core/modules/workspace'; import { track } from '@affine/track'; import type { Doc } from '@blocksuite/affine/store'; -import { type Workspace } from '@toeverything/infra'; import { useCallback } from 'react'; import { ShareMenu } from './share-menu'; diff --git a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx index 71e14603b3e7c..a9e0076f49b95 100644 --- a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx +++ b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx @@ -2,14 +2,11 @@ import { Tabs, Tooltip } from '@affine/component'; import { Button } from '@affine/component/ui/button'; import { Menu } from '@affine/component/ui/menu'; import { ShareInfoService } from '@affine/core/modules/share-doc'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import type { Doc } from '@blocksuite/affine/store'; import { LockIcon, PublishIcon } from '@blocksuite/icons/rc'; -import { - useLiveData, - useService, - type WorkspaceMetadata, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { forwardRef, type PropsWithChildren, type Ref, useEffect } from 'react'; import * as styles from './index.css'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx index 21df2041567df..9225fa6fac65f 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx @@ -4,27 +4,29 @@ import { useLitPortalFactory, } from '@affine/component'; import { TextRenderer } from '@affine/core/blocksuite/presets'; +import { DocService } from '@affine/core/modules/doc'; import { type Backlink, DocLinksService, type Link, } from '@affine/core/modules/doc-link'; import { toURLSearchParams } from '@affine/core/modules/navigation'; +import { GlobalSessionStateService } from '@affine/core/modules/storage'; import { WorkbenchLink } from '@affine/core/modules/workbench'; +import { + getAFFiNEWorkspaceSchema, + WorkspaceService, +} from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; import type { JobMiddleware } from '@blocksuite/affine/store'; import { ToggleExpandIcon } from '@blocksuite/icons/rc'; import * as Collapsible from '@radix-ui/react-collapsible'; import { - DocService, - getAFFiNEWorkspaceSchema, - GlobalSessionStateService, LiveData, useFramework, useLiveData, useServices, - WorkspaceService, } from '@toeverything/infra'; import React, { Fragment, diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx index f566687231769..d6ab8e67889b4 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx @@ -3,6 +3,8 @@ import { useConfirmModal, useLitPortalFactory, } from '@affine/component'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import { DocService, DocsService } from '@affine/core/modules/doc'; import type { DatabaseRow, DatabaseValueCell, @@ -12,6 +14,7 @@ import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { JournalService } from '@affine/core/modules/journal'; import { toURLSearchParams } from '@affine/core/modules/navigation'; import { PeekViewService } from '@affine/core/modules/peek-view/services/peek-view'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import track from '@affine/track'; import type { DocMode } from '@blocksuite/affine/blocks'; import { @@ -21,14 +24,10 @@ import { } from '@blocksuite/affine/presets'; import type { Doc } from '@blocksuite/affine/store'; import { - type DocCustomPropertyInfo, - DocService, - DocsService, useFramework, useLiveData, useService, useServices, - WorkspaceService, } from '@toeverything/infra'; import React, { forwardRef, diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts index d4e1bb7f002df..c2cd8cb89110e 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts @@ -2,8 +2,10 @@ import { AIEdgelessRootBlockSpec, AIPageRootBlockSpec, } from '@affine/core/blocksuite/presets/ai'; +import { DocService, DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { AppThemeService } from '@affine/core/modules/theme'; import { mixpanel } from '@affine/track'; import { @@ -39,12 +41,7 @@ import { } from '@blocksuite/affine-shared/utils'; import type { Container } from '@blocksuite/global/di'; import { LinkedPageIcon, PageIcon } from '@blocksuite/icons/lit'; -import { - DocService, - DocsService, - FeatureFlagService, - type FrameworkProvider, -} from '@toeverything/infra'; +import { type FrameworkProvider } from '@toeverything/infra'; import type { TemplateResult } from 'lit'; import type { Observable } from 'rxjs'; import { combineLatest, map } from 'rxjs'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx index 2d69923dc366c..374f633b3bb4b 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx @@ -8,6 +8,7 @@ import { type useConfirmModal, } from '@affine/component'; import { WorkspaceServerService } from '@affine/core/modules/cloud'; +import { type DocService, DocsService } from '@affine/core/modules/doc'; import type { EditorService } from '@affine/core/modules/editor'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { resolveLinkToDoc } from '@affine/core/modules/navigation'; @@ -22,6 +23,7 @@ import { import { ExternalLinksQuickSearchSession } from '@affine/core/modules/quicksearch/impls/external-links'; import { JournalsQuickSearchSession } from '@affine/core/modules/quicksearch/impls/journals'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { isNewTabTrigger } from '@affine/core/utils'; import { DebugLogger } from '@affine/debug'; import { track } from '@affine/track'; @@ -62,10 +64,7 @@ import type { ReferenceParams } from '@blocksuite/affine-model'; import { AIChatBlockSchema, type DocProps, - type DocService, - DocsService, type FrameworkProvider, - WorkspaceService, } from '@toeverything/infra'; import { type TemplateResult } from 'lit'; import { customElement } from 'lit/decorators.js'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/edgeless.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/edgeless.ts index a1c13dda0af36..3133d5b1863f2 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/edgeless.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/edgeless.ts @@ -1,3 +1,4 @@ +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { builtInTemplates as builtInEdgelessTemplates } from '@affine/templates/edgeless'; import { builtInTemplates as builtInStickersTemplates } from '@affine/templates/stickers'; import type { ExtensionType } from '@blocksuite/affine/block-std'; @@ -10,10 +11,7 @@ import { EdgelessTextBlockSpec, FrameBlockSpec, } from '@blocksuite/affine/blocks'; -import { - FeatureFlagService, - type FrameworkProvider, -} from '@toeverything/infra'; +import { type FrameworkProvider } from '@toeverything/infra'; import { AIBlockSpecs, DefaultBlockSpecs } from './common'; import { createEdgelessRootBlockSpec } from './custom/root-block'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/page.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/page.ts index 102daeb76b04e..aee6a9f6c1ab7 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/page.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/page.ts @@ -1,13 +1,11 @@ +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import type { ExtensionType } from '@blocksuite/affine/block-std'; import { NoteBlockSpec, PageSurfaceBlockSpec, PageSurfaceRefBlockSpec, } from '@blocksuite/affine/blocks'; -import { - FeatureFlagService, - type FrameworkProvider, -} from '@toeverything/infra'; +import { type FrameworkProvider } from '@toeverything/infra'; import { AIBlockSpecs, DefaultBlockSpecs } from './common'; import { createPageRootBlockSpec } from './custom/root-block'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/history-tips-modal/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/history-tips-modal/index.tsx index 3cdc1ad3f85f6..32960dfd2d3c8 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/history-tips-modal/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/history-tips-modal/index.tsx @@ -1,7 +1,8 @@ import { OverlayModal } from '@affine/component'; import { useEnableCloud } from '@affine/core/components/hooks/affine/use-enable-cloud'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback } from 'react'; import TopSvg from './top-svg'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx index 08499929993a4..7df4bef2b0f14 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx @@ -19,6 +19,7 @@ import { EditorService } from '@affine/core/modules/editor'; import { OpenInAppService } from '@affine/core/modules/open-in-app/services'; import { WorkbenchService } from '@affine/core/modules/workbench'; import { ViewService } from '@affine/core/modules/workbench/services/view'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import type { Doc } from '@blocksuite/affine/store'; @@ -42,7 +43,6 @@ import { useLiveData, useService, useServiceOptional, - WorkspaceService, } from '@toeverything/infra'; import { useCallback, useState } from 'react'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx index b9921bc514e4c..f9de0447ab761 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx @@ -1,13 +1,10 @@ import type { InlineEditProps } from '@affine/component'; import { InlineEdit } from '@affine/component'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; +import { DocsService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { track } from '@affine/track'; -import { - DocsService, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import type { HTMLAttributes } from 'react'; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx index 45ad23dba9ac4..3ce6b6a3583aa 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx @@ -1,10 +1,11 @@ import { toast } from '@affine/component'; 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, DocsService, useServices } from '@toeverything/infra'; +import { type DocProps, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; export const usePageHelper = (docCollection: DocCollection) => { diff --git a/packages/frontend/core/src/components/doc-properties/icons/doc-property-icon.tsx b/packages/frontend/core/src/components/doc-properties/icons/doc-property-icon.tsx index 52625becd28d5..94ecb0e5a0ddc 100644 --- a/packages/frontend/core/src/components/doc-properties/icons/doc-property-icon.tsx +++ b/packages/frontend/core/src/components/doc-properties/icons/doc-property-icon.tsx @@ -1,5 +1,5 @@ +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; import * as icons from '@blocksuite/icons/rc'; -import type { DocCustomPropertyInfo } from '@toeverything/infra'; import type { SVGProps } from 'react'; import { diff --git a/packages/frontend/core/src/components/doc-properties/icons/icons-selector.tsx b/packages/frontend/core/src/components/doc-properties/icons/icons-selector.tsx index d8c2416b728e5..ab37ad1e8ccb3 100644 --- a/packages/frontend/core/src/components/doc-properties/icons/icons-selector.tsx +++ b/packages/frontend/core/src/components/doc-properties/icons/icons-selector.tsx @@ -1,6 +1,6 @@ import { Menu, Scrollable } from '@affine/component'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; import { useI18n } from '@affine/i18n'; -import type { DocCustomPropertyInfo } from '@toeverything/infra'; import { chunk } from 'lodash-es'; import { type DocPropertyIconName, DocPropertyIconNames } from './constant'; diff --git a/packages/frontend/core/src/components/doc-properties/manager/index.tsx b/packages/frontend/core/src/components/doc-properties/manager/index.tsx index c9fe1ae62f06a..0d2a9d31049a4 100644 --- a/packages/frontend/core/src/components/doc-properties/manager/index.tsx +++ b/packages/frontend/core/src/components/doc-properties/manager/index.tsx @@ -6,16 +6,13 @@ import { useDraggable, useDropTarget, } from '@affine/component'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import { DocsService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { useI18n } from '@affine/i18n'; import { MoreHorizontalIcon } from '@blocksuite/icons/rc'; -import { - type DocCustomPropertyInfo, - DocsService, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import { type HTMLProps, useCallback, useState } from 'react'; diff --git a/packages/frontend/core/src/components/doc-properties/menu/create-doc-property.tsx b/packages/frontend/core/src/components/doc-properties/menu/create-doc-property.tsx index fdc0a6c707cf3..036970ddc938f 100644 --- a/packages/frontend/core/src/components/doc-properties/menu/create-doc-property.tsx +++ b/packages/frontend/core/src/components/doc-properties/menu/create-doc-property.tsx @@ -1,12 +1,9 @@ import { MenuItem, MenuSeparator } from '@affine/component'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import { DocsService } from '@affine/core/modules/doc'; import { generateUniqueNameInSequence } from '@affine/core/utils/unique-name'; import { useI18n } from '@affine/i18n'; -import { - type DocCustomPropertyInfo, - DocsService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback } from 'react'; import { diff --git a/packages/frontend/core/src/components/doc-properties/menu/edit-doc-property.tsx b/packages/frontend/core/src/components/doc-properties/menu/edit-doc-property.tsx index 74650a7670791..37eed0a6ac52c 100644 --- a/packages/frontend/core/src/components/doc-properties/menu/edit-doc-property.tsx +++ b/packages/frontend/core/src/components/doc-properties/menu/edit-doc-property.tsx @@ -4,9 +4,10 @@ import { MenuSeparator, useConfirmModal, } from '@affine/component'; +import { DocsService } from '@affine/core/modules/doc'; import { Trans, useI18n } from '@affine/i18n'; import { DeleteIcon, InvisibleIcon, ViewIcon } from '@blocksuite/icons/rc'; -import { DocsService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { type KeyboardEventHandler, type MouseEvent, diff --git a/packages/frontend/core/src/components/doc-properties/sidebar/index.tsx b/packages/frontend/core/src/components/doc-properties/sidebar/index.tsx index 8927f8cdd4406..7ffc7a0f0f42f 100644 --- a/packages/frontend/core/src/components/doc-properties/sidebar/index.tsx +++ b/packages/frontend/core/src/components/doc-properties/sidebar/index.tsx @@ -1,4 +1,5 @@ import { Divider, IconButton, Tooltip } from '@affine/component'; +import { DocsService } from '@affine/core/modules/doc'; import { generateUniqueNameInSequence } from '@affine/core/utils/unique-name'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; @@ -7,7 +8,7 @@ import { Content as CollapsibleContent, Root as CollapsibleRoot, } from '@radix-ui/react-collapsible'; -import { DocsService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import { DocPropertyManager } from '../manager'; diff --git a/packages/frontend/core/src/components/doc-properties/table.tsx b/packages/frontend/core/src/components/doc-properties/table.tsx index 81dc3eb6b56ad..9774aa5d1cec3 100644 --- a/packages/frontend/core/src/components/doc-properties/table.tsx +++ b/packages/frontend/core/src/components/doc-properties/table.tsx @@ -8,22 +8,20 @@ import { useDraggable, useDropTarget, } from '@affine/component'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import { DocService, DocsService } from '@affine/core/modules/doc'; import { DocDatabaseBacklinkInfo } from '@affine/core/modules/doc-info'; import type { DatabaseRow, DatabaseValueCell, } from '@affine/core/modules/doc-info/types'; -import { WorkbenchService } from '@affine/core/modules/workbench'; -import { ViewService } from '@affine/core/modules/workbench/services/view'; +import { ViewService, WorkbenchService } from '@affine/core/modules/workbench'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { PlusIcon, PropertyIcon, ToggleExpandIcon } from '@blocksuite/icons/rc'; import * as Collapsible from '@radix-ui/react-collapsible'; import { - type DocCustomPropertyInfo, - DocService, - DocsService, useLiveData, useService, useServiceOptional, diff --git a/packages/frontend/core/src/components/doc-properties/tags-inline-editor.tsx b/packages/frontend/core/src/components/doc-properties/tags-inline-editor.tsx index e496df67393ad..8475f9535e722 100644 --- a/packages/frontend/core/src/components/doc-properties/tags-inline-editor.tsx +++ b/packages/frontend/core/src/components/doc-properties/tags-inline-editor.tsx @@ -1,12 +1,8 @@ import { TagService, useDeleteTagConfirmModal } from '@affine/core/modules/tag'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { TagsIcon } from '@blocksuite/icons/rc'; -import { - LiveData, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { LiveData, useLiveData, useService } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import { useAsyncCallback } from '../hooks/affine-async-hooks'; diff --git a/packages/frontend/core/src/components/doc-properties/types/created-updated-by.tsx b/packages/frontend/core/src/components/doc-properties/types/created-updated-by.tsx index 89e8f49a4a1cc..aed8192107d74 100644 --- a/packages/frontend/core/src/components/doc-properties/types/created-updated-by.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/created-updated-by.tsx @@ -1,7 +1,8 @@ import { Avatar, PropertyValue } from '@affine/component'; import { CloudDocMetaService } from '@affine/core/modules/cloud/services/cloud-doc-meta'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect, useMemo } from 'react'; import { userWrapper } from './created-updated-by.css'; diff --git a/packages/frontend/core/src/components/doc-properties/types/date.tsx b/packages/frontend/core/src/components/doc-properties/types/date.tsx index 21cd34e1ac2f8..52ad9a2a41fc9 100644 --- a/packages/frontend/core/src/components/doc-properties/types/date.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/date.tsx @@ -1,6 +1,7 @@ import { DatePicker, Menu, PropertyValue, Tooltip } from '@affine/component'; +import { DocService } from '@affine/core/modules/doc'; import { i18nTime, useI18n } from '@affine/i18n'; -import { DocService, useLiveData, useServices } from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import * as styles from './date.css'; import type { PropertyValueProps } from './types'; diff --git a/packages/frontend/core/src/components/doc-properties/types/doc-primary-mode.tsx b/packages/frontend/core/src/components/doc-properties/types/doc-primary-mode.tsx index c64f0110d5ef7..d1f8b8546a716 100644 --- a/packages/frontend/core/src/components/doc-properties/types/doc-primary-mode.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/doc-primary-mode.tsx @@ -4,9 +4,10 @@ import { RadioGroup, type RadioItem, } from '@affine/component'; +import { DocService } from '@affine/core/modules/doc'; import { useI18n } from '@affine/i18n'; import type { DocMode } from '@blocksuite/affine/blocks'; -import { DocService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import * as styles from './doc-primary-mode.css'; diff --git a/packages/frontend/core/src/components/doc-properties/types/edgeless-theme.tsx b/packages/frontend/core/src/components/doc-properties/types/edgeless-theme.tsx index 91c27061796f4..b27bb1ebe8409 100644 --- a/packages/frontend/core/src/components/doc-properties/types/edgeless-theme.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/edgeless-theme.tsx @@ -1,6 +1,7 @@ import { PropertyValue, RadioGroup, type RadioItem } from '@affine/component'; +import { DocService } from '@affine/core/modules/doc'; import { useI18n } from '@affine/i18n'; -import { DocService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import * as styles from './edgeless-theme.css'; diff --git a/packages/frontend/core/src/components/doc-properties/types/journal.tsx b/packages/frontend/core/src/components/doc-properties/types/journal.tsx index b32cdd6e4f925..0c3dbc89c9dea 100644 --- a/packages/frontend/core/src/components/doc-properties/types/journal.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/journal.tsx @@ -1,11 +1,11 @@ import { Checkbox, DatePicker, Menu, PropertyValue } from '@affine/component'; import { MobileJournalConflictList } from '@affine/core/mobile/pages/workspace/detail/menu/journal-conflicts'; +import { DocService } from '@affine/core/modules/doc'; import { JournalService } from '@affine/core/modules/journal'; import { WorkbenchService } from '@affine/core/modules/workbench'; import { ViewService } from '@affine/core/modules/workbench/services/view'; import { i18nTime, useI18n } from '@affine/i18n'; import { - DocService, useLiveData, useService, useServiceOptional, diff --git a/packages/frontend/core/src/components/doc-properties/types/page-width.tsx b/packages/frontend/core/src/components/doc-properties/types/page-width.tsx index 4e7b0fcdf5c9c..d9d344a863c17 100644 --- a/packages/frontend/core/src/components/doc-properties/types/page-width.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/page-width.tsx @@ -1,7 +1,8 @@ import { PropertyValue, RadioGroup, type RadioItem } from '@affine/component'; +import { DocService } from '@affine/core/modules/doc'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { useI18n } from '@affine/i18n'; -import { DocService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import { container } from './page-width.css'; diff --git a/packages/frontend/core/src/components/doc-properties/types/tags.tsx b/packages/frontend/core/src/components/doc-properties/types/tags.tsx index 11339f5171cea..456403a8ba05a 100644 --- a/packages/frontend/core/src/components/doc-properties/types/tags.tsx +++ b/packages/frontend/core/src/components/doc-properties/types/tags.tsx @@ -1,7 +1,8 @@ import { PropertyValue } from '@affine/component'; +import { DocService } from '@affine/core/modules/doc'; import { TagService } from '@affine/core/modules/tag'; import { useI18n } from '@affine/i18n'; -import { DocService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { TagsInlineEditor } from '../tags-inline-editor'; import * as styles from './tags.css'; diff --git a/packages/frontend/core/src/components/doc-properties/types/types.ts b/packages/frontend/core/src/components/doc-properties/types/types.ts index aaa1fc101eb38..b53dac916e445 100644 --- a/packages/frontend/core/src/components/doc-properties/types/types.ts +++ b/packages/frontend/core/src/components/doc-properties/types/types.ts @@ -1,4 +1,4 @@ -import type { DocCustomPropertyInfo } from '@toeverything/infra'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; export interface PropertyValueProps { propertyInfo?: DocCustomPropertyInfo; diff --git a/packages/frontend/core/src/components/hooks/affine/use-all-page-list-config.tsx b/packages/frontend/core/src/components/hooks/affine/use-all-page-list-config.tsx index 77490a5966857..b924280694072 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-all-page-list-config.tsx +++ b/packages/frontend/core/src/components/hooks/affine/use-all-page-list-config.tsx @@ -3,10 +3,11 @@ import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-su import { FavoriteTag } from '@affine/core/components/page-list/components/favorite-tag'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; import { ShareDocsListService } from '@affine/core/modules/share-doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { PublicPageMode } from '@affine/graphql'; import { useI18n } from '@affine/i18n'; import type { DocCollection, DocMeta } from '@blocksuite/affine/store'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { type ReactNode, useCallback, useEffect, useMemo } from 'react'; export type AllPageListConfig = { diff --git a/packages/frontend/core/src/components/hooks/affine/use-block-suite-meta-helper.ts b/packages/frontend/core/src/components/hooks/affine/use-block-suite-meta-helper.ts index 6efe884a6fc4e..e9bbaab56e367 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-block-suite-meta-helper.ts +++ b/packages/frontend/core/src/components/hooks/affine/use-block-suite-meta-helper.ts @@ -1,8 +1,10 @@ import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-page-meta'; import { useDocCollectionHelper } from '@affine/core/components/hooks/use-block-suite-workspace-helper'; +import { DocsService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { DocMode } from '@blocksuite/affine/blocks'; -import { DocsService, useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback } from 'react'; import { applyUpdate, encodeStateAsUpdate } from 'yjs'; diff --git a/packages/frontend/core/src/components/hooks/affine/use-enable-cloud.tsx b/packages/frontend/core/src/components/hooks/affine/use-enable-cloud.tsx index 5d765f3d30a05..6b5a7127bf8e3 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-enable-cloud.tsx +++ b/packages/frontend/core/src/components/hooks/affine/use-enable-cloud.tsx @@ -1,13 +1,10 @@ import { notify, useConfirmModal } from '@affine/component'; import { AuthService, ServersService } from '@affine/core/modules/cloud'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; +import type { Workspace } from '@affine/core/modules/workspace'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import type { Workspace } from '@toeverything/infra'; -import { - useLiveData, - useService, - WorkspacesService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback } from 'react'; import { useNavigateHelper } from '../use-navigate-helper'; diff --git a/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx b/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx index b5cfd0bd3f052..b422bb0650701 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx +++ b/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx @@ -4,10 +4,12 @@ import { registerAffineCommand, } from '@affine/core/commands'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocService } from '@affine/core/modules/doc'; import type { Editor } from '@affine/core/modules/editor'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; import { OpenInAppService } from '@affine/core/modules/open-in-app'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { @@ -17,11 +19,9 @@ import { PageIcon, } from '@blocksuite/icons/rc'; import { - DocService, useLiveData, useService, useServiceOptional, - WorkspaceService, } from '@toeverything/infra'; import { useSetAtom } from 'jotai'; import { useCallback, useEffect } from 'react'; diff --git a/packages/frontend/core/src/components/hooks/affine/use-register-copy-link-commands.tsx b/packages/frontend/core/src/components/hooks/affine/use-register-copy-link-commands.tsx index 7184aa4cfc7ec..02f45ec8a0f52 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-register-copy-link-commands.tsx +++ b/packages/frontend/core/src/components/hooks/affine/use-register-copy-link-commands.tsx @@ -4,8 +4,8 @@ import { } from '@affine/core/commands'; import { useSharingUrl } from '@affine/core/components/hooks/affine/use-share-url'; import { useIsActiveView } from '@affine/core/modules/workbench'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { track } from '@affine/track'; -import { type WorkspaceMetadata } from '@toeverything/infra'; import { useEffect } from 'react'; export function useRegisterCopyLinkCommands({ diff --git a/packages/frontend/core/src/components/hooks/affine/use-sign-out.ts b/packages/frontend/core/src/components/hooks/affine/use-sign-out.ts index d9127fa960f65..66b61311f1649 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-sign-out.ts +++ b/packages/frontend/core/src/components/hooks/affine/use-sign-out.ts @@ -4,13 +4,10 @@ import { useConfirmModal, } from '@affine/component'; import { AuthService, ServerService } from '@affine/core/modules/cloud'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { - GlobalContextService, - useLiveData, - useService, - WorkspacesService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback } from 'react'; import { useNavigateHelper } from '../use-navigate-helper'; diff --git a/packages/frontend/core/src/components/hooks/use-block-suite-page-meta.ts b/packages/frontend/core/src/components/hooks/use-block-suite-page-meta.ts index 467765cd86f38..9821a15a5d631 100644 --- a/packages/frontend/core/src/components/hooks/use-block-suite-page-meta.ts +++ b/packages/frontend/core/src/components/hooks/use-block-suite-page-meta.ts @@ -1,5 +1,7 @@ +import { DocsService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { DocCollection, DocMeta } from '@blocksuite/affine/store'; -import { DocsService, useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import { useAsyncCallback } from './affine-async-hooks'; diff --git a/packages/frontend/core/src/components/hooks/use-journal.ts b/packages/frontend/core/src/components/hooks/use-journal.ts index 7c679865dbb55..241f953075e18 100644 --- a/packages/frontend/core/src/components/hooks/use-journal.ts +++ b/packages/frontend/core/src/components/hooks/use-journal.ts @@ -1,3 +1,4 @@ +import { DocsService } from '@affine/core/modules/doc'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { JOURNAL_DATE_FORMAT, @@ -6,7 +7,7 @@ import { } from '@affine/core/modules/journal'; import { i18nTime } from '@affine/i18n'; import { track } from '@affine/track'; -import { DocsService, useService, useServices } from '@toeverything/infra'; +import { useService, useServices } from '@toeverything/infra'; import dayjs from 'dayjs'; import { useCallback, useMemo } from 'react'; diff --git a/packages/frontend/core/src/components/hooks/use-register-workspace-commands.ts b/packages/frontend/core/src/components/hooks/use-register-workspace-commands.ts index f3030e98b88c3..160e930a2a743 100644 --- a/packages/frontend/core/src/components/hooks/use-register-workspace-commands.ts +++ b/packages/frontend/core/src/components/hooks/use-register-workspace-commands.ts @@ -3,13 +3,10 @@ import { DesktopApiService } from '@affine/core/modules/desktop-api'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; import { I18nService } from '@affine/core/modules/i18n'; import { UrlService } from '@affine/core/modules/url'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import type { AffineEditorContainer } from '@blocksuite/affine/presets'; -import { - useService, - useServiceOptional, - WorkspaceService, -} from '@toeverything/infra'; +import { useService, useServiceOptional } from '@toeverything/infra'; import { useStore } from 'jotai'; import { useTheme } from 'next-themes'; import { useEffect } from 'react'; diff --git a/packages/frontend/core/src/components/hooks/use-workspace-info.ts b/packages/frontend/core/src/components/hooks/use-workspace-info.ts index 05bfcf1876acc..aad7957d7d78b 100644 --- a/packages/frontend/core/src/components/hooks/use-workspace-info.ts +++ b/packages/frontend/core/src/components/hooks/use-workspace-info.ts @@ -1,9 +1,8 @@ -import type { WorkspaceMetadata } from '@toeverything/infra'; import { - useLiveData, - useService, + type WorkspaceMetadata, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect } from 'react'; export function useWorkspaceInfo(meta?: WorkspaceMetadata) { diff --git a/packages/frontend/core/src/components/hooks/use-workspace.ts b/packages/frontend/core/src/components/hooks/use-workspace.ts index 0a69933303245..5f187368fe12f 100644 --- a/packages/frontend/core/src/components/hooks/use-workspace.ts +++ b/packages/frontend/core/src/components/hooks/use-workspace.ts @@ -1,5 +1,9 @@ -import type { Workspace, WorkspaceMetadata } from '@toeverything/infra'; -import { useService, WorkspacesService } from '@toeverything/infra'; +import { + type Workspace, + type WorkspaceMetadata, + WorkspacesService, +} from '@affine/core/modules/workspace'; +import { useService } from '@toeverything/infra'; import { useEffect, useState } from 'react'; /** diff --git a/packages/frontend/core/src/components/over-capacity/index.tsx b/packages/frontend/core/src/components/over-capacity/index.tsx index 8df383bafb010..09c96a8e1281d 100644 --- a/packages/frontend/core/src/components/over-capacity/index.tsx +++ b/packages/frontend/core/src/components/over-capacity/index.tsx @@ -1,8 +1,9 @@ import { notify } from '@affine/component'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { debounce } from 'lodash-es'; import { useCallback, useEffect } from 'react'; diff --git a/packages/frontend/core/src/components/page-detail-editor.tsx b/packages/frontend/core/src/components/page-detail-editor.tsx index fec5deff4a401..a50387520bba4 100644 --- a/packages/frontend/core/src/components/page-detail-editor.tsx +++ b/packages/frontend/core/src/components/page-detail-editor.tsx @@ -1,12 +1,13 @@ import './page-detail-editor.css'; import type { AffineEditorContainer } from '@blocksuite/affine/presets'; -import { DocService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import clsx from 'clsx'; import type { CSSProperties } from 'react'; import { useMemo } from 'react'; +import { DocService } from '../modules/doc'; import { EditorService } from '../modules/editor'; import { EditorSettingService, @@ -16,7 +17,7 @@ import { BlockSuiteEditor as Editor } from './blocksuite/block-suite-editor'; import * as styles from './page-detail-editor.css'; declare global { - // eslint-disable-next-line no-var + // oxlint-disable-next-line no-var var currentEditor: AffineEditorContainer | undefined; } diff --git a/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx b/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx index 52372ddbb46c8..54709ebc8ac99 100644 --- a/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx +++ b/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx @@ -1,7 +1,8 @@ import { useDeleteCollectionInfo } from '@affine/core/components/hooks/affine/use-delete-collection-info'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Collection, DeleteCollectionInfo } from '@affine/env/filter'; import { Trans } from '@affine/i18n'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback, useMemo, useRef, useState } from 'react'; import { CollectionService } from '../../../modules/collection'; diff --git a/packages/frontend/core/src/components/page-list/docs/page-list-header.tsx b/packages/frontend/core/src/components/page-list/docs/page-list-header.tsx index 375b4fe94547d..3da0ad6b052d2 100644 --- a/packages/frontend/core/src/components/page-list/docs/page-list-header.tsx +++ b/packages/frontend/core/src/components/page-list/docs/page-list-header.tsx @@ -8,9 +8,11 @@ import { } from '@affine/component'; import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import type { DocRecord } from '@affine/core/modules/doc'; import type { Tag } from '@affine/core/modules/tag'; import { TagService } from '@affine/core/modules/tag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { isNewTabTrigger } from '@affine/core/utils'; import type { Collection } from '@affine/env/filter'; import { useI18n } from '@affine/i18n'; @@ -21,13 +23,7 @@ import { SearchIcon, ViewLayersIcon, } from '@blocksuite/icons/rc'; -import type { DocRecord } from '@toeverything/infra'; -import { - useLiveData, - useService, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import clsx from 'clsx'; import { useCallback, useMemo, useState } from 'react'; import { Link } from 'react-router-dom'; diff --git a/packages/frontend/core/src/components/page-list/docs/select-page.tsx b/packages/frontend/core/src/components/page-list/docs/select-page.tsx index a80db7652af55..eac410f3e596c 100644 --- a/packages/frontend/core/src/components/page-list/docs/select-page.tsx +++ b/packages/frontend/core/src/components/page-list/docs/select-page.tsx @@ -2,15 +2,12 @@ import { IconButton, Menu, toast } from '@affine/component'; import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-suite-page-meta'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; import { ShareDocsListService } from '@affine/core/modules/share-doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { PublicPageMode } from '@affine/graphql'; import { Trans, useI18n } from '@affine/i18n'; import type { DocMeta } from '@blocksuite/affine/store'; import { FilterIcon } from '@blocksuite/icons/rc'; -import { - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { type ReactNode, useCallback, useEffect, useState } from 'react'; import { AffineShapeIcon, FavoriteTag } from '..'; diff --git a/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx b/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx index 0d0fb67a835a3..32aa9164fe9b8 100644 --- a/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx +++ b/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx @@ -1,11 +1,13 @@ import { toast, useConfirmModal } from '@affine/component'; import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-suite-page-meta'; import { CollectionService } from '@affine/core/modules/collection'; +import { DocsService } from '@affine/core/modules/doc'; import type { Tag } from '@affine/core/modules/tag'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Collection, Filter } from '@affine/env/filter'; import { Trans, useI18n } from '@affine/i18n'; import type { DocMeta } from '@blocksuite/affine/store'; -import { DocsService, useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback, useMemo, useRef, useState } from 'react'; import { ListFloatingToolbar } from '../components/list-floating-toolbar'; diff --git a/packages/frontend/core/src/components/page-list/operation-cell.tsx b/packages/frontend/core/src/components/page-list/operation-cell.tsx index 225bcf0adaf8f..1f84d797f6d0a 100644 --- a/packages/frontend/core/src/components/page-list/operation-cell.tsx +++ b/packages/frontend/core/src/components/page-list/operation-cell.tsx @@ -9,11 +9,14 @@ import { import { useBlockSuiteMetaHelper } from '@affine/core/components/hooks/affine/use-block-suite-meta-helper'; import { useCatchEventCallback } from '@affine/core/components/hooks/use-catch-event-hook'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { CompatibleFavoriteItemsAdapter, FavoriteService, } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Collection, DeleteCollectionInfo } from '@affine/env/filter'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; @@ -32,14 +35,7 @@ import { ResetIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - DocsService, - FeatureFlagService, - useLiveData, - useService, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import type { MouseEvent } from 'react'; import { useCallback, useState } from 'react'; diff --git a/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx b/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx index cc7d485089e9a..74c2d1292fa20 100644 --- a/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx +++ b/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx @@ -1,6 +1,7 @@ import type { Tag } from '@affine/core/modules/tag'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { Trans } from '@affine/i18n'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback, useMemo, useRef, useState } from 'react'; import { ListFloatingToolbar } from '../components/list-floating-toolbar'; diff --git a/packages/frontend/core/src/components/page-list/use-all-doc-display-properties.ts b/packages/frontend/core/src/components/page-list/use-all-doc-display-properties.ts index 60496c143c832..cbd25e55e42ef 100644 --- a/packages/frontend/core/src/components/page-list/use-all-doc-display-properties.ts +++ b/packages/frontend/core/src/components/page-list/use-all-doc-display-properties.ts @@ -1,4 +1,5 @@ -import { useService, WorkspaceService } from '@toeverything/infra'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { useService } from '@toeverything/infra'; import { useAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; import { useCallback } from 'react'; diff --git a/packages/frontend/core/src/components/page-list/view/collection-operations.tsx b/packages/frontend/core/src/components/page-list/view/collection-operations.tsx index 6e67b3910bd83..4ff46438816ce 100644 --- a/packages/frontend/core/src/components/page-list/view/collection-operations.tsx +++ b/packages/frontend/core/src/components/page-list/view/collection-operations.tsx @@ -3,6 +3,7 @@ import { Menu, MenuItem, usePromptModal } from '@affine/component'; import { useDeleteCollectionInfo } from '@affine/core/components/hooks/affine/use-delete-collection-info'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { WorkbenchService } from '@affine/core/modules/workbench'; import type { Collection } from '@affine/env/filter'; import { useI18n } from '@affine/i18n'; @@ -14,12 +15,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useService, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import type { PropsWithChildren, ReactElement } from 'react'; import { useCallback, useMemo } from 'react'; diff --git a/packages/frontend/core/src/components/page-list/virtualized-trash-list.tsx b/packages/frontend/core/src/components/page-list/virtualized-trash-list.tsx index 8dbbffd04a81a..61983aee561d3 100644 --- a/packages/frontend/core/src/components/page-list/virtualized-trash-list.tsx +++ b/packages/frontend/core/src/components/page-list/virtualized-trash-list.tsx @@ -1,9 +1,10 @@ import { toast, useConfirmModal } from '@affine/component'; import { useBlockSuiteMetaHelper } from '@affine/core/components/hooks/affine/use-block-suite-meta-helper'; import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-suite-page-meta'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { Trans, useI18n } from '@affine/i18n'; import type { DocMeta } from '@blocksuite/affine/store'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback, useMemo, useRef, useState } from 'react'; import { ListFloatingToolbar } from './components/list-floating-toolbar'; diff --git a/packages/frontend/core/src/components/providers/workspace-side-effects.tsx b/packages/frontend/core/src/components/providers/workspace-side-effects.tsx index 29b43380e34ab..66394eaac0d99 100644 --- a/packages/frontend/core/src/components/providers/workspace-side-effects.tsx +++ b/packages/frontend/core/src/components/providers/workspace-side-effects.tsx @@ -14,22 +14,22 @@ import { GraphQLService, } from '@affine/core/modules/cloud'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { useRegisterNavigationCommands } from '@affine/core/modules/navigation/view/use-register-navigation-commands'; import { QuickSearchContainer } from '@affine/core/modules/quicksearch'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; import { type DocMode, ZipTransformer } from '@blocksuite/affine/blocks'; import { - DocsService, effect, fromPromise, onStart, throwIfAborted, useService, useServices, - WorkspaceService, } from '@toeverything/infra'; import { useSetAtom } from 'jotai'; import { useEffect } from 'react'; diff --git a/packages/frontend/core/src/components/pure/help-island/index.tsx b/packages/frontend/core/src/components/pure/help-island/index.tsx index f10ae72b15388..a7e8011217fb8 100644 --- a/packages/frontend/core/src/components/pure/help-island/index.tsx +++ b/packages/frontend/core/src/components/pure/help-island/index.tsx @@ -1,15 +1,11 @@ import { Tooltip } from '@affine/component/ui/tooltip'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; import type { SettingTab } from '@affine/core/modules/dialogs/constant'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { UrlService } from '@affine/core/modules/url'; import { useI18n } from '@affine/i18n'; import { CloseIcon, NewIcon } from '@blocksuite/icons/rc'; -import { - GlobalContextService, - useLiveData, - useService, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import { ContactIcon, HelpIcon, KeyboardIcon } from './icons'; diff --git a/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx b/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx index 03af2df089efb..5423bd0cd8515 100644 --- a/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx +++ b/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx @@ -1,8 +1,10 @@ import { Button } from '@affine/component/ui/button'; import { ConfirmModal } from '@affine/component/ui/modal'; +import { DocService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { DeleteIcon, ResetIcon } from '@blocksuite/icons/rc'; -import { DocService, useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import { useAppSettingHelper } from '../../../components/hooks/affine/use-app-setting-helper'; diff --git a/packages/frontend/core/src/components/root-app-sidebar/index.tsx b/packages/frontend/core/src/components/root-app-sidebar/index.tsx index 6f003c918a46d..b984b973cfb4e 100644 --- a/packages/frontend/core/src/components/root-app-sidebar/index.tsx +++ b/packages/frontend/core/src/components/root-app-sidebar/index.tsx @@ -22,6 +22,7 @@ import { } from '@affine/core/modules/explorer'; import { ExplorerTags } from '@affine/core/modules/explorer/views/sections/tags'; import { CMDKQuickSearchService } from '@affine/core/modules/quicksearch/services/cmdk'; +import type { Workspace } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import type { Doc } from '@blocksuite/affine/store'; @@ -32,7 +33,6 @@ import { JournalIcon, SettingsIcon, } from '@blocksuite/icons/rc'; -import type { Workspace } from '@toeverything/infra'; import { useLiveData, useService, useServices } from '@toeverything/infra'; import type { ReactElement } from 'react'; import { memo, useCallback } from 'react'; diff --git a/packages/frontend/core/src/components/root-app-sidebar/trash-button.tsx b/packages/frontend/core/src/components/root-app-sidebar/trash-button.tsx index 862379b4be21d..466348814f5d4 100644 --- a/packages/frontend/core/src/components/root-app-sidebar/trash-button.tsx +++ b/packages/frontend/core/src/components/root-app-sidebar/trash-button.tsx @@ -4,14 +4,11 @@ import { useDropTarget, } from '@affine/component'; import { MenuLinkItem } from '@affine/core/modules/app-sidebar/views'; +import { DocsService } from '@affine/core/modules/doc'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { useI18n } from '@affine/i18n'; -import { - DocsService, - GlobalContextService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; export const TrashButton = () => { const t = useI18n(); diff --git a/packages/frontend/core/src/components/sign-in/sign-in.tsx b/packages/frontend/core/src/components/sign-in/sign-in.tsx index 60d06e3f0d5b5..57d13924aa1cb 100644 --- a/packages/frontend/core/src/components/sign-in/sign-in.tsx +++ b/packages/frontend/core/src/components/sign-in/sign-in.tsx @@ -3,14 +3,11 @@ import { AuthInput, ModalHeader } from '@affine/component/auth-components'; import { OAuth } from '@affine/core/components/affine/auth/oauth'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { AuthService, ServerService } from '@affine/core/modules/cloud'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { ServerDeploymentType } from '@affine/graphql'; import { Trans, useI18n } from '@affine/i18n'; import { ArrowRightBigIcon, PublishIcon } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import { type Dispatch, diff --git a/packages/frontend/core/src/components/top-tip.tsx b/packages/frontend/core/src/components/top-tip.tsx index 0e703a3d1b6f4..98b1dbec8744f 100644 --- a/packages/frontend/core/src/components/top-tip.tsx +++ b/packages/frontend/core/src/components/top-tip.tsx @@ -1,11 +1,12 @@ import { BrowserWarning, LocalDemoTips } from '@affine/component/affine-banner'; import { Trans, useI18n } from '@affine/i18n'; -import { useLiveData, useService, type Workspace } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import { useEnableCloud } from '../components/hooks/affine/use-enable-cloud'; import { AuthService } from '../modules/cloud'; import { GlobalDialogService } from '../modules/dialogs'; +import type { Workspace } from '../modules/workspace'; const minimumChromeVersion = 106; diff --git a/packages/frontend/component/src/components/workspace-avatar/index.tsx b/packages/frontend/core/src/components/workspace-avatar/index.tsx similarity index 93% rename from packages/frontend/component/src/components/workspace-avatar/index.tsx rename to packages/frontend/core/src/components/workspace-avatar/index.tsx index 3e849f89c82ad..1c12315861f3e 100644 --- a/packages/frontend/component/src/components/workspace-avatar/index.tsx +++ b/packages/frontend/core/src/components/workspace-avatar/index.tsx @@ -1,13 +1,11 @@ +import { Avatar, type AvatarProps } from '@affine/component'; import { - useLiveData, - useService, type WorkspaceMetadata, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect, useLayoutEffect, useState } from 'react'; -import { Avatar, type AvatarProps } from '../../ui/avatar'; - const cache = new Map(); /** diff --git a/packages/frontend/core/src/components/workspace-selector/index.tsx b/packages/frontend/core/src/components/workspace-selector/index.tsx index 0aa3e0bd69a3d..1f77cc8795721 100644 --- a/packages/frontend/core/src/components/workspace-selector/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/index.tsx @@ -1,13 +1,12 @@ import { Menu, type MenuProps } from '@affine/component'; import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper'; -import { track } from '@affine/track'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { - GlobalContextService, - useLiveData, - useServices, type WorkspaceMetadata, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { track } from '@affine/track'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useEffect, useState } from 'react'; import { UserWithWorkspaceList } from './user-with-workspace-list'; diff --git a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-server/index.tsx b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-server/index.tsx index e10bbf907cf32..0753b9154267a 100644 --- a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-server/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-server/index.tsx @@ -1,11 +1,8 @@ import { MenuItem } from '@affine/component/ui/menu'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { useI18n } from '@affine/i18n'; import { PlusIcon } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import * as styles from './index.css'; diff --git a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx index 1ec5b58dcff3c..564fd9a0b9f11 100644 --- a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx @@ -1,11 +1,8 @@ import { MenuItem } from '@affine/component/ui/menu'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { useI18n } from '@affine/i18n'; import { ImportIcon, PlusIcon } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import * as styles from './index.css'; diff --git a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/index.tsx b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/index.tsx index b5b7e1780f6d9..22accb5c84a7b 100644 --- a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/index.tsx @@ -2,16 +2,15 @@ import { Divider } from '@affine/component/ui/divider'; import { MenuItem } from '@affine/component/ui/menu'; import { AuthService } from '@affine/core/modules/cloud'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; -import { useI18n } from '@affine/i18n'; -import { track } from '@affine/track'; -import { Logo1Icon } from '@blocksuite/icons/rc'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { - FeatureFlagService, - useLiveData, - useService, type WorkspaceMetadata, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { useI18n } from '@affine/i18n'; +import { track } from '@affine/track'; +import { Logo1Icon } from '@blocksuite/icons/rc'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback } from 'react'; import { AddServer } from './add-server'; diff --git a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/workspace-list/index.tsx b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/workspace-list/index.tsx index 1257c7e7fc122..e39cd5acceac9 100644 --- a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/workspace-list/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/workspace-list/index.tsx @@ -11,6 +11,12 @@ import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-he import type { Server } from '@affine/core/modules/cloud'; import { AuthService, ServersService } from '@affine/core/modules/cloud'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { + type WorkspaceMetadata, + WorkspaceService, + WorkspacesService, +} from '@affine/core/modules/workspace'; import { ServerDeploymentType } from '@affine/graphql'; import { useI18n } from '@affine/i18n'; import { @@ -20,15 +26,11 @@ import { PlusIcon, TeamWorkspaceIcon, } from '@blocksuite/icons/rc'; -import type { WorkspaceMetadata } from '@toeverything/infra'; import { FrameworkScope, - GlobalContextService, useLiveData, useService, useServiceOptional, - WorkspaceService, - WorkspacesService, } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; diff --git a/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx b/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx index aeded8663e473..6f22c88e8cbd7 100644 --- a/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx @@ -1,9 +1,12 @@ import { Button, Skeleton, Tooltip } from '@affine/component'; import { Loading } from '@affine/component/ui/loading'; -import { WorkspaceAvatar } from '@affine/component/workspace-avatar'; import { useSystemOnline } from '@affine/core/components/hooks/use-system-online'; import { useWorkspace } from '@affine/core/components/hooks/use-workspace'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import type { + WorkspaceMetadata, + WorkspaceProfileInfo, +} from '@affine/core/modules/workspace'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { ArrowDownSmallIcon, @@ -17,17 +20,14 @@ import { TeamWorkspaceIcon, UnsyncIcon, } from '@blocksuite/icons/rc'; -import { - useLiveData, - type WorkspaceMetadata, - type WorkspaceProfileInfo, -} from '@toeverything/infra'; +import { useLiveData } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import clsx from 'clsx'; import type { HTMLAttributes } from 'react'; import { forwardRef, useCallback, useEffect, useState } from 'react'; import { useCatchEventCallback } from '../../hooks/use-catch-event-hook'; +import { WorkspaceAvatar } from '../../workspace-avatar'; import * as styles from './styles.css'; export { PureWorkspaceCard } from './pure-workspace-card'; diff --git a/packages/frontend/core/src/components/workspace-selector/workspace-card/pure-workspace-card.tsx b/packages/frontend/core/src/components/workspace-selector/workspace-card/pure-workspace-card.tsx index 6e70d429893df..10a682485d7c7 100644 --- a/packages/frontend/core/src/components/workspace-selector/workspace-card/pure-workspace-card.tsx +++ b/packages/frontend/core/src/components/workspace-selector/workspace-card/pure-workspace-card.tsx @@ -1,13 +1,13 @@ import { Skeleton } from '@affine/component'; -import { WorkspaceAvatar } from '@affine/component/workspace-avatar'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { DoneIcon } from '@blocksuite/icons/rc'; -import { type WorkspaceMetadata } from '@toeverything/infra'; import clsx from 'clsx'; import type { HTMLAttributes } from 'react'; import { forwardRef } from 'react'; +import { WorkspaceAvatar } from '../../workspace-avatar'; import * as styles from './styles.css'; export const PureWorkspaceCard = forwardRef< diff --git a/packages/frontend/core/src/desktop/components/ai-island/container.tsx b/packages/frontend/core/src/desktop/components/ai-island/container.tsx index d9edf6035c86d..0f9ddafe0c253 100644 --- a/packages/frontend/core/src/desktop/components/ai-island/container.tsx +++ b/packages/frontend/core/src/desktop/components/ai-island/container.tsx @@ -1,9 +1,6 @@ -import { - DocsService, - GlobalContextService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { DocsService } from '@affine/core/modules/doc'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import type { PropsWithChildren, ReactElement } from 'react'; diff --git a/packages/frontend/core/src/desktop/components/app-container/index.tsx b/packages/frontend/core/src/desktop/components/app-container/index.tsx index 249958723ce18..8160793dde938 100644 --- a/packages/frontend/core/src/desktop/components/app-container/index.tsx +++ b/packages/frontend/core/src/desktop/components/app-container/index.tsx @@ -8,11 +8,11 @@ import { } from '@affine/core/modules/app-sidebar/views'; import { AppTabsHeader } from '@affine/core/modules/app-tabs-header'; import { NavigationButtons } from '@affine/core/modules/navigation'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useLiveData, useService, useServiceOptional, - WorkspaceService, } from '@toeverything/infra'; import clsx from 'clsx'; import { diff --git a/packages/frontend/core/src/desktop/dialogs/collection-editor/rules-mode.tsx b/packages/frontend/core/src/desktop/dialogs/collection-editor/rules-mode.tsx index 8f1b894ece342..db46d69e4e78c 100644 --- a/packages/frontend/core/src/desktop/dialogs/collection-editor/rules-mode.tsx +++ b/packages/frontend/core/src/desktop/dialogs/collection-editor/rules-mode.tsx @@ -8,6 +8,7 @@ import { type ListItem, ListScrollContainer, } from '@affine/core/components/page-list'; +import { DocsService } from '@affine/core/modules/doc'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; import type { Collection } from '@affine/env/filter'; import { Trans, useI18n } from '@affine/i18n'; @@ -18,7 +19,7 @@ import { PageIcon, ToggleCollapseIcon, } from '@blocksuite/icons/rc'; -import { DocsService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import clsx from 'clsx'; import type { ReactNode } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/create-workspace/index.tsx b/packages/frontend/core/src/desktop/dialogs/create-workspace/index.tsx index b1f5b451f9e3a..17b08cebc1aea 100644 --- a/packages/frontend/core/src/desktop/dialogs/create-workspace/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/create-workspace/index.tsx @@ -8,14 +8,11 @@ import { type GLOBAL_DIALOG_SCHEMA, GlobalDialogService, } from '@affine/core/modules/dialogs'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; -import { - FeatureFlagService, - useLiveData, - useService, - WorkspacesService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import { buildShowcaseWorkspace } from '../../../utils/first-app-data'; diff --git a/packages/frontend/core/src/desktop/dialogs/doc-info/index.tsx b/packages/frontend/core/src/desktop/dialogs/doc-info/index.tsx index 04231c7abc6ba..f888cfb264a16 100644 --- a/packages/frontend/core/src/desktop/dialogs/doc-info/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/doc-info/index.tsx @@ -2,8 +2,8 @@ import { Modal, Scrollable } from '@affine/component'; import { BlocksuiteHeaderTitle } from '@affine/core/components/blocksuite/block-suite-header/title'; import type { DialogComponentProps } from '@affine/core/modules/dialogs'; import type { WORKSPACE_DIALOG_SCHEMA } from '@affine/core/modules/dialogs/constant'; -import type { Doc } from '@toeverything/infra'; -import { DocsService, FrameworkScope, useService } from '@toeverything/infra'; +import { type Doc, DocsService } from '@affine/core/modules/doc'; +import { FrameworkScope, useService } from '@toeverything/infra'; import { useEffect, useState } from 'react'; import { InfoTable } from './info-modal'; diff --git a/packages/frontend/core/src/desktop/dialogs/doc-info/info-modal.tsx b/packages/frontend/core/src/desktop/dialogs/doc-info/info-modal.tsx index 2edaa3f217355..e968c0cd80086 100644 --- a/packages/frontend/core/src/desktop/dialogs/doc-info/info-modal.tsx +++ b/packages/frontend/core/src/desktop/dialogs/doc-info/info-modal.tsx @@ -7,6 +7,8 @@ import { } from '@affine/component'; import { CreatePropertyMenuItems } from '@affine/core/components/doc-properties/menu/create-doc-property'; import { DocPropertyRow } from '@affine/core/components/doc-properties/table'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import { DocsService } from '@affine/core/modules/doc'; import { DocDatabaseBacklinkInfo } from '@affine/core/modules/doc-info'; import type { DatabaseRow, @@ -16,13 +18,7 @@ import { DocsSearchService } from '@affine/core/modules/docs-search'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; import { PlusIcon } from '@blocksuite/icons/rc'; -import { - type DocCustomPropertyInfo, - DocsService, - LiveData, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { LiveData, useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useMemo, useState } from 'react'; import * as styles from './info-modal.css'; diff --git a/packages/frontend/core/src/desktop/dialogs/doc-info/time-row.tsx b/packages/frontend/core/src/desktop/dialogs/doc-info/time-row.tsx index 11d62fd06dc7e..bfcced52138b5 100644 --- a/packages/frontend/core/src/desktop/dialogs/doc-info/time-row.tsx +++ b/packages/frontend/core/src/desktop/dialogs/doc-info/time-row.tsx @@ -1,12 +1,9 @@ import { PropertyName, PropertyRoot, PropertyValue } from '@affine/component'; +import { DocsService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { i18nTime, useI18n } from '@affine/i18n'; import { DateTimeIcon, HistoryIcon } from '@blocksuite/icons/rc'; -import { - DocsService, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import type { ConfigType } from 'dayjs'; import { useDebouncedValue } from 'foxact/use-debounced-value'; diff --git a/packages/frontend/core/src/desktop/dialogs/enable-cloud/index.tsx b/packages/frontend/core/src/desktop/dialogs/enable-cloud/index.tsx index 29d099e287b5c..244eaab4172ba 100644 --- a/packages/frontend/core/src/desktop/dialogs/enable-cloud/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/enable-cloud/index.tsx @@ -12,14 +12,10 @@ import { type GLOBAL_DIALOG_SCHEMA, GlobalDialogService, } from '@affine/core/modules/dialogs'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { CloudWorkspaceIcon } from '@blocksuite/icons/rc'; -import { - FrameworkScope, - useLiveData, - useService, - WorkspacesService, -} from '@toeverything/infra'; +import { FrameworkScope, useLiveData, useService } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import * as styles from './dialog.css'; diff --git a/packages/frontend/core/src/desktop/dialogs/import-template/index.tsx b/packages/frontend/core/src/desktop/dialogs/import-template/index.tsx index 79fe01d3133a5..388ac6c6acaf7 100644 --- a/packages/frontend/core/src/desktop/dialogs/import-template/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/import-template/index.tsx @@ -12,15 +12,14 @@ import { ImportTemplateService, TemplateDownloaderService, } from '@affine/core/modules/import-template'; -import { useI18n } from '@affine/i18n'; -import type { DocMode } from '@blocksuite/affine/blocks'; -import { AllDocsIcon } from '@blocksuite/icons/rc'; import { - useLiveData, - useService, type WorkspaceMetadata, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { useI18n } from '@affine/i18n'; +import type { DocMode } from '@blocksuite/affine/blocks'; +import { AllDocsIcon } from '@blocksuite/icons/rc'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import { useCallback, useEffect, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/import-workspace/index.tsx b/packages/frontend/core/src/desktop/dialogs/import-workspace/index.tsx index dafb9b90617f0..80e227835e718 100644 --- a/packages/frontend/core/src/desktop/dialogs/import-workspace/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/import-workspace/index.tsx @@ -3,11 +3,12 @@ import { type DialogComponentProps, type GLOBAL_DIALOG_SCHEMA, } from '@affine/core/modules/dialogs'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { _addLocalWorkspace } from '@affine/core/modules/workspace-engine'; import { DebugLogger } from '@affine/debug'; import { apis } from '@affine/electron-api'; import { useI18n } from '@affine/i18n'; -import { useService, WorkspacesService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useLayoutEffect } from 'react'; const logger = new DebugLogger('ImportWorkspaceDialog'); diff --git a/packages/frontend/core/src/desktop/dialogs/import/index.tsx b/packages/frontend/core/src/desktop/dialogs/import/index.tsx index 4b1adf89f1d69..2c3532a9bf160 100644 --- a/packages/frontend/core/src/desktop/dialogs/import/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/import/index.tsx @@ -5,6 +5,7 @@ import type { WORKSPACE_DIALOG_SCHEMA, } from '@affine/core/modules/dialogs'; import { UrlService } from '@affine/core/modules/url'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { DebugLogger } from '@affine/debug'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; @@ -24,7 +25,7 @@ import { PageIcon, ZipIcon, } from '@blocksuite/icons/rc'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import { cssVarV2 } from '@toeverything/theme/v2'; import { diff --git a/packages/frontend/core/src/desktop/dialogs/selectors/collection.tsx b/packages/frontend/core/src/desktop/dialogs/selectors/collection.tsx index 39a3c26c9316b..a73b1c6bf58cc 100644 --- a/packages/frontend/core/src/desktop/dialogs/selectors/collection.tsx +++ b/packages/frontend/core/src/desktop/dialogs/selectors/collection.tsx @@ -13,8 +13,9 @@ import { CollectionService } from '@affine/core/modules/collection'; import type { DialogComponentProps } from '@affine/core/modules/dialogs'; import type { WORKSPACE_DIALOG_SCHEMA } from '@affine/core/modules/dialogs/constant'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/selectors/tag.tsx b/packages/frontend/core/src/desktop/dialogs/selectors/tag.tsx index 574eb76604789..d48bbaa2ebd78 100644 --- a/packages/frontend/core/src/desktop/dialogs/selectors/tag.tsx +++ b/packages/frontend/core/src/desktop/dialogs/selectors/tag.tsx @@ -15,8 +15,9 @@ import type { } from '@affine/core/modules/dialogs'; import { FavoriteService } from '@affine/core/modules/favorite'; import { TagService } from '@affine/core/modules/tag'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/appearance/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/appearance/index.tsx index d95ec0454968e..a91a46221c50b 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/appearance/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/appearance/index.tsx @@ -6,12 +6,9 @@ import { SettingWrapper, } from '@affine/component/setting-components'; import { LanguageMenu } from '@affine/core/components/affine/language-menu'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { useI18n } from '@affine/i18n'; -import { - FeatureFlagService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useTheme } from 'next-themes'; import { useCallback, useMemo } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/general.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/general.tsx index abc4fcd217e99..42f40b2c44062 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/general.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/general.tsx @@ -24,6 +24,7 @@ import { fontStyleOptions, } from '@affine/core/modules/editor-setting'; import { SpellCheckSettingService } from '@affine/core/modules/editor-setting/services/spell-check-setting'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { type FontData, SystemFontFamilyService, @@ -31,12 +32,7 @@ import { import { Trans, useI18n } from '@affine/i18n'; import type { DocMode } from '@blocksuite/affine/blocks'; import { DoneIcon, SearchIcon } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useService, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import clsx from 'clsx'; import { forwardRef, diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/experimental-features/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/experimental-features/index.tsx index 59c8148160ca2..072c7c11386af 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/experimental-features/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/experimental-features/index.tsx @@ -1,6 +1,11 @@ import { Button, Checkbox, Loading, Switch, Tooltip } from '@affine/component'; import { SettingHeader } from '@affine/component/setting-components'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; +import { + AFFINE_FLAGS, + FeatureFlagService, + type Flag, +} from '@affine/core/modules/feature-flag'; import { useI18n } from '@affine/i18n'; import { ArrowRightSmallIcon, @@ -8,13 +13,7 @@ import { EmailIcon, GithubIcon, } from '@blocksuite/icons/rc'; -import { - AFFINE_FLAGS, - FeatureFlagService, - type Flag, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; import { Suspense, useCallback, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/index.tsx index caa311f141fc9..310ab85ba428c 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/index.tsx @@ -1,5 +1,6 @@ import { UserFeatureService } from '@affine/core/modules/cloud/services/user-feature'; import type { SettingTab } from '@affine/core/modules/dialogs/constant'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { useI18n } from '@affine/i18n'; import { AppearanceIcon, @@ -8,11 +9,7 @@ import { KeyboardIcon, PenIcon, } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import type { ReactElement, SVGProps } from 'react'; import { useEffect } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/index.tsx index af936f3c14a24..d1638e9c4ecca 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/index.tsx @@ -8,13 +8,10 @@ import type { GLOBAL_DIALOG_SCHEMA, } from '@affine/core/modules/dialogs'; import type { SettingTab } from '@affine/core/modules/dialogs/constant'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { Trans } from '@affine/i18n'; import { ContactWithUsIcon } from '@blocksuite/icons/rc'; -import { - useLiveData, - useService, - type WorkspaceMetadata, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { debounce } from 'lodash-es'; import { Suspense, diff --git a/packages/frontend/core/src/desktop/dialogs/setting/setting-sidebar/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/setting-sidebar/index.tsx index c2369d5f9ee90..c66430c97689e 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/setting-sidebar/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/setting-sidebar/index.tsx @@ -4,26 +4,24 @@ import { } from '@affine/component/setting-components'; import { Avatar } from '@affine/component/ui/avatar'; import { Tooltip } from '@affine/component/ui/tooltip'; -import { WorkspaceAvatar } from '@affine/component/workspace-avatar'; import { UserPlanButton } from '@affine/core/components/affine/auth/user-plan-button'; import { useCatchEventCallback } from '@affine/core/components/hooks/use-catch-event-hook'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import { WorkspaceAvatar } from '@affine/core/components/workspace-avatar'; import { AuthService } from '@affine/core/modules/cloud'; import { UserFeatureService } from '@affine/core/modules/cloud/services/user-feature'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; import type { SettingTab } from '@affine/core/modules/dialogs/constant'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { + type WorkspaceMetadata, + WorkspacesService, +} from '@affine/core/modules/workspace'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { Logo1Icon } from '@blocksuite/icons/rc'; -import type { WorkspaceMetadata } from '@toeverything/infra'; -import { - GlobalContextService, - useLiveData, - useService, - useServices, - WorkspacesService, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import clsx from 'clsx'; import { type MouseEvent, diff --git a/packages/frontend/core/src/desktop/dialogs/setting/types.ts b/packages/frontend/core/src/desktop/dialogs/setting/types.ts index 58a0a45415322..8d4e56076d77b 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/types.ts +++ b/packages/frontend/core/src/desktop/dialogs/setting/types.ts @@ -1,5 +1,5 @@ import type { SettingTab } from '@affine/core/modules/dialogs/constant'; -import type { WorkspaceMetadata } from '@toeverything/infra'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; export interface SettingState { activeTab: SettingTab; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/index.tsx index b67ec2f146bbf..ace01bd9d561f 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/index.tsx @@ -17,6 +17,7 @@ import { } from '@affine/core/modules/cloud'; import { WorkspaceQuotaService } from '@affine/core/modules/quota'; import { UrlService } from '@affine/core/modules/url'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { createCustomerPortalMutation, type InvoicesQuery, @@ -26,12 +27,7 @@ import { UserFriendlyError, } from '@affine/graphql'; import { useI18n } from '@affine/i18n'; -import { - FrameworkScope, - useLiveData, - useService, - type WorkspaceMetadata, -} from '@toeverything/infra'; +import { FrameworkScope, useLiveData, useService } from '@toeverything/infra'; import { cssVar } from '@toeverything/theme'; import { useCallback, useEffect, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/index.tsx index 79f5334d3eec6..1b89588a27ec8 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/index.tsx @@ -1,5 +1,5 @@ import type { SettingTab } from '@affine/core/modules/dialogs/constant'; -import type { WorkspaceMetadata } from '@toeverything/infra'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import type { SettingState } from '../types'; import { WorkspaceSettingBilling } from './billing'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx index 68bea254399b6..58d4a809eaf39 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx @@ -2,9 +2,9 @@ import { Input } from '@affine/component'; import type { ConfirmModalProps } from '@affine/component/ui/modal'; import { ConfirmModal } from '@affine/component/ui/modal'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { Trans, useI18n } from '@affine/i18n'; -import type { WorkspaceMetadata } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import * as styles from './style.css'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/index.tsx index b0cbd633c5d8e..38bcccdf4253b 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/delete-leave-workspace/index.tsx @@ -2,16 +2,15 @@ import { notify } from '@affine/component'; import { SettingRow } from '@affine/component/setting-components'; import { ConfirmModal } from '@affine/component/ui/modal'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; -import { useI18n } from '@affine/i18n'; -import { ArrowRightSmallIcon } from '@blocksuite/icons/rc'; import { - GlobalContextService, - useLiveData, - useServices, WorkspaceService, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { useI18n } from '@affine/i18n'; +import { ArrowRightSmallIcon } from '@blocksuite/icons/rc'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useEffect, useState } from 'react'; import { diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/enable-cloud.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/enable-cloud.tsx index 69ca382628b41..658ce5d6f9a4c 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/enable-cloud.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/enable-cloud.tsx @@ -1,14 +1,13 @@ import { SettingRow } from '@affine/component/setting-components'; import { Button } from '@affine/component/ui/button'; import { useEnableCloud } from '@affine/core/components/hooks/affine/use-enable-cloud'; -import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; -import { useI18n } from '@affine/i18n'; import { - useLiveData, - useService, type Workspace, WorkspaceService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; +import { useI18n } from '@affine/i18n'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback } from 'react'; export interface PublishPanelProps { diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/export.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/export.tsx index 4c730246e14f7..03170ff60046e 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/export.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/export.tsx @@ -5,14 +5,13 @@ import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hoo import { useSystemOnline } from '@affine/core/components/hooks/use-system-online'; import { DesktopApiService } from '@affine/core/modules/desktop-api'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; +import type { + Workspace, + WorkspaceMetadata, +} from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; -import { - useLiveData, - useService, - type Workspace, - type WorkspaceMetadata, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useState } from 'react'; interface ExportPanelProps { diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/labels.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/labels.tsx index 27c3517f5fd00..2eae0d924b0b5 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/labels.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/labels.tsx @@ -1,6 +1,7 @@ import { WorkspacePermissionService } from '@affine/core/modules/permissions'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVarV2 } from '@toeverything/theme/v2'; import { useEffect, useMemo } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/index.tsx index d41b06bf93710..f80f51366977a 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/index.tsx @@ -2,8 +2,9 @@ import { Button, Tooltip } from '@affine/component'; import { SettingRow } from '@affine/component/setting-components'; import { AffineErrorBoundary } from '@affine/core/components/affine/affine-error-boundary'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import type { ReactElement } from 'react'; import type { SettingState } from '../../../types'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx index 6a801c27840e9..3ca49f255b8a9 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx @@ -6,6 +6,7 @@ import { WorkspaceMembersService, WorkspacePermissionService, } from '@affine/core/modules/permissions'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { Permission, UserFriendlyError, @@ -17,7 +18,6 @@ import { useEnsureLiveData, useLiveData, useService, - WorkspaceService, } from '@toeverything/infra'; import clsx from 'clsx'; import { clamp } from 'lodash-es'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/profile.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/profile.tsx index 85470a315c42b..70268c9618cee 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/profile.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/profile.tsx @@ -1,14 +1,15 @@ import { FlexWrapper, Input, notify, Wrapper } from '@affine/component'; import { Button } from '@affine/component/ui/button'; -import { WorkspaceAvatar } from '@affine/component/workspace-avatar'; import { useCatchEventCallback } from '@affine/core/components/hooks/use-catch-event-hook'; import { Upload } from '@affine/core/components/pure/file-upload'; +import { WorkspaceAvatar } from '@affine/core/components/workspace-avatar'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { validateAndReduceImage } from '@affine/core/utils/reduce-image'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { useI18n } from '@affine/i18n'; import { CameraIcon } from '@blocksuite/icons/rc'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import type { KeyboardEvent } from 'react'; import { useCallback, useEffect, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/sharing.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/sharing.tsx index b2a4d014cd072..a4e773684f98a 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/sharing.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/sharing.tsx @@ -6,8 +6,9 @@ import { import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { WorkspacePermissionService } from '@affine/core/modules/permissions'; import { WorkspaceShareSettingService } from '@affine/core/modules/share-setting'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; export const SharingPanel = () => { const workspace = useService(WorkspaceService).workspace; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts index e16ef68a5d40d..6604851b7d13a 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts @@ -1,4 +1,4 @@ -import type { WorkspaceMetadata } from '@toeverything/infra'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import type { SettingState } from '../../types'; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx index ae2123de61374..55a3fd360d9c2 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx @@ -3,13 +3,11 @@ import { SettingHeader } from '@affine/component/setting-components'; import { DocPropertyManager } from '@affine/core/components/doc-properties/manager'; import { CreatePropertyMenuItems } from '@affine/core/components/doc-properties/menu/create-doc-property'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import type { WorkspaceMetadata } from '@affine/core/modules/workspace'; import { Trans, useI18n } from '@affine/i18n'; import track from '@affine/track'; -import { - type DocCustomPropertyInfo, - FrameworkScope, - type WorkspaceMetadata, -} from '@toeverything/infra'; +import { FrameworkScope } from '@toeverything/infra'; import { useCallback } from 'react'; import { useWorkspace } from '../../../../../components/hooks/use-workspace'; diff --git a/packages/frontend/core/src/desktop/pages/index/index.tsx b/packages/frontend/core/src/desktop/pages/index/index.tsx index 819323a40fc0e..187c180eb5665 100644 --- a/packages/frontend/core/src/desktop/pages/index/index.tsx +++ b/packages/frontend/core/src/desktop/pages/index/index.tsx @@ -1,4 +1,5 @@ import { DesktopApiService } from '@affine/core/modules/desktop-api'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { buildShowcaseWorkspace, createFirstAppData, @@ -7,7 +8,6 @@ import { useLiveData, useService, useServiceOptional, - WorkspacesService, } from '@toeverything/infra'; import { type ReactNode, diff --git a/packages/frontend/core/src/desktop/pages/root/custom-theme/index.tsx b/packages/frontend/core/src/desktop/pages/root/custom-theme/index.tsx index 9451ae7ff9a62..f3922872b66bd 100644 --- a/packages/frontend/core/src/desktop/pages/root/custom-theme/index.tsx +++ b/packages/frontend/core/src/desktop/pages/root/custom-theme/index.tsx @@ -1,9 +1,6 @@ +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { ThemeEditorService } from '@affine/core/modules/theme-editor'; -import { - FeatureFlagService, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useTheme } from 'next-themes'; import { useEffect } from 'react'; diff --git a/packages/frontend/core/src/desktop/pages/root/index.tsx b/packages/frontend/core/src/desktop/pages/root/index.tsx index 9c22d23248ce4..0b7aff417d611 100644 --- a/packages/frontend/core/src/desktop/pages/root/index.tsx +++ b/packages/frontend/core/src/desktop/pages/root/index.tsx @@ -1,10 +1,7 @@ import { NotificationCenter } from '@affine/component'; import { DefaultServerService } from '@affine/core/modules/cloud'; -import { - FrameworkScope, - GlobalContextService, - useService, -} from '@toeverything/infra'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { FrameworkScope, useService } from '@toeverything/infra'; import { useEffect, useState } from 'react'; import { Outlet } from 'react-router-dom'; diff --git a/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx b/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx index cd404980ee0cb..35c694c938bda 100644 --- a/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx +++ b/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx @@ -13,17 +13,16 @@ import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hoo import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; import { PureWorkspaceCard } from '@affine/core/components/workspace-selector/workspace-card'; import { AuthService } from '@affine/core/modules/cloud'; +import { + type WorkspaceMetadata, + WorkspacesService, +} from '@affine/core/modules/workspace'; import { buildShowcaseWorkspace } from '@affine/core/utils/first-app-data'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql'; import { type I18nString, Trans, useI18n } from '@affine/i18n'; import { DoneIcon, NewPageIcon } from '@blocksuite/icons/rc'; -import { - useLiveData, - useService, - type WorkspaceMetadata, - WorkspacesService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useMemo, useState } from 'react'; import { useSearchParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/all-collection/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/all-collection/index.tsx index d102027b17fcd..267e341f3e9d9 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/all-collection/index.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/all-collection/index.tsx @@ -10,8 +10,9 @@ import { ViewIcon, ViewTitle, } from '@affine/core/modules/workbench/view/view-meta'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { nanoid } from 'nanoid'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-filter.tsx b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-filter.tsx index 7975a32b1d5ed..a4c50adc19f8a 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-filter.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-filter.tsx @@ -1,6 +1,7 @@ import { CollectionService } from '@affine/core/modules/collection'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Collection, Filter } from '@affine/env/filter'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback } from 'react'; import { filterContainerStyle } from '../../../../components/filter-container.css'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-header.tsx b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-header.tsx index 8896f1ec401f0..9bccaad0f1762 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-header.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-header.tsx @@ -8,11 +8,12 @@ import { Header } from '@affine/core/components/pure/header'; import { WorkspaceModeFilterTab } from '@affine/core/components/pure/workspace-mode-filter-tab'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { isNewTabTrigger } from '@affine/core/utils'; import type { Filter } from '@affine/env/filter'; import { track } from '@affine/track'; import { PlusIcon } from '@blocksuite/icons/rc'; -import { useServices, WorkspaceService } from '@toeverything/infra'; +import { useServices } from '@toeverything/infra'; import clsx from 'clsx'; import { useCallback } from 'react'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx index 0c6c032a0bc7a..db690a12617c5 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx @@ -4,13 +4,11 @@ import { useFilteredPageMetas, VirtualizedPageList, } from '@affine/core/components/page-list'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Filter } from '@affine/env/filter'; import { useI18n } from '@affine/i18n'; -import { - GlobalContextService, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useEffect, useState } from 'react'; import { diff --git a/packages/frontend/core/src/desktop/pages/workspace/attachment/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/attachment/index.tsx index 5f042fe7a3809..da04ac40ae86c 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/attachment/index.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/attachment/index.tsx @@ -1,12 +1,7 @@ import { Skeleton } from '@affine/component'; +import { type Doc, DocsService } from '@affine/core/modules/doc'; import { type AttachmentBlockModel } from '@blocksuite/affine/blocks'; -import { - type Doc, - DocsService, - FrameworkScope, - useLiveData, - useService, -} from '@toeverything/infra'; +import { FrameworkScope, useLiveData, useService } from '@toeverything/infra'; import { type ReactElement, useLayoutEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/collection/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/collection/index.tsx index 61cf826f63127..11eb3b852d205 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/collection/index.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/collection/index.tsx @@ -3,16 +3,12 @@ import { EmptyCollectionDetail } from '@affine/core/components/affine/empty/coll import { VirtualizedPageList } from '@affine/core/components/page-list'; import { CollectionService } from '@affine/core/modules/collection'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Collection } from '@affine/env/filter'; import { useI18n } from '@affine/i18n'; import { ViewLayersIcon } from '@blocksuite/icons/rc'; -import { - GlobalContextService, - useLiveData, - useService, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import { useCallback, useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx index bbe446b366c24..233f04eb50c35 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx @@ -20,11 +20,12 @@ import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { EditorService } from '@affine/core/modules/editor'; import { JournalService } from '@affine/core/modules/journal'; import { ViewIcon, ViewTitle } from '@affine/core/modules/workbench'; +import type { Workspace } from '@affine/core/modules/workspace'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import type { Doc } from '@blocksuite/affine/store'; -import { useLiveData, useService, type Workspace } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { forwardRef, useCallback, useEffect, useRef, useState } from 'react'; import * as styles from './detail-page-header.css'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-wrapper.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-wrapper.tsx index 640b4db16bd27..2468461c0122a 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-wrapper.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-wrapper.tsx @@ -1,14 +1,9 @@ +import { type Doc, DocsService } from '@affine/core/modules/doc'; import type { Editor } from '@affine/core/modules/editor'; import { EditorsService } from '@affine/core/modules/editor'; import { ViewService } from '@affine/core/modules/workbench/services/view'; -import type { Doc } from '@toeverything/infra'; -import { - DocsService, - FrameworkScope, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { FrameworkScope, useLiveData, useService } from '@toeverything/infra'; import { type PropsWithChildren, type ReactNode, diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx index 3b2dd82e6366a..716ee695a5b81 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx @@ -7,9 +7,13 @@ import { EditorOutlineViewer } from '@affine/core/components/blocksuite/outline- import { DocPropertySidebar } from '@affine/core/components/doc-properties/sidebar'; import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper'; import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-page-meta'; +import { DocService } from '@affine/core/modules/doc'; import { EditorService } from '@affine/core/modules/editor'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { RecentDocsService } from '@affine/core/modules/quicksearch'; -import { ViewService } from '@affine/core/modules/workbench/services/view'; +import { ViewService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { RefNodeSlotsProvider } from '@blocksuite/affine/blocks'; import { DisposableGroup } from '@blocksuite/affine/global/utils'; import { type AffineEditorContainer } from '@blocksuite/affine/presets'; @@ -21,14 +25,10 @@ import { TodayIcon, } from '@blocksuite/icons/rc'; import { - DocService, - FeatureFlagService, FrameworkScope, - GlobalContextService, useLiveData, useService, useServices, - WorkspaceService, } from '@toeverything/infra'; import clsx from 'clsx'; import { memo, useCallback, useEffect, useRef, useState } from 'react'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/journal.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/journal.tsx index b21460eaac6b2..a278efca06a95 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/journal.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/journal.tsx @@ -10,18 +10,17 @@ import { } from '@affine/component'; import { useJournalRouteHelper } from '@affine/core/components/hooks/use-journal'; import { MoveToTrash } from '@affine/core/components/page-list'; +import { + type DocRecord, + DocService, + DocsService, +} from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { JournalService } from '@affine/core/modules/journal'; import { WorkbenchLink } from '@affine/core/modules/workbench'; import { useI18n } from '@affine/i18n'; import { CalendarXmarkIcon, EditIcon } from '@blocksuite/icons/rc'; -import type { DocRecord } from '@toeverything/infra'; -import { - DocService, - DocsService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { assignInlineVars } from '@vanilla-extract/dynamic'; import clsx from 'clsx'; import dayjs from 'dayjs'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/index.tsx index 4d3d46c222203..49f3b98f0d4c8 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/index.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/index.tsx @@ -6,15 +6,18 @@ import { WorkspaceServerService, } from '@affine/core/modules/cloud'; import { DndService } from '@affine/core/modules/dnd/services'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { + type Workspace, + type WorkspaceMetadata, + WorkspacesService, +} from '@affine/core/modules/workspace'; import { ZipTransformer } from '@blocksuite/affine/blocks'; -import type { Workspace, WorkspaceMetadata } from '@toeverything/infra'; import { FrameworkScope, - GlobalContextService, useLiveData, useService, useServices, - WorkspacesService, } from '@toeverything/infra'; import type { PropsWithChildren, ReactElement } from 'react'; import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; @@ -31,11 +34,11 @@ declare global { /** * @internal debug only */ - // eslint-disable-next-line no-var + // oxlint-disable-next-line no-var var currentWorkspace: Workspace | undefined; - // eslint-disable-next-line no-var + // oxlint-disable-next-line no-var var exportWorkspaceSnapshot: (docs?: string[]) => Promise; - // eslint-disable-next-line no-var + // oxlint-disable-next-line no-var var importWorkspaceSnapshot: () => Promise; interface WindowEventMap { 'affine:workspace:change': CustomEvent<{ id: string }>; diff --git a/packages/frontend/core/src/desktop/pages/workspace/layouts/workspace-layout.tsx b/packages/frontend/core/src/desktop/pages/workspace/layouts/workspace-layout.tsx index 38b5ee51b5a2e..f287d6671fbb4 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/layouts/workspace-layout.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/layouts/workspace-layout.tsx @@ -12,12 +12,8 @@ import { WorkspaceDialogs } from '@affine/core/desktop/dialogs'; import { PeekViewManagerModal } from '@affine/core/modules/peek-view'; import { QuotaCheck } from '@affine/core/modules/quota'; import { WorkbenchService } from '@affine/core/modules/workbench'; -import { - LiveData, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { LiveData, useLiveData, useService } from '@toeverything/infra'; import type { PropsWithChildren } from 'react'; export const WorkspaceLayout = function WorkspaceLayout({ diff --git a/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx index 8d4219960a702..c53adc0873b68 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx @@ -10,6 +10,7 @@ import { FetchService, GraphQLService, } from '@affine/core/modules/cloud'; +import { type Doc, DocsService } from '@affine/core/modules/doc'; import { type Editor, type EditorSelector, @@ -19,6 +20,10 @@ import { import { PeekViewManagerModal } from '@affine/core/modules/peek-view'; import { ShareReaderService } from '@affine/core/modules/share-doc'; import { ViewIcon, ViewTitle } from '@affine/core/modules/workbench'; +import { + type Workspace, + WorkspacesService, +} from '@affine/core/modules/workspace'; import { CloudBlobStorage } from '@affine/core/modules/workspace-engine'; import { useI18n } from '@affine/i18n'; import { @@ -29,16 +34,13 @@ import { import type { AffineEditorContainer } from '@blocksuite/affine/presets'; import { DisposableGroup } from '@blocksuite/global/utils'; import { Logo1Icon } from '@blocksuite/icons/rc'; -import type { Doc, Workspace } from '@toeverything/infra'; import { - DocsService, EmptyBlobStorage, FrameworkScope, ReadonlyDocStorage, useLiveData, useService, useServices, - WorkspacesService, } from '@toeverything/infra'; import clsx from 'clsx'; import { diff --git a/packages/frontend/core/src/desktop/pages/workspace/tag/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/tag/index.tsx index 5736e69661a7d..cf7d355d65fd0 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/tag/index.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/tag/index.tsx @@ -3,6 +3,7 @@ import { TagPageListHeader, VirtualizedPageList, } from '@affine/core/components/page-list'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { TagService } from '@affine/core/modules/tag'; import { useIsActiveView, @@ -11,12 +12,8 @@ import { ViewIcon, ViewTitle, } from '@affine/core/modules/workbench'; -import { - GlobalContextService, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect, useMemo } from 'react'; import { useParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/desktop/pages/workspace/trash-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/trash-page.tsx index ee39e6c0c61d6..8886a11a88617 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/trash-page.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/trash-page.tsx @@ -4,14 +4,12 @@ import { VirtualizedTrashList, } from '@affine/core/components/page-list'; import { Header } from '@affine/core/components/pure/header'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { assertExists } from '@blocksuite/affine/global/utils'; import { DeleteIcon } from '@blocksuite/icons/rc'; -import { - GlobalContextService, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useEffect } from 'react'; import { diff --git a/packages/frontend/core/src/mobile/components/app-tabs/create.tsx b/packages/frontend/core/src/mobile/components/app-tabs/create.tsx index 94681eb6c0d0b..1c638b6202992 100644 --- a/packages/frontend/core/src/mobile/components/app-tabs/create.tsx +++ b/packages/frontend/core/src/mobile/components/app-tabs/create.tsx @@ -1,8 +1,9 @@ import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import track from '@affine/track'; import { EditIcon } from '@blocksuite/icons/rc'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import { useCallback } from 'react'; import type { AppTabCustomFCProps } from './data'; diff --git a/packages/frontend/core/src/mobile/components/app-tabs/tab-item.tsx b/packages/frontend/core/src/mobile/components/app-tabs/tab-item.tsx index f5194ddd2a848..c4297062bc1c3 100644 --- a/packages/frontend/core/src/mobile/components/app-tabs/tab-item.tsx +++ b/packages/frontend/core/src/mobile/components/app-tabs/tab-item.tsx @@ -1,9 +1,5 @@ -import { - GlobalCacheService, - LiveData, - useLiveData, - useService, -} from '@toeverything/infra'; +import { GlobalCacheService } from '@affine/core/modules/storage'; +import { LiveData, useLiveData, useService } from '@toeverything/infra'; import { type PropsWithChildren, useCallback, useMemo } from 'react'; import { tabItem } from './styles.css'; diff --git a/packages/frontend/core/src/mobile/components/doc-info/doc-info.tsx b/packages/frontend/core/src/mobile/components/doc-info/doc-info.tsx index a959a7ce9464c..a86d00afd163a 100644 --- a/packages/frontend/core/src/mobile/components/doc-info/doc-info.tsx +++ b/packages/frontend/core/src/mobile/components/doc-info/doc-info.tsx @@ -13,17 +13,13 @@ import { import { CreatePropertyMenuItems } from '@affine/core/components/doc-properties/menu/create-doc-property'; import { LinksRow } from '@affine/core/desktop/dialogs/doc-info/links-row'; import { TimeRow } from '@affine/core/desktop/dialogs/doc-info/time-row'; +import type { DocCustomPropertyInfo } from '@affine/core/modules/db'; +import { DocsService } from '@affine/core/modules/doc'; import { DocDatabaseBacklinkInfo } from '@affine/core/modules/doc-info'; import { DocsSearchService } from '@affine/core/modules/docs-search'; import { useI18n } from '@affine/i18n'; import { PlusIcon } from '@blocksuite/icons/rc'; -import { - type DocCustomPropertyInfo, - DocsService, - LiveData, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { LiveData, useLiveData, useServices } from '@toeverything/infra'; import { Suspense, useCallback, useMemo, useState } from 'react'; import * as styles from './doc-info.css'; diff --git a/packages/frontend/core/src/mobile/components/doc-info/doc-scope.tsx b/packages/frontend/core/src/mobile/components/doc-info/doc-scope.tsx index 6643551ae0619..8a735c9dff7d8 100644 --- a/packages/frontend/core/src/mobile/components/doc-info/doc-scope.tsx +++ b/packages/frontend/core/src/mobile/components/doc-info/doc-scope.tsx @@ -1,5 +1,5 @@ -import type { Doc } from '@toeverything/infra'; -import { DocsService, FrameworkScope, useService } from '@toeverything/infra'; +import { type Doc, DocsService } from '@affine/core/modules/doc'; +import { FrameworkScope, useService } from '@toeverything/infra'; import { type PropsWithChildren, useEffect, useState } from 'react'; export const DocFrameScope = ({ diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/collection/index.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/collection/index.tsx index 2426edbd69621..645b9d0dc2dc0 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/collection/index.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/collection/index.tsx @@ -2,8 +2,10 @@ import { MenuItem, notify } from '@affine/component'; import { filterPage } from '@affine/core/components/page-list'; import { CollectionService } from '@affine/core/modules/collection'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import type { NodeOperation } from '@affine/core/modules/explorer'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { ShareDocsListService } from '@affine/core/modules/share-doc'; import type { Collection } from '@affine/env/filter'; import { PublicPageMode } from '@affine/graphql'; @@ -11,13 +13,7 @@ import { useI18n } from '@affine/i18n'; import track from '@affine/track'; import type { DocMeta } from '@blocksuite/affine/store'; import { FilterMinusIcon, ViewLayersIcon } from '@blocksuite/icons/rc'; -import { - DocsService, - GlobalContextService, - LiveData, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { LiveData, useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { AddItemPlaceholder } from '../../layouts/add-item-placeholder'; diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/collection/operations.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/collection/operations.tsx index 1d803551090fe..468b0475b8d1f 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/collection/operations.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/collection/operations.tsx @@ -11,7 +11,9 @@ import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; import { CollectionService } from '@affine/core/modules/collection'; import type { NodeOperation } from '@affine/core/modules/explorer'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { @@ -21,12 +23,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import { CollectionRenameSubMenu } from './dialog'; diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/doc/index.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/doc/index.tsx index e3a86ba0bed9d..0a957c83101f8 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/doc/index.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/doc/index.tsx @@ -1,13 +1,13 @@ import { Loading } from '@affine/component'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { DocsSearchService } from '@affine/core/modules/docs-search'; import type { NodeOperation } from '@affine/core/modules/explorer'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { useI18n } from '@affine/i18n'; import { - DocsService, - FeatureFlagService, - GlobalContextService, LiveData, useLiveData, useService, diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/doc/operations.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/doc/operations.tsx index a2fcf793a0e66..3f8f38150ea92 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/doc/operations.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/doc/operations.tsx @@ -10,9 +10,12 @@ import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-pa import { useBlockSuiteMetaHelper } from '@affine/core/components/hooks/affine/use-block-suite-meta-helper'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; +import { DocsService } from '@affine/core/modules/doc'; import type { NodeOperation } from '@affine/core/modules/explorer'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { preventDefault } from '@affine/core/utils'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; @@ -25,14 +28,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - DocsService, - FeatureFlagService, - useLiveData, - useService, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import { DocFrameScope, DocInfoSheet } from '../../../doc-info'; diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/folder/index.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/folder/index.tsx index bf0e0bc74cb83..2e8a6b1aceb35 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/folder/index.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/folder/index.tsx @@ -13,10 +13,12 @@ import type { NodeOperation, } from '@affine/core/modules/explorer'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { type FolderNode, OrganizeService, } from '@affine/core/modules/organize'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; import { @@ -29,12 +31,7 @@ import { RemoveFolderIcon, TagsIcon, } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { difference } from 'lodash-es'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/tag/index.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/tag/index.tsx index 271ab27625535..404b0dae0e10d 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/tag/index.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/tag/index.tsx @@ -1,12 +1,9 @@ import type { NodeOperation } from '@affine/core/modules/explorer'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import type { Tag } from '@affine/core/modules/tag'; import { TagService } from '@affine/core/modules/tag'; import { useI18n } from '@affine/i18n'; -import { - GlobalContextService, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import clsx from 'clsx'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/mobile/components/explorer/nodes/tag/operations.tsx b/packages/frontend/core/src/mobile/components/explorer/nodes/tag/operations.tsx index e98793836e248..cc53c9d5353a6 100644 --- a/packages/frontend/core/src/mobile/components/explorer/nodes/tag/operations.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/nodes/tag/operations.tsx @@ -8,10 +8,14 @@ import { import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils'; import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import type { NodeOperation } from '@affine/core/modules/explorer'; import { FavoriteService } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { GlobalCacheService } from '@affine/core/modules/storage'; import { TagService } from '@affine/core/modules/tag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { @@ -20,15 +24,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - DocsService, - FeatureFlagService, - GlobalCacheService, - useLiveData, - useService, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import { TagRenameSubMenu } from './dialog'; diff --git a/packages/frontend/core/src/mobile/components/explorer/sections/favorites/index.tsx b/packages/frontend/core/src/mobile/components/explorer/sections/favorites/index.tsx index 4343501ca3f90..1c0aebb47bd80 100644 --- a/packages/frontend/core/src/mobile/components/explorer/sections/favorites/index.tsx +++ b/packages/frontend/core/src/mobile/components/explorer/sections/favorites/index.tsx @@ -5,12 +5,9 @@ import { } from '@affine/core/modules/explorer'; import type { FavoriteSupportTypeUnion } from '@affine/core/modules/favorite'; import { FavoriteService } from '@affine/core/modules/favorite'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; -import { - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback } from 'react'; import { AddItemPlaceholder } from '../../layouts/add-item-placeholder'; diff --git a/packages/frontend/core/src/mobile/components/workspace-selector/current-card.tsx b/packages/frontend/core/src/mobile/components/workspace-selector/current-card.tsx index 515af7de59276..5a153219fabe5 100644 --- a/packages/frontend/core/src/mobile/components/workspace-selector/current-card.tsx +++ b/packages/frontend/core/src/mobile/components/workspace-selector/current-card.tsx @@ -1,9 +1,10 @@ import { Avatar } from '@affine/component'; -import { WorkspaceAvatar } from '@affine/component/workspace-avatar'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; +import { WorkspaceAvatar } from '@affine/core/components/workspace-avatar'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant'; import { ArrowDownSmallIcon } from '@blocksuite/icons/rc'; -import { useServiceOptional, WorkspaceService } from '@toeverything/infra'; +import { useServiceOptional } from '@toeverything/infra'; import clsx from 'clsx'; import { forwardRef, type HTMLAttributes } from 'react'; diff --git a/packages/frontend/core/src/mobile/components/workspace-selector/index.tsx b/packages/frontend/core/src/mobile/components/workspace-selector/index.tsx index 6b6213c6eae6f..8a52ae63c11a7 100644 --- a/packages/frontend/core/src/mobile/components/workspace-selector/index.tsx +++ b/packages/frontend/core/src/mobile/components/workspace-selector/index.tsx @@ -1,6 +1,7 @@ import { MobileMenu } from '@affine/component'; +import { WorkspacesService } from '@affine/core/modules/workspace'; import { track } from '@affine/track'; -import { useServiceOptional, WorkspacesService } from '@toeverything/infra'; +import { useServiceOptional } from '@toeverything/infra'; import { forwardRef, type HTMLAttributes, diff --git a/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx b/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx index 5d21ac7caed32..966fd390c3c2e 100644 --- a/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx +++ b/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx @@ -1,15 +1,14 @@ import { IconButton } from '@affine/component'; -import { WorkspaceAvatar } from '@affine/component/workspace-avatar'; import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper'; import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info'; -import { CloseIcon, CollaborationIcon } from '@blocksuite/icons/rc'; +import { WorkspaceAvatar } from '@affine/core/components/workspace-avatar'; import { - useLiveData, - useService, type WorkspaceMetadata, WorkspaceService, WorkspacesService, -} from '@toeverything/infra'; +} from '@affine/core/modules/workspace'; +import { CloseIcon, CollaborationIcon } from '@blocksuite/icons/rc'; +import { useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import { type HTMLAttributes, useCallback, useMemo } from 'react'; diff --git a/packages/frontend/core/src/mobile/dialogs/selectors/doc-selector.tsx b/packages/frontend/core/src/mobile/dialogs/selectors/doc-selector.tsx index 652707b584b40..66996fd9754f8 100644 --- a/packages/frontend/core/src/mobile/dialogs/selectors/doc-selector.tsx +++ b/packages/frontend/core/src/mobile/dialogs/selectors/doc-selector.tsx @@ -3,9 +3,10 @@ import type { DialogComponentProps, WORKSPACE_DIALOG_SCHEMA, } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { useI18n } from '@affine/i18n'; -import { DocsService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { cssVarV2 } from '@toeverything/theme/v2'; import { useMemo } from 'react'; diff --git a/packages/frontend/core/src/mobile/dialogs/setting/experimental/index.tsx b/packages/frontend/core/src/mobile/dialogs/setting/experimental/index.tsx index be57480425884..19c3d3a5c44fe 100644 --- a/packages/frontend/core/src/mobile/dialogs/setting/experimental/index.tsx +++ b/packages/frontend/core/src/mobile/dialogs/setting/experimental/index.tsx @@ -1,13 +1,12 @@ import { Switch } from '@affine/component'; -import { useI18n } from '@affine/i18n'; -import { ArrowRightSmallIcon } from '@blocksuite/icons/rc'; import { AFFINE_FLAGS, FeatureFlagService, type Flag, - useLiveData, - useService, -} from '@toeverything/infra'; +} from '@affine/core/modules/feature-flag'; +import { useI18n } from '@affine/i18n'; +import { ArrowRightSmallIcon } from '@blocksuite/icons/rc'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useState } from 'react'; import { SettingGroup } from '../group'; diff --git a/packages/frontend/core/src/mobile/modules/search/index.ts b/packages/frontend/core/src/mobile/modules/search/index.ts index b4984f20b8dd3..5c6e1ddebabbe 100644 --- a/packages/frontend/core/src/mobile/modules/search/index.ts +++ b/packages/frontend/core/src/mobile/modules/search/index.ts @@ -1,4 +1,5 @@ -import { type Framework, WorkspaceScope } from '@toeverything/infra'; +import { WorkspaceScope } from '@affine/core/modules/workspace'; +import { type Framework } from '@toeverything/infra'; import { MobileSearchService } from './service/search'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/collection/detail.tsx b/packages/frontend/core/src/mobile/pages/workspace/collection/detail.tsx index 814954ee3ca59..1259f94c944a5 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/collection/detail.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/collection/detail.tsx @@ -1,12 +1,9 @@ import { notify, useThemeColorV2 } from '@affine/component'; import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper'; import { CollectionService } from '@affine/core/modules/collection'; -import { - GlobalContextService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { GlobalContextService } from '@affine/core/modules/global-context'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useEffect } from 'react'; import { useParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/journal-conflict-block.tsx b/packages/frontend/core/src/mobile/pages/workspace/detail/journal-conflict-block.tsx index ec007e73421ab..bac0632bc9b50 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/detail/journal-conflict-block.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/detail/journal-conflict-block.tsx @@ -1,11 +1,11 @@ import { IconButton, Menu } from '@affine/component'; +import { type DocRecord, DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { JournalService } from '@affine/core/modules/journal'; import { WorkbenchLink } from '@affine/core/modules/workbench'; import { useI18n } from '@affine/i18n'; import { EditIcon, TodayIcon } from '@blocksuite/icons/rc'; -import type { DocRecord } from '@toeverything/infra'; -import { DocsService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useMemo } from 'react'; import * as styles from './journal-conflict-block.css'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-conflicts.tsx b/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-conflicts.tsx index 53ee5379c1187..ec4d8b134aac8 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-conflicts.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-conflicts.tsx @@ -6,18 +6,17 @@ import { useConfirmModal, } from '@affine/component'; import { MoveToTrash } from '@affine/core/components/page-list'; +import { + type DocRecord, + DocService, + DocsService, +} from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { JournalService } from '@affine/core/modules/journal'; import { WorkbenchLink } from '@affine/core/modules/workbench'; import { useI18n } from '@affine/i18n'; import { CalendarXmarkIcon, EditIcon, TodayIcon } from '@blocksuite/icons/rc'; -import type { DocRecord } from '@toeverything/infra'; -import { - DocService, - DocsService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { type MouseEvent, useCallback, useMemo } from 'react'; import * as styles from './journal-conflicts.css'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-today-activity.tsx b/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-today-activity.tsx index a4942a144b6e4..7ffad30918b60 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-today-activity.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/detail/menu/journal-today-activity.tsx @@ -1,17 +1,16 @@ import { MenuItem, MenuSeparator, MobileMenuSub } from '@affine/component'; import { sortPagesByDate } from '@affine/core/desktop/pages/workspace/detail-page/tabs/journal'; +import { + type DocRecord, + DocService, + DocsService, +} from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { JournalService } from '@affine/core/modules/journal'; import { WorkbenchLink } from '@affine/core/modules/workbench'; import { useI18n } from '@affine/i18n'; import { HistoryIcon } from '@blocksuite/icons/rc'; -import type { DocRecord } from '@toeverything/infra'; -import { - DocService, - DocsService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import dayjs from 'dayjs'; import { type ReactNode, useCallback, useMemo } from 'react'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.tsx b/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.tsx index 055e5aace7c6f..342233b3b87c6 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.tsx @@ -10,11 +10,15 @@ import { PageDetailEditor } from '@affine/core/components/page-detail-editor'; import { DetailPageWrapper } from '@affine/core/desktop/pages/workspace/detail-page/detail-page-wrapper'; import { PageHeader } from '@affine/core/mobile/components'; import { useGlobalEvent } from '@affine/core/mobile/hooks/use-global-events'; +import { DocService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { EditorService } from '@affine/core/modules/editor'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { JournalService } from '@affine/core/modules/journal'; import { WorkbenchService } from '@affine/core/modules/workbench'; import { ViewService } from '@affine/core/modules/workbench/services/view'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { i18nTime } from '@affine/i18n'; import { BookmarkBlockService, @@ -28,14 +32,10 @@ import { import { DisposableGroup } from '@blocksuite/affine/global/utils'; import { type AffineEditorContainer } from '@blocksuite/affine/presets'; import { - DocService, - FeatureFlagService, FrameworkScope, - GlobalContextService, useLiveData, useService, useServices, - WorkspaceService, } from '@toeverything/infra'; import { cssVarV2 } from '@toeverything/theme/v2'; import clsx from 'clsx'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-more-button.tsx b/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-more-button.tsx index 56510085d9d00..32b538516981f 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-more-button.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-more-button.tsx @@ -9,6 +9,7 @@ import { useFavorite } from '@affine/core/components/blocksuite/block-suite-head import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; import { EditorOutlinePanel } from '@affine/core/desktop/pages/workspace/detail-page/tabs/outline'; import { DocInfoSheet } from '@affine/core/mobile/components'; +import { DocService } from '@affine/core/modules/doc'; import { EditorService } from '@affine/core/modules/editor'; import { ViewService } from '@affine/core/modules/workbench/services/view'; import { preventDefault } from '@affine/core/utils'; @@ -21,7 +22,7 @@ import { PageIcon, TocIcon, } from '@blocksuite/icons/rc'; -import { DocService, useLiveData, useService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useEffect, useState } from 'react'; import { JournalConflictsMenuItem } from './menu/journal-conflicts'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-share-button.tsx b/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-share-button.tsx index c1d83a980f052..dbd7daf545724 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-share-button.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/detail/page-header-share-button.tsx @@ -1,8 +1,10 @@ import { IconButton, MobileMenu } from '@affine/component'; import { SharePage } from '@affine/core/components/affine/share-page-modal/share-menu/share-page'; import { useEnableCloud } from '@affine/core/components/hooks/affine/use-enable-cloud'; +import { DocService } from '@affine/core/modules/doc'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { ShareiOsIcon } from '@blocksuite/icons/rc'; -import { DocService, useServices, WorkspaceService } from '@toeverything/infra'; +import { useServices } from '@toeverything/infra'; import * as styles from './page-header-share-button.css'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/index.tsx b/packages/frontend/core/src/mobile/pages/workspace/index.tsx index e172ce9ecb416..62036df3f5901 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/index.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/index.tsx @@ -2,11 +2,8 @@ import { AffineErrorBoundary } from '@affine/core/components/affine/affine-error import { AffineErrorComponent } from '@affine/core/components/affine/affine-error-boundary/affine-error-fallback'; import { PageNotFound } from '@affine/core/desktop/pages/404'; import { workbenchRoutes } from '@affine/core/mobile/workbench-router'; -import { - useLiveData, - useServices, - WorkspacesService, -} from '@toeverything/infra'; +import { WorkspacesService } from '@affine/core/modules/workspace'; +import { useLiveData, useServices } from '@toeverything/infra'; import { lazy as reactLazy, Suspense, diff --git a/packages/frontend/core/src/mobile/pages/workspace/layout.tsx b/packages/frontend/core/src/mobile/pages/workspace/layout.tsx index 565540505887f..e1f699cdf0bf4 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/layout.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/layout.tsx @@ -10,15 +10,14 @@ import { DefaultServerService, WorkspaceServerService, } from '@affine/core/modules/cloud'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { PeekViewManagerModal } from '@affine/core/modules/peek-view'; -import type { Workspace, WorkspaceMetadata } from '@toeverything/infra'; -import { - FrameworkScope, - GlobalContextService, - useLiveData, - useServices, - WorkspacesService, -} from '@toeverything/infra'; +import type { + Workspace, + WorkspaceMetadata, +} from '@affine/core/modules/workspace'; +import { WorkspacesService } from '@affine/core/modules/workspace'; +import { FrameworkScope, useLiveData, useServices } from '@toeverything/infra'; import { type PropsWithChildren, useEffect, diff --git a/packages/frontend/core/src/mobile/pages/workspace/tag/detail.tsx b/packages/frontend/core/src/mobile/pages/workspace/tag/detail.tsx index 25e7ffb79bc9d..f7a323b7dcf17 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/tag/detail.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/tag/detail.tsx @@ -1,11 +1,8 @@ import { useThemeColorV2 } from '@affine/component'; import { PageNotFound } from '@affine/core/desktop/pages/404'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { TagService } from '@affine/core/modules/tag'; -import { - GlobalContextService, - useLiveData, - useService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect } from 'react'; import { useParams } from 'react-router-dom'; diff --git a/packages/frontend/core/src/mobile/views/all-docs/doc/list.tsx b/packages/frontend/core/src/mobile/views/all-docs/doc/list.tsx index f8e37cdccbd7e..1dc26fd298531 100644 --- a/packages/frontend/core/src/mobile/views/all-docs/doc/list.tsx +++ b/packages/frontend/core/src/mobile/views/all-docs/doc/list.tsx @@ -6,11 +6,12 @@ import { useFilteredPageMetas, } from '@affine/core/components/page-list'; import type { Tag } from '@affine/core/modules/tag'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { Collection, Filter } from '@affine/env/filter'; import type { DocMeta } from '@blocksuite/affine/store'; import { ToggleExpandIcon } from '@blocksuite/icons/rc'; import * as Collapsible from '@radix-ui/react-collapsible'; -import { useLiveData, useService, WorkspaceService } from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useMemo } from 'react'; import * as styles from './list.css'; diff --git a/packages/frontend/core/src/mobile/views/recent-docs/index.tsx b/packages/frontend/core/src/mobile/views/recent-docs/index.tsx index 3d4f0e60f08d4..64d56e191ef07 100644 --- a/packages/frontend/core/src/mobile/views/recent-docs/index.tsx +++ b/packages/frontend/core/src/mobile/views/recent-docs/index.tsx @@ -1,5 +1,6 @@ import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-suite-page-meta'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { WorkspaceService } from '@affine/core/modules/workspace'; +import { useService } from '@toeverything/infra'; import { useMemo } from 'react'; import { DocCard } from '../../components/doc-card'; diff --git a/packages/frontend/core/src/modules/app-sidebar/impls/storage.ts b/packages/frontend/core/src/modules/app-sidebar/impls/storage.ts index 9261e692ff5f5..163b0056bb5bd 100644 --- a/packages/frontend/core/src/modules/app-sidebar/impls/storage.ts +++ b/packages/frontend/core/src/modules/app-sidebar/impls/storage.ts @@ -1,9 +1,6 @@ -import { - type GlobalState, - type Memento, - wrapMemento, -} from '@toeverything/infra'; +import { type Memento, wrapMemento } from '@toeverything/infra'; +import type { GlobalState } from '../../storage'; import type { AppSidebarState } from '../providers/storage'; export class AppSidebarStateImpl implements AppSidebarState { diff --git a/packages/frontend/core/src/modules/app-sidebar/index.ts b/packages/frontend/core/src/modules/app-sidebar/index.ts index 13dcd19facb09..7d7660d17bdf0 100644 --- a/packages/frontend/core/src/modules/app-sidebar/index.ts +++ b/packages/frontend/core/src/modules/app-sidebar/index.ts @@ -1,5 +1,6 @@ -import { type Framework, GlobalState } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { GlobalState } from '../storage'; import { AppSidebar } from './entities/app-sidebar'; import { AppSidebarStateImpl } from './impls/storage'; import { AppSidebarState } from './providers/storage'; diff --git a/packages/frontend/core/src/modules/app-sidebar/services/app-sidebar.ts b/packages/frontend/core/src/modules/app-sidebar/services/app-sidebar.ts index dafb93a619445..cb0f400e5b998 100644 --- a/packages/frontend/core/src/modules/app-sidebar/services/app-sidebar.ts +++ b/packages/frontend/core/src/modules/app-sidebar/services/app-sidebar.ts @@ -1,5 +1,6 @@ -import { GlobalState, Service } from '@toeverything/infra'; +import { Service } from '@toeverything/infra'; +import { GlobalState } from '../../storage'; import { AppSidebar } from '../entities/app-sidebar'; export class AppSidebarService extends Service { diff --git a/packages/frontend/core/src/modules/app-sidebar/views/add-page-button/index.tsx b/packages/frontend/core/src/modules/app-sidebar/views/add-page-button/index.tsx index 725bd23a87b24..f9f21d680505d 100644 --- a/packages/frontend/core/src/modules/app-sidebar/views/add-page-button/index.tsx +++ b/packages/frontend/core/src/modules/app-sidebar/views/add-page-button/index.tsx @@ -1,10 +1,11 @@ import { IconButton } from '@affine/component'; import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { isNewTabTrigger } from '@affine/core/utils'; import { useI18n } from '@affine/i18n'; import track from '@affine/track'; import { PlusIcon } from '@blocksuite/icons/rc'; -import { useService, WorkspaceService } from '@toeverything/infra'; +import { useService } from '@toeverything/infra'; import clsx from 'clsx'; import type React from 'react'; import { type MouseEvent, useCallback } from 'react'; diff --git a/packages/frontend/core/src/modules/app-sidebar/views/index.tsx b/packages/frontend/core/src/modules/app-sidebar/views/index.tsx index fad22d1074b28..9c254d74419c1 100644 --- a/packages/frontend/core/src/modules/app-sidebar/views/index.tsx +++ b/packages/frontend/core/src/modules/app-sidebar/views/index.tsx @@ -8,13 +8,13 @@ import { useLiveData, useService, useServiceOptional, - WorkspaceService, } from '@toeverything/infra'; import clsx from 'clsx'; import { debounce } from 'lodash-es'; import type { PropsWithChildren, ReactElement } from 'react'; import { useCallback, useContext, useEffect, useMemo, useState } from 'react'; +import { WorkspaceService } from '../../workspace'; import { AppSidebarService } from '../services/app-sidebar'; import * as styles from './fallback.css'; import { @@ -285,7 +285,7 @@ const RandomBars = ({ count, header }: { count: number; header?: boolean }) => { /> ) : null} {Array.from({ length: count }).map((_, index) => ( - // eslint-disable-next-line react/no-array-index-key + // oxlint-disable-next-line eslint-plugin-react(no-array-index-key) ))} diff --git a/packages/frontend/core/src/modules/at-menu-config/index.ts b/packages/frontend/core/src/modules/at-menu-config/index.ts index 32a89961b5ded..eca4fe7d3d4a2 100644 --- a/packages/frontend/core/src/modules/at-menu-config/index.ts +++ b/packages/frontend/core/src/modules/at-menu-config/index.ts @@ -1,16 +1,13 @@ -import { - DocsService, - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { WorkspaceDialogService } from '../dialogs'; +import { DocsService } from '../doc'; import { DocDisplayMetaService } from '../doc-display-meta'; import { DocsSearchService } from '../docs-search'; import { EditorSettingService } from '../editor-setting'; import { JournalService } from '../journal'; import { RecentDocsService } from '../quicksearch'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { AtMenuConfigService } from './services'; export function configAtMenuConfigModule(framework: Framework) { diff --git a/packages/frontend/core/src/modules/at-menu-config/services/index.ts b/packages/frontend/core/src/modules/at-menu-config/services/index.ts index 6679d8fa94d52..13456b5dfaa4d 100644 --- a/packages/frontend/core/src/modules/at-menu-config/services/index.ts +++ b/packages/frontend/core/src/modules/at-menu-config/services/index.ts @@ -18,18 +18,19 @@ import { } from '@blocksuite/icons/lit'; import type { DocMeta } from '@blocksuite/store'; import { signal } from '@preact/signals-core'; -import type { DocsService, WorkspaceService } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; import { cssVarV2 } from '@toeverything/theme/v2'; import { html } from 'lit'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import type { WorkspaceDialogService } from '../../dialogs'; +import type { DocsService } from '../../doc'; import type { DocDisplayMetaService } from '../../doc-display-meta'; import type { DocsSearchService } from '../../docs-search'; import type { EditorSettingService } from '../../editor-setting'; import { type JournalService, suggestJournalDate } from '../../journal'; import type { RecentDocsService } from '../../quicksearch'; +import type { WorkspaceService } from '../../workspace'; const MAX_DOCS = 3; const LOAD_CHUNK = 100; diff --git a/packages/frontend/core/src/modules/cloud/entities/cloud-doc-meta.ts b/packages/frontend/core/src/modules/cloud/entities/cloud-doc-meta.ts index 94e30a0f82534..3be12ff3ec04e 100644 --- a/packages/frontend/core/src/modules/cloud/entities/cloud-doc-meta.ts +++ b/packages/frontend/core/src/modules/cloud/entities/cloud-doc-meta.ts @@ -1,5 +1,4 @@ import type { GetWorkspacePageMetaByIdQuery } from '@affine/graphql'; -import type { DocService, GlobalCache } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -13,6 +12,8 @@ import { } from '@toeverything/infra'; import { EMPTY, mergeMap } from 'rxjs'; +import type { DocService } from '../../doc'; +import type { GlobalCache } from '../../storage'; import { isBackendError, isNetworkError } from '../error'; import type { CloudDocMetaStore } from '../stores/cloud-doc-meta'; diff --git a/packages/frontend/core/src/modules/cloud/entities/workspace-invoices.ts b/packages/frontend/core/src/modules/cloud/entities/workspace-invoices.ts index ab85f682457b4..ef2b1eaac8237 100644 --- a/packages/frontend/core/src/modules/cloud/entities/workspace-invoices.ts +++ b/packages/frontend/core/src/modules/cloud/entities/workspace-invoices.ts @@ -1,5 +1,4 @@ import type { InvoicesQuery } from '@affine/graphql'; -import type { WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -13,6 +12,7 @@ import { } from '@toeverything/infra'; import { EMPTY, map, mergeMap } from 'rxjs'; +import type { WorkspaceService } from '../../workspace'; import { isBackendError, isNetworkError } from '../error'; import type { WorkspaceServerService } from '../services/workspace-server'; import { InvoicesStore } from '../stores/invoices'; diff --git a/packages/frontend/core/src/modules/cloud/entities/workspace-subscription.ts b/packages/frontend/core/src/modules/cloud/entities/workspace-subscription.ts index 8c6f520950dad..a97640b98b5e8 100644 --- a/packages/frontend/core/src/modules/cloud/entities/workspace-subscription.ts +++ b/packages/frontend/core/src/modules/cloud/entities/workspace-subscription.ts @@ -1,6 +1,5 @@ import type { SubscriptionQuery, SubscriptionRecurring } from '@affine/graphql'; import { SubscriptionPlan } from '@affine/graphql'; -import type { WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -14,10 +13,10 @@ import { } from '@toeverything/infra'; import { EMPTY, mergeMap } from 'rxjs'; +import type { WorkspaceService } from '../../workspace'; import { isBackendError, isNetworkError } from '../error'; import type { WorkspaceServerService } from '../services/workspace-server'; import { SubscriptionStore } from '../stores/subscription'; - export type SubscriptionType = NonNullable< SubscriptionQuery['currentUser'] >['subscriptions'][number]; diff --git a/packages/frontend/core/src/modules/cloud/index.ts b/packages/frontend/core/src/modules/cloud/index.ts index ad32ebc1f952c..a6cc96b44f372 100644 --- a/packages/frontend/core/src/modules/cloud/index.ts +++ b/packages/frontend/core/src/modules/cloud/index.ts @@ -33,18 +33,12 @@ export { WorkspaceServerService } from './services/workspace-server'; export { WorkspaceSubscriptionService } from './services/workspace-subscription'; export type { ServerConfig } from './types'; -import { - DocScope, - DocService, - type Framework, - GlobalCache, - GlobalState, - GlobalStateService, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocScope, DocService } from '../doc'; +import { GlobalCache, GlobalState, GlobalStateService } from '../storage'; import { UrlService } from '../url'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { CloudDocMeta } from './entities/cloud-doc-meta'; import { Invoices } from './entities/invoices'; import { Server } from './entities/server'; diff --git a/packages/frontend/core/src/modules/cloud/services/auth.ts b/packages/frontend/core/src/modules/cloud/services/auth.ts index 7013127308ae1..9812bbbacad44 100644 --- a/packages/frontend/core/src/modules/cloud/services/auth.ts +++ b/packages/frontend/core/src/modules/cloud/services/auth.ts @@ -1,9 +1,10 @@ import { AIProvider } from '@affine/core/blocksuite/presets/ai'; import type { OAuthProviderType } from '@affine/graphql'; import { track } from '@affine/track'; -import { ApplicationFocused, OnEvent, Service } from '@toeverything/infra'; +import { OnEvent, Service } from '@toeverything/infra'; import { distinctUntilChanged, map, skip } from 'rxjs'; +import { ApplicationFocused } from '../../lifecycle'; import type { UrlService } from '../../url'; import { type AuthAccountInfo, AuthSession } from '../entities/session'; import { BackendError } from '../error'; diff --git a/packages/frontend/core/src/modules/cloud/services/websocket.ts b/packages/frontend/core/src/modules/cloud/services/websocket.ts index 6d6fefe9214cc..22db7ea20a1cf 100644 --- a/packages/frontend/core/src/modules/cloud/services/websocket.ts +++ b/packages/frontend/core/src/modules/cloud/services/websocket.ts @@ -1,6 +1,7 @@ -import { ApplicationStarted, OnEvent, Service } from '@toeverything/infra'; +import { OnEvent, Service } from '@toeverything/infra'; import { Manager } from 'socket.io-client'; +import { ApplicationStarted } from '../../lifecycle'; import { AccountChanged } from '../events/account-changed'; import type { WebSocketAuthProvider } from '../provider/websocket-auth'; import type { AuthService } from './auth'; diff --git a/packages/frontend/core/src/modules/cloud/stores/auth.ts b/packages/frontend/core/src/modules/cloud/stores/auth.ts index 6e909c08bb5ee..b909e3885c0fe 100644 --- a/packages/frontend/core/src/modules/cloud/stores/auth.ts +++ b/packages/frontend/core/src/modules/cloud/stores/auth.ts @@ -3,9 +3,9 @@ import { updateUserProfileMutation, uploadAvatarMutation, } from '@affine/graphql'; -import type { GlobalState } from '@toeverything/infra'; import { Store } from '@toeverything/infra'; +import type { GlobalState } from '../../storage'; import type { AuthSessionInfo } from '../entities/session'; import type { FetchService } from '../services/fetch'; import type { GraphQLService } from '../services/graphql'; diff --git a/packages/frontend/core/src/modules/cloud/stores/server-list.ts b/packages/frontend/core/src/modules/cloud/stores/server-list.ts index 8b7cf1d13c0d3..690a2851a6ae9 100644 --- a/packages/frontend/core/src/modules/cloud/stores/server-list.ts +++ b/packages/frontend/core/src/modules/cloud/stores/server-list.ts @@ -1,7 +1,7 @@ -import type { GlobalStateService } from '@toeverything/infra'; import { Store } from '@toeverything/infra'; import { map } from 'rxjs'; +import type { GlobalStateService } from '../../storage'; import { BUILD_IN_SERVERS } from '../constant'; import type { ServerConfig, ServerMetadata } from '../types'; diff --git a/packages/frontend/core/src/modules/cloud/stores/subscription.ts b/packages/frontend/core/src/modules/cloud/stores/subscription.ts index 637e6c4befe12..c2d5a1d844eb0 100644 --- a/packages/frontend/core/src/modules/cloud/stores/subscription.ts +++ b/packages/frontend/core/src/modules/cloud/stores/subscription.ts @@ -12,14 +12,13 @@ import { subscriptionQuery, updateSubscriptionMutation, } from '@affine/graphql'; -import type { GlobalCache } from '@toeverything/infra'; import { Store } from '@toeverything/infra'; +import type { GlobalCache } from '../../storage'; import type { UrlService } from '../../url'; import type { SubscriptionType } from '../entities/subscription'; import type { GraphQLService } from '../services/graphql'; import type { ServerService } from '../services/server'; - const SUBSCRIPTION_CACHE_KEY = 'subscription:'; const getDefaultSubscriptionSuccessCallbackLink = ( diff --git a/packages/frontend/core/src/modules/collection/index.ts b/packages/frontend/core/src/modules/collection/index.ts index d33921f375b07..9fb608c6d29b6 100644 --- a/packages/frontend/core/src/modules/collection/index.ts +++ b/packages/frontend/core/src/modules/collection/index.ts @@ -1,11 +1,8 @@ export { CollectionService } from './services/collection'; -import { - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { CollectionService } from './services/collection'; export function configureCollectionModule(framework: Framework) { diff --git a/packages/frontend/core/src/modules/collection/services/collection.ts b/packages/frontend/core/src/modules/collection/services/collection.ts index 41d42ce202e27..de434461f05f4 100644 --- a/packages/frontend/core/src/modules/collection/services/collection.ts +++ b/packages/frontend/core/src/modules/collection/services/collection.ts @@ -3,11 +3,12 @@ import type { DeleteCollectionInfo, DeletedCollection, } from '@affine/env/filter'; -import type { WorkspaceService } from '@toeverything/infra'; import { LiveData, Service } from '@toeverything/infra'; import { Observable } from 'rxjs'; import { Array as YArray } from 'yjs'; +import type { WorkspaceService } from '../../workspace'; + const SETTING_KEY = 'setting'; const COLLECTIONS_KEY = 'collections'; diff --git a/packages/common/infra/src/modules/db/entities/db.ts b/packages/frontend/core/src/modules/db/entities/db.ts similarity index 87% rename from packages/common/infra/src/modules/db/entities/db.ts rename to packages/frontend/core/src/modules/db/entities/db.ts index feb2d33465d92..654a48aab2028 100644 --- a/packages/common/infra/src/modules/db/entities/db.ts +++ b/packages/frontend/core/src/modules/db/entities/db.ts @@ -1,5 +1,9 @@ -import { Entity } from '../../../framework'; -import type { DBSchemaBuilder, TableMap } from '../../../orm'; +import { + type DBSchemaBuilder, + Entity, + type TableMap, +} from '@toeverything/infra'; + import { WorkspaceDBTable } from './table'; export class WorkspaceDB extends Entity<{ diff --git a/packages/frontend/core/src/modules/db/entities/table.ts b/packages/frontend/core/src/modules/db/entities/table.ts new file mode 100644 index 0000000000000..27ba94d11428f --- /dev/null +++ b/packages/frontend/core/src/modules/db/entities/table.ts @@ -0,0 +1,39 @@ +import type { + Table as OrmTable, + TableSchemaBuilder, +} from '@toeverything/infra'; +import { Entity } from '@toeverything/infra'; + +import type { WorkspaceService } from '../../workspace'; + +export class WorkspaceDBTable< + Schema extends TableSchemaBuilder, +> extends Entity<{ + table: OrmTable; + storageDocId: string; +}> { + readonly table = this.props.table; + + constructor(private readonly workspaceService: WorkspaceService) { + super(); + } + + isSyncing$ = this.workspaceService.workspace.engine.doc + .docState$(this.props.storageDocId) + .map(docState => docState.syncing); + + isLoading$ = this.workspaceService.workspace.engine.doc + .docState$(this.props.storageDocId) + .map(docState => docState.loading); + + create = this.table.create.bind(this.table) as typeof this.table.create; + update = this.table.update.bind(this.table) as typeof this.table.update; + get = this.table.get.bind(this.table) as typeof this.table.get; + // eslint-disable-next-line rxjs/finnish + get$ = this.table.get$.bind(this.table) as typeof this.table.get$; + find = this.table.find.bind(this.table) as typeof this.table.find; + // eslint-disable-next-line rxjs/finnish + find$ = this.table.find$.bind(this.table) as typeof this.table.find$; + keys = this.table.keys.bind(this.table) as typeof this.table.keys; + delete = this.table.delete.bind(this.table) as typeof this.table.delete; +} diff --git a/packages/common/infra/src/modules/db/index.ts b/packages/frontend/core/src/modules/db/index.ts similarity index 92% rename from packages/common/infra/src/modules/db/index.ts rename to packages/frontend/core/src/modules/db/index.ts index c4825f2fa0fe9..7b62456b3b046 100644 --- a/packages/common/infra/src/modules/db/index.ts +++ b/packages/frontend/core/src/modules/db/index.ts @@ -1,4 +1,5 @@ -import type { Framework } from '../../framework'; +import type { Framework } from '@toeverything/infra'; + import { WorkspaceScope, WorkspaceService } from '../workspace'; import { WorkspaceDB } from './entities/db'; import { WorkspaceDBTable } from './entities/table'; diff --git a/packages/common/infra/src/modules/db/schema/index.ts b/packages/frontend/core/src/modules/db/schema/index.ts similarity index 100% rename from packages/common/infra/src/modules/db/schema/index.ts rename to packages/frontend/core/src/modules/db/schema/index.ts diff --git a/packages/common/infra/src/modules/db/schema/schema.ts b/packages/frontend/core/src/modules/db/schema/schema.ts similarity index 94% rename from packages/common/infra/src/modules/db/schema/schema.ts rename to packages/frontend/core/src/modules/db/schema/schema.ts index d917526dc611b..857cf20172bd6 100644 --- a/packages/common/infra/src/modules/db/schema/schema.ts +++ b/packages/frontend/core/src/modules/db/schema/schema.ts @@ -1,7 +1,11 @@ +import { + type DBSchemaBuilder, + f, + type ORMEntity, + t, +} from '@toeverything/infra'; import { nanoid } from 'nanoid'; -import { type DBSchemaBuilder, f, type ORMEntity, t } from '../../../orm'; - export const AFFiNE_WORKSPACE_DB_SCHEMA = { folders: { id: f.string().primaryKey().optional().default(nanoid), diff --git a/packages/common/infra/src/modules/db/services/db.ts b/packages/frontend/core/src/modules/db/services/db.ts similarity index 95% rename from packages/common/infra/src/modules/db/services/db.ts rename to packages/frontend/core/src/modules/db/services/db.ts index c7afa13684beb..624924caaa7d2 100644 --- a/packages/common/infra/src/modules/db/services/db.ts +++ b/packages/frontend/core/src/modules/db/services/db.ts @@ -1,9 +1,12 @@ +import { + createORMClient, + type DocStorage, + ObjectPool, + Service, + YjsDBAdapter, +} from '@toeverything/infra'; import { Doc as YDoc } from 'yjs'; -import { Service } from '../../../framework'; -import { createORMClient, YjsDBAdapter } from '../../../orm'; -import type { DocStorage } from '../../../sync'; -import { ObjectPool } from '../../../utils'; import type { WorkspaceService } from '../../workspace'; import { WorkspaceDB, type WorkspaceDBWithTables } from '../entities/db'; import { diff --git a/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts b/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts index e44a6e1ad59e6..9f2beb7783193 100644 --- a/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts +++ b/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts @@ -5,7 +5,7 @@ import { reactRouterV6BrowserTracingIntegration, setTags, } from '@sentry/react'; -import { ApplicationStarted, OnEvent, Service } from '@toeverything/infra'; +import { OnEvent, Service } from '@toeverything/infra'; import { debounce } from 'lodash-es'; import { useEffect } from 'react'; import { @@ -16,6 +16,7 @@ import { } from 'react-router-dom'; import { AuthService, DefaultServerService, ServersService } from '../../cloud'; +import { ApplicationStarted } from '../../lifecycle'; import type { DesktopApi } from '../entities/electron-api'; @OnEvent(ApplicationStarted, e => e.setupStartListener) diff --git a/packages/frontend/core/src/modules/dialogs/constant.ts b/packages/frontend/core/src/modules/dialogs/constant.ts index 795b295d6fb53..9bb6503bca1f6 100644 --- a/packages/frontend/core/src/modules/dialogs/constant.ts +++ b/packages/frontend/core/src/modules/dialogs/constant.ts @@ -1,5 +1,6 @@ import type { DocMode } from '@blocksuite/affine/blocks'; -import type { WorkspaceMetadata } from '@toeverything/infra'; + +import type { WorkspaceMetadata } from '../workspace'; export type SettingTab = | 'shortcuts' diff --git a/packages/frontend/core/src/modules/dialogs/index.ts b/packages/frontend/core/src/modules/dialogs/index.ts index a32db5bc59ca9..6d98a569ec1c4 100644 --- a/packages/frontend/core/src/modules/dialogs/index.ts +++ b/packages/frontend/core/src/modules/dialogs/index.ts @@ -1,6 +1,6 @@ import type { Framework } from '@toeverything/infra'; -import { WorkspaceScope } from '@toeverything/infra'; +import { WorkspaceScope } from '../workspace'; import { GlobalDialogService } from './services/dialog'; import { WorkspaceDialogService } from './services/workspace-dialog'; diff --git a/packages/frontend/core/src/modules/dnd/index.ts b/packages/frontend/core/src/modules/dnd/index.ts index b8334cda9e92b..fd9729ecefe36 100644 --- a/packages/frontend/core/src/modules/dnd/index.ts +++ b/packages/frontend/core/src/modules/dnd/index.ts @@ -1,10 +1,7 @@ -import { - DocsService, - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocsService } from '../doc'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { DndService } from './services'; export function configureDndModule(framework: Framework) { diff --git a/packages/frontend/core/src/modules/dnd/services/index.ts b/packages/frontend/core/src/modules/dnd/services/index.ts index 12d928a315e39..f02c7fdfa5520 100644 --- a/packages/frontend/core/src/modules/dnd/services/index.ts +++ b/packages/frontend/core/src/modules/dnd/services/index.ts @@ -8,10 +8,11 @@ import type { AffineDNDData } from '@affine/core/types/dnd'; import { BlockStdScope } from '@blocksuite/affine/block-std'; import { DndApiExtensionIdentifier } from '@blocksuite/affine/blocks'; import { type SliceSnapshot } from '@blocksuite/affine/store'; -import type { DocsService, WorkspaceService } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; +import type { DocsService } from '../../doc'; import { resolveLinkToDoc } from '../../navigation'; +import type { WorkspaceService } from '../../workspace'; type Entity = AffineDNDData['draggable']['entity']; type EntityResolver = (data: string) => Entity | null; diff --git a/packages/frontend/core/src/modules/doc-display-meta/index.ts b/packages/frontend/core/src/modules/doc-display-meta/index.ts index 1618b2bbba510..ad1832a8ee6b8 100644 --- a/packages/frontend/core/src/modules/doc-display-meta/index.ts +++ b/packages/frontend/core/src/modules/doc-display-meta/index.ts @@ -1,12 +1,10 @@ -import { - DocsService, - FeatureFlagService, - type Framework, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocsService } from '../doc'; +import { FeatureFlagService } from '../feature-flag'; import { I18nService } from '../i18n'; import { JournalService } from '../journal'; +import { WorkspaceScope } from '../workspace'; import { DocDisplayMetaService } from './services/doc-display-meta'; export { DocDisplayMetaService }; diff --git a/packages/frontend/core/src/modules/doc-display-meta/services/doc-display-meta.ts b/packages/frontend/core/src/modules/doc-display-meta/services/doc-display-meta.ts index 830d726c480ca..257218723e484 100644 --- a/packages/frontend/core/src/modules/doc-display-meta/services/doc-display-meta.ts +++ b/packages/frontend/core/src/modules/doc-display-meta/services/doc-display-meta.ts @@ -22,15 +22,12 @@ import { TomorrowIcon, YesterdayIcon, } from '@blocksuite/icons/rc'; -import type { - DocRecord, - DocsService, - FeatureFlagService, -} from '@toeverything/infra'; import { LiveData, Service } from '@toeverything/infra'; import type { Dayjs } from 'dayjs'; import dayjs from 'dayjs'; +import type { DocRecord, DocsService } from '../../doc'; +import type { FeatureFlagService } from '../../feature-flag'; import type { I18nService } from '../../i18n'; import type { JournalService } from '../../journal'; diff --git a/packages/frontend/core/src/modules/doc-info/index.ts b/packages/frontend/core/src/modules/doc-info/index.ts index 285155153ab46..b57fe794746d5 100644 --- a/packages/frontend/core/src/modules/doc-info/index.ts +++ b/packages/frontend/core/src/modules/doc-info/index.ts @@ -1,10 +1,8 @@ -import { - DocsService, - type Framework, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocsService } from '../doc/services/docs'; import { DocsSearchService } from '../docs-search'; +import { WorkspaceScope } from '../workspace'; import { DocDatabaseBacklinksService } from './services/doc-database-backlinks'; export { DocDatabaseBacklinkInfo } from './views/database-properties/doc-database-backlink-info'; diff --git a/packages/frontend/core/src/modules/doc-info/services/doc-database-backlinks.ts b/packages/frontend/core/src/modules/doc-info/services/doc-database-backlinks.ts index 6ed370db1d964..083d0523a8c9e 100644 --- a/packages/frontend/core/src/modules/doc-info/services/doc-database-backlinks.ts +++ b/packages/frontend/core/src/modules/doc-info/services/doc-database-backlinks.ts @@ -2,11 +2,11 @@ import { DatabaseBlockDataSource, type DatabaseBlockModel, } from '@blocksuite/affine/blocks'; -import type { DocsService } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; import { isEqual } from 'lodash-es'; import { combineLatest, distinctUntilChanged, map, Observable } from 'rxjs'; +import type { DocsService } from '../../doc'; import type { DocsSearchService } from '../../docs-search'; import type { DatabaseRow, DatabaseValueCell } from '../types'; import { signalToLiveData, signalToObservable } from '../utils'; diff --git a/packages/frontend/core/src/modules/doc-info/types.ts b/packages/frontend/core/src/modules/doc-info/types.ts index 48a62758a1ad8..ca94358e93e1c 100644 --- a/packages/frontend/core/src/modules/doc-info/types.ts +++ b/packages/frontend/core/src/modules/doc-info/types.ts @@ -1,5 +1,7 @@ import type { DatabaseBlockDataSource } from '@blocksuite/affine/blocks'; -import type { Doc, LiveData } from '@toeverything/infra'; +import type { LiveData } from '@toeverything/infra'; + +import type { Doc } from '../doc'; // make database property type to be compatible with DocCustomPropertyInfo export type DatabaseProperty> = { diff --git a/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx b/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx index db5918fe189b9..8d2616cb320fa 100644 --- a/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx +++ b/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx @@ -5,15 +5,11 @@ import { PropertyName, } from '@affine/component'; import { AffinePageReference } from '@affine/core/components/affine/reference-link'; +import { DocService } from '@affine/core/modules/doc'; import { useI18n } from '@affine/i18n'; import type { DatabaseBlockDataSource } from '@blocksuite/affine/blocks'; import { DatabaseTableViewIcon, PageIcon } from '@blocksuite/icons/rc'; -import { - DocService, - LiveData, - useLiveData, - useService, -} from '@toeverything/infra'; +import { LiveData, useLiveData, useService } from '@toeverything/infra'; import { Fragment, useMemo } from 'react'; import type { Observable } from 'rxjs'; diff --git a/packages/frontend/core/src/modules/doc-link/entities/doc-backlinks.ts b/packages/frontend/core/src/modules/doc-link/entities/doc-backlinks.ts index fbd0e7251a662..6fcf0ec33d7f5 100644 --- a/packages/frontend/core/src/modules/doc-link/entities/doc-backlinks.ts +++ b/packages/frontend/core/src/modules/doc-link/entities/doc-backlinks.ts @@ -1,6 +1,6 @@ -import type { DocService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; +import type { DocService } from '../../doc'; import type { DocsSearchService } from '../../docs-search'; export interface Backlink { diff --git a/packages/frontend/core/src/modules/doc-link/entities/doc-links.ts b/packages/frontend/core/src/modules/doc-link/entities/doc-links.ts index 0f76dbb1dbddb..e6a57db4ae505 100644 --- a/packages/frontend/core/src/modules/doc-link/entities/doc-links.ts +++ b/packages/frontend/core/src/modules/doc-link/entities/doc-links.ts @@ -1,6 +1,6 @@ -import type { DocService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; +import type { DocService } from '../../doc'; import type { DocsSearchService } from '../../docs-search'; export interface Link { diff --git a/packages/frontend/core/src/modules/doc-link/index.ts b/packages/frontend/core/src/modules/doc-link/index.ts index 6db0af6d1417c..c29edc022c5be 100644 --- a/packages/frontend/core/src/modules/doc-link/index.ts +++ b/packages/frontend/core/src/modules/doc-link/index.ts @@ -1,11 +1,9 @@ -import { - DocScope, - DocService, - type Framework, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocScope } from '../doc/scopes/doc'; +import { DocService } from '../doc/services/doc'; import { DocsSearchService } from '../docs-search'; +import { WorkspaceScope } from '../workspace'; import { DocBacklinks } from './entities/doc-backlinks'; import { DocLinks } from './entities/doc-links'; import { DocLinksService } from './services/doc-links'; diff --git a/packages/common/infra/src/modules/doc/constants.ts b/packages/frontend/core/src/modules/doc/constants.ts similarity index 100% rename from packages/common/infra/src/modules/doc/constants.ts rename to packages/frontend/core/src/modules/doc/constants.ts diff --git a/packages/common/infra/src/modules/doc/entities/doc.ts b/packages/frontend/core/src/modules/doc/entities/doc.ts similarity index 97% rename from packages/common/infra/src/modules/doc/entities/doc.ts rename to packages/frontend/core/src/modules/doc/entities/doc.ts index 9c06b7887d14d..8c2e50a08c327 100644 --- a/packages/common/infra/src/modules/doc/entities/doc.ts +++ b/packages/frontend/core/src/modules/doc/entities/doc.ts @@ -1,6 +1,6 @@ import type { DocMode, RootBlockModel } from '@blocksuite/affine/blocks'; +import { Entity } from '@toeverything/infra'; -import { Entity } from '../../../framework'; import type { WorkspaceService } from '../../workspace'; import type { DocScope } from '../scopes/doc'; import type { DocsStore } from '../stores/docs'; diff --git a/packages/common/infra/src/modules/doc/entities/property-list.ts b/packages/frontend/core/src/modules/doc/entities/property-list.ts similarity index 93% rename from packages/common/infra/src/modules/doc/entities/property-list.ts rename to packages/frontend/core/src/modules/doc/entities/property-list.ts index ee014be4c31a9..b7a146bc5d189 100644 --- a/packages/common/infra/src/modules/doc/entities/property-list.ts +++ b/packages/frontend/core/src/modules/doc/entities/property-list.ts @@ -1,6 +1,9 @@ -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; -import { generateFractionalIndexingKeyBetween } from '../../../utils'; +import { + Entity, + generateFractionalIndexingKeyBetween, + LiveData, +} from '@toeverything/infra'; + import type { DocCustomPropertyInfo } from '../../db/schema/schema'; import type { DocPropertiesStore } from '../stores/doc-properties'; diff --git a/packages/common/infra/src/modules/doc/entities/record-list.ts b/packages/frontend/core/src/modules/doc/entities/record-list.ts similarity index 95% rename from packages/common/infra/src/modules/doc/entities/record-list.ts rename to packages/frontend/core/src/modules/doc/entities/record-list.ts index df5e52daa1b20..35001dac84257 100644 --- a/packages/common/infra/src/modules/doc/entities/record-list.ts +++ b/packages/frontend/core/src/modules/doc/entities/record-list.ts @@ -1,8 +1,7 @@ import type { DocMode } from '@blocksuite/affine/blocks'; +import { Entity, LiveData } from '@toeverything/infra'; import { map } from 'rxjs'; -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; import type { DocsStore } from '../stores/docs'; import { DocRecord } from './record'; diff --git a/packages/common/infra/src/modules/doc/entities/record.ts b/packages/frontend/core/src/modules/doc/entities/record.ts similarity index 95% rename from packages/common/infra/src/modules/doc/entities/record.ts rename to packages/frontend/core/src/modules/doc/entities/record.ts index eeca7c59820b0..50f3f5d6a32b5 100644 --- a/packages/common/infra/src/modules/doc/entities/record.ts +++ b/packages/frontend/core/src/modules/doc/entities/record.ts @@ -1,8 +1,7 @@ import type { DocMode } from '@blocksuite/affine/blocks'; import type { DocMeta } from '@blocksuite/affine/store'; +import { Entity, LiveData } from '@toeverything/infra'; -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; import type { DocProperties } from '../../db'; import type { DocPropertiesStore } from '../stores/doc-properties'; import type { DocsStore } from '../stores/docs'; diff --git a/packages/common/infra/src/modules/doc/events/index.ts b/packages/frontend/core/src/modules/doc/events/index.ts similarity index 69% rename from packages/common/infra/src/modules/doc/events/index.ts rename to packages/frontend/core/src/modules/doc/events/index.ts index a7720e362eecc..b6475175956b0 100644 --- a/packages/common/infra/src/modules/doc/events/index.ts +++ b/packages/frontend/core/src/modules/doc/events/index.ts @@ -1,4 +1,5 @@ -import { createEvent } from '../../../framework'; +import { createEvent } from '@toeverything/infra'; + import type { DocRecord } from '../entities/record'; export const DocCreated = createEvent('DocCreated'); diff --git a/packages/common/infra/src/modules/doc/index.ts b/packages/frontend/core/src/modules/doc/index.ts similarity index 96% rename from packages/common/infra/src/modules/doc/index.ts rename to packages/frontend/core/src/modules/doc/index.ts index fdb8e4c877196..40c418b6cb614 100644 --- a/packages/common/infra/src/modules/doc/index.ts +++ b/packages/frontend/core/src/modules/doc/index.ts @@ -6,7 +6,8 @@ export { DocScope } from './scopes/doc'; export { DocService } from './services/doc'; export { DocsService } from './services/docs'; -import type { Framework } from '../../framework'; +import type { Framework } from '@toeverything/infra'; + import { WorkspaceDBService } from '../db'; import { WorkspaceScope, WorkspaceService } from '../workspace'; import { Doc } from './entities/doc'; diff --git a/packages/common/infra/src/modules/doc/scopes/doc.ts b/packages/frontend/core/src/modules/doc/scopes/doc.ts similarity index 84% rename from packages/common/infra/src/modules/doc/scopes/doc.ts rename to packages/frontend/core/src/modules/doc/scopes/doc.ts index 6ef46871d028a..ba8db10caf317 100644 --- a/packages/common/infra/src/modules/doc/scopes/doc.ts +++ b/packages/frontend/core/src/modules/doc/scopes/doc.ts @@ -1,6 +1,6 @@ import type { Doc as BlockSuiteDoc } from '@blocksuite/affine/store'; +import { Scope } from '@toeverything/infra'; -import { Scope } from '../../../framework'; import type { DocRecord } from '../entities/record'; export class DocScope extends Scope<{ diff --git a/packages/common/infra/src/modules/doc/services/doc.ts b/packages/frontend/core/src/modules/doc/services/doc.ts similarity index 74% rename from packages/common/infra/src/modules/doc/services/doc.ts rename to packages/frontend/core/src/modules/doc/services/doc.ts index cd79eb110535a..abdd10bc1c93c 100644 --- a/packages/common/infra/src/modules/doc/services/doc.ts +++ b/packages/frontend/core/src/modules/doc/services/doc.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import { Doc } from '../entities/doc'; export class DocService extends Service { diff --git a/packages/common/infra/src/modules/doc/services/docs.ts b/packages/frontend/core/src/modules/doc/services/docs.ts similarity index 95% rename from packages/common/infra/src/modules/doc/services/docs.ts rename to packages/frontend/core/src/modules/doc/services/docs.ts index 4b648a328a637..37fbfd3a80e7d 100644 --- a/packages/common/infra/src/modules/doc/services/docs.ts +++ b/packages/frontend/core/src/modules/doc/services/docs.ts @@ -3,10 +3,13 @@ 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 { + type DocProps, + initDocFromProps, + ObjectPool, + Service, +} from '@toeverything/infra'; -import { Service } from '../../../framework'; -import { type DocProps, initDocFromProps } from '../../../initialization'; -import { ObjectPool } from '../../../utils'; import type { Doc } from '../entities/doc'; import { DocPropertyList } from '../entities/property-list'; import { DocRecordList } from '../entities/record-list'; diff --git a/packages/common/infra/src/modules/doc/stores/doc-properties.ts b/packages/frontend/core/src/modules/doc/stores/doc-properties.ts similarity index 98% rename from packages/common/infra/src/modules/doc/stores/doc-properties.ts rename to packages/frontend/core/src/modules/doc/stores/doc-properties.ts index 197b5fb3017b9..b94e66a992e93 100644 --- a/packages/common/infra/src/modules/doc/stores/doc-properties.ts +++ b/packages/frontend/core/src/modules/doc/stores/doc-properties.ts @@ -1,12 +1,8 @@ +import { Store, yjsObserveByPath, yjsObserveDeep } from '@toeverything/infra'; import { differenceBy, isNil, omitBy } from 'lodash-es'; import { combineLatest, map, switchMap } from 'rxjs'; import { AbstractType as YAbstractType } from 'yjs'; -import { Store } from '../../../framework'; -import { - yjsObserveByPath, - yjsObserveDeep, -} from '../../../utils/yjs-observable'; import type { WorkspaceDBService } from '../../db'; import type { DocCustomPropertyInfo, diff --git a/packages/common/infra/src/modules/doc/stores/docs.ts b/packages/frontend/core/src/modules/doc/stores/docs.ts similarity index 96% rename from packages/common/infra/src/modules/doc/stores/docs.ts rename to packages/frontend/core/src/modules/doc/stores/docs.ts index 4df36193770a3..0fd6c1f78107a 100644 --- a/packages/common/infra/src/modules/doc/stores/docs.ts +++ b/packages/frontend/core/src/modules/doc/stores/docs.ts @@ -1,10 +1,14 @@ import type { DocMode } from '@blocksuite/affine/blocks'; import type { DocMeta } from '@blocksuite/affine/store'; +import { + Store, + yjsObserve, + yjsObserveByPath, + yjsObserveDeep, +} from '@toeverything/infra'; import { distinctUntilChanged, map, switchMap } from 'rxjs'; import { Array as YArray, Map as YMap } from 'yjs'; -import { Store } from '../../../framework'; -import { yjsObserve, yjsObserveByPath, yjsObserveDeep } from '../../../utils'; import type { WorkspaceService } from '../../workspace'; import type { DocPropertiesStore } from './doc-properties'; diff --git a/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts b/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts index 419b8a504371d..94d421d4208b3 100644 --- a/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts +++ b/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts @@ -1,20 +1,16 @@ import { DebugLogger } from '@affine/debug'; -import type { - Job, - JobQueue, - WorkspaceLocalState, - WorkspaceService, -} from '@toeverything/infra'; +import type { Job, JobQueue } from '@toeverything/infra'; import { Entity, IndexedDBIndexStorage, IndexedDBJobQueue, JobRunner, LiveData, - WorkspaceDBService, } from '@toeverything/infra'; import { map } from 'rxjs'; +import { WorkspaceDBService } from '../../db'; +import type { WorkspaceLocalState, WorkspaceService } from '../../workspace'; import { blockIndexSchema, docIndexSchema } from '../schema'; import { createWorker, type IndexerWorker } from '../worker/out-worker'; diff --git a/packages/frontend/core/src/modules/docs-search/index.ts b/packages/frontend/core/src/modules/docs-search/index.ts index 03fd0e157ac7a..1f9db66e185e9 100644 --- a/packages/frontend/core/src/modules/docs-search/index.ts +++ b/packages/frontend/core/src/modules/docs-search/index.ts @@ -1,12 +1,12 @@ export { DocsSearchService } from './services/docs-search'; +import { type Framework } from '@toeverything/infra'; + import { - type Framework, WorkspaceLocalState, WorkspaceScope, WorkspaceService, -} from '@toeverything/infra'; - +} from '../workspace'; import { DocsIndexer } from './entities/docs-indexer'; import { DocsSearchService } from './services/docs-search'; diff --git a/packages/frontend/core/src/modules/docs-search/services/docs-search.ts b/packages/frontend/core/src/modules/docs-search/services/docs-search.ts index 0eb1af2ce75ca..792e54d410f6b 100644 --- a/packages/frontend/core/src/modules/docs-search/services/docs-search.ts +++ b/packages/frontend/core/src/modules/docs-search/services/docs-search.ts @@ -1,16 +1,12 @@ import { toURLSearchParams } from '@affine/core/modules/navigation'; import type { ReferenceParams } from '@blocksuite/blocks'; -import type { WorkspaceService } from '@toeverything/infra'; -import { - fromPromise, - OnEvent, - Service, - WorkspaceEngineBeforeStart, -} from '@toeverything/infra'; +import { fromPromise, OnEvent, Service } from '@toeverything/infra'; import { isEmpty, omit } from 'lodash-es'; import { map, type Observable, switchMap } from 'rxjs'; import { z } from 'zod'; +import type { WorkspaceService } from '../../workspace'; +import { WorkspaceEngineBeforeStart } from '../../workspace'; import { DocsIndexer } from '../entities/docs-indexer'; @OnEvent(WorkspaceEngineBeforeStart, s => s.handleWorkspaceEngineBeforeStart) diff --git a/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts b/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts index a6bb1af4d4bcf..8a0e68360b249 100644 --- a/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts +++ b/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts @@ -15,7 +15,7 @@ import { } from '@blocksuite/affine/store'; import type { AffineTextAttributes } from '@blocksuite/affine-shared/types'; import type { DeltaInsert } from '@blocksuite/inline'; -import { Document, getAFFiNEWorkspaceSchema } from '@toeverything/infra'; +import { Document } from '@toeverything/infra'; import { toHexString } from 'lib0/buffer.js'; import { digest as lib0Digest } from 'lib0/hash/sha256'; import { difference, uniq } from 'lodash-es'; @@ -27,6 +27,7 @@ import { Text as YText, } from 'yjs'; +import { getAFFiNEWorkspaceSchema } from '../../workspace/global-schema'; import type { BlockIndexSchema, DocIndexSchema } from '../schema'; import type { WorkerIngoingMessage, diff --git a/packages/frontend/core/src/modules/editor-setting/__test__/editor-setting.spec.ts b/packages/frontend/core/src/modules/editor-setting/__test__/editor-setting.spec.ts deleted file mode 100644 index 3284bab168bd8..0000000000000 --- a/packages/frontend/core/src/modules/editor-setting/__test__/editor-setting.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Framework, GlobalState, MemoryMemento } from '@toeverything/infra'; -import { expect, test } from 'vitest'; - -import { EditorSetting } from '../entities/editor-setting'; -import { GlobalStateEditorSettingProvider } from '../impls/global-state'; -import { EditorSettingProvider } from '../provider/editor-setting-provider'; -import { EditorSettingService } from '../services/editor-setting'; - -test('editor setting service', () => { - const framework = new Framework(); - - framework - .service(EditorSettingService) - .entity(EditorSetting, [EditorSettingProvider]) - .impl(EditorSettingProvider, GlobalStateEditorSettingProvider, [ - GlobalState, - ]) - .impl(GlobalState, MemoryMemento); - - const provider = framework.provider(); - - const editorSettingService = provider.get(EditorSettingService); - - // default value - expect(editorSettingService.editorSetting.get('fontFamily')).toBe('Sans'); - - // set plain object - editorSettingService.editorSetting.set('fontFamily', 'Serif'); - expect(editorSettingService.editorSetting.get('fontFamily')).toBe('Serif'); - - // set nested object - editorSettingService.editorSetting.set('connector', { - stroke: { - dark: '#000000', - light: '#ffffff', - }, - }); - expect(editorSettingService.editorSetting.get('connector').stroke).toEqual({ - dark: '#000000', - light: '#ffffff', - }); - - // invalid font family - editorSettingService.editorSetting.provider.set( - 'fontFamily', - JSON.stringify('abc') - ); - - // fallback to default value - expect(editorSettingService.editorSetting.get('fontFamily')).toBe('Sans'); -}); diff --git a/packages/frontend/core/src/modules/editor-setting/impls/global-state.ts b/packages/frontend/core/src/modules/editor-setting/impls/global-state.ts index 346aca144a93b..3ffcd79afc3dc 100644 --- a/packages/frontend/core/src/modules/editor-setting/impls/global-state.ts +++ b/packages/frontend/core/src/modules/editor-setting/impls/global-state.ts @@ -1,7 +1,7 @@ -import type { GlobalState } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; import { map, type Observable } from 'rxjs'; +import type { GlobalState } from '../../storage'; import type { EditorSettingProvider } from '../provider/editor-setting-provider'; const storageKey = 'editor-setting'; diff --git a/packages/frontend/core/src/modules/editor-setting/impls/user-db.ts b/packages/frontend/core/src/modules/editor-setting/impls/user-db.ts index 5d132230d73f8..15dfbe2284ba8 100644 --- a/packages/frontend/core/src/modules/editor-setting/impls/user-db.ts +++ b/packages/frontend/core/src/modules/editor-setting/impls/user-db.ts @@ -1,8 +1,8 @@ -import type { GlobalState } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; import { map, type Observable, switchMap } from 'rxjs'; import type { ServersService } from '../../cloud'; +import type { GlobalState } from '../../storage'; import { UserDBService } from '../../userspace'; import type { EditorSettingProvider } from '../provider/editor-setting-provider'; diff --git a/packages/frontend/core/src/modules/editor-setting/index.ts b/packages/frontend/core/src/modules/editor-setting/index.ts index fc8771ec4f11b..8095a04a8e8a3 100644 --- a/packages/frontend/core/src/modules/editor-setting/index.ts +++ b/packages/frontend/core/src/modules/editor-setting/index.ts @@ -1,12 +1,9 @@ -import { - type Framework, - GlobalState, - GlobalStateService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { ServersService } from '../cloud'; import { DesktopApiService } from '../desktop-api'; import { I18n } from '../i18n'; +import { GlobalState, GlobalStateService } from '../storage'; import { EditorSetting } from './entities/editor-setting'; import { CurrentUserDBEditorSettingProvider } from './impls/user-db'; import { EditorSettingProvider } from './provider/editor-setting-provider'; diff --git a/packages/frontend/core/src/modules/editor-setting/services/editor-setting.ts b/packages/frontend/core/src/modules/editor-setting/services/editor-setting.ts index b13b42f00c1ba..3dd33c2e4a2af 100644 --- a/packages/frontend/core/src/modules/editor-setting/services/editor-setting.ts +++ b/packages/frontend/core/src/modules/editor-setting/services/editor-setting.ts @@ -1,11 +1,8 @@ -import type { Workspace } from '@toeverything/infra'; -import { - DocsService, - OnEvent, - Service, - WorkspaceInitialized, -} from '@toeverything/infra'; +import { OnEvent, Service } from '@toeverything/infra'; +import { DocsService } from '../../doc'; +import type { Workspace } from '../../workspace'; +import { WorkspaceInitialized } from '../../workspace'; import { EditorSetting, type EditorSettingExt, diff --git a/packages/frontend/core/src/modules/editor-setting/services/spell-check-setting.ts b/packages/frontend/core/src/modules/editor-setting/services/spell-check-setting.ts index 7976e1e4aecb0..e981b45286dfc 100644 --- a/packages/frontend/core/src/modules/editor-setting/services/spell-check-setting.ts +++ b/packages/frontend/core/src/modules/editor-setting/services/spell-check-setting.ts @@ -3,11 +3,11 @@ import type { SpellCheckStateSchema, } from '@affine/electron/main/shared-state-schema'; import type { Language } from '@affine/i18n'; -import type { GlobalStateService } from '@toeverything/infra'; import { LiveData, Service } from '@toeverything/infra'; import type { DesktopApiService } from '../../desktop-api'; import type { I18n } from '../../i18n'; +import type { GlobalStateService } from '../../storage'; const SPELL_CHECK_SETTING_KEY: typeof SpellCheckStateKey = 'spellCheckState'; diff --git a/packages/frontend/core/src/modules/editor/entities/editor.ts b/packages/frontend/core/src/modules/editor/entities/editor.ts index 78daa1f08a5fa..bc64e1f48c9eb 100644 --- a/packages/frontend/core/src/modules/editor/entities/editor.ts +++ b/packages/frontend/core/src/modules/editor/entities/editor.ts @@ -10,13 +10,14 @@ import type { } from '@blocksuite/affine/presets'; import type { InlineEditor } from '@blocksuite/inline'; import { effect } from '@preact/signals-core'; -import type { DocService, WorkspaceService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; import { defaults, isEqual, omit } from 'lodash-es'; import { skip } from 'rxjs'; +import type { DocService } from '../../doc'; import { paramsParseOptions, preprocessParams } from '../../navigation/utils'; import type { WorkbenchView } from '../../workbench'; +import type { WorkspaceService } from '../../workspace'; import { EditorScope } from '../scopes/editor'; import type { EditorSelector } from '../types'; diff --git a/packages/frontend/core/src/modules/editor/index.ts b/packages/frontend/core/src/modules/editor/index.ts index 7b2eb8ee3abb9..edd9ec66300bb 100644 --- a/packages/frontend/core/src/modules/editor/index.ts +++ b/packages/frontend/core/src/modules/editor/index.ts @@ -1,11 +1,7 @@ -import { - DocScope, - DocService, - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocScope, DocService } from '../doc'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { Editor } from './entities/editor'; import { EditorScope } from './scopes/editor'; import { EditorService } from './services/editor'; diff --git a/packages/frontend/core/src/modules/explorer/entities/explore-section.ts b/packages/frontend/core/src/modules/explorer/entities/explore-section.ts index 2c4e281c384a3..3bfba344db357 100644 --- a/packages/frontend/core/src/modules/explorer/entities/explore-section.ts +++ b/packages/frontend/core/src/modules/explorer/entities/explore-section.ts @@ -1,7 +1,7 @@ -import type { GlobalCache } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; import { map } from 'rxjs'; +import type { GlobalCache } from '../../storage'; import type { CollapsibleSectionName } from '../types'; const DEFAULT_COLLAPSABLE_STATE: Record = { diff --git a/packages/frontend/core/src/modules/explorer/index.ts b/packages/frontend/core/src/modules/explorer/index.ts index 96f9d0b4d8887..3d1e72a8c0196 100644 --- a/packages/frontend/core/src/modules/explorer/index.ts +++ b/packages/frontend/core/src/modules/explorer/index.ts @@ -1,9 +1,7 @@ -import { - type Framework, - GlobalCache, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { GlobalCache } from '../storage'; +import { WorkspaceScope } from '../workspace'; import { ExplorerSection } from './entities/explore-section'; import { ExplorerService } from './services/explorer'; export { ExplorerService } from './services/explorer'; diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/collection/index.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/collection/index.tsx index 22a8c097a072f..746c6be8ffb42 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/collection/index.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/collection/index.tsx @@ -8,7 +8,9 @@ import { import { filterPage } from '@affine/core/components/page-list'; import { CollectionService } from '@affine/core/modules/collection'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import { ShareDocsListService } from '@affine/core/modules/share-doc'; import type { AffineDNDData } from '@affine/core/types/dnd'; import type { Collection } from '@affine/env/filter'; @@ -18,8 +20,6 @@ import { track } from '@affine/track'; import type { DocMeta } from '@blocksuite/affine/store'; import { FilterMinusIcon } from '@blocksuite/icons/rc'; import { - DocsService, - GlobalContextService, LiveData, useLiveData, useService, diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx index 6fd8e4dee669e..d5537d4eef4c5 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx @@ -9,7 +9,9 @@ import { useDeleteCollectionInfo } from '@affine/core/components/hooks/affine/us import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; import { CollectionService } from '@affine/core/modules/collection'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { @@ -19,12 +21,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import type { NodeOperation } from '../../tree/types'; diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/doc/index.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/doc/index.tsx index 526f5c5dc007e..a5ee5ebf24d8d 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/doc/index.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/doc/index.tsx @@ -7,15 +7,15 @@ import { } from '@affine/component'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { DocsSearchService } from '@affine/core/modules/docs-search'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { - DocsService, - FeatureFlagService, - GlobalContextService, LiveData, useLiveData, useService, diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx index 82a6ac17b6c65..c25df37c79637 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx @@ -9,8 +9,11 @@ import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-pa import { useBlockSuiteMetaHelper } from '@affine/core/components/hooks/affine/use-block-suite-meta-helper'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; +import { DocsService } from '@affine/core/modules/doc'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { @@ -22,13 +25,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - DocsService, - FeatureFlagService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import type { NodeOperation } from '../../tree/types'; diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/folder/index.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/folder/index.tsx index e49fb08a51f39..3d154d6acc4df 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/folder/index.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/folder/index.tsx @@ -12,10 +12,12 @@ import { import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { type FolderNode, OrganizeService, } from '@affine/core/modules/organize'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { Unreachable } from '@affine/env/constant'; import { useI18n } from '@affine/i18n'; @@ -29,12 +31,7 @@ import { RemoveFolderIcon, TagsIcon, } from '@blocksuite/icons/rc'; -import { - FeatureFlagService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { difference } from 'lodash-es'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/tag/index.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/tag/index.tsx index 0a17b2edabb58..3487310cdca52 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/tag/index.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/tag/index.tsx @@ -3,16 +3,13 @@ import { type DropTargetOptions, toast, } from '@affine/component'; +import { GlobalContextService } from '@affine/core/modules/global-context'; import type { Tag } from '@affine/core/modules/tag'; import { TagService } from '@affine/core/modules/tag'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; -import { - GlobalContextService, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import clsx from 'clsx'; import { useCallback, useMemo, useState } from 'react'; diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx index a9592e3e50c28..e99afb41d007d 100644 --- a/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx +++ b/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx @@ -1,9 +1,12 @@ import { IconButton, MenuItem, MenuSeparator, toast } from '@affine/component'; import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils'; import { IsFavoriteIcon } from '@affine/core/components/pure/icons'; +import { DocsService } from '@affine/core/modules/doc'; import { FavoriteService } from '@affine/core/modules/favorite'; +import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { TagService } from '@affine/core/modules/tag'; import { WorkbenchService } from '@affine/core/modules/workbench'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { @@ -12,13 +15,7 @@ import { PlusIcon, SplitViewIcon, } from '@blocksuite/icons/rc'; -import { - DocsService, - FeatureFlagService, - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; import type { NodeOperation } from '../../tree/types'; diff --git a/packages/frontend/core/src/modules/explorer/views/sections/favorites/index.tsx b/packages/frontend/core/src/modules/explorer/views/sections/favorites/index.tsx index 165b273258a59..57923bdf5ddfe 100644 --- a/packages/frontend/core/src/modules/explorer/views/sections/favorites/index.tsx +++ b/packages/frontend/core/src/modules/explorer/views/sections/favorites/index.tsx @@ -13,16 +13,13 @@ import { FavoriteService, isFavoriteSupportType, } from '@affine/core/modules/favorite'; +import { WorkspaceService } from '@affine/core/modules/workspace'; import type { AffineDNDData } from '@affine/core/types/dnd'; import { isNewTabTrigger } from '@affine/core/utils'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { PlusIcon } from '@blocksuite/icons/rc'; -import { - useLiveData, - useServices, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { type MouseEventHandler, useCallback } from 'react'; import { ExplorerService } from '../../../services/explorer'; diff --git a/packages/frontend/core/src/modules/explorer/views/sections/migration-favorites/index.tsx b/packages/frontend/core/src/modules/explorer/views/sections/migration-favorites/index.tsx index 6e8c4049998f0..b4dc95e5ca8c3 100644 --- a/packages/frontend/core/src/modules/explorer/views/sections/migration-favorites/index.tsx +++ b/packages/frontend/core/src/modules/explorer/views/sections/migration-favorites/index.tsx @@ -1,10 +1,11 @@ import { IconButton, useConfirmModal } from '@affine/component'; +import { DocsService } from '@affine/core/modules/doc'; import { ExplorerTreeRoot } from '@affine/core/modules/explorer/views/tree'; import { MigrationFavoriteItemsAdapter } from '@affine/core/modules/favorite'; import { Trans, useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { BroomIcon, HelpIcon } from '@blocksuite/icons/rc'; -import { DocsService, useLiveData, useServices } from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { useCallback } from 'react'; import { CollapsibleSection } from '../../layouts/collapsible-section'; diff --git a/packages/frontend/core/src/modules/favorite/index.ts b/packages/frontend/core/src/modules/favorite/index.ts index e6cf92e7553a8..b5eae5315bae3 100644 --- a/packages/frontend/core/src/modules/favorite/index.ts +++ b/packages/frontend/core/src/modules/favorite/index.ts @@ -1,11 +1,8 @@ -import { - type Framework, - WorkspaceDBService, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { WorkspaceServerService } from '../cloud'; +import { WorkspaceDBService } from '../db'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { FavoriteList } from './entities/favorite-list'; import { FavoriteService } from './services/favorite'; import { diff --git a/packages/frontend/core/src/modules/favorite/services/old/adapter.ts b/packages/frontend/core/src/modules/favorite/services/old/adapter.ts index 069ba49a22aa4..3bcf5fcc63d28 100644 --- a/packages/frontend/core/src/modules/favorite/services/old/adapter.ts +++ b/packages/frontend/core/src/modules/favorite/services/old/adapter.ts @@ -1,7 +1,6 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ // the adapter is to bridge the workspace rootdoc & native js bindings +import type { WorkspaceService } from '@affine/core/modules/workspace'; import { createYProxy, type Y } from '@blocksuite/affine/store'; -import type { WorkspaceService } from '@toeverything/infra'; import { LiveData, Service } from '@toeverything/infra'; import { defaultsDeep } from 'lodash-es'; import { Observable } from 'rxjs'; @@ -155,6 +154,7 @@ class WorkspacePropertiesAdapter { setJournalPageDateString(id: string, date: string) { this.ensurePageProperties(id); const pageProperties = this.pageProperties?.[id]; + // oxlint-disable-next-line no-non-null-assertion pageProperties!.system[PageSystemPropertyId.Journal].value = date; } diff --git a/packages/frontend/core/src/modules/favorite/stores/favorite.ts b/packages/frontend/core/src/modules/favorite/stores/favorite.ts index 520a22dacaaa7..c4ca68453f93c 100644 --- a/packages/frontend/core/src/modules/favorite/stores/favorite.ts +++ b/packages/frontend/core/src/modules/favorite/stores/favorite.ts @@ -1,8 +1,9 @@ -import type { WorkspaceDBService, WorkspaceService } from '@toeverything/infra'; import { LiveData, Store } from '@toeverything/infra'; import { map } from 'rxjs'; import { AuthService, type WorkspaceServerService } from '../../cloud'; +import type { WorkspaceDBService } from '../../db'; +import type { WorkspaceService } from '../../workspace'; import type { FavoriteSupportTypeUnion } from '../constant'; import { isFavoriteSupportType } from '../constant'; diff --git a/packages/common/infra/src/modules/feature-flag/constant.ts b/packages/frontend/core/src/modules/feature-flag/constant.ts similarity index 100% rename from packages/common/infra/src/modules/feature-flag/constant.ts rename to packages/frontend/core/src/modules/feature-flag/constant.ts diff --git a/packages/common/infra/src/modules/feature-flag/entities/flags.ts b/packages/frontend/core/src/modules/feature-flag/entities/flags.ts similarity index 95% rename from packages/common/infra/src/modules/feature-flag/entities/flags.ts rename to packages/frontend/core/src/modules/feature-flag/entities/flags.ts index b21f1c58ac124..8d6e71da83ef5 100644 --- a/packages/common/infra/src/modules/feature-flag/entities/flags.ts +++ b/packages/frontend/core/src/modules/feature-flag/entities/flags.ts @@ -1,7 +1,6 @@ +import { Entity, LiveData } from '@toeverything/infra'; import { NEVER } from 'rxjs'; -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; import type { GlobalStateService } from '../../storage'; import { AFFINE_FLAGS } from '../constant'; import type { FlagInfo } from '../types'; diff --git a/packages/common/infra/src/modules/feature-flag/index.ts b/packages/frontend/core/src/modules/feature-flag/index.ts similarity index 89% rename from packages/common/infra/src/modules/feature-flag/index.ts rename to packages/frontend/core/src/modules/feature-flag/index.ts index e52725bf5e83e..39390ccea3c2b 100644 --- a/packages/common/infra/src/modules/feature-flag/index.ts +++ b/packages/frontend/core/src/modules/feature-flag/index.ts @@ -1,4 +1,5 @@ -import type { Framework } from '../../framework'; +import type { Framework } from '@toeverything/infra'; + import { GlobalStateService } from '../storage'; import { Flags } from './entities/flags'; import { FeatureFlagService } from './services/feature-flag'; diff --git a/packages/common/infra/src/modules/feature-flag/services/feature-flag.ts b/packages/frontend/core/src/modules/feature-flag/services/feature-flag.ts similarity index 95% rename from packages/common/infra/src/modules/feature-flag/services/feature-flag.ts rename to packages/frontend/core/src/modules/feature-flag/services/feature-flag.ts index efe1fbc84e695..cc0ee7a127d9f 100644 --- a/packages/common/infra/src/modules/feature-flag/services/feature-flag.ts +++ b/packages/frontend/core/src/modules/feature-flag/services/feature-flag.ts @@ -1,6 +1,6 @@ +import { OnEvent, Service } from '@toeverything/infra'; import { distinctUntilChanged, skip } from 'rxjs'; -import { OnEvent, Service } from '../../../framework'; import { ApplicationStarted } from '../../lifecycle'; import type { Workspace } from '../../workspace'; import { WorkspaceInitialized } from '../../workspace/events'; diff --git a/packages/common/infra/src/modules/feature-flag/types.ts b/packages/frontend/core/src/modules/feature-flag/types.ts similarity index 100% rename from packages/common/infra/src/modules/feature-flag/types.ts rename to packages/frontend/core/src/modules/feature-flag/types.ts diff --git a/packages/common/infra/src/modules/global-context/entities/global-context.ts b/packages/frontend/core/src/modules/global-context/entities/global-context.ts similarity index 89% rename from packages/common/infra/src/modules/global-context/entities/global-context.ts rename to packages/frontend/core/src/modules/global-context/entities/global-context.ts index 61121004bbbdf..a589a3b789a1c 100644 --- a/packages/common/infra/src/modules/global-context/entities/global-context.ts +++ b/packages/frontend/core/src/modules/global-context/entities/global-context.ts @@ -1,8 +1,5 @@ import type { DocMode } from '@blocksuite/affine/blocks'; - -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; -import { MemoryMemento } from '../../../storage'; +import { Entity, LiveData, MemoryMemento } from '@toeverything/infra'; export class GlobalContext extends Entity { memento = new MemoryMemento(); diff --git a/packages/common/infra/src/modules/global-context/index.ts b/packages/frontend/core/src/modules/global-context/index.ts similarity index 85% rename from packages/common/infra/src/modules/global-context/index.ts rename to packages/frontend/core/src/modules/global-context/index.ts index f93aa05a0e0d7..481238ed39bfe 100644 --- a/packages/common/infra/src/modules/global-context/index.ts +++ b/packages/frontend/core/src/modules/global-context/index.ts @@ -1,6 +1,7 @@ export { GlobalContextService } from './services/global-context'; -import type { Framework } from '../../framework'; +import type { Framework } from '@toeverything/infra'; + import { GlobalContext } from './entities/global-context'; import { GlobalContextService } from './services/global-context'; diff --git a/packages/common/infra/src/modules/global-context/services/global-context.ts b/packages/frontend/core/src/modules/global-context/services/global-context.ts similarity index 78% rename from packages/common/infra/src/modules/global-context/services/global-context.ts rename to packages/frontend/core/src/modules/global-context/services/global-context.ts index a0a8db0dab0fd..028272c2627a9 100644 --- a/packages/common/infra/src/modules/global-context/services/global-context.ts +++ b/packages/frontend/core/src/modules/global-context/services/global-context.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import { GlobalContext } from '../entities/global-context'; export class GlobalContextService extends Service { diff --git a/packages/frontend/core/src/modules/i18n/entities/i18n.ts b/packages/frontend/core/src/modules/i18n/entities/i18n.ts index 83991f351956c..a343c7cd83acc 100644 --- a/packages/frontend/core/src/modules/i18n/entities/i18n.ts +++ b/packages/frontend/core/src/modules/i18n/entities/i18n.ts @@ -6,10 +6,11 @@ import { type Language, SUPPORTED_LANGUAGES, } from '@affine/i18n'; -import type { GlobalCache } from '@toeverything/infra'; import { effect, Entity, fromPromise, LiveData } from '@toeverything/infra'; import { catchError, EMPTY, exhaustMap, mergeMap } from 'rxjs'; +import type { GlobalCache } from '../../storage'; + export type LanguageInfo = { key: Language; name: string; diff --git a/packages/frontend/core/src/modules/i18n/index.ts b/packages/frontend/core/src/modules/i18n/index.ts index 9f031446e4225..0d78e556b868d 100644 --- a/packages/frontend/core/src/modules/i18n/index.ts +++ b/packages/frontend/core/src/modules/i18n/index.ts @@ -1,5 +1,6 @@ -import { type Framework, GlobalCache } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { GlobalCache } from '../storage'; import { I18nProvider } from './context'; import { I18n, type LanguageInfo } from './entities/i18n'; import { I18nService } from './services/i18n'; diff --git a/packages/frontend/core/src/modules/import-template/index.ts b/packages/frontend/core/src/modules/import-template/index.ts index a0d4c8e42d9c6..b8c86069cd96b 100644 --- a/packages/frontend/core/src/modules/import-template/index.ts +++ b/packages/frontend/core/src/modules/import-template/index.ts @@ -1,6 +1,7 @@ -import { type Framework, WorkspacesService } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { FetchService } from '../cloud'; +import { WorkspacesService } from '../workspace'; import { ImportTemplateDialog } from './entities/dialog'; import { TemplateDownloader } from './entities/downloader'; import { TemplateDownloaderService } from './services/downloader'; diff --git a/packages/frontend/core/src/modules/import-template/services/import.ts b/packages/frontend/core/src/modules/import-template/services/import.ts index 27ae74f783346..1cb24b3b7584c 100644 --- a/packages/frontend/core/src/modules/import-template/services/import.ts +++ b/packages/frontend/core/src/modules/import-template/services/import.ts @@ -1,6 +1,8 @@ import { type DocMode, ZipTransformer } from '@blocksuite/affine/blocks'; -import type { WorkspaceMetadata, WorkspacesService } from '@toeverything/infra'; -import { DocsService, Service } from '@toeverything/infra'; +import { Service } from '@toeverything/infra'; + +import { DocsService } from '../../doc'; +import type { WorkspaceMetadata, WorkspacesService } from '../../workspace'; export class ImportTemplateService extends Service { constructor(private readonly workspacesService: WorkspacesService) { diff --git a/packages/frontend/core/src/modules/index.ts b/packages/frontend/core/src/modules/index.ts index 9e274b0d17363..ad4dffb68d802 100644 --- a/packages/frontend/core/src/modules/index.ts +++ b/packages/frontend/core/src/modules/index.ts @@ -1,12 +1,14 @@ import { configureQuotaModule } from '@affine/core/modules/quota'; -import { configureInfraModules, type Framework } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { configureAppSidebarModule } from './app-sidebar'; import { configAtMenuConfigModule } from './at-menu-config'; import { configureCloudModule } from './cloud'; import { configureCollectionModule } from './collection'; +import { configureWorkspaceDBModule } from './db'; import { configureDialogModule } from './dialogs'; import { configureDndModule } from './dnd'; +import { configureDocModule } from './doc'; import { configureDocDisplayMetaModule } from './doc-display-meta'; import { configureDocInfoModule } from './doc-info'; import { configureDocLinksModule } from './doc-link'; @@ -15,9 +17,12 @@ import { configureEditorModule } from './editor'; import { configureEditorSettingModule } from './editor-setting'; import { configureExplorerModule } from './explorer'; import { configureFavoriteModule } from './favorite'; +import { configureFeatureFlagModule } from './feature-flag'; +import { configureGlobalContextModule } from './global-context'; import { configureI18nModule } from './i18n'; import { configureImportTemplateModule } from './import-template'; import { configureJournalModule } from './journal'; +import { configureLifecycleModule } from './lifecycle'; import { configureNavigationModule } from './navigation'; import { configureOpenInApp } from './open-in-app'; import { configureOrganizeModule } from './organize'; @@ -27,7 +32,10 @@ import { configurePermissionsModule } from './permissions'; import { configureQuickSearchModule } from './quicksearch'; import { configureShareDocsModule } from './share-doc'; import { configureShareSettingModule } from './share-setting'; -import { configureCommonGlobalStorageImpls } from './storage'; +import { + configureCommonGlobalStorageImpls, + configureGlobalStorageModule, +} from './storage'; import { configureSystemFontFamilyModule } from './system-font-family'; import { configureTagModule } from './tag'; import { configureTelemetryModule } from './telemetry'; @@ -35,10 +43,17 @@ import { configureAppThemeModule } from './theme'; import { configureThemeEditorModule } from './theme-editor'; import { configureUrlModule } from './url'; import { configureUserspaceModule } from './userspace'; +import { configureWorkspaceModule } from './workspace'; export function configureCommonModules(framework: Framework) { configureI18nModule(framework); - configureInfraModules(framework); + configureWorkspaceModule(framework); + configureDocModule(framework); + configureWorkspaceDBModule(framework); + configureGlobalStorageModule(framework); + configureGlobalContextModule(framework); + configureLifecycleModule(framework); + configureFeatureFlagModule(framework); configureCollectionModule(framework); configureNavigationModule(framework); configureTagModule(framework); diff --git a/packages/frontend/core/src/modules/journal/index.ts b/packages/frontend/core/src/modules/journal/index.ts index 47838bc69fb3a..3f581038b80bc 100644 --- a/packages/frontend/core/src/modules/journal/index.ts +++ b/packages/frontend/core/src/modules/journal/index.ts @@ -1,12 +1,8 @@ -import { - DocScope, - DocService, - DocsService, - type Framework, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocScope, DocService, DocsService } from '../doc'; import { EditorSettingService } from '../editor-setting'; +import { WorkspaceScope } from '../workspace'; import { JournalService } from './services/journal'; import { JournalDocService } from './services/journal-doc'; import { JournalStore } from './store/journal'; diff --git a/packages/frontend/core/src/modules/journal/services/journal-doc.ts b/packages/frontend/core/src/modules/journal/services/journal-doc.ts index ead865bc1b582..4bdf255b1f884 100644 --- a/packages/frontend/core/src/modules/journal/services/journal-doc.ts +++ b/packages/frontend/core/src/modules/journal/services/journal-doc.ts @@ -1,5 +1,6 @@ -import { type DocService, Service } from '@toeverything/infra'; +import { Service } from '@toeverything/infra'; +import type { DocService } from '../../doc'; import type { JournalService } from './journal'; export class JournalDocService extends Service { diff --git a/packages/frontend/core/src/modules/journal/services/journal.ts b/packages/frontend/core/src/modules/journal/services/journal.ts index d0620bc908746..6796d668461a6 100644 --- a/packages/frontend/core/src/modules/journal/services/journal.ts +++ b/packages/frontend/core/src/modules/journal/services/journal.ts @@ -1,8 +1,9 @@ import { Text } from '@blocksuite/affine/store'; -import type { DocProps, DocsService } from '@toeverything/infra'; +import type { DocProps } from '@toeverything/infra'; import { initDocFromProps, LiveData, Service } from '@toeverything/infra'; import dayjs from 'dayjs'; +import type { DocsService } from '../../doc'; import type { EditorSettingService } from '../../editor-setting'; import type { JournalStore } from '../store/journal'; diff --git a/packages/frontend/core/src/modules/journal/store/journal.ts b/packages/frontend/core/src/modules/journal/store/journal.ts index 9b935c997b353..a44d9edfd1b0f 100644 --- a/packages/frontend/core/src/modules/journal/store/journal.ts +++ b/packages/frontend/core/src/modules/journal/store/journal.ts @@ -1,7 +1,8 @@ -import type { DocsService } from '@toeverything/infra'; import { LiveData, Store } from '@toeverything/infra'; import type { Observable } from 'rxjs'; +import type { DocsService } from '../../doc'; + function isJournalString(j?: string | false) { return j ? !!j?.match(/^\d{4}-\d{2}-\d{2}$/) : false; } diff --git a/packages/common/infra/src/modules/lifecycle/index.ts b/packages/frontend/core/src/modules/lifecycle/index.ts similarity index 82% rename from packages/common/infra/src/modules/lifecycle/index.ts rename to packages/frontend/core/src/modules/lifecycle/index.ts index aeea99c451710..dcd4cecdfa58d 100644 --- a/packages/common/infra/src/modules/lifecycle/index.ts +++ b/packages/frontend/core/src/modules/lifecycle/index.ts @@ -1,4 +1,5 @@ -import type { Framework } from '../../framework'; +import type { Framework } from '@toeverything/infra'; + import { LifecycleService } from './service/lifecycle'; export { diff --git a/packages/common/infra/src/modules/lifecycle/service/lifecycle.ts b/packages/frontend/core/src/modules/lifecycle/service/lifecycle.ts similarity index 91% rename from packages/common/infra/src/modules/lifecycle/service/lifecycle.ts rename to packages/frontend/core/src/modules/lifecycle/service/lifecycle.ts index 51d1148b68bb2..3e3ef8c0f0f36 100644 --- a/packages/common/infra/src/modules/lifecycle/service/lifecycle.ts +++ b/packages/frontend/core/src/modules/lifecycle/service/lifecycle.ts @@ -1,4 +1,4 @@ -import { createEvent, Service } from '../../../framework'; +import { createEvent, Service } from '@toeverything/infra'; /** * Event that is emitted when application is started. diff --git a/packages/frontend/core/src/modules/navigation/index.ts b/packages/frontend/core/src/modules/navigation/index.ts index a6adcbef3fea0..48e0f0a44338c 100644 --- a/packages/frontend/core/src/modules/navigation/index.ts +++ b/packages/frontend/core/src/modules/navigation/index.ts @@ -6,9 +6,10 @@ export { } from './utils'; export { NavigationButtons } from './view/navigation-buttons'; -import { type Framework, WorkspaceScope } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { WorkbenchService } from '../workbench/services/workbench'; +import { WorkspaceScope } from '../workspace'; import { Navigator } from './entities/navigator'; import { NavigatorService } from './services/navigator'; diff --git a/packages/frontend/core/src/modules/open-in-app/index.ts b/packages/frontend/core/src/modules/open-in-app/index.ts index f5312b4c45b4f..0de7f851ec052 100644 --- a/packages/frontend/core/src/modules/open-in-app/index.ts +++ b/packages/frontend/core/src/modules/open-in-app/index.ts @@ -1,9 +1,7 @@ -import { - type Framework, - GlobalState, - WorkspacesService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { GlobalState } from '../storage'; +import { WorkspacesService } from '../workspace'; import { OpenInAppService } from './services'; export { OpenInAppService, OpenLinkMode } from './services'; diff --git a/packages/frontend/core/src/modules/open-in-app/services/index.ts b/packages/frontend/core/src/modules/open-in-app/services/index.ts index 2064dcaa103a0..0cf07fbb8c1d9 100644 --- a/packages/frontend/core/src/modules/open-in-app/services/index.ts +++ b/packages/frontend/core/src/modules/open-in-app/services/index.ts @@ -1,8 +1,9 @@ -import type { GlobalState, WorkspacesService } from '@toeverything/infra'; import { LiveData, OnEvent, Service } from '@toeverything/infra'; import { resolveLinkToDoc } from '../../navigation'; +import type { GlobalState } from '../../storage'; import { WorkbenchLocationChanged } from '../../workbench/services/workbench'; +import type { WorkspacesService } from '../../workspace'; import { getLocalWorkspaceIds } from '../../workspace-engine/impls/local'; const storageKey = 'open-link-mode'; diff --git a/packages/frontend/core/src/modules/organize/index.ts b/packages/frontend/core/src/modules/organize/index.ts index 89388b1f17342..8cb8fe16a190f 100644 --- a/packages/frontend/core/src/modules/organize/index.ts +++ b/packages/frontend/core/src/modules/organize/index.ts @@ -1,9 +1,7 @@ -import { - type Framework, - WorkspaceDBService, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { WorkspaceDBService } from '../db'; +import { WorkspaceScope } from '../workspace'; import { FolderNode } from './entities/folder-node'; import { FolderTree } from './entities/folder-tree'; import { OrganizeService } from './services/organize'; diff --git a/packages/frontend/core/src/modules/organize/stores/folder.ts b/packages/frontend/core/src/modules/organize/stores/folder.ts index fd107324b4f52..f423b5201c8b2 100644 --- a/packages/frontend/core/src/modules/organize/stores/folder.ts +++ b/packages/frontend/core/src/modules/organize/stores/folder.ts @@ -1,6 +1,7 @@ -import type { WorkspaceDBService } from '@toeverything/infra'; import { Store } from '@toeverything/infra'; +import type { WorkspaceDBService } from '../../db'; + export class FolderStore extends Store { constructor(private readonly dbService: WorkspaceDBService) { super(); diff --git a/packages/frontend/core/src/modules/pdf/index.ts b/packages/frontend/core/src/modules/pdf/index.ts index 998173d9ce585..5a6a4f5a15c86 100644 --- a/packages/frontend/core/src/modules/pdf/index.ts +++ b/packages/frontend/core/src/modules/pdf/index.ts @@ -1,6 +1,6 @@ import type { Framework } from '@toeverything/infra'; -import { WorkspaceScope } from '@toeverything/infra'; +import { WorkspaceScope } from '../workspace'; import { PDF } from './entities/pdf'; import { PDFPage } from './entities/pdf-page'; import { PDFService } from './services/pdf'; diff --git a/packages/frontend/core/src/modules/peek-view/index.ts b/packages/frontend/core/src/modules/peek-view/index.ts index 0956ad759653e..ad170c5961dac 100644 --- a/packages/frontend/core/src/modules/peek-view/index.ts +++ b/packages/frontend/core/src/modules/peek-view/index.ts @@ -1,6 +1,7 @@ -import { type Framework, WorkspaceScope } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { WorkbenchService } from '../workbench'; +import { WorkspaceScope } from '../workspace'; import { PeekViewEntity } from './entities/peek-view'; import { PeekViewService } from './services/peek-view'; diff --git a/packages/frontend/core/src/modules/peek-view/view/utils.ts b/packages/frontend/core/src/modules/peek-view/view/utils.ts index 27dadbcc61268..183cbaa4b3f44 100644 --- a/packages/frontend/core/src/modules/peek-view/view/utils.ts +++ b/packages/frontend/core/src/modules/peek-view/view/utils.ts @@ -1,15 +1,12 @@ import type { DefaultOpenProperty } from '@affine/core/components/doc-properties'; import type { DocMode } from '@blocksuite/affine/blocks'; -import type { Doc } from '@toeverything/infra'; -import { - DocsService, - useLiveData, - useService, - WorkspaceService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useEffect, useLayoutEffect, useRef, useState } from 'react'; +import type { Doc } from '../../doc'; +import { DocsService } from '../../doc'; import { type Editor, type EditorSelector, EditorsService } from '../../editor'; +import { WorkspaceService } from '../../workspace'; export const useEditor = ( pageId: string, diff --git a/packages/frontend/core/src/modules/permissions/entities/members.ts b/packages/frontend/core/src/modules/permissions/entities/members.ts index e0cf37df89491..4b810a74e92ac 100644 --- a/packages/frontend/core/src/modules/permissions/entities/members.ts +++ b/packages/frontend/core/src/modules/permissions/entities/members.ts @@ -1,5 +1,4 @@ import type { GetMembersByWorkspaceIdQuery } from '@affine/graphql'; -import type { WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -13,6 +12,7 @@ import { import { EMPTY, map, mergeMap, switchMap } from 'rxjs'; import { isBackendError, isNetworkError } from '../../cloud'; +import type { WorkspaceService } from '../../workspace'; import type { WorkspaceMembersStore } from '../stores/members'; export type Member = diff --git a/packages/frontend/core/src/modules/permissions/entities/permission.ts b/packages/frontend/core/src/modules/permissions/entities/permission.ts index 6e8ad03b269e5..e9e4eb761efba 100644 --- a/packages/frontend/core/src/modules/permissions/entities/permission.ts +++ b/packages/frontend/core/src/modules/permissions/entities/permission.ts @@ -3,7 +3,6 @@ import type { Permission, WorkspaceInviteLinkExpireTime, } from '@affine/graphql'; -import type { WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -17,6 +16,7 @@ import { import { EMPTY, exhaustMap, mergeMap } from 'rxjs'; import { isBackendError, isNetworkError } from '../../cloud'; +import type { WorkspaceService } from '../../workspace'; import type { WorkspacePermissionStore } from '../stores/permission'; const logger = new DebugLogger('affine:workspace-permission'); diff --git a/packages/frontend/core/src/modules/permissions/index.ts b/packages/frontend/core/src/modules/permissions/index.ts index ca67a5aab8f1a..feefe3a7b99a3 100644 --- a/packages/frontend/core/src/modules/permissions/index.ts +++ b/packages/frontend/core/src/modules/permissions/index.ts @@ -2,14 +2,14 @@ export type { Member } from './entities/members'; export { WorkspaceMembersService } from './services/members'; export { WorkspacePermissionService } from './services/permission'; +import { type Framework } from '@toeverything/infra'; + +import { WorkspaceServerService } from '../cloud'; import { - type Framework, WorkspaceScope, WorkspaceService, WorkspacesService, -} from '@toeverything/infra'; - -import { WorkspaceServerService } from '../cloud'; +} from '../workspace'; import { WorkspaceMembers } from './entities/members'; import { WorkspacePermission } from './entities/permission'; import { WorkspaceMembersService } from './services/members'; diff --git a/packages/frontend/core/src/modules/permissions/services/permission.ts b/packages/frontend/core/src/modules/permissions/services/permission.ts index 092e08fad8d4c..73f89f421c776 100644 --- a/packages/frontend/core/src/modules/permissions/services/permission.ts +++ b/packages/frontend/core/src/modules/permissions/services/permission.ts @@ -1,6 +1,6 @@ -import type { WorkspaceService, WorkspacesService } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; +import type { WorkspaceService, WorkspacesService } from '../../workspace'; import { WorkspacePermission } from '../entities/permission'; import type { WorkspacePermissionStore } from '../stores/permission'; diff --git a/packages/frontend/core/src/modules/quicksearch/impls/commands.ts b/packages/frontend/core/src/modules/quicksearch/impls/commands.ts index e275a5a73aa76..b6480284d33ee 100644 --- a/packages/frontend/core/src/modules/quicksearch/impls/commands.ts +++ b/packages/frontend/core/src/modules/quicksearch/impls/commands.ts @@ -5,10 +5,10 @@ import { PreconditionStrategy, } from '@affine/core/commands'; import type { DocMode } from '@blocksuite/affine/blocks'; -import type { GlobalContextService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; import Fuse from 'fuse.js'; +import type { GlobalContextService } from '../../global-context'; import type { QuickSearchSession } from '../providers/quick-search-provider'; import type { QuickSearchGroup } from '../types/group'; import type { QuickSearchItem } from '../types/item'; diff --git a/packages/frontend/core/src/modules/quicksearch/impls/docs.ts b/packages/frontend/core/src/modules/quicksearch/impls/docs.ts index 64115daf5a8ad..a2edce49ae4cd 100644 --- a/packages/frontend/core/src/modules/quicksearch/impls/docs.ts +++ b/packages/frontend/core/src/modules/quicksearch/impls/docs.ts @@ -1,4 +1,3 @@ -import type { DocRecord, DocsService } from '@toeverything/infra'; import { effect, Entity, @@ -9,6 +8,7 @@ import { import { truncate } from 'lodash-es'; import { EMPTY, map, mergeMap, of, switchMap } from 'rxjs'; +import type { DocRecord, DocsService } from '../../doc'; import type { DocDisplayMetaService } from '../../doc-display-meta'; import type { DocsSearchService } from '../../docs-search'; import type { QuickSearchSession } from '../providers/quick-search-provider'; diff --git a/packages/frontend/core/src/modules/quicksearch/impls/external-links.ts b/packages/frontend/core/src/modules/quicksearch/impls/external-links.ts index d65bc016ecd78..56196aa3f6959 100644 --- a/packages/frontend/core/src/modules/quicksearch/impls/external-links.ts +++ b/packages/frontend/core/src/modules/quicksearch/impls/external-links.ts @@ -1,9 +1,9 @@ import { LinkIcon } from '@blocksuite/icons/rc'; -import type { WorkspaceService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; import { resolveLinkToDoc } from '../../navigation'; import { isLink } from '../../navigation/utils'; +import type { WorkspaceService } from '../../workspace'; import type { QuickSearchSession } from '../providers/quick-search-provider'; import type { QuickSearchItem } from '../types/item'; diff --git a/packages/frontend/core/src/modules/quicksearch/impls/links.ts b/packages/frontend/core/src/modules/quicksearch/impls/links.ts index 756c152e1c043..353163d8ad797 100644 --- a/packages/frontend/core/src/modules/quicksearch/impls/links.ts +++ b/packages/frontend/core/src/modules/quicksearch/impls/links.ts @@ -1,12 +1,13 @@ import type { ReferenceParams } from '@blocksuite/affine/blocks'; import { BlockLinkIcon, EdgelessIcon, PageIcon } from '@blocksuite/icons/rc'; -import type { DocsService, WorkspaceService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; import { omit, truncate } from 'lodash-es'; +import type { DocsService } from '../../doc'; import type { DocDisplayMetaService } from '../../doc-display-meta'; import { resolveLinkToDoc } from '../../navigation'; import { isLink } from '../../navigation/utils'; +import type { WorkspaceService } from '../../workspace'; import type { QuickSearchSession } from '../providers/quick-search-provider'; import type { QuickSearchItem } from '../types/item'; diff --git a/packages/frontend/core/src/modules/quicksearch/index.ts b/packages/frontend/core/src/modules/quicksearch/index.ts index 85cd2445e0680..b469c89b9f772 100644 --- a/packages/frontend/core/src/modules/quicksearch/index.ts +++ b/packages/frontend/core/src/modules/quicksearch/index.ts @@ -1,19 +1,19 @@ -import { - DocsService, - type Framework, - GlobalContextService, - WorkspaceLocalState, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { CollectionService } from '../collection'; import { WorkspaceDialogService } from '../dialogs'; -import { DocDisplayMetaService } from '../doc-display-meta/services/doc-display-meta'; +import { DocsService } from '../doc'; +import { DocDisplayMetaService } from '../doc-display-meta'; import { DocsSearchService } from '../docs-search'; +import { GlobalContextService } from '../global-context'; import { JournalService } from '../journal'; import { TagService } from '../tag'; import { WorkbenchService } from '../workbench'; +import { + WorkspaceLocalState, + WorkspaceScope, + WorkspaceService, +} from '../workspace'; import { QuickSearch } from './entities/quick-search'; import { CollectionsQuickSearchSession } from './impls/collections'; import { CommandsQuickSearchSession } from './impls/commands'; diff --git a/packages/frontend/core/src/modules/quicksearch/services/cmdk.ts b/packages/frontend/core/src/modules/quicksearch/services/cmdk.ts index c6b57992dab19..f64d5a52f7d02 100644 --- a/packages/frontend/core/src/modules/quicksearch/services/cmdk.ts +++ b/packages/frontend/core/src/modules/quicksearch/services/cmdk.ts @@ -1,8 +1,9 @@ import { track } from '@affine/track'; import { Text } from '@blocksuite/affine/store'; -import type { DocProps, DocsService } from '@toeverything/infra'; +import type { DocProps } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; +import type { DocsService } from '../../doc'; import { EditorSettingService } from '../../editor-setting'; import type { WorkbenchService } from '../../workbench'; import { CollectionsQuickSearchSession } from '../impls/collections'; diff --git a/packages/frontend/core/src/modules/quicksearch/services/recent-pages.ts b/packages/frontend/core/src/modules/quicksearch/services/recent-pages.ts index 1712e3a36bc1b..34106cbbc52ae 100644 --- a/packages/frontend/core/src/modules/quicksearch/services/recent-pages.ts +++ b/packages/frontend/core/src/modules/quicksearch/services/recent-pages.ts @@ -1,10 +1,8 @@ -import type { - DocRecord, - DocsService, - WorkspaceLocalState, -} from '@toeverything/infra'; import { Service } from '@toeverything/infra'; +import type { DocRecord, DocsService } from '../../doc'; +import type { WorkspaceLocalState } from '../../workspace'; + const RECENT_PAGES_LIMIT = 3; // adjust this? const RECENT_PAGES_KEY = 'recent-pages'; diff --git a/packages/frontend/core/src/modules/quota/entities/quota.ts b/packages/frontend/core/src/modules/quota/entities/quota.ts index 6f2ac774fec5c..19e2ed4ad255b 100644 --- a/packages/frontend/core/src/modules/quota/entities/quota.ts +++ b/packages/frontend/core/src/modules/quota/entities/quota.ts @@ -1,6 +1,5 @@ import { DebugLogger } from '@affine/debug'; import type { WorkspaceQuotaQuery } from '@affine/graphql'; -import type { WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -17,6 +16,7 @@ import bytes from 'bytes'; import { EMPTY, map, mergeMap } from 'rxjs'; import { isBackendError, isNetworkError } from '../../cloud'; +import type { WorkspaceService } from '../../workspace'; import type { WorkspaceQuotaStore } from '../stores/quota'; type QuotaType = WorkspaceQuotaQuery['workspace']['quota']; diff --git a/packages/frontend/core/src/modules/quota/index.ts b/packages/frontend/core/src/modules/quota/index.ts index 790fe42796f67..db5b5bc2bc19c 100644 --- a/packages/frontend/core/src/modules/quota/index.ts +++ b/packages/frontend/core/src/modules/quota/index.ts @@ -1,13 +1,10 @@ export { WorkspaceQuotaService } from './services/quota'; export { QuotaCheck } from './views/quota-check'; -import { - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { WorkspaceServerService } from '../cloud'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { WorkspaceQuota } from './entities/quota'; import { WorkspaceQuotaService } from './services/quota'; import { WorkspaceQuotaStore } from './stores/quota'; diff --git a/packages/frontend/core/src/modules/quota/views/quota-check.tsx b/packages/frontend/core/src/modules/quota/views/quota-check.tsx index 62394d451b3a4..e28fa19fe64bc 100644 --- a/packages/frontend/core/src/modules/quota/views/quota-check.tsx +++ b/packages/frontend/core/src/modules/quota/views/quota-check.tsx @@ -1,14 +1,10 @@ import { useConfirmModal } from '@affine/component'; import { GlobalDialogService } from '@affine/core/modules/dialogs'; import { type I18nString, useI18n } from '@affine/i18n'; -import { - useLiveData, - useService, - type WorkspaceMetadata, - WorkspacesService, -} from '@toeverything/infra'; +import { useLiveData, useService } from '@toeverything/infra'; import { useCallback, useEffect } from 'react'; +import { type WorkspaceMetadata, WorkspacesService } from '../../workspace'; import { WorkspaceQuotaService } from '../services/quota'; import * as styles from './styles.css'; diff --git a/packages/frontend/core/src/modules/share-doc/entities/share-docs-list.ts b/packages/frontend/core/src/modules/share-doc/entities/share-docs-list.ts index 6a29d4b9343c0..17fb637cb8a64 100644 --- a/packages/frontend/core/src/modules/share-doc/entities/share-docs-list.ts +++ b/packages/frontend/core/src/modules/share-doc/entities/share-docs-list.ts @@ -1,6 +1,5 @@ import { DebugLogger } from '@affine/debug'; import type { GetWorkspacePublicPagesQuery } from '@affine/graphql'; -import type { GlobalCache, WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -15,6 +14,8 @@ import { import { EMPTY, mergeMap } from 'rxjs'; import { isBackendError, isNetworkError } from '../../cloud'; +import type { GlobalCache } from '../../storage'; +import type { WorkspaceService } from '../../workspace'; import type { ShareDocsStore } from '../stores/share-docs'; type ShareDocListType = diff --git a/packages/frontend/core/src/modules/share-doc/entities/share-info.ts b/packages/frontend/core/src/modules/share-doc/entities/share-info.ts index b99c3c8773361..926646d0e3d5d 100644 --- a/packages/frontend/core/src/modules/share-doc/entities/share-info.ts +++ b/packages/frontend/core/src/modules/share-doc/entities/share-info.ts @@ -2,7 +2,6 @@ import type { GetWorkspacePublicPageByIdQuery, PublicPageMode, } from '@affine/graphql'; -import type { DocService, WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -17,6 +16,8 @@ import { import { switchMap } from 'rxjs'; import { isBackendError, isNetworkError } from '../../cloud'; +import type { DocService } from '../../doc'; +import type { WorkspaceService } from '../../workspace'; import type { ShareStore } from '../stores/share'; type ShareInfoType = GetWorkspacePublicPageByIdQuery['workspace']['publicPage']; diff --git a/packages/frontend/core/src/modules/share-doc/index.ts b/packages/frontend/core/src/modules/share-doc/index.ts index 3feaa92939d34..c1a06f4bbc1d2 100644 --- a/packages/frontend/core/src/modules/share-doc/index.ts +++ b/packages/frontend/core/src/modules/share-doc/index.ts @@ -3,16 +3,15 @@ export { ShareDocsListService } from './services/share-docs-list'; export { ShareInfoService } from './services/share-info'; export { ShareReaderService } from './services/share-reader'; +import { type Framework } from '@toeverything/infra'; + +import { RawFetchProvider, WorkspaceServerService } from '../cloud'; +import { DocScope, DocService } from '../doc'; import { - DocScope, - DocService, - type Framework, WorkspaceLocalCache, WorkspaceScope, WorkspaceService, -} from '@toeverything/infra'; - -import { RawFetchProvider, WorkspaceServerService } from '../cloud'; +} from '../workspace'; import { ShareDocsList } from './entities/share-docs-list'; import { ShareInfo } from './entities/share-info'; import { ShareReader } from './entities/share-reader'; diff --git a/packages/frontend/core/src/modules/share-doc/services/share-docs-list.ts b/packages/frontend/core/src/modules/share-doc/services/share-docs-list.ts index b291fcf87b65e..ac4d2f54759ee 100644 --- a/packages/frontend/core/src/modules/share-doc/services/share-docs-list.ts +++ b/packages/frontend/core/src/modules/share-doc/services/share-docs-list.ts @@ -1,6 +1,6 @@ -import type { WorkspaceService } from '@toeverything/infra'; import { Service } from '@toeverything/infra'; +import type { WorkspaceService } from '../../workspace'; import { ShareDocsList } from '../entities/share-docs-list'; export class ShareDocsListService extends Service { diff --git a/packages/frontend/core/src/modules/share-setting/entities/share-setting.ts b/packages/frontend/core/src/modules/share-setting/entities/share-setting.ts index f77bccadd06bb..e837f676b7f79 100644 --- a/packages/frontend/core/src/modules/share-setting/entities/share-setting.ts +++ b/packages/frontend/core/src/modules/share-setting/entities/share-setting.ts @@ -1,6 +1,5 @@ import { DebugLogger } from '@affine/debug'; import type { GetWorkspaceConfigQuery, InviteLink } from '@affine/graphql'; -import type { WorkspaceService } from '@toeverything/infra'; import { backoffRetry, catchErrorInto, @@ -14,6 +13,7 @@ import { import { EMPTY, exhaustMap, mergeMap } from 'rxjs'; import { isBackendError, isNetworkError } from '../../cloud'; +import type { WorkspaceService } from '../../workspace'; import type { WorkspaceShareSettingStore } from '../stores/share-setting'; type EnableAi = GetWorkspaceConfigQuery['workspace']['enableAi']; diff --git a/packages/frontend/core/src/modules/share-setting/index.ts b/packages/frontend/core/src/modules/share-setting/index.ts index 3e24a82c49e57..7297c8db90d75 100644 --- a/packages/frontend/core/src/modules/share-setting/index.ts +++ b/packages/frontend/core/src/modules/share-setting/index.ts @@ -1,12 +1,9 @@ export { WorkspaceShareSettingService } from './services/share-setting'; -import { - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { WorkspaceServerService } from '../cloud'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { WorkspaceShareSetting } from './entities/share-setting'; import { WorkspaceShareSettingService } from './services/share-setting'; import { WorkspaceShareSettingStore } from './stores/share-setting'; diff --git a/packages/frontend/core/src/modules/storage/impls/electron.ts b/packages/frontend/core/src/modules/storage/impls/electron.ts index 8e31e31db65e0..7cbb6795aed2a 100644 --- a/packages/frontend/core/src/modules/storage/impls/electron.ts +++ b/packages/frontend/core/src/modules/storage/impls/electron.ts @@ -1,7 +1,7 @@ -import type { GlobalCache, GlobalState } from '@toeverything/infra'; import { Observable } from 'rxjs'; import type { DesktopApiService } from '../../desktop-api'; +import type { GlobalCache, GlobalState } from '../providers/global'; export class ElectronGlobalState implements GlobalState { constructor(private readonly electronApi: DesktopApiService) {} diff --git a/packages/frontend/core/src/modules/storage/impls/storage.ts b/packages/frontend/core/src/modules/storage/impls/storage.ts index 99aa43caca647..d17141dd29b46 100644 --- a/packages/frontend/core/src/modules/storage/impls/storage.ts +++ b/packages/frontend/core/src/modules/storage/impls/storage.ts @@ -1,10 +1,11 @@ +import type { Memento } from '@toeverything/infra'; +import { Observable } from 'rxjs'; + import type { GlobalCache, GlobalSessionState, GlobalState, - Memento, -} from '@toeverything/infra'; -import { Observable } from 'rxjs'; +} from '../providers/global'; export class StorageMemento implements Memento { constructor( diff --git a/packages/frontend/core/src/modules/storage/index.ts b/packages/frontend/core/src/modules/storage/index.ts index 3f2cf1c5e9830..7387b70c8f202 100644 --- a/packages/frontend/core/src/modules/storage/index.ts +++ b/packages/frontend/core/src/modules/storage/index.ts @@ -1,9 +1,15 @@ -import { - type Framework, +export { GlobalCache, GlobalSessionState, GlobalState, -} from '@toeverything/infra'; +} from './providers/global'; +export { + GlobalCacheService, + GlobalSessionStateService, + GlobalStateService, +} from './services/global'; + +import { type Framework } from '@toeverything/infra'; import { DesktopApiService } from '../desktop-api'; import { ElectronGlobalCache, ElectronGlobalState } from './impls/electron'; @@ -12,6 +18,22 @@ import { LocalStorageGlobalState, SessionStorageGlobalSessionState, } from './impls/storage'; +import { + GlobalCache, + GlobalSessionState, + GlobalState, +} from './providers/global'; +import { + GlobalCacheService, + GlobalSessionStateService, + GlobalStateService, +} from './services/global'; + +export const configureGlobalStorageModule = (framework: Framework) => { + framework.service(GlobalStateService, [GlobalState]); + framework.service(GlobalCacheService, [GlobalCache]); + framework.service(GlobalSessionStateService, [GlobalSessionState]); +}; export function configureLocalStorageStateStorageImpls(framework: Framework) { framework.impl(GlobalCache, LocalStorageGlobalCache); diff --git a/packages/common/infra/src/modules/storage/providers/global.ts b/packages/frontend/core/src/modules/storage/providers/global.ts similarity index 89% rename from packages/common/infra/src/modules/storage/providers/global.ts rename to packages/frontend/core/src/modules/storage/providers/global.ts index 5f127e9521d1c..36f643c25d60c 100644 --- a/packages/common/infra/src/modules/storage/providers/global.ts +++ b/packages/frontend/core/src/modules/storage/providers/global.ts @@ -1,5 +1,4 @@ -import { createIdentifier } from '../../../framework'; -import type { Memento } from '../../../storage'; +import { createIdentifier, type Memento } from '@toeverything/infra'; /** * A memento object that stores the entire application state. diff --git a/packages/common/infra/src/modules/storage/services/global.ts b/packages/frontend/core/src/modules/storage/services/global.ts similarity index 91% rename from packages/common/infra/src/modules/storage/services/global.ts rename to packages/frontend/core/src/modules/storage/services/global.ts index d121b46a5facb..1d81810b41785 100644 --- a/packages/common/infra/src/modules/storage/services/global.ts +++ b/packages/frontend/core/src/modules/storage/services/global.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import type { GlobalCache, GlobalSessionState, diff --git a/packages/frontend/core/src/modules/tag/entities/tag-list.ts b/packages/frontend/core/src/modules/tag/entities/tag-list.ts index efc5f473ffb0d..0bd77c61dd79f 100644 --- a/packages/frontend/core/src/modules/tag/entities/tag-list.ts +++ b/packages/frontend/core/src/modules/tag/entities/tag-list.ts @@ -1,6 +1,6 @@ -import type { DocsService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; +import type { DocsService } from '../../doc'; import { Tag } from '../entities/tag'; import type { TagStore } from '../stores/tag'; diff --git a/packages/frontend/core/src/modules/tag/entities/tag.ts b/packages/frontend/core/src/modules/tag/entities/tag.ts index 3c1076a1ee068..bee222f2d143a 100644 --- a/packages/frontend/core/src/modules/tag/entities/tag.ts +++ b/packages/frontend/core/src/modules/tag/entities/tag.ts @@ -1,6 +1,6 @@ -import type { DocsService } from '@toeverything/infra'; import { Entity, LiveData } from '@toeverything/infra'; +import type { DocsService } from '../../doc'; import type { TagStore } from '../stores/tag'; import { databaseTagColorToAffineLabel } from './utils'; diff --git a/packages/frontend/core/src/modules/tag/index.ts b/packages/frontend/core/src/modules/tag/index.ts index 5874b8072c1dc..9303bc0ab1753 100644 --- a/packages/frontend/core/src/modules/tag/index.ts +++ b/packages/frontend/core/src/modules/tag/index.ts @@ -6,13 +6,10 @@ export { export { TagService } from './service/tag'; export { useDeleteTagConfirmModal } from './view/delete-tag-modal'; -import { - DocsService, - type Framework, - WorkspaceScope, - WorkspaceService, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { DocsService } from '../doc'; +import { WorkspaceScope, WorkspaceService } from '../workspace'; import { Tag } from './entities/tag'; import { TagList } from './entities/tag-list'; import { TagService } from './service/tag'; diff --git a/packages/frontend/core/src/modules/tag/stores/tag.ts b/packages/frontend/core/src/modules/tag/stores/tag.ts index f22435d2f64b9..5f8e20a6663f8 100644 --- a/packages/frontend/core/src/modules/tag/stores/tag.ts +++ b/packages/frontend/core/src/modules/tag/stores/tag.ts @@ -1,10 +1,11 @@ import type { Tag, Tag as TagSchema } from '@affine/env/filter'; import type { DocsPropertiesMeta } from '@blocksuite/affine/store'; -import type { WorkspaceService } from '@toeverything/infra'; import { LiveData, Store } from '@toeverything/infra'; import { nanoid } from 'nanoid'; import { Observable } from 'rxjs'; +import type { WorkspaceService } from '../../workspace'; + export class TagStore extends Store { get properties() { return this.workspaceService.workspace.docCollection.meta.properties; diff --git a/packages/frontend/core/src/modules/telemetry/index.ts b/packages/frontend/core/src/modules/telemetry/index.ts index f44e97605b3d4..691b0d21031af 100644 --- a/packages/frontend/core/src/modules/telemetry/index.ts +++ b/packages/frontend/core/src/modules/telemetry/index.ts @@ -1,6 +1,7 @@ -import { type Framework, GlobalContextService } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { ServersService } from '../cloud'; +import { GlobalContextService } from '../global-context'; import { TelemetryService } from './services/telemetry'; export function configureTelemetryModule(framework: Framework) { diff --git a/packages/frontend/core/src/modules/telemetry/services/telemetry.ts b/packages/frontend/core/src/modules/telemetry/services/telemetry.ts index 4ab89d43ee372..3a111fe8a8e10 100644 --- a/packages/frontend/core/src/modules/telemetry/services/telemetry.ts +++ b/packages/frontend/core/src/modules/telemetry/services/telemetry.ts @@ -1,13 +1,9 @@ import { mixpanel } from '@affine/track'; -import type { GlobalContextService } from '@toeverything/infra'; -import { - ApplicationStarted, - LiveData, - OnEvent, - Service, -} from '@toeverything/infra'; +import { LiveData, OnEvent, Service } from '@toeverything/infra'; import type { AuthAccountInfo, Server, ServersService } from '../../cloud'; +import type { GlobalContextService } from '../../global-context'; +import { ApplicationStarted } from '../../lifecycle'; @OnEvent(ApplicationStarted, e => e.onApplicationStart) export class TelemetryService extends Service { diff --git a/packages/frontend/core/src/modules/theme-editor/index.ts b/packages/frontend/core/src/modules/theme-editor/index.ts index 20ad54662ec5b..7e3e001409314 100644 --- a/packages/frontend/core/src/modules/theme-editor/index.ts +++ b/packages/frontend/core/src/modules/theme-editor/index.ts @@ -1,5 +1,6 @@ -import { type Framework, GlobalState } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; +import { GlobalState } from '../storage'; import { ThemeEditorService } from './services/theme-editor'; export { ThemeEditorService }; diff --git a/packages/frontend/core/src/modules/theme-editor/services/theme-editor.ts b/packages/frontend/core/src/modules/theme-editor/services/theme-editor.ts index 8d5683693b09f..8ad5c91f46b3c 100644 --- a/packages/frontend/core/src/modules/theme-editor/services/theme-editor.ts +++ b/packages/frontend/core/src/modules/theme-editor/services/theme-editor.ts @@ -1,7 +1,7 @@ -import type { GlobalState } from '@toeverything/infra'; import { LiveData, Service } from '@toeverything/infra'; import { map } from 'rxjs'; +import type { GlobalState } from '../../storage'; import type { CustomTheme } from '../types'; export class ThemeEditorService extends Service { diff --git a/packages/frontend/core/src/modules/theme/index.ts b/packages/frontend/core/src/modules/theme/index.ts index f54ba14281b4e..027454eb9f53c 100644 --- a/packages/frontend/core/src/modules/theme/index.ts +++ b/packages/frontend/core/src/modules/theme/index.ts @@ -1,8 +1,9 @@ export { AppThemeService } from './services/theme'; -import { type Framework, WorkspaceScope } from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { EditorSettingService } from '../editor-setting'; +import { WorkspaceScope } from '../workspace'; import { AppTheme } from './entities/theme'; import { EdgelessThemeService } from './services/edgeless-theme'; import { AppThemeService } from './services/theme'; diff --git a/packages/frontend/core/src/modules/theme/services/edgeless-theme.ts b/packages/frontend/core/src/modules/theme/services/edgeless-theme.ts index d9806bf708525..ac3506e6255c4 100644 --- a/packages/frontend/core/src/modules/theme/services/edgeless-theme.ts +++ b/packages/frontend/core/src/modules/theme/services/edgeless-theme.ts @@ -1,6 +1,7 @@ -import type { DocRecord } from '@toeverything/infra'; -import { DocCreated, OnEvent, Service } from '@toeverything/infra'; +import { OnEvent, Service } from '@toeverything/infra'; +import type { DocRecord } from '../../doc'; +import { DocCreated } from '../../doc'; import type { EditorSettingService } from '../../editor-setting'; import type { EdgelessDefaultTheme } from '../../editor-setting/schema'; import type { AppThemeService } from './theme'; diff --git a/packages/frontend/core/src/modules/workbench/index.ts b/packages/frontend/core/src/modules/workbench/index.ts index 0a534128319ea..c2349d5fea15c 100644 --- a/packages/frontend/core/src/modules/workbench/index.ts +++ b/packages/frontend/core/src/modules/workbench/index.ts @@ -11,13 +11,11 @@ export type { WorkbenchLinkProps } from './view/workbench-link'; export { WorkbenchLink } from './view/workbench-link'; export { WorkbenchRoot } from './view/workbench-root'; -import { - type Framework, - GlobalStateService, - WorkspaceScope, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { DesktopApiService } from '../desktop-api'; +import { GlobalStateService } from '../storage'; +import { WorkspaceScope } from '../workspace'; import { SidebarTab } from './entities/sidebar-tab'; import { View } from './entities/view'; import { Workbench } from './entities/workbench'; diff --git a/packages/frontend/core/src/modules/workbench/services/workbench-view-state.ts b/packages/frontend/core/src/modules/workbench/services/workbench-view-state.ts index 18d3694cc47ad..d88dfea3c3fa9 100644 --- a/packages/frontend/core/src/modules/workbench/services/workbench-view-state.ts +++ b/packages/frontend/core/src/modules/workbench/services/workbench-view-state.ts @@ -1,8 +1,8 @@ -import type { GlobalStateService } from '@toeverything/infra'; import { createIdentifier, Service } from '@toeverything/infra'; import { nanoid } from 'nanoid'; import type { DesktopApiService, TabViewsMetaSchema } from '../../desktop-api'; +import type { GlobalStateService } from '../../storage'; import type { ViewIconName } from '../constants'; export type WorkbenchDefaultState = { diff --git a/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx b/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx index 429d42ae4ca39..98c6a5b156d1f 100644 --- a/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx +++ b/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx @@ -1,13 +1,10 @@ import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { isNewTabTrigger } from '@affine/core/utils'; -import { - FeatureFlagService, - useLiveData, - useServices, -} from '@toeverything/infra'; +import { useLiveData, useServices } from '@toeverything/infra'; import { type To } from 'history'; import { forwardRef, type MouseEvent } from 'react'; +import { FeatureFlagService } from '../../feature-flag'; import { WorkbenchService } from '../services/workbench'; export type WorkbenchLinkProps = React.PropsWithChildren< diff --git a/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts b/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts index 19559bfd6cb74..f047a31bb488c 100644 --- a/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts +++ b/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts @@ -13,19 +13,11 @@ import { effect, exhaustMapSwitchUntilChanged, fromPromise, - getAFFiNEWorkspaceSchema, - type GlobalState, LiveData, ObjectPool, onComplete, onStart, Service, - type Workspace, - type WorkspaceEngineProvider, - type WorkspaceFlavourProvider, - type WorkspaceFlavoursProvider, - type WorkspaceMetadata, - type WorkspaceProfileInfo, } from '@toeverything/infra'; import { isEqual } from 'lodash-es'; import { nanoid } from 'nanoid'; @@ -41,6 +33,16 @@ import { WebSocketService, WorkspaceServerService, } from '../../cloud'; +import type { GlobalState } from '../../storage'; +import { + getAFFiNEWorkspaceSchema, + type Workspace, + type WorkspaceEngineProvider, + type WorkspaceFlavourProvider, + type WorkspaceFlavoursProvider, + type WorkspaceMetadata, + type WorkspaceProfileInfo, +} from '../../workspace'; import type { WorkspaceEngineStorageProvider } from '../providers/engine'; import { BroadcastChannelAwarenessConnection } from './engine/awareness-broadcast-channel'; import { CloudAwarenessConnection } from './engine/awareness-cloud'; diff --git a/packages/frontend/core/src/modules/workspace-engine/impls/local.ts b/packages/frontend/core/src/modules/workspace-engine/impls/local.ts index 9fe869d144949..45c60b0f201a1 100644 --- a/packages/frontend/core/src/modules/workspace-engine/impls/local.ts +++ b/packages/frontend/core/src/modules/workspace-engine/impls/local.ts @@ -4,23 +4,22 @@ import type { BlobStorage, DocStorage, FrameworkProvider, - WorkspaceEngineProvider, - WorkspaceFlavourProvider, - WorkspaceFlavoursProvider, - WorkspaceMetadata, - WorkspaceProfileInfo, -} from '@toeverything/infra'; -import { - getAFFiNEWorkspaceSchema, - LiveData, - Service, } from '@toeverything/infra'; +import { LiveData, Service } from '@toeverything/infra'; import { isEqual } from 'lodash-es'; import { nanoid } from 'nanoid'; import { Observable } from 'rxjs'; import { encodeStateAsUpdate } from 'yjs'; import { DesktopApiService } from '../../desktop-api'; +import { + getAFFiNEWorkspaceSchema, + type WorkspaceEngineProvider, + type WorkspaceFlavourProvider, + type WorkspaceFlavoursProvider, + type WorkspaceMetadata, + type WorkspaceProfileInfo, +} from '../../workspace'; import type { WorkspaceEngineStorageProvider } from '../providers/engine'; import { BroadcastChannelAwarenessConnection } from './engine/awareness-broadcast-channel'; import { StaticBlobStorage } from './engine/blob-static'; diff --git a/packages/frontend/core/src/modules/workspace-engine/index.ts b/packages/frontend/core/src/modules/workspace-engine/index.ts index 4175a499b6e4c..bde7581b45c44 100644 --- a/packages/frontend/core/src/modules/workspace-engine/index.ts +++ b/packages/frontend/core/src/modules/workspace-engine/index.ts @@ -1,11 +1,9 @@ -import { - type Framework, - GlobalState, - WorkspaceFlavoursProvider, -} from '@toeverything/infra'; +import { type Framework } from '@toeverything/infra'; import { ServersService } from '../cloud/services/servers'; import { DesktopApiService } from '../desktop-api'; +import { GlobalState } from '../storage'; +import { WorkspaceFlavoursProvider } from '../workspace'; import { CloudWorkspaceFlavoursProvider } from './impls/cloud'; import { IndexedDBBlobStorage } from './impls/engine/blob-indexeddb'; import { SqliteBlobStorage } from './impls/engine/blob-sqlite'; diff --git a/packages/common/infra/src/modules/workspace/entities/engine.ts b/packages/frontend/core/src/modules/workspace/entities/engine.ts similarity index 92% rename from packages/common/infra/src/modules/workspace/entities/engine.ts rename to packages/frontend/core/src/modules/workspace/entities/engine.ts index fb6354ccd1beb..8433cf6c57e58 100644 --- a/packages/common/infra/src/modules/workspace/entities/engine.ts +++ b/packages/frontend/core/src/modules/workspace/entities/engine.ts @@ -1,8 +1,12 @@ +import { + AwarenessEngine, + BlobEngine, + DocEngine, + Entity, + throwIfAborted, +} from '@toeverything/infra'; import type { Doc as YDoc } from 'yjs'; -import { Entity } from '../../../framework'; -import { AwarenessEngine, BlobEngine, DocEngine } from '../../../sync'; -import { throwIfAborted } from '../../../utils'; import { WorkspaceEngineBeforeStart } from '../events'; import type { WorkspaceEngineProvider } from '../providers/flavour'; import type { WorkspaceService } from '../services/workspace'; diff --git a/packages/common/infra/src/modules/workspace/entities/list.ts b/packages/frontend/core/src/modules/workspace/entities/list.ts similarity index 93% rename from packages/common/infra/src/modules/workspace/entities/list.ts rename to packages/frontend/core/src/modules/workspace/entities/list.ts index 54fda37b0f693..8d0384515a020 100644 --- a/packages/common/infra/src/modules/workspace/entities/list.ts +++ b/packages/frontend/core/src/modules/workspace/entities/list.ts @@ -1,7 +1,6 @@ +import { Entity, LiveData } from '@toeverything/infra'; import { combineLatest, map, of, switchMap } from 'rxjs'; -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; import type { WorkspaceMetadata } from '../metadata'; import type { WorkspaceFlavoursService } from '../services/flavours'; diff --git a/packages/common/infra/src/modules/workspace/entities/profile.ts b/packages/frontend/core/src/modules/workspace/entities/profile.ts similarity index 97% rename from packages/common/infra/src/modules/workspace/entities/profile.ts rename to packages/frontend/core/src/modules/workspace/entities/profile.ts index a4ed2445f842c..e621055fa18ab 100644 --- a/packages/common/infra/src/modules/workspace/entities/profile.ts +++ b/packages/frontend/core/src/modules/workspace/entities/profile.ts @@ -1,15 +1,15 @@ import { DebugLogger } from '@affine/debug'; -import { isEqual } from 'lodash-es'; -import { catchError, EMPTY, exhaustMap, mergeMap } from 'rxjs'; - -import { Entity } from '../../../framework'; import { effect, + Entity, fromPromise, LiveData, onComplete, onStart, -} from '../../../livedata'; +} from '@toeverything/infra'; +import { isEqual } from 'lodash-es'; +import { catchError, EMPTY, exhaustMap, mergeMap } from 'rxjs'; + import type { WorkspaceMetadata } from '../metadata'; import type { WorkspaceFlavourProvider } from '../providers/flavour'; import type { WorkspaceFlavoursService } from '../services/flavours'; diff --git a/packages/common/infra/src/modules/workspace/entities/workspace.ts b/packages/frontend/core/src/modules/workspace/entities/workspace.ts similarity index 96% rename from packages/common/infra/src/modules/workspace/entities/workspace.ts rename to packages/frontend/core/src/modules/workspace/entities/workspace.ts index 0d01fc62de87c..12d83e689bc6a 100644 --- a/packages/common/infra/src/modules/workspace/entities/workspace.ts +++ b/packages/frontend/core/src/modules/workspace/entities/workspace.ts @@ -1,10 +1,9 @@ import { DocCollection } from '@blocksuite/affine/store'; +import { Entity, LiveData } from '@toeverything/infra'; import { nanoid } from 'nanoid'; import { Observable } from 'rxjs'; import type { Awareness } from 'y-protocols/awareness.js'; -import { Entity } from '../../../framework'; -import { LiveData } from '../../../livedata'; import { WorkspaceDBService } from '../../db'; import { getAFFiNEWorkspaceSchema } from '../global-schema'; import type { WorkspaceScope } from '../scopes/workspace'; diff --git a/packages/common/infra/src/modules/workspace/events/index.ts b/packages/frontend/core/src/modules/workspace/events/index.ts similarity index 85% rename from packages/common/infra/src/modules/workspace/events/index.ts rename to packages/frontend/core/src/modules/workspace/events/index.ts index 9e0c68c01d150..4da388a729334 100644 --- a/packages/common/infra/src/modules/workspace/events/index.ts +++ b/packages/frontend/core/src/modules/workspace/events/index.ts @@ -1,4 +1,5 @@ -import { createEvent } from '../../../framework'; +import { createEvent } from '@toeverything/infra'; + import type { WorkspaceEngine } from '../entities/engine'; import type { Workspace } from '../entities/workspace'; diff --git a/packages/common/infra/src/modules/workspace/global-schema.ts b/packages/frontend/core/src/modules/workspace/global-schema.ts similarity index 78% rename from packages/common/infra/src/modules/workspace/global-schema.ts rename to packages/frontend/core/src/modules/workspace/global-schema.ts index 5f8dc895487e2..49f1da210c195 100644 --- a/packages/common/infra/src/modules/workspace/global-schema.ts +++ b/packages/frontend/core/src/modules/workspace/global-schema.ts @@ -1,7 +1,6 @@ import { AffineSchemas } from '@blocksuite/affine/blocks/schemas'; import { Schema } from '@blocksuite/affine/store'; - -import { AIChatBlockSchema } from '../../blocksuite/blocks/ai-chat-block/ai-chat-model'; +import { AIChatBlockSchema } from '@toeverything/infra'; let _schema: Schema | null = null; export function getAFFiNEWorkspaceSchema() { diff --git a/packages/common/infra/src/modules/workspace/impls/storage.ts b/packages/frontend/core/src/modules/workspace/impls/storage.ts similarity index 96% rename from packages/common/infra/src/modules/workspace/impls/storage.ts rename to packages/frontend/core/src/modules/workspace/impls/storage.ts index fd85f0ff4c4f3..033feaebaa9ff 100644 --- a/packages/common/infra/src/modules/workspace/impls/storage.ts +++ b/packages/frontend/core/src/modules/workspace/impls/storage.ts @@ -1,4 +1,5 @@ -import { type Memento, wrapMemento } from '../../../storage'; +import { type Memento, wrapMemento } from '@toeverything/infra'; + import type { GlobalCache, GlobalState } from '../../storage'; import type { WorkspaceLocalCache, diff --git a/packages/common/infra/src/modules/workspace/index.ts b/packages/frontend/core/src/modules/workspace/index.ts similarity index 91% rename from packages/common/infra/src/modules/workspace/index.ts rename to packages/frontend/core/src/modules/workspace/index.ts index 763909270591a..130d043d7665d 100644 --- a/packages/common/infra/src/modules/workspace/index.ts +++ b/packages/frontend/core/src/modules/workspace/index.ts @@ -12,7 +12,8 @@ export { WorkspaceScope } from './scopes/workspace'; export { WorkspaceService } from './services/workspace'; export { WorkspacesService } from './services/workspaces'; -import type { Framework } from '../../framework'; +import type { Framework } from '@toeverything/infra'; + import { GlobalCache, GlobalState } from '../storage'; import { WorkspaceEngine } from './entities/engine'; import { WorkspaceList } from './entities/list'; @@ -36,7 +37,6 @@ import { WorkspaceTransformService } from './services/transform'; import { WorkspaceService } from './services/workspace'; import { WorkspacesService } from './services/workspaces'; import { WorkspaceProfileCacheStore } from './stores/profile-cache'; -import { TestingWorkspaceFlavoursProvider } from './testing/testing-provider'; export function configureWorkspaceModule(framework: Framework) { framework @@ -82,11 +82,3 @@ export function configureWorkspaceModule(framework: Framework) { GlobalCache, ]); } - -export function configureTestingWorkspaceProvider(framework: Framework) { - framework.impl( - WorkspaceFlavoursProvider('LOCAL'), - TestingWorkspaceFlavoursProvider, - [GlobalState] - ); -} diff --git a/packages/common/infra/src/modules/workspace/metadata.ts b/packages/frontend/core/src/modules/workspace/metadata.ts similarity index 100% rename from packages/common/infra/src/modules/workspace/metadata.ts rename to packages/frontend/core/src/modules/workspace/metadata.ts diff --git a/packages/common/infra/src/modules/workspace/open-options.ts b/packages/frontend/core/src/modules/workspace/open-options.ts similarity index 100% rename from packages/common/infra/src/modules/workspace/open-options.ts rename to packages/frontend/core/src/modules/workspace/open-options.ts diff --git a/packages/common/infra/src/modules/workspace/providers/flavour.ts b/packages/frontend/core/src/modules/workspace/providers/flavour.ts similarity index 88% rename from packages/common/infra/src/modules/workspace/providers/flavour.ts rename to packages/frontend/core/src/modules/workspace/providers/flavour.ts index ce2a24fc3ab7a..c194aaee4ab73 100644 --- a/packages/common/infra/src/modules/workspace/providers/flavour.ts +++ b/packages/frontend/core/src/modules/workspace/providers/flavour.ts @@ -1,13 +1,13 @@ import type { DocCollection } from '@blocksuite/affine/store'; +import { + type AwarenessConnection, + type BlobStorage, + createIdentifier, + type DocServer, + type DocStorage, + type LiveData, +} from '@toeverything/infra'; -import { createIdentifier } from '../../../framework'; -import type { LiveData } from '../../../livedata'; -import type { - AwarenessConnection, - BlobStorage, - DocServer, - DocStorage, -} from '../../../sync'; import type { WorkspaceProfileInfo } from '../entities/profile'; import type { Workspace } from '../entities/workspace'; import type { WorkspaceMetadata } from '../metadata'; diff --git a/packages/common/infra/src/modules/workspace/providers/storage.ts b/packages/frontend/core/src/modules/workspace/providers/storage.ts similarity index 75% rename from packages/common/infra/src/modules/workspace/providers/storage.ts rename to packages/frontend/core/src/modules/workspace/providers/storage.ts index 08090d671cdcc..a266a58a8cf4b 100644 --- a/packages/common/infra/src/modules/workspace/providers/storage.ts +++ b/packages/frontend/core/src/modules/workspace/providers/storage.ts @@ -1,5 +1,4 @@ -import { createIdentifier } from '../../../framework'; -import type { Memento } from '../../../storage'; +import { createIdentifier, type Memento } from '@toeverything/infra'; export interface WorkspaceLocalState extends Memento {} export interface WorkspaceLocalCache extends Memento {} diff --git a/packages/common/infra/src/modules/workspace/scopes/workspace.ts b/packages/frontend/core/src/modules/workspace/scopes/workspace.ts similarity index 87% rename from packages/common/infra/src/modules/workspace/scopes/workspace.ts rename to packages/frontend/core/src/modules/workspace/scopes/workspace.ts index 934eee8ebd6af..8a8ac82d7117d 100644 --- a/packages/common/infra/src/modules/workspace/scopes/workspace.ts +++ b/packages/frontend/core/src/modules/workspace/scopes/workspace.ts @@ -1,4 +1,5 @@ -import { Scope } from '../../../framework'; +import { Scope } from '@toeverything/infra'; + import type { WorkspaceOpenOptions } from '../open-options'; import type { WorkspaceEngineProvider } from '../providers/flavour'; diff --git a/packages/common/infra/src/modules/workspace/services/destroy.ts b/packages/frontend/core/src/modules/workspace/services/destroy.ts similarity index 92% rename from packages/common/infra/src/modules/workspace/services/destroy.ts rename to packages/frontend/core/src/modules/workspace/services/destroy.ts index 71a090e5416b7..40e7d85e90b61 100644 --- a/packages/common/infra/src/modules/workspace/services/destroy.ts +++ b/packages/frontend/core/src/modules/workspace/services/destroy.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import type { WorkspaceMetadata } from '../metadata'; import type { WorkspaceFlavoursService } from './flavours'; diff --git a/packages/common/infra/src/modules/workspace/services/engine.ts b/packages/frontend/core/src/modules/workspace/services/engine.ts similarity index 92% rename from packages/common/infra/src/modules/workspace/services/engine.ts rename to packages/frontend/core/src/modules/workspace/services/engine.ts index 93eba3e04a1e4..10907d6e802db 100644 --- a/packages/common/infra/src/modules/workspace/services/engine.ts +++ b/packages/frontend/core/src/modules/workspace/services/engine.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import { WorkspaceEngine } from '../entities/engine'; import type { WorkspaceScope } from '../scopes/workspace'; diff --git a/packages/common/infra/src/modules/workspace/services/factory.ts b/packages/frontend/core/src/modules/workspace/services/factory.ts similarity index 89% rename from packages/common/infra/src/modules/workspace/services/factory.ts rename to packages/frontend/core/src/modules/workspace/services/factory.ts index 2442e227dc7eb..bd642360608ba 100644 --- a/packages/common/infra/src/modules/workspace/services/factory.ts +++ b/packages/frontend/core/src/modules/workspace/services/factory.ts @@ -1,7 +1,10 @@ import type { DocCollection } from '@blocksuite/affine/store'; +import { + type BlobStorage, + type DocStorage, + Service, +} from '@toeverything/infra'; -import { Service } from '../../../framework'; -import type { BlobStorage, DocStorage } from '../../../sync'; import type { WorkspaceFlavoursService } from './flavours'; export class WorkspaceFactoryService extends Service { diff --git a/packages/common/infra/src/modules/workspace/services/flavours.ts b/packages/frontend/core/src/modules/workspace/services/flavours.ts similarity index 82% rename from packages/common/infra/src/modules/workspace/services/flavours.ts rename to packages/frontend/core/src/modules/workspace/services/flavours.ts index c248eb36e0630..21a84380f66b5 100644 --- a/packages/common/infra/src/modules/workspace/services/flavours.ts +++ b/packages/frontend/core/src/modules/workspace/services/flavours.ts @@ -1,7 +1,6 @@ +import { LiveData, Service } from '@toeverything/infra'; import { combineLatest, map } from 'rxjs'; -import { Service } from '../../../framework'; -import { LiveData } from '../../../livedata'; import type { WorkspaceFlavoursProvider } from '../providers/flavour'; export class WorkspaceFlavoursService extends Service { diff --git a/packages/common/infra/src/modules/workspace/services/list.ts b/packages/frontend/core/src/modules/workspace/services/list.ts similarity index 76% rename from packages/common/infra/src/modules/workspace/services/list.ts rename to packages/frontend/core/src/modules/workspace/services/list.ts index 7521f8b60cb13..53c86bce3438a 100644 --- a/packages/common/infra/src/modules/workspace/services/list.ts +++ b/packages/frontend/core/src/modules/workspace/services/list.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import { WorkspaceList } from '../entities/list'; export class WorkspaceListService extends Service { diff --git a/packages/common/infra/src/modules/workspace/services/profile.ts b/packages/frontend/core/src/modules/workspace/services/profile.ts similarity index 85% rename from packages/common/infra/src/modules/workspace/services/profile.ts rename to packages/frontend/core/src/modules/workspace/services/profile.ts index 01f06f760f05f..3ee7d29feb6ef 100644 --- a/packages/common/infra/src/modules/workspace/services/profile.ts +++ b/packages/frontend/core/src/modules/workspace/services/profile.ts @@ -1,5 +1,5 @@ -import { Service } from '../../../framework'; -import { ObjectPool } from '../../../utils'; +import { ObjectPool, Service } from '@toeverything/infra'; + import { WorkspaceProfile } from '../entities/profile'; import type { WorkspaceMetadata } from '../metadata'; diff --git a/packages/common/infra/src/modules/workspace/services/repo.ts b/packages/frontend/core/src/modules/workspace/services/repo.ts similarity index 97% rename from packages/common/infra/src/modules/workspace/services/repo.ts rename to packages/frontend/core/src/modules/workspace/services/repo.ts index 1fee2f1cfa85d..57fe2cf4075ee 100644 --- a/packages/common/infra/src/modules/workspace/services/repo.ts +++ b/packages/frontend/core/src/modules/workspace/services/repo.ts @@ -1,7 +1,6 @@ import { DebugLogger } from '@affine/debug'; +import { ObjectPool, Service } from '@toeverything/infra'; -import { Service } from '../../../framework'; -import { ObjectPool } from '../../../utils'; import type { Workspace } from '../entities/workspace'; import { WorkspaceInitialized } from '../events'; import type { WorkspaceOpenOptions } from '../open-options'; diff --git a/packages/common/infra/src/modules/workspace/services/transform.ts b/packages/frontend/core/src/modules/workspace/services/transform.ts similarity index 97% rename from packages/common/infra/src/modules/workspace/services/transform.ts rename to packages/frontend/core/src/modules/workspace/services/transform.ts index b84ddeb4d7ce2..dc5ecad53e273 100644 --- a/packages/common/infra/src/modules/workspace/services/transform.ts +++ b/packages/frontend/core/src/modules/workspace/services/transform.ts @@ -1,7 +1,7 @@ import { assertEquals } from '@blocksuite/affine/global/utils'; +import { Service } from '@toeverything/infra'; import { applyUpdate } from 'yjs'; -import { Service } from '../../../framework'; import { transformWorkspaceDBLocalToCloud } from '../../db'; import type { Workspace } from '../entities/workspace'; import type { WorkspaceMetadata } from '../metadata'; diff --git a/packages/common/infra/src/modules/workspace/services/workspace.ts b/packages/frontend/core/src/modules/workspace/services/workspace.ts similarity index 88% rename from packages/common/infra/src/modules/workspace/services/workspace.ts rename to packages/frontend/core/src/modules/workspace/services/workspace.ts index 40ae067de7f09..6266f9a82f1a1 100644 --- a/packages/common/infra/src/modules/workspace/services/workspace.ts +++ b/packages/frontend/core/src/modules/workspace/services/workspace.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import { Workspace } from '../entities/workspace'; export class WorkspaceService extends Service { diff --git a/packages/common/infra/src/modules/workspace/services/workspaces.ts b/packages/frontend/core/src/modules/workspace/services/workspaces.ts similarity index 97% rename from packages/common/infra/src/modules/workspace/services/workspaces.ts rename to packages/frontend/core/src/modules/workspace/services/workspaces.ts index 455982105aa60..4d08882421dad 100644 --- a/packages/common/infra/src/modules/workspace/services/workspaces.ts +++ b/packages/frontend/core/src/modules/workspace/services/workspaces.ts @@ -1,4 +1,5 @@ -import { Service } from '../../../framework'; +import { Service } from '@toeverything/infra'; + import type { WorkspaceMetadata } from '..'; import type { WorkspaceDestroyService } from './destroy'; import type { WorkspaceFactoryService } from './factory'; diff --git a/packages/common/infra/src/modules/workspace/stores/profile-cache.ts b/packages/frontend/core/src/modules/workspace/stores/profile-cache.ts similarity index 95% rename from packages/common/infra/src/modules/workspace/stores/profile-cache.ts rename to packages/frontend/core/src/modules/workspace/stores/profile-cache.ts index 621739d40ec71..b6bf8d736a218 100644 --- a/packages/common/infra/src/modules/workspace/stores/profile-cache.ts +++ b/packages/frontend/core/src/modules/workspace/stores/profile-cache.ts @@ -1,6 +1,6 @@ +import { Store } from '@toeverything/infra'; import { map } from 'rxjs'; -import { Store } from '../../../framework'; import type { GlobalCache } from '../../storage'; import type { WorkspaceProfileInfo } from '../entities/profile'; diff --git a/packages/frontend/core/src/utils/first-app-data.ts b/packages/frontend/core/src/utils/first-app-data.ts index 57c977d9b5c16..368bd7acf1e2f 100644 --- a/packages/frontend/core/src/utils/first-app-data.ts +++ b/packages/frontend/core/src/utils/first-app-data.ts @@ -2,8 +2,9 @@ import { DebugLogger } from '@affine/debug'; import { DEFAULT_WORKSPACE_NAME } from '@affine/env/constant'; import onboardingUrl from '@affine/templates/onboarding.zip'; import { ZipTransformer } from '@blocksuite/affine/blocks'; -import type { WorkspacesService } from '@toeverything/infra'; -import { DocsService } from '@toeverything/infra'; + +import { DocsService } from '../modules/doc'; +import type { WorkspacesService } from '../modules/workspace'; export async function buildShowcaseWorkspace( workspacesService: WorkspacesService,