refactor: move command registry to frontend/core (#7135)

move command registeration related logic out of infra module.
This commit is contained in:
pengx17 2024-06-05 14:09:20 +00:00
parent fa4e4c738a
commit de81527e29
No known key found for this signature in database
GPG Key ID: 23F23D9E8B3971ED
24 changed files with 31 additions and 32 deletions

View File

@ -23,7 +23,6 @@
"lodash-es": "^4.17.21",
"nanoid": "^5.0.7",
"react": "18.3.1",
"tinykeys": "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch",
"yjs": "^13.6.14",
"zod": "^3.22.4"
},

View File

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

View File

@ -83,6 +83,7 @@
"ses": "^1.4.1",
"socket.io-client": "^4.7.5",
"swr": "2.2.5",
"tinykeys": "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch",
"uuid": "^9.0.1",
"valtio": "^1.13.2",
"y-protocols": "^1.0.6",

View File

@ -1,10 +1,10 @@
import type { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ImportIcon, PlusIcon } from '@blocksuite/icons';
import { registerAffineCommand } from '@toeverything/infra';
import type { createStore } from 'jotai';
import { openCreateWorkspaceModalAtom } from '../atoms';
import type { usePageHelper } from '../components/blocksuite/block-suite-page-list/utils';
import { registerAffineCommand } from './registry';
export function registerAffineCreationCommands({
store,

View File

@ -1,10 +1,10 @@
import type { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ContactWithUsIcon, NewIcon } from '@blocksuite/icons';
import { registerAffineCommand } from '@toeverything/infra';
import type { createStore } from 'jotai';
import { openSettingModalAtom } from '../atoms';
import { popupWindow } from '../utils';
import { registerAffineCommand } from './registry';
export function registerAffineHelpCommands({
t,

View File

@ -1,9 +1,9 @@
import type { useAFFiNEI18N } from '@affine/i18n/hooks';
import { SidebarIcon } from '@blocksuite/icons';
import { registerAffineCommand } from '@toeverything/infra';
import type { createStore } from 'jotai';
import { appSidebarOpenAtom } from '../components/app-sidebar';
import { registerAffineCommand } from './registry';
export function registerAffineLayoutCommands({
t,

View File

@ -2,12 +2,12 @@ import { WorkspaceSubPath } from '@affine/core/shared';
import type { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ArrowRightBigIcon } from '@blocksuite/icons';
import type { DocCollection } from '@blocksuite/store';
import { registerAffineCommand } from '@toeverything/infra';
import type { createStore } from 'jotai';
import { openSettingModalAtom, openWorkspaceListModalAtom } from '../atoms';
import type { useNavigateHelper } from '../hooks/use-navigate-helper';
import { mixpanel } from '../utils/mixpanel';
import { registerAffineCommand } from './registry';
export function registerAffineNavigationCommands({
t,

View File

@ -1,17 +1,14 @@
import type { useAFFiNEI18N } from '@affine/i18n/hooks';
import { SettingsIcon } from '@blocksuite/icons';
import type { AffineEditorContainer } from '@blocksuite/presets';
import {
appSettingAtom,
PreconditionStrategy,
registerAffineCommand,
} from '@toeverything/infra';
import { appSettingAtom } from '@toeverything/infra';
import type { createStore } from 'jotai';
import type { useTheme } from 'next-themes';
import { openQuickSearchModalAtom } from '../atoms';
import type { useLanguageHelper } from '../hooks/affine/use-language-helper';
import { mixpanel } from '../utils';
import { PreconditionStrategy, registerAffineCommand } from './registry';
export function registerAffineSettingsCommands({
t,

View File

@ -2,9 +2,10 @@ import { updateReadyAtom } from '@affine/core/hooks/use-app-updater';
import { apis } from '@affine/electron-api';
import type { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ResetIcon } from '@blocksuite/icons';
import { registerAffineCommand } from '@toeverything/infra';
import type { createStore } from 'jotai';
import { registerAffineCommand } from './registry';
export function registerAffineUpdatesCommands({
t,
store,

View File

@ -4,3 +4,4 @@ export * from './affine-layout';
export * from './affine-navigation';
export * from './affine-settings';
export * from './affine-updates';
export * from './registry';

View File

@ -1,3 +1,9 @@
import {
type AffineCommand,
AffineCommandRegistry,
type CommandCategory,
PreconditionStrategy,
} from '@affine/core/commands';
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
import { useGetDocCollectionPageTitle } from '@affine/core/hooks/use-block-suite-workspace-page-title';
import { useJournalHelper } from '@affine/core/hooks/use-journal';
@ -12,17 +18,10 @@ import {
TodayIcon,
ViewLayersIcon,
} from '@blocksuite/icons';
import type {
AffineCommand,
CommandCategory,
DocRecord,
Workspace,
} from '@toeverything/infra';
import type { DocRecord, Workspace } from '@toeverything/infra';
import {
AffineCommandRegistry,
DocsService,
GlobalContextService,
PreconditionStrategy,
useLiveData,
useService,
WorkspaceService,

View File

@ -1,4 +1,4 @@
import type { CommandCategory } from '@toeverything/infra';
import type { CommandCategory } from '@affine/core/commands';
import { groupBy } from 'lodash-es';
import { commandScore } from './command-score';

View File

@ -1,10 +1,10 @@
import { Loading } from '@affine/component/ui/loading';
import type { CommandCategory } from '@affine/core/commands';
import { formatDate } from '@affine/core/components/page-list';
import { useDocEngineStatus } from '@affine/core/hooks/affine/use-doc-engine-status';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import type { DocMeta } from '@blocksuite/store';
import type { CommandCategory } from '@toeverything/infra';
import clsx from 'clsx';
import { Command } from 'cmdk';
import { useDebouncedValue } from 'foxact/use-debounced-value';

View File

@ -1,4 +1,5 @@
import type { CommandCategory, DocMode } from '@toeverything/infra';
import type { CommandCategory } from '@affine/core/commands';
import type { DocMode } from '@toeverything/infra';
export interface CommandContext {
docMode: DocMode | undefined;

View File

@ -1,4 +1,8 @@
import { toast } from '@affine/component';
import {
PreconditionStrategy,
registerAffineCommand,
} from '@affine/core/commands';
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
import { mixpanel } from '@affine/core/utils';
@ -8,8 +12,6 @@ import { assertExists } from '@blocksuite/global/utils';
import { EdgelessIcon, HistoryIcon, PageIcon } from '@blocksuite/icons';
import {
DocService,
PreconditionStrategy,
registerAffineCommand,
useLiveData,
useService,
WorkspaceService,

View File

@ -1,5 +1,5 @@
import { registerAffineCommand } from '@affine/core/commands';
import { useSharingUrl } from '@affine/core/hooks/affine/use-share-url';
import { registerAffineCommand } from '@toeverything/infra';
import { useEffect } from 'react';
export function useRegisterCopyLinkCommands({

View File

@ -1,5 +1,6 @@
import { registerAffineCommand } from '@affine/core/commands';
import { FindInPageService } from '@affine/core/modules/find-in-page/services/find-in-page';
import { registerAffineCommand, useService } from '@toeverything/infra';
import { useService } from '@toeverything/infra';
import { useCallback, useEffect } from 'react';
export function useRegisterFindInPageCommands() {

View File

@ -1,8 +1,8 @@
import {
PreconditionStrategy,
registerAffineCommand,
useService,
} from '@toeverything/infra';
} from '@affine/core/commands';
import { useService } from '@toeverything/infra';
import { useEffect } from 'react';
import { NavigatorService } from '../services/navigator';

View File

@ -68,7 +68,6 @@
"react-router-dom": "^6.22.3",
"rxjs": "^7.8.1",
"semver": "^7.6.0",
"tinykeys": "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch",
"tree-kill": "^1.2.2",
"ts-node": "^10.9.2",
"undici": "^6.12.0",

View File

@ -400,6 +400,7 @@ __metadata:
ses: "npm:^1.4.1"
socket.io-client: "npm:^4.7.5"
swr: "npm:2.2.5"
tinykeys: "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch"
uuid: "npm:^9.0.1"
valtio: "npm:^1.13.2"
vitest: "npm:1.6.0"
@ -490,7 +491,6 @@ __metadata:
react-router-dom: "npm:^6.22.3"
rxjs: "npm:^7.8.1"
semver: "npm:^7.6.0"
tinykeys: "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch"
tree-kill: "npm:^1.2.2"
ts-node: "npm:^10.9.2"
undici: "npm:^6.12.0"
@ -13908,7 +13908,6 @@ __metadata:
nanoid: "npm:^5.0.7"
react: "npm:^18.2.0"
rxjs: "npm:^7.8.1"
tinykeys: "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch"
vite: "npm:^5.2.8"
vite-plugin-dts: "npm:3.9.1"
vitest: "npm:1.6.0"