refactor: rename plugins to adapters (#2480)
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
import { AFFINE_STORAGE_KEY, config, prefixUrl } from '@affine/env';
|
import { AFFINE_STORAGE_KEY, config } from '@affine/env';
|
||||||
import { initPage } from '@affine/env/blocksuite';
|
import { initPage } from '@affine/env/blocksuite';
|
||||||
import { PageNotFoundError } from '@affine/env/constant';
|
import { PageNotFoundError } from '@affine/env/constant';
|
||||||
import { currentAffineUserAtom } from '@affine/workspace/affine/atom';
|
import { currentAffineUserAtom } from '@affine/workspace/affine/atom';
|
||||||
import {
|
import {
|
||||||
clearLoginStorage,
|
clearLoginStorage,
|
||||||
createAffineAuth,
|
|
||||||
getLoginStorage,
|
getLoginStorage,
|
||||||
isExpired,
|
isExpired,
|
||||||
parseIdToken,
|
parseIdToken,
|
||||||
@@ -37,9 +36,9 @@ import { PageDetailEditor } from '../../components/page-detail-editor';
|
|||||||
import { PageLoading } from '../../components/pure/loading';
|
import { PageLoading } from '../../components/pure/loading';
|
||||||
import { useAffineRefreshAuthToken } from '../../hooks/affine/use-affine-refresh-auth-token';
|
import { useAffineRefreshAuthToken } from '../../hooks/affine/use-affine-refresh-auth-token';
|
||||||
import { BlockSuiteWorkspace } from '../../shared';
|
import { BlockSuiteWorkspace } from '../../shared';
|
||||||
import { affineApis } from '../../shared/apis';
|
import { affineApis, affineAuth } from '../../shared/apis';
|
||||||
import { toast } from '../../utils';
|
import { toast } from '../../utils';
|
||||||
import type { WorkspaceAdapter } from '..';
|
import type { WorkspaceAdapter } from '../type';
|
||||||
import { QueryKey } from './fetcher';
|
import { QueryKey } from './fetcher';
|
||||||
|
|
||||||
const storage = createJSONStorage(() => localStorage);
|
const storage = createJSONStorage(() => localStorage);
|
||||||
@@ -79,8 +78,6 @@ const getPersistenceAllWorkspace = () => {
|
|||||||
return allWorkspaces;
|
return allWorkspaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const affineAuth = createAffineAuth(prefixUrl);
|
|
||||||
|
|
||||||
function AuthContext({ children }: PropsWithChildren): ReactElement {
|
function AuthContext({ children }: PropsWithChildren): ReactElement {
|
||||||
const login = useAffineRefreshAuthToken();
|
const login = useAffineRefreshAuthToken();
|
||||||
|
|
||||||
@@ -17,12 +17,31 @@ import {
|
|||||||
} from '@affine/workspace/type';
|
} from '@affine/workspace/type';
|
||||||
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
|
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
|
||||||
import { nanoid } from '@blocksuite/store';
|
import { nanoid } from '@blocksuite/store';
|
||||||
import React from 'react';
|
import { lazy } from 'react';
|
||||||
|
|
||||||
import { WorkspaceSettingDetail } from '../../components/affine/workspace-setting-detail';
|
import type { WorkspaceAdapter } from '../type';
|
||||||
import { BlockSuitePageList } from '../../components/blocksuite/block-suite-page-list';
|
|
||||||
import { PageDetailEditor } from '../../components/page-detail-editor';
|
const WorkspaceSettingDetail = lazy(() =>
|
||||||
import type { WorkspaceAdapter } from '..';
|
import('../../components/affine/workspace-setting-detail').then(
|
||||||
|
({ WorkspaceSettingDetail }) => ({
|
||||||
|
default: WorkspaceSettingDetail,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const BlockSuitePageList = lazy(() =>
|
||||||
|
import('../../components/blocksuite/block-suite-page-list').then(
|
||||||
|
({ BlockSuitePageList }) => ({
|
||||||
|
default: BlockSuitePageList,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const PageDetailEditor = lazy(() =>
|
||||||
|
import('../../components/page-detail-editor').then(
|
||||||
|
({ PageDetailEditor }) => ({
|
||||||
|
default: PageDetailEditor,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const logger = new DebugLogger('use-create-first-workspace');
|
const logger = new DebugLogger('use-create-first-workspace');
|
||||||
|
|
||||||
21
apps/web/src/adapters/type.tsx
Normal file
21
apps/web/src/adapters/type.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import type {
|
||||||
|
AppEvents,
|
||||||
|
WorkspaceCRUD,
|
||||||
|
WorkspaceUISchema,
|
||||||
|
} from '@affine/workspace/type';
|
||||||
|
import type {
|
||||||
|
LoadPriority,
|
||||||
|
ReleaseType,
|
||||||
|
WorkspaceFlavour,
|
||||||
|
} from '@affine/workspace/type';
|
||||||
|
|
||||||
|
export interface WorkspaceAdapter<Flavour extends WorkspaceFlavour> {
|
||||||
|
releaseType: ReleaseType;
|
||||||
|
flavour: Flavour;
|
||||||
|
// Plugin will be loaded according to the priority
|
||||||
|
loadPriority: LoadPriority;
|
||||||
|
Events: Partial<AppEvents>;
|
||||||
|
// Fetch necessary data for the first render
|
||||||
|
CRUD: WorkspaceCRUD<Flavour>;
|
||||||
|
UI: WorkspaceUISchema<Flavour>;
|
||||||
|
}
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
import type {
|
import type { AppEvents } from '@affine/workspace/type';
|
||||||
AppEvents,
|
|
||||||
WorkspaceCRUD,
|
|
||||||
WorkspaceUISchema,
|
|
||||||
} from '@affine/workspace/type';
|
|
||||||
import {
|
import {
|
||||||
LoadPriority,
|
LoadPriority,
|
||||||
ReleaseType,
|
ReleaseType,
|
||||||
@@ -11,17 +7,7 @@ import {
|
|||||||
|
|
||||||
import { AffinePlugin } from './affine';
|
import { AffinePlugin } from './affine';
|
||||||
import { LocalPlugin } from './local';
|
import { LocalPlugin } from './local';
|
||||||
|
import type { WorkspaceAdapter } from './type';
|
||||||
export interface WorkspaceAdapter<Flavour extends WorkspaceFlavour> {
|
|
||||||
releaseType: ReleaseType;
|
|
||||||
flavour: Flavour;
|
|
||||||
// Plugin will be loaded according to the priority
|
|
||||||
loadPriority: LoadPriority;
|
|
||||||
Events: Partial<AppEvents>;
|
|
||||||
// Fetch necessary data for the first render
|
|
||||||
CRUD: WorkspaceCRUD<Flavour>;
|
|
||||||
UI: WorkspaceUISchema<Flavour>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const unimplemented = () => {
|
const unimplemented = () => {
|
||||||
throw new Error('Not implemented');
|
throw new Error('Not implemented');
|
||||||
@@ -19,7 +19,7 @@ import type { Page } from '@blocksuite/store';
|
|||||||
import { createStore } from 'jotai';
|
import { createStore } from 'jotai';
|
||||||
import { describe, expect, test } from 'vitest';
|
import { describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
import { WorkspaceAdapters } from '../../plugins';
|
import { WorkspaceAdapters } from '../../adapters/workspace';
|
||||||
import { rootCurrentWorkspaceAtom } from '../root';
|
import { rootCurrentWorkspaceAtom } from '../root';
|
||||||
|
|
||||||
describe('currentWorkspace atom', () => {
|
describe('currentWorkspace atom', () => {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import type { Page } from '@blocksuite/store';
|
|||||||
import { atom } from 'jotai';
|
import { atom } from 'jotai';
|
||||||
import { atomWithStorage } from 'jotai/utils';
|
import { atomWithStorage } from 'jotai/utils';
|
||||||
|
|
||||||
|
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||||
import type { CreateWorkspaceMode } from '../components/affine/create-workspace-modal';
|
import type { CreateWorkspaceMode } from '../components/affine/create-workspace-modal';
|
||||||
import { WorkspaceAdapters } from '../plugins';
|
|
||||||
|
|
||||||
const logger = new DebugLogger('web:atoms');
|
const logger = new DebugLogger('web:atoms');
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
|
|||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
import { atom } from 'jotai';
|
import { atom } from 'jotai';
|
||||||
|
|
||||||
import { WorkspaceAdapters } from '../plugins';
|
|
||||||
import type { AllWorkspace } from '../shared';
|
import type { AllWorkspace } from '../shared';
|
||||||
|
|
||||||
const logger = new DebugLogger('web:atoms:root');
|
const logger = new DebugLogger('web:atoms:root');
|
||||||
@@ -22,6 +21,7 @@ const logger = new DebugLogger('web:atoms:root');
|
|||||||
* Fetch all workspaces from the Plugin CRUD
|
* Fetch all workspaces from the Plugin CRUD
|
||||||
*/
|
*/
|
||||||
export const workspacesAtom = atom<Promise<AllWorkspace[]>>(async get => {
|
export const workspacesAtom = atom<Promise<AllWorkspace[]>>(async get => {
|
||||||
|
const { WorkspaceAdapters } = await import('../adapters/workspace');
|
||||||
const flavours: string[] = Object.values(WorkspaceAdapters).map(
|
const flavours: string[] = Object.values(WorkspaceAdapters).map(
|
||||||
plugin => plugin.flavour
|
plugin => plugin.flavour
|
||||||
);
|
);
|
||||||
@@ -82,6 +82,7 @@ export const workspacesAtom = atom<Promise<AllWorkspace[]>>(async get => {
|
|||||||
*/
|
*/
|
||||||
export const rootCurrentWorkspaceAtom = atom<Promise<AllWorkspace>>(
|
export const rootCurrentWorkspaceAtom = atom<Promise<AllWorkspace>>(
|
||||||
async get => {
|
async get => {
|
||||||
|
const { WorkspaceAdapters } = await import('../adapters/workspace');
|
||||||
const metadata = get(rootWorkspacesMetadataAtom);
|
const metadata = get(rootWorkspacesMetadataAtom);
|
||||||
const targetId = get(rootCurrentWorkspaceIdAtom);
|
const targetId = get(rootCurrentWorkspaceIdAtom);
|
||||||
if (targetId === null) {
|
if (targetId === null) {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import type React from 'react';
|
|||||||
import { Suspense, useCallback, useEffect, useMemo, useRef } from 'react';
|
import { Suspense, useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import { preload } from 'swr';
|
import { preload } from 'swr';
|
||||||
|
|
||||||
|
import { fetcher, QueryKey } from '../../../adapters/affine/fetcher';
|
||||||
import { useIsWorkspaceOwner } from '../../../hooks/affine/use-is-workspace-owner';
|
import { useIsWorkspaceOwner } from '../../../hooks/affine/use-is-workspace-owner';
|
||||||
import { fetcher, QueryKey } from '../../../plugins/affine/fetcher';
|
|
||||||
import type { AffineOfficialWorkspace } from '../../../shared';
|
import type { AffineOfficialWorkspace } from '../../../shared';
|
||||||
import * as style from './index.css';
|
import * as style from './index.css';
|
||||||
import { CollaborationPanel } from './panel/collaboration';
|
import { CollaborationPanel } from './panel/collaboration';
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import React, { useEffect, useState } from 'react';
|
|||||||
|
|
||||||
import { useCurrentWorkspace } from '../../../../hooks/current/use-current-workspace';
|
import { useCurrentWorkspace } from '../../../../hooks/current/use-current-workspace';
|
||||||
import { useTransformWorkspace } from '../../../../hooks/use-transform-workspace';
|
import { useTransformWorkspace } from '../../../../hooks/use-transform-workspace';
|
||||||
import { affineAuth } from '../../../../plugins/affine';
|
|
||||||
import type { AffineOfficialWorkspace } from '../../../../shared';
|
import type { AffineOfficialWorkspace } from '../../../../shared';
|
||||||
|
import { affineAuth } from '../../../../shared/apis';
|
||||||
import { TransformWorkspaceToAffineModal } from '../../../affine/transform-workspace-to-affine-modal';
|
import { TransformWorkspaceToAffineModal } from '../../../affine/transform-workspace-to-affine-modal';
|
||||||
|
|
||||||
const IconWrapper = styled('div')(() => {
|
const IconWrapper = styled('div')(() => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type React from 'react';
|
|||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { useAffineLogOut } from '../../../hooks/affine/use-affine-log-out';
|
import { useAffineLogOut } from '../../../hooks/affine/use-affine-log-out';
|
||||||
import { affineAuth } from '../../../plugins/affine';
|
import { affineAuth } from '../../../shared/apis';
|
||||||
import { toast } from '../../../utils';
|
import { toast } from '../../../utils';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ beforeAll(() => {
|
|||||||
`/workspace/[workspaceId/${WorkspaceSubPath.ALL}`,
|
`/workspace/[workspaceId/${WorkspaceSubPath.ALL}`,
|
||||||
`/workspace/[workspaceId/${WorkspaceSubPath.SETTING}`,
|
`/workspace/[workspaceId/${WorkspaceSubPath.SETTING}`,
|
||||||
`/workspace/[workspaceId/${WorkspaceSubPath.TRASH}`,
|
`/workspace/[workspaceId/${WorkspaceSubPath.TRASH}`,
|
||||||
`/workspace/[workspaceId/${WorkspaceSubPath.FAVORITE}`,
|
|
||||||
'/workspace/[workspaceId]/[pageId]',
|
'/workspace/[workspaceId]/[pageId]',
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,14 +11,15 @@ import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
|||||||
import type { Page } from '@blocksuite/store';
|
import type { Page } from '@blocksuite/store';
|
||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
import { createStore, Provider } from 'jotai/index';
|
import { createStore, Provider } from 'jotai';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import routerMock from 'next-router-mock';
|
import routerMock from 'next-router-mock';
|
||||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes';
|
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes';
|
||||||
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
|
import { LocalPlugin } from '../../adapters/local';
|
||||||
import { workspacesAtom } from '../../atoms';
|
import { workspacesAtom } from '../../atoms';
|
||||||
import { LocalPlugin } from '../../plugins/local';
|
|
||||||
import { BlockSuiteWorkspace } from '../../shared';
|
import { BlockSuiteWorkspace } from '../../shared';
|
||||||
import { WorkspaceSubPath } from '../../shared';
|
import { WorkspaceSubPath } from '../../shared';
|
||||||
import {
|
import {
|
||||||
@@ -37,7 +38,6 @@ beforeAll(() => {
|
|||||||
`/workspace/[workspaceId/${WorkspaceSubPath.ALL}`,
|
`/workspace/[workspaceId/${WorkspaceSubPath.ALL}`,
|
||||||
`/workspace/[workspaceId/${WorkspaceSubPath.SETTING}`,
|
`/workspace/[workspaceId/${WorkspaceSubPath.SETTING}`,
|
||||||
`/workspace/[workspaceId/${WorkspaceSubPath.TRASH}`,
|
`/workspace/[workspaceId/${WorkspaceSubPath.TRASH}`,
|
||||||
`/workspace/[workspaceId/${WorkspaceSubPath.FAVORITE}`,
|
|
||||||
'/workspace/[workspaceId]/[pageId]',
|
'/workspace/[workspaceId]/[pageId]',
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
@@ -45,8 +45,9 @@ beforeAll(() => {
|
|||||||
|
|
||||||
async function getJotaiContext() {
|
async function getJotaiContext() {
|
||||||
const store = createStore();
|
const store = createStore();
|
||||||
const ProviderWrapper: React.FC<React.PropsWithChildren> =
|
const ProviderWrapper: FC<PropsWithChildren> = function ProviderWrapper({
|
||||||
function ProviderWrapper({ children }) {
|
children,
|
||||||
|
}) {
|
||||||
return <Provider store={store}>{children}</Provider>;
|
return <Provider store={store}>{children}</Provider>;
|
||||||
};
|
};
|
||||||
const workspaces = await store.get(workspacesAtom);
|
const workspaces = await store.get(workspacesAtom);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { WorkspaceAdapters } from '../../plugins';
|
import { WorkspaceAdapters } from '../../adapters/workspace';
|
||||||
|
|
||||||
export function useAffineLogIn() {
|
export function useAffineLogIn() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { WorkspaceAdapters } from '../../plugins';
|
import { WorkspaceAdapters } from '../../adapters/workspace';
|
||||||
|
|
||||||
export function useAffineLogOut() {
|
export function useAffineLogOut() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from '@affine/workspace/affine/login';
|
} from '@affine/workspace/affine/login';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
import { affineAuth } from '../../plugins/affine';
|
import { affineAuth } from '../../shared/apis';
|
||||||
|
|
||||||
const logger = new DebugLogger('auth-token');
|
const logger = new DebugLogger('auth-token');
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { Member } from '@affine/workspace/affine/api';
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
import { QueryKey } from '../../plugins/affine/fetcher';
|
import { QueryKey } from '../../adapters/affine/fetcher';
|
||||||
import { affineApis } from '../../shared/apis';
|
import { affineApis } from '../../shared/apis';
|
||||||
|
|
||||||
export function useMembers(workspaceId: string) {
|
export function useMembers(workspaceId: string) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { AffineLegacyCloudWorkspace } from '@affine/workspace/type';
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
import { QueryKey } from '../../plugins/affine/fetcher';
|
import { QueryKey } from '../../adapters/affine/fetcher';
|
||||||
import { affineApis } from '../../shared/apis';
|
import { affineApis } from '../../shared/apis';
|
||||||
|
|
||||||
export function useToggleWorkspacePublish(
|
export function useToggleWorkspacePublish(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
import { QueryKey } from '../../plugins/affine/fetcher';
|
import { QueryKey } from '../../adapters/affine/fetcher';
|
||||||
|
|
||||||
export interface QueryEmailMember {
|
export interface QueryEmailMember {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
|
|||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { affineAuth } from '../../plugins/affine';
|
import { affineAuth } from '../../shared/apis';
|
||||||
import { useTransformWorkspace } from '../use-transform-workspace';
|
import { useTransformWorkspace } from '../use-transform-workspace';
|
||||||
|
|
||||||
export function useOnTransformWorkspace() {
|
export function useOnTransformWorkspace() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { WorkspaceRegistry } from '@affine/workspace/type';
|
|||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { WorkspaceAdapters } from '../plugins';
|
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform workspace from one flavour to another
|
* Transform workspace from one flavour to another
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import { nanoid } from '@blocksuite/store';
|
|||||||
import { useAtomValue, useSetAtom } from 'jotai';
|
import { useAtomValue, useSetAtom } from 'jotai';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
|
import { LocalPlugin } from '../adapters/local';
|
||||||
|
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||||
import { workspacesAtom } from '../atoms';
|
import { workspacesAtom } from '../atoms';
|
||||||
import { WorkspaceAdapters } from '../plugins';
|
|
||||||
import { LocalPlugin } from '../plugins/local';
|
|
||||||
import type { AllWorkspace } from '../shared';
|
import type { AllWorkspace } from '../shared';
|
||||||
|
|
||||||
export function useWorkspaces(): AllWorkspace[] {
|
export function useWorkspaces(): AllWorkspace[] {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { useRouter } from 'next/router';
|
|||||||
import type { FC, PropsWithChildren, ReactElement } from 'react';
|
import type { FC, PropsWithChildren, ReactElement } from 'react';
|
||||||
import { lazy, Suspense, useCallback, useEffect, useMemo } from 'react';
|
import { lazy, Suspense, useCallback, useEffect, useMemo } from 'react';
|
||||||
|
|
||||||
|
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||||
import { openQuickSearchModalAtom, openWorkspacesModalAtom } from '../atoms';
|
import { openQuickSearchModalAtom, openWorkspacesModalAtom } from '../atoms';
|
||||||
import { useTrackRouterHistoryEffect } from '../atoms/history';
|
import { useTrackRouterHistoryEffect } from '../atoms/history';
|
||||||
import {
|
import {
|
||||||
@@ -38,7 +39,6 @@ import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
|
|||||||
import { useRouterHelper } from '../hooks/use-router-helper';
|
import { useRouterHelper } from '../hooks/use-router-helper';
|
||||||
import { useRouterTitle } from '../hooks/use-router-title';
|
import { useRouterTitle } from '../hooks/use-router-title';
|
||||||
import { useWorkspaces } from '../hooks/use-workspaces';
|
import { useWorkspaces } from '../hooks/use-workspaces';
|
||||||
import { WorkspaceAdapters } from '../plugins';
|
|
||||||
import { ModalProvider } from '../providers/modal-provider';
|
import { ModalProvider } from '../providers/modal-provider';
|
||||||
import { pathGenerator, publicPathGenerator } from '../shared';
|
import { pathGenerator, publicPathGenerator } from '../shared';
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import { useRouter } from 'next/router';
|
|||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import { QueryKey } from '../../adapters/affine/fetcher';
|
||||||
import { PageLoading } from '../../components/pure/loading';
|
import { PageLoading } from '../../components/pure/loading';
|
||||||
import { RouteLogic, useRouterHelper } from '../../hooks/use-router-helper';
|
import { RouteLogic, useRouterHelper } from '../../hooks/use-router-helper';
|
||||||
import { QueryKey } from '../../plugins/affine/fetcher';
|
|
||||||
import type { NextPageWithLayout } from '../../shared';
|
import type { NextPageWithLayout } from '../../shared';
|
||||||
import { WorkspaceSubPath } from '../../shared';
|
import { WorkspaceSubPath } from '../../shared';
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { useRouter } from 'next/router';
|
|||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
|
import { WorkspaceAdapters } from '../../../adapters/workspace';
|
||||||
import { rootCurrentWorkspaceAtom } from '../../../atoms/root';
|
import { rootCurrentWorkspaceAtom } from '../../../atoms/root';
|
||||||
import { useReferenceLinkEffect } from '../../../hooks/affine/use-reference-link-effect';
|
import { useReferenceLinkEffect } from '../../../hooks/affine/use-reference-link-effect';
|
||||||
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
||||||
@@ -22,7 +23,6 @@ import { usePinboardHandler } from '../../../hooks/use-pinboard-handler';
|
|||||||
import { useSyncRecentViewsWithRouter } from '../../../hooks/use-recent-views';
|
import { useSyncRecentViewsWithRouter } from '../../../hooks/use-recent-views';
|
||||||
import { useRouterHelper } from '../../../hooks/use-router-helper';
|
import { useRouterHelper } from '../../../hooks/use-router-helper';
|
||||||
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
||||||
import { WorkspaceAdapters } from '../../../plugins';
|
|
||||||
import type { BlockSuiteWorkspace, NextPageWithLayout } from '../../../shared';
|
import type { BlockSuiteWorkspace, NextPageWithLayout } from '../../../shared';
|
||||||
|
|
||||||
function setEditorFlags(blockSuiteWorkspace: BlockSuiteWorkspace) {
|
function setEditorFlags(blockSuiteWorkspace: BlockSuiteWorkspace) {
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import Head from 'next/head';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
|
|
||||||
|
import { WorkspaceAdapters } from '../../../adapters/workspace';
|
||||||
import { PageLoading } from '../../../components/pure/loading';
|
import { PageLoading } from '../../../components/pure/loading';
|
||||||
import { WorkspaceTitle } from '../../../components/pure/workspace-title';
|
import { WorkspaceTitle } from '../../../components/pure/workspace-title';
|
||||||
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
||||||
import { useRouterHelper } from '../../../hooks/use-router-helper';
|
import { useRouterHelper } from '../../../hooks/use-router-helper';
|
||||||
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
||||||
import { WorkspaceAdapters } from '../../../plugins';
|
|
||||||
import type { NextPageWithLayout } from '../../../shared';
|
import type { NextPageWithLayout } from '../../../shared';
|
||||||
|
|
||||||
const AllPage: NextPageWithLayout = () => {
|
const AllPage: NextPageWithLayout = () => {
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ import type { NextRouter } from 'next/router';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
|
import { WorkspaceAdapters } from '../../../adapters/workspace';
|
||||||
import { PageLoading } from '../../../components/pure/loading';
|
import { PageLoading } from '../../../components/pure/loading';
|
||||||
import { WorkspaceTitle } from '../../../components/pure/workspace-title';
|
import { WorkspaceTitle } from '../../../components/pure/workspace-title';
|
||||||
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
||||||
import { useOnTransformWorkspace } from '../../../hooks/root/use-on-transform-workspace';
|
import { useOnTransformWorkspace } from '../../../hooks/root/use-on-transform-workspace';
|
||||||
import { useAppHelper } from '../../../hooks/use-workspaces';
|
import { useAppHelper } from '../../../hooks/use-workspaces';
|
||||||
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
||||||
import { WorkspaceAdapters } from '../../../plugins';
|
|
||||||
import type { NextPageWithLayout } from '../../../shared';
|
import type { NextPageWithLayout } from '../../../shared';
|
||||||
import { toast } from '../../../utils';
|
import { toast } from '../../../utils';
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { memo } from 'react';
|
|||||||
import type { SWRConfiguration } from 'swr';
|
import type { SWRConfiguration } from 'swr';
|
||||||
import { SWRConfig } from 'swr';
|
import { SWRConfig } from 'swr';
|
||||||
|
|
||||||
import { fetcher } from '../plugins/affine/fetcher';
|
import { fetcher } from '../adapters/affine/fetcher';
|
||||||
|
|
||||||
const config: SWRConfiguration = {
|
const config: SWRConfiguration = {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ import {
|
|||||||
} from '@affine/workspace/affine/api';
|
} from '@affine/workspace/affine/api';
|
||||||
import { currentAffineUserAtom } from '@affine/workspace/affine/atom';
|
import { currentAffineUserAtom } from '@affine/workspace/affine/atom';
|
||||||
import type { LoginResponse } from '@affine/workspace/affine/login';
|
import type { LoginResponse } from '@affine/workspace/affine/login';
|
||||||
import { parseIdToken, setLoginStorage } from '@affine/workspace/affine/login';
|
import {
|
||||||
|
createAffineAuth,
|
||||||
|
parseIdToken,
|
||||||
|
setLoginStorage,
|
||||||
|
} from '@affine/workspace/affine/login';
|
||||||
import { rootStore } from '@affine/workspace/atom';
|
import { rootStore } from '@affine/workspace/atom';
|
||||||
|
|
||||||
|
export const affineAuth = createAffineAuth(prefixUrl);
|
||||||
const affineApis = {} as ReturnType<typeof createUserApis> &
|
const affineApis = {} as ReturnType<typeof createUserApis> &
|
||||||
ReturnType<typeof createWorkspaceApis>;
|
ReturnType<typeof createWorkspaceApis>;
|
||||||
Object.assign(affineApis, createUserApis(prefixUrl));
|
Object.assign(affineApis, createUserApis(prefixUrl));
|
||||||
|
|||||||
Reference in New Issue
Block a user