mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-22 09:13:18 +03:00
chore: prohibit import package itself (#2612)
Co-authored-by: Whitewater <me@waterwater.moe>
This commit is contained in:
parent
06abb702f5
commit
248cd9a8ab
51
.eslintrc.js
51
.eslintrc.js
@ -1,3 +1,43 @@
|
|||||||
|
const createPattern = packageName => [
|
||||||
|
{
|
||||||
|
group: ['**/dist', '**/dist/**'],
|
||||||
|
message: 'Do not import from dist',
|
||||||
|
allowTypeImports: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
group: ['**/src', '**/src/**'],
|
||||||
|
message: 'Do not import from src',
|
||||||
|
allowTypeImports: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
group: [`@affine/${packageName}`],
|
||||||
|
message: 'Do not import package itself',
|
||||||
|
allowTypeImports: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
group: [`@toeverything/${packageName}`],
|
||||||
|
message: 'Do not import package itself',
|
||||||
|
allowTypeImports: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const allPackages = [
|
||||||
|
'cli',
|
||||||
|
'component',
|
||||||
|
'debug',
|
||||||
|
'env',
|
||||||
|
'graphql',
|
||||||
|
'hooks',
|
||||||
|
'i18n',
|
||||||
|
'jotai',
|
||||||
|
'native',
|
||||||
|
'plugin-infra',
|
||||||
|
'templates',
|
||||||
|
'theme',
|
||||||
|
'workspace',
|
||||||
|
'y-indexeddb',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('eslint').Linter.Config}
|
* @type {import('eslint').Linter.Config}
|
||||||
*/
|
*/
|
||||||
@ -96,6 +136,17 @@ const config = {
|
|||||||
'@typescript-eslint/no-var-requires': 0,
|
'@typescript-eslint/no-var-requires': 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
...allPackages.map(pkg => ({
|
||||||
|
files: [`packages/${pkg}/src/**/*.ts`, `packages/${pkg}/src/**/*.tsx`],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-restricted-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
patterns: createPattern(pkg),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { IconButton } from '@affine/component';
|
|
||||||
import {
|
import {
|
||||||
DeleteTemporarilyIcon,
|
DeleteTemporarilyIcon,
|
||||||
SettingsIcon,
|
SettingsIcon,
|
||||||
@ -8,6 +7,7 @@ import type { Meta, StoryFn } from '@storybook/react';
|
|||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import { type PropsWithChildren, useState } from 'react';
|
import { type PropsWithChildren, useState } from 'react';
|
||||||
|
|
||||||
|
import { IconButton } from '../..';
|
||||||
import { AppSidebar, AppSidebarFallback, appSidebarOpenAtom } from '.';
|
import { AppSidebar, AppSidebarFallback, appSidebarOpenAtom } from '.';
|
||||||
import { AddPageButton } from './add-page-button';
|
import { AddPageButton } from './add-page-button';
|
||||||
import { CategoryDivider } from './category-divider';
|
import { CategoryDivider } from './category-divider';
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { IconButton } from '@affine/component';
|
|
||||||
import { getEnvironment } from '@affine/env/config';
|
import { getEnvironment } from '@affine/env/config';
|
||||||
import {
|
import {
|
||||||
ArrowLeftSmallIcon,
|
ArrowLeftSmallIcon,
|
||||||
@ -7,6 +6,7 @@ import {
|
|||||||
} from '@blocksuite/icons';
|
} from '@blocksuite/icons';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
|
|
||||||
|
import { IconButton } from '../../..';
|
||||||
import type { History } from '..';
|
import type { History } from '..';
|
||||||
import { navHeaderStyle, sidebarButtonStyle } from '../index.css';
|
import { navHeaderStyle, sidebarButtonStyle } from '../index.css';
|
||||||
import { appSidebarOpenAtom } from '../index.jotai';
|
import { appSidebarOpenAtom } from '../index.jotai';
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { MenuItem, MuiClickAwayListener, PureMenu } from '@affine/component';
|
|
||||||
import type { EditorPlugin } from '@affine/component/block-suite-editor';
|
|
||||||
import type { SerializedBlock } from '@blocksuite/blocks';
|
import type { SerializedBlock } from '@blocksuite/blocks';
|
||||||
import {
|
import {
|
||||||
getCurrentBlockRange,
|
getCurrentBlockRange,
|
||||||
@ -10,6 +8,9 @@ import type { Page } from '@blocksuite/store';
|
|||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
import { MenuItem, MuiClickAwayListener, PureMenu } from '../../..';
|
||||||
|
import type { EditorPlugin } from '..';
|
||||||
|
|
||||||
type ShortcutMap = {
|
type ShortcutMap = {
|
||||||
[key: string]: (e: KeyboardEvent, page: Page) => void;
|
[key: string]: (e: KeyboardEvent, page: Page) => void;
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import {
|
|
||||||
FlexWrapper,
|
|
||||||
Modal,
|
|
||||||
ModalCloseButton,
|
|
||||||
ModalWrapper,
|
|
||||||
} from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
|
|
||||||
|
import { FlexWrapper, Modal, ModalCloseButton, ModalWrapper } from '../..';
|
||||||
import {
|
import {
|
||||||
DiscordIcon,
|
DiscordIcon,
|
||||||
DocIcon,
|
DocIcon,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { absoluteCenter, displayFlex, styled } from '@affine/component';
|
import { absoluteCenter, displayFlex, styled } from '../..';
|
||||||
|
|
||||||
export const StyledBigLink = styled('a')(() => {
|
export const StyledBigLink = styled('a')(() => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
import {
|
|
||||||
Table,
|
|
||||||
TableBody,
|
|
||||||
TableCell,
|
|
||||||
TableHead,
|
|
||||||
TableRow,
|
|
||||||
} from '@affine/component';
|
|
||||||
import { DEFAULT_SORT_KEY } from '@affine/env/constant';
|
import { DEFAULT_SORT_KEY } from '@affine/env/constant';
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { ArrowDownBigIcon, ArrowUpBigIcon } from '@blocksuite/icons';
|
import { ArrowDownBigIcon, ArrowUpBigIcon } from '@blocksuite/icons';
|
||||||
@ -12,6 +5,7 @@ import { useMediaQuery, useTheme } from '@mui/material';
|
|||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { type CSSProperties } from 'react';
|
import { type CSSProperties } from 'react';
|
||||||
|
|
||||||
|
import { Table, TableBody, TableCell, TableHead, TableRow } from '../..';
|
||||||
import { AllPagesBody } from './all-pages-body';
|
import { AllPagesBody } from './all-pages-body';
|
||||||
import { NewPageButton } from './components/new-page-buttton';
|
import { NewPageButton } from './components/new-page-buttton';
|
||||||
import { TitleCell } from './components/title-cell';
|
import { TitleCell } from './components/title-cell';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { styled, TableBody, TableCell } from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { useDraggable } from '@dnd-kit/core';
|
import { useDraggable } from '@dnd-kit/core';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { Fragment } from 'react';
|
import { Fragment } from 'react';
|
||||||
|
|
||||||
|
import { styled, TableBody, TableCell } from '../../..';
|
||||||
import { FavoriteTag } from './components/favorite-tag';
|
import { FavoriteTag } from './components/favorite-tag';
|
||||||
import { TitleCell } from './components/title-cell';
|
import { TitleCell } from './components/title-cell';
|
||||||
import { OperationCell } from './operation-cell';
|
import { OperationCell } from './operation-cell';
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import type { IconButtonProps } from '@affine/component';
|
|
||||||
import { IconButton, Tooltip } from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { FavoritedIcon, FavoriteIcon } from '@blocksuite/icons';
|
import { FavoritedIcon, FavoriteIcon } from '@blocksuite/icons';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
|
|
||||||
|
import type { IconButtonProps } from '../../..';
|
||||||
|
import { IconButton, Tooltip } from '../../..';
|
||||||
|
|
||||||
export const FavoriteTag = forwardRef<
|
export const FavoriteTag = forwardRef<
|
||||||
HTMLButtonElement,
|
HTMLButtonElement,
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { TableCellProps } from '@affine/component';
|
|
||||||
import { Content, TableCell } from '@affine/component';
|
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
|
|
||||||
|
import type { TableCellProps } from '../../..';
|
||||||
|
import { Content, TableCell } from '../../..';
|
||||||
import {
|
import {
|
||||||
StyledTitleContentWrapper,
|
StyledTitleContentWrapper,
|
||||||
StyledTitleLink,
|
StyledTitleLink,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Menu } from '@affine/component';
|
import { Menu } from '../../..';
|
||||||
|
|
||||||
import { Condition } from './condition';
|
import { Condition } from './condition';
|
||||||
import type { Filter } from './vars';
|
import type { Filter } from './vars';
|
||||||
import { CreateFilterMenu } from './vars';
|
import { CreateFilterMenu } from './vars';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Content,
|
Content,
|
||||||
Table,
|
Table,
|
||||||
@ -5,9 +7,7 @@ import {
|
|||||||
TableCell,
|
TableCell,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from '@affine/component';
|
} from '../../..';
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
|
||||||
|
|
||||||
import { AllPagesBody } from './all-pages-body';
|
import { AllPagesBody } from './all-pages-body';
|
||||||
import { NewPageButton } from './components/new-page-buttton';
|
import { NewPageButton } from './components/new-page-buttton';
|
||||||
import {
|
import {
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
import {
|
|
||||||
Confirm,
|
|
||||||
FlexWrapper,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Tooltip,
|
|
||||||
} from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import {
|
import {
|
||||||
DeletePermanentlyIcon,
|
DeletePermanentlyIcon,
|
||||||
@ -18,6 +10,14 @@ import {
|
|||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Confirm,
|
||||||
|
FlexWrapper,
|
||||||
|
IconButton,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
Tooltip,
|
||||||
|
} from '../../..';
|
||||||
import { DisablePublicSharing, MoveToTrash } from './operation-menu-items';
|
import { DisablePublicSharing, MoveToTrash } from './operation-menu-items';
|
||||||
|
|
||||||
export type OperationCellProps = {
|
export type OperationCellProps = {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { MenuItem, toast } from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { CopyIcon } from '@blocksuite/icons';
|
import { CopyIcon } from '@blocksuite/icons';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
|
import { MenuItem, toast } from '../../..';
|
||||||
import type { CommonMenuItemProps } from './types';
|
import type { CommonMenuItemProps } from './types';
|
||||||
|
|
||||||
export const CopyLink = ({ onItemClick, onSelect }: CommonMenuItemProps) => {
|
export const CopyLink = ({ onItemClick, onSelect }: CommonMenuItemProps) => {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { MenuItem, styled } from '@affine/component';
|
|
||||||
import { PublicLinkDisableModal } from '@affine/component/share-menu';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { ShareIcon } from '@blocksuite/icons';
|
import { ShareIcon } from '@blocksuite/icons';
|
||||||
|
|
||||||
|
import { MenuItem, styled } from '../../../';
|
||||||
|
import { PublicLinkDisableModal } from '../../share-menu';
|
||||||
import type { CommonMenuItemProps } from './types';
|
import type { CommonMenuItemProps } from './types';
|
||||||
|
|
||||||
const StyledMenuItem = styled(MenuItem)(({ theme }) => {
|
const StyledMenuItem = styled(MenuItem)(({ theme }) => {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { Menu, MenuItem } from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import type { PageBlockModel } from '@blocksuite/blocks';
|
import type { PageBlockModel } from '@blocksuite/blocks';
|
||||||
import { ContentParser } from '@blocksuite/blocks/content-parser';
|
import { ContentParser } from '@blocksuite/blocks/content-parser';
|
||||||
@ -12,6 +11,7 @@ import {
|
|||||||
} from '@blocksuite/icons';
|
} from '@blocksuite/icons';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
|
|
||||||
|
import { Menu, MenuItem } from '../../..';
|
||||||
import type { CommonMenuItemProps } from './types';
|
import type { CommonMenuItemProps } from './types';
|
||||||
|
|
||||||
export const Export = ({
|
export const Export = ({
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import type { ConfirmProps } from '@affine/component';
|
|
||||||
import { Confirm, MenuItem } from '@affine/component';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { DeleteTemporarilyIcon } from '@blocksuite/icons';
|
import { DeleteTemporarilyIcon } from '@blocksuite/icons';
|
||||||
|
|
||||||
|
import type { ConfirmProps } from '../../..';
|
||||||
|
import { Confirm, MenuItem } from '../../..';
|
||||||
import type { CommonMenuItemProps } from './types';
|
import type { CommonMenuItemProps } from './types';
|
||||||
|
|
||||||
export const MoveToTrash = ({
|
export const MoveToTrash = ({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Content, displayFlex, styled } from '@affine/component';
|
import { TableRow } from '../..';
|
||||||
import { TableRow } from '@affine/component';
|
import { Content, displayFlex, styled } from '../../';
|
||||||
|
|
||||||
export const StyledTableContainer = styled('div')(({ theme }) => {
|
export const StyledTableContainer = styled('div')(({ theme }) => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Button, Input, Modal, ModalWrapper } from '@affine/component';
|
|
||||||
import { uuidv4 } from '@blocksuite/store';
|
import { uuidv4 } from '@blocksuite/store';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import { Button, Input, Modal, ModalWrapper } from '../../..';
|
||||||
import { FilterList } from '../filter';
|
import { FilterList } from '../filter';
|
||||||
import type { Filter } from '../filter/vars';
|
import type { Filter } from '../filter/vars';
|
||||||
import type { View } from '../use-all-page-setting';
|
import type { View } from '../use-all-page-setting';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Button, MenuItem } from '@affine/component';
|
|
||||||
import { FilteredIcon } from '@blocksuite/icons';
|
import { FilteredIcon } from '@blocksuite/icons';
|
||||||
|
|
||||||
|
import { Button, MenuItem } from '../../..';
|
||||||
import Menu from '../../../ui/menu/menu';
|
import Menu from '../../../ui/menu/menu';
|
||||||
import { CreateFilterMenu } from '../filter/vars';
|
import { CreateFilterMenu } from '../filter/vars';
|
||||||
import type { useAllPageSetting } from '../use-all-page-setting';
|
import type { useAllPageSetting } from '../use-all-page-setting';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { styled, TextButton } from '@affine/component';
|
import { styled, TextButton } from '../../..';
|
||||||
|
|
||||||
export const StyledModalWrapper = styled('div')(() => {
|
export const StyledModalWrapper = styled('div')(() => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { BlockCard } from '@affine/component/card/block-card';
|
|
||||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
import { WorkspaceFlavour } from '@affine/workspace/type';
|
||||||
import { EdgelessIcon, PageIcon } from '@blocksuite/icons';
|
import { EdgelessIcon, PageIcon } from '@blocksuite/icons';
|
||||||
import { Workspace } from '@blocksuite/store';
|
import { Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
|
import { BlockCard } from '../components/card/block-card';
|
||||||
import { WorkspaceCard } from '../components/card/workspace-card';
|
import { WorkspaceCard } from '../components/card/workspace-card';
|
||||||
import { toast } from '../ui/toast';
|
import { toast } from '../ui/toast';
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Button } from '@affine/component';
|
|
||||||
import type { StoryFn } from '@storybook/react';
|
import type { StoryFn } from '@storybook/react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import type { ContactModalProps } from '../components/contact-modal';
|
import type { ContactModalProps } from '../components/contact-modal';
|
||||||
import { ContactModal } from '../components/contact-modal';
|
import { ContactModal } from '../components/contact-modal';
|
||||||
|
import { Button } from '../ui/button';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'AFFiNE/ContactModal',
|
title: 'AFFiNE/ContactModal',
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* @vitest-environment happy-dom
|
* @vitest-environment happy-dom
|
||||||
*/
|
*/
|
||||||
import { DebugLogger } from '@affine/debug';
|
|
||||||
import { describe, expect, test, vi } from 'vitest';
|
import { describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
|
import { DebugLogger } from '..';
|
||||||
|
|
||||||
describe('debug', () => {
|
describe('debug', () => {
|
||||||
test('disabled', () => {
|
test('disabled', () => {
|
||||||
const logger = new DebugLogger('test');
|
const logger = new DebugLogger('test');
|
||||||
|
@ -9,14 +9,14 @@ import type { Page } from '@blocksuite/store';
|
|||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
import { useBlockSuitePagePreview } from '@toeverything/hooks/use-block-suite-page-preview';
|
|
||||||
import { useBlockSuiteWorkspacePageIsPublic } from '@toeverything/hooks/use-block-suite-workspace-page-is-public';
|
|
||||||
import { useBlockSuiteWorkspacePageTitle } from '@toeverything/hooks/use-block-suite-workspace-page-title';
|
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import { describe, expect, test, vitest } from 'vitest';
|
import { describe, expect, test, vitest } from 'vitest';
|
||||||
import { beforeEach } from 'vitest';
|
import { beforeEach } from 'vitest';
|
||||||
|
|
||||||
|
import { useBlockSuitePagePreview } from '../use-block-suite-page-preview';
|
||||||
import { useBlockSuiteWorkspaceName } from '../use-block-suite-workspace-name';
|
import { useBlockSuiteWorkspaceName } from '../use-block-suite-workspace-name';
|
||||||
|
import { useBlockSuiteWorkspacePageIsPublic } from '../use-block-suite-workspace-page-is-public';
|
||||||
|
import { useBlockSuiteWorkspacePageTitle } from '../use-block-suite-workspace-page-title';
|
||||||
|
|
||||||
let blockSuiteWorkspace: BlockSuiteWorkspace;
|
let blockSuiteWorkspace: BlockSuiteWorkspace;
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ import { initPage } from '@affine/env/blocksuite';
|
|||||||
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
||||||
import { Workspace } from '@blocksuite/store';
|
import { Workspace } from '@blocksuite/store';
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
|
|
||||||
import { useBlockSuiteWorkspaceHelper } from '@toeverything/hooks/use-block-suite-workspace-helper';
|
|
||||||
import { beforeEach, describe, expect, test } from 'vitest';
|
import { beforeEach, describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
|
import { useBlockSuitePageMeta } from '../use-block-suite-page-meta';
|
||||||
|
import { useBlockSuiteWorkspaceHelper } from '../use-block-suite-workspace-helper';
|
||||||
|
|
||||||
let blockSuiteWorkspace: Workspace;
|
let blockSuiteWorkspace: Workspace;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -6,10 +6,6 @@ import 'fake-indexeddb/auto';
|
|||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
|
|
||||||
import { MessageCode } from '@affine/env/constant';
|
import { MessageCode } from '@affine/env/constant';
|
||||||
import { createStatusApis } from '@affine/workspace/affine/api/status';
|
|
||||||
import { KeckProvider } from '@affine/workspace/affine/keck';
|
|
||||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
|
||||||
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
|
|
||||||
import user1 from '@affine-test/fixtures/built-in-user1.json';
|
import user1 from '@affine-test/fixtures/built-in-user1.json';
|
||||||
import user2 from '@affine-test/fixtures/built-in-user2.json';
|
import user2 from '@affine-test/fixtures/built-in-user2.json';
|
||||||
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
||||||
@ -22,6 +18,8 @@ import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|||||||
import { WebSocket } from 'ws';
|
import { WebSocket } from 'ws';
|
||||||
import { applyUpdate } from 'yjs';
|
import { applyUpdate } from 'yjs';
|
||||||
|
|
||||||
|
import { WorkspaceFlavour } from '../../type';
|
||||||
|
import { createEmptyBlockSuiteWorkspace } from '../../utils';
|
||||||
import {
|
import {
|
||||||
createUserApis,
|
createUserApis,
|
||||||
createWorkspaceApis,
|
createWorkspaceApis,
|
||||||
@ -29,6 +27,8 @@ import {
|
|||||||
RequestError,
|
RequestError,
|
||||||
usageResponseSchema,
|
usageResponseSchema,
|
||||||
} from '../api';
|
} from '../api';
|
||||||
|
import { createStatusApis } from '../api/status';
|
||||||
|
import { KeckProvider } from '../keck';
|
||||||
import {
|
import {
|
||||||
createAffineAuth,
|
createAffineAuth,
|
||||||
getLoginStorage,
|
getLoginStorage,
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* @vitest-environment happy-dom
|
* @vitest-environment happy-dom
|
||||||
*/
|
*/
|
||||||
import type { AccessTokenMessage } from '@affine/workspace/affine/login';
|
import { describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
|
import type { AccessTokenMessage } from '../login';
|
||||||
import {
|
import {
|
||||||
getLoginStorage,
|
getLoginStorage,
|
||||||
isExpired,
|
isExpired,
|
||||||
setLoginStorage,
|
setLoginStorage,
|
||||||
STORAGE_KEY,
|
STORAGE_KEY,
|
||||||
} from '@affine/workspace/affine/login';
|
} from '../login';
|
||||||
import { describe, expect, test } from 'vitest';
|
|
||||||
|
|
||||||
describe('storage', () => {
|
describe('storage', () => {
|
||||||
test('should work', () => {
|
test('should work', () => {
|
||||||
|
@ -3,16 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
import 'fake-indexeddb/auto';
|
import 'fake-indexeddb/auto';
|
||||||
|
|
||||||
import type { Workspace } from '@affine/workspace/affine/api';
|
|
||||||
import {
|
|
||||||
createWorkspaceApis,
|
|
||||||
PermissionType,
|
|
||||||
} from '@affine/workspace/affine/api';
|
|
||||||
import { KeckProvider } from '@affine/workspace/affine/keck';
|
|
||||||
import type { LoginResponse } from '@affine/workspace/affine/login';
|
|
||||||
import { loginResponseSchema } from '@affine/workspace/affine/login';
|
|
||||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
|
||||||
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
|
|
||||||
import user1 from '@affine-test/fixtures/built-in-user1.json';
|
import user1 from '@affine-test/fixtures/built-in-user1.json';
|
||||||
import user2 from '@affine-test/fixtures/built-in-user2.json';
|
import user2 from '@affine-test/fixtures/built-in-user2.json';
|
||||||
import type { ParagraphBlockModel } from '@blocksuite/blocks/models';
|
import type { ParagraphBlockModel } from '@blocksuite/blocks/models';
|
||||||
@ -21,6 +11,14 @@ import { uuidv4, Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
|||||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||||
import { WebSocket } from 'ws';
|
import { WebSocket } from 'ws';
|
||||||
|
|
||||||
|
import type { LoginResponse } from '../../affine/login';
|
||||||
|
import { loginResponseSchema } from '../../affine/login';
|
||||||
|
import { WorkspaceFlavour } from '../../type';
|
||||||
|
import { createEmptyBlockSuiteWorkspace } from '../../utils';
|
||||||
|
import type { Workspace } from '../api';
|
||||||
|
import { createWorkspaceApis, PermissionType } from '../api';
|
||||||
|
import { KeckProvider } from '../keck';
|
||||||
|
|
||||||
declare module '@blocksuite/store' {
|
declare module '@blocksuite/store' {
|
||||||
interface PageMeta {
|
interface PageMeta {
|
||||||
foo: string;
|
foo: string;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import type { AccessTokenMessage } from '@affine/workspace/affine/login';
|
|
||||||
import { atomWithStorage } from 'jotai/utils';
|
import { atomWithStorage } from 'jotai/utils';
|
||||||
|
|
||||||
|
import type { AccessTokenMessage } from '../affine/login';
|
||||||
|
|
||||||
export const currentAffineUserAtom = atomWithStorage<AccessTokenMessage | null>(
|
export const currentAffineUserAtom = atomWithStorage<AccessTokenMessage | null>(
|
||||||
'affine-user-atom',
|
'affine-user-atom',
|
||||||
null
|
null
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
import {
|
|
||||||
getLoginStorage,
|
|
||||||
isExpired,
|
|
||||||
parseIdToken,
|
|
||||||
} from '@affine/workspace/affine/login';
|
|
||||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
|
||||||
import { cleanupWorkspace } from '@affine/workspace/utils';
|
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import * as url from 'lib0/url';
|
import * as url from 'lib0/url';
|
||||||
import * as websocket from 'lib0/websocket';
|
import * as websocket from 'lib0/websocket';
|
||||||
|
|
||||||
|
import { getLoginStorage, isExpired, parseIdToken } from '../affine/login';
|
||||||
|
import { WorkspaceFlavour } from '../type';
|
||||||
|
import { cleanupWorkspace } from '../utils';
|
||||||
|
|
||||||
const RECONNECT_INTERVAL_TIME = 500;
|
const RECONNECT_INTERVAL_TIME = 500;
|
||||||
const MAX_RECONNECT_TIMES = 50;
|
const MAX_RECONNECT_TIMES = 50;
|
||||||
|
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
import { websocketPrefixUrl } from '@affine/env/api';
|
import { websocketPrefixUrl } from '@affine/env/api';
|
||||||
import {
|
|
||||||
workspaceDetailSchema,
|
|
||||||
workspaceSchema,
|
|
||||||
} from '@affine/workspace/affine/api';
|
|
||||||
import { WebsocketClient } from '@affine/workspace/affine/channel';
|
|
||||||
import { storageChangeSlot } from '@affine/workspace/affine/login';
|
|
||||||
import { rootStore, rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
|
|
||||||
import type { WorkspaceCRUD } from '@affine/workspace/type';
|
|
||||||
import type { WorkspaceFlavour } from '@affine/workspace/type';
|
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import type { Disposable } from '@blocksuite/store';
|
import type { Disposable } from '@blocksuite/store';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import { workspaceDetailSchema, workspaceSchema } from '../affine/api';
|
||||||
|
import { WebsocketClient } from '../affine/channel';
|
||||||
|
import { storageChangeSlot } from '../affine/login';
|
||||||
|
import { rootStore, rootWorkspacesMetadataAtom } from '../atom';
|
||||||
|
import type { WorkspaceCRUD } from '../type';
|
||||||
|
import type { WorkspaceFlavour } from '../type';
|
||||||
|
|
||||||
const logger = new DebugLogger('affine-sync');
|
const logger = new DebugLogger('affine-sync');
|
||||||
|
|
||||||
const channelMessageSchema = z.object({
|
const channelMessageSchema = z.object({
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import type { createWorkspaceApis } from '@affine/workspace/affine/api';
|
|
||||||
import type { BlobStorage } from '@blocksuite/store';
|
import type { BlobStorage } from '@blocksuite/store';
|
||||||
import { createIndexeddbStorage } from '@blocksuite/store';
|
import { createIndexeddbStorage } from '@blocksuite/store';
|
||||||
import { openDB } from 'idb';
|
import { openDB } from 'idb';
|
||||||
import type { DBSchema } from 'idb/build/entry';
|
import type { DBSchema } from 'idb/build/entry';
|
||||||
|
|
||||||
|
import type { createWorkspaceApis } from '../affine/api';
|
||||||
|
|
||||||
type UploadingBlob = {
|
type UploadingBlob = {
|
||||||
key: string;
|
key: string;
|
||||||
arrayBuffer: ArrayBuffer;
|
arrayBuffer: ArrayBuffer;
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
import 'fake-indexeddb/auto';
|
import 'fake-indexeddb/auto';
|
||||||
|
|
||||||
import type { LocalWorkspace, WorkspaceCRUD } from '@affine/workspace/type';
|
|
||||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
|
||||||
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
||||||
import { Workspace } from '@blocksuite/store';
|
import { Workspace } from '@blocksuite/store';
|
||||||
import { afterEach, assertType, describe, expect, test } from 'vitest';
|
import { afterEach, assertType, describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
|
import type { LocalWorkspace, WorkspaceCRUD } from '../../type';
|
||||||
|
import { WorkspaceFlavour } from '../../type';
|
||||||
import { CRUD } from '../crud';
|
import { CRUD } from '../crud';
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import type { SQLiteProvider } from '@affine/workspace/type';
|
|
||||||
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
||||||
import type { Y as YType } from '@blocksuite/store';
|
import type { Y as YType } from '@blocksuite/store';
|
||||||
import { uuidv4, Workspace } from '@blocksuite/store';
|
import { uuidv4, Workspace } from '@blocksuite/store';
|
||||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
|
import type { SQLiteProvider } from '../../type';
|
||||||
import { createSQLiteProvider } from '../index';
|
import { createSQLiteProvider } from '../index';
|
||||||
|
|
||||||
const Y = Workspace.Y;
|
const Y = Workspace.Y;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { CallbackSet } from '@affine/workspace/utils';
|
|
||||||
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
import type { Awareness } from 'y-protocols/awareness';
|
import type { Awareness } from 'y-protocols/awareness';
|
||||||
@ -8,6 +7,7 @@ import {
|
|||||||
} from 'y-protocols/awareness';
|
} from 'y-protocols/awareness';
|
||||||
|
|
||||||
import type { BroadCastChannelProvider } from '../../type';
|
import type { BroadCastChannelProvider } from '../../type';
|
||||||
|
import { CallbackSet } from '../../utils';
|
||||||
import { localProviderLogger } from '../logger';
|
import { localProviderLogger } from '../logger';
|
||||||
import type {
|
import type {
|
||||||
AwarenessChanges,
|
AwarenessChanges,
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
||||||
/// <reference path='../../../apps/electron/layers/preload/preload.d.ts' />
|
/// <reference path='../../../apps/electron/layers/preload/preload.d.ts' />
|
||||||
import type { View } from '@affine/component/page-list';
|
import type { View } from '@affine/component/page-list';
|
||||||
import type { Workspace as RemoteWorkspace } from '@affine/workspace/affine/api';
|
|
||||||
import type { EditorContainer } from '@blocksuite/editor';
|
import type { EditorContainer } from '@blocksuite/editor';
|
||||||
import type { Page } from '@blocksuite/store';
|
import type { Page } from '@blocksuite/store';
|
||||||
import type { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
import type { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
||||||
import type { createStore } from 'jotai';
|
import type { createStore } from 'jotai';
|
||||||
import type { FC, PropsWithChildren } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
|
|
||||||
|
import type { Workspace as RemoteWorkspace } from './affine/api';
|
||||||
|
|
||||||
export type JotaiStore = ReturnType<typeof createStore>;
|
export type JotaiStore = ReturnType<typeof createStore>;
|
||||||
|
|
||||||
export const enum WorkspaceSubPath {
|
export const enum WorkspaceSubPath {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import type { createWorkspaceApis } from '@affine/workspace/affine/api';
|
|
||||||
import { rootStore, rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
|
|
||||||
import { createAffineBlobStorage } from '@affine/workspace/blob';
|
|
||||||
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
||||||
import type { Generator, StoreOptions } from '@blocksuite/store';
|
import type { Generator, StoreOptions } from '@blocksuite/store';
|
||||||
import { createIndexeddbStorage, Workspace } from '@blocksuite/store';
|
import { createIndexeddbStorage, Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
|
import type { createWorkspaceApis } from './affine/api';
|
||||||
|
import { rootStore, rootWorkspacesMetadataAtom } from './atom';
|
||||||
|
import { createAffineBlobStorage } from './blob';
|
||||||
import { createSQLiteStorage } from './blob/sqlite-blob-storage';
|
import { createSQLiteStorage } from './blob/sqlite-blob-storage';
|
||||||
import { WorkspaceFlavour } from './type';
|
import { WorkspaceFlavour } from './type';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user