mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor(core): adjust core struct (#8218)
packages/frontend/core/src hooks -> components/hooks atoms -> components/atoms layouts -> components/layouts providers -> components/providers mixpanel -> @affine/track ~~shared~~ ~~unexpected-application-state~~
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"@affine/env": "workspace:*",
|
||||
"@affine/graphql": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@affine/track": "workspace:*",
|
||||
"@blocksuite/blocks": "0.17.9",
|
||||
"@blocksuite/icons": "^2.1.66",
|
||||
"@radix-ui/react-collapsible": "^1.0.3",
|
||||
|
||||
@@ -4,6 +4,7 @@ import './styles/mobile.css';
|
||||
|
||||
import { AffineContext } from '@affine/component/context';
|
||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||
import { Telemetry } from '@affine/core/components/telemetry';
|
||||
import { configureCommonModules } from '@affine/core/modules';
|
||||
import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage';
|
||||
import { configureBrowserWorkbenchModule } from '@affine/core/modules/workbench';
|
||||
@@ -11,11 +12,6 @@ import {
|
||||
configureBrowserWorkspaceFlavours,
|
||||
configureIndexedDBWorkspaceEngineStorageProvider,
|
||||
} from '@affine/core/modules/workspace-engine';
|
||||
import {
|
||||
performanceLogger,
|
||||
performanceRenderLogger,
|
||||
} from '@affine/core/shared';
|
||||
import { Telemetry } from '@affine/core/telemetry';
|
||||
import { createI18n, setUpLanguage } from '@affine/i18n';
|
||||
import {
|
||||
Framework,
|
||||
@@ -33,17 +29,11 @@ const future = {
|
||||
v7_startTransition: true,
|
||||
} as const;
|
||||
|
||||
const performanceI18nLogger = performanceLogger.namespace('i18n');
|
||||
|
||||
async function loadLanguage() {
|
||||
performanceI18nLogger.info('start');
|
||||
|
||||
const i18n = createI18n();
|
||||
document.documentElement.lang = i18n.language;
|
||||
|
||||
performanceI18nLogger.info('set up');
|
||||
await setUpLanguage(i18n);
|
||||
performanceI18nLogger.info('done');
|
||||
}
|
||||
|
||||
let languageLoadingPromise: Promise<void> | null = null;
|
||||
@@ -64,8 +54,6 @@ window.addEventListener('focus', () => {
|
||||
frameworkProvider.get(LifecycleService).applicationStart();
|
||||
|
||||
export function App() {
|
||||
performanceRenderLogger.debug('App');
|
||||
|
||||
if (!languageLoadingPromise) {
|
||||
languageLoadingPromise = loadLanguage().catch(console.error);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IconButton } from '@affine/component';
|
||||
import { useCatchEventCallback } from '@affine/core/components/hooks/use-catch-event-hook';
|
||||
import { PagePreview } from '@affine/core/components/page-list/page-content-preview';
|
||||
import { IsFavoriteIcon } from '@affine/core/components/pure/icons';
|
||||
import { useCatchEventCallback } from '@affine/core/hooks/use-catch-event-hook';
|
||||
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||
import {
|
||||
WorkbenchLink,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WorkspaceAvatar } from '@affine/component/workspace-avatar';
|
||||
import { useWorkspaceInfo } from '@affine/core/hooks/use-workspace-info';
|
||||
import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info';
|
||||
import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant';
|
||||
import { ArrowDownSmallIcon } from '@blocksuite/icons/rc';
|
||||
import { useService, WorkspaceService } from '@toeverything/infra';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MobileMenu } from '@affine/component';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { track } from '@affine/track';
|
||||
import { useService, WorkspacesService } from '@toeverything/infra';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { IconButton } from '@affine/component';
|
||||
import { WorkspaceAvatar } from '@affine/component/workspace-avatar';
|
||||
import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';
|
||||
import { useWorkspaceInfo } from '@affine/core/hooks/use-workspace-info';
|
||||
import { WorkspaceSubPath } from '@affine/core/shared';
|
||||
import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
|
||||
import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { CloseIcon, CollaborationIcon } from '@blocksuite/icons/rc';
|
||||
import {
|
||||
@@ -61,15 +60,15 @@ const WorkspaceList = ({
|
||||
}) => {
|
||||
const currentWorkspace = useService(WorkspaceService).workspace;
|
||||
|
||||
const { jumpToSubPath } = useNavigateHelper();
|
||||
const { jumpToPage } = useNavigateHelper();
|
||||
const toggleWorkspace = useCallback(
|
||||
(id: string) => {
|
||||
if (id !== currentWorkspace.id) {
|
||||
jumpToSubPath(id, WorkspaceSubPath.ALL);
|
||||
jumpToPage(id, 'all');
|
||||
}
|
||||
onClose?.();
|
||||
},
|
||||
[currentWorkspace.id, jumpToSubPath, onClose]
|
||||
[currentWorkspace.id, jumpToPage, onClose]
|
||||
);
|
||||
|
||||
if (!list.length) return null;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import './setup';
|
||||
|
||||
import { performanceLogger } from '@affine/core/shared';
|
||||
import {
|
||||
init,
|
||||
reactRouterV6BrowserTracingIntegration,
|
||||
@@ -17,9 +16,7 @@ import {
|
||||
|
||||
import { App } from './app';
|
||||
|
||||
const performanceMainLogger = performanceLogger.namespace('main');
|
||||
function main() {
|
||||
performanceMainLogger.info('setup start');
|
||||
if (BUILD_CONFIG.debug || window.SENTRY_RELEASE) {
|
||||
// https://docs.sentry.io/platforms/javascript/guides/react/#configure
|
||||
init({
|
||||
@@ -40,15 +37,12 @@ function main() {
|
||||
editorVersion: BUILD_CONFIG.editorVersion,
|
||||
});
|
||||
}
|
||||
performanceMainLogger.info('setup done');
|
||||
mountApp();
|
||||
}
|
||||
|
||||
function mountApp() {
|
||||
performanceMainLogger.info('import app');
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const root = document.getElementById('app')!;
|
||||
performanceMainLogger.info('render app');
|
||||
createRoot(root).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Component as IndexComponent } from '@affine/core/pages/index';
|
||||
import { WorkspaceSubPath } from '@affine/core/shared';
|
||||
|
||||
// Default route fallback for mobile
|
||||
|
||||
export const Component = () => {
|
||||
// TODO: replace with a mobile version
|
||||
return <IndexComponent defaultIndexRoute={WorkspaceSubPath.HOME} />;
|
||||
return <IndexComponent defaultIndexRoute={'home'} />;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
RouteLogic,
|
||||
useNavigateHelper,
|
||||
} from '@affine/core/hooks/use-navigate-helper';
|
||||
} from '@affine/core/components/hooks/use-navigate-helper';
|
||||
import { AuthService } from '@affine/core/modules/cloud';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { notify, useThemeColorV2 } from '@affine/component';
|
||||
import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';
|
||||
import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
|
||||
import { CollectionService } from '@affine/core/modules/collection';
|
||||
import { WorkspaceSubPath } from '@affine/core/shared';
|
||||
import {
|
||||
GlobalContextService,
|
||||
useLiveData,
|
||||
@@ -44,7 +43,7 @@ export const Component = () => {
|
||||
}, [collection, globalContext]);
|
||||
|
||||
const notifyCollectionDeleted = useCallback(() => {
|
||||
navigate.jumpToSubPath(workspace.id, WorkspaceSubPath.HOME);
|
||||
navigate.jumpToPage(workspace.id, 'home');
|
||||
const collection = collectionService.collectionsTrash$.value.find(
|
||||
v => v.collection.id === params.collectionId
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IconButton, MobileMenu } from '@affine/component';
|
||||
import { useJournalInfoHelper } from '@affine/core/hooks/use-journal';
|
||||
import { useJournalInfoHelper } from '@affine/core/components/hooks/use-journal';
|
||||
import { EditorJournalPanel } from '@affine/core/pages/workspace/detail-page/tabs/journal';
|
||||
import { TodayIcon, TomorrowIcon, YesterdayIcon } from '@blocksuite/icons/rc';
|
||||
import { useService, WorkspaceService } from '@toeverything/infra';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useThemeColorV2 } from '@affine/component';
|
||||
import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton';
|
||||
import { AffineErrorBoundary } from '@affine/core/components/affine/affine-error-boundary';
|
||||
import { useRegisterBlocksuiteEditorCommands } from '@affine/core/components/hooks/affine/use-register-blocksuite-editor-commands';
|
||||
import { useActiveBlocksuiteEditor } from '@affine/core/components/hooks/use-block-suite-editor';
|
||||
import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-page-meta';
|
||||
import { usePageDocumentTitle } from '@affine/core/components/hooks/use-global-state';
|
||||
import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
|
||||
import { PageDetailEditor } from '@affine/core/components/page-detail-editor';
|
||||
import { useRegisterBlocksuiteEditorCommands } from '@affine/core/hooks/affine/use-register-blocksuite-editor-commands';
|
||||
import { useActiveBlocksuiteEditor } from '@affine/core/hooks/use-block-suite-editor';
|
||||
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||
import { usePageDocumentTitle } from '@affine/core/hooks/use-global-state';
|
||||
import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';
|
||||
import { EditorService } from '@affine/core/modules/editor';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
} from '@affine/component/ui/menu';
|
||||
import { useFavorite } from '@affine/core/components/blocksuite/block-suite-header/favorite';
|
||||
import { IsFavoriteIcon } from '@affine/core/components/pure/icons';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { EditorService } from '@affine/core/modules/editor';
|
||||
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||
import { EditorOutlinePanel } from '@affine/core/pages/workspace/detail-page/tabs/outline';
|
||||
import { preventDefault } from '@affine/core/utils';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import {
|
||||
EdgelessIcon,
|
||||
InformationIcon,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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/hooks/affine/use-enable-cloud';
|
||||
import { useEnableCloud } from '@affine/core/components/hooks/affine/use-enable-cloud';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { ShareiOsIcon } from '@blocksuite/icons/rc';
|
||||
import { DocService, useServices, WorkspaceService } from '@toeverything/infra';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AffineErrorBoundary } from '@affine/core/components/affine/affine-error-boundary';
|
||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||
import { WorkspaceLayoutProviders } from '@affine/core/layouts/workspace-layout';
|
||||
import { SWRConfigProvider } from '@affine/core/providers/swr-config-provider';
|
||||
import { WorkspaceLayoutProviders } from '@affine/core/components/layouts/workspace-layout';
|
||||
import { SWRConfigProvider } from '@affine/core/components/providers/swr-config-provider';
|
||||
import type { Workspace, WorkspaceMetadata } from '@toeverything/infra';
|
||||
import {
|
||||
FrameworkScope,
|
||||
|
||||
@@ -7,11 +7,11 @@ import {
|
||||
LocalQuotaModal,
|
||||
} from '@affine/core/components/affine/quota-reached-modal';
|
||||
import { StarAFFiNEModal } from '@affine/core/components/affine/star-affine-modal';
|
||||
import { useTrashModalHelper } from '@affine/core/components/hooks/affine/use-trash-modal-helper';
|
||||
import { MoveToTrash } from '@affine/core/components/page-list';
|
||||
import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper';
|
||||
import { SignOutConfirmModal } from '@affine/core/components/providers/modal-provider';
|
||||
import { CreateWorkspaceDialogProvider } from '@affine/core/modules/create-workspace';
|
||||
import { PeekViewManagerModal } from '@affine/core/modules/peek-view';
|
||||
import { SignOutConfirmModal } from '@affine/core/providers/modal-provider';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { useService, WorkspaceService } from '@toeverything/infra';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NavigateContext } from '@affine/core/hooks/use-navigate-helper';
|
||||
import { NavigateContext } from '@affine/core/components/hooks/use-navigate-helper';
|
||||
import { wrapCreateBrowserRouter } from '@sentry/react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { RouteObject } from 'react-router-dom';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { EmptyDocs } from '@affine/core/components/affine/empty';
|
||||
import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-suite-page-meta';
|
||||
import {
|
||||
type ItemGroupDefinition,
|
||||
type ItemGroupProps,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
usePageItemGroupDefinitions,
|
||||
} from '@affine/core/components/page-list';
|
||||
import { itemsToItemGroups } from '@affine/core/components/page-list/items-to-item-group';
|
||||
import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||
import type { Tag } from '@affine/core/modules/tag';
|
||||
import type { Collection, Filter } from '@affine/env/filter';
|
||||
import { ToggleExpandIcon } from '@blocksuite/icons/rc';
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
SafeArea,
|
||||
startScopedViewTransition,
|
||||
} from '@affine/component';
|
||||
import { openSettingModalAtom } from '@affine/core/atoms';
|
||||
import { openSettingModalAtom } from '@affine/core/components/atoms';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { SettingsIcon } from '@blocksuite/icons/rc';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||
import { useBlockSuiteDocMeta } from '@affine/core/components/hooks/use-block-suite-page-meta';
|
||||
import { CollapsibleSection } from '@affine/core/modules/explorer';
|
||||
import { useService, WorkspaceService } from '@toeverything/infra';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useLanguageHelper } from '@affine/core/hooks/affine/use-language-helper';
|
||||
import { useLanguageHelper } from '@affine/core/components/hooks/affine/use-language-helper';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Modal } from '@affine/component';
|
||||
import { openSettingModalAtom } from '@affine/core/atoms';
|
||||
import { openSettingModalAtom } from '@affine/core/components/atoms';
|
||||
import { AuthService } from '@affine/core/modules/cloud';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { useService } from '@toeverything/infra';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Avatar } from '@affine/component';
|
||||
import { authAtom } from '@affine/core/atoms';
|
||||
import { useSignOut } from '@affine/core/hooks/affine/use-sign-out';
|
||||
import { authAtom } from '@affine/core/components/atoms';
|
||||
import { useSignOut } from '@affine/core/components/hooks/affine/use-sign-out';
|
||||
import { AuthService } from '@affine/core/modules/cloud';
|
||||
import { ArrowRightSmallIcon } from '@blocksuite/icons/rc';
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Modal } from '@affine/component';
|
||||
import { authAtom } from '@affine/core/atoms';
|
||||
import { authAtom } from '@affine/core/components/atoms';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
import { useAtom } from 'jotai';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
Reference in New Issue
Block a user