refactor: merge plugin-infra into infra (#3540)

This commit is contained in:
Alex Yang
2023-08-03 01:48:59 -07:00
committed by GitHub
parent 3282344d4a
commit 0e32803247
62 changed files with 169 additions and 284 deletions

View File

@@ -24,7 +24,6 @@
"debug", "debug",
"storage", "storage",
"infra", "infra",
"plugin-infra",
"plugin-cli", "plugin-cli",
"sdk" "sdk"
] ]

View File

@@ -43,7 +43,8 @@ const allPackages = [
'packages/i18n', 'packages/i18n',
'packages/jotai', 'packages/jotai',
'packages/native', 'packages/native',
'packages/plugin-infra', 'packages/infra',
'packages/sdk',
'packages/templates', 'packages/templates',
'packages/theme', 'packages/theme',
'packages/workspace', 'packages/workspace',

1
.github/labeler.yml vendored
View File

@@ -23,7 +23,6 @@ plugin:copilot:
- 'plugins/copilot/**/*' - 'plugins/copilot/**/*'
mod:infra: mod:infra:
- 'packages/plugin-infra/**/*'
- 'packages/infra/**/*' - 'packages/infra/**/*'
mod:sdk: mod:sdk:

View File

@@ -1,8 +1,5 @@
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { import { registeredPluginAtom, rootStore } from '@toeverything/infra/atom';
registeredPluginAtom,
rootStore,
} from '@toeverything/plugin-infra/atom';
import { use } from 'foxact/use'; import { use } from 'foxact/use';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { Provider } from 'jotai/react'; import { Provider } from 'jotai/react';

View File

@@ -19,7 +19,7 @@ import {
import { getOrCreateWorkspace } from '@affine/workspace/manager'; import { getOrCreateWorkspace } from '@affine/workspace/manager';
import { createIndexedDBDownloadProvider } from '@affine/workspace/providers'; import { createIndexedDBDownloadProvider } from '@affine/workspace/providers';
import { nanoid } from '@blocksuite/store'; import { nanoid } from '@blocksuite/store';
import { useStaticBlockSuiteWorkspace } from '@toeverything/plugin-infra/__internal__/react'; import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
import { import {
BlockSuitePageList, BlockSuitePageList,

View File

@@ -1,4 +1,4 @@
import { currentPageIdAtom } from '@toeverything/plugin-infra/atom'; import { currentPageIdAtom } from '@toeverything/infra/atom';
import { atom } from 'jotai/vanilla'; import { atom } from 'jotai/vanilla';
import { pageSettingFamily } from './index'; import { pageSettingFamily } from './index';

View File

@@ -20,7 +20,7 @@ import {
} from '@affine/workspace/migration'; } from '@affine/workspace/migration';
import { createIndexedDBDownloadProvider } from '@affine/workspace/providers'; import { createIndexedDBDownloadProvider } from '@affine/workspace/providers';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { rootStore } from '@toeverything/plugin-infra/atom'; import { rootStore } from '@toeverything/infra/atom';
import { WorkspaceAdapters } from '../adapters/workspace'; import { WorkspaceAdapters } from '../adapters/workspace';

View File

@@ -7,7 +7,6 @@ import * as BlockSuiteGlobalUtils from '@blocksuite/global/utils';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { DisposableGroup } from '@blocksuite/global/utils'; import { DisposableGroup } from '@blocksuite/global/utils';
import * as Icons from '@blocksuite/icons'; import * as Icons from '@blocksuite/icons';
import * as Atom from '@toeverything/plugin-infra/atom';
import { import {
contentLayoutAtom, contentLayoutAtom,
currentPageAtom, currentPageAtom,
@@ -17,7 +16,7 @@ import {
rootStore, rootStore,
settingItemsAtom, settingItemsAtom,
windowItemsAtom, windowItemsAtom,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import * as Jotai from 'jotai/index'; import * as Jotai from 'jotai/index';
import { Provider } from 'jotai/react'; import { Provider } from 'jotai/react';
import * as JotaiUtils from 'jotai/utils'; import * as JotaiUtils from 'jotai/utils';
@@ -62,10 +61,6 @@ const setupRootImportsMap = () => {
); );
_rootImportsMap.set('jotai', new Map(Object.entries(Jotai))); _rootImportsMap.set('jotai', new Map(Object.entries(Jotai)));
_rootImportsMap.set('jotai/utils', new Map(Object.entries(JotaiUtils))); _rootImportsMap.set('jotai/utils', new Map(Object.entries(JotaiUtils)));
_rootImportsMap.set(
'@toeverything/plugin-infra/atom',
new Map(Object.entries(Atom))
);
_rootImportsMap.set( _rootImportsMap.set(
'@affine/sdk/entry', '@affine/sdk/entry',
new Map( new Map(

View File

@@ -1,8 +1,5 @@
import { DebugLogger } from '@affine/debug'; import { DebugLogger } from '@affine/debug';
import { import { registeredPluginAtom, rootStore } from '@toeverything/infra/atom';
registeredPluginAtom,
rootStore,
} from '@toeverything/plugin-infra/atom';
import { evaluatePluginEntry, setupPluginCode } from './plugins/setup'; import { evaluatePluginEntry, setupPluginCode } from './plugins/setup';

View File

@@ -9,7 +9,7 @@ import {
currentPageIdAtom, currentPageIdAtom,
currentWorkspaceIdAtom, currentWorkspaceIdAtom,
rootStore, rootStore,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import { useAtomValue } from 'jotai/react'; import { useAtomValue } from 'jotai/react';
import { Provider } from 'jotai/react'; import { Provider } from 'jotai/react';
import type { ErrorInfo, ReactElement, ReactNode } from 'react'; import type { ErrorInfo, ReactElement, ReactNode } from 'react';

View File

@@ -3,7 +3,7 @@ import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { import {
registeredPluginAtom, registeredPluginAtom,
settingItemsAtom, settingItemsAtom,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import type { FC, ReactNode } from 'react'; import type { FC, ReactNode } from 'react';
import { useRef } from 'react'; import { useRef } from 'react';

View File

@@ -8,7 +8,7 @@ import { useAFFiNEI18N } from '@affine/i18n/hooks';
import type { RootWorkspaceMetadata } from '@affine/workspace/atom'; import type { RootWorkspaceMetadata } from '@affine/workspace/atom';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom'; import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name'; import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
import { useStaticBlockSuiteWorkspace } from '@toeverything/plugin-infra/__internal__/react'; import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
import clsx from 'clsx'; import clsx from 'clsx';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import type { FC } from 'react'; import type { FC } from 'react';

View File

@@ -1,5 +1,5 @@
import { WorkspaceDetailSkeleton } from '@affine/component/setting-components'; import { WorkspaceDetailSkeleton } from '@affine/component/setting-components';
import { usePassiveWorkspaceEffect } from '@toeverything/plugin-infra/__internal__/react'; import { usePassiveWorkspaceEffect } from '@toeverything/infra/__internal__/react';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import { Suspense, useCallback } from 'react'; import { Suspense, useCallback } from 'react';

View File

@@ -14,7 +14,7 @@ import {
useBlockSuitePageMeta, useBlockSuitePageMeta,
usePageMetaHelper, usePageMetaHelper,
} from '@toeverything/hooks/use-block-suite-page-meta'; } from '@toeverything/hooks/use-block-suite-page-meta';
import { currentPageIdAtom } from '@toeverything/plugin-infra/atom'; import { currentPageIdAtom } from '@toeverything/infra/atom';
import { useAtom, useAtomValue } from 'jotai'; import { useAtom, useAtomValue } from 'jotai';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';

View File

@@ -3,7 +3,7 @@ import { WorkspaceSubPath } from '@affine/env/workspace';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta'; import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
import { currentPageIdAtom } from '@toeverything/plugin-infra/atom'; import { currentPageIdAtom } from '@toeverything/infra/atom';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';

View File

@@ -7,7 +7,7 @@ import { SidebarSwitch } from '@affine/component/app-sidebar/sidebar-header';
import { isDesktop } from '@affine/env/constant'; import { isDesktop } from '@affine/env/constant';
import { CloseIcon, MinusIcon, RoundedRectangleIcon } from '@blocksuite/icons'; import { CloseIcon, MinusIcon, RoundedRectangleIcon } from '@blocksuite/icons';
import type { Page } from '@blocksuite/store'; import type { Page } from '@blocksuite/store';
import { headerItemsAtom } from '@toeverything/plugin-infra/atom'; import { headerItemsAtom } from '@toeverything/infra/atom';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import type { FC, HTMLAttributes, PropsWithChildren, ReactNode } from 'react'; import type { FC, HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
import { import {

View File

@@ -13,7 +13,7 @@ import {
editorItemsAtom, editorItemsAtom,
rootStore, rootStore,
windowItemsAtom, windowItemsAtom,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import clsx from 'clsx'; import clsx from 'clsx';
import { useAtomValue, useSetAtom } from 'jotai'; import { useAtomValue, useSetAtom } from 'jotai';
import type { CSSProperties, FC, ReactElement } from 'react'; import type { CSSProperties, FC, ReactElement } from 'react';

View File

@@ -2,7 +2,7 @@ import { assertExists } from '@blocksuite/global/utils';
import { import {
currentPageIdAtom, currentPageIdAtom,
currentWorkspaceIdAtom, currentWorkspaceIdAtom,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import { useAtom, useSetAtom } from 'jotai'; import { useAtom, useSetAtom } from 'jotai';
import { useCallback, useEffect } from 'react'; import { useCallback, useEffect } from 'react';

View File

@@ -1,6 +1,6 @@
import type { WorkspaceRegistry } from '@affine/env/workspace'; import type { WorkspaceRegistry } from '@affine/env/workspace';
import type { WorkspaceFlavour } from '@affine/env/workspace'; import type { WorkspaceFlavour } from '@affine/env/workspace';
import { currentPageIdAtom } from '@toeverything/plugin-infra/atom'; import { currentPageIdAtom } from '@toeverything/infra/atom';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import { useCallback } from 'react'; import { useCallback } from 'react';

View File

@@ -2,7 +2,7 @@ import type { WorkspaceSubPath } from '@affine/env/workspace';
import { import {
currentPageIdAtom, currentPageIdAtom,
currentWorkspaceIdAtom, currentWorkspaceIdAtom,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import { useCallback } from 'react'; import { useCallback } from 'react';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports // eslint-disable-next-line @typescript-eslint/no-restricted-imports

View File

@@ -1,7 +1,7 @@
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom'; import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import type { Workspace } from '@blocksuite/store'; import type { Workspace } from '@blocksuite/store';
import { useStaticBlockSuiteWorkspace } from '@toeverything/plugin-infra/__internal__/react'; import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
import type { Atom } from 'jotai'; import type { Atom } from 'jotai';
import { atom, useAtomValue } from 'jotai'; import { atom, useAtomValue } from 'jotai';

View File

@@ -7,7 +7,7 @@ import { saveWorkspaceToLocalStorage } from '@affine/workspace/local/crud';
import { getOrCreateWorkspace } from '@affine/workspace/manager'; import { getOrCreateWorkspace } from '@affine/workspace/manager';
import { assertEquals } from '@blocksuite/global/utils'; import { assertEquals } from '@blocksuite/global/utils';
import { nanoid } from '@blocksuite/store'; import { nanoid } from '@blocksuite/store';
import { getWorkspace } from '@toeverything/plugin-infra/__internal__/workspace'; import { getWorkspace } from '@toeverything/infra/__internal__/workspace';
import { useAtomValue, useSetAtom } from 'jotai'; import { useAtomValue, useSetAtom } from 'jotai';
import { useCallback } from 'react'; import { useCallback } from 'react';

View File

@@ -26,8 +26,8 @@ import {
useSensor, useSensor,
useSensors, useSensors,
} from '@dnd-kit/core'; } from '@dnd-kit/core';
import { usePassiveWorkspaceEffect } from '@toeverything/plugin-infra/__internal__/react'; import { usePassiveWorkspaceEffect } from '@toeverything/infra/__internal__/react';
import { currentWorkspaceIdAtom } from '@toeverything/plugin-infra/atom'; import { currentWorkspaceIdAtom } from '@toeverything/infra/atom';
import { useAtom, useAtomValue, useSetAtom } from 'jotai'; import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import type { FC, PropsWithChildren, ReactElement } from 'react'; import type { FC, PropsWithChildren, ReactElement } from 'react';
import { lazy, Suspense, useCallback, useMemo } from 'react'; import { lazy, Suspense, useCallback, useMemo } from 'react';

View File

@@ -1,7 +1,7 @@
import { DebugLogger } from '@affine/debug'; import { DebugLogger } from '@affine/debug';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom'; import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { getWorkspace } from '@toeverything/plugin-infra/__internal__/workspace'; import { getWorkspace } from '@toeverything/infra/__internal__/workspace';
import { rootStore } from '@toeverything/plugin-infra/atom'; import { rootStore } from '@toeverything/infra/atom';
import { lazy } from 'react'; import { lazy } from 'react';
import type { LoaderFunction } from 'react-router-dom'; import type { LoaderFunction } from 'react-router-dom';
import { redirect } from 'react-router-dom'; import { redirect } from 'react-router-dom';

View File

@@ -2,8 +2,8 @@ import { useCollectionManager } from '@affine/component/page-list';
import { DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX } from '@affine/env/constant'; import { DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX } from '@affine/env/constant';
import { WorkspaceSubPath } from '@affine/env/workspace'; import { WorkspaceSubPath } from '@affine/env/workspace';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { getActiveBlockSuiteWorkspaceAtom } from '@toeverything/plugin-infra/__internal__/workspace'; import { getActiveBlockSuiteWorkspaceAtom } from '@toeverything/infra/__internal__/workspace';
import { currentPageIdAtom, rootStore } from '@toeverything/plugin-infra/atom'; import { currentPageIdAtom, rootStore } from '@toeverything/infra/atom';
import { useAtom } from 'jotai/react'; import { useAtom } from 'jotai/react';
import { useCallback, useEffect } from 'react'; import { useCallback, useEffect } from 'react';
import type { LoaderFunction } from 'react-router-dom'; import type { LoaderFunction } from 'react-router-dom';

View File

@@ -7,7 +7,7 @@ import { WorkspaceSubPath } from '@affine/env/workspace';
import type { EditorContainer } from '@blocksuite/editor'; import type { EditorContainer } from '@blocksuite/editor';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import type { Page } from '@blocksuite/store'; import type { Page } from '@blocksuite/store';
import { currentPageIdAtom, rootStore } from '@toeverything/plugin-infra/atom'; import { currentPageIdAtom, rootStore } from '@toeverything/infra/atom';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { useAtom } from 'jotai/react'; import { useAtom } from 'jotai/react';
import { type ReactElement, useCallback, useEffect } from 'react'; import { type ReactElement, useCallback, useEffect } from 'react';

View File

@@ -1,8 +1,5 @@
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom'; import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { import { currentWorkspaceIdAtom, rootStore } from '@toeverything/infra/atom';
currentWorkspaceIdAtom,
rootStore,
} from '@toeverything/plugin-infra/atom';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import { type LoaderFunction, Outlet, redirect } from 'react-router-dom'; import { type LoaderFunction, Outlet, redirect } from 'react-router-dom';

View File

@@ -5,7 +5,7 @@ import { arrayMove } from '@dnd-kit/sortable';
import { import {
currentPageIdAtom, currentPageIdAtom,
currentWorkspaceIdAtom, currentWorkspaceIdAtom,
} from '@toeverything/plugin-infra/atom'; } from '@toeverything/infra/atom';
import { useAtom, useAtomValue, useSetAtom } from 'jotai'; import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import type { FC, ReactElement } from 'react'; import type { FC, ReactElement } from 'react';
import { lazy, Suspense, useCallback, useTransition } from 'react'; import { lazy, Suspense, useCallback, useTransition } from 'react';

View File

@@ -121,17 +121,14 @@ module.exports = {
const { rm, cp } = require('node:fs/promises'); const { rm, cp } = require('node:fs/promises');
const { resolve } = require('node:path'); const { resolve } = require('node:path');
await rm( await rm(resolve(__dirname, './node_modules/@toeverything/infra'), {
resolve(__dirname, './node_modules/@toeverything/plugin-infra'), recursive: true,
{ force: true,
recursive: true, });
force: true,
}
);
await cp( await cp(
resolve(__dirname, '../../packages/plugin-infra'), resolve(__dirname, '../../packages/infra'),
resolve(__dirname, './node_modules/@toeverything/plugin-infra'), resolve(__dirname, './node_modules/@toeverything/infra'),
{ {
recursive: true, recursive: true,
force: true, force: true,

View File

@@ -41,7 +41,6 @@
"@electron-forge/shared-types": "^6.2.1", "@electron-forge/shared-types": "^6.2.1",
"@electron/remote": "2.0.10", "@electron/remote": "2.0.10",
"@reforged/maker-appimage": "^3.3.1", "@reforged/maker-appimage": "^3.3.1",
"@toeverything/infra": "workspace:*",
"@types/fs-extra": "^11.0.1", "@types/fs-extra": "^11.0.1",
"@types/uuid": "^9.0.2", "@types/uuid": "^9.0.2",
"cross-env": "7.0.3", "cross-env": "7.0.3",
@@ -60,7 +59,7 @@
"zx": "^7.2.3" "zx": "^7.2.3"
}, },
"dependencies": { "dependencies": {
"@toeverything/plugin-infra": "workspace:*", "@toeverything/infra": "workspace:*",
"async-call-rpc": "^6.3.1", "async-call-rpc": "^6.3.1",
"electron-updater": "^6.0.0", "electron-updater": "^6.0.0",
"link-preview-js": "^3.0.4", "link-preview-js": "^3.0.4",

View File

@@ -17,7 +17,7 @@
"exclude": ["node_modules", "out", "dist", "**/__tests__/**/*"], "exclude": ["node_modules", "out", "dist", "**/__tests__/**/*"],
"references": [ "references": [
{ {
"path": "../../packages/plugin-infra" "path": "../../packages/infra"
}, },
{ {
"path": "../../packages/native" "path": "../../packages/native"

View File

@@ -38,6 +38,8 @@
"{workspaceRoot}/apps/core/public/plugins" "{workspaceRoot}/apps/core/public/plugins"
], ],
"inputs": [ "inputs": [
"{workspaceRoot}/infra/**/*",
"{workspaceRoot}/sdk/**/*",
{ {
"runtime": "node -v" "runtime": "node -v"
}, },

View File

@@ -24,7 +24,7 @@
"build": "yarn nx build @affine/core", "build": "yarn nx build @affine/core",
"build:electron": "yarn nx build @affine/electron", "build:electron": "yarn nx build @affine/electron",
"build:storage": "yarn nx run-many -t build -p @affine/storage", "build:storage": "yarn nx run-many -t build -p @affine/storage",
"build:infra": "yarn nx run-many -t build -p plugin-infra infra sdk", "build:infra": "yarn nx run-many -t build -p infra sdk",
"build:plugins": "yarn nx run-many -t build --projects=tag:plugin", "build:plugins": "yarn nx run-many -t build --projects=tag:plugin",
"build:storybook": "yarn nx build @affine/storybook", "build:storybook": "yarn nx build @affine/storybook",
"start:web-static": "yarn workspace @affine/core static-server", "start:web-static": "yarn workspace @affine/core static-server",
@@ -70,7 +70,6 @@
"@taplo/cli": "^0.5.2", "@taplo/cli": "^0.5.2",
"@testing-library/react": "^14.0.0", "@testing-library/react": "^14.0.0",
"@toeverything/infra": "workspace:*", "@toeverything/infra": "workspace:*",
"@toeverything/plugin-infra": "workspace:*",
"@types/eslint": "^8.44.1", "@types/eslint": "^8.44.1",
"@types/node": "^18.17.1", "@types/node": "^18.17.1",
"@typescript-eslint/eslint-plugin": "^6.2.0", "@typescript-eslint/eslint-plugin": "^6.2.0",

View File

@@ -9,7 +9,7 @@
"include": ["src"], "include": ["src"],
"references": [ "references": [
{ {
"path": "../plugin-infra" "path": "../infra"
} }
] ]
} }

View File

@@ -36,7 +36,6 @@
"@radix-ui/react-scroll-area": "^1.0.4", "@radix-ui/react-scroll-area": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4", "@radix-ui/react-toast": "^1.1.4",
"@toeverything/hooks": "workspace:*", "@toeverything/hooks": "workspace:*",
"@toeverything/plugin-infra": "workspace:*",
"@toeverything/theme": "^0.7.9", "@toeverything/theme": "^0.7.9",
"@vanilla-extract/dynamic": "^2.0.3", "@vanilla-extract/dynamic": "^2.0.3",
"clsx": "^2.0.0", "clsx": "^2.0.0",

View File

@@ -9,7 +9,7 @@ import {
LocalWorkspaceIcon as DefaultLocalWorkspaceIcon, LocalWorkspaceIcon as DefaultLocalWorkspaceIcon,
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name'; import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
import { useStaticBlockSuiteWorkspace } from '@toeverything/plugin-infra/__internal__/react'; import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
import type { FC } from 'react'; import type { FC } from 'react';
import { useCallback } from 'react'; import { useCallback } from 'react';

View File

@@ -1,6 +1,6 @@
import { ProviderComposer } from '@affine/component/provider-composer'; import { ProviderComposer } from '@affine/component/provider-composer';
import { ThemeProvider } from '@affine/component/theme-provider'; import { ThemeProvider } from '@affine/component/theme-provider';
import { rootStore } from '@toeverything/plugin-infra/atom'; import { rootStore } from '@toeverything/infra/atom';
import { Provider } from 'jotai'; import { Provider } from 'jotai';
import type { PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import { useMemo } from 'react'; import { useMemo } from 'react';

View File

@@ -22,7 +22,7 @@
"path": "../hooks" "path": "../hooks"
}, },
{ {
"path": "../plugin-infra" "path": "../infra"
}, },
{ "path": "../workspace" }, { "path": "../workspace" },
{ "path": "../../tests/fixtures" } { "path": "../../tests/fixtures" }

View File

@@ -19,6 +19,26 @@
"types": "./dist/src/preload/*.d.ts", "types": "./dist/src/preload/*.d.ts",
"import": "./dist/preload/*.js", "import": "./dist/preload/*.js",
"require": "./dist/preload/*.cjs" "require": "./dist/preload/*.cjs"
},
"./atom": {
"type": "./dist/src/atom.d.ts",
"import": "./dist/atom.js",
"require": "./dist/atom.cjs"
},
"./type": {
"type": "./dist/src/type.d.ts",
"import": "./dist/type.js",
"require": "./dist/type.cjs"
},
"./__internal__/workspace": {
"type": "./dist/src/__internal__/workspace.d.ts",
"import": "./dist/__internal__/workspace.js",
"require": "./dist/__internal__/workspace.cjs"
},
"./__internal__/react": {
"type": "./dist/src/__internal__/react.d.ts",
"import": "./dist/__internal__/react.js",
"require": "./dist/__internal__/react.cjs"
} }
}, },
"files": [ "files": [
@@ -28,22 +48,43 @@
"build": "vite build", "build": "vite build",
"dev": "vite build --watch" "dev": "vite build --watch"
}, },
"dependencies": {
"@affine/sdk": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/global": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/store": "0.0.0-20230802200139-381599c0-nightly",
"jotai": "^2.2.2",
"zod": "^3.21.4"
},
"devDependencies": { "devDependencies": {
"@blocksuite/editor": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/lit": "0.0.0-20230802200139-381599c0-nightly",
"async-call-rpc": "^6.3.1", "async-call-rpc": "^6.3.1",
"electron": "link:../../apps/electron/node_modules/electron", "electron": "link:../../apps/electron/node_modules/electron",
"react": "^18.2.0",
"vite": "^4.4.7", "vite": "^4.4.7",
"vite-plugin-dts": "3.3.1" "vite-plugin-dts": "3.3.1"
}, },
"peerDependencies": { "peerDependencies": {
"async-call-rpc": "*", "async-call-rpc": "*",
"electron": "*" "electron": "*",
"react": "*"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@blocksuite/editor": {
"optional": true
},
"@blocksuite/lit": {
"optional": true
},
"async-call-rpc": { "async-call-rpc": {
"optional": true "optional": true
}, },
"electron": { "electron": {
"optional": true "optional": true
},
"react": {
"optional": true
} }
}, },
"version": "0.8.0-canary.8" "version": "0.8.0-canary.8"

View File

@@ -1,5 +1,45 @@
import type { ExpectedLayout } from '@affine/sdk/entry';
import type { WritableAtom } from 'jotai';
import { z } from 'zod';
import type { TypedEventEmitter } from './core/event-emitter.js'; import type { TypedEventEmitter } from './core/event-emitter.js';
export const packageJsonInputSchema = z.object({
name: z.string(),
version: z.string(),
description: z.string(),
affinePlugin: z.object({
release: z.boolean(),
entry: z.object({
core: z.string(),
server: z.string().optional(),
}),
serverCommand: z.array(z.string()).optional(),
}),
});
export const packageJsonOutputSchema = z.object({
name: z.string(),
version: z.string(),
description: z.string(),
affinePlugin: z.object({
release: z.boolean(),
entry: z.object({
core: z.string(),
}),
assets: z.array(z.string()),
serverCommand: z.array(z.string()).optional(),
}),
});
type SetStateAction<Value> = Value | ((prev: Value) => Value);
export type ContentLayoutAtom = WritableAtom<
ExpectedLayout,
[SetStateAction<ExpectedLayout>],
void
>;
export abstract class HandlerManager< export abstract class HandlerManager<
Namespace extends string, Namespace extends string,
Handlers extends Record<string, PrimitiveHandlers>, Handlers extends Record<string, PrimitiveHandlers>,

View File

@@ -12,14 +12,29 @@ export default defineConfig({
lib: { lib: {
entry: { entry: {
index: resolve(root, 'src/index.ts'), index: resolve(root, 'src/index.ts'),
atom: resolve(root, 'src/atom.ts'),
type: resolve(root, 'src/type.ts'),
'core/event-emitter': resolve(root, 'src/core/event-emitter.ts'), 'core/event-emitter': resolve(root, 'src/core/event-emitter.ts'),
'preload/electron': resolve(root, 'src/preload/electron.ts'), 'preload/electron': resolve(root, 'src/preload/electron.ts'),
'__internal__/workspace': resolve(
root,
'src/__internal__/workspace.ts'
),
'__internal__/react': resolve(root, 'src/__internal__/react.ts'),
}, },
formats: ['es', 'cjs'], formats: ['es', 'cjs'],
name: 'AffineInfra', name: 'AffineInfra',
}, },
rollupOptions: { rollupOptions: {
external: ['electron', 'async-call-rpc', 'rxjs'], external: [
'electron',
'async-call-rpc',
'rxjs',
'zod',
'react',
/^jotai/,
/^@blocksuite/,
],
}, },
}, },
plugins: [dts()], plugins: [dts()],

View File

@@ -12,7 +12,7 @@
"dependencies": { "dependencies": {
"@endo/static-module-record": "^0.7.20", "@endo/static-module-record": "^0.7.20",
"@swc/core": "^1.3.72", "@swc/core": "^1.3.72",
"@toeverything/plugin-infra": "workspace:^", "@toeverything/infra": "workspace:^",
"@vanilla-extract/rollup-plugin": "^1.2.2", "@vanilla-extract/rollup-plugin": "^1.2.2",
"rollup": "^3.27.0", "rollup": "^3.27.0",
"rollup-plugin-swc3": "^0.9.1", "rollup-plugin-swc3": "^0.9.1",

View File

@@ -8,7 +8,7 @@ import { StaticModuleRecord } from '@endo/static-module-record';
import { import {
packageJsonInputSchema, packageJsonInputSchema,
packageJsonOutputSchema, packageJsonOutputSchema,
} from '@toeverything/plugin-infra/type'; } from '@toeverything/infra/type';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import react from '@vitejs/plugin-react-swc'; import react from '@vitejs/plugin-react-swc';
import { build, type PluginOption } from 'vite'; import { build, type PluginOption } from 'vite';

View File

@@ -9,7 +9,7 @@
"include": ["src"], "include": ["src"],
"references": [ "references": [
{ {
"path": "../plugin-infra" "path": "../infra"
} }
] ]
} }

View File

@@ -1,60 +0,0 @@
{
"name": "@toeverything/plugin-infra",
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite build --watch"
},
"files": [
"dist"
],
"exports": {
"./entry": {
"type": "./dist/src/entry.d.ts",
"import": "./dist/entry.js",
"require": "./dist/entry.cjs"
},
"./atom": {
"type": "./dist/src/atom.d.ts",
"import": "./dist/atom.js",
"require": "./dist/atom.cjs"
},
"./type": {
"type": "./dist/src/type.d.ts",
"import": "./dist/type.js",
"require": "./dist/type.cjs"
},
"./__internal__/workspace": {
"type": "./dist/src/__internal__/workspace.d.ts",
"import": "./dist/__internal__/workspace.js",
"require": "./dist/__internal__/workspace.cjs"
},
"./__internal__/react": {
"type": "./dist/src/__internal__/react.d.ts",
"import": "./dist/__internal__/react.js",
"require": "./dist/__internal__/react.cjs"
}
},
"dependencies": {
"@affine/sdk": "workspace:*",
"@blocksuite/global": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/store": "0.0.0-20230802200139-381599c0-nightly",
"jotai": "^2.2.2",
"zod": "^3.21.4"
},
"devDependencies": {
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/editor": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/lit": "0.0.0-20230802200139-381599c0-nightly",
"vite": "^4.4.7",
"vite-plugin-dts": "3.3.1"
},
"peerDependencies": {
"@blocksuite/blocks": "*",
"@blocksuite/editor": "*",
"@blocksuite/lit": "*",
"react": "*",
"react-dom": "*"
},
"version": "0.8.0-canary.8"
}

View File

@@ -1,21 +0,0 @@
{
"name": "plugin-infra",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "packages/plugin-infra/src",
"targets": {
"build": {
"executor": "@nx/vite:build",
"options": {
"outputPath": "packages/plugin-infra/dist"
}
},
"serve": {
"executor": "@nx/vite:build",
"options": {
"outputPath": "packages/plugin-infra/dist",
"watch": true
}
}
}
}

View File

@@ -1,39 +0,0 @@
import type { ExpectedLayout } from '@affine/sdk/entry';
import type { WritableAtom } from 'jotai';
import { z } from 'zod';
export const packageJsonInputSchema = z.object({
name: z.string(),
version: z.string(),
description: z.string(),
affinePlugin: z.object({
release: z.boolean(),
entry: z.object({
core: z.string(),
server: z.string().optional(),
}),
serverCommand: z.array(z.string()).optional(),
}),
});
export const packageJsonOutputSchema = z.object({
name: z.string(),
version: z.string(),
description: z.string(),
affinePlugin: z.object({
release: z.boolean(),
entry: z.object({
core: z.string(),
}),
assets: z.array(z.string()),
serverCommand: z.array(z.string()).optional(),
}),
});
type SetStateAction<Value> = Value | ((prev: Value) => Value);
export type ContentLayoutAtom = WritableAtom<
ExpectedLayout,
[SetStateAction<ExpectedLayout>],
void
>;

View File

@@ -1,15 +0,0 @@
{
"extends": "../../tsconfig.json",
"include": ["./src"],
"compilerOptions": {
"composite": true,
"noEmit": false,
"outDir": "lib",
"moduleResolution": "node16"
},
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

View File

@@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"outDir": "lib"
},
"include": ["vite.config.ts"]
}

View File

@@ -1,28 +0,0 @@
import { resolve } from 'node:path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
const root = fileURLToPath(new URL('.', import.meta.url));
export default defineConfig({
build: {
minify: false,
lib: {
entry: {
type: resolve(root, 'src/type.ts'),
atom: resolve(root, 'src/atom.ts'),
'__internal__/workspace': resolve(
root,
'src/__internal__/workspace.ts'
),
'__internal__/react': resolve(root, 'src/__internal__/react.ts'),
},
},
rollupOptions: {
external: ['react', /^jotai/, /^@blocksuite/, 'zod'],
},
},
plugins: [dts()],
});

View File

@@ -18,7 +18,6 @@
"@affine/debug": "workspace:*", "@affine/debug": "workspace:*",
"@affine/env": "workspace:*", "@affine/env": "workspace:*",
"@toeverything/hooks": "workspace:*", "@toeverything/hooks": "workspace:*",
"@toeverything/plugin-infra": "workspace:*",
"@toeverything/y-indexeddb": "workspace:*", "@toeverything/y-indexeddb": "workspace:*",
"async-call-rpc": "^6.3.1", "async-call-rpc": "^6.3.1",
"jotai": "^2.2.2", "jotai": "^2.2.2",

View File

@@ -8,7 +8,7 @@ import {
Generator, Generator,
Workspace, Workspace,
} from '@blocksuite/store'; } from '@blocksuite/store';
import { INTERNAL_BLOCKSUITE_HASH_MAP } from '@toeverything/plugin-infra/__internal__/workspace'; import { INTERNAL_BLOCKSUITE_HASH_MAP } from '@toeverything/infra/__internal__/workspace';
import type { Doc } from 'yjs'; import type { Doc } from 'yjs';
import type { Transaction } from 'yjs'; import type { Transaction } from 'yjs';

View File

@@ -11,6 +11,6 @@
{ "path": "../env" }, { "path": "../env" },
{ "path": "../debug" }, { "path": "../debug" },
{ "path": "../hooks" }, { "path": "../hooks" },
{ "path": "../plugin-infra" } { "path": "../infra" }
] ]
} }

View File

@@ -1,5 +1,5 @@
import { IconButton, Tooltip } from '@affine/component'; import { IconButton, Tooltip } from '@affine/component';
import { contentLayoutAtom } from '@toeverything/plugin-infra/atom'; import { contentLayoutAtom } from '@affine/sdk/entry';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import { useCallback } from 'react'; import { useCallback } from 'react';

View File

@@ -17,8 +17,7 @@
"dependencies": { "dependencies": {
"@affine/component": "workspace:*", "@affine/component": "workspace:*",
"@affine/sdk": "workspace:*", "@affine/sdk": "workspace:*",
"@blocksuite/icons": "^2.1.29", "@blocksuite/icons": "^2.1.29"
"@toeverything/plugin-infra": "workspace:*"
}, },
"devDependencies": { "devDependencies": {
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"

View File

@@ -3,7 +3,6 @@
packages=( packages=(
"y-indexeddb" "y-indexeddb"
"infra" "infra"
"plugin-infra"
"sdk" "sdk"
) )

View File

@@ -76,7 +76,6 @@
"@toeverything/y-indexeddb": ["./packages/y-indexeddb/src"], "@toeverything/y-indexeddb": ["./packages/y-indexeddb/src"],
"@toeverything/hooks/*": ["./packages/hooks/src/*"], "@toeverything/hooks/*": ["./packages/hooks/src/*"],
"@toeverything/infra/*": ["./packages/infra/src/*"], "@toeverything/infra/*": ["./packages/infra/src/*"],
"@toeverything/plugin-infra/*": ["./packages/plugin-infra/src/*"],
"@affine/sdk/*": ["./packages/sdk/src/*"], "@affine/sdk/*": ["./packages/sdk/src/*"],
"@affine/native": ["./packages/native/index.d.ts"], "@affine/native": ["./packages/native/index.d.ts"],
"@affine/native/*": ["./packages/native/*"], "@affine/native/*": ["./packages/native/*"],
@@ -105,9 +104,6 @@
{ {
"path": "./packages/infra" "path": "./packages/infra"
}, },
{
"path": "./packages/plugin-infra"
},
{ {
"path": "./packages/graphql" "path": "./packages/graphql"
}, },

View File

@@ -148,7 +148,6 @@ __metadata:
"@radix-ui/react-scroll-area": ^1.0.4 "@radix-ui/react-scroll-area": ^1.0.4
"@radix-ui/react-toast": ^1.1.4 "@radix-ui/react-toast": ^1.1.4
"@toeverything/hooks": "workspace:*" "@toeverything/hooks": "workspace:*"
"@toeverything/plugin-infra": "workspace:*"
"@toeverything/theme": ^0.7.9 "@toeverything/theme": ^0.7.9
"@types/react": ^18.2.17 "@types/react": ^18.2.17
"@types/react-datepicker": ^4.15.0 "@types/react-datepicker": ^4.15.0
@@ -336,7 +335,6 @@ __metadata:
"@electron/remote": 2.0.10 "@electron/remote": 2.0.10
"@reforged/maker-appimage": ^3.3.1 "@reforged/maker-appimage": ^3.3.1
"@toeverything/infra": "workspace:*" "@toeverything/infra": "workspace:*"
"@toeverything/plugin-infra": "workspace:*"
"@types/fs-extra": ^11.0.1 "@types/fs-extra": ^11.0.1
"@types/uuid": ^9.0.2 "@types/uuid": ^9.0.2
async-call-rpc: ^6.3.1 async-call-rpc: ^6.3.1
@@ -404,7 +402,6 @@ __metadata:
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"
"@affine/sdk": "workspace:*" "@affine/sdk": "workspace:*"
"@blocksuite/icons": ^2.1.29 "@blocksuite/icons": ^2.1.29
"@toeverything/plugin-infra": "workspace:*"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -491,7 +488,6 @@ __metadata:
"@taplo/cli": ^0.5.2 "@taplo/cli": ^0.5.2
"@testing-library/react": ^14.0.0 "@testing-library/react": ^14.0.0
"@toeverything/infra": "workspace:*" "@toeverything/infra": "workspace:*"
"@toeverything/plugin-infra": "workspace:*"
"@types/eslint": ^8.44.1 "@types/eslint": ^8.44.1
"@types/node": ^18.17.1 "@types/node": ^18.17.1
"@typescript-eslint/eslint-plugin": ^6.2.0 "@typescript-eslint/eslint-plugin": ^6.2.0
@@ -557,7 +553,7 @@ __metadata:
dependencies: dependencies:
"@endo/static-module-record": ^0.7.20 "@endo/static-module-record": ^0.7.20
"@swc/core": ^1.3.72 "@swc/core": ^1.3.72
"@toeverything/plugin-infra": "workspace:^" "@toeverything/infra": "workspace:^"
"@vanilla-extract/rollup-plugin": ^1.2.2 "@vanilla-extract/rollup-plugin": ^1.2.2
rollup: ^3.27.0 rollup: ^3.27.0
rollup-plugin-swc3: ^0.9.1 rollup-plugin-swc3: ^0.9.1
@@ -706,7 +702,6 @@ __metadata:
"@affine/debug": "workspace:*" "@affine/debug": "workspace:*"
"@affine/env": "workspace:*" "@affine/env": "workspace:*"
"@toeverything/hooks": "workspace:*" "@toeverything/hooks": "workspace:*"
"@toeverything/plugin-infra": "workspace:*"
"@toeverything/y-indexeddb": "workspace:*" "@toeverything/y-indexeddb": "workspace:*"
"@types/ws": ^8.5.5 "@types/ws": ^8.5.5
async-call-rpc: ^6.3.1 async-call-rpc: ^6.3.1
@@ -11389,28 +11384,9 @@ __metadata:
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"@toeverything/infra@workspace:*, @toeverything/infra@workspace:packages/infra": "@toeverything/infra@workspace:*, @toeverything/infra@workspace:^, @toeverything/infra@workspace:packages/infra":
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "@toeverything/infra@workspace:packages/infra" resolution: "@toeverything/infra@workspace:packages/infra"
dependencies:
async-call-rpc: ^6.3.1
electron: "link:../../apps/electron/node_modules/electron"
vite: ^4.4.7
vite-plugin-dts: 3.3.1
peerDependencies:
async-call-rpc: "*"
electron: "*"
peerDependenciesMeta:
async-call-rpc:
optional: true
electron:
optional: true
languageName: unknown
linkType: soft
"@toeverything/plugin-infra@workspace:*, @toeverything/plugin-infra@workspace:^, @toeverything/plugin-infra@workspace:packages/plugin-infra":
version: 0.0.0-use.local
resolution: "@toeverything/plugin-infra@workspace:packages/plugin-infra"
dependencies: dependencies:
"@affine/sdk": "workspace:*" "@affine/sdk": "workspace:*"
"@blocksuite/blocks": 0.0.0-20230802200139-381599c0-nightly "@blocksuite/blocks": 0.0.0-20230802200139-381599c0-nightly
@@ -11418,16 +11394,28 @@ __metadata:
"@blocksuite/global": 0.0.0-20230802200139-381599c0-nightly "@blocksuite/global": 0.0.0-20230802200139-381599c0-nightly
"@blocksuite/lit": 0.0.0-20230802200139-381599c0-nightly "@blocksuite/lit": 0.0.0-20230802200139-381599c0-nightly
"@blocksuite/store": 0.0.0-20230802200139-381599c0-nightly "@blocksuite/store": 0.0.0-20230802200139-381599c0-nightly
async-call-rpc: ^6.3.1
electron: "link:../../apps/electron/node_modules/electron"
jotai: ^2.2.2 jotai: ^2.2.2
react: ^18.2.0
vite: ^4.4.7 vite: ^4.4.7
vite-plugin-dts: 3.3.1 vite-plugin-dts: 3.3.1
zod: ^3.21.4 zod: ^3.21.4
peerDependencies: peerDependencies:
"@blocksuite/blocks": "*" async-call-rpc: "*"
"@blocksuite/editor": "*" electron: "*"
"@blocksuite/lit": "*"
react: "*" react: "*"
react-dom: "*" peerDependenciesMeta:
"@blocksuite/editor":
optional: true
"@blocksuite/lit":
optional: true
async-call-rpc:
optional: true
electron:
optional: true
react:
optional: true
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -27687,7 +27675,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"react@npm:18.2.0": "react@npm:18.2.0, react@npm:^18.2.0":
version: 18.2.0 version: 18.2.0
resolution: "react@npm:18.2.0" resolution: "react@npm:18.2.0"
dependencies: dependencies: