There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor: move command registry to frontend/core (#7135)
pengx17de81527e294e
diff --git a/packages/common/infra/package.json b/packages/common/infra/package.jsonindex 42b27bfc36..6ee89f2c4d 100644--- a/packages/common/infra/package.json+++ b/packages/common/infra/package.json@@ -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"},diff --git a/packages/common/infra/src/index.ts b/packages/common/infra/src/index.tsindex 03155ccf94..e06e9400fe 100644--- a/packages/common/infra/src/index.ts+++ b/packages/common/infra/src/index.ts@@ -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';diff --git a/packages/frontend/core/package.json b/packages/frontend/core/package.jsonindex d73370d5e9..eccc9c293d 100644--- a/packages/frontend/core/package.json+++ b/packages/frontend/core/package.json@@ -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",diff --git a/packages/frontend/core/src/commands/affine-creation.tsx b/packages/frontend/core/src/commands/affine-creation.tsxindex 3dd502e76e..2f7cdd4b02 100644--- a/packages/frontend/core/src/commands/affine-creation.tsx+++ b/packages/frontend/core/src/commands/affine-creation.tsx@@ -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,diff --git a/packages/frontend/core/src/commands/affine-help.tsx b/packages/frontend/core/src/commands/affine-help.tsxindex 130f86b306..7edb5708e4 100644--- a/packages/frontend/core/src/commands/affine-help.tsx+++ b/packages/frontend/core/src/commands/affine-help.tsx@@ -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,diff --git a/packages/frontend/core/src/commands/affine-layout.tsx b/packages/frontend/core/src/commands/affine-layout.tsxindex 6906f5ea7c..748accb072 100644--- a/packages/frontend/core/src/commands/affine-layout.tsx+++ b/packages/frontend/core/src/commands/affine-layout.tsx@@ -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,diff --git a/packages/frontend/core/src/commands/affine-navigation.tsx b/packages/frontend/core/src/commands/affine-navigation.tsxindex 5e6454175e..8ae99bd285 100644--- a/packages/frontend/core/src/commands/affine-navigation.tsx+++ b/packages/frontend/core/src/commands/affine-navigation.tsx@@ -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,diff --git a/packages/frontend/core/src/commands/affine-settings.tsx b/packages/frontend/core/src/commands/affine-settings.tsxindex 2429931945..1bc2b56e6f 100644--- a/packages/frontend/core/src/commands/affine-settings.tsx+++ b/packages/frontend/core/src/commands/affine-settings.tsx@@ -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,diff --git a/packages/frontend/core/src/commands/affine-updates.tsx b/packages/frontend/core/src/commands/affine-updates.tsxindex ba2274dee1..28092f10f4 100644--- a/packages/frontend/core/src/commands/affine-updates.tsx+++ b/packages/frontend/core/src/commands/affine-updates.tsx@@ -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,diff --git a/packages/frontend/core/src/commands/index.ts b/packages/frontend/core/src/commands/index.tsindex b2b5ddafab..8a496f1453 100644--- a/packages/frontend/core/src/commands/index.ts+++ b/packages/frontend/core/src/commands/index.ts@@ -4,3 +4,4 @@ export * from './affine-layout';export * from './affine-navigation';export * from './affine-settings';export * from './affine-updates';+export * from './registry';diff --git a/packages/common/infra/src/command/README.md b/packages/frontend/core/src/commands/registry/README.mdsimilarity index 100%rename from packages/common/infra/src/command/README.mdrename to packages/frontend/core/src/commands/registry/README.mddiff --git a/packages/common/infra/src/command/command.ts b/packages/frontend/core/src/commands/registry/command.tssimilarity index 100%rename from packages/common/infra/src/command/command.tsrename to packages/frontend/core/src/commands/registry/command.tsdiff --git a/packages/common/infra/src/command/index.ts b/packages/frontend/core/src/commands/registry/index.tssimilarity index 100%rename from packages/common/infra/src/command/index.tsrename to packages/frontend/core/src/commands/registry/index.tsdiff --git a/packages/common/infra/src/command/registry.ts b/packages/frontend/core/src/commands/registry/registry.tssimilarity index 100%rename from packages/common/infra/src/command/registry.tsrename to packages/frontend/core/src/commands/registry/registry.tsdiff --git a/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx b/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsxindex 402c99cd75..1ca9021901 100644--- a/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx+++ b/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx@@ -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,diff --git a/packages/frontend/core/src/components/pure/cmdk/filter-commands.ts b/packages/frontend/core/src/components/pure/cmdk/filter-commands.tsindex 6c442b6555..9bb20138ee 100644--- a/packages/frontend/core/src/components/pure/cmdk/filter-commands.ts+++ b/packages/frontend/core/src/components/pure/cmdk/filter-commands.ts@@ -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';diff --git a/packages/frontend/core/src/components/pure/cmdk/main.tsx b/packages/frontend/core/src/components/pure/cmdk/main.tsxindex 7458eb288b..95588701f0 100644--- a/packages/frontend/core/src/components/pure/cmdk/main.tsx+++ b/packages/frontend/core/src/components/pure/cmdk/main.tsx@@ -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';diff --git a/packages/frontend/core/src/components/pure/cmdk/types.ts b/packages/frontend/core/src/components/pure/cmdk/types.tsindex b73105b12a..dbf6af5002 100644--- a/packages/frontend/core/src/components/pure/cmdk/types.ts+++ b/packages/frontend/core/src/components/pure/cmdk/types.ts@@ -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;diff --git a/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx b/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsxindex ee11999e89..f7704eda4e 100644--- a/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx+++ b/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx@@ -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,diff --git a/packages/frontend/core/src/hooks/affine/use-register-copy-link-commands.tsx b/packages/frontend/core/src/hooks/affine/use-register-copy-link-commands.tsxindex 31d3a039f7..d4beb96182 100644--- a/packages/frontend/core/src/hooks/affine/use-register-copy-link-commands.tsx+++ b/packages/frontend/core/src/hooks/affine/use-register-copy-link-commands.tsx@@ -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({diff --git a/packages/frontend/core/src/hooks/affine/use-register-find-in-page-commands.ts b/packages/frontend/core/src/hooks/affine/use-register-find-in-page-commands.tsindex 4a5c140d55..11cb88d812 100644--- a/packages/frontend/core/src/hooks/affine/use-register-find-in-page-commands.ts+++ b/packages/frontend/core/src/hooks/affine/use-register-find-in-page-commands.ts@@ -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() {diff --git a/packages/frontend/core/src/modules/navigation/view/use-register-navigation-commands.ts b/packages/frontend/core/src/modules/navigation/view/use-register-navigation-commands.tsindex 400ff95efa..c349fed65d 100644--- a/packages/frontend/core/src/modules/navigation/view/use-register-navigation-commands.ts+++ b/packages/frontend/core/src/modules/navigation/view/use-register-navigation-commands.ts@@ -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';diff --git a/packages/frontend/electron/package.json b/packages/frontend/electron/package.jsonindex b8166bcaf5..621018a21a 100644--- a/packages/frontend/electron/package.json+++ b/packages/frontend/electron/package.json@@ -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",diff --git a/yarn.lock b/yarn.lockindex ef84cb8241..3fdbd52c70 100644--- a/yarn.lock+++ b/yarn.lock@@ -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"